| | |
| | | import org.yeshi.utils.NumberUtil;
|
| | |
|
| | | import com.aliyun.openservices.ons.api.Message;
|
| | | import com.aliyun.openservices.ons.api.SendResult;
|
| | | import com.aliyun.openservices.ons.api.Producer;
|
| | | import com.aliyun.openservices.ons.api.transaction.LocalTransactionExecuter;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionProducer;
|
| | | import com.aliyun.openservices.ons.api.transaction.TransactionStatus;
|
| | |
| | | import com.yeshi.fanli.dao.mybatis.order.HongBaoOrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.order.OrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.dto.mq.order.OrderTopicTagEnum;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMQMsg;
|
| | | import com.yeshi.fanli.dto.mq.order.body.OrderMoneyRecievedMQMsg;
|
| | | import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO;
|
| | | import com.yeshi.fanli.dto.order.OrderMQMsgDTO;
|
| | | import com.yeshi.fanli.dto.order.OrderMoneyRecievedMQMsgDTO;
|
| | | 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.taobao.TaoBaoUnionConfig;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanDrawBack;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.exception.elme.ElmeOrderException;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.money.UserMoneyDetailException;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.exception.order.HongBaoException;
|
| | | import com.yeshi.fanli.exception.order.OrderItemException;
|
| | | import com.yeshi.fanli.exception.order.TaoBaoWeiQuanException;
|
| | | import com.yeshi.fanli.exception.user.UserAccountException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.log.OrderLogHelper;
|
| | | import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
|
| | | import com.yeshi.fanli.service.inter.elme.ElmeOrderProcessService;
|
| | | import com.yeshi.fanli.service.inter.elme.ElmeOrderService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | |
| | | import com.yeshi.fanli.service.inter.order.LostOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneySettleService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderTeamRewardService;
|
| | | import com.yeshi.fanli.service.inter.order.jd.JDOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.pdd.PDDOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
|
| | |
| | | import com.yeshi.fanli.service.inter.taobao.TaoBaoUnionConfigService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.service.manger.order.HongBaoV2AddManager;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
| | | 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.rocketmq.MQTagConstant;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | @Service
|
| | |
| | | @Resource(name = "orderTransactionProducer")
|
| | | private TransactionProducer orderTransactionProducer;
|
| | |
|
| | | @Resource(name = "producer")
|
| | | private Producer producer;
|
| | |
|
| | | @Resource
|
| | | private OrderMoneySettleService orderMoneySettleService;
|
| | |
|
| | | @Resource
|
| | | private HongBaoV2AddManager hongBaoV2AddManager;
|
| | |
|
| | | @Resource
|
| | | private OrderTeamRewardService orderTeamRewardService;
|
| | |
|
| | | /**
|
| | | * 是否是分享订单
|
| | |
| | | Iterator<String> its = orders.keySet().iterator();
|
| | | Map<String, List<TaoBaoOrder>> fanliOrderMap = new HashMap<>();
|
| | | Map<String, List<TaoBaoOrder>> shareOrderMap = new HashMap<>();
|
| | | Map<String, List<TaoBaoOrder>> elmeOrderMap = new HashMap<>();
|
| | | while (its.hasNext()) {
|
| | | String orderId = its.next();
|
| | |
|
| | |
| | | List<TaoBaoOrder> list = orders.get(orderId);
|
| | | 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 {
|
| | | // 通过红包查询
|
| | | 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;
|
| | | }
|
| | | if ("饿了么".equalsIgnoreCase(list.get(0).getOrderType())) {
|
| | | // 饿了么订单开始归入到淘宝订单
|
| | | if (TimeUtil.convertToTimeTemp(list.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss") > TimeUtil
|
| | | .convertToTimeTemp("2020-04-15", "yyyy-MM-dd")) {
|
| | | fanliOrderMap.put(orderId, list);
|
| | | } else {
|
| | | elmeOrderMap.put(orderId, list);
|
| | | }
|
| | | fanliOrderMap.put(orderId, list);
|
| | | } else {
|
| | | 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 {
|
| | | // 通过红包查询
|
| | | 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);
|
| | | // 处理饿了么订单
|
| | | processElemeOrder(elmeOrderMap);
|
| | | }
|
| | |
|
| | | private ElmeOrder createElmeOrder(TaoBaoOrder taoBaoOrder) {
|
| | | ElmeOrder elmeOrder = new ElmeOrder();
|
| | | elmeOrder.setChannelId("");
|
| | | elmeOrder.setCreateTime(new Date());
|
| | | elmeOrder
|
| | | .setOrderDate(new Date(TimeUtil.convertToTimeTemp(taoBaoOrder.getCreateTime(), "yyyy-MM-dd HH:mm:ss")));
|
| | | elmeOrder.setOrderId(taoBaoOrder.getOrderId());
|
| | | elmeOrder.setPayMoney(taoBaoOrder.getPayment());
|
| | | elmeOrder.setRid(taoBaoOrder.getRelationId());
|
| | | if (taoBaoOrder.getOrderState().equalsIgnoreCase("订单结算"))
|
| | | elmeOrder.setIsSettle(true);
|
| | | else
|
| | | elmeOrder.setIsSettle(false);
|
| | |
|
| | | if (!taoBaoOrder.getOrderState().equalsIgnoreCase("订单失效"))
|
| | | elmeOrder.setState(1);
|
| | | else {
|
| | | elmeOrder.setState(0);
|
| | | elmeOrder.setPayMoney(new BigDecimal(0));
|
| | | }
|
| | | elmeOrder.setTrackPid(
|
| | | String.format("mm_124933865_%s_%s", taoBaoOrder.getSourceMediaId(), taoBaoOrder.getAdPositionId()));
|
| | | if (!StringUtil.isNullOrEmpty(taoBaoOrder.getRelationId())) {
|
| | | UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService.getByRelationId(taoBaoOrder.getRelationId());
|
| | | if (extraInfo != null)
|
| | | elmeOrder.setUid(extraInfo.getUser().getId());
|
| | | }
|
| | | return elmeOrder;
|
| | | }
|
| | |
|
| | | private void processElemeOrder(Map<String, List<TaoBaoOrder>> orders) {
|
| | | for (Iterator<String> its = orders.keySet().iterator(); its.hasNext();) {
|
| | | String orderId = its.next();
|
| | | List<TaoBaoOrder> orderList = orders.get(orderId);
|
| | | for (TaoBaoOrder taoBaoOrder : orderList) {
|
| | | ElmeOrder elmeOrder = createElmeOrder(taoBaoOrder);
|
| | | try {
|
| | | elmeOrderProcessService.processOrder(elmeOrder);
|
| | | } catch (ElmeOrderException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | private HongBaoOrderMapper hongBaoOrderMapper;
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void fanli(HongBaoV2 hb1) throws TaoBaoWeiQuanException {
|
| | | // 查询最新的红包数据
|
| | | hb1 = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hb1.getId());
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | // 查询该订单之前是否有到账
|
| | | List<HongBaoOrder> list = hongBaoOrderMapper.listByOrderIdAndSourceType(
|
| | | hongBaoOrder.getCommonOrder().getOrderNo(), hongBaoOrder.getCommonOrder().getSourceType());
|
| | | List<Long> hongBaoIdList = new ArrayList<>();
|
| | | if (list != null) {
|
| | | for (HongBaoOrder ho : list) {
|
| | | hongBaoIdList.add(ho.getHongBaoV2().getId());
|
| | | }
|
| | | }
|
| | |
|
| | | List<HongBaoV2> allHongBaoList = hongBaoV2Mapper.listByIds(hongBaoIdList);
|
| | | boolean first = true;
|
| | | for (HongBaoV2 v2 : allHongBaoList)
|
| | | if (v2.getState() == HongBaoV2.STATE_YILINGQU) {
|
| | | first = false;
|
| | | break;
|
| | | }
|
| | |
|
| | | // 自购到账事务消息
|
| | | OrderMoneyRecievedMQMsgDTO mqMsg = new OrderMoneyRecievedMQMsgDTO(OrderMoneyRecievedMQMsgDTO.TYPE_ZIGOU,
|
| | | OrderMoneyRecievedMQMsg mqMsg = new OrderMoneyRecievedMQMsg(OrderMoneyRecievedMQMsg.TYPE_ZIGOU,
|
| | | mainUser.getId(), hongBaoOrder.getCommonOrder().getSourceType(),
|
| | | hongBaoOrder.getCommonOrder().getOrderNo(), null, new Date());
|
| | | Message msg = new Message(MQTopicName.TOPIC_FANLI.name(), "actual", new Gson().toJson(mqMsg).getBytes());
|
| | | hongBaoOrder.getCommonOrder().getOrderNo(), null, new Date(), 0);
|
| | | mqMsg.setOrderFirst(first);
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderFanLiActual, mqMsg);
|
| | | String key = mainUser.getId() + "-" + UUID.randomUUID().toString();
|
| | | msg.setKey(key);
|
| | | try {
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | orderMoneySettleService.ziGouSettle(hongBaoOrder.getCommonOrder().getOrderNo(),
|
| | | hongBaoOrder.getCommonOrder().getSourceType(), key);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | } catch (Exception e) {
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | if (!Constant.IS_TEST)
|
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | try {
|
| | | orderMoneySettleService.ziGouSettle(hongBaoOrder.getCommonOrder().getOrderNo(),
|
| | | hongBaoOrder.getCommonOrder().getSourceType(), key);
|
| | | return TransactionStatus.CommitTransaction;
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | return TransactionStatus.RollbackTransaction;
|
| | | }
|
| | | }
|
| | | }, null);
|
| | | else {
|
| | | try {
|
| | | orderMoneySettleService.ziGouSettle(hongBaoOrder.getCommonOrder().getOrderNo(),
|
| | | hongBaoOrder.getCommonOrder().getSourceType(), key);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }, null);
|
| | | }
|
| | | } catch (Exception e) {
|
| | | LogHelper.mqError(e.getMessage(), msg.getTopic(), msg.getTag(), new Gson().toJson(mqMsg));
|
| | | }
|
| | |
| | | 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;
|
| | | // }
|
| | |
|
| | | // 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());
|
| | |
| | | TaoBaoWeiQuanDrawBack drawBack = taoBaoWeiQuanDrawBackService
|
| | | .selectByOrderItemId(order.getOrderItemId());
|
| | | if (drawBack == null) {// 还未扣款
|
| | | OrderLogHelper.taoBaoWeiQuan("已到账未扣款处理:子订单号:" + order.getOrderItemId());
|
| | | try {
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanFanli(order.getOrderId());
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanFanli(order.getOrderId(), true);
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanShare(order.getOrderId());
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanInvite(order.getOrderId());
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, null, "订单号:" + order.getOrderId());
|
| | | LogHelper.errorDetailInfo(e, "到账后处理维权扣款出错", "订单号:" + order.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | } else {
|
| | | // 查询子红包是否已到账
|
| | | List<HongBaoV2> children = hongBaoV2Service
|
| | | .listChildrenById(hongBaoOrder.getHongBaoV2().getId());
|
| | | for (HongBaoV2 hongBaoV2 : children) {
|
| | | if (hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU) {
|
| | | try {
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanInvite(order.getOrderId());
|
| | | } catch (TaoBaoWeiQuanException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "到账后处理维权扣款出错", "订单号:" + order.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | List<Long> inviteAndShareUids = hongBaoV2Mapper.listUidCanBanlanceShareAndInvite(1000);
|
| | | Set<Long> uidSets = new HashSet<>();
|
| | | if (inviteAndShareUids != null)
|
| | | for (Long uid : inviteAndShareUids)
|
| | | uidSets.add(uid);
|
| | | for (Long uid : inviteAndShareUids) {
|
| | | if (userInfoMapper.selectAvailableByPrimaryKey(uid) != null)
|
| | | uidSets.add(uid);
|
| | | }
|
| | | // 根据用户ID
|
| | | Iterator<Long> its = uidSets.iterator();
|
| | | while (its.hasNext()) {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void fanliInvaiteAndShare(Long uid) throws TaoBaoWeiQuanException {
|
| | | // 邀请赚到账
|
| | | try {
|
| | |
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | if(1>0)
|
| | | return;
|
| | |
|
| | | try {
|
| | | orderMoneySettleService.inviteSettleJD(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | //
|
| | | try {
|
| | | orderMoneySettleService.inviteSettlePDD(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | |
| | | } catch (OrderMoneySettleException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | //
|
| | | try {
|
| | | orderMoneySettleService.shareSettlePDD(uid);
|
| | | } catch (OrderMoneySettleException e) {
|
| | |
| | | if (oldOrder == null) {
|
| | | Long targetUid = null;
|
| | | if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)
|
| | | && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {
|
| | | && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {// 处理非返利商品库的商品
|
| | | targetUid = taoBaoBuyRelationMapService.selectUidByRelationId(orderList.get(0).getRelationId());
|
| | |
|
| | | } else if (pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_ELEME_PID)
|
| | | && !StringUtil.isNullOrEmpty(orderList.get(0).getRelationId())) {// 处理饿了么的订单
|
| | | UserExtraTaoBaoInfo extraInfo = userExtraTaoBaoInfoService
|
| | | .getByRelationId(orderList.get(0).getRelationId());
|
| | | if (extraInfo != null) {
|
| | | targetUid = extraInfo.getUser().getId();
|
| | | }
|
| | | } else if (!StringUtil.isNullOrEmpty(orderList.get(0).getSpecialId())) {
|
| | | UserExtraTaoBaoInfo info = userExtraTaoBaoInfoService
|
| | | .getBySpecialId(orderList.get(0).getSpecialId());
|
| | |
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | if (!Constant.IS_TEST)
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | |
| | | public void processJDOrder(JDOrder order) {
|
| | | if (order == null || order.getOrderItemList() == null || order.getOrderItemList().size() == 0)
|
| | | return;
|
| | |
|
| | | // 拆单的不做处理
|
| | | if (order.getValidCode() == 2)
|
| | | return;
|
| | |
|
| | | // 根据ext1与subUnionId跟单
|
| | | String uidStr = order.getExt1();
|
| | | if (StringUtil.isNullOrEmpty(uidStr))
|
| | | uidStr = order.getOrderItemList().get(0).getSubUnionId();
|
| | |
|
| | | Long uid = null;
|
| | | if (!StringUtil.isNullOrEmpty(uidStr) && NumberUtil.isNumeric(uidStr))
|
| | | uid = Long.parseLong(uidStr);
|
| | |
| | | @Resource
|
| | | private ElmeOrderService elmeOrderService;
|
| | |
|
| | | @Resource
|
| | | private ElmeOrderProcessService elmeOrderProcessService;
|
| | |
|
| | | /**
|
| | | * 获取饿了么可以返利的红包
|
| | | *
|
| | |
| | | * @param sourceType
|
| | | * @param hongBaoType
|
| | | */
|
| | | @Transactional
|
| | | private void addHongBaoWithMQ(List<CommonOrderAddResultDTO> commonOrderList, String orderId, Long uid,
|
| | | int sourceType, int hongBaoType) {
|
| | | final List<CommonOrder> coList = convertCommonOrder(commonOrderList);
|
| | | OrderMQMsgDTO mqMsg = new OrderMQMsgDTO(orderId, sourceType, uid);
|
| | | Message msg = new Message(MQTopicName.TOPIC_ORDER.name(),
|
| | | String.format(MQTagConstant.TAG_ORDER_STATISTIC_PREFIX + "%s-%s", sourceType, hongBaoType),
|
| | | new Gson().toJson(mqMsg).getBytes());
|
| | | SendResult result= orderTransactionProducer.send(msg, new LocalTransactionExecuter() {
|
| | | @Override
|
| | | public TransactionStatus execute(Message arg0, Object arg1) {
|
| | | int resultCode = 0;
|
| | | try {
|
| | | resultCode = hongBaoV2Service.addHongBao(coList, hongBaoType);
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + orderId);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | return TransactionStatus.CommitTransaction;
|
| | | // if (resultCode != 0)
|
| | | // return TransactionStatus.CommitTransaction;
|
| | | // else
|
| | | // return TransactionStatus.RollbackTransaction;
|
| | | int resultCode = 0;
|
| | | try {
|
| | | long time = TimeUtil.convertToTimeTemp("2019-12-06", "yyyy-MM-dd");
|
| | | if (!Constant.IS_TEST)
|
| | | time = TimeUtil.convertToTimeTemp("2019-12-20", "yyyy-MM-dd");
|
| | |
|
| | | if (coList.get(0).getThirdCreateTime().getTime() < time)
|
| | | resultCode = hongBaoV2Service.addHongBao(coList, hongBaoType);
|
| | | else
|
| | | resultCode = hongBaoV2AddManager.addHongBao(coList, hongBaoType);
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + orderId);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }, null);
|
| | | System.out.println(result);
|
| | | } catch (UserAccountException e) {
|
| | |
|
| | | }
|
| | | if (!Constant.IS_TEST)
|
| | | if (resultCode == 1) {// 只发送新增消息
|
| | | OrderMQMsg mqMsg = new OrderMQMsg(orderId, sourceType, uid, OrderMQMsg.HANDLE_TYPE_ADD,
|
| | | isCommonOrderValid(coList), 0, new Date());
|
| | | Message msg = MQMsgBodyFactory.create(MQTopicName.TOPIC_ORDER, OrderTopicTagEnum.orderStatistic, mqMsg);
|
| | | producer.send(msg);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 订单是否有效
|
| | | * |
| | | * @param coList
|
| | | * @return
|
| | | */
|
| | | private boolean isCommonOrderValid(List<CommonOrder> coList) {
|
| | | for (CommonOrder commonOrder : coList) {
|
| | | if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK
|
| | | || commonOrder.getState() == CommonOrder.STATE_WQ) {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void fanliOrderTeamReward() {
|
| | | Date time = new Date();
|
| | | long count = orderTeamRewardService.countCanSettleUid(time);
|
| | | int pageSize = 500;
|
| | | int page = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | List<Long> uidList = new ArrayList<>();
|
| | | for (int i = 0; i < page; i++) {
|
| | | List<Long> list = orderTeamRewardService.listCanSettleUid(time, i + 1, pageSize);
|
| | | if (list != null && list.size() > 0)
|
| | | uidList.addAll(list);
|
| | | }
|
| | | // 添加到队列
|
| | | if (uidList != null)
|
| | | for (Long uid : uidList)
|
| | | if (!Constant.IS_TEST)
|
| | | CMQManager.getInstance().addFanLiOrderTeamRewardMsg(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public void fanliOrderTeamReward(Long uid) throws OrderMoneySettleException {
|
| | | orderMoneySettleService.orderTeamRewardSettle(uid);
|
| | | }
|
| | |
|
| | | }
|