From 6f39058853846f0580545878921fa2b2fb02773f Mon Sep 17 00:00:00 2001
From: yujian <yujian@123.com>
Date: 星期一, 26 八月 2019 15:33:50 +0800
Subject: [PATCH] 券调整
---
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java | 571 ++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 386 insertions(+), 185 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 be802b0..066ec25 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
@@ -1,6 +1,7 @@
package com.yeshi.fanli.service.impl.order;
import java.math.BigDecimal;
+import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@@ -52,9 +53,13 @@
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.MoneyBigDecimalUtil;
import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.TimeUtil;
+import com.yeshi.fanli.util.VersionUtil;
+import com.yeshi.fanli.util.account.UserUtil;
import com.yeshi.fanli.util.factory.CommonOrderGoodsFactory;
import com.yeshi.fanli.util.factory.goods.CommonOrderFactory;
import com.yeshi.fanli.util.jd.JDApiUtil;
+import com.yeshi.fanli.util.jd.JDUtil;
import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
import com.yeshi.fanli.util.taobao.TaoBaoUtil;
@@ -62,6 +67,7 @@
import com.yeshi.fanli.vo.msg.ClientTextStyleVO;
import com.yeshi.fanli.vo.order.CommonOrderGoodsVO;
import com.yeshi.fanli.vo.order.CommonOrderVO;
+import com.yeshi.fanli.vo.order.WeiQuanInfo;
import net.sf.json.JSONObject;
@@ -153,12 +159,14 @@
@Override
public long countGroupOrderNoByUid(Long uid, Integer state, Integer type, Integer orderState, String orderNo,
String startTime, String endTime, Integer dateType, Integer source) throws CommonOrderException {
- return commonOrderMapper.countUserOrder(uid, state, type, orderState, orderNo, startTime, endTime, dateType, source);
+ return commonOrderMapper.countUserOrder(uid, state, type, orderState, orderNo, startTime, endTime, dateType,
+ source);
}
@Override
- public List<CommonOrderVO> getOrderByUid(AcceptData acceptData,Integer page, Long uid, Integer state, Integer type, Integer orderState,
- String orderNo, String startTime, String endTime, Integer dateType, Integer source) throws CommonOrderException {
+ public List<CommonOrderVO> getOrderByUid(AcceptData acceptData, Integer page, Long uid, Integer state, Integer type,
+ Integer orderState, String orderNo, String startTime, String endTime, Integer dateType, Integer source)
+ throws CommonOrderException {
int pageSize = Constant.PAGE_SIZE;
@@ -190,19 +198,21 @@
}
@Override
- public long countBonusOrderNumber(Long uid, Integer type, Integer day, String startTime, String endTime, Integer source) {
+ public long countBonusOrderNumber(Long uid, Integer type, Integer day, String startTime, String endTime,
+ Integer source) {
return commonOrderMapper.countBonusOrderNumber(uid, type, day, startTime, endTime, source);
}
@Override
- public BigDecimal countBonusOrderMoney(Long uid, Integer type, Integer day, String startTime, String endTime, Integer source) {
+ public BigDecimal countBonusOrderMoney(Long uid, Integer type, Integer day, String startTime, String endTime,
+ Integer source) {
return commonOrderMapper.countBonusOrderMoney(uid, type, day, startTime, endTime, source);
}
@Override
public Map<String, Object> countBonusOrderMoneyAndNumber(Long uid, Integer type, Integer day, String startTime,
- String endTime) {
- return commonOrderMapper.countBonusOrderMoneyAndNumber(uid, type, day, startTime, endTime);
+ String endTime, Integer source) {
+ return commonOrderMapper.countBonusOrderMoneyAndNumber(uid, type, day, startTime, endTime, source);
}
@Override
@@ -211,19 +221,42 @@
return commonOrderMapper.countByUidAndOrderState(uid, type, startTime, endTime, day, source);
}
- public void listDataFactory(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods, Long uid) {
+ public void listDataFactory(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods,
+ Long uid) {
- List<String> listNo = new ArrayList<String>();
+ List<String> listTB = new ArrayList<String>();
+ List<String> listJD = new ArrayList<String>();
+ List<String> listPDD = new ArrayList<String>();
for (CommonOrderVO commonOrderVO : listOrder) {
- listNo.add(commonOrderVO.getOrderNo());
+ Integer sourceType = commonOrderVO.getSourceType();
+ if (sourceType == null) {
+ continue;
+ } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
+ listTB.add(commonOrderVO.getOrderNo());
+ } else if (sourceType == Constant.SOURCE_TYPE_JD) {
+ listJD.add(commonOrderVO.getOrderNo());
+ } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
+ listPDD.add(commonOrderVO.getOrderNo());
+ }
}
- // 宸茬粡浣跨敤鍒歌鍗�
- List<UserSystemCouponRecord> couponRecordList = userSystemCouponRecordService.getRecordByOrderNoList(listNo);
+ List<UserSystemCouponRecord> listRecordTB = null;
+ if (listTB.size() > 0) {
+ listRecordTB = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_TAOBAO, listTB);
+ }
+
+ List<UserSystemCouponRecord> listRecordJD = null;
+ if (listJD.size() > 0) {
+ listRecordJD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_JD, listJD);
+ }
+
+ List<UserSystemCouponRecord> listRecordPDD = null;
+ if (listPDD.size() > 0) {
+ listRecordPDD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_PDD, listPDD);
+ }
/* 缁勫悎鍟嗗搧淇℃伅 */
for (CommonOrderVO commonOrder : listGoods) {
-
CommonOrderGoods goods = commonOrder.getCommonOrderGoods();
if (goods == null) {
continue;
@@ -231,7 +264,6 @@
String orderNo1 = commonOrder.getOrderNo();
Integer sourceType = commonOrder.getSourceType();
-
for (CommonOrderVO order : listOrder) {
String orderNo2 = order.getOrderNo();
Integer sourceType2 = order.getSourceType();
@@ -247,6 +279,8 @@
} catch (Exception e) {
e.printStackTrace();
}
+
+ commonGoodsVO.setGoodsType(sourceType2);
String picture = commonGoodsVO.getPicture();
if (!StringUtil.isNullOrEmpty(picture) && !picture.contains("320x320")) {
@@ -276,8 +310,6 @@
// 瀹炰粯娆�
commonGoodsVO.setActualPay("浠樻閲戦锛毬�" + totalSettlement);
- listOrderGoods.add(commonGoodsVO);
-
Integer orderType = order.getOrderType();
if (orderType == null) {
String shopType = commonGoodsVO.getShopType();
@@ -285,15 +317,9 @@
order.setOrderType(1);
} else if (CommonOrderGoodsVO.TYPE_TMALL.equalsIgnoreCase(shopType)) {
order.setOrderType(2);
- }
-
- if (Constant.SOURCE_TYPE_JD == sourceType2) {
- order.setOrderType(3);
- } else if (Constant.SOURCE_TYPE_PDD == sourceType2) {
- order.setOrderType(4);
}
}
-
+ listOrderGoods.add(commonGoodsVO);
break;
}
}
@@ -304,6 +330,14 @@
// 鏄惁瀛樺湪濂栧姳鍒�
boolean hasRewardCoupon = userSystemCouponService.hasRewardCoupon(uid);
+
+ // 2019.8.1寮�濮嬭繑鍥炵淮鏉冧俊鎭�
+ Date august = null;
+ try {
+ august = TimeUtil.parse("2019-08-01");
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
/* 缁勭粐璁㈠崟鐘舵�� 绛変俊鎭� */
for (CommonOrderVO order : listOrder) {
@@ -317,6 +351,18 @@
Date settleTime = order.getSettleTime();
if (settleTime != null) {
order.setReceiveTime("鏀惰揣鏃堕棿锛�" + format.format(settleTime));
+ }
+
+ Integer sourceType2 = order.getSourceType();
+ if (sourceType2 == Constant.SOURCE_TYPE_TAOBAO) {
+ Integer orderType = order.getOrderType();
+ if (orderType == null) {
+ order.setOrderType(1);
+ }
+ } else if (sourceType2 == Constant.SOURCE_TYPE_JD) {
+ order.setOrderType(3);
+ } else if (sourceType2 == Constant.SOURCE_TYPE_PDD) {
+ order.setOrderType(4);
}
/* 璁㈠崟鐘舵�� 杞崲澶勭悊 */
@@ -340,6 +386,11 @@
}
}
+ BigDecimal hongBao = order.getHongBao();
+ if (hongBao == null) {
+ hongBao = new BigDecimal(0);
+ }
+
if (CommonOrder.STATE_FK == orderState) {
orderStateContent = "宸蹭粯娆�";
} else if (CommonOrder.STATE_JS == orderState) {
@@ -349,30 +400,57 @@
} else if (CommonOrder.STATE_WQ == orderState) {
orderStateContent = "宸茬淮鏉�";
- /* 璁㈠崟缁存潈 鍒ゆ柇鏄惁鍏ㄩ儴缁存潈 */
- List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
- .selectListByOrderIdAndState(order.getOrderNo(), "缁存潈鎴愬姛");
+ Integer sourceType = order.getSourceType();
+ if (sourceType != null && sourceType == Constant.SOURCE_TYPE_TAOBAO) {
+ /* 璁㈠崟缁存潈 鍒ゆ柇鏄惁鍏ㄩ儴缁存潈 */
+ List<TaoBaoWeiQuanOrder> listWQ = taoBaoWeiQuanOrderMapper
+ .selectListByOrderIdAndState(order.getOrderNo(), "缁存潈鎴愬姛");
- boolean isPart = false;// 榛樿澶辨晥
+ boolean isPart = false;// 榛樿澶辨晥
+ BigDecimal weiQuanMoney = new BigDecimal(0);
+ if (listWQ != null && listWQ.size() > 0) {
+ BigDecimal fanTotalMoney = new BigDecimal(0);
+ for (TaoBaoWeiQuanOrder weiQuanOrder : listWQ) {
+ BigDecimal fanMoney = weiQuanOrder.getFanMoney();
+ if (fanMoney != null) {
+ fanTotalMoney = MoneyBigDecimalUtil.add(fanTotalMoney, fanMoney);
+ }
+ weiQuanMoney = MoneyBigDecimalUtil.add(weiQuanOrder.getMoney(), weiQuanMoney);
+ }
- if (listWQ != null && listWQ.size() > 0) {
- BigDecimal fanTotalMoney = new BigDecimal(0);
- for (TaoBaoWeiQuanOrder weiQuanOrder : listWQ) {
- BigDecimal fanMoney = weiQuanOrder.getFanMoney();
- if (fanMoney != null) {
- fanTotalMoney = MoneyBigDecimalUtil.add(fanTotalMoney, fanMoney);
+ if (fanTotalMoney.compareTo(hongBao) < 0) {
+ isPart = true;
}
}
- if (fanTotalMoney.compareTo(order.getHongBao()) < 0) {
- isPart = true;
+ if (!VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
+ if (isPart) {
+ hongBaoState = HongBaoV2.STATE_BUFENSHIXIAO; // 閮ㄥ垎澶辨晥
+ } else {
+ hongBaoState = HongBaoV2.STATE_SHIXIAO; // 鍏ㄩ儴澶辨晥
+ }
+ } else {
+ // 2019.8.1 杩斿洖缁存潈淇℃伅
+ if (settleTime != null && august != null && settleTime.getTime() > august.getTime()) {
+ orderStateContent = "缁存潈鎴愬姛";
+ WeiQuanInfo weiQuanInfo = new WeiQuanInfo();
+ weiQuanInfo.setOldHongBao("楼" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
+ if (isPart) {
+ // 缁存潈澶辨晥閲戦=缁存潈鐨勯噾棰�*鑾峰緱鐨勭孩鍖�/缁撶畻閲戦
+ BigDecimal settlement = order.getSettlement();
+ BigDecimal wqHongbao = MoneyBigDecimalUtil
+ .div(MoneyBigDecimalUtil.mul(hongBao, settlement), settlement);
+ weiQuanInfo.setWqHongBao(
+ "缁存潈锛�-楼" + wqHongbao.setScale(2, BigDecimal.ROUND_DOWN).toString());
+ hongBao = MoneyBigDecimalUtil.sub(hongBao, wqHongbao);
+ } else {
+ weiQuanInfo
+ .setWqHongBao("缁存潈锛�-楼" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
+ hongBao = new BigDecimal(0);
+ }
+ order.setWeiQuanInfo(weiQuanInfo);
+ }
}
- }
-
- if (isPart) {
- hongBaoState = HongBaoV2.STATE_BUFENSHIXIAO; // 閮ㄥ垎澶辨晥
- } else {
- hongBaoState = HongBaoV2.STATE_SHIXIAO; // 鍏ㄩ儴澶辨晥
}
}
orderStateMap.put("content", orderStateContent);
@@ -458,127 +536,154 @@
hongbaoInfo = hongBaoState_Str + hongbaoInfo;
- BigDecimal hongBao = order.getHongBao();
- if (hongBao == null) {
- hongBao = new BigDecimal(0);
- }
Map<String, String> hongBaoMap = new HashMap<String, String>();
hongBaoMap.put("content", hongbaoInfo + " 楼" + hongBao.setScale(2, BigDecimal.ROUND_DOWN).toString());
hongBaoMap.put("fontColor", hongbaoInfoFontColor);
order.setHongBaoInfo(hongBaoMap);
+ Integer sourceType = order.getSourceType();
// 闈炶嚜璐殑璁㈠崟 涓嶆樉绀鸿繑鍒┿�佸厤鍗曡鎯�
if (HongBaoV2.TYPE_ZIGOU != hongBaoType) {
- // 璁㈠崟鏍囪瘑
order.setSignList(signList);
-
} else {
-
- // 鏄惁鍏嶅崟鍟嗗搧
- boolean freeOrder = false;
- // 鏄惁濂栧姳鎴愬姛
- boolean rewardSuccess = false;
-
// 濂栧姳璁㈠崟銆佸厤鍗� 浣跨敤璁板綍
- if (couponRecordList != null && couponRecordList.size() > 0) {
-
- for (UserSystemCouponRecord couponRecord : couponRecordList) {
- // 璁㈠崟鍙峰尮閰�
- if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
-
- String systemCouponType = couponRecord.getCouponType();
- Integer state = couponRecord.getState();
-
- // 濂栧姳璁㈠崟: 涓旀垚鍔�
- if (CouponTypeEnum.rebatePercentCoupon.name().equals(systemCouponType)
- && UserSystemCouponRecord.STATE_SUCCESS == state) {
- rewardSuccess = true;
- signList.add(PIC_REWARD); // 鍔犲叆濂栧姳鎴愬姛鍥剧墖
-
- } else if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
- || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
-
- if (UserSystemCouponRecord.STATE_FREE_ON == state) {
- // 鍏嶅崟涓�
- freeOrder = true;
- signList.add(PIC_FREE_ON);
- } else if (UserSystemCouponRecord.STATE_SUCCESS == state) {
- // 鍏嶅崟鎴愬姛
- freeOrder = true;
- signList.add(PIC_FREE_SUCCEED);
- } else if (UserSystemCouponRecord.STATE_FAIL_RULE == state
- || UserSystemCouponRecord.STATE_FAIL_DRAWBACK == state) {
- // 瑙勫垯涓嶅尮閰嶃�侀��娆�
- freeOrder = true;
- signList.add(PIC_FREE_FAIL);
- }
- }
-
- break;
- }
- }
- }
-
- // 璁㈠崟鏍囪瘑
- order.setSignList(signList);
-
- boolean rewardOrder = false;
-
- int type = 1; // 1 甯歌璺宠浆椤甸潰 2寮瑰嚭閫夐」锛堝鍔卞埜锛�
- if (rewardSuccess) {
- // 濂栧姳鎴愬姛
- rewardOrder = true;
- } else if (hasRewardCoupon && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType
- && HongBaoV2.STATE_YILINGQU == hongBaoState) {
- // 鏈夊彲鐢ㄧ殑濂栧姳鍒� 銆侀潪鍏嶅崟璁㈠崟 銆佷笖宸插埌璐︾殑 銆佽繑鍒╄鍗�
- type = 2;
- rewardOrder = true;
- }
-
- if (rewardOrder) {
- ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
- // 濂栧姳鍒歌繘搴﹁鎯�
- rewardStyleVO.setContent("杩斿埄濂栧姳 >");
- rewardStyleVO.setColor("#E5005C");
- rewardStyleVO.setBottomColor("#FFDCEA");
-
- Map<String, Object> jumpLink = new HashMap<String, Object>();
- jumpLink.put("orderNo", order.getOrderNo());
-
- Map<String, Object> jump = new HashMap<String, Object>();
- jump.put("type", type);
- 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);
- }
-
- if (freeOrder) {
- ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
- // 杩斿埄銆佸厤鍗曡鎯�
- rewardStyleVO.setContent("鍏嶅崟璇︽儏 >");
- rewardStyleVO.setColor("#E5005C");
- rewardStyleVO.setBottomColor("#FFDCEA");
-
- Map<String, Object> jumpLink = new HashMap<String, Object>();
- jumpLink.put("orderNo", order.getOrderNo());
-
- Map<String, Object> jump = new HashMap<String, Object>();
- jump.put("type", 1); // 椤甸潰璺宠浆
- jump.put("params", jumpLink);
- jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("freeCouponDetail"));
-
- Map<String, Object> rewardMap = new HashMap<String, Object>();
- rewardMap.put("text", rewardStyleVO);
- rewardMap.put("jump", jump);
-
- order.setRewardDetail(rewardMap);
+ if (sourceType == null) {
+ setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, null, signList, acceptData);
+ } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
+ setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordTB, signList, acceptData);
+ } else if (sourceType == Constant.SOURCE_TYPE_JD) {
+ setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordJD, signList, acceptData);
+ } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
+ setSystemCouponRecord(order, hasRewardCoupon, hongBaoState, hongBaoType, listRecordPDD, signList, acceptData);
}
}
+
+ // 鍒嗕韩銆侀個璇� 闅愯棌璁㈠崟鍙�
+ if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType || HongBaoV2.TYPE_YAOQING == hongBaoType
+ || HongBaoV2.TYPE_YIJI == hongBaoType || HongBaoV2.TYPE_ERJI == hongBaoType
+ || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType || HongBaoV2.TYPE_SHARE_ERJI == hongBaoType) {
+ order.setOrderNo(UserUtil.filterOrderId(order.getOrderNo()));
+ }
+ }
+ }
+
+ /**
+ * 璁㈠崟锛� 鍏嶅崟鏍囪瘑 濂栧姳鏍囪瘑
+ *
+ * @param order
+ * @param hasRewardCoupon
+ * @param hongBaoState
+ * @param list
+ * @param signList
+ */
+ public void setSystemCouponRecord(CommonOrderVO order, boolean hasRewardCoupon, Integer hongBaoState,
+ Integer hongBaoType, List<UserSystemCouponRecord> list, List<String> signList, AcceptData acceptData) {
+
+ // 鏄惁鍏嶅崟鍟嗗搧
+ boolean freeOrder = false;
+ // 鏄惁濂栧姳鎴愬姛
+ boolean rewardSuccess = false;
+
+ if (list != null && list.size() > 0) {
+ for (UserSystemCouponRecord couponRecord : list) {
+ // 璁㈠崟鍙峰尮閰�
+ if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
+ Integer state = couponRecord.getState();
+ String systemCouponType = couponRecord.getCouponType();
+ // 濂栧姳璁㈠崟: 涓旀垚鍔�
+ if (CouponTypeEnum.rebatePercentCoupon.name().equals(systemCouponType)
+ && UserSystemCouponRecord.STATE_SUCCESS == state) {
+ rewardSuccess = true;
+ signList.add(PIC_REWARD); // 鍔犲叆濂栧姳鎴愬姛鍥剧墖
+
+ } else if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
+ || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
+
+ if (UserSystemCouponRecord.STATE_FREE_ON == state) {
+ // 鍏嶅崟涓�
+ freeOrder = true;
+ signList.add(PIC_FREE_ON);
+ } else if (UserSystemCouponRecord.STATE_SUCCESS == state) {
+ // 鍏嶅崟鎴愬姛
+ freeOrder = true;
+ signList.add(PIC_FREE_SUCCEED);
+ } else if (UserSystemCouponRecord.STATE_FAIL_RULE == state
+ || UserSystemCouponRecord.STATE_FAIL_DRAWBACK == state) {
+ // 瑙勫垯涓嶅尮閰嶃�侀��娆�
+ freeOrder = true;
+ signList.add(PIC_FREE_FAIL);
+ }
+ }
+
+ break;
+ }
+ }
+ }
+
+ // 璁㈠崟鏍囪瘑
+ order.setSignList(signList);
+
+ boolean rewardOrder = false;
+
+ int type = 1; // 1 甯歌璺宠浆椤甸潰 2寮瑰嚭閫夐」锛堝鍔卞埜锛�
+ if (rewardSuccess) {
+ // 濂栧姳鎴愬姛
+ rewardOrder = true;
+ } else if (hasRewardCoupon && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType
+ && HongBaoV2.STATE_YILINGQU == hongBaoState) {
+ // 鏈夊彲鐢ㄧ殑濂栧姳鍒� 銆侀潪鍏嶅崟璁㈠崟 銆佷笖宸插埌璐︾殑 銆佽繑鍒╄鍗�
+ type = 2;
+ rewardOrder = true;
+ }
+
+ if (rewardOrder) {
+ ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
+ // 濂栧姳鍒歌繘搴﹁鎯�
+ rewardStyleVO.setContent("杩斿埄濂栧姳 >");
+ rewardStyleVO.setColor("#E5005C");
+ rewardStyleVO.setBottomColor("#FFDCEA");
+
+ Map<String, Object> jumpLink = new HashMap<String, Object>();
+ jumpLink.put("orderNo", order.getOrderNo());
+ if (VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
+ jumpLink.put("goodsType", order.getSourceType());
+ }
+
+ Map<String, Object> jump = new HashMap<String, Object>();
+ jump.put("type", type);
+ 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);
+ }
+
+ if (freeOrder) {
+ ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO();
+ // 杩斿埄銆佸厤鍗曡鎯�
+ rewardStyleVO.setContent("鍏嶅崟璇︽儏 >");
+ rewardStyleVO.setColor("#E5005C");
+ rewardStyleVO.setBottomColor("#FFDCEA");
+
+ Map<String, Object> jumpLink = new HashMap<String, Object>();
+ jumpLink.put("orderNo", order.getOrderNo());
+ if (VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
+ jumpLink.put("goodsType", order.getSourceType());
+ }
+
+ Map<String, Object> jump = new HashMap<String, Object>();
+ jump.put("type", 1); // 椤甸潰璺宠浆
+ jump.put("params", jumpLink);
+ jump.put("jumpDetail", jumpDetailV2Service.getByTypeCache("freeCouponDetail"));
+
+ Map<String, Object> rewardMap = new HashMap<String, Object>();
+ rewardMap.put("text", rewardStyleVO);
+ rewardMap.put("jump", jump);
+
+ order.setRewardDetail(rewardMap);
}
}
@@ -689,6 +794,7 @@
cog.setUpdateTime(new Date());
commonOrderGoodsMapper.insertSelective(cog);
newCommonOrder.setCommonOrderGoods(cog);
+ } else {
}
newCommonOrder.setUserInfo(new UserInfo(uid));
commonOrderList.add(addCommonOrder(newCommonOrder));
@@ -734,13 +840,26 @@
if (commonGoodsList.size() <= 0)// 涓嶅瓨鍦ㄥ氨鎻掑叆鍟嗗搧
{
JDGoods goods = JDApiUtil.getGoodsDetail(itemOrder.getSkuId());
+ if (goods == null) {
+ goods = JDUtil.getGoodsFromWeb(itemOrder.getSkuId());
+ }
+
+ if (goods == null) {
+ goods = new JDGoods();
+ goods.setSkuName(itemOrder.getSkuName());
+ goods.setPrice(itemOrder.getPrice());
+ goods.setSkuId(itemOrder.getSkuId());
+ }
if (goods != null) {
cog = CommonOrderGoodsFactory.create(goods);
}
+
cog.setCreateTime(new Date());
cog.setUpdateTime(new Date());
commonOrderGoodsMapper.insertSelective(cog);
+ } else {
+
}
newCommonOrder.setUserInfo(new UserInfo(uid));
commonOrderList.add(addCommonOrder(newCommonOrder));
@@ -782,9 +901,14 @@
commonOrder.setCommonOrderGoods(goods);
}
- CommonOrder oldCommonOrder = commonOrderMapper.selectByOrderNoAndOrderTypeAndOrderBy(commonOrder.getOrderNo(),
- commonOrder.getSourceType(), commonOrder.getOrderBy());
+ CommonOrder oldCommonOrder = null;
+ if (!StringUtil.isNullOrEmpty(commonOrder.getTradeId()))
+ oldCommonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(commonOrder.getSourceType(),
+ commonOrder.getTradeId());
+ else {
+ throw new CommonOrderException(10, "浜ゆ槗ID涓虹┖");
+ }
if (oldCommonOrder == null)// 鏂板
{
commonOrder.setCreateTime(new Date());
@@ -794,9 +918,10 @@
commonOrder.getTradeId(), new Date(), commonOrder.getSourceType()));
return commonOrder;
} else {// 淇敼
- // 宸茬粡缁撶畻鎴栬�呭凡缁忓け鏁堢殑璁㈠崟涓嶅鐞�
- if (oldCommonOrder.getState() == CommonOrder.STATE_JS
- || oldCommonOrder.getState() == CommonOrder.STATE_SX) {
+ // 宸茬粡缁撶畻锛屽凡缁忓け鏁堬紝鐘舵�佹湭鏀瑰彉鐨勮鍗曚笉澶勭悊
+ if (oldCommonOrder.getState() == CommonOrder.STATE_JS || oldCommonOrder.getState() == CommonOrder.STATE_SX
+ || oldCommonOrder.getState() == CommonOrder.STATE_WQ
+ || (oldCommonOrder.getState().intValue() == commonOrder.getState())) {
return oldCommonOrder;
}
// 浜ゆ槗ID涓�鑷存墠淇敼
@@ -908,10 +1033,17 @@
@Override
public List<CommonOrderVO> listQuery(long start, int count, Integer keyType, String key, Integer state,
- Integer type, Integer orderState, String startTime, String endTime) throws CommonOrderException {
+ Integer type, Integer orderState, String startTime, String endTime, Integer source)
+ throws CommonOrderException {
- List<CommonOrderVO> list = commonOrderMapper.listQuery(start, count, keyType, key, state, type, orderState,
- startTime, endTime);
+ List<CommonOrderVO> list = null;
+
+ if (StringUtil.isNullOrEmpty(key) || keyType == 1) {// 鎼滅储妗嗘棤鍊兼垨鑰呮寜璁㈠崟鍙锋悳绱㈡椂閮藉彧鎼滅储涓昏鍗�
+ list = commonOrderMapper.listQueryWithNoChild(start, count, keyType, key, state, type, orderState,
+ startTime, endTime, source);
+ } else
+ list = commonOrderMapper.listQuery(start, count, keyType, key, state, type, orderState, startTime, endTime,
+ source);
if (list == null) {
list = new ArrayList<CommonOrderVO>();
@@ -920,14 +1052,37 @@
if (list.size() == 0) {
return list;
}
-
- List<String> listNo = new ArrayList<String>();
- for (CommonOrderVO commonOrderVO : list) {
- listNo.add(commonOrderVO.getOrderNo());
- }
- // 宸茬粡浣跨敤鍒歌鍗�
- List<UserSystemCouponRecord> couponRecordList = userSystemCouponRecordService.getRecordByOrderNoList(listNo);
+ List<String> listTB = new ArrayList<String>();
+ List<String> listJD = new ArrayList<String>();
+ List<String> listPDD = new ArrayList<String>();
+ for (CommonOrderVO commonOrderVO : list) {
+ Integer sourceType = commonOrderVO.getSourceType();
+ if (sourceType == null) {
+ continue;
+ } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) {
+ listTB.add(commonOrderVO.getOrderNo());
+ } else if (sourceType == Constant.SOURCE_TYPE_JD) {
+ listJD.add(commonOrderVO.getOrderNo());
+ } else if (sourceType == Constant.SOURCE_TYPE_PDD) {
+ listPDD.add(commonOrderVO.getOrderNo());
+ }
+ }
+
+ List<UserSystemCouponRecord> listRecordTB = null;
+ if (listTB.size() > 0) {
+ listRecordTB = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_TAOBAO, listTB);
+ }
+
+ List<UserSystemCouponRecord> listRecordJD = null;
+ if (listJD.size() > 0) {
+ listRecordJD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_JD, listJD);
+ }
+
+ List<UserSystemCouponRecord> listRecordPDD = null;
+ if (listPDD.size() > 0) {
+ listRecordPDD = userSystemCouponRecordService.getRecordByOrderNoList(Constant.SOURCE_TYPE_PDD, listPDD);
+ }
SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
for (CommonOrderVO order : list) {
@@ -1005,29 +1160,63 @@
}
}
}
-
- // 濂栧姳璁㈠崟銆佸厤鍗� 浣跨敤璁板綍
- if (couponRecordList != null && couponRecordList.size() > 0) {
- for (UserSystemCouponRecord couponRecord : couponRecordList) {
- // 璁㈠崟鍙峰尮閰�
- if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
+ Integer sourceType = order.getSourceType();
+ // 濂栧姳璁㈠崟銆佸厤鍗� 浣跨敤璁板綍
+ if (sourceType == null) {
+
+ } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO && listRecordTB != null && listRecordTB.size() > 0) {
+ for (UserSystemCouponRecord couponRecord : listRecordTB) {
+ if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
String systemCouponType = couponRecord.getCouponType();
Integer couponState = couponRecord.getState();
if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
|| CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
- if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
+ if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
// 鍏嶅崟鎴愬姛
- order.setOtherState(1);
- }
+ order.setOtherState(2);
+ } else if (UserSystemCouponRecord.STATE_FREE_ON == couponState) {
+ order.setOtherState(1);
+ }
}
-
+ break;
+ }
+ }
+ } else if (sourceType == Constant.SOURCE_TYPE_JD && listRecordJD != null && listRecordJD.size() > 0) {
+ for (UserSystemCouponRecord couponRecord : listRecordJD) {
+ if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
+ String systemCouponType = couponRecord.getCouponType();
+ Integer couponState = couponRecord.getState();
+ if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
+ || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
+ if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
+ // 鍏嶅崟鎴愬姛
+ order.setOtherState(2);
+ } else if (UserSystemCouponRecord.STATE_FREE_ON == couponState) {
+ order.setOtherState(1);
+ }
+ }
+ break;
+ }
+ }
+ } else if (sourceType == Constant.SOURCE_TYPE_PDD && listRecordPDD != null && listRecordPDD.size() > 0) {
+ for (UserSystemCouponRecord couponRecord : listRecordPDD) {
+ if (order.getOrderNo().equals(couponRecord.getOrderNo())) {
+ String systemCouponType = couponRecord.getCouponType();
+ Integer couponState = couponRecord.getState();
+ if (CouponTypeEnum.freeCoupon.name().equals(systemCouponType)
+ || CouponTypeEnum.welfareFreeCoupon.name().equals(systemCouponType)) {
+ if (UserSystemCouponRecord.STATE_SUCCESS == couponState) {
+ // 鍏嶅崟鎴愬姛
+ order.setOtherState(2);
+ } else if (UserSystemCouponRecord.STATE_FREE_ON == couponState) {
+ order.setOtherState(1);
+ }
+ }
break;
}
}
}
-
-
}
return list;
@@ -1036,16 +1225,23 @@
@Override
public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState,
- String startTime, String endTime) throws CommonOrderException {
- return commonOrderMapper.countQuery(keyType, key, state, type, orderState, startTime, endTime);
+ String startTime, String endTime, Integer source) throws CommonOrderException {
+ if (StringUtil.isNullOrEmpty(key) || keyType == 1) {// 鎼滅储妗嗘棤鍊兼垨鑰呮寜璁㈠崟鍙锋悳绱㈡椂閮藉彧鎼滅储涓昏鍗�
+ return commonOrderMapper.countQueryWithNoChild(keyType, key, state, type, orderState, startTime, endTime,
+ source);
+ } else
+ return commonOrderMapper.countQuery(keyType, key, state, type, orderState, startTime, endTime, source);
}
-
@Override
- public CommonOrderVO getCommonOrderByOrderNo(Long uid, String orderNo, Integer orderState)
+ public CommonOrderVO getCommonOrderByOrderNo(Long uid, String orderNo, Integer orderState, Integer sourceType)
throws CommonOrderException {
- CommonOrderVO commonOrderVO = commonOrderMapper.getCommonOrderByOrderNo(uid, orderNo, orderState);
+ if (sourceType == null) {
+ sourceType = Constant.SOURCE_TYPE_TAOBAO;
+ }
+
+ CommonOrderVO commonOrderVO = commonOrderMapper.getCommonOrderByOrderNo(uid, orderNo, orderState, sourceType);
// 璁㈠崟淇℃伅涓虹┖
if (commonOrderVO == null) {
return null;
@@ -1070,13 +1266,13 @@
}
String orderNo1 = commonOrder.getOrderNo();
- Integer sourceType = commonOrder.getSourceType();
+ Integer sourceType1 = commonOrder.getSourceType();
String orderNo2 = commonOrderVO.getOrderNo();
Integer sourceType2 = commonOrderVO.getSourceType();
// 鏉ユ簮銆佽鍗曞彿鐩稿悓
- if (sourceType.equals(sourceType2) && orderNo1.equals(orderNo2)) {
+ if (sourceType1.equals(sourceType2) && orderNo1.equals(orderNo2)) {
// 鍔犲叆鍟嗗搧淇℃伅
List<CommonOrderGoodsVO> listOrderGoods = commonOrderVO.getListOrderGoods();
@@ -1133,7 +1329,6 @@
return commonOrderVO;
}
-
@Override
public JSONObject getRewardJumpInfo(String orderNo) {
@@ -1207,4 +1402,10 @@
return commonOrderMapper.listBySourceTypeAndTradeId(sourceType, tradeId);
}
+ @Override
+ public List<CommonOrder> listBySourceTypeAndStateAndThirdCrateTime(int sourceType, Integer state, Long minTime,
+ Long maxTime, int page, int pageSize) {
+ return commonOrderMapper.listBySourceTypeAndStateAndThirdCrateTime(sourceType, state, minTime, maxTime,
+ (page - 1) * pageSize, pageSize);
+ }
}
--
Gitblit v1.8.0