| | |
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
| | | import com.yeshi.fanli.entity.SystemEnum;
|
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Propagation;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.HongBaoV2Mapper;
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.order.OrderRepairHistoryMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
|
| | | import com.yeshi.fanli.entity.goods.CommonGoods;
|
| | | import com.yeshi.fanli.entity.money.ExtractCheckCompensate;
|
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | |
| | | import com.yeshi.fanli.entity.order.ShareGoodsActivityOrder;
|
| | | import com.yeshi.fanli.entity.push.PushInfo;
|
| | | import com.yeshi.fanli.entity.push.PushInfo.PushTypeEnum;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.HongBaoException;
|
| | | import com.yeshi.fanli.exception.PushException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | | import com.yeshi.fanli.exception.push.PushException;
|
| | | import com.yeshi.fanli.exception.push.PushInfoException;
|
| | | import com.yeshi.fanli.exception.taobao.TaobaoGoodsDownException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.OrderRepairHistoryService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderRepairService;
|
| | | import com.yeshi.fanli.service.inter.order.ShareGoodsActivityOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
|
| | | import com.yeshi.fanli.service.inter.push.PushInfoService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoWeiQuanOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import org.yeshi.utils.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import org.yeshi.utils.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.CommonOrderGoodsFactory;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | | import com.yeshi.fanli.util.factory.goods.CommonOrderFactory;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | |
|
| | |
| | | private OrderRepairHistoryService orderRepairHistoryService;
|
| | |
|
| | | @Resource
|
| | | private DataSourceTransactionManager dataSourceTransactionManager;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService;
|
| | |
|
| | | @Resource
|
| | |
| | | @Resource
|
| | | private ExtractCheckCompensateMapper extractCheckCompensateMapper;
|
| | |
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void repairOrder(String orderId) throws Exception {
|
| | | // 比较CommonOrder与TaoBaoOrder的预估收益
|
| | |
| | |
|
| | | }
|
| | |
|
| | | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
| | | private void processLessFanOrder(String orderId) throws Exception {
|
| | |
|
| | | List<CommonOrder> commonOrderList = commonOrderMapper.listBySourceTypeAndOrderNo(Constant.SOURCE_TYPE_TAOBAO,
|
| | |
| | | wholeOrderState = CommonOrder.STATE_WHOLE_ORDER_BUFENYOUXIAO;
|
| | |
|
| | | for (TaoBaoOrder taoBaoOrder : taoBaoOrderList) {
|
| | | CommonOrder commonOrder = TaoBaoOrderUtil.convert(taoBaoOrder);
|
| | | CommonOrder commonOrder = CommonOrderFactory.create(taoBaoOrder);
|
| | | commonOrder.setStateWholeOrder(wholeOrderState);
|
| | | commonOrder.setCommonOrderGoods(getCommonOrderGoods(taoBaoOrder.getAuctionId()));
|
| | | commonOrder.setUserInfo(new UserInfo(mainUid));
|
| | |
| | | }
|
| | |
|
| | | // 修改订单信息
|
| | | @Transactional
|
| | | private void updateOrderInfo(TaoBaoOrder taoBaoOrder, Long commonOrderId) throws Exception {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderService.selectDetailByCommonOrderId(commonOrderId);
|
| | | CommonOrder newCommonOrder = TaoBaoOrderUtil.convert(taoBaoOrder);
|
| | | CommonOrder newCommonOrder = CommonOrderFactory.create(taoBaoOrder);
|
| | |
|
| | | SystemEnum system=userInfoService.getUserSystem(newCommonOrder.getUserInfo().getId());
|
| | |
|
| | | List<CommonOrderGoods> commonGoodsList = commonOrderGoodsMapper
|
| | | .listByGoodsIdAndGoodsType(taoBaoOrder.getAuctionId() + "", newCommonOrder.getSourceType());
|
| | | CommonOrderGoods cog = null;
|
| | |
| | | CommonOrder commonOrder = commonOrderService.selectByPrimaryKey(newCommonOrder.getId());
|
| | |
|
| | | if (hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_ZIGOU) {
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
|
| | | commonOrder.getCreateTime().getTime(),system);
|
| | | // 免单处理
|
| | | boolean mianDan = false;
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
|
| | |
| | | if (commonOrder.getState() == CommonOrder.STATE_JS)
|
| | | payMent = commonOrder.getSettlement();
|
| | | if (payMent.compareTo(new BigDecimal(10)) < 0) {
|
| | | mianDan = userSystemCouponRecordService.isSuccessMianDan(commonOrder.getOrderNo());
|
| | | mianDan = userSystemCouponRecordService.isSuccessMianDan(commonOrder.getSourceType(),
|
| | | commonOrder.getOrderNo());
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | hongBao.setMoney(new BigDecimal(0));
|
| | | if (mianDan) {
|
| | | try {
|
| | | userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo());
|
| | | userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo(),commonOrder.getSourceType());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | throw new HongBaoException(12, "免单券退款出错");
|
| | |
| | | BigDecimal rate = null;
|
| | | if (child.getType() == HongBaoV2.TYPE_YIJI) {// 一级分享赚
|
| | | rate = hongBaoManageService.getFirstInviteRate(child.getUrank(),
|
| | | commonOrder.getCreateTime().getTime());
|
| | | commonOrder.getCreateTime().getTime(),system);
|
| | | } else if (child.getType() == HongBaoV2.TYPE_ERJI) {// 二级分享赚
|
| | | rate = hongBaoManageService.getSecondInviteRate(child.getUrank(),
|
| | | commonOrder.getCreateTime().getTime());
|
| | | commonOrder.getCreateTime().getTime(),system);
|
| | | }
|
| | |
|
| | | // 以实际收入为准计算预估收益
|
| | |
| | | }
|
| | | } else if (hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | |
|
| | | BigDecimal fanliRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
|
| | | BigDecimal fanliRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
|
| | | commonOrder.getCreateTime().getTime(),system);
|
| | | List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService
|
| | | .listByOrderIdAndUid(commonOrder.getUserInfo().getId(), commonOrder.getOrderNo());
|
| | | if (list != null && list.size() > 0) {
|
| | |
| | | childUpdate.setUpdateTime(new Date());
|
| | | BigDecimal rate = null;
|
| | | if (child.getType() == HongBaoV2.TYPE_SHARE_YIJI) {// 一级分享赚
|
| | | rate = hongBaoManageService.getFirstShareRate(1, commonOrder.getCreateTime().getTime());
|
| | | rate = hongBaoManageService.getFirstShareRate(1, commonOrder.getCreateTime().getTime(),system);
|
| | | } else if (child.getType() == HongBaoV2.TYPE_SHARE_ERJI) {// 二级分享赚
|
| | | rate = hongBaoManageService.getSecondShareRate(1, commonOrder.getCreateTime().getTime());
|
| | | rate = hongBaoManageService.getSecondShareRate(1, commonOrder.getCreateTime().getTime(),system);
|
| | | }
|
| | |
|
| | | // 以实际收入为准计算预估收益
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void addOrder(CommonOrder commonOrder, int type, Long firstUid, Long secondUid) throws Exception {
|
| | | // 增加commonOrder
|
| | | commonOrder.setCreateTime(commonOrder.getThirdCreateTime());
|
| | |
| | | commonOrder.setCommonOrderGoods(goods);
|
| | | }
|
| | |
|
| | | SystemEnum system=userInfoService.getUserSystem(commonOrder.getUserInfo().getId());
|
| | |
|
| | | CommonOrder oldCommonOrder = commonOrderMapper.selectBySourceTypeAndTradeId(commonOrder.getSourceType(),
|
| | | commonOrder.getTradeId());
|
| | | if (oldCommonOrder == null)// 新增
|
| | |
| | |
|
| | | // 添加红包
|
| | | if (type == HongBaoV2.TYPE_ZIGOU) {// 获取自购的返利比例
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
|
| | | BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
|
| | | commonOrder.getCreateTime().getTime(),system);
|
| | | // 查询是否有免单计划
|
| | | BigDecimal mianDanMoney = null;
|
| | | if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
|
| | |
| | |
|
| | | try {
|
| | | if (userSystemCouponService.updateCouponRecordUsed(commonOrder.getUserInfo().getId(),
|
| | | commonOrder.getOrderNo(), payMent, Long.parseLong(goods.getGoodsId())))
|
| | | commonOrder.getOrderNo(), payMent, Long.parseLong(goods.getGoodsId()),commonOrder.getSourceType()))
|
| | | mianDanMoney = payMent;
|
| | | } catch (NumberFormatException e) {
|
| | | throw new HongBaoException(10, "免单商品处理出错");
|
| | |
| | | }
|
| | | } else if (commonOrder.getState() == CommonOrder.STATE_SX) {// 设置免单券失效
|
| | | try {
|
| | | userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo());
|
| | | userSystemCouponService.updateStateByDrawback(commonOrder.getOrderNo(),commonOrder.getSourceType());
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
| | |
|
| | | // 插入一级子红包
|
| | | BigDecimal firstRate = hongBaoManageService
|
| | | .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
|
| | | .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
|
| | | if (firstRate.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | HongBaoV2 firstHongbao = new HongBaoV2();
|
| | |
| | |
|
| | | if (boss != null) {// 二级BOSS存在
|
| | | BigDecimal secondRate = hongBaoManageService
|
| | | .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
|
| | | .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
|
| | | if (secondRate.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | HongBaoV2 secondHongbao = new HongBaoV2();
|
| | |
| | | if (commonOrder.getState() == CommonOrder.STATE_SX || commonOrder.getState() == CommonOrder.STATE_WQ)
|
| | | return;
|
| | | // 分享赚
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
|
| | | BigDecimal shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
|
| | | commonOrder.getCreateTime().getTime(),system);
|
| | |
|
| | | HongBaoV2 hongBao = new HongBaoV2();
|
| | | hongBao.setBeizhu("2019年7月批量修改");
|
| | |
| | | boss = userInfoService.selectByPKey(firstUid);
|
| | | if (boss != null) {
|
| | | BigDecimal firstLevelRate = hongBaoManageService.getFirstShareRate(1,
|
| | | commonOrder.getThirdCreateTime().getTime());
|
| | | commonOrder.getThirdCreateTime().getTime(),system);
|
| | | HongBaoV2 child = new HongBaoV2();
|
| | | child.setBeizhu("2019年7月批量修改");
|
| | | child.setParent(hongBao);
|
| | |
| | |
|
| | | }
|
| | |
|
| | | @Transactional(propagation = Propagation.REQUIRED)
|
| | | private void deleteByCommonOrderId(Long commonOrderId) {
|
| | | commonOrderMapper.deleteByPrimaryKey(commonOrderId);
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrderId);
|
| | |
| | | return orderInfoMap.get(orderId);
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void repireFirstAndSecondLevel(String orderId) throws Exception {
|
| | | repireFirstShare(orderId);
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | | for (CommonOrder commonOrder : list) {
|
| | | SystemEnum system=userInfoService.getUserSystem(commonOrder.getUserInfo().getId());
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | if (hongBaoOrder == null)
|
| | | continue;
|
| | |
| | | if (boss != null && hongBao.getState() != HongBaoV2.STATE_SHIXIAO) {// 1级BOSS存在且红包未失效,免单不支持多级分销
|
| | | // 插入一级子红包
|
| | | BigDecimal firstRate = hongBaoManageService
|
| | | .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
|
| | | .getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
|
| | | if (firstRate.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | HongBaoV2 firstHongbao = new HongBaoV2();
|
| | |
| | |
|
| | | if (boss != null) {// 二级BOSS存在
|
| | | BigDecimal secondRate = hongBaoManageService
|
| | | .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
|
| | | .getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank(),system);
|
| | | if (secondRate.compareTo(new BigDecimal(0)) <= 0)
|
| | | return;
|
| | | HongBaoV2 secondHongbao = new HongBaoV2();
|
| | |
| | | if (hongBaoOrder == null)
|
| | | continue;
|
| | |
|
| | | SystemEnum system=userInfoService.getUserSystem(commonOrder.getUserInfo().getId());
|
| | |
|
| | | HongBaoV2 hongBao = hongBaoOrder.getHongBaoV2();
|
| | | // 4月17日后才有一级分享赚
|
| | | if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-17",
|
| | |
| | | boss = userInfoService.selectByPKey(firstUid);
|
| | | if (boss != null) {
|
| | | BigDecimal firstLevelRate = hongBaoManageService.getFirstShareRate(1,
|
| | | commonOrder.getThirdCreateTime().getTime());
|
| | | commonOrder.getThirdCreateTime().getTime(),system);
|
| | | HongBaoV2 child = new HongBaoV2();
|
| | | child.setBeizhu("2019年7月批量修改");
|
| | | child.setParent(hongBao);
|
| | |
| | | // 加资金
|
| | | userMoneyService.addUserMoney(uid, money, detail);
|
| | | pushMsg(uid, "关于近期订单与资金异常的排查与修复结果通知",
|
| | | "尊敬的用户,经仔细核对您账户中的订单,发现您账户中有未统计或错误统计的订单,我们已经为您补齐资金,对应资金已经存入您的账户余额中,敬请查收注查收。感谢信任,返利券App终将成为您最信任的购物省钱助手。");
|
| | | "尊敬的用户,经仔细核对您账户中的订单,发现您账户中有未统计或错误统计的订单,我们已经为您补齐资金,对应资金已经存入您的账户余额中,敬请查收注查收。感谢信任,板栗快省App终将成为您最信任的购物省钱助手。");
|
| | | userMoneyMsgNotificationService.systemEqualize(uid, "订单统计异常修复", money, userInfoService.getBalance(uid));
|
| | | } catch (UserMoneyDetailException e) {
|
| | | e.printStackTrace();
|
| | |
| | |
|
| | | } else {// 资金需要减少,不要扣钱
|
| | | pushMsg(uid, "关于近期订单与资金异常的排查与修复结果通知",
|
| | | "尊敬的用户,经仔细核对您账户中的订单,发现您账户中有错误统计的订单,我们已经为您恢复正常,所涉及订单多统计出来的资金,不会被扣除,即您账户中的资金将保持不变,已提现的资金,也不会收回,敬请知晓。感谢信任,返利券App终将成为您最信任的购物省钱助手。");
|
| | | "尊敬的用户,经仔细核对您账户中的订单,发现您账户中有错误统计的订单,我们已经为您恢复正常,所涉及订单多统计出来的资金,不会被扣除,即您账户中的资金将保持不变,已提现的资金,也不会收回,敬请知晓。感谢信任,板栗快省App终将成为您最信任的购物省钱助手。");
|
| | | // userMoneyMsgNotificationService.systemEqualize(uid, "订单统计异常修复",
|
| | | // money, userInfoService.getBalance(uid));
|
| | | // 加入提现审核异常保护中
|