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 | 67 +++++++++++++++++++-------------- 1 files changed, 38 insertions(+), 29 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 49872b9..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,7 +36,6 @@ 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; @@ -44,7 +43,6 @@ 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; @@ -214,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)// 璧勯噾涓嶈冻 @@ -261,8 +261,8 @@ 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); } @@ -366,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); @@ -434,7 +436,7 @@ } 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); @@ -486,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); @@ -494,36 +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, "璧勯噾鍊熻捶寮傚父"); + // 濡傛灉璧勯噾澶т簬0鎵嶆墸闄� + + if (drawBackMoney != null && drawBackMoney.compareTo(new BigDecimal(0)) > 0) { + + // 鍒ゆ柇璧勯噾鏄惁瓒冲鎵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; } - continue; - } - UserMoneyDetail userMoneyDetail = null; - // 鏂扮増璧勯噾璁板綍 - try { - userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid, weiQuanDrawBack, - drawBackMoney); - } catch (UserMoneyDetailException e) { + UserMoneyDetail userMoneyDetail = null; + // 鏂扮増璧勯噾璁板綍 try { - LogHelper.errorDetailInfo(e); - } catch (Exception e1) { - e1.printStackTrace(); + userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid, weiQuanDrawBack, + drawBackMoney); + } catch (UserMoneyDetailException e) { + try { + LogHelper.errorDetailInfo(e); + } catch (Exception e1) { + e1.printStackTrace(); + } } - } - userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail); + userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail); - // 鏂扮増閫氱煡 - userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId, drawBackMoney, - userInfoMapper.selectByPrimaryKey(uid).getMyHongBao()); + // 鏂扮増閫氱煡 + userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId,Constant.SOURCE_TYPE_TAOBAO, drawBackMoney, + userInfoMapper.selectByPrimaryKey(uid).getMyHongBao()); + } } } } -- Gitblit v1.8.0