fanli/src/main/java/com/yeshi/fanli/controller/client/v1/h5/AppH5CouponController.java
@@ -16,11 +16,13 @@ import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.lable.QualityFactory; import com.yeshi.fanli.entity.bus.user.UserInfo; import com.yeshi.fanli.entity.bus.user.UserInfoExtra; import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; import com.yeshi.fanli.exception.taobao.TaoKeApiException; import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException; import com.yeshi.fanli.service.inter.lable.QualityGoodsService; import com.yeshi.fanli.service.inter.order.config.HongBaoManageService; import com.yeshi.fanli.service.inter.user.UserInfoExtraService; import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.util.factory.goods.GoodsDetailVOFactory; @@ -46,6 +48,9 @@ @Resource private UserSystemCouponService userSystemCouponService; @Resource private UserInfoExtraService userInfoExtraService; @RequestMapping("getMianDanGoodsList") public void getMianDanGoodsList(AcceptData acceptData, PrintWriter out, int page, int pageSize, String callback) { @@ -166,6 +171,8 @@ } // 获取免单券数量 long couponCount = userSystemCouponService.countUsableRewardCoupon(uid); UserInfoExtra extraInfo=userInfoExtraService.getUserInfoExtra(uid); long integralCount=extraInfo!=null?extraInfo.getGoldCoin():0L; JSONObject userJson = new JSONObject(); userJson.put("nickName", user.getNickName()); userJson.put("portrait", user.getPortrait()); @@ -174,6 +181,7 @@ JSONObject data = new JSONObject(); data.put("user", userJson); data.put("couponCount", couponCount); data.put("integralCount", integralCount); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); } fanli/src/main/java/com/yeshi/fanli/controller/client/v2/IntegralControllerV2.java
@@ -344,7 +344,7 @@ JSONObject data = new JSONObject(); data.put("goldCoin", goldCoin); out.print(JsonUtil.loadTrueResult(data)); } catch (IntegralTaskRecordException e) { } catch (IntegralTaskRecordException e) { out.print(JsonUtil.loadFalseResult(e.getMsg())); } } @@ -392,6 +392,28 @@ out.print(JsonUtil.loadTrueResult(data)); } @RequestMapping(value = "getExchangeDetail") public void getExchangeDetail(AcceptData acceptData, Long id, String callback, PrintWriter out) { if (id == null || id <= 0) { out.print(JsonUtil.loadFalseResult(1, "兑换ID有误")); return; } IntegralExchange exchange = integralExchangeService.selectByPrimaryKey(id); if (exchange != null) { GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation(); Gson gson = gsonBuilder.create(); if (StringUtil.isNullOrEmpty(callback)) out.print(JsonUtil.loadTrueResult(gson.toJson(exchange))); else out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(gson.toJson(exchange)))); } else { if (StringUtil.isNullOrEmpty(callback)) out.print(JsonUtil.loadFalseResult("未找到")); else out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未找到"))); } } /** * 兑换金币检验 * @@ -400,8 +422,8 @@ * @param id * @param out */ @RequestMapping(value = "verifyExchange", method = RequestMethod.POST) public void verifyExchange(AcceptData acceptData, Long uid, Long id, PrintWriter out) { @RequestMapping(value = "verifyExchange") public void verifyExchange(AcceptData acceptData, Long uid, Long id, String callback, PrintWriter out) { try { ExchangeTipVO exchange = integralExchangeService.verifyExchange(uid, id); @@ -409,9 +431,17 @@ Gson gson = gsonBuilder.create(); JSONObject data = new JSONObject(); data.put("result", gson.toJson(exchange)); out.print(JsonUtil.loadTrueResult(data)); if (StringUtil.isNullOrEmpty(callback)) { out.print(JsonUtil.loadTrueResult(data)); } else { out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); } } catch (IntegralExchangeException e) { out.print(JsonUtil.loadFalseResult(1, e.getMsg())); if (StringUtil.isNullOrEmpty(callback)) { out.print(JsonUtil.loadFalseResult(1, e.getMsg())); } else { out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, e.getMsg()))); } } } @@ -424,8 +454,8 @@ * @param out */ @RequestSerializableByKey(key = "'integralexchange-'+#uid") @RequestMapping(value = "exchange", method = RequestMethod.POST) public void exchange(AcceptData acceptData, Long uid, Long id, PrintWriter out) { @RequestMapping(value = "exchange") public void exchange(AcceptData acceptData, Long uid, Long id, String callback, PrintWriter out) { try { IntegralExchange exchange = integralExchangeService.exchange(uid, id); @@ -437,9 +467,15 @@ JSONObject data = new JSONObject(); data.put("result", gson.toJson(exchange)); data.put("goldCoin", extraVO.getGoldCoin() + "枚"); out.print(JsonUtil.loadTrueResult(data)); if (StringUtil.isNullOrEmpty(callback)) out.print(JsonUtil.loadTrueResult(data)); else out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); } catch (IntegralExchangeException e) { out.print(JsonUtil.loadFalseResult(1, e.getMsg())); if (StringUtil.isNullOrEmpty(callback)) out.print(JsonUtil.loadFalseResult(1, e.getMsg())); else out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, e.getMsg()))); } } fanli/src/main/java/com/yeshi/fanli/mapping/jd/JDOrderItemMapper.xml
@@ -272,7 +272,7 @@ <select id="countOrderNumber" resultType="java.util.HashMap"> SELECT IFNULL(COUNT(`joi_id`),0) AS showValue, <include refid="Column_DateType" /> FROM `yeshi_ec_jd_order_item` left join yeshi_ec_jd_order on jo_order_id=joi_order_id WHERE jo_order_time IS NOT NULL FROM `yeshi_ec_jd_order_item` left join yeshi_ec_jd_order on jo_order_id=joi_order_id WHERE jo_order_time IS NOT NULL and joi_valid_code!=2 <include refid="Count_Select_DateType" /> <include refid="Count_Group_DateType" /> ORDER BY jo_order_time fanli/src/main/java/com/yeshi/fanli/service/impl/user/integral/IntegralExchangeServiceImpl.java
@@ -46,81 +46,83 @@ @Resource(name = "taskExecutor") private TaskExecutor executor; @Resource private IntegralExchangeMapper integralExchangeMapper; @Resource private ConfigService configService; @Resource private UserInfoExtraService userInfoExtraService; @Resource private UserSystemCouponService userSystemCouponService; @Resource private UserTaoLiJinOriginService userTaoLiJinOriginService; @Resource private HongBaoV2Service hongBaoV2Service; @Resource private UserMoneyDetailService userMoneyDetailService; @Resource private UserInfoService userInfoService; @Resource private CodePublishRecordService codePublishRecordService; @Resource private IntegralExchangeRecordService integralExchangeRecordService; @Resource private UserOtherMsgNotificationService userOtherMsgNotificationService; @Resource private MsgInviteDetailService msgInviteDetailService; @Resource private IntegralDetailService integralDetailService; @Override public List<IntegralExchange> listValidCache(long start, int count){ public IntegralExchange selectByPrimaryKey(Long id) { return integralExchangeMapper.selectByPrimaryKey(id); } @Override public List<IntegralExchange> listValidCache(long start, int count) { return integralExchangeMapper.listValid(start, count); } @Override public Long countValid(){ public Long countValid() { return integralExchangeMapper.countValid(); } @Override public ExchangeTipVO verifyExchange(Long uid, Long id) throws IntegralExchangeException{ if (uid == null || uid <= 0) public ExchangeTipVO verifyExchange(Long uid, Long id) throws IntegralExchangeException { if (uid == null || uid <= 0) throw new IntegralExchangeException(1, "用户未登录"); if (id == null || id <= 0) if (id == null || id <= 0) throw new IntegralExchangeException(1, "兑换id不正确"); UserInfoExtraVO extraVO = userInfoExtraService.getInfoExtraVOByUid(uid); if (extraVO == null) throw new IntegralExchangeException(1, "用户相关信息不存在"); IntegralExchange exchange = integralExchangeMapper.selectByPrimaryKey(id); if (exchange == null) throw new IntegralExchangeException(1, "兑换方式不存在"); Integer state = exchange.getState(); if (state == null || state != 1) throw new IntegralExchangeException(1, "兑换活动未开启"); Integer goldCoin = exchange.getGoldCoin(); ExchangeTipVO exchangeTip = new ExchangeTipVO(); exchangeTip.setId(id); ExchangeTypeEnum type = exchange.getType(); @@ -128,7 +130,7 @@ exchangeTip.setType(type.name()); return exchangeTip; } long exchangeCount = 0; if (ExchangeTypeEnum.freeCouponBuy == type) { exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, null); @@ -136,7 +138,7 @@ throw new IntegralExchangeException(1, "自购免单券,仅能兑换一次"); } } Integer upperLimit = exchange.getUpperLimit(); if (upperLimit != null) { // 是否有限制每日次数 Integer today = 1; @@ -145,7 +147,7 @@ throw new IntegralExchangeException(1, "今日兑换已达上限"); } } Integer goldCoinHas = extraVO.getGoldCoin(); if (goldCoin.intValue() > goldCoinHas.intValue()) { exchangeTip.setType("notEnough"); @@ -153,7 +155,7 @@ exchangeTip.setGoldCoin((goldCoin.intValue() - goldCoinHas.intValue()) + "金币"); return exchangeTip; } if (ExchangeTypeEnum.freeCouponBuy == type) { exchangeTip.setTip("自购免单券仅能自己使用,且每个用户ID只能兑换一次。\r\n注:兑换成功后请到“我的-福利中心”中查看"); } else if (ExchangeTypeEnum.freeCouponGive == type) { @@ -161,25 +163,25 @@ } else if (ExchangeTypeEnum.rebatePercentCoupon == type) { exchangeTip.setTip("返利奖励券兑换次数不限,赠送次数不限,受赠人若无“邀请人”成功领取后将成为你的一级队员。\r\n注:兑换成功后请到“我的-福利中心”中查看"); } else if (ExchangeTypeEnum.inviteCodePublish == type) { if(codePublishRecordService.countValidRecord(uid) > 0) if (codePublishRecordService.countValidRecord(uid) > 0) throw new IntegralExchangeException(1, "三天之内不可重复兑换"); exchangeTip.setInviteCode(extraVO.getInviteCode()); exchangeTip.setTip("兑换成功后,将发布于“激活邀请码兑换功能中”,需激活邀请的用户可用金币兑换,本次展示有效期为3天。"); } else if (ExchangeTypeEnum.taoLiJin == type) { exchangeTip.setName(exchange.getAmount().setScale(0) + "元推广红包"); exchangeTip.setTip("注:兑换成功后请到“我的-推广红包”中查看"); } else if (ExchangeTypeEnum.cash == type) { } else if (ExchangeTypeEnum.cash == type) { exchangeTip.setName(exchange.getAmount().setScale(0) + "元现金红包"); exchangeTip.setTip("注:兑换成功后请到“我的-账户余额”中查看"); } else { throw new IntegralExchangeException(1, "兑换方式不存在"); } exchangeTip.setGoldCoin(goldCoin + "金币"); exchangeTip.setType(type.name()); return exchangeTip; } @Override public IntegralExchange exchange(Long uid, Long id) throws IntegralExchangeException { if (uid == null || uid <= 0) @@ -199,7 +201,7 @@ Integer state = exchange.getState(); if (state == null || state != 1) throw new IntegralExchangeException(1, "兑换活动未开启"); long exchangeCount = 0; ExchangeTypeEnum type = exchange.getType(); if (ExchangeTypeEnum.freeCouponBuy == type) { @@ -208,55 +210,59 @@ throw new IntegralExchangeException(1, "自购免单券,仅能兑换一次"); } } Integer upperLimit = exchange.getUpperLimit(); if (upperLimit != null) { // 是否有限制每日次数 if (upperLimit != null) { // 是否有限制每日次数 Integer today = 1; exchangeCount = integralExchangeRecordService.countRecordByUid(id, uid, today); if (exchangeCount >= upperLimit) { throw new IntegralExchangeException(1, "兑换已达上限"); } } Integer goldCoin = exchange.getGoldCoin(); Integer goldCoinHas = extraVO.getGoldCoin(); if (goldCoin.intValue() > goldCoinHas.intValue()) { throw new IntegralExchangeException(1, "当前账户中可用金币不足,无法兑换该奖品!"); } String thing = ""; String thingNum = ""; int couponNews = 0; boolean once = false; // 兑换一次是否消失 try { if (ExchangeTypeEnum.freeCouponBuy == type) { List<UserSystemCoupon> listCoupon = userSystemCouponService.getFreeCouponByType(uid, CouponTypeEnum.freeCouponBuy.name()); List<UserSystemCoupon> listCoupon = userSystemCouponService.getFreeCouponByType(uid, CouponTypeEnum.freeCouponBuy.name()); if (listCoupon != null && listCoupon.size() > 0) throw new IntegralExchangeException(1, "自购免单券,仅能兑换一次"); thing = "自购免单券"; thingNum = "1张"; userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponBuy.name(), UserSystemCoupon.SOURCE_EXCHANGE, null); once = true; userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponBuy.name(), UserSystemCoupon.SOURCE_EXCHANGE, null); once = true; couponNews = 1; } else if (ExchangeTypeEnum.freeCouponGive == type) { thing = "赠送免单券"; thingNum = "1张"; userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponGive.name(), UserSystemCoupon.SOURCE_EXCHANGE, null); userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.freeCouponGive.name(), UserSystemCoupon.SOURCE_EXCHANGE, null); couponNews = 1; } else if (ExchangeTypeEnum.rebatePercentCoupon == type) { thing = "返利奖励券"; thingNum = "1张"; String percent = configService.get("exchange_rebate_percent"); userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent)); userSystemCouponService.exchangeCoupon(uid, CouponTypeEnum.rebatePercentCoupon.name(), UserSystemCoupon.SOURCE_EXCHANGE, new BigDecimal(percent)); couponNews = 1; } else if (ExchangeTypeEnum.inviteCodePublish == type) { thing = "邀请码发布卡"; thingNum = "3天"; if(codePublishRecordService.countValidRecord(uid) > 0) if (codePublishRecordService.countValidRecord(uid) > 0) throw new IntegralExchangeException(1, "三天之内不可重复兑换"); codePublishRecordService.publishInviteCode(uid); exchange.setNeedJump(true); exchange.setBtnName("去查看"); } else if (ExchangeTypeEnum.taoLiJin == type) { @@ -267,7 +273,7 @@ thing = "现金红包"; BigDecimal money = exchange.getAmount(); thingNum = money + "元"; // 1、插入红包数据 HongBaoV2 hongBaoV2 = new HongBaoV2(); hongBaoV2.setMoney(money); @@ -288,30 +294,31 @@ } else { throw new IntegralExchangeException(1, "兑换方式不存在"); } exchangeCount ++; exchangeCount++; String progress = exchange.getProgress(); if (!StringUtil.isNullOrEmpty(progress)) progress = progress.replace("{已兑换}",exchangeCount + "").replace("{上限数}", exchange.getUpperLimit() + ""); progress = progress.replace("{已兑换}", exchangeCount + "").replace("{上限数}", exchange.getUpperLimit() + ""); exchange.setProgress(progress); // 剩余金币 int surplus = goldCoinHas.intValue() - goldCoin.intValue(); exchange.setUserGoldCoin(surplus + "枚"); // 更新金币 + 福利中心消息数 if (extraVO.getCouponNews() != null && extraVO.getCouponNews() > 0) if (extraVO.getCouponNews() != null && extraVO.getCouponNews() > 0) couponNews = couponNews + extraVO.getCouponNews(); UserInfoExtraVO extraUpdate = new UserInfoExtraVO(); extraUpdate.setId(extraVO.getId()); extraUpdate.setGoldCoin(surplus); extraUpdate.setCouponNews(couponNews); userInfoExtraService.saveUserInfoExtra(extraUpdate); // 添加兑换记录 integralExchangeRecordService.addExchangeRecord(id, uid); // 加入明细 IntegralDetail detail = new IntegralDetail(); detail.setUid(uid); @@ -319,8 +326,8 @@ detail.setMoney(-goldCoin); detail.setCreateTime(new Date()); integralDetailService.insertSelective(detail); // 消息 // 消息 final String things = thing; executor.execute(new Runnable() { @Override @@ -333,10 +340,10 @@ userOtherMsgNotificationService.exchangeMsg(uid, "", msgOther); } }); if (once) // 兑换之后消失 exchange = null; return exchange; } catch (IntegralExchangeException e) { throw new IntegralExchangeException(1, e.getMsg()); @@ -345,10 +352,9 @@ throw new IntegralExchangeException(1, "兑换异常"); } } @Override public ExchangeTipVO verifyInviteCode(Long uid, Long id) throws IntegralExchangeException{ public ExchangeTipVO verifyInviteCode(Long uid, Long id) throws IntegralExchangeException { if (uid == null || uid <= 0) throw new IntegralExchangeException(1, "用户未登录"); @@ -359,9 +365,9 @@ if (extraVO == null) throw new IntegralExchangeException(1, "用户相关信息不存在"); if (!StringUtil.isNullOrEmpty(extraVO.getInviteCode())) if (!StringUtil.isNullOrEmpty(extraVO.getInviteCode())) throw new IntegralExchangeException(1, "邀请码已激活,无需兑换"); CodePublishRecord record = codePublishRecordService.selectByPrimaryKey(id); if (record == null) throw new IntegralExchangeException(1, "兑换记录不存在"); @@ -379,15 +385,14 @@ exchangeTip.setTip("当前账户中可用金币不足,无法兑换该奖品!"); exchangeTip.setGoldCoin((goldCoin.intValue() - goldCoinHas.intValue()) + "金币"); return exchangeTip; } } exchangeTip.setTip("注:兑换成功后请到“消息-系统消息”查看"); exchangeTip.setGoldCoin(goldCoin + "金币"); exchangeTip.setType(ExchangeTypeEnum.inviteCodeActivate.name()); return exchangeTip; } @Override public String exchangeInviteCode(Long uid, Long id) throws IntegralExchangeException { if (uid == null || uid <= 0) @@ -400,9 +405,9 @@ if (extraVO == null) throw new IntegralExchangeException(1, "用户相关信息不存在"); if (!StringUtil.isNullOrEmpty(extraVO.getInviteCode())) if (!StringUtil.isNullOrEmpty(extraVO.getInviteCode())) throw new IntegralExchangeException(1, "邀请码已激活,无需兑换"); CodePublishRecord record = codePublishRecordService.selectByPrimaryKey(id); if (record == null) throw new IntegralExchangeException(1, "兑换记录不存在"); @@ -415,24 +420,23 @@ Integer goldCoinHas = extraVO.getGoldCoin(); if (goldCoin.intValue() > goldCoinHas.intValue()) throw new IntegralExchangeException(1, "当前账户中可用金币不足,无法兑换该奖品!"); try { UserInfoExtraVO inviteExtra = userInfoExtraService.getInfoExtraVOByUid(record.getUid()); if (inviteExtra == null || StringUtil.isNullOrEmpty(inviteExtra.getInviteCode())) throw new IntegralExchangeException(1, "兑换失败,该用户邀请码不存在"); String inviteCode = inviteExtra.getInviteCode(); // 剩余金币 int surplus = goldCoinHas.intValue() - goldCoin.intValue(); // 更新金币 UserInfoExtraVO extraUpdate = new UserInfoExtraVO(); extraUpdate.setId(extraVO.getId()); extraUpdate.setGoldCoin(surplus); userInfoExtraService.saveUserInfoExtra(extraUpdate); // 加入明细 IntegralDetail detail = new IntegralDetail(); detail.setUid(uid); @@ -440,34 +444,35 @@ detail.setMoney(-goldCoin); detail.setCreateTime(new Date()); integralDetailService.insertSelective(detail); // 添加兑换记录 integralExchangeRecordService.addExchangeRecord(exchange.getId(), uid); // 消息 // 消息 executor.execute(new Runnable() { @Override public void run() { UserInfo userInfo = userInfoService.selectByPKey(record.getUid()); if (userInfo == null) return; String beizu = "邀请人:" + userInfo.getNickName() + ",邀请码:" + inviteCode; MsgOtherExchangeContentDTO msgOther = new MsgOtherExchangeContentDTO(); msgOther.setState("金币兑换成功"); msgOther.setExpend(goldCoin + "金币"); msgOther.setTotalGold(surplus + "金币"); msgOther.setThing("邀请码激活卡"); userOtherMsgNotificationService.exchangeMsg(uid, beizu, msgOther); } }); return inviteCode; } catch (Exception e) { LogHelper.errorDetailInfo(e); throw new IntegralExchangeException(1, "兑换失败"); } } } fanli/src/main/java/com/yeshi/fanli/service/inter/user/integral/IntegralExchangeRecordService.java
@@ -14,6 +14,7 @@ * @return */ public List<IntegralExchange> listExchange(long start, int count, Long uid); /** * 今日任务统计 fanli/src/main/java/com/yeshi/fanli/service/inter/user/integral/IntegralExchangeService.java
@@ -7,6 +7,13 @@ import com.yeshi.fanli.vo.integral.ExchangeTipVO; public interface IntegralExchangeService { /** * 根据主键查询 * @param id * @return */ public IntegralExchange selectByPrimaryKey(Long id); /** * 查询有效的 fanli/src/main/java/com/yeshi/fanli/util/SpringContext.java
@@ -171,10 +171,10 @@ doUpdateGoodsJob(); // 更新商品队列 doJDOrderJob();// 京东订单处理 doPDDOrderJob();// 拼多多订单处理 doImportantTaoBaoGoodsUpdateJob();// 淘宝重要商品的信息更新 doImportantTaoBaoGoodsUpdateJob();// 淘宝重要商品的信息更新 doHongBaoRecieveIntegralGetJob();// 返利到账,金币增加 // doPlaceOrderIntegralJob();// 下单赠送金币任务 doDouYinDeviceActiveJob();// 抖音设备激活广告监测 // doPlaceOrderIntegralJob();// 下单赠送金币任务 doDouYinDeviceActiveJob();// 抖音设备激活广告监测 } } @@ -791,79 +791,83 @@ Map<String, Order> map = PlaceOrderCMQManager.getInstance() .consumeQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL, 16); if (map != null) { // 是否是首单 for (Iterator<String> its = map.keySet().iterator(); its.hasNext();) { try { String key = its.next(); Order order = map.get(key); // 统计订单下的用户所获得的返利金额 List<CommonOrder> list = commonOrderService .listBySourceTypeAndOrderId(order.getOrderType(), order.getOrderId()); Map<Long, BigDecimal> hongBaoMoney = new HashMap<>(); if (list != null) for (CommonOrder commonOrder : list) { HongBaoOrder hongBaoOrder = hongBaoOrderService .selectDetailByCommonOrderId(commonOrder.getId()); if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) { Long mainUid = hongBaoOrder.getHongBaoV2().getUserInfo().getId(); if (hongBaoMoney.get(mainUid) == null) hongBaoMoney.put(mainUid, new BigDecimal(0)); hongBaoMoney.put(mainUid, hongBaoMoney.get(mainUid) .add(hongBaoOrder.getHongBaoV2().getMoney())); // 查询上级 List<HongBaoV2> children = hongBaoV2Service .listChildrenById(hongBaoOrder.getHongBaoV2().getId()); if (children != null) { for (HongBaoV2 hongBao : children) { Long uid = hongBao.getUserInfo().getId(); if (hongBaoMoney.get(uid) == null) hongBaoMoney.put(uid, new BigDecimal(0)); hongBaoMoney.put(uid, hongBaoMoney.get(uid).add(hongBao.getMoney())); // 是否是首单 if (isFirstValidOrder(order.getOrderId(), order.getOrderType(), order.getUserInfo().getId())) { // 统计订单下的用户所获得的返利金额 List<CommonOrder> list = commonOrderService .listBySourceTypeAndOrderId(order.getOrderType(), order.getOrderId()); Map<Long, BigDecimal> hongBaoMoney = new HashMap<>(); if (list != null) for (CommonOrder commonOrder : list) { HongBaoOrder hongBaoOrder = hongBaoOrderService .selectDetailByCommonOrderId(commonOrder.getId()); if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) { Long mainUid = hongBaoOrder.getHongBaoV2().getUserInfo().getId(); if (hongBaoMoney.get(mainUid) == null) hongBaoMoney.put(mainUid, new BigDecimal(0)); hongBaoMoney.put(mainUid, hongBaoMoney.get(mainUid) .add(hongBaoOrder.getHongBaoV2().getMoney())); // 查询上级 List<HongBaoV2> children = hongBaoV2Service .listChildrenById(hongBaoOrder.getHongBaoV2().getId()); if (children != null) { for (HongBaoV2 hongBao : children) { Long uid = hongBao.getUserInfo().getId(); if (hongBaoMoney.get(uid) == null) hongBaoMoney.put(uid, new BigDecimal(0)); hongBaoMoney.put(uid, hongBaoMoney.get(uid).add(hongBao.getMoney())); } } } } } if (isFirstValidOrder(order.getOrderId(), order.getOrderType(), order.getUserInfo().getId())) {// 有效的首单 if (hongBaoMoney.get(order.getUserInfo().getId()) == null || hongBaoMoney .get(order.getUserInfo().getId()).compareTo(new BigDecimal("0")) <= 0) { // 分享奖金是0 integralTaskRecordService.firstShareOrderReward(order.getUserInfo().getId(), null); } // 获取上两级数据 UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId()); if (boss != null) {// 判断上级的红包 if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) { // 补偿金币 integralTaskRecordService.firstSharerOrderRewardBoss(boss.getId(), order.getUserInfo().getId(), null); } } } else {// 自购订单 UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId()); if (boss != null) {// 判断上级的红包 if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) { // 补偿金币1级 integralTaskRecordService.firstRebateOrderRewardBoss(boss.getId(), order.getUserInfo().getId(), null); if (isFirstValidOrder(order.getOrderId(), order.getOrderType(), order.getUserInfo().getId())) {// 有效的首单 if (hongBaoMoney.get(order.getUserInfo().getId()) == null || hongBaoMoney .get(order.getUserInfo().getId()).compareTo(new BigDecimal("0")) <= 0) { // 分享奖金是0 integralTaskRecordService.firstShareOrderReward(order.getUserInfo().getId(), null); } boss = threeSaleSerivce.getBoss(boss.getId()); // 获取上两级数据 UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId()); if (boss != null) {// 判断上级的红包 if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId()) .compareTo(new BigDecimal("0")) <= 0) { // 补偿金币2级 integralTaskRecordService.firstRebateOrderRewardBossSuper(boss.getId(), // 补偿金币 integralTaskRecordService.firstSharerOrderRewardBoss(boss.getId(), order.getUserInfo().getId(), null); } } } else {// 自购订单 UserInfo boss = threeSaleSerivce.getBoss(order.getUserInfo().getId()); if (boss != null) {// 判断上级的红包 if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney.get(boss.getId()) .compareTo(new BigDecimal("0")) <= 0) { // 补偿金币1级 integralTaskRecordService.firstRebateOrderRewardBoss(boss.getId(), order.getUserInfo().getId(), null); } boss = threeSaleSerivce.getBoss(boss.getId()); if (boss != null) {// 判断上级的红包 if (hongBaoMoney.get(boss.getId()) == null || hongBaoMoney .get(boss.getId()).compareTo(new BigDecimal("0")) <= 0) { // 补偿金币2级 integralTaskRecordService.firstRebateOrderRewardBossSuper( boss.getId(), order.getUserInfo().getId(), null); } } } } } PlaceOrderCMQManager.getInstance().deleteQueueMsg(PlaceOrderCMQManager.QUEUE_INTEGRAL,