| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Propagation;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.AccountMessageMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.HongBaoManageMapper;
|
| | | import com.google.gson.Gson;
|
| | | 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.order.OrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.share.PidUserMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.jd.JDOrder;
|
| | | import com.yeshi.fanli.entity.jd.JDOrderItem;
|
| | | 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.pdd.PDDOrder;
|
| | | 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.entity.taobao.TaoBaoWeiQuanDrawBack;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.HongBaoException;
|
| | | import com.yeshi.fanli.exception.OrderItemException;
|
| | |
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService;
|
| | | 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.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.LostOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.service.inter.push.PushService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoBuyRelationMapService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoWeiQuanDrawBackService;
|
| | | import com.yeshi.fanli.service.inter.user.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserNotificationService;
|
| | | import com.yeshi.fanli.service.inter.user.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | 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.TimeUtil;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeOrderApiUtil;
|
| | |
|
| | | @Service
|
| | |
| | | private OrderMapper orderMapper;
|
| | |
|
| | | @Resource
|
| | | private PidUserMapper pidUserMapper;
|
| | |
|
| | | @Resource
|
| | | private UserInfoMapper userInfoMapper;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageMapper hongBaoManageMapper;
|
| | |
|
| | | @Resource
|
| | | private AccountMessageMapper accountMessageMapper;
|
| | |
|
| | | @Resource
|
| | | private OrderService orderService;
|
| | |
|
| | | @Resource
|
| | | private PushService pushService;
|
| | |
|
| | | @Resource
|
| | | private UserNotificationService userNotificationService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoUnionConfigService taoBaoUnionConfigService;
|
| | |
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private RedisManager redisManager;
|
| | |
|
| | | @Resource
|
| | | private LostOrderService lostOrderService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
|
| | |
|
| | | @Resource
|
| | | private HongBaoManageService hongBaoManageService;
|
| | |
|
| | | @Resource
|
| | | private AccountDetailsHongBaoMapService accountDetailsHongBaoMapService;
|
| | |
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyService userMoneyService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoBuyRelationMapService taoBaoBuyRelationMapService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Override
|
| | | public void processOrder(Map<String, List<TaoBaoOrder>> orders) {
|
| | | public synchronized void processOrder(Map<String, List<TaoBaoOrder>> orders) {
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
|
| | |
|
| | | // 分离出返利订单与分享赚订单
|
| | |
| | |
|
| | | if (orders.get(orderId) != null && orders.get(orderId).size() > 0) {
|
| | | List<TaoBaoOrder> list = orders.get(orderId);
|
| | | LogHelper.test(String.format("订单处理:订单号-%s 订单数量-%s", orderId, list.size() + ""));
|
| | | if (!StringUtil.isNullOrEmpty(list.get(0).getRelationId())) {
|
| | | shareOrderMap.put(orderId, list);
|
| | | } else if (!StringUtil.isNullOrEmpty(list.get(0).getSpecialId())) {
|
| | | String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(),
|
| | | list.get(0).getSourceMediaId(), list.get(0).getAdPositionId());
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(list.get(0).getSpecialId())
|
| | | || pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)) {// 设置渠道ID当做会员运营ID的位置ID
|
| | | fanliOrderMap.put(orderId, list);
|
| | | } else if (!StringUtil.isNullOrEmpty(list.get(0).getRelationId())) {
|
| | | shareOrderMap.put(orderId, list);
|
| | | } else {
|
| | | String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(),
|
| | | list.get(0).getSourceMediaId(), list.get(0).getAdPositionId());
|
| | | PidUser pidUser = pidUserMapper.selectByPid(pid);
|
| | | if (pidUser != null && pidUser.getType() == PidUser.TYPE_SHARE_GOODS) {// 商品分享订单
|
| | | // List<PidOrder> pidOrderList = new ArrayList<>();
|
| | | // for (TaoBaoOrder order : list) {
|
| | | // pidOrderList.add(TaoBaoOrderUtil.convertToPidOrder(order));
|
| | | // }
|
| | | // sharePidOrderMap.put(orderId, pidOrderList);
|
| | | shareOrderMap.put(orderId, list);
|
| | | } else {// 普通返利订单
|
| | | fanliOrderMap.put(orderId, list);
|
| | | // 通过红包查询
|
| | | CommonOrder commonOrder = commonOrderService
|
| | | .selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO, list.get(0).getTradeId());
|
| | |
|
| | | if (commonOrder != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null
|
| | | && hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | shareOrderMap.put(orderId, list);
|
| | | continue;
|
| | | }
|
| | | }
|
| | | fanliOrderMap.put(orderId, list);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | processShopingFanliOrder(fanliOrderMap);
|
| | | // 处理分享赚订单
|
| | | processShareGoodsOrder(shareOrderMap);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 利用redis的原子性将订单号锁住,不让其他处理
|
| | | * |
| | | * @param orderId
|
| | | */
|
| | | private void redisLockOrder(String orderId) {
|
| | | String key = "doorder-" + orderId;
|
| | | redisManager.cacheCommonString(key, "1");
|
| | | }
|
| | |
|
| | | /**
|
| | | * 订单解锁
|
| | | * |
| | | * @param orderId
|
| | | */
|
| | | private void redisUnlockOrder(String orderId) {
|
| | | String key = "doorder-" + orderId;
|
| | | redisManager.removeCommonString(key);
|
| | | }
|
| | |
|
| | | /**
|
| | | * 订单是否被锁住了
|
| | | * |
| | | * @param orderId
|
| | | * @return
|
| | | */
|
| | | private boolean isRedisLockOrder(String orderId) {
|
| | | String key = "doorder-" + orderId;
|
| | | String doing = redisManager.getCommonString(key);
|
| | | if (!StringUtil.isNullOrEmpty(doing))
|
| | | return true;
|
| | | else
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | // 出错了就不处理该订单了,需要定期检查
|
| | |
|
| | | // 更改丢失订单的状态
|
| | | lostOrderService.processSuceess(orderId);
|
| | | lostOrderService.processSuceess(orderId, Constant.SOURCE_TYPE_TAOBAO);
|
| | |
|
| | | } catch (HongBaoException e1) {
|
| | | e1.printStackTrace();
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 获取最大的创建时间与最小的创建时间
|
| | | * |
| | | * @param hongBaoList
|
| | | * @return
|
| | | */
|
| | | private Map<String, Long> getMaxAndMinCreateTime(List<HongBao> hongBaoList) {
|
| | | if (hongBaoList.size() > 0) {
|
| | | Map<String, Long> map = new HashMap<>();
|
| | | long min = hongBaoList.get(0).getCreatetime();
|
| | | long max = hongBaoList.get(0).getCreatetime();
|
| | | for (HongBao hb : hongBaoList) {
|
| | | if (hb.getCreatetime() > max)
|
| | | max = hb.getCreatetime();
|
| | | if (hb.getCreatetime() < min)
|
| | | min = hb.getCreatetime();
|
| | | }
|
| | | map.put("max", max);
|
| | | map.put("min", min);
|
| | | return map;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void fanli() {
|
| | | LogHelper.test("处理返利到账");
|
| | | // 获取主红包
|
| | | List<HongBaoV2> hongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByType(HongBao.TYPE_TAOBAO, 100);
|
| | | List<HongBaoV2> hongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByType(HongBaoV2.TYPE_ZIGOU, 1000);
|
| | | //
|
| | | // /**
|
| | | // * 需要实时更新待返利的订单
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 判断订单是否失效 全部订单失效才判断为失效
|
| | | * |
| | | * @param list
|
| | | * @return
|
| | | */
|
| | | private boolean isOrderValid(List<TaoBaoOrder> list) {
|
| | | int validCount = 0;
|
| | | for (TaoBaoOrder order : list) {
|
| | | if (order.getOrderState().equalsIgnoreCase("订单失效"))
|
| | | validCount++;
|
| | | }
|
| | | return validCount >= list.size();
|
| | | }
|
| | |
|
| | | @Resource
|
| | | private HongBaoOrderMapper hongBaoOrderMapper;
|
| | |
|
| | |
| | | public void fanli(HongBaoV2 hb1) throws TaoBaoWeiQuanException {
|
| | | // 查询最新的红包数据
|
| | | hb1 = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hb1.getId());
|
| | | // 正常用户才能到账
|
| | | UserInfo mainUser = userInfoMapper.selectByPrimaryKey(hb1.getUserInfo().getId());
|
| | | if (mainUser == null || mainUser.getState() != UserInfo.STATE_NORMAL) {
|
| | | return;
|
| | | }
|
| | | // 查询红包相关联的订单
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hb1.getId());
|
| | | if (hongBaoOrder == null) {
|
| | | LogHelper.error("返利失败:" + hb1.getId());
|
| | | return;
|
| | | }
|
| | | // 维权中的不返利
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongBaoOrder.getCommonOrder().getOrderNo(), "维权创建");
|
| | | if (taoBaoWeiQuanList != null && taoBaoWeiQuanList.size() > 0)
|
| | | return;
|
| | |
|
| | | taoBaoWeiQuanList = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongBaoOrder.getCommonOrder().getOrderNo(), "等待处理");
|
| | | if (taoBaoWeiQuanList != null && taoBaoWeiQuanList.size() > 0)
|
| | | // 灰度测试中,京东/拼多多不返利
|
| | | if (hongBaoOrder.getCommonOrder() == null
|
| | | || hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_JD
|
| | | || hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_PDD) {
|
| | | return;
|
| | | }
|
| | |
|
| | | if (hongBaoOrder.getCommonOrder() != null
|
| | | && hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_TAOBAO) {
|
| | | // 维权中的不返利
|
| | | List<TaoBaoWeiQuanOrder> taoBaoWeiQuanList = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongBaoOrder.getCommonOrder().getOrderNo(), "维权创建");
|
| | | if (taoBaoWeiQuanList != null && taoBaoWeiQuanList.size() > 0)
|
| | | return;
|
| | |
|
| | | taoBaoWeiQuanList = taoBaoWeiQuanOrderMapper
|
| | | .selectListByOrderIdAndState(hongBaoOrder.getCommonOrder().getOrderNo(), "等待处理");
|
| | | if (taoBaoWeiQuanList != null && taoBaoWeiQuanList.size() > 0)
|
| | | return;
|
| | | }
|
| | |
|
| | | // 查询同一订单号的红包
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | userMoneyDetailMapper.insertSelective(userMoneyDetail);
|
| | | userMoneyService.addUserMoney(uid, money, userMoneyDetail);
|
| | | // 添加资金明细与红包的映射关系
|
| | | for (HongBaoV2 v2 : userHongBao.get(uid)) {
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(v2.getId(), userMoneyDetail.getId());
|
| | | }
|
| | | // 增加用户资金
|
| | | userInfoMapper.addHongBaoByUid(uid, money);
|
| | |
|
| | | // 站内信+推送
|
| | | UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
|
| | | try {
|
| | | userNotificationService.orderFanliRecieved(uid, hongBaoOrder.getCommonOrder().getOrderNo(),
|
| | | userGoodsCount.get(uid), user.getMyHongBao(), money);
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | UserInfo user = userInfoMapper.selectByPKey(uid);
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.fanliOrderReceived(uid, hongBaoOrder.getCommonOrder().getOrderNo(),
|
| | | userGoodsCount.get(uid), money, user.getMyHongBao());
|
| | | hongBaoOrder.getCommonOrder().getSourceType(), userGoodsCount.get(uid), money, user.getMyHongBao());
|
| | | }
|
| | | // 通知免单到账
|
| | | try {
|
| | |
| | | if (hongBaoOrder.getCommonOrder().getSettleTime() != null && hongBaoOrder.getCommonOrder().getSettleTime()
|
| | | .getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | try {
|
| | |
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanFanli(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | |
|
| | | if (hongBaoOrder.getCommonOrder().getSourceType() == Constant.SOURCE_TYPE_TAOBAO)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanFanli(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | if (e.getCode() == TaoBaoWeiQuanException.CODE_NEDD_UPDATE_ORDER) {
|
| | | List<TaoBaoOrder> olist = taoBaoOrderService
|
| | |
| | | if (olist != null && olist.size() > 0) {
|
| | | long time = TimeUtil.convertToTimeTemp(olist.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss");
|
| | | olist = TaoKeOrderApiUtil.getTaoBaoAllOrder(TimeUtil.getGernalTime(time, "yyyy-MM-dd HH:mm:ss"),
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET,
|
| | | TaoKeOrderApiUtil.TK_STATUS_ALL);
|
| | | List<TaoBaoOrder> thirdOList = TaoKeOrderApiUtil.getTaoBaoThirdAllOrder(
|
| | | TimeUtil.getGernalTime(time, "yyyy-MM-dd HH:mm:ss"), 30, 1,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPKEY, TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | TaoKeOrderApiUtil.TK_STATUS_ALL, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | if (thirdOList != null && thirdOList.size() > 0)
|
| | | olist.addAll(thirdOList);
|
| | |
|
| | |
| | | public void weiQuanOrder(List<TaoBaoWeiQuanOrder> orderList) {
|
| | | if (orderList != null)
|
| | | for (TaoBaoWeiQuanOrder order : orderList) {
|
| | | if (order.getState().equalsIgnoreCase("维权成功")) {
|
| | | CMQManager.getInstance().addWeiQuanOrderMsg(order);
|
| | | try {
|
| | | if (order.getState().contains("维权成功")) {
|
| | | CMQManager.getInstance().addWeiQuanOrderMsg(order);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.error("维权订单加入到队列出错:" + order != null ? new Gson().toJson(order) : null);
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | if (orderList != null && orderList.size() > 0 & !StringUtil.isNullOrEmpty(orderList.get(0).getSettlementTime()))
|
| | | order.setJieSuanTime(
|
| | | new Date(TimeUtil.convertToTimeTemp(orderList.get(0).getSettlementTime(), "yyyy-MM-dd HH:mm:ss")));
|
| | | if (order.getJieSuanTime().getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | return;
|
| | | // if (order.getJieSuanTime().getTime() >=
|
| | | // TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | | // return;
|
| | | // }
|
| | |
|
| | | // TODO 处理维权成功但是已到账的订单
|
| | |
|
| | | if (order.getJieSuanTime().getTime() > TimeUtil.convertToTimeTemp("2019-01-01", "yyyy-MM-dd")) {// 结算时间在2月1号的开始处理已到账但是维权的
|
| | | CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | order.getOrderItemId());
|
| | | if (commonOrder != null && !StringUtil.isNullOrEmpty(commonOrder.getTradeId())) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null
|
| | | && hongBaoOrder.getHongBaoV2().getState() == HongBaoV2.STATE_YILINGQU) {// 已经到账的看是否需要扣款
|
| | | TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackService
|
| | | .selectByOrderItemId(order.getOrderItemId());
|
| | | if (drawBack == null) {// 还未扣款
|
| | | try {
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanFanli(order.getOrderId());
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanShare(order.getOrderId());
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanInvite(order.getOrderId());
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, null, "订单号:" + order.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | List<Integer> types = new ArrayList<>();
|
| | | types.add(HongBaoV2.TYPE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_ERJI);
|
| | | List<HongBaoV2> hongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 1000);
|
| | | long count= hongBaoV2Mapper.countCanBalanceHongBaoByTypeAndUid(types, uid);
|
| | | List<HongBaoV2> hongBaoList =new ArrayList<>();
|
| | | //1000条数据为1页
|
| | | int page=(int) (count%1000==0?count/1000:count/1000+1);
|
| | | for(int i=0;i<page;i++)
|
| | | {
|
| | | List<HongBaoV2> tempHongBaoList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, i*1000,1000);
|
| | | if(tempHongBaoList!=null&&tempHongBaoList.size()>0)
|
| | | hongBaoList.addAll(tempHongBaoList);
|
| | | }
|
| | | // 灰度测试中,京东/拼多多订单分享/邀请订单不返利
|
| | | for (int i = 0; i < hongBaoList.size(); i++) {
|
| | | HongBaoV2 item = hongBaoList.get(i);
|
| | | if (item.getType() == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | } else {
|
| | | item = item.getParent();
|
| | | }
|
| | | if (item != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(item.getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
|
| | | CommonOrder co = hongBaoOrder.getCommonOrder();
|
| | | if (co.getSourceType() == Constant.SOURCE_TYPE_JD
|
| | | || co.getSourceType() == Constant.SOURCE_TYPE_PDD) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | } else {// 上级用户不是正常用户,订单均不能到账
|
| | | UserInfo userInfo = userInfoMapper.selectByPrimaryKey(co.getUserInfo().getId());
|
| | | if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | List<Long> hbIdList = new ArrayList<>();
|
| | |
|
| | |
| | | types.clear();
|
| | | types.add(HongBaoV2.TYPE_SHARE_YIJI);
|
| | | types.add(HongBaoV2.TYPE_SHARE_ERJI);
|
| | | List<HongBaoV2> hbList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 10000);
|
| | | //TODO 需要处理超过1w条数据的订单
|
| | | List<HongBaoV2> hbList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid,0, 10000);
|
| | |
|
| | | if (hbList != null && hbList.size() > 0)
|
| | | totalHongBaoList.addAll(hbList);
|
| | |
| | |
|
| | | // 邀请赚到账
|
| | | if (invitemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | userInfoMapper.addHongBaoByUid(uid, invitemoney);
|
| | |
|
| | | // 添加新版详情记录
|
| | | try {
|
| | |
| | | long invalidCount = hongBaoV2Mapper.countInviteOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_SX,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, (int) validCount,
|
| | | (int) weiQuanCount, (int) invalidCount, invitemoney, new Date());
|
| | | userMoneyDetailMapper.insert(userMoneyDetail);
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createInvite(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, (int) invalidCount, invitemoney, new Date());
|
| | |
|
| | | // 增加资金
|
| | | userMoneyService.addUserMoney(uid, invitemoney, userMoneyDetail);
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | } catch (UserMoneyDetailException e) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 发送推送
|
| | | try {
|
| | | // 提成到账消息通知
|
| | | userNotificationService.tiChengInviteRecieved(uid, inviteOrders.size(), inviteGoodsCount, null,
|
| | | invitemoney);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderReceived(uid, inviteOrders.size(), inviteGoodsCount, invitemoney,
|
| | | userInfoMapper.selectByPKey(uid).getMyHongBao());
|
| | | userMoneyMsgNotificationService.inviteOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, inviteOrders.size(),
|
| | | inviteGoodsCount, invitemoney, userInfoMapper.selectByPKey(uid).getMyHongBao());
|
| | |
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanInvite(orderId);
|
| | |
| | | // 查询UID的分享赚订单
|
| | | types.clear();
|
| | | types.add(HongBaoV2.TYPE_SHARE_GOODS);
|
| | | List<HongBaoV2> hongBaoShareList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid, 10000);
|
| | | //TODO 需要处理超过10000条数据的订单
|
| | | List<HongBaoV2> hongBaoShareList = hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(types, uid,0, 10000);
|
| | | for (HongBaoV2 hongBao : hongBaoShareList) {
|
| | | hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBao.getId());
|
| | | hongBao = filterWeiQuanINGHongBao(hongBao);
|
| | |
| | | // 2018-08-05 过后的订单才处理维权
|
| | | Date balanceTime = null;
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByHongBaoId(hongBao.getId());
|
| | | if (hongBaoOrder != null)
|
| | | if (hongBaoOrder != null) {
|
| | | balanceTime = hongBaoOrder.getCommonOrder().getSettleTime();
|
| | | shareGoodsCount += hongBaoOrder.getCommonOrder().getCount();
|
| | | }
|
| | | shareOrders.add(hongBaoOrder.getCommonOrder().getOrderNo());
|
| | | if (balanceTime != null
|
| | | && balanceTime.getTime() >= TimeUtil.convertToTimeTemp("2018-08-05", "yyyy-MM-dd")) {
|
| | |
| | | */
|
| | |
|
| | | if (sharemoney.compareTo(new BigDecimal(0)) > 0) {
|
| | | userInfoMapper.addHongBaoByUid(uid, sharemoney);
|
| | | // 添加新版详情记录
|
| | | try {
|
| | | // 计算本月的有效订单,失效订单,维权订单
|
| | |
| | |
|
| | | Date minDate = new Date(TimeUtil
|
| | | .convertToTimeTemp(ca.get(Calendar.YEAR) + "-" + (ca.get(Calendar.MONTH) + 1), "yyyy-M"));
|
| | | long validCount = commonOrderService.countByUidAndOrderStateWithOrderBalanceTime(uid,
|
| | | CommonOrder.STATE_JS, minDate, maxDate);
|
| | | long weiQuanCount = commonOrderService.countByUidAndOrderStateWithOrderBalanceTime(uid,
|
| | | CommonOrder.STATE_WQ, minDate, maxDate);
|
| | | long invalidCount = commonOrderService.countByUidAndOrderStateWithOrderBalanceTime(uid,
|
| | | CommonOrder.STATE_SX, minDate, maxDate);
|
| | | long validCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_JS,
|
| | | minDate, maxDate);
|
| | | long weiQuanCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_WQ,
|
| | | minDate, maxDate);
|
| | | long invalidCount = hongBaoV2Mapper.countShareOrderCountByUidAndSettleTime(uid, CommonOrder.STATE_SX,
|
| | | minDate, maxDate);
|
| | |
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, (int) validCount,
|
| | | (int) weiQuanCount, (int) invalidCount, sharemoney, new Date());
|
| | | userMoneyDetailMapper.insert(userMoneyDetail);
|
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO,
|
| | | (int) validCount, (int) weiQuanCount, (int) invalidCount, sharemoney, new Date());
|
| | | // 添加资金
|
| | | userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail);
|
| | |
|
| | | // 添加到红包返利记录集合
|
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(hbIdList, userMoneyDetail.getId());
|
| | | } catch (UserMoneyDetailException e) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | // 发送推送
|
| | | try {
|
| | | // 提成到账消息通知
|
| | | userNotificationService.tiChengShareRecieved(uid, shareOrders.size(), shareGoodsCount, null,
|
| | | sharemoney);
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.shareOrderReceived(uid, shareOrders.size(), shareGoodsCount, sharemoney,
|
| | | userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | | userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(),
|
| | | shareGoodsCount, sharemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanShare(orderId);
|
| | |
| | |
|
| | | }
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void processShopingFanliOrderNew(String orderId, List<TaoBaoOrder> orderList)
|
| | | throws HongBaoException, OrderItemException {
|
| | |
|
| | | LogHelper.test(String.format("订单处理:订单号-%s 订单数量-%s", orderId, orderList.size() + ""));
|
| | | if (orderList.size() == 1)
|
| | | LogHelper.test("订单排序值:" + orderList.get(0).getOrderBy());
|
| | |
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
|
| | |
|
| | | if (orderList != null && orderList.size() > 0) {
|
| | | String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(),
|
| | | orderList.get(0).getSourceMediaId(), orderList.get(0).getAdPositionId());
|
| | |
|
| | | Order oldOrder = orderMapper.selectOrderByOrderId(orderId);
|
| | | Order oldOrder = orderMapper.selectOrderByOrderIdAndOrderType(orderId, Constant.SOURCE_TYPE_TAOBAO);
|
| | | // 原来不存在订单
|
| | | Long uid = null;
|
| | | if (oldOrder == null) {
|
| | | PidUser pidUser = pidUserMapper.selectByPid(pid);
|
| | | PidUser pidUser = null;// pidUserMapper.selectByPid(pid);
|
| | | if (pidUser != null) {
|
| | | uid = pidUser.getUid();
|
| | |
|
| | |
| | | orderMapper.insertSelective(order);
|
| | | oldOrder = order;
|
| | | } else {
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService
|
| | | .getBySpecialId(orderList.get(0).getSpecialId());
|
| | | if (info != null && info.getUser() != null) {
|
| | | uid = info.getUser().getId();
|
| | | Long targetUid = null;
|
| | | if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)
|
| | | && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {
|
| | | targetUid = taoBaoBuyRelationMapService.selectUidByRelationId(orderList.get(0).getRelationId());
|
| | |
|
| | | } else if (!StringUtil.isNullOrEmpty(orderList.get(0).getSpecialId())) {
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService
|
| | | .getBySpecialId(orderList.get(0).getSpecialId());
|
| | | if (info != null && info.getUser() != null)
|
| | | targetUid = info.getUser().getId();
|
| | | }
|
| | |
|
| | | if (targetUid != null) {
|
| | | uid = targetUid;
|
| | | // 插入到Order中
|
| | | // 添加到订单中去
|
| | | Order order = new Order();
|
| | |
| | | try {
|
| | | commonOrderList = commonOrderService.addTaoBaoOrder(orderList, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
|
| | |
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addTaoBaoOrder或addHongBao出错", "订单号:" + orderId);
|
| | |
| | | orderList.get(0).getSourceMediaId(), orderList.get(0).getAdPositionId());
|
| | | // 原来不存在订单
|
| | | Long uid = null;
|
| | | PidUser pidUser = pidUserMapper.selectByPid(pid);
|
| | | PidUser pidUser = null; // pidUserMapper.selectByPid(pid);-PID机制移除
|
| | | if (pidUser != null)
|
| | | uid = pidUser.getUid();
|
| | | else {
|
| | |
| | | }
|
| | |
|
| | | // 尚未找到和PID对应的用户
|
| | | if (uid == null) {
|
| | | // 通过红包查询
|
| | | CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | orderList.get(0).getTradeId());
|
| | |
|
| | | if (commonOrder != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null
|
| | | && hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | uid = hongBaoOrder.getHongBaoV2().getUserInfo().getId();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | if (uid == null)
|
| | | return;
|
| | |
|
| | |
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void processJDOrder(JDOrder order) {
|
| | | if (order == null || order.getOrderItemList() == null || order.getOrderItemList().size() == 0)
|
| | | return;
|
| | |
|
| | | // 拆单的不做处理
|
| | | if (order.getValidCode() == 2)
|
| | | return;
|
| | |
|
| | | String uidStr = order.getExt1();
|
| | | Long uid = null;
|
| | | if (!StringUtil.isNullOrEmpty(uidStr) && NumberUtil.isNumeric(uidStr))
|
| | | uid = Long.parseLong(uidStr);
|
| | | Long positionId = order.getOrderItemList().get(0).getPositionId();
|
| | | if (positionId == JDApiUtil.POSITION_FANLI)// 返利订单
|
| | | {
|
| | | processFanLiJDOrder(order, uid);
|
| | | lostOrderService.processSuceess(order.getOrderId() + "", Constant.SOURCE_TYPE_JD);
|
| | | } else if (positionId == JDApiUtil.POSITION_SHARE) {// 分享订单
|
| | | if (uid == null)// 分享订单不允许找回
|
| | | return;
|
| | | processShareJDOrder(order, uid);
|
| | | } else {// 处理是否有订单找回的状态
|
| | | processFanLiJDOrder(order, null);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理京东返利订单
|
| | | * |
| | | * @param jdOrder
|
| | | * @param uid
|
| | | */
|
| | | @Transactional
|
| | | private void processFanLiJDOrder(JDOrder jdOrder, Long uid) {
|
| | | int invalidCount = 0;
|
| | | BigDecimal totalMoney = new BigDecimal(0);
|
| | | // 订单状态判断
|
| | | for (JDOrderItem item : jdOrder.getOrderItemList()) {
|
| | | if (item.getEstimateCosPrice() != null)
|
| | | totalMoney = totalMoney.add(item.getEstimateCosPrice());
|
| | |
|
| | | if (item.getValidCode() == 16 || item.getValidCode() == 17 || item.getValidCode() == 18) {// 已付款
|
| | |
|
| | | } else if (item.getValidCode() == 15) {// 未支付
|
| | |
|
| | | } else {
|
| | | invalidCount++;
|
| | | }
|
| | | }
|
| | |
|
| | | // 加入订单
|
| | | Order oldOrder = orderMapper.selectOrderByOrderIdAndOrderType(jdOrder.getOrderId() + "",
|
| | | Constant.SOURCE_TYPE_JD);
|
| | | if (uid == null && oldOrder != null && oldOrder.getBeizhu() != null && oldOrder.getBeizhu().contains("补单"))
|
| | | uid = oldOrder.getUserInfo().getId();
|
| | |
|
| | | if (uid == null)
|
| | | return;
|
| | |
|
| | | if (oldOrder == null)// 新增
|
| | | {
|
| | | Order order = new Order();
|
| | | order.setBeizhu("京东返利订单");
|
| | | order.setCreatetime(System.currentTimeMillis());
|
| | | order.setOrderId(jdOrder.getOrderId() + "");
|
| | | order.setOrderType(Constant.SOURCE_TYPE_JD);
|
| | | order.setState(
|
| | | invalidCount == jdOrder.getOrderItemList().size() ? Order.STATE_SHIXIAO : Order.STATE_YIZHIFU);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | order.setVersion(2);
|
| | | order.setThirdCreateTime(new Date(jdOrder.getOrderTime()));
|
| | | order.setMoney(totalMoney);
|
| | | // 加入到订单表
|
| | | orderMapper.insertSelective(order);
|
| | | } else {
|
| | | Order updateOrder = new Order();
|
| | | updateOrder.setId(oldOrder.getId());
|
| | | updateOrder.setMoney(totalMoney);
|
| | | orderMapper.updateByPrimaryKeySelective(updateOrder);
|
| | | }
|
| | |
|
| | | try {
|
| | | List<CommonOrder> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理京东分享订单
|
| | | * |
| | | * @param order
|
| | | * @param uid
|
| | | */
|
| | | @Transactional
|
| | | private void processShareJDOrder(JDOrder order, Long uid) {
|
| | | try {
|
| | | List<CommonOrder> commonOrderList = commonOrderService.addJDOrder(order, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_SHARE_GOODS);
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理拼多多订单
|
| | | */
|
| | | @Override
|
| | | public void processPDDOrder(PDDOrder pddOrder) {
|
| | | if (pddOrder == null)
|
| | | return;
|
| | | String uidStr = pddOrder.getCustomParameters();
|
| | | Long uid = null;
|
| | | if (!StringUtil.isNullOrEmpty(uidStr))
|
| | | uid = Long.parseLong(uidStr);
|
| | | String positionId = pddOrder.getpId();
|
| | | if (PinDuoDuoApiUtil.PID_FANLI.equalsIgnoreCase(positionId))// 返利订单
|
| | | {
|
| | | processFanLiPDDOrder(pddOrder, uid);
|
| | | lostOrderService.processSuceess(pddOrder.getOrderSn(), Constant.SOURCE_TYPE_PDD);
|
| | | } else if (PinDuoDuoApiUtil.PID_SHARE.equalsIgnoreCase(positionId)) {// 分享订单
|
| | | if (uid == null)// 分享订单不允许找回
|
| | | return;
|
| | | processSharePDDOrder(pddOrder, uid);
|
| | | } else {// 处理是否有订单找回的状态
|
| | | processFanLiPDDOrder(pddOrder, null);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理拼多多自购返利订单
|
| | | * |
| | | * @param pddOrder
|
| | | * @param uid
|
| | | */
|
| | | @Transactional
|
| | | private void processFanLiPDDOrder(PDDOrder pddOrder, Long uid) {
|
| | | int orderState = 0;
|
| | | if (pddOrder.getOrderStatus() == -1 || pddOrder.getOrderStatus() == 8)
|
| | | orderState = Order.STATE_SHIXIAO;
|
| | | else
|
| | | orderState = Order.STATE_YIZHIFU;
|
| | |
|
| | | BigDecimal totalMoney = MoneyBigDecimalUtil.div(new BigDecimal(pddOrder.getOrderAmount()), new BigDecimal(100));
|
| | |
|
| | | // 加入订单
|
| | | Order oldOrder = orderMapper.selectOrderByOrderIdAndOrderType(pddOrder.getOrderSn(), Constant.SOURCE_TYPE_PDD);
|
| | | if (uid == null && oldOrder != null && oldOrder.getBeizhu() != null && oldOrder.getBeizhu().contains("补单"))
|
| | | uid = oldOrder.getUserInfo().getId();
|
| | |
|
| | | if (uid == null)
|
| | | return;
|
| | |
|
| | | if (oldOrder == null)// 新增
|
| | | {
|
| | | Order order = new Order();
|
| | | order.setBeizhu("拼多多返利订单");
|
| | | order.setCreatetime(System.currentTimeMillis());
|
| | | order.setOrderId(pddOrder.getOrderSn());
|
| | | order.setOrderType(Constant.SOURCE_TYPE_PDD);
|
| | | order.setState(orderState);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | order.setVersion(2);
|
| | | order.setThirdCreateTime(new Date(pddOrder.getOrderCreateTime() * 1000));
|
| | | order.setMoney(totalMoney);
|
| | | // 加入到订单表
|
| | | orderMapper.insertSelective(order);
|
| | | } else {
|
| | | Order updateOrder = new Order();
|
| | | updateOrder.setId(oldOrder.getId());
|
| | | updateOrder.setMoney(totalMoney);
|
| | | orderMapper.updateByPrimaryKeySelective(updateOrder);
|
| | | }
|
| | |
|
| | | try {
|
| | | List<PDDOrder> pddOrderList = new ArrayList<>();
|
| | | pddOrderList.add(pddOrder);
|
| | | List<CommonOrder> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addPDDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderSn());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addPDDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderSn());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 处理拼多多分享订单
|
| | | * |
| | | * @param order
|
| | | * @param uid
|
| | | */
|
| | | @Transactional
|
| | | private void processSharePDDOrder(PDDOrder order, Long uid) {
|
| | | try {
|
| | | List<PDDOrder> pddOrderList = new ArrayList<>();
|
| | | pddOrderList.add(order);
|
| | | List<CommonOrder> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_SHARE_GOODS);
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void repairCommonOrderByByTaoBaoOrder(String orderId) {
|
| | | // 根据订单号查询淘宝订单
|
| | | List<TaoBaoOrder> orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId);
|
| | | if (orderList != null)
|
| | | for (TaoBaoOrder order : orderList) {
|
| | | // 根据交易ID查询常规订单
|
| | | CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | order.getTradeId());
|
| | | // 修复orderby
|
| | | if (commonOrder != null) {
|
| | | CommonOrder update = new CommonOrder(commonOrder.getId());
|
| | | update.setOrderBy(order.getOrderBy());
|
| | | update.setUpdateTime(new Date());
|
| | | commonOrderService.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|