| | |
| | | import com.yeshi.fanli.entity.taobao.PidUser;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoManageService;
|
| | | import com.yeshi.fanli.service.inter.order.PidOrderService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.UserNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.UserShareGoodsGroupService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | // @Resource
|
| | | // private LostOrderService lostOrderService;
|
| | | |
| | | @Resource |
| | | private UserShareGoodsGroupService userShareGoodsGroupService;
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | |
| | | while (its.hasNext()) {
|
| | | String orderId = its.next();
|
| | | // 订单锁定
|
| | | // if (isRedisLockOrder(orderId))
|
| | | // continue;
|
| | | // redisLockOrder(orderId);
|
| | | // if (isRedisLockOrder(orderId))
|
| | | // continue;
|
| | | // redisLockOrder(orderId);
|
| | | doPidOrder(orderId);
|
| | | // redisUnlockOrder(orderId);
|
| | | // 处理订单找回
|
| | | // lostOrderService.processSuceess(orderId);
|
| | | // redisUnlockOrder(orderId);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | @Override
|
| | | @Transactional
|
| | | public void doPidOrder(String orderId) {
|
| | | Map<String, String> convertMap = hongBaoManageService.convertMap();
|
| | | BigDecimal rate = new BigDecimal(convertMap.get("hongbao_goods_proportion")).divide(new BigDecimal(100));
|
| | |
|
| | | List<PidOrder> orders = pidOrderMapper.getPidOrderListByOrderId(orderId);
|
| | | // 只看有用户Id的情况
|
| | | if (orders.get(0).getUserInfo() != null) {
|
| | | // 根据第一个的订单创建时间来确定返利比例
|
| | | BigDecimal rate = hongBaoManageService.getShareRate(orders.get(0).getOrderCreateTime().getTime())
|
| | | .divide(new BigDecimal("100"));
|
| | | List<HongBao> hbList = hongBaoMapper.selectByOrderId(orderId);
|
| | | if (hbList.size() <= 0) {// 还没有加入红包
|
| | | // 加入红包
|
| | | for (PidOrder order : orders) {
|
| | |
|
| | | // 防止同一订单号来源于不同的PID
|
| | | if (order.getUserInfo() == null)
|
| | | continue;
|
| | |
| | | HongBao.TYPE_SHARE_GOODS, HongBao.STATE_BUKELINGQU, new Date().getTime(),
|
| | | new Date().getTime(), 0, "192.168.1.1", "系统添加");
|
| | | hongBao.setOrderId(order.getOrderId());
|
| | | hongBao.setPayMoney(order.getPayMoney());
|
| | | if ("订单结算".equalsIgnoreCase(order.getState()))
|
| | | hongBao.setPayMoney(order.getFinalMoney());
|
| | | else
|
| | | hongBao.setPayMoney(order.getPayMoney());
|
| | | if (order.getBalanceTime() != null)
|
| | | hongBao.setBalanceTime(order.getBalanceTime());
|
| | |
|
| | |
| | | }
|
| | |
|
| | | hongBaoMapper.insertSelective(hongBao);
|
| | | |
| | | //统计分享订单的数据
|
| | | try {
|
| | | userShareGoodsGroupService.updateOrderRecord(hongBao);
|
| | | } catch (UserShareGoodsRecordException e1) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e1);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | try {
|
| | | // 第三方提成订单被统计的通知
|