| | |
| | | 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;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private UserMoneyDebtService userMoneyDebtService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Override
|
| | | public void addWeiQuanDrawBack(TaoBaoWeiQuanDrawBack taoBaoWeiQuanDrawBack) {
|
| | |
| | |
|
| | | // 退款金额
|
| | | 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)// 资金不足
|
| | |
| | | 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);
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail);
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.fanliOrderWeiQuan(uid, orderId, drawBackMoney,
|
| | |
| | |
|
| | | // 退款金额
|
| | | BigDecimal drawBackMoney = MoneyBigDecimalUtil.div(userGetMoney.multiply(fanMoney), sumFee);
|
| | | if (drawBackMoney.compareTo(userGetMoney) > 0)
|
| | | drawBackMoney = userGetMoney;
|
| | |
|
| | | for (TaoBaoWeiQuanDrawBack drawBack : newWeiQuanDrawBackList)
|
| | | taoBaoWeiQuanDrawBackMapper.insertSelective(drawBack);
|
| | |
| | | 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);
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail);
|
| | |
|
| | | userMoneyMsgNotificationService.shareOrderWeiQuan(uid, orderId, drawBackMoney,
|
| | | userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | |
| | | 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);
|
| | |
| | | continue;
|
| | | }
|
| | |
|
| | | userInfoMapper.subHongBaoByUid(uid, drawBackMoney);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = null;
|
| | | // 新版资金记录
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid,
|
| | | weiQuanDrawBack, drawBackMoney);
|
| | | userMoneyDetailMapper.insert(userMoneyDetail);
|
| | | userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid, weiQuanDrawBack,
|
| | | drawBackMoney);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail);
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId, drawBackMoney,
|
| | | userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|