From 5d59c0ad6e82b6255cf38c3dba715395af1d60a7 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期一, 10 十二月 2018 14:37:15 +0800 Subject: [PATCH] 取消红包参数异常 --- fanli/src/main/java/com/yeshi/fanli/service/impl/order/OrderProcessServiceImpl.java | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 47 insertions(+), 3 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 de532c1..dbc4515 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 @@ -45,6 +45,7 @@ import com.yeshi.fanli.exception.OrderItemException; import com.yeshi.fanli.exception.TaoBaoWeiQuanException; import com.yeshi.fanli.log.LogHelper; +import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService; import com.yeshi.fanli.service.inter.hongbao.HongBaoService; import com.yeshi.fanli.service.inter.order.LostOrderService; import com.yeshi.fanli.service.inter.order.OrderItemServcie; @@ -135,6 +136,9 @@ @Resource private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper; + + @Resource + private HongBaoManageService hongBaoManageService; @Override public void processOrder(Map<String, List<TaoBaoOrder>> orders) { @@ -417,7 +421,7 @@ orderMapper.updateByPrimaryKeySelective(updateOrder); Order order = oldOrder; // 璁㈠崟杩斿埄姣斾緥 - BigDecimal rate = new BigDecimal(hongBaoManageMapper.selectByKey("hongbao_goods_proportion").getValue()); + BigDecimal rate = hongBaoManageService.getFanLiRate(); // 鏌ユ壘鏄惁瀛樺湪绾㈠寘 List<HongBao> hongBaoList = hongBaoMapper.selectByOid(order.getId()); @@ -573,17 +577,37 @@ } } + private HongBao filterWeiQuanINGHongBao(HongBao hongBao) { + + List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList = taoBaoWeiQuanOrderMapper + .selectListByOrderIdAndState(hongBao.getOrderId(), "缁存潈鍒涘缓"); + + List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList1 = taoBaoWeiQuanOrderMapper + .selectListByOrderIdAndState(hongBao.getOrderId(), "绛夊緟澶勭悊"); + if ((taoBaoWeiQuanList != null && taoBaoWeiQuanList.size() > 0) + || (taoBaoWeiQuanList1 != null && taoBaoWeiQuanList1.size() > 0)) { + return null; + } + return hongBao; + } + @Override @Transactional public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException { + /** + * 澶勭悊閭�璇疯禋璁㈠崟 + */ // 鏌ヨUID鐨勯個璇疯禋璁㈠崟 List<HongBao> hongBaoList = hongBaoMapper.selectCanBalanceHongBaoByChildHongBaoAndUid(uid); - BigDecimal money = new BigDecimal(0); + BigDecimal money = new BigDecimal(0); // 闇�瑕佸垽鏂��娆剧殑璁㈠崟鍙� Set<String> drawBackOrders = new HashSet<String>(); - for (HongBao hongBao : hongBaoList) { + hongBao = filterWeiQuanINGHongBao(hongBao); + if (hongBao == null) + continue; + hongBao = hongBaoMapper.selectByPrimaryKeyForUpdate(hongBao.getId()); if (hongBao.getState() == HongBao.STATE_BUKELINGQU || hongBao.getState() == HongBao.STATE_KELINGQU) { money = money.add(hongBao.getMoney()); @@ -608,10 +632,17 @@ } } + /** + * 澶勭悊椤剁骇鍒嗕韩璧� + */ + // 鏌ヨUID鐨勫垎浜禋璁㈠崟 List<PidOrder> pidOrderList = pidOrderMapper.getCanBalanceListByUid(uid); for (PidOrder pidOrder : pidOrderList) { HongBao hongBao = hongBaoMapper.selectByPrimaryKeyForUpdate(pidOrder.getHongBao().getId()); + hongBao = filterWeiQuanINGHongBao(hongBao); + if (hongBao == null) + continue; if (hongBao.getState() == HongBao.STATE_BUKELINGQU || hongBao.getState() == HongBao.STATE_KELINGQU) { money = money.add(hongBao.getMoney()); HongBao updateHongBao = new HongBao(); @@ -632,10 +663,15 @@ } } + /** + * 澶勭悊涓�绾т簩绾у垎浜禋 + */ + List<HongBao> totalHongBaoList = new ArrayList<>(); // 鏌ヨUID鐨勪簩绾ф垨鑰呬笁绾у垎浜禋璁㈠崟 // TODO 鏆傛椂鏌ヨ10000鏉℃暟鎹紝鍚庨潰鍐嶅仛鍒嗛〉 List<HongBao> hbList = hongBaoMapper.selectCanBalanceHongBaoByTypeAndUid(HongBao.TYPE_SHARE_YIJI, uid, 10000); + if (hbList != null && hbList.size() > 0) totalHongBaoList.addAll(hbList); @@ -643,8 +679,12 @@ if (hbList != null && hbList.size() > 0) totalHongBaoList.addAll(hbList); + for (HongBao hb : totalHongBaoList) { if (hb.getState() == HongBao.STATE_BUKELINGQU || hb.getState() == HongBao.STATE_KELINGQU) { + hb = filterWeiQuanINGHongBao(hb); + if (hb == null) + continue; money = money.add(hb.getMoney()); HongBao updateHongBao = new HongBao(); updateHongBao.setId(hb.getId()); @@ -656,6 +696,10 @@ } } + /** + * 澧炲姞鐢ㄦ埛璧勯噾璁板綍 + */ + if (money.compareTo(new BigDecimal(0)) > 0) { userInfoMapper.addHongBaoByUid(uid, money); // 娣诲姞璁板綍 -- Gitblit v1.8.0