| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.AccountDetailsMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper;
|
| | | import com.yeshi.fanli.dao.mybatis.UserInfoMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.money.UserMoneyDetailMapper;
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.order.HongBaoOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanDrawBackMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.AccountDetails;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.order.HongBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
|
| | |
| | | import com.yeshi.fanli.exception.TaoBaoWeiQuanException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoWeiQuanDrawBackService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoWeiQuanOrderService;
|
| | | 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.factory.AccountDetailsFactory;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | |
|
| | |
| | | @Resource
|
| | | private UserMoneyDetailMapper userMoneyDetailMapper;
|
| | |
|
| | | @Resource
|
| | | private AccountDetailsMapper accountDetailsMapper;
|
| | |
|
| | | @Resource
|
| | | private UserNotificationService userNotificationService;
|
| | |
| | |
|
| | | @Resource
|
| | | private HongBaoOrderMapper hongBaoOrderMapper;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | |
|
| | | @Override
|
| | | public void addWeiQuanDrawBack(TaoBaoWeiQuanDrawBack taoBaoWeiQuanDrawBack) {
|
| | |
| | | cv.setOrderNo(orderId);
|
| | | typeList.add(cv);
|
| | |
|
| | | List<CommonOrderVO> commonOrderList = commonOrderMapper.listByOrderNoAndType(typeList);
|
| | | List<CommonOrderVO> commonOrderList = commonOrderMapper.listOrderGoodsInfo(typeList);
|
| | | List<HongBaoV2> mainHongBaoList = new ArrayList<>();
|
| | | if (commonOrderList != null)
|
| | | for (CommonOrderVO vo : commonOrderList) {
|
| | | // 修改订单状态为维权
|
| | | CommonOrder co = new CommonOrder(vo.getId());
|
| | | co.setState(CommonOrder.STATE_WQ);
|
| | | co.setUpdateTime(new Date());
|
| | | commonOrderMapper.updateByPrimaryKeySelective(co);
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(vo.getId());
|
| | | mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | }
|
| | | if (mainHongBaoList == null || mainHongBaoList.size() == 0)
|
| | | return;
|
| | | for (int i = 0; i < mainHongBaoList.size(); i++) {
|
| | | HongBaoV2 hb = hongBaoV2Mapper.selectByPrimaryKey(mainHongBaoList.get(i).getId());
|
| | | mainHongBaoList.set(i, hb);
|
| | | // 只处理返利订单
|
| | | if (mainHongBaoList.get(i).getType() != HongBaoV2.TYPE_ZIGOU) {
|
| | | if (hb.getType() != HongBaoV2.TYPE_ZIGOU) {
|
| | | mainHongBaoList.remove(i);
|
| | | i--;
|
| | | }
|
| | |
| | | // 退款金额
|
| | | BigDecimal drawBackMoney = MoneyBigDecimalUtil.div(userGetMoney.multiply(fanMoney), sumFee);
|
| | | userInfoMapper.subHongBaoByUid(uid, drawBackMoney);
|
| | | // 添加资金记录
|
| | | AccountDetails accountDetails = AccountDetailsFactory.create("-" + drawBackMoney,
|
| | | AccountDetailsFactory.SHARE_GOODS_DRAWBACK, null, null, new UserInfo(uid));
|
| | | accountDetailsMapper.insertSelective(accountDetails);
|
| | | // 新版资金记录
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createFanLiWeiQuan(uid, weiQuanDrawBack,
|
| | | drawBackMoney);
|
| | | userMoneyDetail.setId(accountDetails.getId());
|
| | | userMoneyDetailMapper.insert(userMoneyDetail);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.fanliOrderWeiQuan(uid, orderId, drawBackMoney,
|
| | | userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | userNotificationService.weiQuanFanli(uid, orderId, drawBackMoney);
|
| | | }
|
| | |
| | | cv.setOrderNo(orderId);
|
| | | typeList.add(cv);
|
| | |
|
| | | List<CommonOrderVO> commonOrderList = commonOrderMapper.listByOrderNoAndType(typeList);
|
| | | List<CommonOrderVO> commonOrderList = commonOrderMapper.listOrderGoodsInfo(typeList);
|
| | | List<HongBaoV2> mainHongBaoList = new ArrayList<>();
|
| | | if (commonOrderList != null)
|
| | | for (CommonOrderVO vo : commonOrderList) {
|
| | | // 更改订单状态
|
| | | CommonOrder co = new CommonOrder(vo.getId());
|
| | | co.setState(CommonOrder.STATE_WQ);
|
| | | co.setUpdateTime(new Date());
|
| | | commonOrderMapper.updateByPrimaryKeySelective(co);
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(vo.getId());
|
| | | mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | }
|
| | |
| | | // 退款金额
|
| | | BigDecimal drawBackMoney = MoneyBigDecimalUtil.div(userGetMoney.multiply(fanMoney), sumFee);
|
| | | userInfoMapper.subHongBaoByUid(uid, drawBackMoney);
|
| | | // 添加资金记录
|
| | | AccountDetails accountDetails = AccountDetailsFactory.create("-" + drawBackMoney,
|
| | | AccountDetailsFactory.SHARE_GOODS_DRAWBACK, null, null, new UserInfo(uid));
|
| | | accountDetailsMapper.insertSelective(accountDetails);
|
| | | // 新版资金记录
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShareWeiQuan(uid, weiQuanDrawBack,
|
| | | drawBackMoney);
|
| | | userMoneyDetail.setId(accountDetails.getId());
|
| | | userMoneyDetailMapper.insert(userMoneyDetail);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | userMoneyMsgNotificationService.shareOrderWeiQuan(uid, orderId, drawBackMoney,
|
| | | userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | userNotificationService.weiQuanTiCheng(uid, orderId, drawBackMoney);
|
| | | }
|
| | |
| | | cv.setOrderNo(orderId);
|
| | | typeList.add(cv);
|
| | |
|
| | | List<CommonOrderVO> commonOrderList = commonOrderMapper.listByOrderNoAndType(typeList);
|
| | | List<CommonOrderVO> commonOrderList = commonOrderMapper.listOrderGoodsInfo(typeList);
|
| | | List<HongBaoV2> mainHongBaoList = new ArrayList<>();
|
| | | if (commonOrderList != null)
|
| | | for (CommonOrderVO vo : commonOrderList) {
|
| | | CommonOrder co = commonOrderMapper.selectByPrimaryKey(vo.getId());
|
| | | if (co.getState() != CommonOrder.STATE_WQ) {
|
| | | co = new CommonOrder(vo.getId());
|
| | | co.setState(CommonOrder.STATE_WQ);
|
| | | co.setUpdateTime(new Date());
|
| | | commonOrderMapper.updateByPrimaryKeySelective(co);
|
| | | }
|
| | |
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(vo.getId());
|
| | | mainHongBaoList.add(hongBaoOrder.getHongBaoV2());
|
| | | }
|
| | |
| | |
|
| | | if (mainHongBaoList != null)
|
| | | for (HongBaoV2 hongBao : mainHongBaoList) {
|
| | | HongBaoV2 hb = hongBaoV2Mapper.selectByPrimaryKey(hongBao.getId());
|
| | | hongBao = hb;
|
| | |
|
| | | if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | continue;
|
| | | // 返利红包不计入
|
| | |
| | | // 退款金额
|
| | | BigDecimal drawBackMoney = MoneyBigDecimalUtil.div(userGetMoney.multiply(fanMoney), sumFee);
|
| | | userInfoMapper.subHongBaoByUid(uid, drawBackMoney);
|
| | | // 添加资金记录
|
| | | AccountDetails accountDetails = AccountDetailsFactory.create("-" + drawBackMoney,
|
| | | AccountDetailsFactory.SHARE_GOODS_DRAWBACK, null, null, new UserInfo(uid));
|
| | | accountDetailsMapper.insertSelective(accountDetails);
|
| | |
|
| | | // 新版资金记录
|
| | | try {
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInviteWeiQuan(uid, weiQuanDrawBack,
|
| | | drawBackMoney);
|
| | | userMoneyDetail.setId(accountDetails.getId());
|
| | | userMoneyDetailMapper.insert(userMoneyDetail);
|
| | | } catch (UserMoneyDetailException e) {
|
| | | try {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | //
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderWeiQuan(uid, orderId, drawBackMoney,
|
| | | userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | userNotificationService.weiQuanTiCheng(uid, orderId, drawBackMoney);
|
| | | }
|