From 89cc8f054c27f70fcfe16f14554a8a12e0c19e23 Mon Sep 17 00:00:00 2001 From: yujian <yujian@163.com> Date: 星期三, 18 十二月 2019 09:22:31 +0800 Subject: [PATCH] 邀请统计 --- fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java | 129 +++++++++++++++++++++++------------------- 1 files changed, 70 insertions(+), 59 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java index 306113a..a6075af 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java @@ -52,6 +52,7 @@ import com.yeshi.fanli.service.inter.order.HongBaoOrderService; import com.yeshi.fanli.service.inter.order.HongBaoV2Service; import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService; +import com.yeshi.fanli.service.inter.user.UserInfoService; import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService; import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService; @@ -121,6 +122,9 @@ @Resource private UserVIPInfoService userVIPInfoService; + + @Resource + private UserInfoService userInfoService; // 濂栧姳璁㈠崟鍥剧墖 public final static String PIC_REWARD = "http://img.flqapp.com/resource/order/order_state_reward.png"; @@ -200,10 +204,9 @@ // 鏁版嵁鍔犲伐閲嶆柊缁勭粐 orderVOFactory(acceptData, listOrder, listGoods, uid); - + return listOrder; } - /** * 璁㈠崟淇℃伅鍔犲伐 @@ -269,11 +272,11 @@ order.setVipOrder(false); } else order.setVipOrder(false); - - if(order.isVipOrder()) + + if (order.isVipOrder()) order.setVipOrderDesc("璁㈠崟鏉ユ簮锛氱敱瓒呯骇浼氬憳鐨勭矇涓濅骇鐢�"); } - + SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm"); SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd"); // 2019.8.1寮�濮嬭繑鍥炵淮鏉冧俊鎭� @@ -489,7 +492,7 @@ } } order.setSignList(signList); - + String hongBaoDate = null; String hongBaoState_Str = ""; String hongbaoInfoFontColor = "#E5005C"; @@ -549,21 +552,21 @@ hongBaoMap.put("content", hongbaoInfo + " 楼" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString()); hongBaoMap.put("fontColor", hongbaoInfoFontColor); order.setHongBaoInfo(hongBaoMap); - + // 鏄剧ず杩斿埄銆佸厤鍗曡鎯� if (HongBaoV2.TYPE_ZIGOU == hongBaoType) { // 濂栧姳璁㈠崟銆佸厤鍗� 浣跨敤璁板綍 if (sourceType == null) { couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, null, uid, vip, acceptData); } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) { - couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, - listRecordTB, uid, vip, acceptData); + couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, uid, vip, + acceptData); } else if (sourceType == Constant.SOURCE_TYPE_JD) { - couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, - listRecordJD, uid, vip, acceptData); + couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, uid, vip, + acceptData); } else if (sourceType == Constant.SOURCE_TYPE_PDD) { - couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, - listRecordPDD, uid, vip, acceptData); + couponFactory(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, uid, vip, + acceptData); } } @@ -575,8 +578,7 @@ } } } - - + /** * 璁㈠崟锛� 鍏嶅崟鏍囪瘑 濂栧姳鏍囪瘑 * @@ -586,21 +588,21 @@ * @param list * @param signList */ - private void couponFactory(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState, - Integer hongBaoType, List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData) throws Exception{ + private void couponFactory(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState, Integer hongBaoType, + List<UserSystemCouponRecord> list, Long uid, boolean vip, AcceptData acceptData) throws Exception { // 鏄惁鍏嶅崟鍟嗗搧 boolean freeOrder = false; // 鏄惁濂栧姳鎴愬姛 boolean rewardSuccess = false; boolean version2_1 = VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion()); - + if (list != null && list.size() > 0) { for (UserSystemCouponRecord couponRecord : list) { int goodSource = couponRecord.getGoodSource(); if (goodSource == 0) goodSource = 1; - + if (order.getOrderNo().equals(couponRecord.getOrderNo()) && goodSource == order.getSourceType()) { Integer state = couponRecord.getState(); String systemCouponType = couponRecord.getCouponType(); @@ -634,7 +636,7 @@ } } } - + // 鍏嶅崟璇︽儏 if (freeOrder) { ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO(); @@ -658,19 +660,19 @@ rewardMap.put("jump", jump); order.setRewardDetail(rewardMap); } - + // 宸蹭娇鐢ㄥ鍔卞埜 if (rewardSuccess) { ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO(); rewardStyleVO.setColor("#E5005C"); rewardStyleVO.setBottomColor("#FFDCEA"); - + if (version2_1) { rewardStyleVO.setContent("宸蹭娇鐢ㄥ鍔卞埜 >"); } else { rewardStyleVO.setContent("杩斿埄濂栧姳 >"); } - + Map<String, Object> rewardMap = new HashMap<String, Object>(); rewardMap.put("text", rewardStyleVO); Map<String, Object> jumpLink = new HashMap<String, Object>(); @@ -678,58 +680,60 @@ jumpLink.put("goodsType", order.getSourceType() + ""); Map<String, Object> jump = new HashMap<String, Object>(); - jump.put("type", 1); // 1 甯歌璺宠浆椤甸潰 + jump.put("type", 1); // 1 甯歌璺宠浆椤甸潰 jump.put("params", jumpLink); jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail")); rewardMap.put("jump", jump); order.setRewardDetail(rewardMap); } - - // 鏄惁鍙娇鐢ㄥ鍔卞埜 - if (!rewardSuccess && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType - && HongBaoV2.STATE_YILINGQU == hongBaoState && !vip && CommonOrder.STATE_WQ != order.getState()) { - if (version2_1) { - rewardCounponLimitTime(order); // 2.1 鐗堥檺鍒� - } else if (hasRewardCoupon) { - Map<String, Object> rewardMap = new HashMap<String, Object>(); + // 鏄惁鍙娇鐢ㄥ鍔卞埜 + if (!rewardSuccess && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType + && HongBaoV2.STATE_YILINGQU == hongBaoState && !vip && CommonOrder.STATE_WQ != order.getState()) { + // 涓嬪崟鏃堕棿 + Date thirdCreateTime = order.getThirdCreateTime(); + // 鍒拌处鏃堕棿 + Date accountTime = order.getAccountTime(); + if (thirdCreateTime == null || accountTime == null) + return; + + // 涓嬪崟鏃ユ湡鏄惁鏄鍚堜笂绾挎棩鏈� + long downOrderTime = thirdCreateTime.getTime(); + long limitDate = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME); + if (downOrderTime > limitDate) { + // 2.1 寮�濮嬫柊鐗� + rewardCounponLimitTime(order, accountTime); + } else if (hasRewardCoupon) { + // 鍦�2.1鏂扮増涓婄嚎涔嬪墠璁㈠崟-瀛樺湪鍒欐樉绀哄鍔卞埜鍙娇鐢� ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO(); rewardStyleVO.setColor("#E5005C"); rewardStyleVO.setBottomColor("#FFDCEA"); rewardStyleVO.setContent("杩斿埄濂栧姳 >"); - rewardMap.put("text", rewardStyleVO); + Map<String, Object> jumpLink = new HashMap<String, Object>(); jumpLink.put("orderNo", order.getOrderNo()); jumpLink.put("goodsType", order.getSourceType() + ""); - + Map<String, Object> jump = new HashMap<String, Object>(); jump.put("type", 2); // 寮规 jump.put("params", jumpLink); jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("rewardCouponDetail")); + + Map<String, Object> rewardMap = new HashMap<String, Object>(); + rewardMap.put("text", rewardStyleVO); rewardMap.put("jump", jump); order.setRewardDetail(rewardMap); - } + } } } - private void rewardCounponLimitTime(CommonOrderVO order) throws Exception { - Date thirdCreateTime = order.getThirdCreateTime(); - Date accountTime = order.getAccountTime(); - if (thirdCreateTime == null || accountTime == null) - return; - - // 涓嬪崟鏃ユ湡鏄惁鏄鍚堜笂绾挎棩鏈� - long downOrderTime = thirdCreateTime.getTime(); - long limitDate = TimeUtil.parse(Constant.COUPON_REWARD_TIME).getTime(); - if (downOrderTime < limitDate) - return; - + private void rewardCounponLimitTime(CommonOrderVO order, Date accountTime) throws Exception { // 鍊掕鏃堕獙璇� Date endDay = DateUtil.plusDayDate(Constant.COUPON_REWARD_LIMIT_DAY, accountTime); long currentTime = java.lang.System.currentTimeMillis(); if (endDay.getTime() <= currentTime) return; - + String num = null; String unit = null; boolean canUse = false; @@ -760,16 +764,16 @@ } // 宸茬粡瓒呮椂 - if (!canUse) + if (!canUse) return; - + Map<String, Object> rewardMap = new HashMap<String, Object>(); ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO(); rewardStyleVO.setColor("#E5005C"); rewardStyleVO.setBottomColor("#FFDCEA"); rewardStyleVO.setContent("浣跨敤濂栧姳鍒�"); rewardMap.put("text", rewardStyleVO); - + ClientTextStyleVO txt1 = new ClientTextStyleVO(); txt1.setContent("鍓�"); txt1.setColor("#666666"); @@ -802,13 +806,12 @@ rewardMap.put("jump", jump); order.setRewardDetail(rewardMap); } - - + @Override public Map<String, BigDecimal> countHistoryOrder(Long uid, Integer day, Integer source) { return commonOrderMapper.countHistoryOrder(uid, day, source); } - + @Override public OrderCountVO getOrderCount(Long uid, Integer day, Integer source) { return commonOrderMapper.getOrderCount(uid, day, source); @@ -1091,6 +1094,16 @@ if (oldCommonOrder == null)// 鏂板 { commonOrder.setCreateTime(new Date()); + // 鏌ヨ鏄惁涓簐ip + boolean isVIP = userVIPInfoService.isVIP(commonOrder.getUserInfo().getId()); + if (isVIP) + commonOrder.setUrank(100);// VIP璁㈠崟 + else { + UserInfo user = userInfoService.selectAvailableByPrimaryKey(commonOrder.getUserInfo().getId()); + if (user != null) + commonOrder.setUrank(user.getRank()); + } + commonOrderMapper.insertSelective(commonOrder); // 鎻掑叆鏄犲皠锛屼繚璇佷氦鏄揑D鐨勫畬鏁存�� commonOrderTradeIdMapMapper.insertSelective(new CommonOrderTradeIdMap(commonOrder.getId(), @@ -1525,13 +1538,13 @@ JSONObject map = new JSONObject(); // 璁㈠崟鏍囪瘑 List<String> signList = new ArrayList<String>(); - signList.add(CommonOrder.TYPE_FANLI); - signList.add(PIC_REWARD); // 鍔犲叆濂栧姳鎴愬姛鍥剧墖 + // signList.add(CommonOrder.TYPE_FANLI); + // signList.add(PIC_REWARD); // 鍔犲叆濂栧姳鎴愬姛鍥剧墖 map.put("signList", signList); ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO(); // 濂栧姳鍒歌繘搴﹁鎯� - rewardStyleVO.setContent("杩斿埄濂栧姳 >"); + rewardStyleVO.setContent("宸蹭娇鐢ㄥ鍔卞埜 >"); rewardStyleVO.setColor("#E5005C"); rewardStyleVO.setBottomColor("#FFDCEA"); @@ -1547,9 +1560,7 @@ Map<String, Object> rewardMap = new HashMap<String, Object>(); rewardMap.put("text", rewardStyleVO); rewardMap.put("jump", jump); - map.put("rewardDetail", rewardMap); - return map; } -- Gitblit v1.8.0