From 972d3bc71115ec977dccf835fbcd148da3bcc86c Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期二, 03 九月 2019 16:41:49 +0800 Subject: [PATCH] 统计可用的免单券数量-countUsableFreeCouponForBuy --- fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java | 84 ++++++++++++++++++++++++++++++----------- 1 files changed, 61 insertions(+), 23 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java index 03aa650..8c001fd 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java @@ -41,11 +41,11 @@ import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig; import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack; import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder; -import com.yeshi.fanli.exception.HongBaoException; -import com.yeshi.fanli.exception.OrderItemException; -import com.yeshi.fanli.exception.TaoBaoWeiQuanException; import com.yeshi.fanli.exception.money.UserMoneyDetailException; import com.yeshi.fanli.exception.order.CommonOrderException; +import com.yeshi.fanli.exception.order.HongBaoException; +import com.yeshi.fanli.exception.order.OrderItemException; +import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException; import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService; import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service; @@ -66,6 +66,7 @@ import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.TaoBaoConstant; import com.yeshi.fanli.util.TimeUtil; +import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager; import com.yeshi.fanli.util.factory.UserMoneyDetailFactory; import com.yeshi.fanli.util.jd.JDApiUtil; import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil; @@ -307,12 +308,20 @@ return; } - // 鐏板害娴嬭瘯涓紝浜笢/鎷煎澶氫笉杩斿埄 - if (hongBaoOrder.getCommonOrder() == null - || hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_JD - || hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_PDD) { + if (hongBaoOrder.getCommonOrder() == null) {// || + // hongBaoOrder.getCommonOrder().getSourceType() + // == + // Constant.SOURCE_TYPE_JD + // || hongBaoOrder.getCommonOrder().getSourceType() == + // Constant.SOURCE_TYPE_PDD return; } + + // 濡傛灉鏄嫾澶氬/浜笢缁存潈鍒欒繑鍥烇紝涓嶉渶瑕佽繑鍒� + if ((hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_PDD + || hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_JD) + && hongBaoOrder.getCommonOrder().getState() == CommonOrder.STATE_WQ) + return; if (hongBaoOrder.getCommonOrder() != null && hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_TAOBAO) { @@ -404,6 +413,11 @@ // 娣诲姞璧勯噾鏄庣粏涓庣孩鍖呯殑鏄犲皠鍏崇郴 for (HongBaoV2 v2 : userHongBao.get(uid)) { accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(v2.getId(), userMoneyDetail.getId()); + try { + HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(v2.getId()); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } } // 绔欏唴淇�+鎺ㄩ�� @@ -567,6 +581,7 @@ @Override @Transactional public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException { + List<Long> recieveHongBaoIds = new ArrayList<>(); /** * 澶勭悊閭�璇疯禋璁㈠崟 */ @@ -574,7 +589,16 @@ List<Integer> types = new ArrayList<>(); types.add(HongBaoV2.TYPE_YIJI); types.add(HongBaoV2.TYPE_ERJI); - List<HongBaoV2> hongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 1000); + long count = hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid); + List<HongBaoV2> hongBaoList = new ArrayList<>(); + // 1000鏉℃暟鎹负1椤� + int page = (int) (count % 1000 == 0 ? count / 1000 : count / 1000 + 1); + for (int i = 0; i < page; i++) { + List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, i * 1000, + 1000); + if (tempHongBaoList != null && tempHongBaoList.size() > 0) + hongBaoList.addAll(tempHongBaoList); + } // 鐏板害娴嬭瘯涓紝浜笢/鎷煎澶氳鍗曞垎浜�/閭�璇疯鍗曚笉杩斿埄 for (int i = 0; i < hongBaoList.size(); i++) { HongBaoV2 item = hongBaoList.get(i); @@ -586,17 +610,13 @@ HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getId()); if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) { CommonOrder co = hongBaoOrder.getCommonOrder(); - if (co.getSourceType() == Constant.SOURCE_TYPE_JD - || co.getSourceType() == Constant.SOURCE_TYPE_PDD) { + // 涓婄骇鐢ㄦ埛涓嶆槸姝e父鐢ㄦ埛锛岃鍗曞潎涓嶈兘鍒拌处 + UserInfo userInfo = userInfoMapper.selectByPrimaryKey(co.getUserInfo().getId()); + if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) { hongBaoList.remove(i); i--; - } else {// 涓婄骇鐢ㄦ埛涓嶆槸姝e父鐢ㄦ埛锛岃鍗曞潎涓嶈兘鍒拌处 - UserInfo userInfo = userInfoMapper.selectByPrimaryKey(item.getUserInfo().getId()); - if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) { - hongBaoList.remove(i); - i--; - } } + } } } @@ -651,7 +671,8 @@ types.clear(); types.add(HongBaoV2.TYPE_SHARE_YIJI); types.add(HongBaoV2.TYPE_SHARE_ERJI); - List<HongBaoV2> hbList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 10000); + // TODO 闇�瑕佸鐞嗚秴杩�1w鏉℃暟鎹殑璁㈠崟 + List<HongBaoV2> hbList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 0, 10000); if (hbList != null && hbList.size() > 0) totalHongBaoList.addAll(hbList); @@ -696,11 +717,9 @@ minDate, maxDate); long weiQuanCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ, minDate, maxDate); - long invalidCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_SX, - minDate, maxDate); UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, Constant.SOURCE_TYPE_TAOBAO, - (int) validCount, (int) weiQuanCount, (int) invalidCount, invitemoney, new Date()); + (int) validCount, (int) weiQuanCount, invitemoney, new Date()); // 澧炲姞璧勯噾 userMoneyService.addUserMoney(uid, invitemoney, userMoneyDetail); @@ -721,7 +740,8 @@ for (String orderId : drawBackOrders) taoBaoWeiQuanDrawBackService.doWeiQuanInvite(orderId); } - + if (hbIdList.size() > 0) + recieveHongBaoIds.addAll(hbIdList); hbIdList.clear(); drawBackOrders.clear(); @@ -735,7 +755,8 @@ // 鏌ヨUID鐨勫垎浜禋璁㈠崟 types.clear(); types.add(HongBaoV2.TYPE_SHARE_GOODS); - List<HongBaoV2> hongBaoShareList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 10000); + // TODO 闇�瑕佸鐞嗚秴杩�10000鏉℃暟鎹殑璁㈠崟 + List<HongBaoV2> hongBaoShareList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 0, 10000); for (HongBaoV2 hongBao : hongBaoShareList) { hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId()); hongBao = filterWeiQuanINGHongBao(hongBao); @@ -790,12 +811,14 @@ minDate, maxDate); UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO, - (int) validCount, (int) weiQuanCount, (int) invalidCount, sharemoney, new Date()); + (int) validCount, (int) weiQuanCount, sharemoney, new Date()); // 娣诲姞璧勯噾 userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail); // 娣诲姞鍒扮孩鍖呰繑鍒╄褰曢泦鍚� accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId()); + if (hbIdList.size() > 0) + recieveHongBaoIds.addAll(hbIdList); } catch (UserMoneyDetailException e) { try { LogHelper.errorDetailInfo(e); @@ -810,6 +833,16 @@ for (String orderId : drawBackOrders) taoBaoWeiQuanDrawBackService.doWeiQuanShare(orderId); + } + + // 鎵�鏈夌殑杩斿埄鍒拌处绾㈠寘ID + for (Long hongBaoId : recieveHongBaoIds) { + try { + HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId); + } catch (Exception e) { + LogHelper.errorDetailInfo(e); + } + } } @@ -980,6 +1013,11 @@ public void processJDOrder(JDOrder order) { if (order == null || order.getOrderItemList() == null || order.getOrderItemList().size() == 0) return; + + // 鎷嗗崟鐨勪笉鍋氬鐞� + if (order.getValidCode() == 2) + return; + String uidStr = order.getExt1(); Long uid = null; if (!StringUtil.isNullOrEmpty(uidStr) && NumberUtil.isNumeric(uidStr)) -- Gitblit v1.8.0