From b9f8ef2c4737b6e6be4b12fc8f7bafb033bfcfe5 Mon Sep 17 00:00:00 2001 From: admin <2780501319@qq.com> Date: 星期日, 22 九月 2019 16:47:33 +0800 Subject: [PATCH] 金币BUG修改 --- fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java | 154 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 93 insertions(+), 61 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 d17a644..e13ab17 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 @@ -20,6 +20,7 @@ import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper; import com.yeshi.fanli.dao.mybatis.order.CommonOrderTradeIdMapMapper; import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper; +import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO; import com.yeshi.fanli.dto.pdd.PDDGoodsDetail; import com.yeshi.fanli.entity.accept.AcceptData; import com.yeshi.fanli.entity.bus.user.HongBaoV2; @@ -45,9 +46,9 @@ import com.yeshi.fanli.service.inter.config.ConfigService; import com.yeshi.fanli.service.inter.config.SystemCouponService; import com.yeshi.fanli.service.inter.goods.CommonGoodsService; -import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service; import com.yeshi.fanli.service.inter.order.CommonOrderService; import com.yeshi.fanli.service.inter.order.HongBaoOrderService; +import com.yeshi.fanli.service.inter.order.HongBaoV2Service; import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService; import com.yeshi.fanli.service.inter.user.UserSystemCouponService; import com.yeshi.fanli.util.Constant; @@ -216,9 +217,35 @@ } @Override - public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime, String endTime, - Integer day, Integer source) { - return commonOrderMapper.countByUidAndOrderState(uid, type, startTime, endTime, day, source); + public Long countUserOrderToApp(Long uid, Integer type, String startTime, String endTime, + Integer day, Integer source, Integer state, Integer stateOrder) { + return commonOrderMapper.countUserOrderToApp(uid, type, startTime, endTime, day, source, state, stateOrder); + } + + private BigDecimal getWeiQuanMoney(List<TaoBaoWeiQuanOrder> listWQ, int sourceType, Long uid) { + BigDecimal weiQuanMoney = new BigDecimal(0); + if (listWQ != null && listWQ.size() > 0) { + for (TaoBaoWeiQuanOrder weiQuanOrder : listWQ) { + String tradeId = weiQuanOrder.getOrderItemId(); + // 鏌ヨ绾㈠寘 + List<String> tradeList = new ArrayList<>(); + tradeList.add(tradeId); + List<HongBaoV2> hongBaoList = hongBaoV2Service.listBySourceTypeAndTradeIdListAndUid(sourceType, uid, + tradeList); + if (hongBaoList != null && hongBaoList.size() > 0) { + CommonOrder commonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(sourceType, tradeId); + if (commonOrder != null && commonOrder.getSettlement().compareTo(new BigDecimal(0)) > 0) { + BigDecimal wqMoney = MoneyBigDecimalUtil + .mul(hongBaoList.get(0).getMoney(), weiQuanOrder.getMoney()) + .divide(commonOrder.getSettlement(), 2, BigDecimal.ROUND_UP); + if (wqMoney.compareTo(hongBaoList.get(0).getMoney()) > 0) + wqMoney = hongBaoList.get(0).getMoney(); + weiQuanMoney = weiQuanMoney.add(wqMoney); + } + } + } + } + return weiQuanMoney; } public void listDataFactory(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods, @@ -329,7 +356,8 @@ SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd"); // 鏄惁瀛樺湪濂栧姳鍒� - //boolean hasRewardCoupon = userSystemCouponService.hasRewardCoupon(uid); + // boolean hasRewardCoupon = + // userSystemCouponService.hasRewardCoupon(uid); boolean hasRewardCoupon = userSystemCouponService.getIncludeNotExchange(uid); boolean exchangeCoupon = userSystemCouponService.getIncludeExchange(uid); @@ -409,21 +437,7 @@ .selectListByOrderIdAndState(order.getOrderNo(), "缁存潈鎴愬姛"); 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 (fanTotalMoney.compareTo(hongBao) < 0) { - isPart = true; - } - } + BigDecimal weiQuanMoney = getWeiQuanMoney(listWQ, sourceType, uid); if (!VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) { if (isPart) { @@ -437,19 +451,17 @@ 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); - } + // if (isPart) { + weiQuanInfo + .setWqHongBao("缁存潈锛�-楼" + weiQuanMoney.setScale(2, BigDecimal.ROUND_DOWN).toString()); + hongBao = MoneyBigDecimalUtil.sub(hongBao, weiQuanMoney); + // } else { + // weiQuanInfo + // .setWqHongBao("缁存潈锛�-楼" + weiQuanMoney.setScale(2, + // BigDecimal.ROUND_DOWN).toString()); + // hongBao = MoneyBigDecimalUtil.sub(hongBao, + // weiQuanMoney); + // } order.setWeiQuanInfo(weiQuanInfo); } } @@ -550,13 +562,17 @@ } else { // 濂栧姳璁㈠崟銆佸厤鍗� 浣跨敤璁板綍 if (sourceType == null) { - setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType, null, signList, acceptData); + setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType, null, + signList, acceptData); } else if (sourceType == Constant.SOURCE_TYPE_TAOBAO) { - setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType, listRecordTB, signList, acceptData); + setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType, + listRecordTB, signList, acceptData); } else if (sourceType == Constant.SOURCE_TYPE_JD) { - setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType, listRecordJD, signList, acceptData); + setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType, + listRecordJD, signList, acceptData); } else if (sourceType == Constant.SOURCE_TYPE_PDD) { - setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType, listRecordPDD, signList, acceptData); + setSystemCouponRecord(order, hasRewardCoupon, exchangeCoupon, hongBaoState, hongBaoType, + listRecordPDD, signList, acceptData); } } @@ -578,8 +594,9 @@ * @param list * @param signList */ - public void setSystemCouponRecord(CommonOrderVO order, boolean hasRewardCoupon, boolean exchangeCoupon, Integer hongBaoState, - Integer hongBaoType, List<UserSystemCouponRecord> list, List<String> signList, AcceptData acceptData) { + public void setSystemCouponRecord(CommonOrderVO order, boolean hasRewardCoupon, boolean exchangeCoupon, + Integer hongBaoState, Integer hongBaoType, List<UserSystemCouponRecord> list, List<String> signList, + AcceptData acceptData) { // 鏄惁鍏嶅崟鍟嗗搧 boolean freeOrder = false; @@ -629,18 +646,18 @@ // 1.6.5 鏄惁瀛樺湪鏂板厬鎹㈢殑鍒� if (!hasRewardCoupon && exchangeCoupon) { try { - String downTime = order.getDownTime(); - if (!StringUtil.isNullOrEmpty(downTime)) { - long downOrderTime = TimeUtil.convertDateToTemp2(downTime); - long limitDate = TimeUtil.convertDateToTemp("2019-09-01"); - if (downOrderTime > limitDate ) + Date thirdCreateTime = order.getThirdCreateTime(); + if (thirdCreateTime != null) { + long downOrderTime = thirdCreateTime.getTime(); + long limitDate = TimeUtil.convertDateToTemp("2019-09-05"); + if (downOrderTime > limitDate) hasRewardCoupon = true; } } catch (Exception e) { e.printStackTrace(); } } - + boolean rewardOrder = false; int type = 1; // 1 甯歌璺宠浆椤甸潰 2寮瑰嚭閫夐」锛堝鍔卞埜锛� @@ -652,7 +669,7 @@ // 鏈夊彲鐢ㄧ殑濂栧姳鍒� 銆侀潪鍏嶅崟璁㈠崟 銆佷笖宸插埌璐︾殑 銆佽繑鍒╄鍗� type = 2; rewardOrder = true; - } + } if (rewardOrder) { ClientTextStyleVO rewardStyleVO = new ClientTextStyleVO(); @@ -664,7 +681,7 @@ 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()); + jumpLink.put("goodsType", order.getSourceType()+""); } Map<String, Object> jump = new HashMap<String, Object>(); @@ -689,7 +706,7 @@ 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()); + jumpLink.put("goodsType", order.getSourceType()+""); } Map<String, Object> jump = new HashMap<String, Object>(); @@ -712,8 +729,9 @@ @Transactional @Override - public List<CommonOrder> addTaoBaoOrder(List<TaoBaoOrder> taoBaoOrders, Long uid) throws CommonOrderException { - List<CommonOrder> commonOrderList = new ArrayList<>(); + public List<CommonOrderAddResultDTO> addTaoBaoOrder(List<TaoBaoOrder> taoBaoOrders, Long uid) + throws CommonOrderException { + List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>(); // 鍒ゆ柇鎵�鏈夌殑璁㈠崟鐘舵�� int invalidCount = 0; for (TaoBaoOrder tb : taoBaoOrders) { @@ -773,8 +791,9 @@ @Transactional @Override - public List<CommonOrder> addPDDOrder(List<PDDOrder> pddOrderList, Long uid) throws CommonOrderException { - List<CommonOrder> commonOrderList = new ArrayList<>(); + public List<CommonOrderAddResultDTO> addPDDOrder(List<PDDOrder> pddOrderList, Long uid) + throws CommonOrderException { + List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>(); // 鍒ゆ柇鎵�鏈夌殑璁㈠崟鐘舵�� int invalidCount = 0; for (PDDOrder order : pddOrderList) { @@ -822,8 +841,8 @@ @Transactional @Override - public List<CommonOrder> addJDOrder(JDOrder jdOrder, Long uid) throws CommonOrderException { - List<CommonOrder> commonOrderList = new ArrayList<>(); + public List<CommonOrderAddResultDTO> addJDOrder(JDOrder jdOrder, Long uid) throws CommonOrderException { + List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>(); // 鍒ゆ柇鎵�鏈夌殑璁㈠崟鐘舵�� int invalidCount = 0; for (JDOrderItem tb : jdOrder.getOrderItemList()) { @@ -891,7 +910,7 @@ * @param commonOrder */ @Transactional - private CommonOrder addCommonOrder(CommonOrder commonOrder) throws CommonOrderException { + private CommonOrderAddResultDTO addCommonOrder(CommonOrder commonOrder) throws CommonOrderException { // 鍒ゆ柇鍟嗗搧鏄惁瀛樺湪 if (commonOrder == null) throw new CommonOrderException(1, "璁㈠崟涓虹┖"); @@ -934,13 +953,13 @@ // 鎻掑叆鏄犲皠锛屼繚璇佷氦鏄揑D鐨勫畬鏁存�� commonOrderTradeIdMapMapper.insertSelective(new CommonOrderTradeIdMap(commonOrder.getId(), commonOrder.getTradeId(), new Date(), commonOrder.getSourceType())); - return commonOrder; + return new CommonOrderAddResultDTO(commonOrder, CommonOrderAddResultDTO.TYPE_ADD); } else {// 淇敼 // 宸茬粡缁撶畻锛屽凡缁忓け鏁堬紝鐘舵�佹湭鏀瑰彉鐨勮鍗曚笉澶勭悊 if (oldCommonOrder.getState() == CommonOrder.STATE_JS || oldCommonOrder.getState() == CommonOrder.STATE_SX || oldCommonOrder.getState() == CommonOrder.STATE_WQ || (oldCommonOrder.getState().intValue() == commonOrder.getState())) { - return oldCommonOrder; + return new CommonOrderAddResultDTO(oldCommonOrder, CommonOrderAddResultDTO.TYPE_NOUPDATE); } // 浜ゆ槗ID涓�鑷存墠淇敼 if (commonOrder.getTradeId() != null @@ -956,9 +975,10 @@ updateCommonOrder.setUpdateTime(new Date()); updateCommonOrder.setTradeId(commonOrder.getTradeId()); commonOrderMapper.updateByPrimaryKeySelective(updateCommonOrder); - return commonOrderMapper.selectByPrimaryKey(updateCommonOrder.getId()); + return new CommonOrderAddResultDTO(commonOrderMapper.selectByPrimaryKey(updateCommonOrder.getId()), + CommonOrderAddResultDTO.TYPE_UPDATE); } else - return oldCommonOrder; + return new CommonOrderAddResultDTO(oldCommonOrder, CommonOrderAddResultDTO.TYPE_NOUPDATE); } } @@ -1352,7 +1372,7 @@ } @Override - public JSONObject getRewardJumpInfo(String orderNo) { + public JSONObject getRewardJumpInfo(String orderNo, Integer goodsType) { JSONObject map = new JSONObject(); // 璁㈠崟鏍囪瘑 @@ -1369,6 +1389,7 @@ Map<String, Object> jumpLink = new HashMap<String, Object>(); jumpLink.put("orderNo", orderNo); + jumpLink.put("goodsType", goodsType == null? goodsType: goodsType +""); Map<String, Object> jump = new HashMap<String, Object>(); jump.put("type", 1); @@ -1429,10 +1450,21 @@ return commonOrderMapper.listBySourceTypeAndStateAndThirdCrateTime(sourceType, state, minTime, maxTime, (page - 1) * pageSize, pageSize); } - + @Override public List<CommonOrder> getByOrderNo(Long uid, String orderNO) { return commonOrderMapper.getByOrderNo(uid, orderNO); } + @Override + public CommonOrder selectLatestValidByUid(Long uid) { + List<Integer> stateList = new ArrayList<>(); + stateList.add(CommonOrder.STATE_FK); + stateList.add(CommonOrder.STATE_JS); + List<CommonOrder> commonOrderList = commonOrderMapper.listByUid(uid, stateList, 0, 1); + if (commonOrderList == null || commonOrderList.size() == 0) + return null; + return commonOrderList.get(0); + } + } -- Gitblit v1.8.0