| @@ -5,7 +5,6 @@ import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.IdWorker; | |||
| import com.iformall.domain.po.base.BaseCUserEntity; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.EnumAppPlat; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| @@ -13,8 +12,6 @@ import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.CUserTokenService; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.WxCUserService; | |||
| import com.iformall.service.cuser.CUserServiceFactory; | |||
| import com.iformall.service.wechat.FmOpenService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.IPUtil; | |||
| @@ -22,10 +19,11 @@ import com.iformall.utils.MaUtil; | |||
| import com.iformall.utils.RedisCacheUtils; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.beans.factory.annotation.Qualifier; | |||
| import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.data.redis.core.ValueOperations; | |||
| import org.springframework.web.bind.WebDataBinder; | |||
| import org.springframework.web.bind.annotation.InitBinder; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| @@ -37,15 +35,14 @@ import java.beans.PropertyEditorSupport; | |||
| import java.text.ParseException; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.Date; | |||
| import java.util.concurrent.TimeUnit; | |||
| @RestController | |||
| public class BaseController { | |||
| @Autowired | |||
| private boolean isFmOpen; | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| @Autowired | |||
| private WxCUserService wxCUserService; | |||
| private boolean isFmOpen; | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @@ -104,17 +101,10 @@ public class BaseController { | |||
| public String getFinalTenantId() { | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| String tenantId = tenantEntity.getTenantId(); | |||
| return tenantEntity.getFinalTenantId(); | |||
| } | |||
| // public Long getUserId() { | |||
| // HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| // Long cUserId = (Long) request.getAttribute(Constant.LOGIN_USER_KEY); | |||
| // return cUserId; | |||
| // } | |||
| public Long getMemberId() throws Exception { | |||
| public Long getMemberId() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| Long memberId = (Long) request.getAttribute(Constant.LOGIN_MEMBER_KEY); | |||
| if(memberId == null){ | |||
| @@ -130,8 +120,7 @@ public class BaseController { | |||
| public WxCUser getWxCUser() { | |||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||
| BaseCUserEntity baseuser = (BaseCUserEntity) request.getAttribute(Constant.REQUEST_C_USER_KEY); | |||
| // Long cUserId = getUserId(); | |||
| // WxCUser user = wxCUserService.getById(cUserId); | |||
| if (baseuser == null) { | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| } | |||
| @@ -190,14 +179,6 @@ public class BaseController { | |||
| String shortKey = "webapp:short:member:"+memberId; | |||
| RedisCacheUtils.removeCache(cuserBasicInfoTemplate, shortKey); | |||
| } | |||
| // public WxCUserBasicInfo getMember() throws Exception { | |||
| // Long memberId = getMemberId(); | |||
| // WxCUserBasicInfo member = wxCUserBasicInfoService.getById(memberId); | |||
| // if (member == null) { | |||
| // throw new MallinkException(ErrorCode.USER_IS_EMPTY); | |||
| // } | |||
| // return member; | |||
| // } | |||
| public WxAppinfo getAppInfo(String appId) { | |||
| return wxAppinfoService.getByAppId(appId); | |||
| @@ -236,62 +217,56 @@ public class BaseController { | |||
| byId = wxCUserBasicInfoService.getById(userId,getFinalTenantId()); | |||
| } | |||
| // List<WxCUserBasicInfo> list = wxCUserBasicInfoService.findByPhone(tenantEntity, phone); | |||
| WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(tenantEntity, userPhone); | |||
| if (basicInfo != null) { | |||
| if(byId != null && !byId.getPhone().equals(basicInfo.getPhone())){ | |||
| return Long.valueOf(-1); | |||
| if (byId != null) { | |||
| if (!byId.getId().equals(basicInfo.getId())) { | |||
| //数据库存在此手机号的会员,并且当前微信存在另一手机号会员 | |||
| logger.error("会员" + userId + "更换手机号时,当前手机号会员表已存在:" + userPhone); | |||
| return Long.valueOf(-1); | |||
| } | |||
| } | |||
| if(!basicInfo.getTenantId().contains(","+tenantEntity.getTenantId()+",")){ | |||
| basicInfo.setTenantId(basicInfo.getTenantId()+tenantEntity.getTenantId()+","); | |||
| wxCUserBasicInfoService.update(basicInfo); | |||
| if (!basicInfo.getTenantId().contains("," + tenantEntity.getTenantId() + ",")) { | |||
| basicInfo.setTenantId(basicInfo.getTenantId() + tenantEntity.getTenantId() + ","); | |||
| } | |||
| // WxCUserBasicInfo basicInfo = list.get(0); | |||
| // 微信名称,统一成微信昵称 | |||
| // if (!Objects.equals(basicInfo.getNickName(), user.getNickName())) { | |||
| // basicInfo.setNickName(user.getNickName()); | |||
| // } | |||
| // // 性别 | |||
| // if (basicInfo.getSex() == null) { | |||
| // basicInfo.setSex(user.getGender()); | |||
| // } | |||
| // // 成长值 | |||
| // if (Objects.nonNull(user.getScore())) { | |||
| // basicInfo.setPoins(user.getScore()); | |||
| // } | |||
| // // 积分 | |||
| // if (Objects.nonNull(user.getCredit())) { | |||
| // basicInfo.setCredit(user.getCredit()); | |||
| // } | |||
| //wxCUserBasicInfoService.updateObj(basicInfo, user); | |||
| return basicInfo.getId(); | |||
| } else if(byId != null){ | |||
| byId.setPhone(userPhone); | |||
| byId.setNickName(userName); | |||
| byId.setAvatarUrl(avatarUrl); | |||
| byId.setSex(sex); | |||
| wxCUserBasicInfoService.update(byId); | |||
| removeCacheMember(byId.getId()); | |||
| return byId.getId(); | |||
| }else{ | |||
| Date cur = new Date(); | |||
| basicInfo = new WxCUserBasicInfo(); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| basicInfo.setId(idWorker.nextId()); | |||
| basicInfo.setTenantId(","+tenantEntity.getTenantId()+","); | |||
| basicInfo.undateFinalTenantId(tenantEntity); | |||
| basicInfo.setPhone(userPhone); | |||
| basicInfo.setNickName(userName); | |||
| basicInfo.setAvatarUrl(avatarUrl); | |||
| basicInfo.setSex(sex); | |||
| basicInfo.setLoginCount(1); | |||
| basicInfo.setActiveTime(cur); | |||
| basicInfo.setCreateDate(cur); | |||
| basicInfo.setUpdateDate(cur); | |||
| wxCUserBasicInfoService.save(basicInfo); | |||
| wxCUserBasicInfoService.update(basicInfo); | |||
| removeCacheMember(basicInfo.getId()); | |||
| return basicInfo.getId(); | |||
| } else { | |||
| if (byId != null) { | |||
| if (!byId.getTenantId().contains("," + tenantEntity.getTenantId() + ",")) { | |||
| byId.setTenantId(byId.getTenantId() + tenantEntity.getTenantId() + ","); | |||
| } | |||
| byId.setPhone(userPhone); | |||
| byId.setNickName(userName); | |||
| byId.setAvatarUrl(avatarUrl); | |||
| byId.setSex(sex); | |||
| wxCUserBasicInfoService.update(byId); | |||
| removeCacheMember(basicInfo.getId()); | |||
| return byId.getId(); | |||
| } else { | |||
| Date cur = new Date(); | |||
| basicInfo = new WxCUserBasicInfo(); | |||
| final IdWorker idWorker = IdWorker.get(); | |||
| basicInfo.setId(idWorker.nextId()); | |||
| basicInfo.setTenantId("," + tenantEntity.getTenantId() + ","); | |||
| basicInfo.setFinalTenantId(tenantEntity.getFinalTenantId()); | |||
| basicInfo.setPhone(userPhone); | |||
| basicInfo.setNickName(userName); | |||
| basicInfo.setAvatarUrl(avatarUrl); | |||
| basicInfo.setSex(sex); | |||
| basicInfo.setLoginCount(1); | |||
| basicInfo.setActiveTime(cur); | |||
| basicInfo.setCreateDate(cur); | |||
| basicInfo.setUpdateDate(cur); | |||
| wxCUserBasicInfoService.save(basicInfo); | |||
| removeCacheMember(basicInfo.getId()); | |||
| return basicInfo.getId(); | |||
| } | |||
| } | |||
| } | |||
| @@ -549,11 +549,6 @@ public class WxUserGrantController extends BaseController { | |||
| if (user != null) { | |||
| logger.debug(user.toString()); | |||
| // boolean bFirstNickName = false; | |||
| // if(StringUtils.isNoneEmpty(user.getNickName())) { | |||
| // bFirstNickName = true; | |||
| // } | |||
| WxMaService wxMaService = getWeappService(user.getAppId()); | |||
| String session_key = user.getSessionKey(); | |||
| @@ -592,13 +587,6 @@ public class WxUserGrantController extends BaseController { | |||
| removeCacheCUser(); | |||
| // if(bFirstNickName) { | |||
| // // 首次获取昵称 | |||
| // // 成长值 | |||
| // wxScoreRulesService.addScore(getTenantInfo(),EnumScoreType.WECHAT_PERSION, user); | |||
| // //增加积分 | |||
| // wxCUserService.addCredit(user, EnumScoreType.WECHAT_PERSION); | |||
| // } | |||
| resultMap.put("openId", user.getOpenId()); | |||
| resultMap.put("unionId", user.getUnionId()); | |||
| resultMap.put("msg", "获取用户信息成功!"); | |||
| @@ -624,9 +612,9 @@ public class WxUserGrantController extends BaseController { | |||
| @PostMapping("/getUserPhone") | |||
| @ApiOperation(value = "授权后获取用户的手机号", notes = "{\"encryptedData\":\"string\",\"iv\":\"string\"}") | |||
| public ResultData getUserPhone(@RequestBody Map<String, String> map) { | |||
| logger.debug(map.toString()); | |||
| logger.info(map.toString()); | |||
| TenantEntity tenantEntity = getTenantInfo(); | |||
| Map resultMap = new HashMap(); | |||
| String encryptedData = map.get("encryptedData"); | |||
| String iv = map.get("iv"); | |||
| @@ -638,6 +626,8 @@ public class WxUserGrantController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL.getCode(), "iv 不能为空"); | |||
| } | |||
| Map resultMap = new HashMap(); | |||
| WxCUser user = getWxCUser(); | |||
| if (user == null) { | |||
| @@ -645,7 +635,7 @@ public class WxUserGrantController extends BaseController { | |||
| } | |||
| boolean isFirstPhone = false; | |||
| if(StringUtils.isBlank(user.getPhone())) { | |||
| if(user.getUserId() == null) { | |||
| isFirstPhone = true; | |||
| } | |||
| @@ -660,18 +650,6 @@ public class WxUserGrantController extends BaseController { | |||
| user.setPhone(phoneNoInfo.getPhoneNumber()); | |||
| user.setPurePhone(phoneNoInfo.getPurePhoneNumber()); | |||
| user.setCountryCode(phoneNoInfo.getCountryCode()); | |||
| if (isFirstPhone) { | |||
| //检查是否存在会员信息 如果有 赋值积分 | |||
| // WxCUserBasicInfo basicInfo = wxCUserBasicInfoService.findInfoByPhone(tenantEntity, user.getPhone()); | |||
| // if (basicInfo != null ) { | |||
| // int credit = user.getCredit() == null ? 0 : user.getCredit(); | |||
| // int score = user.getScore() == null ? 0 : user.getScore(); | |||
| // int memScore = basicInfo.getPoins() == null ? 0 : basicInfo.getPoins(); | |||
| // int memCredit = basicInfo.getCredit() == null ? 0 : basicInfo.getCredit(); | |||
| // user.setCredit(memCredit + credit); | |||
| // user.setScore(memScore + score); | |||
| // } | |||
| } | |||
| if (!user.getPhone().contains("*")) { // 用户手机非加密 | |||
| String phone = user.getPhone(); | |||
| @@ -685,6 +663,8 @@ public class WxUserGrantController extends BaseController { | |||
| return new ResultData(ErrorCode.USER_PHONE_IS_FOUND); | |||
| } | |||
| user.setUserId(userBasicId); | |||
| }else{ | |||
| return new ResultData(ErrorCode.PHONE_DECODE_ERR, resultMap); | |||
| } | |||
| wxCUserService.saveOrUpdate(user); | |||
| wxCUserService.delForUserIdOnly(user.getId(),user.getUserId(),user.getTenantId()); | |||
| @@ -1414,92 +1414,92 @@ public class PosServiceImpl implements PosService { | |||
| return 0; | |||
| } | |||
| /** | |||
| * 核销回退 | |||
| * @param couponOrderCVo | |||
| * @param buUserId | |||
| * @param posOrderId | |||
| */ | |||
| private void cancelVerify(WxCouponOrderCVo couponOrderCVo, Long buUserId, Long posOrderId) { | |||
| // 1. 积分历史回退 | |||
| try { | |||
| WxCreditHistory creditHistory = new WxCreditHistory(); | |||
| creditHistory.setOperatorType(EnumUserType.BUSER.getCode()); | |||
| creditHistory.setOperatorId(buUserId); | |||
| creditHistory.setCUserId(couponOrderCVo.getcUserId()); | |||
| // creditHistory.updateTenantInfo(couponOrderCVo); | |||
| creditHistory.setFinalTenantId(couponOrderCVo.getFinalTenantId()); | |||
| creditHistory.setTenantId(couponOrderCVo.getFinalTenantId()); | |||
| creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); | |||
| creditHistory.setCouponId(couponOrderCVo.getCouponId()); | |||
| int num = creditHistoryService.cancelCredit(creditHistory); | |||
| if (num <= 1) { | |||
| logger.warn("核销积分历史回退: " + creditHistory.toString()); | |||
| } | |||
| } catch (Exception e) { | |||
| String errMessage = "核销积分历史回退:" + e.getMessage(); | |||
| logger.error(errMessage); | |||
| throw new MallinkException(500, errMessage); | |||
| } | |||
| // 2. 成长值历史回退 | |||
| try { | |||
| WxScoreHistory scoreHistory = new WxScoreHistory(); | |||
| // scoreHistory.updateTenantInfo(couponOrderCVo); | |||
| scoreHistory.setTenantId(couponOrderCVo.getFinalTenantId()); | |||
| scoreHistory.setFinalTenantId(couponOrderCVo.getFinalTenantId()); | |||
| scoreHistory.setScoreType(EnumScoreType.CONSUMPTION.getCode()); | |||
| scoreHistory.setCUserId(couponOrderCVo.getcUserId()); | |||
| scoreHistory.setOrderId(couponOrderCVo.getOrderId()); | |||
| int num = scoreRulesService.cancelScore(scoreHistory); | |||
| if (num <= 1) { | |||
| logger.warn("核销成长值历史回退: " + scoreHistory.toString()); | |||
| } | |||
| } catch (Exception e) { | |||
| String errMessage = "核销成长值历史回退:" + e.getMessage(); | |||
| logger.error(errMessage); | |||
| throw new MallinkException(500, errMessage); | |||
| } | |||
| // 3. update posOrderId | |||
| PosCouponOrderVerify posCouponOrderVerify = new PosCouponOrderVerify(); | |||
| posCouponOrderVerify.updateTenantInfo(couponOrderCVo); | |||
| posCouponOrderVerify.setCouponOrderId(couponOrderCVo.getId()); | |||
| posCouponOrderVerify.setPosOrderId(posOrderId); | |||
| posCouponOrderVerify.setState(EnumEnableType.Enable.getCode()); | |||
| List<PosCouponOrderVerify> posCouponOrderVerifyList = posCouponOrderVerifyService.getList(posCouponOrderVerify); | |||
| if (posCouponOrderVerifyList.size() == 1) { | |||
| posCouponOrderVerify = posCouponOrderVerifyList.get(0); | |||
| if (posCouponOrderVerify != null) { | |||
| try { | |||
| posCouponOrderVerifyService.deleteById(posCouponOrderVerify.getId()); | |||
| } catch(Exception e){ | |||
| logger.error("db failed: couponOrder-" + couponOrderCVo.getId() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| } | |||
| } else { | |||
| logger.error(ErrorCode.VERIFY_POS_ORDER_NOT_EQUAL.getMessage() + ": " + posOrderId); | |||
| throw new MallinkException(ErrorCode.VERIFY_POS_ORDER_NOT_EQUAL); | |||
| } | |||
| // 4. update couponOrder | |||
| int num = 0; | |||
| try { | |||
| WxCouponOrder couponOrder = new WxCouponOrder(); | |||
| couponOrder.setId(couponOrderCVo.getId()); | |||
| couponOrder.updateTenantInfo(couponOrderCVo); | |||
| couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| couponOrder.setUpdateDate(new Date()); | |||
| num = couponOrderMapper.cancelVerifyCouponOrder(couponOrder); | |||
| } catch (Exception e) { | |||
| logger.error("db failed: couponOrder-" + couponOrderCVo.getId() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| if (num != 1) { | |||
| logger.error("核销异常:updatete num " + num); | |||
| throw new MallinkException(ErrorCode.VERIFY_ERROR.getCode(), "updatete num " + num); | |||
| } | |||
| logger.info("核销已取消: " + couponOrderCVo.getId()); | |||
| } | |||
| // /** | |||
| // * 核销回退 | |||
| // * @param couponOrderCVo | |||
| // * @param buUserId | |||
| // * @param posOrderId | |||
| // */ | |||
| // private void cancelVerify(WxCouponOrderCVo couponOrderCVo, Long buUserId, Long posOrderId) { | |||
| // // 1. 积分历史回退 | |||
| // try { | |||
| // WxCreditHistory creditHistory = new WxCreditHistory(); | |||
| // creditHistory.setOperatorType(EnumUserType.BUSER.getCode()); | |||
| // creditHistory.setOperatorId(buUserId); | |||
| // creditHistory.setCUserId(couponOrderCVo.getcUserId()); | |||
| //// creditHistory.updateTenantInfo(couponOrderCVo); | |||
| // creditHistory.setFinalTenantId(couponOrderCVo.getFinalTenantId()); | |||
| // creditHistory.setTenantId(couponOrderCVo.getFinalTenantId()); | |||
| // creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); | |||
| // creditHistory.setCouponId(couponOrderCVo.getCouponId()); | |||
| // int num = creditHistoryService.cancelCredit(creditHistory); | |||
| // if (num <= 1) { | |||
| // logger.warn("核销积分历史回退: " + creditHistory.toString()); | |||
| // } | |||
| // } catch (Exception e) { | |||
| // String errMessage = "核销积分历史回退:" + e.getMessage(); | |||
| // logger.error(errMessage); | |||
| // throw new MallinkException(500, errMessage); | |||
| // } | |||
| // // 2. 成长值历史回退 | |||
| // try { | |||
| // WxScoreHistory scoreHistory = new WxScoreHistory(); | |||
| //// scoreHistory.updateTenantInfo(couponOrderCVo); | |||
| // scoreHistory.setTenantId(couponOrderCVo.getFinalTenantId()); | |||
| // scoreHistory.setFinalTenantId(couponOrderCVo.getFinalTenantId()); | |||
| // scoreHistory.setScoreType(EnumScoreType.CONSUMPTION.getCode()); | |||
| // scoreHistory.setCUserId(couponOrderCVo.getcUserId()); | |||
| // scoreHistory.setOrderId(couponOrderCVo.getOrderId()); | |||
| // int num = scoreRulesService.cancelScore(scoreHistory); | |||
| // if (num <= 1) { | |||
| // logger.warn("核销成长值历史回退: " + scoreHistory.toString()); | |||
| // } | |||
| // } catch (Exception e) { | |||
| // String errMessage = "核销成长值历史回退:" + e.getMessage(); | |||
| // logger.error(errMessage); | |||
| // throw new MallinkException(500, errMessage); | |||
| // } | |||
| // | |||
| // // 3. update posOrderId | |||
| // PosCouponOrderVerify posCouponOrderVerify = new PosCouponOrderVerify(); | |||
| // posCouponOrderVerify.updateTenantInfo(couponOrderCVo); | |||
| // posCouponOrderVerify.setCouponOrderId(couponOrderCVo.getId()); | |||
| // posCouponOrderVerify.setPosOrderId(posOrderId); | |||
| // posCouponOrderVerify.setState(EnumEnableType.Enable.getCode()); | |||
| // List<PosCouponOrderVerify> posCouponOrderVerifyList = posCouponOrderVerifyService.getList(posCouponOrderVerify); | |||
| // if (posCouponOrderVerifyList.size() == 1) { | |||
| // posCouponOrderVerify = posCouponOrderVerifyList.get(0); | |||
| // if (posCouponOrderVerify != null) { | |||
| // try { | |||
| // posCouponOrderVerifyService.deleteById(posCouponOrderVerify.getId()); | |||
| // } catch(Exception e){ | |||
| // logger.error("db failed: couponOrder-" + couponOrderCVo.getId() + ", e:" + e.getMessage()); | |||
| // throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| // } | |||
| // } | |||
| // } else { | |||
| // logger.error(ErrorCode.VERIFY_POS_ORDER_NOT_EQUAL.getMessage() + ": " + posOrderId); | |||
| // throw new MallinkException(ErrorCode.VERIFY_POS_ORDER_NOT_EQUAL); | |||
| // } | |||
| // // 4. update couponOrder | |||
| // int num = 0; | |||
| // try { | |||
| // WxCouponOrder couponOrder = new WxCouponOrder(); | |||
| // couponOrder.setId(couponOrderCVo.getId()); | |||
| // couponOrder.updateTenantInfo(couponOrderCVo); | |||
| // couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()); | |||
| // couponOrder.setUpdateDate(new Date()); | |||
| // num = couponOrderMapper.cancelVerifyCouponOrder(couponOrder); | |||
| // } catch (Exception e) { | |||
| // logger.error("db failed: couponOrder-" + couponOrderCVo.getId() + ", e:" + e.getMessage()); | |||
| // throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| // } | |||
| // if (num != 1) { | |||
| // logger.error("核销异常:updatete num " + num); | |||
| // throw new MallinkException(ErrorCode.VERIFY_ERROR.getCode(), "updatete num " + num); | |||
| // } | |||
| // logger.info("核销已取消: " + couponOrderCVo.getId()); | |||
| // } | |||
| @Override | |||
| @Transactional(rollbackFor = Exception.class) | |||
| @@ -348,10 +348,10 @@ public class WxCUserServiceImpl implements WxCUserService { | |||
| wxCreditHistory.setCreditType(enumScoreType.getCode()); | |||
| wxCreditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||
| wxCreditHistory.setOperatorId(user.getUserId()); | |||
| wxCreditHistory.setCreditNum(user.getCredit()); | |||
| wxCreditHistory.setCreditAmount(user.getCredit()); | |||
| // wxCreditHistory.setCreditNum(user.getCredit()); | |||
| // wxCreditHistory.setCreditAmount(user.getCredit()); | |||
| WxCreditHistory record = wxCreditHistoryService.saveOrUpdate(wxCreditHistory); | |||
| user.setCredit(record.getCreditAmount()); | |||
| // user.setCredit(record.getCreditAmount()); | |||
| return record.getCreditAmount(); | |||
| } | |||
| @@ -212,13 +212,11 @@ public class WxCreditHistoryServiceImpl implements WxCreditHistoryService { | |||
| record.setSpend(new BigDecimal(record.getSpendStr()).multiply(new BigDecimal(100)).intValue()); | |||
| } | |||
| int currentCreditAmount = 0; | |||
| //获取当前用户总积分规则:优先获取wxCUser中数据 若不存在 再获取wxCUserBasicInfo表中数据 | |||
| //获取当前用户总积分规则: | |||
| if (wxCUserBasicInfo != null && wxCUserBasicInfo.getCredit() != null && wxCUserBasicInfo.getCredit() > 0) { | |||
| currentCreditAmount = wxCUserBasicInfo.getCredit(); | |||
| } | |||
| if (record.getCreditAmount() == null) { | |||
| record.setCreditAmount(currentCreditAmount); | |||
| } | |||
| record.setCreditAmount(currentCreditAmount); | |||
| int creditChangeNumOrigin = creditIncrement(record); | |||
| int creditChangeNum = creditChangeNumOrigin ; | |||