| | |
| | | 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;
|
| | |
| | |
|
| | | @Resource
|
| | | private UserMoneyDetailMapper userMoneyDetailMapper;
|
| | |
|
| | | @Resource
|
| | | private UserNotificationService userNotificationService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderMapper commonOrderMapper;
|
| | |
| | | userMoneyDebtService.addUserMoneyDebt(debt);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 计算退款金额
|
| | | * |
| | | * @param settlement
|
| | | * @param wqMoney
|
| | | * @param hongBaoMoney
|
| | | * @return
|
| | | */
|
| | | private BigDecimal computeDrawBackMoney(BigDecimal settlement, BigDecimal wqMoney, BigDecimal hongBaoMoney) {
|
| | | BigDecimal money = (hongBaoMoney.multiply(wqMoney)).divide(settlement, 2, BigDecimal.ROUND_UP);
|
| | | if (money.compareTo(hongBaoMoney) > 0)
|
| | | money = hongBaoMoney;
|
| | | return money;
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void doWeiQuanFanli(String orderId) throws TaoBaoWeiQuanException {
|
| | |
| | | List<TaoBaoWeiQuanOrder> list = taoBaoWeiQuanOrderService.getWeiQuanSuccessOrders(orderId);
|
| | | if (list == null || list.size() == 0)
|
| | | return;
|
| | | // 查询订单库
|
| | | List<TaoBaoOrder> orderList = taoBaoOrderMapper.selectTaoBaoOrderByOrderId(orderId);
|
| | | // 计算淘宝联盟返给平台的资金
|
| | | BigDecimal sumFee = new BigDecimal("0");
|
| | | for (TaoBaoOrder order : orderList)
|
| | | if (order.getOrderState().equalsIgnoreCase("订单结算")) {
|
| | | sumFee = sumFee.add(order.geteIncome());
|
| | | if (order.getSubsidy() != null)
|
| | | sumFee = sumFee.add(order.getSubsidy());
|
| | | }
|
| | | if (new BigDecimal(0).compareTo(sumFee) == 0)
|
| | | throw new TaoBaoWeiQuanException(TaoBaoWeiQuanException.CODE_NEDD_UPDATE_ORDER, "需要更新订单");
|
| | |
|
| | | // 获取和该订单号有关联的用户
|
| | | // 获取主红包(同一个订单号的单只会对应同一个用户)
|
| | | List<CommonOrderVO> typeList = new ArrayList<>();
|
| | |
| | | commonOrderMapper.updateByPrimaryKeySelective(co);
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(vo.getId());
|
| | | mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | if (hongBaoOrder.getCommonOrder() != null
|
| | | && !StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getTradeId()))
|
| | | // 查询是否已经维权
|
| | | {
|
| | | TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackMapper.selectByOrderItemIdAndUid(
|
| | | hongBaoOrder.getCommonOrder().getTradeId(),
|
| | | hongBaoOrder.getHongBaoV2().getUserInfo().getId());
|
| | | if (drawBack == null)// 添加还未扣款的子订单
|
| | | mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | }
|
| | | }
|
| | | if (mainHongBaoList == null || mainHongBaoList.size() == 0)
|
| | | return;
|
| | |
| | |
|
| | | if (mainHongBaoList != null)
|
| | | for (HongBaoV2 hongBao : mainHongBaoList) {
|
| | | if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | if (hongBao.getState() != HongBaoV2.STATE_YILINGQU)
|
| | | continue;
|
| | | // 累计主红包的金额
|
| | | if (fanMoneyMap.get(hongBao.getUserInfo().getId()) == null) {
|
| | |
| | | while (its.hasNext()) {
|
| | | Long uid = its.next();
|
| | | BigDecimal userGetMoney = fanMoneyMap.get(uid);
|
| | | BigDecimal fanMoney = new BigDecimal("0");
|
| | | BigDecimal wqMoney = new BigDecimal("0");
|
| | | // 统计用户在这个单中需要扣除的资金
|
| | | TaoBaoWeiQuanDrawBack weiQuanDrawBack = null;
|
| | | List<TaoBaoWeiQuanDrawBack> newWeiQuanDrawBackList = new ArrayList<>();
|
| | | BigDecimal settleMent = new BigDecimal(0);
|
| | | for (TaoBaoWeiQuanOrder weiQuanOrder : list) {
|
| | | weiQuanDrawBack = taoBaoWeiQuanDrawBackMapper.selectByOrderItemIdAndUid(weiQuanOrder.getOrderItemId(),
|
| | | uid);
|
| | | if (weiQuanDrawBack != null)
|
| | | continue;
|
| | | // 计算结算金额
|
| | | TaoBaoOrder taoBaoOrder = taoBaoOrderMapper.selectTaoBaoOrderByTradeId(weiQuanOrder.getOrderItemId());
|
| | | if (taoBaoOrder == null)
|
| | | throw new TaoBaoWeiQuanException(101, "未找到子订单相关数据");
|
| | |
|
| | | if (taoBaoOrder.getSettlement() == null)
|
| | | throw new TaoBaoWeiQuanException(102, "淘宝结算金额为空");
|
| | |
|
| | | settleMent = settleMent.add(taoBaoOrder.getSettlement());
|
| | |
|
| | | // 退款的资金
|
| | | fanMoney = fanMoney.add(weiQuanOrder.getFanMoney());
|
| | | wqMoney = wqMoney.add(weiQuanOrder.getMoney());
|
| | | weiQuanDrawBack = new TaoBaoWeiQuanDrawBack();
|
| | | weiQuanDrawBack.setCreateTime(new Date());
|
| | | // 暂时设为0
|
| | | weiQuanDrawBack.setDrawBackMoney(new BigDecimal(0));
|
| | |
|
| | | CommonOrder commonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | weiQuanOrder.getOrderItemId());
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | // 计算退款的资金
|
| | | BigDecimal drawBack = null;
|
| | | if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null)
|
| | | drawBack = computeDrawBackMoney(commonOrder.getSettlement(), weiQuanOrder.getMoney(),
|
| | | hongBaoOrder.getHongBaoV2().getMoney());
|
| | |
|
| | | weiQuanDrawBack.setDrawBackMoney(drawBack);
|
| | | weiQuanDrawBack.setOrderId(weiQuanOrder.getOrderId());
|
| | | weiQuanDrawBack.setOrderItemId(weiQuanOrder.getOrderItemId());
|
| | | weiQuanDrawBack.setUser(new UserInfo(uid));
|
| | | newWeiQuanDrawBackList.add(weiQuanDrawBack);
|
| | | }
|
| | |
|
| | | if (fanMoney.compareTo(new BigDecimal("0")) <= 0)
|
| | | if (wqMoney.compareTo(new BigDecimal("0")) <= 0)
|
| | | continue;
|
| | |
|
| | | // 插入记录
|
| | |
| | | }
|
| | |
|
| | | // 退款金额
|
| | | BigDecimal drawBackMoney = MoneyBigDecimalUtil.div(userGetMoney.multiply(fanMoney), sumFee);
|
| | | if (drawBackMoney.compareTo(userGetMoney) > 0)
|
| | | drawBackMoney = userGetMoney;// 退款金额不能比获得的金额大
|
| | | BigDecimal drawBackMoney = computeDrawBackMoney(settleMent, wqMoney, userGetMoney);
|
| | |
|
| | | // 计算资金是否充足
|
| | | UserInfo user = userInfoMapper.selectByPKey(uid);
|
| | | if (user != null && user.getMyHongBao().compareTo(drawBackMoney) < 0)// 资金不足
|
| | | {
|
| | | // 添加债务
|
| | | for (TaoBaoWeiQuanOrder weiQuanOrder : list) {
|
| | | TaoBaoOrder taoBaoOrder = taoBaoOrderMapper
|
| | | .selectTaoBaoOrderByTradeId(weiQuanOrder.getOrderItemId());
|
| | | for (TaoBaoWeiQuanDrawBack drawBack : newWeiQuanDrawBackList) {
|
| | | TaoBaoOrder taoBaoOrder = taoBaoOrderMapper.selectTaoBaoOrderByTradeId(drawBack.getOrderItemId());
|
| | | if (taoBaoOrder != null) {
|
| | | BigDecimal totalFee = taoBaoOrder.geteIncome();
|
| | | if (taoBaoOrder.getSubsidy() != null)
|
| | | totalFee = totalFee.add(taoBaoOrder.getSubsidy());
|
| | | //
|
| | | TaoBaoWeiQuanOrder weiQuanOrder = taoBaoWeiQuanOrderService
|
| | | .selectByTradeId(drawBack.getOrderItemId());
|
| | | CommonOrder co = commonOrderMapper.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | weiQuanOrder.getOrderItemId());
|
| | | drawBack.getOrderItemId());
|
| | | if (co != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(co.getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) {
|
| | | BigDecimal drawback = MoneyBigDecimalUtil.div(
|
| | | hongBaoOrder.getHongBaoV2().getMoney().multiply(weiQuanOrder.getFanMoney()),
|
| | | totalFee);
|
| | | BigDecimal drawback = computeDrawBackMoney(taoBaoOrder.getSettlement(),
|
| | | weiQuanOrder.getMoney(), hongBaoOrder.getHongBaoV2().getMoney());
|
| | | try {
|
| | | addDebt(uid, hongBaoOrder.getHongBaoV2().getId(), drawback);
|
| | | } catch (UserMoneyDebtException e) {
|
| | |
| | | userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail);
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.fanliOrderWeiQuan(uid, orderId,Constant.SOURCE_TYPE_TAOBAO, drawBackMoney,
|
| | | userMoneyMsgNotificationService.fanliOrderWeiQuan(uid, orderId, Constant.SOURCE_TYPE_TAOBAO, drawBackMoney,
|
| | | userInfoMapper.selectByPKey(uid).getMyHongBao());
|
| | |
|
| | | userNotificationService.weiQuanFanli(uid, orderId, drawBackMoney);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | List<TaoBaoWeiQuanOrder> list = taoBaoWeiQuanOrderService.getWeiQuanSuccessOrders(orderId);
|
| | | if (list == null || list.size() == 0)
|
| | | return;
|
| | | // 查询订单库
|
| | | List<TaoBaoOrder> orderList = taoBaoOrderMapper.selectTaoBaoOrderByOrderId(orderId);
|
| | | // 计算淘宝联盟返给平台的资金
|
| | | BigDecimal sumFee = new BigDecimal("0");
|
| | | for (TaoBaoOrder order : orderList)
|
| | | if (order.getOrderState().equalsIgnoreCase("订单结算")) {
|
| | | sumFee = sumFee.add(order.geteIncome());
|
| | | if (order.getSubsidy() != null)
|
| | | sumFee = sumFee.add(order.getSubsidy());
|
| | | }
|
| | | // 获取和该订单号有关联的用户
|
| | | // 获取主红包(同一个订单号的单只会对应同一个用户)
|
| | |
|
| | | List<CommonOrderVO> typeList = new ArrayList<>();
|
| | | CommonOrderVO cv = new CommonOrderVO();
|
| | | cv.setSourceType(Constant.SOURCE_TYPE_TAOBAO);
|
| | |
| | | co.setState(CommonOrder.STATE_WQ);
|
| | | co.setUpdateTime(new Date());
|
| | | commonOrderMapper.updateByPrimaryKeySelective(co);
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(vo.getId());
|
| | | mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | if (hongBaoOrder.getCommonOrder() != null
|
| | | && !StringUtil.isNullOrEmpty(hongBaoOrder.getCommonOrder().getTradeId()))
|
| | | // 查询是否已经维权
|
| | | {
|
| | | TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackMapper.selectByOrderItemIdAndUid(
|
| | | hongBaoOrder.getCommonOrder().getTradeId(),
|
| | | hongBaoOrder.getHongBaoV2().getUserInfo().getId());
|
| | | if (drawBack == null)// 添加还未扣款的子订单
|
| | | mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | }
|
| | | }
|
| | |
|
| | | if (mainHongBaoList == null || mainHongBaoList.size() == 0)
|
| | |
| | | Map<Long, BigDecimal> fanMoneyMap = new HashMap<>();
|
| | |
|
| | | if (mainHongBaoList != null)
|
| | | for (HongBaoV2 hongBao : mainHongBaoList) {
|
| | | for (HongBaoV2 hongBao : mainHongBaoList) {// 统计订单下的所有主红包
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKey(hongBao.getId());
|
| | | if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | if (hongBao.getState() != HongBaoV2.STATE_YILINGQU)
|
| | | continue;
|
| | |
|
| | | // 只计入分享赚的红包
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 计算每个用户的返利比例
|
| | | Iterator<Long> its = fanMoneyMap.keySet().iterator();
|
| | | // 查询和这个订单有关的用户(主订单)
|
| | | while (its.hasNext()) {
|
| | | Long uid = its.next();
|
| | | BigDecimal userGetMoney = fanMoneyMap.get(uid);
|
| | | BigDecimal fanMoney = new BigDecimal("0");
|
| | | BigDecimal wqMoney = new BigDecimal("0");
|
| | | BigDecimal settleMent = new BigDecimal("0");
|
| | | // 统计用户在这个单中需要扣除的资金
|
| | | TaoBaoWeiQuanDrawBack weiQuanDrawBack = null;
|
| | |
|
| | |
| | | uid);
|
| | | if (weiQuanDrawBack != null)
|
| | | continue;
|
| | | // 计算结算金额
|
| | | TaoBaoOrder taoBaoOrder = taoBaoOrderMapper.selectTaoBaoOrderByTradeId(weiQuanOrder.getOrderItemId());
|
| | | if (taoBaoOrder == null)
|
| | | throw new TaoBaoWeiQuanException(101, "未找到子订单相关数据");
|
| | |
|
| | | if (taoBaoOrder.getSettlement() == null)
|
| | | throw new TaoBaoWeiQuanException(102, "淘宝结算金额为空");
|
| | |
|
| | | settleMent = settleMent.add(taoBaoOrder.getSettlement());
|
| | |
|
| | | // 退款的资金
|
| | | fanMoney = fanMoney.add(weiQuanOrder.getFanMoney());
|
| | | wqMoney = wqMoney.add(weiQuanOrder.getMoney());
|
| | | // 插入记录
|
| | | weiQuanDrawBack = new TaoBaoWeiQuanDrawBack();
|
| | | weiQuanDrawBack.setCreateTime(new Date());
|
| | | // TODO 暂时设为0
|
| | | weiQuanDrawBack.setDrawBackMoney(new BigDecimal(0));
|
| | | // 计算退款资金
|
| | | CommonOrder commonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | weiQuanOrder.getOrderItemId());
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | // 计算退款的资金
|
| | | BigDecimal drawBack = null;
|
| | | if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null)
|
| | | drawBack = computeDrawBackMoney(commonOrder.getSettlement(), weiQuanOrder.getMoney(),
|
| | | hongBaoOrder.getHongBaoV2().getMoney());
|
| | |
|
| | | weiQuanDrawBack.setDrawBackMoney(drawBack);
|
| | |
|
| | | weiQuanDrawBack.setOrderId(weiQuanOrder.getOrderId());
|
| | | weiQuanDrawBack.setOrderItemId(weiQuanOrder.getOrderItemId());
|
| | | weiQuanDrawBack.setUser(new UserInfo(uid));
|
| | | newWeiQuanDrawBackList.add(weiQuanDrawBack);
|
| | | }
|
| | |
|
| | | if (fanMoney.compareTo(new BigDecimal("0")) <= 0)
|
| | | if (wqMoney.compareTo(new BigDecimal("0")) <= 0)
|
| | | continue;
|
| | |
|
| | | // 退款金额
|
| | | BigDecimal drawBackMoney = MoneyBigDecimalUtil.div(userGetMoney.multiply(fanMoney), sumFee);
|
| | | BigDecimal drawBackMoney = computeDrawBackMoney(settleMent, wqMoney, userGetMoney);
|
| | | if (drawBackMoney.compareTo(userGetMoney) > 0)
|
| | | drawBackMoney = userGetMoney;
|
| | |
|
| | |
| | | if (user != null && user.getMyHongBao().compareTo(drawBackMoney) < 0)// 资金不足
|
| | | {
|
| | | // 添加债务
|
| | | for (TaoBaoWeiQuanOrder weiQuanOrder : list) {
|
| | | TaoBaoOrder taoBaoOrder = taoBaoOrderMapper
|
| | | .selectTaoBaoOrderByTradeId(weiQuanOrder.getOrderItemId());
|
| | | for (TaoBaoWeiQuanDrawBack drawBack : newWeiQuanDrawBackList) {
|
| | | TaoBaoOrder taoBaoOrder = taoBaoOrderMapper.selectTaoBaoOrderByTradeId(drawBack.getOrderItemId());
|
| | | if (taoBaoOrder != null) {
|
| | | BigDecimal totalFee = taoBaoOrder.geteIncome();
|
| | | if (taoBaoOrder.getSubsidy() != null)
|
| | | totalFee = totalFee.add(taoBaoOrder.getSubsidy());
|
| | | //
|
| | | TaoBaoWeiQuanOrder weiQuanOrder = taoBaoWeiQuanOrderService
|
| | | .selectByTradeId(drawBack.getOrderItemId());
|
| | | BigDecimal settleMentMoney = taoBaoOrder.getSettlement();
|
| | | CommonOrder co = commonOrderMapper.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | weiQuanOrder.getOrderItemId());
|
| | | if (co != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(co.getId());
|
| | | BigDecimal drawback = MoneyBigDecimalUtil.div(
|
| | | hongBaoOrder.getHongBaoV2().getMoney().multiply(weiQuanOrder.getFanMoney()),
|
| | | totalFee);
|
| | | BigDecimal drawback = computeDrawBackMoney(settleMentMoney, weiQuanOrder.getMoney(),
|
| | | hongBaoOrder.getHongBaoV2().getMoney());
|
| | | try {
|
| | | addDebt(uid, hongBaoOrder.getHongBaoV2().getId(), drawback);
|
| | | } catch (UserMoneyDebtException e) {
|
| | | throw new TaoBaoWeiQuanException(101, "资金借贷异常");
|
| | | }
|
| | |
|
| | | if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) {
|
| | | List<HongBaoV2> hongBaoList = hongBaoV2Mapper
|
| | | .listChildrenById(hongBaoOrder.getHongBaoV2().getId());
|
| | | for (int i = 0; i < hongBaoList.size(); i++) {
|
| | | if (hongBaoList.get(i).getUserInfo().getId().longValue() != uid) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | |
|
| | | for (HongBaoV2 hb : hongBaoList) {
|
| | | drawback = MoneyBigDecimalUtil
|
| | | .div(hb.getMoney().multiply(weiQuanOrder.getFanMoney()), totalFee);
|
| | | try {
|
| | | addDebt(hb.getUserInfo().getId(), hb.getId(), drawback);
|
| | | } catch (UserMoneyDebtException e) {
|
| | | throw new TaoBaoWeiQuanException(101, "资金借贷异常");
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | | userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail);
|
| | | userMoneyMsgNotificationService.shareOrderWeiQuan(uid, orderId, Constant.SOURCE_TYPE_TAOBAO, drawBackMoney,
|
| | |
|
| | | userMoneyMsgNotificationService.shareOrderWeiQuan(uid, orderId, Constant.SOURCE_TYPE_TAOBAO,drawBackMoney,
|
| | | userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | userNotificationService.weiQuanTiCheng(uid, orderId, drawBackMoney);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | // 查询订单库
|
| | | for (TaoBaoWeiQuanOrder weiQuanOrder : list) {
|
| | | TaoBaoOrder taoBaoOrder = taoBaoOrderMapper.selectTaoBaoOrderByTradeId(weiQuanOrder.getOrderItemId());
|
| | | BigDecimal fanMoney = weiQuanOrder.getFanMoney();
|
| | | BigDecimal wqMoney = weiQuanOrder.getMoney();
|
| | | if (taoBaoOrder == null)
|
| | | throw new TaoBaoWeiQuanException(1, "来源交易ID有误");
|
| | | BigDecimal sumFee = new BigDecimal("0");
|
| | | BigDecimal settleMent = new BigDecimal("0");
|
| | | if (taoBaoOrder.getOrderState().equalsIgnoreCase("订单结算")) {
|
| | | sumFee = sumFee.add(taoBaoOrder.geteIncome());
|
| | | if (taoBaoOrder.getSubsidy() != null)
|
| | | sumFee = sumFee.add(taoBaoOrder.getSubsidy());
|
| | | settleMent = settleMent.add(taoBaoOrder.getSettlement());
|
| | | }
|
| | |
|
| | | // 查询下级子用户
|
| | |
| | | .selectByOrderItemIdAndUid(weiQuanOrder.getOrderItemId(), child.getUserInfo().getId());
|
| | | if (weiQuanDrawBack != null)
|
| | | continue;
|
| | | BigDecimal drawBackMoney = MoneyBigDecimalUtil.div(child.getMoney().multiply(fanMoney), sumFee);
|
| | | if (drawBackMoney.compareTo(child.getMoney()) > 0)
|
| | | drawBackMoney = child.getMoney();
|
| | | BigDecimal drawBackMoney = computeDrawBackMoney(settleMent, wqMoney, child.getMoney());
|
| | | weiQuanDrawBack = new TaoBaoWeiQuanDrawBack();
|
| | | weiQuanDrawBack.setCreateTime(new Date());
|
| | | weiQuanDrawBack.setDrawBackMoney(drawBackMoney);
|
| | |
| | | weiQuanDrawBack.setUser(child.getUserInfo());
|
| | | taoBaoWeiQuanDrawBackMapper.insertSelective(weiQuanDrawBack);// 加入返还记录
|
| | |
|
| | | // 判断资金是否足够扣款
|
| | | 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) {
|
| | |
|
| | | // 判断资金是否足够扣款
|
| | | 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);
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId, Constant.SOURCE_TYPE_TAOBAO,
|
| | | drawBackMoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | | }
|
| | |
|
| | | userMoneyService.subUserMoney(uid, drawBackMoney, userMoneyDetail);
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId,Constant.SOURCE_TYPE_TAOBAO, drawBackMoney,
|
| | | userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | | }
|
| | | }
|
| | | }
|