|
|
|
@@ -0,0 +1,242 @@ |
|
|
|
package com.iformall.controller.market; |
|
|
|
|
|
|
|
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.annotation.SystemControllerLog; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.ResultData; |
|
|
|
import com.iformall.controller.base.BaseController; |
|
|
|
import com.iformall.domain.po.*; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.domain.vo.WxCardSpendVo; |
|
|
|
import com.iformall.domain.vo.WxCardVo; |
|
|
|
import com.iformall.enums.EnumMerchantSubsidySource; |
|
|
|
import com.iformall.enums.EnumMerchantSubsidyType; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.service.WxCardInfoService; |
|
|
|
import com.iformall.service.WxCardSpendService; |
|
|
|
import com.iformall.service.WxMerchantService; |
|
|
|
import com.iformall.service.WxOrderService; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiImplicitParam; |
|
|
|
import io.swagger.annotations.ApiImplicitParams; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author Stormeye Wu wuguoqiang@iformall.com |
|
|
|
*/ |
|
|
|
@RestController |
|
|
|
@RequestMapping("cardInfo") |
|
|
|
@Api(description = "储值卡") |
|
|
|
public class WxCardInfoController extends BaseController { |
|
|
|
private final Logger logger = LoggerFactory.getLogger(this.getClass()); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxMerchantService wxMerchantService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxOrderService wxOrderService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxCardInfoService wxCardInfoService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxCardSpendService wxCardSpendService; |
|
|
|
|
|
|
|
@ApiOperation("批次消费卡的卡列表") |
|
|
|
@GetMapping("list") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), |
|
|
|
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) |
|
|
|
@SystemControllerLog(description = "储值卡支付-售卡记录列表") |
|
|
|
public ResultData cardOrderList(@ModelAttribute WxCardVo wxCardVo, Integer pageNum, Integer pageSize) { |
|
|
|
String ipStr = getIpAddr(); |
|
|
|
if (wxCardVo == null) {wxCardVo = new WxCardVo();} |
|
|
|
else { |
|
|
|
if(StringUtils.isBlank(wxCardVo.getOuPhone())) { |
|
|
|
wxCardVo.setOuPhone(null); |
|
|
|
} |
|
|
|
} |
|
|
|
wxCardVo.updateTenantInfo(getTenantInfo()); |
|
|
|
if(StringUtils.isNotBlank(wxCardVo.getStatusStr())) { |
|
|
|
String [] statusAttr = wxCardVo.getStatusStr().split(","); |
|
|
|
List<Integer> tmpList = new ArrayList<Integer>(); |
|
|
|
for(String status: statusAttr) { |
|
|
|
tmpList.add(Integer.valueOf(status)); |
|
|
|
} |
|
|
|
if(!tmpList.isEmpty()) { |
|
|
|
wxCardVo.setStatusS(tmpList); |
|
|
|
} |
|
|
|
} |
|
|
|
final PageInfo<WxCardVo> page = wxCardInfoService.listAsPage(wxCardVo, pageNum, pageSize); |
|
|
|
return new ResultData(page); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("C端扫B端储值卡交易流水(消费记录 + 补贴)列表接口") |
|
|
|
@GetMapping("cardSpendlist") |
|
|
|
@ApiImplicitParams({ |
|
|
|
@ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), |
|
|
|
@ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) |
|
|
|
@SystemControllerLog(description = "储值卡支付-储值卡交易流水") |
|
|
|
public ResultData cardSpendlist(@ModelAttribute WxCardSpendVo wxCardSpendVo, Integer pageNum, Integer pageSize) { |
|
|
|
String ipStr = getIpAddr(); |
|
|
|
logger.info("cardPay/cardSpendlist: " + ipStr); |
|
|
|
if (wxCardSpendVo == null) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); |
|
|
|
} |
|
|
|
wxCardSpendVo.updateTenantInfo(getTenantInfo()); |
|
|
|
if(StringUtils.isNotBlank(wxCardSpendVo.getPayStatusStr())) { |
|
|
|
String [] statusAttr = wxCardSpendVo.getPayStatusStr().split(","); |
|
|
|
List<Integer> tmpList = new ArrayList<Integer>(); |
|
|
|
for(String status: statusAttr) { |
|
|
|
tmpList.add(Integer.valueOf(status)); |
|
|
|
} |
|
|
|
if(!tmpList.isEmpty()) { |
|
|
|
wxCardSpendVo.setPayStatusS(tmpList); |
|
|
|
} |
|
|
|
} |
|
|
|
List<Integer> sources = new ArrayList<Integer>(); |
|
|
|
sources.add(EnumMerchantSubsidySource.CARD.getCode()); |
|
|
|
wxCardSpendVo.setSources(sources); |
|
|
|
wxCardSpendVo.setCardSpendListShow(1); |
|
|
|
final PageInfo<WxCardSpendVo> page = wxCardSpendService.listAsPage(wxCardSpendVo, pageNum, pageSize); |
|
|
|
return new ResultData(page); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("C端扫B端储值卡交易流水SUM") |
|
|
|
@GetMapping("sum") |
|
|
|
@SystemControllerLog(description = "储值卡支付-储值卡交易流水SUM") |
|
|
|
public ResultData sumCardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend) { |
|
|
|
String ipStr = getIpAddr(); |
|
|
|
logger.info("cardPay/sumCardSpendList: " + ipStr + " :" + wxCardSpend.toString()); |
|
|
|
if (wxCardSpend == null) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); |
|
|
|
} |
|
|
|
wxCardSpend.updateTenantInfo(getTenantInfo()); |
|
|
|
List<Integer> sources = new ArrayList<Integer>(); |
|
|
|
sources.add(EnumMerchantSubsidySource.CARD.getCode()); |
|
|
|
wxCardSpend.setSources(sources); |
|
|
|
wxCardSpend.setCardSpendListShow(1); |
|
|
|
final List<Map<String, Object>> mapList = wxCardSpendService.sumCardSpendForMerchant(wxCardSpend); |
|
|
|
return new ResultData(mapList); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("交易流水导出") |
|
|
|
@GetMapping("/exportData") |
|
|
|
@SystemControllerLog(description = "储值卡支付-储值卡交易流水导出") |
|
|
|
public void exportData(@ModelAttribute WxCardSpendVo wxCardSpendVo, HttpServletRequest request, HttpServletResponse response) { |
|
|
|
logger.info("[" + getIpAddr() + "] cardPay/exportData"); |
|
|
|
if (wxCardSpendVo == null) { |
|
|
|
throw new MallinkException(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); |
|
|
|
} |
|
|
|
wxCardSpendVo.updateTenantInfo(getTenantInfo()); |
|
|
|
if(StringUtils.isNotBlank(wxCardSpendVo.getPayStatusStr())) { |
|
|
|
String [] statusAttr = wxCardSpendVo.getPayStatusStr().split(","); |
|
|
|
List<Integer> tmpList = new ArrayList<Integer>(); |
|
|
|
for(String status: statusAttr) { |
|
|
|
tmpList.add(Integer.valueOf(status)); |
|
|
|
} |
|
|
|
if(!tmpList.isEmpty()) { |
|
|
|
wxCardSpendVo.setPayStatusS(tmpList); |
|
|
|
} |
|
|
|
} |
|
|
|
wxCardSpendService.exportData(wxCardSpendVo, request, response); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("更新卡消费支付状态") |
|
|
|
@PostMapping("/updatePayStatus") |
|
|
|
@SystemControllerLog(description = "储值卡支付-更新卡消费支付状态") |
|
|
|
public ResultData update(@RequestBody WxCardSpend wxCardSpend) { |
|
|
|
String ipStr = getIpAddr(); |
|
|
|
logger.info("cardPay/updatePayStatus: " + ipStr + " :" + wxCardSpend.toString()); |
|
|
|
if (wxCardSpend == null) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); |
|
|
|
} |
|
|
|
wxCardSpend.updateTenantInfo(getTenantInfo()); |
|
|
|
wxCardSpendService.update(wxCardSpend); |
|
|
|
return new ResultData(); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("卡完结") |
|
|
|
@PostMapping("/finishCard") |
|
|
|
@SystemControllerLog(description = "储值卡支付-卡完结") |
|
|
|
public ResultData finishCard(@RequestBody WxCardInfo wxCardInfo) { |
|
|
|
String ipStr = getIpAddr(); |
|
|
|
logger.info("cardPay/finishCard: " + ipStr + " :" + wxCardInfo.toString()); |
|
|
|
if (wxCardInfo == null) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); |
|
|
|
} |
|
|
|
if (wxCardInfo.getId() == null) { |
|
|
|
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件ID为空"); |
|
|
|
} |
|
|
|
wxCardInfo.updateTenantInfo(getTenantInfo()); |
|
|
|
int remainShareAmount = wxCardSpendService.finishCard(wxCardInfo); |
|
|
|
return new ResultData(remainShareAmount); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("卡订单-导出数据") |
|
|
|
@GetMapping("/exportCardOrder") |
|
|
|
@SystemControllerLog(description = "卡订单-导出数据") |
|
|
|
public void exportCardOrder(@ModelAttribute WxCardVo wxCardVo, HttpServletRequest request, HttpServletResponse response) { |
|
|
|
logger.info("[" + getIpAddr() + "] cardPay/exportCardOrder"); |
|
|
|
if (wxCardVo == null) { |
|
|
|
wxCardVo = new WxCardVo(); |
|
|
|
} else { |
|
|
|
if (StringUtils.isBlank(wxCardVo.getOuPhone())) { |
|
|
|
wxCardVo.setOuPhone(null); |
|
|
|
} |
|
|
|
} |
|
|
|
wxCardVo.updateTenantInfo(getTenantInfo()); |
|
|
|
if (StringUtils.isNotBlank(wxCardVo.getStatusStr())) { |
|
|
|
String[] statusAttr = wxCardVo.getStatusStr().split(","); |
|
|
|
List<Integer> tmpList = new ArrayList<Integer>(); |
|
|
|
for (String status : statusAttr) { |
|
|
|
tmpList.add(Integer.valueOf(status)); |
|
|
|
} |
|
|
|
if (!tmpList.isEmpty()) { |
|
|
|
wxCardVo.setStatusS(tmpList); |
|
|
|
} |
|
|
|
} |
|
|
|
wxCardInfoService.exportData(wxCardVo, request, response); |
|
|
|
} |
|
|
|
|
|
|
|
@ApiOperation("卡消费订单-导出数据") |
|
|
|
@GetMapping("exportCardSpend") |
|
|
|
@SystemControllerLog(description = "卡消费订单-导出数据") |
|
|
|
public void exportCardSpend(@ModelAttribute WxCardSpendVo wxCardSpendVo, HttpServletRequest request, HttpServletResponse response) { |
|
|
|
String ipStr = getIpAddr(); |
|
|
|
logger.info("cardPay/exportCardSpend: " + ipStr); |
|
|
|
if (wxCardSpendVo == null) { |
|
|
|
wxCardSpendVo = new WxCardSpendVo(); |
|
|
|
} |
|
|
|
wxCardSpendVo.updateTenantInfo(getTenantInfo()); |
|
|
|
if (StringUtils.isNotBlank(wxCardSpendVo.getPayStatusStr())) { |
|
|
|
String[] statusAttr = wxCardSpendVo.getPayStatusStr().split(","); |
|
|
|
List<Integer> tmpList = new ArrayList<Integer>(); |
|
|
|
for (String status : statusAttr) { |
|
|
|
tmpList.add(Integer.valueOf(status)); |
|
|
|
} |
|
|
|
if (!tmpList.isEmpty()) { |
|
|
|
wxCardSpendVo.setPayStatusS(tmpList); |
|
|
|
} |
|
|
|
} |
|
|
|
List<Integer> sources = new ArrayList<Integer>(); |
|
|
|
sources.add(EnumMerchantSubsidySource.CARD.getCode()); |
|
|
|
wxCardSpendVo.setSources(sources); |
|
|
|
wxCardSpendVo.setCardSpendListShow(1); |
|
|
|
wxCardSpendService.exportData(wxCardSpendVo, request, response); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |