From fc50cc62621612bd9d259afb0bfc0c69615c46b4 Mon Sep 17 00:00:00 2001 From: lin <642018748@qq.com> Date: Tue, 28 Feb 2023 19:26:17 +0800 Subject: [PATCH] fix card --- .../market/WxCardInfoController.java | 140 ++++++------ .../market/WxCardPayController.java | 26 ++- .../controller/WxCardPayController.java | 100 ++++----- .../com/iformall/domain/po/WxCardSpend.java | 6 + .../iformall/domain/po/WxMerchantSubsidy.java | 4 + .../com/iformall/domain/vo/WxCardSpendVo.java | 32 +-- .../iformall/mapper/WxCardSpendMapper.java | 2 - .../mapper/WxMerchantSubsidyMapper.java | 1 + .../service/impl/WxCardSpendServiceImpl.java | 200 +++++++++++++++++- .../resources/mapper/WxCardSpendMapper.xml | 180 +++------------- .../mapper/WxMerchantSubsidyMapper.xml | 22 ++ 11 files changed, 415 insertions(+), 298 deletions(-) diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCardInfoController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCardInfoController.java index 61e70522a..2bb060cb6 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCardInfoController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCardInfoController.java @@ -83,76 +83,76 @@ public class WxCardInfoController extends BaseController { 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 tmpList = new ArrayList(); - for(String status: statusAttr) { - tmpList.add(Integer.valueOf(status)); - } - if(!tmpList.isEmpty()) { - wxCardSpendVo.setPayStatusS(tmpList); - } - } - List sources = new ArrayList(); - sources.add(EnumMerchantSubsidySource.CARD.getCode()); - wxCardSpendVo.setSources(sources); - wxCardSpendVo.setCardSpendListShow(1); - final PageInfo 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 sources = new ArrayList(); - sources.add(EnumMerchantSubsidySource.CARD.getCode()); - wxCardSpend.setSources(sources); - wxCardSpend.setCardSpendListShow(1); - final List> 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 tmpList = new ArrayList(); - for(String status: statusAttr) { - tmpList.add(Integer.valueOf(status)); - } - if(!tmpList.isEmpty()) { - wxCardSpendVo.setPayStatusS(tmpList); - } - } - wxCardSpendService.exportData(wxCardSpendVo, request, response); - } +// @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 tmpList = new ArrayList(); +// for(String status: statusAttr) { +// tmpList.add(Integer.valueOf(status)); +// } +// if(!tmpList.isEmpty()) { +// wxCardSpendVo.setPayStatusS(tmpList); +// } +// } +// List sources = new ArrayList(); +// sources.add(EnumMerchantSubsidySource.CARD.getCode()); +// wxCardSpendVo.setSources(sources); +// wxCardSpendVo.setCardSpendListShow(1); +// final PageInfo 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 sources = new ArrayList(); +// sources.add(EnumMerchantSubsidySource.CARD.getCode()); +// wxCardSpend.setSources(sources); +// wxCardSpend.setCardSpendListShow(1); +// final List> 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 tmpList = new ArrayList(); +// for(String status: statusAttr) { +// tmpList.add(Integer.valueOf(status)); +// } +// if(!tmpList.isEmpty()) { +// wxCardSpendVo.setPayStatusS(tmpList); +// } +// } +// wxCardSpendService.exportData(wxCardSpendVo, request, response); +// } @ApiOperation("更新卡消费支付状态") @PostMapping("/updatePayStatus") diff --git a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCardPayController.java b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCardPayController.java index 17a75d340..a0902d5a1 100644 --- a/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCardPayController.java +++ b/mallinkAdmin/src/main/java/com/iformall/controller/market/WxCardPayController.java @@ -114,12 +114,28 @@ public class WxCardPayController extends BaseController { return new ResultData(page); } - @ApiOperation("C端扫B端储值卡交易流水SUM") - @GetMapping("sum") +// @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 sources = new ArrayList(); +// sources.add(EnumMerchantSubsidySource.CARD.getCode()); +// wxCardSpend.setSources(sources); +// wxCardSpend.setCardSpendListShow(1); +// final List> mapList = wxCardSpendService.sumCardSpendForMerchant(wxCardSpend); +// return new ResultData(mapList); +// } + + @ApiOperation("储值卡交易流水SUM") + @GetMapping("sumCard") @SystemControllerLog(description = "储值卡支付-储值卡交易流水SUM") - public ResultData sumCardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend) { - String ipStr = getIpAddr(); - logger.info("cardPay/sumCardSpendList: " + ipStr + " :" + wxCardSpend.toString()); + public ResultData sumCard(@ModelAttribute WxCardSpendVo wxCardSpend) { if (wxCardSpend == null) { return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "过滤条件为空"); } diff --git a/mallinkCApi/src/main/java/com/iformall/controller/WxCardPayController.java b/mallinkCApi/src/main/java/com/iformall/controller/WxCardPayController.java index 13d2c869d..147cefa81 100644 --- a/mallinkCApi/src/main/java/com/iformall/controller/WxCardPayController.java +++ b/mallinkCApi/src/main/java/com/iformall/controller/WxCardPayController.java @@ -199,54 +199,54 @@ public class WxCardPayController extends BaseController { } - @ApiOperation("C端扫B端储值卡交易流水列表接口") - @GetMapping("list") - @ApiImplicitParams({ - @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), - @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) - public ResultData cardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend, Integer pageNum, Integer pageSize) { - String ipStr = getIpAddr(); - logger.info("list: " + ipStr + " :" + wxCardSpend.toString()); - Long memberId; - try { - memberId = getMemberId(); - } catch (Exception e) { - return new ResultData(Result.ERROR,e.getMessage()); - } - return cardSpendList(wxCardSpend,memberId, pageNum, pageSize); - } - - private ResultData cardSpendList(WxCardSpendVo wxCardSpend,Long cUserId,Integer pageNum, Integer pageSize) { - if (wxCardSpend == null) wxCardSpend = new WxCardSpendVo(); - wxCardSpend.updateTenantInfo(getTenantInfo()); - wxCardSpend.setOwnerId(cUserId); - List sources = new ArrayList(); - sources.add(EnumMerchantSubsidySource.CARD.getCode()); - wxCardSpend.setSources(sources); - wxCardSpend.setCardSpendListShow(1); - final PageInfo page = wxCardSpendService.listAsPage(wxCardSpend, pageNum, pageSize); - return new ResultData(page); - } - - @ApiOperation("C端扫B端储值卡交易流水SUM接口") - @GetMapping("sum") - public ResultData sumCardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend) { - String ipStr = getIpAddr(); - logger.info("sumCardSpendList: " + ipStr + " :" + wxCardSpend.toString()); - Long memberId; - try { - memberId = getMemberId(); - } catch (Exception e) { - return new ResultData(Result.ERROR,e.getMessage()); - } - return sumCardSpendList(wxCardSpend,memberId); - } - - private ResultData sumCardSpendList(WxCardSpendVo wxCardSpend,Long cUserId) { - if (wxCardSpend == null) wxCardSpend = new WxCardSpendVo(); - wxCardSpend.updateTenantInfo(getTenantInfo()); - wxCardSpend.setOwnerId(cUserId); - final List> mapList = wxCardSpendService.sumCardSpendForOwner(wxCardSpend); - return new ResultData(mapList); - } +// @ApiOperation("C端扫B端储值卡交易流水列表接口") +// @GetMapping("list") +// @ApiImplicitParams({ +// @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), +// @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) +// public ResultData cardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend, Integer pageNum, Integer pageSize) { +// String ipStr = getIpAddr(); +// logger.info("list: " + ipStr + " :" + wxCardSpend.toString()); +// Long memberId; +// try { +// memberId = getMemberId(); +// } catch (Exception e) { +// return new ResultData(Result.ERROR,e.getMessage()); +// } +// return cardSpendList(wxCardSpend,memberId, pageNum, pageSize); +// } +// +// private ResultData cardSpendList(WxCardSpendVo wxCardSpend,Long cUserId,Integer pageNum, Integer pageSize) { +// if (wxCardSpend == null) wxCardSpend = new WxCardSpendVo(); +// wxCardSpend.updateTenantInfo(getTenantInfo()); +// wxCardSpend.setOwnerId(cUserId); +// List sources = new ArrayList(); +// sources.add(EnumMerchantSubsidySource.CARD.getCode()); +// wxCardSpend.setSources(sources); +// wxCardSpend.setCardSpendListShow(1); +// final PageInfo page = wxCardSpendService.listAsPage(wxCardSpend, pageNum, pageSize); +// return new ResultData(page); +// } +// +// @ApiOperation("C端扫B端储值卡交易流水SUM接口") +// @GetMapping("sum") +// public ResultData sumCardSpendList(@ModelAttribute WxCardSpendVo wxCardSpend) { +// String ipStr = getIpAddr(); +// logger.info("sumCardSpendList: " + ipStr + " :" + wxCardSpend.toString()); +// Long memberId; +// try { +// memberId = getMemberId(); +// } catch (Exception e) { +// return new ResultData(Result.ERROR,e.getMessage()); +// } +// return sumCardSpendList(wxCardSpend,memberId); +// } +// +// private ResultData sumCardSpendList(WxCardSpendVo wxCardSpend,Long cUserId) { +// if (wxCardSpend == null) wxCardSpend = new WxCardSpendVo(); +// wxCardSpend.updateTenantInfo(getTenantInfo()); +// wxCardSpend.setOwnerId(cUserId); +// final List> mapList = wxCardSpendService.sumCardSpendForOwner(wxCardSpend); +// return new ResultData(mapList); +// } } diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java index 65ad8c499..7d6e4e825 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCardSpend.java @@ -21,14 +21,20 @@ public class WxCardSpend extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="储值卡ID",name="cardId") private Long cardId; + @TableField(exist = false) + private List cardIdList; @io.swagger.annotations.ApiModelProperty(value="持有人ID",name="ownerId") private Long ownerId; + @TableField(exist = false) + private List ownerIdList; @io.swagger.annotations.ApiModelProperty(value="商户ID",name="merchantId") private Long merchantId; @Excel(name = "订单号", width = 20, orderNum = "5") @io.swagger.annotations.ApiModelProperty(value="订单账号",name="orderId") private Long orderId; + @TableField(exist = false) + private List orderIdList; @io.swagger.annotations.ApiModelProperty(value="POS订单账号",name="posOrderId") private Long posOrderId; @io.swagger.annotations.ApiModelProperty(value="ip地址",name="ip") diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxMerchantSubsidy.java b/mallinkService/src/main/java/com/iformall/domain/po/WxMerchantSubsidy.java index 4e9e04848..23ca2981c 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxMerchantSubsidy.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxMerchantSubsidy.java @@ -32,6 +32,8 @@ public class WxMerchantSubsidy extends TenantEntity { @Excel(name="交易单号",width = 20,orderNum = "1") @io.swagger.annotations.ApiModelProperty(value="订单ID",name="orderId") private Long orderId; + @TableField(exist = false) + private List orderIdList; @io.swagger.annotations.ApiModelProperty(value="订单支付类型(0:券1:付款码支付,2:C扫码支付,3,储值卡)",name="orderType") private Integer orderType; @@ -139,4 +141,6 @@ public class WxMerchantSubsidy extends TenantEntity { @Excel(name = "结算来源", width = 20, orderNum = "3", replace = {"补贴_0", "卡消费_1", "券核销_2", "砍价核销_3", "拼团核销_4", "收银分账_5", " _-1"}) @io.swagger.annotations.ApiModelProperty(value = "结算来源0补贴1卡消费2券核销3砍价核销4拼团核销5收银分账", name = "source") private Integer source; + @TableField(exist = false) + private List sourceList; } diff --git a/mallinkService/src/main/java/com/iformall/domain/vo/WxCardSpendVo.java b/mallinkService/src/main/java/com/iformall/domain/vo/WxCardSpendVo.java index cb50bf112..477272625 100644 --- a/mallinkService/src/main/java/com/iformall/domain/vo/WxCardSpendVo.java +++ b/mallinkService/src/main/java/com/iformall/domain/vo/WxCardSpendVo.java @@ -16,31 +16,33 @@ import lombok.ToString; @EqualsAndHashCode(callSuper = true) public class WxCardSpendVo extends WxCardSpend { + @io.swagger.annotations.ApiModelProperty(value="卡类型EnumCardInfoType",name="cardType") + @Excel(name = "卡类型", width = 20,replace = {"电子卡_0","实体卡_1"}, orderNum = "1") + private Integer cardType; + @Excel(name = "卡号", width = 20, orderNum = "2") + @io.swagger.annotations.ApiModelProperty(value="卡号",name="cardId") + private Long cardId; + @Excel(name = "消费者", width = 20, orderNum = "3") + @io.swagger.annotations.ApiModelProperty(value="持有人昵称",name="onickName") + private String onickName; + @Excel(name = "手机", width = 20, orderNum = "4") + @io.swagger.annotations.ApiModelProperty(value="持有人绑定的手机号",name="ouPhone") + private String ouPhone; /**卡信息*/ @io.swagger.annotations.ApiModelProperty(value="卡券名称",name="title") - @Excel(name = "卡名称", width = 20, orderNum = "3") + @Excel(name = "卡名称", width = 20, orderNum = "5") private String title; - @io.swagger.annotations.ApiModelProperty(value="商户名",name="merchantName") - @Excel(name = "消费商户", width = 20, orderNum = "4") + @Excel(name = "消费商户", width = 20, orderNum = "6") private String merchantName; - + @Excel(name = "补贴额(包含通道费)", width = 20, orderNum = "6") @io.swagger.annotations.ApiModelProperty(value="补贴额(包含通道费)",name="subsidy") private Integer subsidy; + @Excel(name = "线上补贴额/实收补贴额(通道费扣除)", width = 20, orderNum = "7") @io.swagger.annotations.ApiModelProperty(value="线上补贴额/实收补贴额(通道费扣除)",name="realSubsidy") private Integer realSubsidy; @io.swagger.annotations.ApiModelProperty(value="补贴状态(0:未补贴, 1:已补贴)",name="status") private Integer status; - - @Excel(name = "消费者", width = 20, orderNum = "1") - @io.swagger.annotations.ApiModelProperty(value="持有人昵称",name="onickName") - private String onickName; - - - @Excel(name = "手机", width = 20, orderNum = "2") - @io.swagger.annotations.ApiModelProperty(value="持有人绑定的手机号",name="ouPhone") - private String ouPhone; - @io.swagger.annotations.ApiModelProperty(value="账单来源查询条件",name="sources") @TableField(exist = false) private List sources; @@ -54,7 +56,5 @@ public class WxCardSpendVo extends WxCardSpend { private Date couponOnlineStartDate; @TableField(exist = false) private Date couponOnlineEndDate; - @TableField(exist = false) - private List cardIdList; } diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCardSpendMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCardSpendMapper.java index 141d8346e..2e996474e 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCardSpendMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCardSpendMapper.java @@ -15,8 +15,6 @@ public interface WxCardSpendMapper extends CommonMapper { List> getMerchantCount(WxCardSpend wxCardSpend); - List findCardSpendVoList(WxCardSpendVo wxCardSpend); - List> sumCardSpendVoForMerchant(WxCardSpendVo wxCardSpend); List> sumCardSpendVoForOwner(WxCardSpendVo wxCardSpend); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxMerchantSubsidyMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxMerchantSubsidyMapper.java index 8a2f49bf6..b4b81825e 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxMerchantSubsidyMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxMerchantSubsidyMapper.java @@ -13,6 +13,7 @@ public interface WxMerchantSubsidyMapper extends CommonMapper findList(WxMerchantSubsidy wxMerchantSubsidy); + List findOrderIdList(WxMerchantSubsidy wxMerchantSubsidy); int updateByCond(WxMerchantSubsidy wxMerchantSubsidy); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java index c8eb9ec07..3ee4ad6f7 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCardSpendServiceImpl.java @@ -1,5 +1,6 @@ package com.iformall.service.impl; +import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -12,6 +13,7 @@ import com.iformall.domain.po.*; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.vo.PromotionCalc; import com.iformall.domain.vo.WxCardSpendVo; +import com.iformall.domain.vo.WxCardVo; import com.iformall.enums.*; import com.iformall.exception.MallinkException; import com.iformall.mapper.*; @@ -20,6 +22,7 @@ import com.iformall.utils.Constant; import com.iformall.utils.PayUtils; import com.iformall.utils.RedisLock; +import org.apache.commons.beanutils.BeanUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -30,7 +33,11 @@ import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -93,6 +100,9 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { @Autowired WxCouponChannelMapper wxCouponChannelMapper; + @Autowired + WxCUserBasicInfoMapper wxCUserBasicInfoMapper; + @Override public WxCouponMerchant checkMerchantInCoupon(WxCardInfo cardInfo, Long merchantId) { WxCouponMerchant couponMerchant = null; @@ -394,15 +404,168 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { return false; } + private List handleToCardSpendVoList(List list,TenantEntity tenantEntity) { + if (null != list && list.size() > 0 ){ + List merchantIdList = new ArrayList(); + List cardInfoIdList = new ArrayList(); + List merchantSubsidyOrderIdList = new ArrayList(); + List userIdList = new ArrayList(); + List couponIdList = new ArrayList(); + for (int i = 0 ; i < list.size(); i++ ){ + WxCardSpend _wcs = list.get(i); + if (null != _wcs.getMerchantId() && (!merchantIdList.contains(_wcs.getMerchantId()))) { + merchantIdList.add(_wcs.getMerchantId()) ; + } + if (null != _wcs.getCardId() && (!cardInfoIdList.contains(_wcs.getCardId()))) { + cardInfoIdList.add(_wcs.getCardId()) ; + } + if (null != _wcs.getOrderId() && (!merchantSubsidyOrderIdList.contains(_wcs.getOrderId()))) { + merchantSubsidyOrderIdList.add(_wcs.getOrderId()) ; + } + if (null != _wcs.getOwnerId() && (!userIdList.contains(_wcs.getOwnerId()))) { + userIdList.add(_wcs.getOwnerId()) ; + } + + } + + Map merchantMap = new HashMap(); + if (merchantIdList.size() > 0 ){ + WxMerchant mq = new WxMerchant(); + mq.updateTenantInfo(tenantEntity); + mq.setIds(merchantIdList); + List merchantList = wxMerchantMapper.findList(mq); + if (null != merchantList && merchantList.size() > 0 ){ + for (int i = 0 ;i < merchantList.size();i++){ + WxMerchant m = merchantList.get(i); + merchantMap.put(m.getId(), m); + } + } + } + + Map cardCouponIdMap = new HashMap(); + if (cardInfoIdList.size() > 0 ){ + WxCardInfo ciq = new WxCardInfo(); + ciq.updateTenantInfo(tenantEntity); + ciq.setIds(cardInfoIdList); + List cardInfoList = wxCardInfoMapper.findList(ciq); + if (null != cardInfoList && cardInfoList.size() > 0 ){ + for (int i = 0 ;i < cardInfoList.size();i++){ + WxCardInfo ci = cardInfoList.get(i); + if (null != ci.getId() && (!couponIdList.contains(ci.getId()))) { + couponIdList.add(ci.getId()) ; + cardCouponIdMap.put(ci.getId(),ci.getCouponId()); + } + } + } + } + + Map couponMap = new HashMap(); + if (couponIdList.size() > 0 ){ + WxCoupon cq = new WxCoupon(); + cq.updateTenantInfo(tenantEntity); + cq.setIds(couponIdList); + List couponList = wxCouponMapper.findList(cq); + if (null != couponList && couponList.size() > 0 ){ + for (int i = 0 ;i < couponList.size();i++){ + WxCoupon c = couponList.get(i); + couponMap.put(c.getId(),c); + } + } + } + + Map orderSubsidyMap = new HashMap(); + if (merchantSubsidyOrderIdList.size() > 0 ){ + WxMerchantSubsidy msq = new WxMerchantSubsidy(); + msq.updateTenantInfo(tenantEntity); + msq.setOrderIdList(merchantSubsidyOrderIdList); + List msqList = wxMerchantSubsidyMapper.findList(msq); + if (null != msqList && msqList.size() > 0 ){ + for (int i = 0 ;i < msqList.size();i++){ + WxMerchantSubsidy c = msqList.get(i); + orderSubsidyMap.put(c.getOrderId(),c); + } + } + } + + Map userMap = new HashMap(); + if (userIdList.size() > 0 ){ + WxCUserBasicInfo u = new WxCUserBasicInfo(); + u.setFinalTenantId(tenantEntity.getFinalTenantId()); + u.setIds(userIdList); + List msqList = wxCUserBasicInfoMapper.findList(u); + if (null != msqList && msqList.size() > 0 ){ + for (int i = 0 ;i < msqList.size();i++){ + WxCUserBasicInfo c = msqList.get(i); + userMap.put(c.getId(),c); + } + } + } + + List retList = new ArrayList(); + for (int i = 0 ; i < list.size(); i++ ){ + WxCardSpend _wcs = list.get(i); + WxCardSpendVo vo = new WxCardSpendVo(); + try { + BeanUtils.copyProperties(vo, _wcs); + if (null != _wcs.getMerchantId()) { + WxMerchant merchant = merchantMap.get(_wcs.getMerchantId()); + if (null != merchant) { + vo.setMerchantName(merchant.getName()); + } + } + if (null != _wcs.getCardId()) { + Long couponId = cardCouponIdMap.get(_wcs.getCardId()); + if (null != couponId) { + WxCoupon coupon = couponMap.get(couponId); + if (null != coupon) { + vo.setTitle(coupon.getTitle()); + } + } + } + if (null != _wcs.getOrderId()) { + WxMerchantSubsidy subsidy = orderSubsidyMap.get(_wcs.getOrderId()); + if (null != subsidy) { + vo.setSubsidy(subsidy.getSubsidy()); + vo.setRealSubsidy(subsidy.getRealSubsidy()); + vo.setStatus(subsidy.getStatus()); + } + } + if (null != _wcs.getOwnerId()) { + WxCUserBasicInfo user = userMap.get(_wcs.getOwnerId()); + if (null != user) { + vo.setOnickName(user.getNickName()); + vo.setOuPhone(user.getPhone()); + } + } + retList.add(vo); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + + } + + } + return null; + } @Override public PageInfo listAsPage(WxCardSpendVo record, Integer pageIndex, Integer pageSize) { - handleCouponOnlineStartDate(record); - return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCardSpendMapper.findCardSpendVoList(record)); + handleQueryParam(record); + PageInfo cardInfoPage = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCardSpendMapper.findList(record)); + PageInfo pageInfo = new PageInfo(); + pageInfo.setList(handleToCardSpendVoList(cardInfoPage.getList(),record)); + pageInfo.setPageNum(cardInfoPage.getPageNum()); + pageInfo.setPageSize(cardInfoPage.getPageSize()); + pageInfo.setPages(cardInfoPage.getPages()); + pageInfo.setTotal(cardInfoPage.getTotal()); + return pageInfo; } - //处理券投放时间 - private void handleCouponOnlineStartDate(WxCardSpendVo record){ + + private void handleQueryParam(WxCardSpendVo record){ + //处理券投放时间 if (null != record.getCouponOnlineStartDate() || null != record.getCouponOnlineEndDate() ) { WxCouponChannel wxCouponChannelQ = new WxCouponChannel(); wxCouponChannelQ.updateTenantInfo(record); @@ -423,6 +586,31 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { } } } + if (null != record.getStatus() || null != record.getSources() || null != record.getCardSpendListShow()) { + WxMerchantSubsidy subq = new WxMerchantSubsidy(); + subq.updateTenantInfo(record); + subq.setStatus(record.getStatus()); + subq.setSourceList(record.getSources()); + subq.setCardSpendListShow(record.getCardSpendListShow()); + List orderList = wxMerchantSubsidyMapper.findOrderIdList(subq); + if (null == orderList || orderList.size() <=0 ){ + record.setId(-999L); + }else { + record.setOrderIdList(orderList); + } + } + + if (StringUtils.isNotBlank(record.getOuPhone())) { + WxCUserBasicInfo uq = new WxCUserBasicInfo(); + uq.setFinalTenantId(record.getFinalTenantId()); + uq.setPhone(record.getOuPhone()); + List uids = wxCUserBasicInfoMapper.findIdList(uq); + if (null == uids || uids.size() <=0 ){ + record.setId(-999L); + }else { + record.setOwnerIdList(uids); + } + } } @Override @@ -668,8 +856,8 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { @Override public void exportData(WxCardSpendVo record, HttpServletRequest request, HttpServletResponse response) { - handleCouponOnlineStartDate(record); - List list = wxCardSpendMapper.findCardSpendVoList(record); + handleQueryParam(record); + List list = listAsPage(record,0,50000).getList(); excelService.exportExcel(list, null, "卡消费记录", WxCardSpendVo.class, "卡消费记录.xlsx", response, false); } diff --git a/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml b/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml index ba173e849..011b13721 100644 --- a/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCardSpendMapper.xml @@ -89,10 +89,38 @@ and `pay_from` = #{payFrom} - - and `create_date` between #{startdate} and #{enddate} + + + and `create_date` >= #{startdate} + + + and `create_date` <= and #{enddate} + + + + and `pay_status` in + + #{psItem} + + + + and `card_id` in + + #{cardIdItem} + + + + and owner_id in + + #{owneridItem} + + + + and order_id in + + #{oidItem} + - and id in @@ -229,152 +257,6 @@ group by cs.merchant_id - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - cs.`id`,cs.`tenant_id`,cs.`parent_tenant_id`,cs.`card_id`,cs.`owner_id`,cs.`merchant_id`,cs.`order_id`,cs.`deduction_amount`,cs.`payment`,cs.`real_payment`, - cs.`card_remain_amount`,cs.`card_before_amount`,cs.`card_remain_real_amount`,cs.`card_before_real_amount`, - cs.`create_date`,cs.`update_date`, cs.`pay_status`, - m.`name`, c.`title`, - ms.`subsidy`,ms.`real_subsidy`,ms.`status`, - ou.`nick_name` as onick_name, ou.`phone` as ou_phone - - - - where 1 = 1 - - and cs.`id` = #{id} - - - and cs.`tenant_id` = #{tenantId} - - - and cs.`parent_tenant_id` = #{parentTenantId} - - - and cs.`card_id` = #{cardId} - - - and cs.`owner_id` = #{ownerId} - - - and cs.`merchant_id` = #{merchantId} - - - and cs.`order_id` = #{orderId} - - - and cs.`deduction_amount` = #{deductionAmount} - - - and cs.`payment` = #{payment} - - - and cs.`real_payment` = #{realPayment} - - - and cs.`card_remain_amount` = #{cardRemainAmount} - - - and cs.`card_before_amount` = #{cardBeforeAmount} - - - and cs.`card_remain_real_amount` = #{cardRemainRealAmount} - - - and cs.`card_before_real_amount` = #{cardBeforeRealAmount} - - - and cs.`pay_status` = #{payStatus} - - - and ms.`status` = #{status} - - - - and ( ms.source is null or ms.source in - - #{sourceItem} - - ) - - - - and ( ms.card_spend_list_show is null or ms.card_spend_list_show = #{cardSpendListShow} ) - - - - and ou.`phone` = #{ouPhone} - - - and cs.`create_date` between #{startdate} and #{enddate} - - - and cs.`pay_status` in - - #{sItem} - - - - - and cs.`card_id` in - - #{cardIdItem} - - - - - and cs.id in - - #{idItem} - - - - - - + + update wx_merchant_subsidy set `status` = #{status}