| @@ -49,6 +49,9 @@ public class WxCUserBasicInfo extends TenantEntity { | |||||
| @io.swagger.annotations.ApiModelProperty(value="用户昵称",name="nickName") | @io.swagger.annotations.ApiModelProperty(value="用户昵称",name="nickName") | ||||
| private String nickName; | private String nickName; | ||||
| @io.swagger.annotations.ApiModelProperty(value="用户头像地址",name="avatarUrl") | |||||
| private String avatarUrl; | |||||
| @Excel(name="学历",width = 20,orderNum = "5") | @Excel(name="学历",width = 20,orderNum = "5") | ||||
| @NotNull | @NotNull | ||||
| @io.swagger.annotations.ApiModelProperty(value="学历",name="education") | @io.swagger.annotations.ApiModelProperty(value="学历",name="education") | ||||
| @@ -8,10 +8,7 @@ import com.iformall.common.ErrorCode; | |||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.Result; | import com.iformall.common.Result; | ||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.po.WxActivity; | |||||
| import com.iformall.domain.po.WxActivityJoin; | |||||
| import com.iformall.domain.po.WxCUser; | |||||
| import com.iformall.domain.po.WxCreditHistory; | |||||
| import com.iformall.domain.po.*; | |||||
| import com.iformall.domain.po.msg.WxMsgRecord; | import com.iformall.domain.po.msg.WxMsgRecord; | ||||
| import com.iformall.domain.vo.WxActivityJoinQuestionAnswer; | import com.iformall.domain.vo.WxActivityJoinQuestionAnswer; | ||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| @@ -175,7 +172,7 @@ public class WxActivityJoinServiceImpl implements WxActivityJoinService { | |||||
| if (count > 0) { | if (count > 0) { | ||||
| return new ResultData(ErrorCode.ACTIVITY_JOINED); | return new ResultData(ErrorCode.ACTIVITY_JOINED); | ||||
| } | } | ||||
| WxCUser user = wxCUserMapper.selectById(wxActivityJoin.getUserId()); | |||||
| WxCUserBasicInfo user = wxCUserBasicInfoMapper.selectById(wxActivityJoin.getUserId()); | |||||
| //查询是否消耗积分 | //查询是否消耗积分 | ||||
| WxActivity wxActivity = wxActivityMapper.selectById(wxActivityJoin.getActivityId()); | WxActivity wxActivity = wxActivityMapper.selectById(wxActivityJoin.getActivityId()); | ||||
| Date date = new Date(); | Date date = new Date(); | ||||
| @@ -187,7 +184,7 @@ public class WxActivityJoinServiceImpl implements WxActivityJoinService { | |||||
| wxCreditHistory.setCUserId(wxActivityJoin.getUserId()); | wxCreditHistory.setCUserId(wxActivityJoin.getUserId()); | ||||
| wxCreditHistory.setCreditNum(credit); | wxCreditHistory.setCreditNum(credit); | ||||
| wxCreditHistory.setCreditType(EnumScoreType.ACTIVITY_JOIN.getCode()); | wxCreditHistory.setCreditType(EnumScoreType.ACTIVITY_JOIN.getCode()); | ||||
| wxCreditHistory.setOperatorType(EnumUserType.CUSER.getCode()); | |||||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||||
| wxCreditHistory.setOperatorId(wxActivityJoin.getUserId()); | wxCreditHistory.setOperatorId(wxActivityJoin.getUserId()); | ||||
| wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | ||||
| } | } | ||||
| @@ -305,7 +305,7 @@ public class WxCUserServiceImpl implements WxCUserService { | |||||
| wxCreditHistory.updateTenantInfo(user); | wxCreditHistory.updateTenantInfo(user); | ||||
| wxCreditHistory.setCreateDate(new Date()); | wxCreditHistory.setCreateDate(new Date()); | ||||
| wxCreditHistory.setCreditType(enumScoreType.getCode()); | wxCreditHistory.setCreditType(enumScoreType.getCode()); | ||||
| wxCreditHistory.setOperatorType(EnumUserType.CUSER.getCode()); | |||||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||||
| wxCreditHistory.setOperatorId(user.getUserId()); | wxCreditHistory.setOperatorId(user.getUserId()); | ||||
| wxCreditHistory.setCreditNum(user.getCredit()); | wxCreditHistory.setCreditNum(user.getCredit()); | ||||
| wxCreditHistory.setCreditAmount(user.getCredit()); | wxCreditHistory.setCreditAmount(user.getCredit()); | ||||
| @@ -291,7 +291,7 @@ public class WxCardSpendServiceImpl implements WxCardSpendService { | |||||
| try { | try { | ||||
| //-------此处为【现金支付】记录增加积分操作------- | //-------此处为【现金支付】记录增加积分操作------- | ||||
| WxCreditHistory creditHistory = new WxCreditHistory(); | WxCreditHistory creditHistory = new WxCreditHistory(); | ||||
| creditHistory.setOperatorType(EnumUserType.CUSER.getCode()); | |||||
| creditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||||
| creditHistory.setOperatorId(record.getOwnerId()); | creditHistory.setOperatorId(record.getOwnerId()); | ||||
| creditHistory.setCUserId(record.getOwnerId()); | creditHistory.setCUserId(record.getOwnerId()); | ||||
| creditHistory.setCreateDate(new Date()); | creditHistory.setCreateDate(new Date()); | ||||
| @@ -167,7 +167,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { | |||||
| couponInjectMapper.insert(record); | couponInjectMapper.insert(record); | ||||
| if(record.getSendType().equals(EnumCouponInjectSendType.IMMEDIATE.getCode())) { | if(record.getSendType().equals(EnumCouponInjectSendType.IMMEDIATE.getCode())) { | ||||
| List<WxCUser> sentUsers = sendCoupon(wxCoupon, userList, record); | |||||
| List<WxCUserBasicInfo> sentUsers = sendCoupon(wxCoupon, userList, record); | |||||
| if (sentUsers.size() > 0) { | if (sentUsers.size() > 0) { | ||||
| record.setStatus(EnumCouponInjectStatus.HAS_SENT.getCode()); | record.setStatus(EnumCouponInjectStatus.HAS_SENT.getCode()); | ||||
| //发送短信 | //发送短信 | ||||
| @@ -182,7 +182,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| private ResultData sendMsg(WxCouponInject record, List<WxCUser> cUsers) { | |||||
| private ResultData sendMsg(WxCouponInject record, List<WxCUserBasicInfo> cUsers) { | |||||
| //根据模板ID查询短信信息 | //根据模板ID查询短信信息 | ||||
| WxMsgModel model = wxMsgModelService.getById(record.getModelId()); | WxMsgModel model = wxMsgModelService.getById(record.getModelId()); | ||||
| @@ -214,7 +214,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { | |||||
| return new ResultData(ErrorCode.MSG_NO_VALID_PHONE); | return new ResultData(ErrorCode.MSG_NO_VALID_PHONE); | ||||
| } | } | ||||
| StringBuilder sb=new StringBuilder(); | StringBuilder sb=new StringBuilder(); | ||||
| for(WxCUser user:cUsers){ | |||||
| for(WxCUserBasicInfo user:cUsers){ | |||||
| String phone = user.getPhone(); | String phone = user.getPhone(); | ||||
| if(null!=phone && !phone.equals("")){ | if(null!=phone && !phone.equals("")){ | ||||
| sb.append(phone).append(","); | sb.append(phone).append(","); | ||||
| @@ -244,16 +244,15 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { | |||||
| return new ResultData(); | return new ResultData(); | ||||
| } | } | ||||
| private List<WxCUser> sendCoupon(WxCoupon wxCoupon,List<WxCUserBasicInfo> cUsers,WxCouponInject record){ | |||||
| private List<WxCUserBasicInfo> sendCoupon(WxCoupon wxCoupon,List<WxCUserBasicInfo> cUsers,WxCouponInject record){ | |||||
| //查询标签用户 | //查询标签用户 | ||||
| List<WxCUser> sentUsers = new ArrayList<WxCUser>(); | |||||
| List<WxCUserBasicInfo> sentUsers = new ArrayList<WxCUserBasicInfo>(); | |||||
| for (WxCUserBasicInfo tempCUserBasicInfo : cUsers) { | for (WxCUserBasicInfo tempCUserBasicInfo : cUsers) { | ||||
| WxCUser tempCUser = wxCUserService.getById(tempCUserBasicInfo.getId()); | |||||
| if (tempCUser != null) { | |||||
| boolean bResult = sendCouponToUser(tempCUser, wxCoupon, record.getId()); | |||||
| if (tempCUserBasicInfo != null) { | |||||
| boolean bResult = sendCouponToUser(tempCUserBasicInfo, wxCoupon, record.getId()); | |||||
| if (bResult) { | if (bResult) { | ||||
| sentUsers.add(tempCUser); | |||||
| sentUsers.add(tempCUserBasicInfo); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @@ -261,7 +260,7 @@ public class WxCouponInjectServiceImpl implements WxCouponInjectService { | |||||
| } | } | ||||
| private boolean sendCouponToUser(WxCUser tempCUser,WxCoupon wxCoupon,Long couponInjectId) { | |||||
| private boolean sendCouponToUser(WxCUserBasicInfo tempCUser,WxCoupon wxCoupon,Long couponInjectId) { | |||||
| boolean checkLimit = false; | boolean checkLimit = false; | ||||
| // 检查疲劳度 | // 检查疲劳度 | ||||
| try { | try { | ||||
| @@ -440,7 +440,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| try { | try { | ||||
| //-------此处为【现金支付】记录增加积分操作------- | //-------此处为【现金支付】记录增加积分操作------- | ||||
| WxCreditHistory creditHistory = new WxCreditHistory(); | WxCreditHistory creditHistory = new WxCreditHistory(); | ||||
| creditHistory.setOperatorType(EnumUserType.CUSER.getCode()); | |||||
| creditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||||
| creditHistory.setOperatorId(cuUser.getId()); | creditHistory.setOperatorId(cuUser.getId()); | ||||
| creditHistory.setCUserId(couponOrder.getcUserId()); | creditHistory.setCUserId(couponOrder.getcUserId()); | ||||
| creditHistory.setCreateDate(new Date()); | creditHistory.setCreateDate(new Date()); | ||||
| @@ -737,10 +737,10 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||||
| // 4. get user info | // 4. get user info | ||||
| WxCUser user = null; | WxCUser user = null; | ||||
| WxCUser userQ = new WxCUser(); | |||||
| userQ.setTenantId(bUser.getTenantId()); | |||||
| userQ.setUserId(couponOrder.getCUserId()); | |||||
| List<WxCUser> list = wxCUserMapper.findList(userQ); | |||||
| List<WxCUser> list = wxCUserMapper.findList(new WxCUser(){{ | |||||
| updateTenantInfo(bUser); | |||||
| setUserId(couponOrder.getCUserId()); | |||||
| }}); | |||||
| if(list != null && list.size() > 0){ | if(list != null && list.size() > 0){ | ||||
| user = list.get(0); | user = list.get(0); | ||||
| } | } | ||||
| @@ -375,15 +375,9 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| wxCouponActionLogService.addOne(couponOrder, send.getCouponId(), couponOrder.getId(), type.getCode(), send.getId()); | wxCouponActionLogService.addOne(couponOrder, send.getCouponId(), couponOrder.getId(), type.getCode(), send.getId()); | ||||
| // 查找cUser | |||||
| WxCUser user = wxCUserMapper.selectById(cUserId); | |||||
| if (user == null) { | |||||
| continue; | |||||
| } | |||||
| // 发送消息 | // 发送消息 | ||||
| if (couponOrder != null) { | if (couponOrder != null) { | ||||
| sendMsgForSendCoupon(couponOrder, send, couponOrder, user); | |||||
| sendMsgForSendCoupon(couponOrder, send, couponOrder, wxCUserBasicInfo); | |||||
| } | } | ||||
| bRet = true; | bRet = true; | ||||
| @@ -398,9 +392,20 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| return bRet; | return bRet; | ||||
| } | } | ||||
| private void sendMsgForSendCoupon(TenantEntity tenantEntity, WxCouponSend send, WxCouponOrder couponOrder, WxCUser user) { | |||||
| // 发送微信模板消息(公众号模板消息/小程序统一消息/小程序模板消息) | |||||
| sendMpMsgForSendCoupon(send, couponOrder, user); | |||||
| private void sendMsgForSendCoupon(TenantEntity tenantEntity, WxCouponSend send, WxCouponOrder couponOrder, WxCUserBasicInfo user) { | |||||
| List<WxCUser> list = wxCUserMapper.findList(new WxCUser(){{ | |||||
| updateTenantInfo(tenantEntity); | |||||
| setUserId(couponOrder.getCUserId()); | |||||
| }}); | |||||
| if(list != null && list.size() > 0){ | |||||
| WxCUser cuser = list.get(0); | |||||
| if(cuser != null){ | |||||
| // 发送微信模板消息(公众号模板消息/小程序统一消息/小程序模板消息) | |||||
| sendMpMsgForSendCoupon(send, couponOrder, cuser); | |||||
| } | |||||
| } | |||||
| // 发送短信 | // 发送短信 | ||||
| if (send.getSendSms().equals(EnumCouponSendSms.YES.getCode())) { | if (send.getSendSms().equals(EnumCouponSendSms.YES.getCode())) { | ||||
| @@ -491,7 +496,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| // 8. 微信小程序-统一消息 | // 8. 微信小程序-统一消息 | ||||
| // 检查是否超限 | // 检查是否超限 | ||||
| WxMsgLimit msgLimit = new WxMsgLimit(); | WxMsgLimit msgLimit = new WxMsgLimit(); | ||||
| msgLimit.updateTenantInfo(user); | |||||
| msgLimit.updateTenantInfo(couponOrder); | |||||
| msgLimit.setType(EnumMsgLimitType.WEAPP_OPENID_SEND.getCode()); | msgLimit.setType(EnumMsgLimitType.WEAPP_OPENID_SEND.getCode()); | ||||
| msgLimit.setLimitId(user.getOpenId()); | msgLimit.setLimitId(user.getOpenId()); | ||||
| if (wxMsgLimitService.checkIsLimit(msgLimit)) { | if (wxMsgLimitService.checkIsLimit(msgLimit)) { | ||||
| @@ -501,7 +506,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| // 获取小程序关联的服务号 | // 获取小程序关联的服务号 | ||||
| WxAuthorizerInfo authQ = new WxAuthorizerInfo(); | WxAuthorizerInfo authQ = new WxAuthorizerInfo(); | ||||
| authQ.setAuthorizerAppid(user.getAppId()); | authQ.setAuthorizerAppid(user.getAppId()); | ||||
| authQ.updateTenantInfo(user); | |||||
| authQ.updateTenantInfo(couponOrder); | |||||
| WxAuthorizerInfo weappInfo = authorizerInfoMapper.findMp(authQ); | WxAuthorizerInfo weappInfo = authorizerInfoMapper.findMp(authQ); | ||||
| if (weappInfo != null) { | if (weappInfo != null) { | ||||
| AppUniformMsg appUniformMsg = new AppUniformMsg(); | AppUniformMsg appUniformMsg = new AppUniformMsg(); | ||||
| @@ -611,16 +616,8 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public void handSel(WxCouponSend wxCouponSend, Long cUserId) { | public void handSel(WxCouponSend wxCouponSend, Long cUserId) { | ||||
| WxCUser cu = wxCUserMapper.selectById(cUserId); | |||||
| if (Objects.isNull(cu)) { | |||||
| throw new MallinkException(ErrorCode.USER_NOT_AUTH_PHONE); | |||||
| } | |||||
| if(StringUtils.isEmpty(cu.getPhone())) { | |||||
| throw new MallinkException(ErrorCode.USER_NOT_AUTH_PHONE); | |||||
| } | |||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(cu.getId()); | |||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(cUserId); | |||||
| if (Objects.isNull(wxCUserBasicInfo)) { | if (Objects.isNull(wxCUserBasicInfo)) { | ||||
| throw new MallinkException(ErrorCode.USER_NOT_AUTH_PHONE); | throw new MallinkException(ErrorCode.USER_NOT_AUTH_PHONE); | ||||
| } | } | ||||
| @@ -631,10 +628,10 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||||
| } | } | ||||
| couponSendList.forEach(cs -> { | couponSendList.forEach(cs -> { | ||||
| // 发放免费券 | // 发放免费券 | ||||
| WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cu.getId(), cs.getCouponId(), cs); | |||||
| WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, cs.getCouponId(), cs); | |||||
| if (couponOrder != null) { | 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()); | ||||
| sendMsgForSendCoupon(couponOrder, cs, couponOrder, cu); | |||||
| sendMsgForSendCoupon(couponOrder, cs, couponOrder, wxCUserBasicInfo); | |||||
| } else { | } else { | ||||
| logger.warn("handSel couponOrder is null"); | logger.warn("handSel couponOrder is null"); | ||||
| } | } | ||||
| @@ -125,14 +125,15 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| List<Long> cUserBasicIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.CUSERBASIC.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); | List<Long> cUserBasicIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.CUSERBASIC.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); | ||||
| List<Long> bUserIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.BUSER.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); | List<Long> bUserIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.BUSER.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); | ||||
| List<Long> mallUserIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.MALLUSER.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); | List<Long> mallUserIds = wxCreditHistoryVoList.stream().filter(a -> a.getOperatorType().equals(EnumUserType.MALLUSER.getCode())).map(WxCreditHistoryVo::getOperatorId).collect(Collectors.toList()); | ||||
| List<WxCUser> wxCUserList = Lists.newArrayList(); | |||||
| List<WxCUserBasicInfo> wxCUserList = Lists.newArrayList(); | |||||
| List<WxCUserBasicInfo> wxCUserBasicInfoList = Lists.newArrayList(); | List<WxCUserBasicInfo> wxCUserBasicInfoList = Lists.newArrayList(); | ||||
| List<WxMerchantBUser> wxMerchantBUserList = Lists.newArrayList(); | List<WxMerchantBUser> wxMerchantBUserList = Lists.newArrayList(); | ||||
| List<MallUserInfo> mallUserInfoList = Lists.newArrayList(); | List<MallUserInfo> mallUserInfoList = Lists.newArrayList(); | ||||
| if (cUserIds != null && cUserIds.size() > 0) { | if (cUserIds != null && cUserIds.size() > 0) { | ||||
| WxCUser wxUser = new WxCUser(); | |||||
| wxUser.setIds(cUserIds); | |||||
| wxCUserList = wxCUserMapper.findList(wxUser); | |||||
| //兼容老数据 | |||||
| WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); | |||||
| wxCUserBasicInfo.setIds(cUserIds); | |||||
| wxCUserList = wxCUserBasicInfoMapper.findList(wxCUserBasicInfo); | |||||
| } | } | ||||
| if (cUserBasicIds != null && cUserBasicIds.size() > 0) { | if (cUserBasicIds != null && cUserBasicIds.size() > 0) { | ||||
| WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); | WxCUserBasicInfo wxCUserBasicInfo = new WxCUserBasicInfo(); | ||||
| @@ -191,15 +192,13 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| @Override | @Override | ||||
| public void creditUsercheck(Long cUserId) { | public void creditUsercheck(Long cUserId) { | ||||
| WxCUser wxCUser = wxCUserMapper.selectById(cUserId); | |||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(cUserId); | WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(cUserId); | ||||
| UserUtil.creditUserCheck(wxCUser, wxCUserBasicInfo); | |||||
| UserUtil.creditUserCheck(wxCUserBasicInfo); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | ||||
| public WxCreditHistory saveOrUpdate(WxCreditHistory record) { | public WxCreditHistory saveOrUpdate(WxCreditHistory record) { | ||||
| //WxCUser wxCUser = wxCUserMapper.selectById(record.getCUserId()); | |||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(record.getCUserId()); | WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(record.getCUserId()); | ||||
| if (wxCUserBasicInfo == null) { | if (wxCUserBasicInfo == null) { | ||||
| //验证此用户是否存在 | //验证此用户是否存在 | ||||
| @@ -257,13 +256,6 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| record.setId(idWorker.nextId()); | record.setId(idWorker.nextId()); | ||||
| record.setCreateDate(new Date()); | record.setCreateDate(new Date()); | ||||
| wxCreditHistoryMapper.insert(record); | wxCreditHistoryMapper.insert(record); | ||||
| //将计算出来新的总积分 更新到两张用户表里 | |||||
| // if (wxCUser != null) { | |||||
| // WxCUser wxCUserNew = new WxCUser(); | |||||
| // wxCUserNew.setId(wxCUser.getId()); | |||||
| // wxCUserNew.setCredit(record.getCreditAmount()); | |||||
| // wxCUserMapper.updateById(wxCUserNew); | |||||
| // } | |||||
| if (wxCUserBasicInfo != null) { | if (wxCUserBasicInfo != null) { | ||||
| WxCUserBasicInfo wxCUserBasicInfoNew = new WxCUserBasicInfo(); | WxCUserBasicInfo wxCUserBasicInfoNew = new WxCUserBasicInfo(); | ||||
| wxCUserBasicInfoNew.setId(wxCUserBasicInfo.getId()); | wxCUserBasicInfoNew.setId(wxCUserBasicInfo.getId()); | ||||
| @@ -304,15 +296,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| // 2. user | // 2. user | ||||
| WxCUser wxCUser = wxCUserMapper.selectById(record.getCUserId()); | |||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(record.getCUserId()); | WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(record.getCUserId()); | ||||
| if (wxCUser != null) { | |||||
| WxCUser wxCUserNew = new WxCUser(); | |||||
| wxCUserNew.setId(wxCUser.getId()); | |||||
| wxCUserNew.setCredit(wxCUser.getCredit() - wxCreditHistory.getCreditNum()); | |||||
| wxCUserNew.setUpdateDate(new Date()); | |||||
| wxCUserMapper.updateById(wxCUserNew); | |||||
| } | |||||
| if (wxCUserBasicInfo != null) { | if (wxCUserBasicInfo != null) { | ||||
| WxCUserBasicInfo wxCUserBasicInfoNew = new WxCUserBasicInfo(); | WxCUserBasicInfo wxCUserBasicInfoNew = new WxCUserBasicInfo(); | ||||
| wxCUserBasicInfoNew.setId(wxCUserBasicInfo.getId()); | wxCUserBasicInfoNew.setId(wxCUserBasicInfo.getId()); | ||||
| @@ -342,7 +326,6 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| wxCreditHistory.setSpend(new BigDecimal(spendStr).multiply(new BigDecimal(100)).intValue()); | wxCreditHistory.setSpend(new BigDecimal(spendStr).multiply(new BigDecimal(100)).intValue()); | ||||
| credit = payAddCredit(wxCreditHistory); | credit = payAddCredit(wxCreditHistory); | ||||
| if (Objects.nonNull(userId)) { | if (Objects.nonNull(userId)) { | ||||
| //WxCUser wxCUser = wxCUserMapper.selectById(userId); | |||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(userId); | WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(userId); | ||||
| creditNew = CreditUtil.calUserCredit(credit, null, wxCUserBasicInfo, wxScoreRulesService,wxLevelConfigMapper); | creditNew = CreditUtil.calUserCredit(credit, null, wxCUserBasicInfo, wxScoreRulesService,wxLevelConfigMapper); | ||||
| } else { | } else { | ||||
| @@ -432,7 +415,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| return wxScoreRules.getRule(EnumScoreType.WECHAT_PHONE, WxScoreRules.SCORE); | return wxScoreRules.getRule(EnumScoreType.WECHAT_PHONE, WxScoreRules.SCORE); | ||||
| } | } | ||||
| private int checkCompleteInfoScoreCount(WxCUser cUser) { | |||||
| private int checkCompleteInfoScoreCount(WxCUserBasicInfo cUser) { | |||||
| WxCreditHistory wxCreditHistory = new WxCreditHistory(); | WxCreditHistory wxCreditHistory = new WxCreditHistory(); | ||||
| wxCreditHistory.updateTenantInfo(cUser); | wxCreditHistory.updateTenantInfo(cUser); | ||||
| wxCreditHistory.setCUserId(cUser.getId()); | wxCreditHistory.setCUserId(cUser.getId()); | ||||
| @@ -441,7 +424,7 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||||
| } | } | ||||
| private int infoAddCredit(WxCreditHistory record) { | private int infoAddCredit(WxCreditHistory record) { | ||||
| WxCUser user = wxCUserMapper.selectById(record.getCUserId()); | |||||
| WxCUserBasicInfo user = wxCUserBasicInfoMapper.selectById(record.getCUserId()); | |||||
| if (user == null || checkCompleteInfoScoreCount(user) > 0) | if (user == null || checkCompleteInfoScoreCount(user) > 0) | ||||
| return 0; | return 0; | ||||
| // 1. 获取score rules | // 1. 获取score rules | ||||
| @@ -47,6 +47,9 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { | |||||
| @Autowired | @Autowired | ||||
| WxCUserMapper wxCUserMapper; | WxCUserMapper wxCUserMapper; | ||||
| @Autowired | |||||
| WxCUserBasicInfoMapper wxCUserBasicInfoMapper; | |||||
| @Autowired | @Autowired | ||||
| WxCouponMapper wxCouponMapper; | WxCouponMapper wxCouponMapper; | ||||
| @@ -303,16 +306,16 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { | |||||
| o.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode()); | o.getOrderStatus().equals(EnumOrderStatus.ORDER_STATUS_COOPERATING_CANCEL.getCode()); | ||||
| }).sorted(Comparator.comparing(order -> order.getId())).collect(Collectors.toList()); | }).sorted(Comparator.comparing(order -> order.getId())).collect(Collectors.toList()); | ||||
| if (!orderList.isEmpty()) { | if (!orderList.isEmpty()) { | ||||
| List<WxCUser> userList = new ArrayList<>(); | |||||
| List<WxCUserBasicInfo> userList = new ArrayList<>(); | |||||
| for (WxOrder order : orderList) { | for (WxOrder order : orderList) { | ||||
| WxCUser user = wxCUserMapper.selectById(order.getCUserId()); | |||||
| WxCUserBasicInfo user = wxCUserBasicInfoMapper.selectById(order.getCUserId()); | |||||
| if (user != null) { | if (user != null) { | ||||
| userList.add(user); | userList.add(user); | ||||
| } | } | ||||
| } | } | ||||
| if (!userList.isEmpty()) { | if (!userList.isEmpty()) { | ||||
| userList = userList.parallelStream().map(u -> { | userList = userList.parallelStream().map(u -> { | ||||
| WxCUser temp = new WxCUser(); | |||||
| WxCUserBasicInfo temp = new WxCUserBasicInfo(); | |||||
| temp.setId(u.getId()); | temp.setId(u.getId()); | ||||
| temp.setNickName(u.getNickName()); | temp.setNickName(u.getNickName()); | ||||
| temp.setAvatarUrl(u.getAvatarUrl()); | temp.setAvatarUrl(u.getAvatarUrl()); | ||||
| @@ -31,6 +31,7 @@ import org.springframework.stereotype.Service; | |||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.Calendar; | import java.util.Calendar; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | |||||
| import java.util.concurrent.TimeUnit; | import java.util.concurrent.TimeUnit; | ||||
| @Service | @Service | ||||
| @@ -161,7 +162,14 @@ public class WxOrderPressServiceImpl implements WxOrderPressService { | |||||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | ||||
| } | } | ||||
| // 3. get user info | // 3. get user info | ||||
| WxCUser user = userMapper.selectById(order.getCUserId()); | |||||
| WxCUser user = null; | |||||
| List<WxCUser> list = userMapper.findList(new WxCUser(){{ | |||||
| updateTenantInfo(order); | |||||
| setUserId(order.getCUserId()); | |||||
| }}); | |||||
| if(list != null && list.size() > 0){ | |||||
| user = list.get(0); | |||||
| } | |||||
| if (user == null) { | if (user == null) { | ||||
| logger.error("找不到C端用户"); | logger.error("找不到C端用户"); | ||||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | throw new MallinkException(ErrorCode.USER_IS_EMPTY); | ||||
| @@ -1520,7 +1520,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| try { | try { | ||||
| //扣减积分操作记录 | //扣减积分操作记录 | ||||
| WxCreditHistory creditHistory = new WxCreditHistory(); | WxCreditHistory creditHistory = new WxCreditHistory(); | ||||
| creditHistory.setOperatorType(EnumUserType.CUSER.getCode()); | |||||
| creditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||||
| creditHistory.setOperatorId(user.getId()); | creditHistory.setOperatorId(user.getId()); | ||||
| creditHistory.setCUserId(user.getId()); | creditHistory.setCUserId(user.getId()); | ||||
| creditHistory.setCreateDate(new Date()); | creditHistory.setCreateDate(new Date()); | ||||
| @@ -2148,7 +2148,7 @@ public class WxOrderServiceImpl implements WxOrderService { | |||||
| creditHistory.setOperatorType(EnumUserType.MALLUSER.getCode()); | creditHistory.setOperatorType(EnumUserType.MALLUSER.getCode()); | ||||
| creditHistory.setOperatorId(user.getOperatorId()); | creditHistory.setOperatorId(user.getOperatorId()); | ||||
| } else { | } else { | ||||
| creditHistory.setOperatorType(EnumUserType.CUSER.getCode()); | |||||
| creditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||||
| creditHistory.setOperatorId(user.getId()); | creditHistory.setOperatorId(user.getId()); | ||||
| } | } | ||||
| creditHistory.setCreditNum(coupon.getCreditPrice()); | creditHistory.setCreditNum(coupon.getCreditPrice()); | ||||
| @@ -283,15 +283,7 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| return 0; | return 0; | ||||
| } | } | ||||
| // 2. user score back | // 2. user score back | ||||
| WxCUser wxCUser = wxCUserMapper.selectById(record.getCUserId()); | |||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(record.getCUserId()); | WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(record.getCUserId()); | ||||
| if (wxCUser != null) { | |||||
| WxCUser wxCUserNew = new WxCUser(); | |||||
| wxCUserNew.setId(wxCUser.getId()); | |||||
| wxCUserNew.setScore(wxCUser.getScore() - history.getScoreAmount()); | |||||
| wxCUserNew.setUpdateDate(new Date()); | |||||
| wxCUserMapper.updateById(wxCUserNew); | |||||
| } | |||||
| if (wxCUserBasicInfo != null) { | if (wxCUserBasicInfo != null) { | ||||
| WxCUserBasicInfo wxCUserBasicInfoNew = new WxCUserBasicInfo(); | WxCUserBasicInfo wxCUserBasicInfoNew = new WxCUserBasicInfo(); | ||||
| wxCUserBasicInfoNew.setId(wxCUserBasicInfo.getId()); | wxCUserBasicInfoNew.setId(wxCUserBasicInfo.getId()); | ||||
| @@ -312,67 +304,9 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| wxCUserBasicInfoMapper.updateScore(wxCUserBasicInfo); | wxCUserBasicInfoMapper.updateScore(wxCUserBasicInfo); | ||||
| // // 1. 获取cUser | |||||
| // WxCUser wxCUser = wxCUserService.getById(userId); | |||||
| // if (wxCUser.getScore() == null) { | |||||
| // wxCUser.setScore(0); | |||||
| // } | |||||
| // | |||||
| // int newScore = wxCUser.getScore() + addedScoreNumber; | |||||
| // | |||||
| // // 2. update score | |||||
| // wxCUser.setScore(newScore); | |||||
| // wxCUserService.saveOrUpdate(wxCUser); | |||||
| } | } | ||||
| /*private void resetBasicUserScore(Long userId, int scoreNumber) { | |||||
| // 1. basicUser | |||||
| WxCUserBasicInfo user = wxCUserBasicInfoMapper.selectById(userId); | |||||
| if(user == null) { | |||||
| return; | |||||
| } | |||||
| // 2. update score/ 修改basic表积分 | |||||
| user.setPoins(scoreNumber); | |||||
| wxCUserBasicInfoMapper.updateScore(user); | |||||
| // 3. 修改 c_user表积分 score | |||||
| if (user.getPhone() != null) { | |||||
| WxCUser wxCUser = new WxCUser(); | |||||
| wxCUser.updateTenantInfo(user); | |||||
| wxCUser.setPhone(user.getPhone()); | |||||
| List<WxCUser> list = wxCUserMapper.findList(wxCUser); | |||||
| if (!list.isEmpty()) { | |||||
| wxCUser = list.get(0); | |||||
| wxCUser.setScore(scoreNumber); | |||||
| wxCUserService.saveOrUpdate(wxCUser); | |||||
| } | |||||
| } | |||||
| }*/ | |||||
| private void resetBasicUserScore(WxCUserBasicInfo user, boolean bHaveCUser) { | |||||
| // 1. basicUser | |||||
| if(user == null) { | |||||
| return; | |||||
| } | |||||
| // 2. update score/ 修改basic表积分 | |||||
| // user.setPoins(scoreNumber); | |||||
| // wxCUserBasicInfoMapper.updateScore(user); | |||||
| // 3. 只修改已存在 c_user表积分 score | |||||
| if(bHaveCUser) { | |||||
| WxCUser wxCUser = new WxCUser(); | |||||
| wxCUser.setId(user.getId()); | |||||
| wxCUser.setScore(user.getPoins()); | |||||
| wxCUserService.saveOrUpdate(wxCUser); | |||||
| } | |||||
| } | |||||
| private int checkTodayLoginScoreCount(WxCUserBasicInfo cUser) { | private int checkTodayLoginScoreCount(WxCUserBasicInfo cUser) { | ||||
| WxScoreHistory scoreHistory = new WxScoreHistory(); | WxScoreHistory scoreHistory = new WxScoreHistory(); | ||||
| scoreHistory.updateFinalTenantInfo(cUser); | scoreHistory.updateFinalTenantInfo(cUser); | ||||
| @@ -536,9 +470,6 @@ public class WxScoreRulesServiceImpl implements WxScoreRulesService { | |||||
| private int memResetScore(WxCUserBasicInfo userInfo, boolean bHaveCUser) { | private int memResetScore(WxCUserBasicInfo userInfo, boolean bHaveCUser) { | ||||
| // 1. 导入成长值 | |||||
| resetBasicUserScore(userInfo, bHaveCUser); | |||||
| // 2. 记录历史 | // 2. 记录历史 | ||||
| recordScoreHistory(userInfo, EnumScoreType.MEM_IMPORT); | recordScoreHistory(userInfo, EnumScoreType.MEM_IMPORT); | ||||
| return userInfo.getPoins(); | return userInfo.getPoins(); | ||||
| @@ -17,11 +17,10 @@ public class UserUtil { | |||||
| /** | /** | ||||
| * 增加积分:校验用户信息 | * 增加积分:校验用户信息 | ||||
| * 规则:有手机号增加积分,无手机号提示授权手机号 | * 规则:有手机号增加积分,无手机号提示授权手机号 | ||||
| * @param wxCUser | |||||
| * @param wxCUserBasicInfo | * @param wxCUserBasicInfo | ||||
| */ | */ | ||||
| public static void creditUserCheck(WxCUser wxCUser, WxCUserBasicInfo wxCUserBasicInfo) { | |||||
| if (Objects.isNull(wxCUser) && Objects.isNull(wxCUserBasicInfo)) { | |||||
| public static void creditUserCheck(WxCUserBasicInfo wxCUserBasicInfo) { | |||||
| if (Objects.isNull(wxCUserBasicInfo)) { | |||||
| throw new MallinkException(ErrorCode.USER_NOT_AUTH_PHONE); | throw new MallinkException(ErrorCode.USER_NOT_AUTH_PHONE); | ||||
| } | } | ||||
| @@ -19,6 +19,7 @@ | |||||
| <result column="name" jdbcType="VARCHAR" property="name"/> | <result column="name" jdbcType="VARCHAR" property="name"/> | ||||
| <result column="level" jdbcType="VARCHAR" property="level"/> | <result column="level" jdbcType="VARCHAR" property="level"/> | ||||
| <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | <result column="nick_name" jdbcType="VARCHAR" property="nickName"/> | ||||
| <result column="avatar_url" jdbcType="VARCHAR" property="avatarUrl"/> | |||||
| <result column="credit" jdbcType="INTEGER" property="credit"/> | <result column="credit" jdbcType="INTEGER" property="credit"/> | ||||
| <result column="active_time" jdbcType="TIMESTAMP" property="activeTime"/> | <result column="active_time" jdbcType="TIMESTAMP" property="activeTime"/> | ||||
| <result column="login_count" jdbcType="INTEGER" property="loginCount"/> | <result column="login_count" jdbcType="INTEGER" property="loginCount"/> | ||||
| @@ -30,7 +31,7 @@ | |||||
| <sql id="allColumns"> | <sql id="allColumns"> | ||||
| `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`, | `id`,`phone`,`birthdate`,`education`,`sex`,`email`,`address`,`poins`,`tag_id`, | ||||
| `create_date`,`update_date`,`tenant_id`,`parent_tenant_id`,`final_tenant_id`,`name`,`nick_name`, | |||||
| `create_date`,`update_date`,`tenant_id`,`parent_tenant_id`,`final_tenant_id`,`name`,`nick_name`,`avatar_url`, | |||||
| `credit`,`active_time`,`login_count`,`act_record` | `credit`,`active_time`,`login_count`,`act_record` | ||||
| ,(select level from wx_level_config | ,(select level from wx_level_config | ||||
| where poins >= points and tenant_id=wcubi.tenant_id | where poins >= points and tenant_id=wcubi.tenant_id | ||||
| @@ -57,7 +57,7 @@ | |||||
| select o.press_end_date expiredDate,o.order_group_id orderGroupId,c.nick_name nickName, | select o.press_end_date expiredDate,o.order_group_id orderGroupId,c.nick_name nickName, | ||||
| c.avatar_url avatarUrl,o.id orderId,o.product_id couponId | c.avatar_url avatarUrl,o.id orderId,o.product_id couponId | ||||
| from wx_order o | from wx_order o | ||||
| left join wx_c_user c on o.c_user_id=c.id | |||||
| left join wx_c_user_basic_info c on o.c_user_id=c.id | |||||
| where o.id=#{orderId} | where o.id=#{orderId} | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and o.`tenant_id` = #{tenantId} | and o.`tenant_id` = #{tenantId} | ||||
| @@ -78,7 +78,7 @@ | |||||
| from wx_order o | from wx_order o | ||||
| left join wx_coupon c on o.product_id=c.id | left join wx_coupon c on o.product_id=c.id | ||||
| left join wx_order_group g on o.order_group_id=g.id | left join wx_order_group g on o.order_group_id=g.id | ||||
| left join wx_c_user u on o.c_user_id=u.id | |||||
| left join wx_c_user_basic_info u on o.c_user_id=u.id | |||||
| where c.type=9 | where c.type=9 | ||||
| <if test=" null != tenantId and '' != tenantId"> | <if test=" null != tenantId and '' != tenantId"> | ||||
| and o.`tenant_id` = #{tenantId} | and o.`tenant_id` = #{tenantId} | ||||