From 906e8245b3b4ae34eed445376df6b8cb56d475f6 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Mon, 21 Sep 2020 11:25:26 +0800 Subject: [PATCH 01/11] fix bug --- .../src/main/java/com/iformall/aop/RedisCacheAspect.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mallinkCApi/src/main/java/com/iformall/aop/RedisCacheAspect.java b/mallinkCApi/src/main/java/com/iformall/aop/RedisCacheAspect.java index 9b712058f..f001c7912 100644 --- a/mallinkCApi/src/main/java/com/iformall/aop/RedisCacheAspect.java +++ b/mallinkCApi/src/main/java/com/iformall/aop/RedisCacheAspect.java @@ -68,7 +68,8 @@ public class RedisCacheAspect { token = request.getParameter("token"); } if(StringUtils.isBlank(token) || "null".equals(token) || "undefined".equals(token)){ - throw new MallinkException(ErrorCode.NET_TOKEN_EMPTY.getCode(),"token为空["+token+"]"); + token=""; + //throw new MallinkException(ErrorCode.NET_TOKEN_EMPTY.getCode(),"token为空["+token+"]"); } log.info("token>>>>>>>>>>>>>>>"+token); String tenantId; From 94120a79b06882975c7608ec2dd57795509bef40 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Mon, 21 Sep 2020 11:26:32 +0800 Subject: [PATCH 02/11] fix bug --- .../src/main/java/com/iformall/aop/RedisCacheAspect.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mallinkCApi/src/main/java/com/iformall/aop/RedisCacheAspect.java b/mallinkCApi/src/main/java/com/iformall/aop/RedisCacheAspect.java index 9b712058f..322525daa 100644 --- a/mallinkCApi/src/main/java/com/iformall/aop/RedisCacheAspect.java +++ b/mallinkCApi/src/main/java/com/iformall/aop/RedisCacheAspect.java @@ -68,7 +68,8 @@ public class RedisCacheAspect { token = request.getParameter("token"); } if(StringUtils.isBlank(token) || "null".equals(token) || "undefined".equals(token)){ - throw new MallinkException(ErrorCode.NET_TOKEN_EMPTY.getCode(),"token为空["+token+"]"); + token = ""; + //throw new MallinkException(ErrorCode.NET_TOKEN_EMPTY.getCode(),"token为空["+token+"]"); } log.info("token>>>>>>>>>>>>>>>"+token); String tenantId; From 1666088524864990f262222c3a2dc780e1434c8c Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Mon, 21 Sep 2020 15:59:23 +0800 Subject: [PATCH 03/11] fix bug --- .../com/iformall/domain/po/WxCUserTags.java | 3 ++ .../mapper/WxCUserBasicInfoMapper.java | 2 + .../iformall/mapper/WxCUserTagsMapper.java | 3 ++ .../impl/WxCUserBasicInfoServiceImpl.java | 51 +++++++++++++------ .../mapper/WxCUserBasicInfoMapper.xml | 11 ++++ .../resources/mapper/WxCUserTagsMapper.xml | 16 ++++++ 6 files changed, 71 insertions(+), 15 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCUserTags.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCUserTags.java index 17ab259a0..0740e4022 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCUserTags.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCUserTags.java @@ -1,5 +1,6 @@ package com.iformall.domain.po; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableName; import com.iformall.domain.po.base.BaseTenantEntity; import lombok.Data; @@ -16,6 +17,8 @@ public class WxCUserTags extends BaseTenantEntity { @io.swagger.annotations.ApiModelProperty(value="c端用户id",name="userId") private Long userId; + @TableField(exist = false) + private List userIds; @io.swagger.annotations.ApiModelProperty(value="",name="tags") private String tags; @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java index a9949651c..545989fee 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCUserBasicInfoMapper.java @@ -53,6 +53,8 @@ public interface WxCUserBasicInfoMapper extends CommonMapper findCountHistory1(@Param("tenantInfo")TenantEntity tenantInfo,@Param("basicInfo")WxCUserBasicInfoDto dto); List findVoList(WxCUserBasicInfo wxCUserBasicInfo); + List findVoIdsList(WxCUserBasicInfo wxCUserBasicInfo); + List findVoList1(@Param("tenantInfo")TenantEntity tenantInfo, @Param("basicInfo")WxCUserBasicInfo basicInfo); Integer countVoList(WxCUserBasicInfo wxCUserBasicInfo); diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java index 98c0a668d..4fc38952d 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java @@ -2,6 +2,7 @@ package com.iformall.mapper; import java.util.Date; import java.util.List; +import java.util.Map; import com.iformall.common.CommonMapper; import com.iformall.domain.po.WxCUserTags; @@ -16,4 +17,6 @@ public interface WxCUserTagsMapper extends CommonMapper { @Param("startTime")Date startTime,@Param("endTime")Date endTime); void updateNewId(CUserTagNewIdVo record); + + Map findUserTagsMap(WxCUserTags wxCUserTags); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java index 16abac583..c7091069f 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java @@ -1220,21 +1220,42 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc @Override public List selectListForExcelExport(Object queryParams, int page) { - Map params = (Map) queryParams; - WxCUserBasicInfo basicInfo = (WxCUserBasicInfo) params.get("basicInfo"); - TenantEntity tenantInfo = (TenantEntity) params.get("tenantInfo"); - List list = new ArrayList(); - basicInfo.setBegin((page-1)*10000); - basicInfo.setLimit(10000); - if(StringUtils.isNotBlank(tenantInfo.getParentTenantId())){ - //关联微信表查询 - list = wxCUserBasicInfoMapper.findVoList1(tenantInfo,basicInfo); - }else{ - //直接查询本表 - basicInfo.undateFinalTenantId(tenantInfo); - list = wxCUserBasicInfoMapper.findVoList(basicInfo); - } - return list; + Map params = (Map) queryParams; + WxCUserBasicInfo basicInfo = (WxCUserBasicInfo) params.get("basicInfo"); + TenantEntity tenantInfo = (TenantEntity) params.get("tenantInfo"); + List list = new ArrayList(); + basicInfo.setBegin((page-1)*10000); + basicInfo.setLimit(10000); + if(StringUtils.isNotBlank(tenantInfo.getParentTenantId())){ + //list = wxCUserBasicInfoMapper.findVoList1(tenantInfo,basicInfo); + }else{ + basicInfo.undateFinalTenantId(tenantInfo); + } + list = wxCUserBasicInfoMapper.findVoList(basicInfo); + List userIds = wxCUserBasicInfoMapper.findVoIdsList(basicInfo); + if (null != userIds ) { + WxCUserTags tq = new WxCUserTags(); + tq.setUserIds(userIds); + Map userTagsMap = wxCUserTagsMapper.findUserTagsMap(tq); + if (null != userTagsMap) { + List tagList = wxTagsMapper.findListAll(); + Map tagMap = tagList.stream().collect(Collectors.toMap(WxTags::getId, WxTags::getName)); + list.stream().forEach(u->{ + List ids = JSONObject.parseArray(userTagsMap.get(u.getId()), Long.class); + if (null != ids) { + String tagNames = StringUtils.join(ids.stream().map(id->tagMap.get(id)).collect(Collectors.toList()),"/"); + u.setTagNames(tagNames); + } + }); + + } + } + if (null != list ) { + List retList = new ArrayList(); + retList.addAll(list); + return retList; + } + return null; } } diff --git a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml index b22a6e21b..724401818 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml @@ -764,6 +764,17 @@ limit #{begin}, #{limit} + + + + + + + + From 45222acd0a07badc22e816a3931e2acf32eba194 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Mon, 21 Sep 2020 17:02:43 +0800 Subject: [PATCH 04/11] =?UTF-8?q?=E6=89=93=E6=A0=87=E7=AD=BE=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../migration/V202009161600__ppsRegulator.sql | 3 + .../schedule/WxCUserTagsSchedule.java | 79 ++++++++++++++----- .../iformall/domain/po/WxCUserBasicInfo.java | 13 ++- .../mapper/WxCUserBasicInfoMapper.xml | 45 +++++++++-- 4 files changed, 116 insertions(+), 24 deletions(-) diff --git a/mallinkAdmin/src/main/resources/db/migration/V202009161600__ppsRegulator.sql b/mallinkAdmin/src/main/resources/db/migration/V202009161600__ppsRegulator.sql index 7ad4c0530..c22544882 100644 --- a/mallinkAdmin/src/main/resources/db/migration/V202009161600__ppsRegulator.sql +++ b/mallinkAdmin/src/main/resources/db/migration/V202009161600__ppsRegulator.sql @@ -13,3 +13,6 @@ from mall_user_info mui left join mall_user_role mur on mui.id = mur.uid where mui.is_admin = 1 and mur.role_id is not null GROUP BY mur.role_id; +ALTER TABLE `wx_c_user_basic_info` +ADD COLUMN `tag_scan_time` DATETIME COMMENT '标签定时扫描时间'; + diff --git a/mallinkSchedule/src/main/java/com/iformall/schedule/WxCUserTagsSchedule.java b/mallinkSchedule/src/main/java/com/iformall/schedule/WxCUserTagsSchedule.java index 7ac17824f..1c19d066a 100644 --- a/mallinkSchedule/src/main/java/com/iformall/schedule/WxCUserTagsSchedule.java +++ b/mallinkSchedule/src/main/java/com/iformall/schedule/WxCUserTagsSchedule.java @@ -1,16 +1,24 @@ package com.iformall.schedule; -import com.github.pagehelper.PageInfo; -import com.iformall.domain.po.WxCUserBasicInfo; -import com.iformall.enums.EnumAssignTagsTrigger; -import com.iformall.service.WxCUserBasicInfoService; -import com.iformall.service.WxCUserTagsService; +import java.util.Calendar; +import java.util.Date; +import java.util.List; + +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; +import com.github.pagehelper.PageInfo; +import com.iformall.domain.po.WxCUserBasicInfo; +import com.iformall.domain.po.WxMall; +import com.iformall.enums.EnumAssignTagsTrigger; +import com.iformall.service.WxCUserBasicInfoService; +import com.iformall.service.WxCUserTagsService; +import com.iformall.service.WxMallService; + @Component public class WxCUserTagsSchedule { @@ -21,22 +29,57 @@ public class WxCUserTagsSchedule { @Autowired WxCUserBasicInfoService wxCUserBasicInfoService; + + @Autowired + WxMallService wxMallService; // TODO 先不执行打标签操作了, 数据量太大,导致数据库CPU 100% //@Scheduled(cron = "0 0 0 25 * ?") // 每月25日凌晨01:00对会员列表扫描补录标签 - //@Scheduled(cron = "0 */5 * * * ?") // 测试1分钟一次 + @Scheduled(cron = "0 0 2 * * ?") // 测试1分钟一次 public void wxCUserTagsSchedule() { - WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); - - int pageIndex = 1; - final int pageSize = 1000; - - PageInfo page; - do{ - page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, pageIndex++, pageSize); - page.getList().stream().forEach(cubi -> { - wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_SCAN, cubi); - }); - } while ((page.isHasNextPage())); + + WxMall wxMall = new WxMall(); + List malls = wxMallService.findList(wxMall); + for (WxMall mall : malls) { + WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); + if (StringUtils.isBlank(mall.getParentTenantId())) { + wxCUserBasicInfo.setFinalTenantId(mall.getTenantId()); + }else { + wxCUserBasicInfo.setFinalTenantId(mall.getParentTenantId()); + } + Date curDate = new Date(); + Calendar startC = Calendar.getInstance(); + startC.setTime(curDate); + startC.add(Calendar.DAY_OF_YEAR, -30); + + Calendar endC = Calendar.getInstance(); + endC.setTime(curDate); + endC.add(Calendar.DAY_OF_YEAR, -5); + //5天内未扫描的,且只扫描1个月内未扫描的 + wxCUserBasicInfo.setScanStartTime(startC.getTime()); + wxCUserBasicInfo.setScanEndTime(endC.getTime()); + + //活跃时间在10天内的 + Calendar startA = Calendar.getInstance(); + startA.setTime(curDate); + startA.add(Calendar.DAY_OF_YEAR, -10); + wxCUserBasicInfo.setActiveStartTime(startA.getTime()); + wxCUserBasicInfo.setActiveEndTime(curDate); + int pageIndex = 1; + final int pageSize = 5000; + + PageInfo page; + do{ + page = wxCUserBasicInfoService.listAsPage(wxCUserBasicInfo, pageIndex++, pageSize); + page.getList().stream().forEach(cubi -> { + try { + wxCUserTagsService.triggerAssignTags(EnumAssignTagsTrigger.ASSIGN_TAGS_TRIGGER_SCAN, cubi); + }catch(Exception e) { + logger.error("wxCUserTagsSchedule error."+cubi.toString(),e); + } + }); + } while ((page.isHasNextPage())); + + } } } \ No newline at end of file diff --git a/mallinkService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java b/mallinkService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java index 6651b6e1e..c1cb1d851 100644 --- a/mallinkService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java +++ b/mallinkService/src/main/java/com/iformall/domain/po/WxCUserBasicInfo.java @@ -73,6 +73,10 @@ public class WxCUserBasicInfo extends TenantEntity { @Excel(name="上次活跃时间",width = 20,format="yyyy-MM-dd", orderNum = "8") @io.swagger.annotations.ApiModelProperty(value="上次活跃时间",name="activeTime") private Date activeTime; + @TableField(exist = false) + private Date activeStartTime; + @TableField(exist = false) + private Date activeEndTime; @Excel(name="注册时间",width = 20,format="yyyy-MM-dd", orderNum = "9") @io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate") @@ -106,9 +110,16 @@ public class WxCUserBasicInfo extends TenantEntity { @io.swagger.annotations.ApiModelProperty(value = "状态0正常1锁定", name = "status") private Integer status; + + @io.swagger.annotations.ApiModelProperty(value = "标签扫描时间", name = "tagScanTime") + private Date tagScanTime; + @TableField(exist = false) + private Date scanStartTime; + @TableField(exist = false) + private Date scanEndTime; @TableField(exist = false) - //@Excel(name="标签",width = 50,orderNum = "10") + @Excel(name="标签",width = 50,orderNum = "10") private String tagNames; diff --git a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml index 724401818..b04edf76f 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml @@ -26,13 +26,13 @@ - + distinct wcubi.`id`,wcubi.`phone`,wcubi.`birthdate`,wcubi.`education`,wcubi.`sex`,wcubi.`email`, wcubi.`address`,wcubi.`poins`,wcubi.`tag_id`,wcubi.`create_date`,wcubi.`update_date`, - wcubi.`final_tenant_id`,wcubi.`name`,wcubi.`nick_name`, + wcubi.`final_tenant_id`,wcubi.`name`,wcubi.`nick_name`,wcubi.`tag_scan_time`, wcubi.`avatar_url`,wcubi.`credit`,wcubi.`active_time`,wcubi.`login_count`,wcubi.`act_record` ,(select level from wx_level_config where poins >= points and tenant_id=wcubi.final_tenant_id @@ -40,7 +40,7 @@ - `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`, + `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`,`tag_scan_time`, `create_date`,`update_date`,`tenant_id`,`parent_tenant_id`,`name`,`nick_name`,`credit`,`active_time`,`act_record` @@ -109,6 +109,14 @@ and wcubi.`create_date` between #{startTime} and #{endTime} + + + and wcubi.`tag_scan_time` between #{scanStartTime} and #{scanEndTime} + + + + and wcubi.`active_time` between #{activeStartTime} and #{activeEndTime} + and wcubi.`status` = #{status} @@ -204,6 +212,14 @@ and wcubi.`create_date` between #{basicInfo.startTime} and #{basicInfo.endTime} + + and wcubi.`tag_scan_time` between #{scanStartTime} and #{scanEndTime} + + + + and wcubi.`active_time` between #{activeStartTime} and #{activeEndTime} + + and wcubi.`status` = #{basicInfo.status} @@ -390,7 +406,7 @@ distinct cub.id,cub.phone,cub.birthdate,cub.education,cub.sex,cub.email,cub.address,cub.poins,cub.tag_id, - cub.create_date,cub.update_date,cub.name,cub.level,cub.nick_name,cub.score_date,cub.final_tenant_id + cub.create_date,cub.update_date,cub.name,cub.level,cub.nick_name,cub.score_date,cub.final_tenant_id,cub.tag_scan_time + + + update wx_coupon set valid_end_date = #{validEndDate} , update_date = #{updateDate} where id = #{id} + diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml index a167bd8c3..1ff927370 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml @@ -1393,5 +1393,9 @@ where co.coupon_id = c.id and co.id = a.id and co.id = #{id} + + + update wx_coupon_order set coupon_order_status = 4,update_date = now() where coupon_id = #{couponId} and coupon_order_status = 5 + \ No newline at end of file diff --git a/mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml index 0ffe0e054..3d5357bed 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponPasswordMapper.xml @@ -195,5 +195,9 @@ and `parent_tenant_id` = #{parentTenantId} + + + update wx_coupon_password set expire_date = #{expiredTime} , update_date = now() where coupon_id = #{couponId} + From 7754e6cc0b1cf5178c7cbb635f94e9f690ab22ad Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Mon, 21 Sep 2020 17:58:17 +0800 Subject: [PATCH 06/11] =?UTF-8?q?=E5=8D=A1=E5=BB=B6=E6=9C=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/iformall/mapper/WxCouponOrderMapper.java | 2 +- .../java/com/iformall/service/impl/WxCouponServiceImpl.java | 2 +- .../src/main/resources/mapper/WxCouponOrderMapper.xml | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java index 3fe1009e0..7696aa217 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java @@ -83,5 +83,5 @@ public interface WxCouponOrderMapper extends CommonMapper { List findAvailCouponOrder(Map params); //卡延期,将过期的状态变为使用中 - void cardDefer(@Param("couponId")Long couponId); + void cardDefer(@Param("couponId")Long couponId,@Param("expireTime")Date expireTime); } 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 fb8805c47..c2b3ef9ea 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -762,7 +762,7 @@ public class WxCouponServiceImpl implements WxCouponService { wxCouponMapper.updateValidEndDate(coupon); //更新coupon_order的状态,已过期的变为使用中 5-->4 - wxCouponOrderMapper.cardDefer(id); + wxCouponOrderMapper.cardDefer(id,validEndDate); //更新coupon_passwd couponPasswordMapper.updateExpiredTime(id, validEndDate); diff --git a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml index 1ff927370..4403ed34d 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml @@ -1394,8 +1394,8 @@ and co.id = #{id} - - update wx_coupon_order set coupon_order_status = 4,update_date = now() where coupon_id = #{couponId} and coupon_order_status = 5 + + update wx_coupon_order set coupon_order_status = 4,update_date = now(), expired_time= #{expireTime} where coupon_id = #{couponId} and coupon_order_status = 5 \ No newline at end of file From 201d9d1fe3484c4946935889549c32e49969a293 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Tue, 22 Sep 2020 09:54:23 +0800 Subject: [PATCH 07/11] fix --- .../main/java/com/iformall/mapper/WxCouponChannelMapper.java | 2 ++ .../java/com/iformall/service/impl/WxCouponServiceImpl.java | 3 +++ .../src/main/resources/mapper/WxCouponChannelMapper.xml | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java index 332e4a631..dbd4d98e3 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCouponChannelMapper.java @@ -40,4 +40,6 @@ public interface WxCouponChannelMapper extends CommonMapper findQrcodeEmptyList(); + + void cardDefer(@Param("couponId")Long couponId,@Param("endTime")Date endTime); } 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 c2b3ef9ea..b26ea4c2c 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponServiceImpl.java @@ -761,6 +761,9 @@ public class WxCouponServiceImpl implements WxCouponService { coupon.setUpdateDate(new Date()); wxCouponMapper.updateValidEndDate(coupon); + //更新coupon_channel + wxCouponChannelMapper.cardDefer(id, validEndDate); + //更新coupon_order的状态,已过期的变为使用中 5-->4 wxCouponOrderMapper.cardDefer(id,validEndDate); diff --git a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml index a58e02773..0f67821a6 100644 --- a/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCouponChannelMapper.xml @@ -394,6 +394,10 @@ + + + update wx_coupon_channel set end_time = #{endTime} where coupon_id = #{couponId} and target_ad = 5 and type = 100 + From b2519ececb32fea89fa59fb80ca3959b52c3a9d0 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Tue, 22 Sep 2020 13:59:30 +0800 Subject: [PATCH 08/11] fix --- .../resources/mapper/WxCUserBasicInfoMapper.xml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml index b04edf76f..b132d1285 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml @@ -212,12 +212,12 @@ and wcubi.`create_date` between #{basicInfo.startTime} and #{basicInfo.endTime} - - and wcubi.`tag_scan_time` between #{scanStartTime} and #{scanEndTime} + + and wcubi.`tag_scan_time` between #{basicInfo.scanStartTime} and #{basicInfo.scanEndTime} - - and wcubi.`active_time` between #{activeStartTime} and #{activeEndTime} + + and wcubi.`active_time` between #{basicInfo.activeStartTime} and #{basicInfo.activeEndTime} @@ -772,12 +772,12 @@ and cu.`create_date` between #{basicInfo.startTime} and #{basicInfo.endTime} - - and wcubi.`tag_scan_time` between #{scanStartTime} and #{scanEndTime} + + and wcubi.`tag_scan_time` between #{basicInfo.scanStartTime} and #{basicInfo.scanEndTime} - - and wcubi.`active_time` between #{activeStartTime} and #{activeEndTime} + + and wcubi.`active_time` between #{basicInfo.activeStartTime} and #{basicInfo.activeEndTime} From e0ce74704d5a27683bab2dbff6679c197cafe1b0 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Tue, 22 Sep 2020 14:13:03 +0800 Subject: [PATCH 09/11] fix --- .../src/main/resources/mapper/WxCUserTagsMapper.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml index 0788bcdca..c78c29e93 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml @@ -95,8 +95,8 @@ - + select user_id as 'key' ,tags as 'value' from wx_c_user_tags From f33993d5804b90abf600477d228c9fd5b2bbd50a Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Tue, 22 Sep 2020 14:48:02 +0800 Subject: [PATCH 10/11] fix --- .../main/java/com/iformall/mapper/WxCUserTagsMapper.java | 2 -- .../iformall/service/impl/WxCUserBasicInfoServiceImpl.java | 7 +++++-- .../src/main/resources/mapper/WxCUserTagsMapper.xml | 6 ------ 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java b/mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java index 4fc38952d..99b983566 100644 --- a/mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java +++ b/mallinkService/src/main/java/com/iformall/mapper/WxCUserTagsMapper.java @@ -17,6 +17,4 @@ public interface WxCUserTagsMapper extends CommonMapper { @Param("startTime")Date startTime,@Param("endTime")Date endTime); void updateNewId(CUserTagNewIdVo record); - - Map findUserTagsMap(WxCUserTags wxCUserTags); } diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java index c7091069f..80e6231ae 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCUserBasicInfoServiceImpl.java @@ -1236,10 +1236,13 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService,IExc if (null != userIds ) { WxCUserTags tq = new WxCUserTags(); tq.setUserIds(userIds); - Map userTagsMap = wxCUserTagsMapper.findUserTagsMap(tq); - if (null != userTagsMap) { + List userTagList = wxCUserTagsMapper.findList(tq); + if (null != userTagList) { List tagList = wxTagsMapper.findListAll(); Map tagMap = tagList.stream().collect(Collectors.toMap(WxTags::getId, WxTags::getName)); + + Map userTagsMap = userTagList.stream().collect(Collectors.toMap(WxCUserTags::getUserId, WxCUserTags::getTags)); + list.stream().forEach(u->{ List ids = JSONObject.parseArray(userTagsMap.get(u.getId()), Long.class); if (null != ids) { diff --git a/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml index c78c29e93..6f8ec4293 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserTagsMapper.xml @@ -95,12 +95,6 @@ - - From 848def2c4bfe69357bd43dbe525cc5074534bdc1 Mon Sep 17 00:00:00 2001 From: xiaohanzi Date: Tue, 22 Sep 2020 17:31:57 +0800 Subject: [PATCH 11/11] fix bug --- .../impl/WxCouponOrderServiceImpl.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java index 934a4b6c1..9c931d5e8 100644 --- a/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java +++ b/mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java @@ -1353,7 +1353,13 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { throw new MallinkException(ErrorCode.VERIFY_ERROR.getCode(), "updatete num " + num); } } - + WxAppinfo appInfo = wxAppinfoService.getCAppInfo(bUser,payWay); + WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); + EnumPayShare isShare = EnumPayShare.NO; + if (payAccount.checkShare()) { + isShare = EnumPayShare.YES; + } + final Integer shareCode = isShare.getCode(); // 添加payOrder final IdWorker idWorker = IdWorker.get(); Long payOrderId = idWorker.nextId(); @@ -1370,7 +1376,8 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { setPayOrderNo(String.valueOf(payOrderId)); setIp(ipstr); setAuthCode(authCode); - setPayAmount(microOrder.getPayment() - wxCoupon.getPrice()); + Integer payAmount = microOrder.getPayment() - wxCoupon.getPrice(); + setPayAmount(payAmount); // if (microOrder.getPayment() > wxCoupon.getPrice()) { // setPayAmount(wxCoupon.getPrice()); // } else { @@ -1378,7 +1385,20 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { // } setPayVendor(payWay.getCode()); setPayOrderStatus(EnumPayStatus.PAY_STATUS_WAIT.getCode()); - setShare(EnumPayShare.NO.getCode()); + setShare(shareCode); + if (shareCode.intValue() == EnumPayShare.YES.getCode().intValue()) { + // 分账金额 + int iChargeFee = PayUtils.getPayRate(payAmount, payAccount.getRate(), false); + Integer share_amount = payAmount - iChargeFee; + setShareAmount(share_amount); + if(payAccount.getRealRate() != null) { + int iRealChargeFee = PayUtils.getPayRate(payAmount, payAccount.getRealRate(), true); + setRateAmount(iRealChargeFee); + } + if (share_amount <= 0) { + setShare(EnumPayShare.NO.getCode()); + } + } setPayFrom(EnumPayFrom.INSIDE_B.getCode()); setPosPayOrderId(couponOrder.getId()); }};