From a9a7efc8b3676f9cac4ada65e78618fb72ca5fe5 Mon Sep 17 00:00:00 2001 From: winter Date: Sat, 15 Jan 2022 21:11:47 +0800 Subject: [PATCH] =?UTF-8?q?fix=20=E6=B3=A8=E5=88=B8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxCouponController.java | 103 ++++++----- .../controller/WxCouponSendController.java | 1 - .../iformall/schedule/CouponSendSchedule.java | 10 +- .../com/iformall/domain/po/WxCouponSend.java | 143 +++++++-------- .../com/iformall/mapper/WxCouponMapper.java | 3 + .../iformall/mapper/WxCouponSendMapper.java | 4 +- .../iformall/service/WxCouponSendService.java | 5 + .../service/impl/WxCouponSendServiceImpl.java | 167 +++++++++++++++--- .../service/impl/WxCouponServiceImpl.java | 1 - .../mapper/WxCouponActionLogMapper.xml | 2 +- .../main/resources/mapper/WxCouponMapper.xml | 93 +++++----- .../resources/mapper/WxCouponSendMapper.xml | 80 ++------- 12 files changed, 345 insertions(+), 267 deletions(-) diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java index d1d3c7b89..b28e7fbbf 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponController.java @@ -56,58 +56,57 @@ public class WxCouponController extends BaseController { @Autowired RedisLock redisLock; - //TODO 待优化数据 -// @ApiOperation("分页列表接口") -// @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 list(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize, Integer dataType) { -// logger.debug("[" + getIpAddr() + "] WxCouponController::list"); -// if (wxCoupon == null) wxCoupon = new WxCoupon(); -// wxCoupon.updateTenantInfo(getTenantInfo()); -// if(null == wxCoupon.getSourceType()){ -// wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Bapi.getCode()); -// } -// wxCoupon.setMerchantId(getLoginBUser().getMerchantId()); -// -// if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){ -// String coryColumn = "c."+wxCoupon.getSortColumns(); -// wxCoupon.setSortColumns(coryColumn); -// wxCoupon.setSortColumn(null); -// } -// -// return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表 -// } -// -// @ApiOperation("分页列表接口") -// @GetMapping("listWithTypePress") -// @ApiImplicitParams({ -// @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), -// @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) -// public ResultData listWithTypePress(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { -// logger.debug("[" + getIpAddr() + "] WxCouponController::list"); -// if (wxCoupon == null) wxCoupon = new WxCoupon(); -// wxCoupon.updateTenantInfo(getTenantInfo()); -// Integer[] typeArray = { -// EnumCouponType.COUPON_MANJIAN.getCode(), -// EnumCouponType.COUPON_DAIJIN.getCode(), -// EnumCouponType.COUPON_TUANGOU.getCode(), -// EnumCouponType.COUPON_LIPIN.getCode(), -// EnumCouponType.COUPON_TINGCHE.getCode(), -// EnumCouponType.COUPON_MULTIMCH.getCode(), -// EnumCouponType.COUPON_PRESS.getCode(), -// EnumCouponType.COUPON_PREORDER.getCode()}; -// -// wxCoupon.setTypes(Arrays.asList(typeArray)); -// wxCoupon.setMerchantId(getLoginBUser().getMerchantId()); -// if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){ -// String coryColumn = "c."+wxCoupon.getSortColumns(); -// wxCoupon.setSortColumns(coryColumn); -// wxCoupon.setSortColumn(null); -// } -// return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表 -// } + @ApiOperation("分页列表接口") + @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 list(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize, Integer dataType) { + logger.debug("[" + getIpAddr() + "] WxCouponController::list"); + if (wxCoupon == null) wxCoupon = new WxCoupon(); + wxCoupon.updateTenantInfo(getTenantInfo()); + if(null == wxCoupon.getSourceType()){ + wxCoupon.setSourceType(EnumCouponSourceType.COUPONSource_Bapi.getCode()); + } + wxCoupon.setMerchantId(getLoginBUser().getMerchantId()); + + if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){ + String coryColumn = "c."+wxCoupon.getSortColumns(); + wxCoupon.setSortColumns(coryColumn); + wxCoupon.setSortColumn(null); + } + + return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表 + } + + @ApiOperation("分页列表接口") + @GetMapping("listWithTypePress") + @ApiImplicitParams({ + @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), + @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) + public ResultData listWithTypePress(@ModelAttribute WxCoupon wxCoupon, Integer pageNum, Integer pageSize) { + logger.debug("[" + getIpAddr() + "] WxCouponController::list"); + if (wxCoupon == null) wxCoupon = new WxCoupon(); + wxCoupon.updateTenantInfo(getTenantInfo()); + Integer[] typeArray = { + EnumCouponType.COUPON_MANJIAN.getCode(), + EnumCouponType.COUPON_DAIJIN.getCode(), + EnumCouponType.COUPON_TUANGOU.getCode(), + EnumCouponType.COUPON_LIPIN.getCode(), + EnumCouponType.COUPON_TINGCHE.getCode(), + EnumCouponType.COUPON_MULTIMCH.getCode(), + EnumCouponType.COUPON_PRESS.getCode(), + EnumCouponType.COUPON_PREORDER.getCode()}; + + wxCoupon.setTypes(Arrays.asList(typeArray)); + wxCoupon.setMerchantId(getLoginBUser().getMerchantId()); + if(StringUtils.isNotBlank(wxCoupon.getSortColumn())){ + String coryColumn = "c."+wxCoupon.getSortColumns(); + wxCoupon.setSortColumns(coryColumn); + wxCoupon.setSortColumn(null); + } + return wxCouponService.list(wxCoupon,wxCoupon, pageNum, pageSize); //全列表 + } private Map generateFlowParams(EnumFlowKey flowType,EnumCouponAppType approvalType, WxCoupon wxCoupon,String remark,String phone) { Map map = new HashMap(); diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java index 5e9eab18c..69e49887f 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java @@ -44,7 +44,6 @@ public class WxCouponSendController extends BaseController { @Resource private WxCUserMapper wxCUserMapper; - //TODO 待优化数据 @ApiOperation("查询商户注券列表") @GetMapping("/list") @ApiImplicitParams({ diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java index 613dcf960..9a2abb8c7 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java @@ -16,6 +16,7 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; @@ -50,8 +51,9 @@ public class CouponSendSchedule { @Autowired private WxCUserBasicInfoService wxCUserBasicInfoService; + @Lazy @Autowired - private WxCouponSendMapper wxCouponSendMapper; + private WxCouponSendService wxCouponSendService; @Autowired private WxCouponActionLogMapper wxCouponActionLogMapper; @@ -65,8 +67,6 @@ public class CouponSendSchedule { @Autowired private WxCouponSendConfigMapper couponSendConfigMapper; - @Autowired - private WxCouponSendService wxCouponSendService; @Autowired private WxScoreRulesService wxScoreRulesService; @@ -147,7 +147,7 @@ public class CouponSendSchedule { wxCouponSend.updateTenantInfo(tenantEntity); wxCouponSend.setSendType(EnumCouponSendSendType.TIMED.getCode()); wxCouponSend.setStatus(EnumCouponSendStatus.VALID.getCode()); - List couponSendList = wxCouponSendMapper.findListVo(wxCouponSend); + List couponSendList = wxCouponSendService.findListVo(wxCouponSend); int remain = couponSendList.stream().map(cs -> { int count = cs.getRemainInventory(); logger.info("定时发券:给[" + cu.getNickName() + @@ -256,7 +256,7 @@ public class CouponSendSchedule { wxCouponSend.updateTenantInfo(tenantEntity); wxCouponSend.setSendType(EnumCouponSendSendType.BIRTHDAY.getCode()); wxCouponSend.setStatus(EnumCouponSendStatus.VALID.getCode()); - List couponSendList = wxCouponSendMapper.findListVo(wxCouponSend); + List couponSendList = wxCouponSendService.findListVo(wxCouponSend); if (CollectionUtils.isEmpty(couponSendList)) { logger.info("生日发券: 会员生日券投放列表为空 couponSendList = {}, 任务跳过不执行", couponSendList); return; diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponSend.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponSend.java index 69a2f2446..aabd24fdb 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponSend.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponSend.java @@ -1,5 +1,7 @@ package com.iformall.domain.po; +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonIgnore; @@ -12,126 +14,125 @@ import lombok.ToString; import java.util.Date; import java.util.List; +import org.apache.commons.lang3.StringUtils; + @TableName(value = "wx_coupon_send") @Data @ToString(callSuper = true) @EqualsAndHashCode(callSuper = true) public class WxCouponSend extends TenantEntity { - /** - * 卡券ids - */ + private static final long serialVersionUID = 1169744095647819041L; + + + protected Long id; + @io.swagger.annotations.ApiModelProperty(value="卡券id",name="couponId") + private Long couponId; @TableField(exist = false) - public static final String KEY_COUPONIDS = "couponIds" ; - /** - * beforeDays - */ + private List couponIds; + @io.swagger.annotations.ApiModelProperty(value="券名称",name="title") + private String title; + @io.swagger.annotations.ApiModelProperty(value="2:停车发券 3:核销发券 4: B端刷卡发券 5:商户发券 6:定时发券 7:商户发券",name="sendType") + private Integer sendType; + @io.swagger.annotations.ApiModelProperty(value="发券条件",name="condition") + private String conditions; + @io.swagger.annotations.ApiModelProperty(value="0:有效 1:无效,全部时不传",name="status") + private Integer status; + @io.swagger.annotations.ApiModelProperty(value = "1是0否", name = "是否发送短信1是0否") + private Integer sendSms; + + @JsonIgnore + @io.swagger.annotations.ApiModelProperty(value="操作人ID",name="operatorId") + private Long operatorId; + @io.swagger.annotations.ApiModelProperty(value="操作人",name="operator") @TableField(exist = false) - public static final String KEY_BEFOREDAYS = "beforeDays" ; + private String operator; + + @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") + private Date createDate; + @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") + private Date updateDate; + + /** - * limit 商户购券数 + * 商户购券数 */ + //@TableField(exist = false) + //protected Integer merchantLnventory; @JsonIgnore @TableField(exist = false) public static final String KEY_MERCHANT_LNVENTORY = "merchantLnventory" ; - + public Integer getMerchantLnventory() { + return (Integer)getConditonsValue(KEY_MERCHANT_LNVENTORY); + } + /** - * limit 商户注券数 + * 商户注券数 */ + //@TableField(exist = false) + //protected Integer merchantSend; @JsonIgnore @TableField(exist = false) public static final String KEY_MERCHANT_SEND = "merchantSend" ; - + public Integer getMerchantSend() { + return (Integer)getConditonsValue(KEY_MERCHANT_SEND); + } + + /** - * limit 商户注券数 + * 商户剩余数 */ + @JsonIgnore @TableField(exist = false) public static final String KEY_MERCHANT_REMAIN = "merchantRemain" ; - + public Integer getMerchantRemain() { + return (Integer)getConditonsValue(KEY_MERCHANT_REMAIN); + } + + @TableField(exist = false) + public static final String KEY_COUPONIDS = "couponIds" ; + @TableField(exist = false) + public static final String KEY_BEFOREDAYS = "beforeDays" ; /** * 排序-商户购券数 */ @JsonIgnore public static final String SORT_MERCHANT_LNVENTORY = "merchantLnventory" ; - /** * 排序-商户已发数 */ @JsonIgnore public static final String SORT_MERCHANT_SEND = "merchantSend" ; - /** * 排序-商户剩余数 */ @JsonIgnore public static final String SORT_REMAIN = "merchantRemain" ; - - - protected Long id; - + private Object getConditonsValue(String key) { + if (!StringUtils.isBlank(conditions)) { + JSONObject object = JSON.parseObject(conditions); + if (null != object) { + return object.get(key); + } + } + return null; + } + + @TableField(exist = false) protected List ids; - - /** - * 商户购券数 - */ - @TableField(exist = false) - protected Integer merchantLnventory; - - /** - * 商户已发数 - */ - @TableField(exist = false) - protected Integer merchantSend; - - /** - * 商户剩余数 - */ - @TableField(exist = false) - protected Integer merchantRemain; - - /**发券所属商户名**/ @TableField(exist = false) private String merchantName; - /** - * 商户ID - */ @TableField(exist = false) private Long merchantId; - - @io.swagger.annotations.ApiModelProperty(value="卡券id",name="couponId") - private Long couponId; - - @io.swagger.annotations.ApiModelProperty(value="券名称",name="title") - private String title; - @io.swagger.annotations.ApiModelProperty(value="2:停车发券 3:核销发券 4: B端刷卡发券 5:商户发券 6:定时发券 7:商户发券",name="sendType") - private Integer sendType; - @io.swagger.annotations.ApiModelProperty(value="发券条件",name="condition") - private String conditions; - @io.swagger.annotations.ApiModelProperty(value="0:有效 1:无效,全部时不传",name="status") - private Integer status; - - @JsonIgnore - @io.swagger.annotations.ApiModelProperty(value="操作人ID",name="operatorId") - private Long operatorId; - - @io.swagger.annotations.ApiModelProperty(value="操作人",name="operator") @TableField(exist = false) - private String operator; - - @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") - private Date createDate; - @io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate") - private Date updateDate; - + protected Integer merchantRemain; + @TableField(exist = false) @io.swagger.annotations.ApiModelProperty(value="场景发券计数",name="sendCount") protected int sendCount; - @io.swagger.annotations.ApiModelProperty(value = "1是0否", name = "是否发送短信1是0否") - private Integer sendSms; - @io.swagger.annotations.ApiModelProperty(value = "0未过期1已过期,全部时不传", name = "expired" ) @TableField(exist = false) private Integer expired; diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java index 395d9abaa..5416a9900 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java @@ -23,6 +23,9 @@ public interface WxCouponMapper extends CommonMapper { List findIdList(WxCoupon wxCoupon); List findCouponList(WxCoupon wxCoupon); + + List findSendCouponList(WxCoupon wxCoupon); + List findSendCouponIds(@Param("expired")Integer expired,@Param("tenantId")String tenantId); WxCoupon selectById(@Param("id")Long id,@Param("tenantId")String tenantId); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponSendMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponSendMapper.java index bc12d86c2..ab5b5b5de 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponSendMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponSendMapper.java @@ -3,7 +3,6 @@ package com.iformall.mapper; import java.util.*; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxCouponSend; -import com.iformall.domain.vo.WxCouponSendVo; import org.apache.ibatis.annotations.Param; public interface WxCouponSendMapper extends CommonMapper { @@ -12,8 +11,7 @@ public interface WxCouponSendMapper extends CommonMapper { int deleteById(@Param("id")Long id,@Param("tenantId")String tenantId); - List findListVo(WxCouponSend wxCouponSend); - List findListVoByValidType(WxCouponSend wxCouponSend); + List findList(WxCouponSend wxCouponSend); void updateStatusByCouponId(WxCouponSend wxCouponSend); diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java index aef2a0de9..91f17ac80 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java @@ -1,5 +1,7 @@ package com.iformall.service; +import java.util.List; + import com.github.pagehelper.PageInfo; import com.iformall.domain.po.base.TenantEntity; import com.iformall.domain.po.WxCouponSend; @@ -97,6 +99,9 @@ public interface WxCouponSendService { * @param wxCouponSend */ void handSel(WxCouponSend wxCouponSend,Long cUserId,EnumPayWay payWay,Long merchantId,Long bUserId) ; + + + List findListVo(WxCouponSend record); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java index dfae1781b..fd42c2170 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java @@ -22,6 +22,8 @@ import com.iformall.mq.MqBaseProducer; import com.iformall.service.*; import com.iformall.utils.Constant; import com.iformall.utils.DateUtils; + +import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; @@ -31,6 +33,8 @@ import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; + +import java.lang.reflect.InvocationTargetException; import java.text.SimpleDateFormat; import java.util.*; import java.util.stream.Collectors; @@ -93,6 +97,12 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { @Lazy @Autowired private WxMsgService wxMsgService; + + @Autowired + WxCouponMapper wxCouponMapper; + + @Autowired + MallUserInfoMapper mallUserInfoMapper; @Override public PageInfo listAsPage(WxCouponSend record, Integer pageIndex, Integer pageSize) { @@ -112,30 +122,147 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { } record.setSortColumn(null); record.setSortCol(sortStr); - pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findListVoByValidType(record)); - for (WxCouponSendVo cs : pageInfo.getList()) { - JSONObject jo = JSONObject.parseObject(cs.getConditions()); - int inventory = jo.getIntValue(WxCouponSend.KEY_MERCHANT_LNVENTORY); - cs.setInventory(inventory); - int expired = 0; - if (!DateUtils.isDateBefore(cs.getValidEndDate())) { - expired = 1; - } - cs.setExpired(expired); - } + record.setCouponIds(wxCouponMapper.findSendCouponIds(record.getExpired(),record.getTenantId())); + PageInfo sendPageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findList(record)); + pageInfo = new PageInfo(); + pageInfo.setPageNum(sendPageInfo.getPageNum()); + pageInfo.setPageSize(sendPageInfo.getPageSize()); + pageInfo.setPages(sendPageInfo.getPages()); + pageInfo.setList(couponSendToVoList(record,sendPageInfo.getList(),true,false)); } else { record.setStatus(EnumCouponSendStatus.VALID.getCode()); record.setSortColumns(BaseEntity.SortField.CreateDate_DESC); - pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findListVo(record)); - List couponIds = pageInfo.getList().stream().map(cs -> cs.getCouponId()).collect(Collectors.toList()); - Map couponMerchantMap = wxCouponService.getCouponMerchantMap(couponIds,record); - for (WxCouponSendVo cs:pageInfo.getList()){ - cs.setMerchantName(couponMerchantMap.get(cs.getCouponId())); - cs.setSendCount(wxCouponActionLogService.getCountByChannelId(record, cs.getSendType(), cs.getId())); - } + PageInfo sendPageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponSendMapper.findList(record)); + pageInfo = new PageInfo(); + pageInfo.setPageNum(sendPageInfo.getPageNum()); + pageInfo.setPageSize(sendPageInfo.getPageSize()); + pageInfo.setPages(sendPageInfo.getPages()); + pageInfo.setList(couponSendToVoList(record,sendPageInfo.getList(),false,true)); } return pageInfo; } + + @Override + public List findListVo(WxCouponSend record) { + List couponSendList = wxCouponSendMapper.findList(record); + return couponSendToVoList(record,couponSendList,false,false); + } + + private List couponSendToVoList(TenantEntity tenantEntity,List couponSendList,boolean setInventoryAndExpired,boolean setMerchantNameAndSendCount) { + if (null != couponSendList) { + List couponIdList = new ArrayList<>(); + List mallUserInfoIdList = new ArrayList(); + for (int i = 0 ; i couponMap = new HashMap(); + if (couponIdList.size() > 0 ) { + WxCoupon couponQ = new WxCoupon(); + couponQ.updateTenantInfo(tenantEntity); + couponQ.setIds(couponIdList); + List couponList = wxCouponMapper.findSendCouponList(couponQ); + if (null != couponList) { + for (int k = 0 ; k < couponList.size() ; k++) { + WxCoupon c = couponList.get(k); + couponMap.put(c.getId(), c); + } + } + } + + //获取mallUserInfo + Map mallUserMap = new HashMap(); + if (mallUserInfoIdList.size() > 0 ) { + MallUserInfo mallUserInfoQ = new MallUserInfo(); + mallUserInfoQ.updateTenantInfo(tenantEntity); + mallUserInfoQ.setIds(mallUserInfoIdList); + List userInfoList = mallUserInfoMapper.findList(mallUserInfoQ); + if (null != userInfoList) { + for (int k = 0 ; k < userInfoList.size() ; k++) { + MallUserInfo ui = userInfoList.get(k); + mallUserMap.put(ui.getId(), ui); + } + } + } + + //couponMerchant + Map couponMerchantMap = null; + if (setMerchantNameAndSendCount) { + couponMerchantMap = wxCouponService.getCouponMerchantMap(couponIdList,tenantEntity); + } + List retList = new ArrayList(); + for (int i = 0 ; i couponMap,Map mallUserMap,Map couponMerchantMap, + boolean setInventoryAndExpired,boolean setMerchantNameAndSendCount) { + if (null == cs) { + return null; + } + WxCouponSendVo vo = new WxCouponSendVo(); + try { + BeanUtils.copyProperties(vo, cs); + Long couponId = vo.getCouponId(); + if (null != couponId ) { + WxCoupon coupon = couponMap.get(couponId); + if (null != coupon) { + vo.setRemainInventory(coupon.getRemainInventory()); + vo.setUseLimitRule(coupon.getUseLimitRule()); + vo.setUseLimitQuantity(coupon.getUseLimitQuantity()); + if (setInventoryAndExpired) { + vo.setInventory(cs.getMerchantLnventory()); + int expired = 0; + if (!DateUtils.isDateBefore(coupon.getValidEndDate())) { + expired = 1; + } + cs.setExpired(expired); + }else { + vo.setInventory(coupon.getInventory()); + } + vo.setValidStartDate(coupon.getValidStartDate()); + vo.setValidEndDate(coupon.getValidEndDate()); + vo.setValidDays(coupon.getValidDays()); + } + } + + Long mallUserId = vo.getOperatorId(); + if (null != mallUserId ) { + MallUserInfo user = mallUserMap.get(couponId); + if (null != user) { + vo.setOperator(user.getName()); + } + } + + if (setMerchantNameAndSendCount) { + vo.setMerchantName(couponMerchantMap.get(vo.getCouponId())); + vo.setSendCount(wxCouponActionLogService.getCountByChannelId(vo, vo.getSendType(), vo.getId())); + } + return vo; + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (InvocationTargetException e) { + e.printStackTrace(); + } + return null; + } @Override public WxCouponSend getById(Long id,String tenantId) { @@ -419,7 +546,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { wxCouponSendQuery.setSendType(type.getCode()); wxCouponSendQuery.setStatus(EnumCouponSendStatus.VALID.getCode()); - List wxCouponSends = wxCouponSendMapper.findListVo(wxCouponSendQuery); + List wxCouponSends = findListVo(wxCouponSendQuery); for (WxCouponSend send : wxCouponSends) { boolean checkLimit = false; // 检查疲劳度 @@ -737,7 +864,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { throw new MallinkException(ErrorCode.USER_NOT_AUTH_PHONE); } - List couponSendList = wxCouponSendMapper.findListVo(wxCouponSend); + List couponSendList = findListVo(wxCouponSend); if (CollectionUtils.isEmpty(couponSendList)) { throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java index b3518d137..7d3a21ae1 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -980,7 +980,6 @@ public class WxCouponServiceImpl implements WxCouponService { } List merchantProductVos = wxCouponMerchantMapper.findMerchantProduct(tenantEntity.getTenantId(), merchantIds); -// Map couponMerchantMap = new HashMap(); if (null != merchantProductVos) { for (int i = 0 ; i < merchantProductVos.size(); i ++) { WxMerchantProductVo mp = merchantProductVos.get(i); diff --git a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml index 6d3a5dcb8..05d2ab1c7 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml @@ -274,7 +274,7 @@ + + + + update wx_coupon set is_del = 1 where id = #{id} and tenant_id = #{tenantId} @@ -565,58 +605,6 @@ and cm.`merchant_id` = #{merchantId} - - and JSON_CONTAINS(c.gift_list,json_array(#{giftList})) @@ -1287,4 +1275,5 @@ + diff --git a/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml index 696183dbe..7340b11a2 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponSendMapper.xml @@ -1,7 +1,7 @@ - + @@ -12,30 +12,16 @@ - - - - - - - - - - - + + `id`,`tenant_id`,`parent_tenant_id`,`coupon_id`,`title`,`send_type`,`conditions`,`status`,`create_date`,`update_date`,`send_sms`,`operator_id` - - - - cs.id,cs.tenant_id,cs.parent_tenant_id,cs.coupon_id,cs.title,cs.send_type,cs.conditions,cs.status,cs.create_date,cs.update_date, cs.conditions -> '$.merchantSend' as merchantSend, cs.conditions -> '$.merchantLnventory' as merchantLnventory, - cs.conditions -> '$.merchantRemain' as merchantRemain, - c.remain_inventory, c.use_limit_rule,c.use_limit_quantity, c.inventory, c.valid_start_date, c.valid_end_date,c.valid_type,cs.send_sms,c.valid_days + cs.conditions -> '$.merchantRemain' as merchantRemain - + where 1 = 1 @@ -82,6 +68,12 @@ and cs.conditions -> '$.merchantRemain'> #{merchantRemain} + + and cs.coupon_id in + + #{couponIdItem} + + and cs.id in @@ -94,6 +86,9 @@ order by ${sortColumns} + + order by ${sortCol} + - select - from wx_coupon_send cs - left join wx_coupon c on c.id = cs.coupon_id - - - - + select + from wx_coupon_send cs + + update wx_coupon_send set status=#{status} where coupon_id=#{couponId}