From cdd852f8e8eff7eb2e8f7c3fceaa955b9fc3f9d3 Mon Sep 17 00:00:00 2001 From: yujian <yujian@123.com> Date: 星期一, 29 七月 2019 10:46:32 +0800 Subject: [PATCH] 订单商品类型处理 --- fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanDrawBackServiceImpl.java | 90 +++++++++++++++++++++++++------------------- 1 files changed, 51 insertions(+), 39 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanDrawBackServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanDrawBackServiceImpl.java index 76db6ac..91cafcd 100644 --- a/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanDrawBackServiceImpl.java +++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/taobao/TaoBaoWeiQuanDrawBackServiceImpl.java @@ -36,14 +36,13 @@ import com.yeshi.fanli.log.LogHelper; import com.yeshi.fanli.service.inter.money.UserMoneyDebtService; import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService; -import com.yeshi.fanli.service.inter.order.CommonOrderService; import com.yeshi.fanli.service.inter.taobao.TaoBaoWeiQuanDrawBackService; import com.yeshi.fanli.service.inter.taobao.TaoBaoWeiQuanOrderService; +import com.yeshi.fanli.service.inter.user.UserMoneyService; import com.yeshi.fanli.service.inter.user.UserNotificationService; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.MoneyBigDecimalUtil; import com.yeshi.fanli.util.StringUtil; -import com.yeshi.fanli.util.TaoBaoConstant; import com.yeshi.fanli.util.factory.UserMoneyDetailFactory; import com.yeshi.fanli.vo.order.CommonOrderVO; @@ -81,6 +80,9 @@ @Resource private UserMoneyDebtService userMoneyDebtService; + + @Resource + private UserMoneyService userMoneyService; @Override public void addWeiQuanDrawBack(TaoBaoWeiQuanDrawBack taoBaoWeiQuanDrawBack) { @@ -210,6 +212,8 @@ // 閫�娆鹃噾棰� BigDecimal drawBackMoney = MoneyBigDecimalUtil.div(userGetMoney.multiply(fanMoney), sumFee); + if (drawBackMoney.compareTo(userGetMoney) > 0) + drawBackMoney = userGetMoney;// 閫�娆鹃噾棰濅笉鑳芥瘮鑾峰緱鐨勯噾棰濆ぇ // 璁$畻璧勯噾鏄惁鍏呰冻 UserInfo user = userInfoMapper.selectByPKey(uid); if (user != null && user.getMyHongBao().compareTo(drawBackMoney) < 0)// 璧勯噾涓嶈冻 @@ -243,12 +247,10 @@ continue; } - userInfoMapper.subHongBaoByUid(uid, drawBackMoney); + UserMoneyDetail userMoneyDetail = null; // 鏂扮増璧勯噾璁板綍 try { - UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createFanLiWeiQuan(uid, weiQuanDrawBack, - drawBackMoney); - userMoneyDetailMapper.insert(userMoneyDetail); + userMoneyDetail = UserMoneyDetailFactory.createFanLiWeiQuan(uid, weiQuanDrawBack, drawBackMoney); } catch (UserMoneyDetailException e) { try { LogHelper.errorDetailInfo(e); @@ -256,10 +258,11 @@ e1.printStackTrace(); } } + userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail); // 鏂扮増閫氱煡 - userMoneyMsgNotificationService.fanliOrderWeiQuan(uid, orderId, drawBackMoney, - userInfoMapper.selectByPrimaryKey(uid).getMyHongBao()); + userMoneyMsgNotificationService.fanliOrderWeiQuan(uid, orderId,Constant.SOURCE_TYPE_TAOBAO, drawBackMoney, + userInfoMapper.selectByPKey(uid).getMyHongBao()); userNotificationService.weiQuanFanli(uid, orderId, drawBackMoney); } @@ -363,6 +366,8 @@ // 閫�娆鹃噾棰� BigDecimal drawBackMoney = MoneyBigDecimalUtil.div(userGetMoney.multiply(fanMoney), sumFee); + if (drawBackMoney.compareTo(userGetMoney) > 0) + drawBackMoney = userGetMoney; for (TaoBaoWeiQuanDrawBack drawBack : newWeiQuanDrawBackList) taoBaoWeiQuanDrawBackMapper.insertSelective(drawBack); @@ -418,12 +423,10 @@ continue; } - userInfoMapper.subHongBaoByUid(uid, drawBackMoney); + UserMoneyDetail userMoneyDetail = null; // 鏂扮増璧勯噾璁板綍 try { - UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShareWeiQuan(uid, weiQuanDrawBack, - drawBackMoney); - userMoneyDetailMapper.insert(userMoneyDetail); + userMoneyDetail = UserMoneyDetailFactory.createShareWeiQuan(uid, weiQuanDrawBack, drawBackMoney); } catch (UserMoneyDetailException e) { try { LogHelper.errorDetailInfo(e); @@ -431,8 +434,9 @@ e1.printStackTrace(); } } + userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail); - userMoneyMsgNotificationService.shareOrderWeiQuan(uid, orderId, drawBackMoney, + userMoneyMsgNotificationService.shareOrderWeiQuan(uid, orderId, Constant.SOURCE_TYPE_TAOBAO,drawBackMoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao()); userNotificationService.weiQuanTiCheng(uid, orderId, drawBackMoney); @@ -484,6 +488,8 @@ if (weiQuanDrawBack != null) continue; BigDecimal drawBackMoney = MoneyBigDecimalUtil.div(child.getMoney().multiply(fanMoney), sumFee); + if (drawBackMoney.compareTo(child.getMoney()) > 0) + drawBackMoney = child.getMoney(); weiQuanDrawBack = new TaoBaoWeiQuanDrawBack(); weiQuanDrawBack.setCreateTime(new Date()); weiQuanDrawBack.setDrawBackMoney(drawBackMoney); @@ -492,35 +498,41 @@ weiQuanDrawBack.setUser(child.getUserInfo()); taoBaoWeiQuanDrawBackMapper.insertSelective(weiQuanDrawBack);// 鍔犲叆杩旇繕璁板綍 - // 鍒ゆ柇璧勯噾鏄惁瓒冲鎵f - UserInfo user = userInfoMapper.selectByPKey(uid); - if (user != null && user.getMyHongBao().compareTo(drawBackMoney) < 0)// 璧勯噾涓嶈冻 - { - try { - addDebt(uid, child.getId(), drawBackMoney); - } catch (UserMoneyDebtException e) { - throw new TaoBaoWeiQuanException(101, "璧勯噾鍊熻捶寮傚父"); - } - continue; - } + // 濡傛灉璧勯噾澶т簬0鎵嶆墸闄� - userInfoMapper.subHongBaoByUid(uid, drawBackMoney); + if (drawBackMoney != null && drawBackMoney.compareTo(new BigDecimal(0)) > 0) { - // 鏂扮増璧勯噾璁板綍 - try { - UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid, - weiQuanDrawBack, drawBackMoney); - userMoneyDetailMapper.insert(userMoneyDetail); - } catch (UserMoneyDetailException e) { - try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); + // 鍒ゆ柇璧勯噾鏄惁瓒冲鎵f + UserInfo user = userInfoMapper.selectByPKey(uid); + if (user != null && user.getMyHongBao().compareTo(drawBackMoney) < 0)// 璧勯噾涓嶈冻 + { + try { + addDebt(uid, child.getId(), drawBackMoney); + } catch (UserMoneyDebtException e) { + throw new TaoBaoWeiQuanException(101, "璧勯噾鍊熻捶寮傚父"); + } + continue; } - } - // 鏂扮増閫氱煡 - userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId, drawBackMoney, - userInfoMapper.selectByPrimaryKey(uid).getMyHongBao()); + + UserMoneyDetail userMoneyDetail = null; + // 鏂扮増璧勯噾璁板綍 + try { + userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid, weiQuanDrawBack, + drawBackMoney); + } catch (UserMoneyDetailException e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } + } + + userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail); + + // 鏂扮増閫氱煡 + userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId,Constant.SOURCE_TYPE_TAOBAO, drawBackMoney, + userInfoMapper.selectByPrimaryKey(uid).getMyHongBao()); + } } } } -- Gitblit v1.8.0