From fe92cec8c20b3753e95f976d9298689fed205a8d Mon Sep 17 00:00:00 2001 From: xhxu Date: Mon, 28 Dec 2020 18:21:56 +0800 Subject: [PATCH] jifen --- .../controller/WxCouponSendController.java | 2 +- .../iformall/schedule/CouponSendSchedule.java | 4 +-- .../iformall/domain/po/WxCouponActionLog.java | 5 ++++ .../service/WxCouponActionLogService.java | 2 +- .../iformall/service/WxCouponSendService.java | 2 +- .../impl/WxCouponActionLogServiceImpl.java | 21 ++++++++------- .../impl/WxCouponInjectServiceImpl.java | 2 +- .../service/impl/WxCouponSendServiceImpl.java | 26 +++++++++---------- .../service/impl/WxOrderServiceImpl.java | 2 +- .../mapper/WxCouponActionLogMapper.xml | 3 ++- 10 files changed, 38 insertions(+), 31 deletions(-) diff --git a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java index 95d4466a3..1fc61603e 100644 --- a/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java +++ b/mallinkBApi/src/main/java/com/iformall/controller/WxCouponSendController.java @@ -102,7 +102,7 @@ public class WxCouponSendController extends BaseController { wxCouponSend.setSendType(EnumCouponSendSendType.MERCHANT.getCode()); wxCouponSend.setStatus(EnumCouponSendStatus.VALID.getCode()); try { - wxCouponSendService.handSel(wxCouponSend, Long.parseLong(cUserId),EnumPayWay.PAY_WAY_NOT_UNPAY_MERCHANT); + wxCouponSendService.handSel(wxCouponSend, Long.parseLong(cUserId),EnumPayWay.PAY_WAY_NOT_UNPAY_MERCHANT,getWxBuserId()); } catch (MallinkException e) { logger.error("注券异常: ", e); return new ResultData(e.getErrorCode(), e.getMessage()); diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java index dde758d91..ced1d89dc 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/CouponSendSchedule.java @@ -192,7 +192,7 @@ public class CouponSendSchedule { // 发放免费券 try { WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cu.getId(), cs,cs.getCouponId(), null,EnumPayWay.PAY_WAY_NOT_UNPAY_SYSTEM_SEND); - wxCouponActionLogService.addOne(tenantEntity, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId()); + wxCouponActionLogService.addOne(tenantEntity, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId(),0L); } catch (Exception e) { logger.error("定时发券:发券失败 levelId=" + l.getId() + " couponId=" + cs.getCouponId() + " userId=" + cu.getId() + e.getMessage()); continue; @@ -322,7 +322,7 @@ public class CouponSendSchedule { // 发放生日券 try { WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cu.getId(),cs, cs.getCouponId(), null,EnumPayWay.PAY_WAY_NOT_UNPAY_SYSTEM_SEND); - wxCouponActionLogService.addOne(tenantEntity, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId()); + wxCouponActionLogService.addOne(tenantEntity, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId(), 0L); couponSendedUsers.add(cu); } catch (Exception e) { logger.error("定时发券:发券失败 levelId=" + cu.getId() + " couponId=" + cs.getCouponId() + " userId=" + cu.getId() + e.getMessage()); diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponActionLog.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponActionLog.java index 37f666986..95c1f8e07 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCouponActionLog.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCouponActionLog.java @@ -2,6 +2,7 @@ package com.iformall.domain.po; import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonIgnore; import com.iformall.domain.po.base.TenantEntity; import lombok.Data; import lombok.EqualsAndHashCode; @@ -36,4 +37,8 @@ public class WxCouponActionLog extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value="月日",name="createTimeMd") private String createTimeMd; + @JsonIgnore + @io.swagger.annotations.ApiModelProperty(value="操作人ID",name="operatorId") + private Long operatorId; + } diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponActionLogService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponActionLogService.java index d2a8046b8..bddd6bdca 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponActionLogService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponActionLogService.java @@ -42,7 +42,7 @@ public interface WxCouponActionLogService { void deleteById(Long id,String tenantId); - void addOne(TenantEntity tenantEntity,Long couponId,Long coupon_order_id,int channelType,Long channelId); + void addOne(TenantEntity tenantEntity,Long couponId,Long coupon_order_id,int channelType,Long channelId,Long bUserId); int getCountByChannelId(TenantEntity tenantEntity, int channelType, Long channelId); diff --git a/mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java b/mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java index c4b75e144..a5ca39b7d 100644 --- a/mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java +++ b/mallinkService/src/main/java/com/iformall/service/WxCouponSendService.java @@ -96,7 +96,7 @@ public interface WxCouponSendService { * * @param wxCouponSend */ - void handSel(WxCouponSend wxCouponSend,Long cUserId,EnumPayWay payWay) ; + void handSel(WxCouponSend wxCouponSend,Long cUserId,EnumPayWay payWay,Long bUserId) ; } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java index 251ab5748..903be3bbf 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponActionLogServiceImpl.java @@ -56,17 +56,18 @@ public class WxCouponActionLogServiceImpl implements WxCouponActionLogService { } @Override - public void addOne(TenantEntity tenantEntity, Long couponId, Long coupon_order_id, int channelType, Long channelId) { + public void addOne(TenantEntity tenantEntity, Long couponId, Long coupon_order_id, int channelType, Long channelId,Long bUserId) { Date curDate = new Date(); - WxCouponActionLog actionLog = new WxCouponActionLog() {{ - updateTenantInfo(tenantEntity); - setCouponId(couponId); - setChannelId(channelId); - setCouponOrderId(coupon_order_id); - setChannelType(channelType); - setCreateTime(curDate); - setCreateTimeMd(new SimpleDateFormat("MM/dd").format(curDate)); - }}; + WxCouponActionLog actionLog = new WxCouponActionLog(); + actionLog.updateTenantInfo(tenantEntity); + actionLog.setCouponId(couponId); + actionLog.setChannelId(channelId); + actionLog.setCouponOrderId(coupon_order_id); + actionLog.setChannelType(channelType); + actionLog.setCreateTime(curDate); + actionLog.setCreateTimeMd(new SimpleDateFormat("MM/dd").format(curDate)); + actionLog.setOperatorId(bUserId); + saveOrUpdate(actionLog); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponInjectServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponInjectServiceImpl.java index 0a8508c5d..2d6a32936 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponInjectServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponInjectServiceImpl.java @@ -276,7 +276,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { try { couponOrder = wxOrderService.sendFreeCouponToUser(tempCUser.getId(),wxCoupon, wxCoupon.getId(),null,EnumPayWay.PAY_WAY_NOT_UNPAY_BATCH_SEND); if (couponOrder != null) { - wxCouponActionLogService.addOne(couponOrder, wxCoupon.getId(), couponOrder.getId(), EnumCouponSendSendType.INJECT.getCode(), couponInjectId); + wxCouponActionLogService.addOne(couponOrder, wxCoupon.getId(), couponOrder.getId(), EnumCouponSendSendType.INJECT.getCode(), couponInjectId,0L); } } catch (MallinkException e) { logger.error(e.getMessage()); 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 cc6dec98f..c6c63d459 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponSendServiceImpl.java @@ -72,21 +72,21 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { @Override public PageInfo listAsPage(WxCouponSend record, Integer pageIndex, Integer pageSize) { PageInfo pageInfo; - /** - * 设置商户购买券数 - * 前端排序:时间、商户总库存、商户已发数、商户剩余 - */ + /** + * 设置商户购买券数 + * 前端排序:时间、商户总库存、商户已发数、商户剩余 + */ if (Objects.equals(EnumCouponSendSendType.MERCHANT.getCode(), record.getSendType())) { String sortStr = null; - if (Objects.equals(record.getSortColumn(), WxCouponSend.SORT_MERCHANT_LNVENTORY) || - Objects.equals(record.getSortColumn(), WxCouponSend.SORT_MERCHANT_SEND) || + if (Objects.equals(record.getSortColumn(), WxCouponSend.SORT_MERCHANT_LNVENTORY) || + Objects.equals(record.getSortColumn(), WxCouponSend.SORT_MERCHANT_SEND) || Objects.equals(record.getSortColumn(), WxCouponSend.SORT_REMAIN)) { sortStr = record.getSortColumn() + " " + record.getSortOrder(); } else if (Objects.equals(record.getSortColumn(), "createDate")) { sortStr = "create_date" + " " + record.getSortOrder(); } - record.setSortColumn(null); - record.setSortCol(sortStr); + 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()); @@ -375,7 +375,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { if (couponOrder != null) { bRet = true; - wxCouponActionLogService.addOne(couponOrder, send.getCouponId(), couponOrder.getId(), type.getCode(), send.getId()); + wxCouponActionLogService.addOne(couponOrder, send.getCouponId(), couponOrder.getId(), type.getCode(), send.getId(),0L); // 发送消息 if (couponOrder != null) { @@ -430,8 +430,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { List appList = wxAppinfoService.getList(appinfoQ); appName = appList.get(0).getName(); }else { - WxAppinfo appInfo = wxAppinfoService.getCAppInfo(tenantEntity,payw); - appName = appInfo.getName(); + WxAppinfo appInfo = wxAppinfoService.getCAppInfo(tenantEntity,payw); + appName = appInfo.getName(); } Map msgReplaceMap = new HashMap(); msgReplaceMap.put("title", title); @@ -628,7 +628,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { @Override @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) - public void handSel(WxCouponSend wxCouponSend, Long cUserId,EnumPayWay payWay) { + public void handSel(WxCouponSend wxCouponSend, Long cUserId,EnumPayWay payWay,Long bUserId) { WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(cUserId,wxCouponSend.getFinalTenantId()); if (Objects.isNull(wxCUserBasicInfo)) { @@ -643,7 +643,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { // 发放免费券 WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cUserId,cs, cs.getCouponId(), cs,payWay); if (couponOrder != null) { - wxCouponActionLogService.addOne(couponOrder, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId()); + wxCouponActionLogService.addOne(couponOrder, cs.getCouponId(), couponOrder.getId(), cs.getSendType(), cs.getId(),bUserId); sendMsgForSendCoupon(couponOrder, cs, couponOrder, wxCUserBasicInfo); } else { logger.warn("handSel couponOrder is null"); diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java index edbc1f53b..346a04ab2 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxOrderServiceImpl.java @@ -2017,7 +2017,7 @@ public class WxOrderServiceImpl implements WxOrderService { } // couponActionLog try { - wxCouponActionLogService.addOne(order, order.getProductId(), order.getOrderNumber(), EnumCouponSendSendType.ACTIVE.getCode(), orderSaveDto.getCouponChannelId()); + wxCouponActionLogService.addOne(order, order.getProductId(), order.getOrderNumber(), EnumCouponSendSendType.ACTIVE.getCode(), orderSaveDto.getCouponChannelId(),0L); } catch (Exception e) { // 库存恢复 stockBack(order); diff --git a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml index 724dbfb4f..6d3a5dcb8 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponActionLogMapper.xml @@ -346,7 +346,8 @@ LEFT JOIN wx_coupon_order co ON cal.coupon_order_id = co.id LEFT JOIN wx_coupon c ON cal.coupon_id = c.id LEFT JOIN wx_c_user_basic_info cu ON cu.id = co.c_user_id - LEFT JOIN wx_merchant_b_user mbu ON concat(mbu.merchant_id,'') = JSON_EXTRACT(cs.conditions , '$.id') + LEFT JOIN wx_merchant_b_user mbu ON mbu.id = cal.operator_id + WHERE cal.channel_type = #{channelType} AND cs.conditions -> '$.id' = concat(#{merchantId},'')