| | |
| | | import com.yeshi.fanli.dao.mybatis.order.OrderMapper;
|
| | | import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
|
| | | import com.yeshi.fanli.dto.HongBao;
|
| | | import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO;
|
| | | 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.elme.ElmeHongBaoOrderMap;
|
| | | import com.yeshi.fanli.entity.elme.ElmeOrder;
|
| | | 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.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.TaoBaoWeiQuanException;
|
| | | 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.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
|
| | | import com.yeshi.fanli.service.inter.elme.ElmeOrderService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.AccountDetailsHongBaoMapService;
|
| | | 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.money.tb.TaoBaoWeiQuanDrawBackService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
|
| | | import com.yeshi.fanli.service.inter.order.LostOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | 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.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.UserMoneyService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.CMQManager;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | |
| | | import com.yeshi.fanli.util.TaoBaoConstant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.cmq.HongBaoRecieveCMQManager;
|
| | | import com.yeshi.fanli.util.cmq.PlaceOrderCMQManager;
|
| | | import com.yeshi.fanli.util.factory.UserMoneyDetailFactory;
|
| | | import com.yeshi.fanli.util.jd.JDApiUtil;
|
| | | import com.yeshi.fanli.util.pinduoduo.PinDuoDuoApiUtil;
|
| | |
| | |
|
| | | @Resource
|
| | | private HongBaoV2Service hongBaoV2Service;
|
| | |
|
| | | @Resource
|
| | | private JDOrderService jdOrderService;
|
| | |
|
| | | @Resource
|
| | | private PDDOrderService pddOrderService;
|
| | |
|
| | | /**
|
| | | * 是否是分享订单
|
| | | * |
| | | * @param order
|
| | | * @return
|
| | | */
|
| | | private boolean isShareOrder(TaoBaoOrder order) {
|
| | | List<TaoBaoUnionConfig> configList = taoBaoUnionConfigService.getConfigByTypeCache(PidUser.TYPE_FANLI_ANDROID);
|
| | | String pid = String.format("mm_%s_%s_%s", configList.get(0).getAccountId(), order.getSourceMediaId(),
|
| | | order.getAdPositionId());
|
| | | if (!StringUtil.isNullOrEmpty(order.getSpecialId())
|
| | | || pid.equalsIgnoreCase(TaoBaoConstant.TAOBAO_RELATION_AS_SPECIAL_PID)) {// 设置渠道ID当做会员运营ID的位置ID
|
| | | return false;
|
| | | } else if (!StringUtil.isNullOrEmpty(order.getRelationId())) {
|
| | | return true;
|
| | | } else {
|
| | | // 通过红包查询
|
| | | CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
|
| | | order.getTradeId());
|
| | |
|
| | | if (commonOrder != null) {
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null
|
| | | && hongBaoOrder.getHongBaoV2().getType() == HongBaoV2.TYPE_SHARE_GOODS) {
|
| | | return true;
|
| | | }
|
| | | }
|
| | | return false;
|
| | | }
|
| | | }
|
| | |
|
| | | @Override
|
| | | public synchronized void processOrder(Map<String, List<TaoBaoOrder>> orders) {
|
| | |
| | | // 查询最新的红包数据
|
| | | hb1 = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hb1.getId());
|
| | | // 正常用户才能到账
|
| | | UserInfo mainUser = userInfoMapper.selectByPrimaryKey(hb1.getUserInfo().getId());
|
| | | UserInfo mainUser = userInfoMapper.selectAvailableByPrimaryKey(hb1.getUserInfo().getId());
|
| | | if (mainUser == null || mainUser.getState() != UserInfo.STATE_NORMAL) {
|
| | | return;
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | // 站内信+推送
|
| | | UserInfo user = userInfoMapper.selectByPKey(uid);
|
| | | UserInfo user = userInfoMapper.selectByPrimaryKey(uid);
|
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.fanliOrderReceived(uid, hongBaoOrder.getCommonOrder().getOrderNo(),
|
| | |
| | |
|
| | | 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,
|
| | | TaoKeOrderApiUtil.TK_STATUS_ALL);
|
| | | List<TaoBaoOrder> thirdOList = TaoKeOrderApiUtil.getTaoBaoThirdAllOrder(
|
| | | TimeUtil.getGernalTime(time, "yyyy-MM-dd HH:mm:ss"), 30, 1,
|
| | | TaoKeOrderApiUtil.TK_STATUS_ALL, TaoBaoConstant.TAOBAO_AUTH_APPKEY,
|
| | | TaoBaoConstant.TAOBAO_AUTH_APPSECRET);
|
| | | if (thirdOList != null && thirdOList.size() > 0)
|
| | | olist.addAll(thirdOList);
|
| | |
|
| | | olist = TaoKeOrderApiUtil.getTaoBaoCommonOrderList(time, time + 1000 * 2L, 1);
|
| | | if (olist != null && olist.size() > 0) {
|
| | | for (int i = 0; i < olist.size(); i++) {
|
| | | if (!olist.get(i).getOrderId()
|
| | |
| | | if (hongBaoOrder != null && hongBaoOrder.getCommonOrder() != null) {
|
| | | CommonOrder co = hongBaoOrder.getCommonOrder();
|
| | | // 上级用户不是正常用户,订单均不能到账
|
| | | UserInfo userInfo = userInfoMapper.selectByPrimaryKey(co.getUserInfo().getId());
|
| | | UserInfo userInfo = userInfoMapper.selectAvailableByPrimaryKey(co.getUserInfo().getId());
|
| | | if (userInfo == null || userInfo.getState() != UserInfo.STATE_NORMAL) {
|
| | | hongBaoList.remove(i);
|
| | | i--;
|
| | |
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.inviteOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, inviteOrders.size(),
|
| | | inviteGoodsCount, invitemoney, userInfoMapper.selectByPKey(uid).getMyHongBao());
|
| | | inviteGoodsCount, invitemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanInvite(orderId);
|
| | |
| | |
|
| | | // 新版通知
|
| | | userMoneyMsgNotificationService.shareOrderReceived(uid, Constant.SOURCE_TYPE_TAOBAO, shareOrders.size(),
|
| | | shareGoodsCount, sharemoney, userInfoMapper.selectByPrimaryKey(uid).getMyHongBao());
|
| | | shareGoodsCount, sharemoney, userInfoMapper.selectAvailableByPrimaryKey(uid).getMyHongBao());
|
| | |
|
| | | for (String orderId : drawBackOrders)
|
| | | taoBaoWeiQuanDrawBackService.doWeiQuanShare(orderId);
|
| | |
| | | orderMapper.updateByPrimaryKeySelective(updateOrder);
|
| | |
|
| | | // 用第一个子订单锁定用户
|
| | | List<CommonOrder> commonOrderList = null;
|
| | | List<CommonOrderAddResultDTO> commonOrderList = null;
|
| | | try {
|
| | | commonOrderList = commonOrderService.addTaoBaoOrder(orderList, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
|
| | | hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_ZIGOU);
|
| | |
|
| | | if (isCommonOrderAllAdd(commonOrderList)) {
|
| | | Order order = new Order();
|
| | | order.setOrderId(orderId);
|
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addTaoBaoOrder或addHongBao出错", "订单号:" + orderId);
|
| | |
| | |
|
| | | // 用第一个子订单锁定用户
|
| | | try {
|
| | | List<CommonOrder> commonOrders = commonOrderService.addTaoBaoOrder(orderList, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrders, HongBaoV2.TYPE_SHARE_GOODS);
|
| | | List<CommonOrderAddResultDTO> commonOrders = commonOrderService.addTaoBaoOrder(orderList, uid);
|
| | | hongBaoV2Service.addHongBao(convertCommonOrder(commonOrders), HongBaoV2.TYPE_SHARE_GOODS);
|
| | | if (isCommonOrderAllAdd(commonOrders)) {
|
| | | Order order = new Order();
|
| | | order.setOrderId(orderId);
|
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | | } catch (CommonOrderException e) {
|
| | | e.printStackTrace();
|
| | | } catch (HongBaoException e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 是否为分享订单
|
| | | * |
| | | * @param order
|
| | | * @return
|
| | | */
|
| | | private boolean isShareOrder(JDOrder order) {
|
| | | if (order == null || order.getOrderItemList() == null || order.getOrderItemList().size() == 0)
|
| | | return false;
|
| | | Long positionId = order.getOrderItemList().get(0).getPositionId();
|
| | | if (positionId == JDApiUtil.POSITION_SHARE) {// 分享订单
|
| | | return true;
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | |
|
| | | try {
|
| | | List<CommonOrder> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
|
| | | List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
|
| | | hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_ZIGOU);
|
| | | if (isCommonOrderAllAdd(commonOrderList)) {
|
| | | Order order = new Order();
|
| | | order.setOrderId(jdOrder.getOrderId() + "");
|
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
|
| | |
| | | * @param uid
|
| | | */
|
| | | @Transactional
|
| | | private void processShareJDOrder(JDOrder order, Long uid) {
|
| | | private void processShareJDOrder(JDOrder jdOrder, Long uid) {
|
| | | try {
|
| | | List<CommonOrder> commonOrderList = commonOrderService.addJDOrder(order, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_SHARE_GOODS);
|
| | | List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addJDOrder(jdOrder, uid);
|
| | | hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_SHARE_GOODS);
|
| | | if (isCommonOrderAllAdd(commonOrderList)) {
|
| | | Order order = new Order();
|
| | | order.setOrderId(jdOrder.getOrderId() + "");
|
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + jdOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 是否是分享赚订单
|
| | | * |
| | | * @param order
|
| | | * @return
|
| | | */
|
| | | private boolean isShareOrder(PDDOrder pddOrder) {
|
| | | String positionId = pddOrder.getpId();
|
| | | if (PinDuoDuoApiUtil.PID_SHARE.equalsIgnoreCase(positionId))
|
| | | return true;
|
| | | else
|
| | | return false;
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | try {
|
| | | List<PDDOrder> pddOrderList = new ArrayList<>();
|
| | | pddOrderList.add(pddOrder);
|
| | | List<CommonOrder> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
|
| | | hongBaoV2Service.addHongBao(commonOrderList, HongBaoV2.TYPE_ZIGOU);
|
| | | List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
|
| | | hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_ZIGOU);
|
| | | if (isCommonOrderAllAdd(commonOrderList)) {
|
| | | Order order = new Order();
|
| | | order.setOrderId(pddOrder.getOrderSn());
|
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addPDDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderSn());
|
| | |
| | | * @param uid
|
| | | */
|
| | | @Transactional
|
| | | private void processSharePDDOrder(PDDOrder order, Long uid) {
|
| | | private void processSharePDDOrder(PDDOrder pddOrder, 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);
|
| | | pddOrderList.add(pddOrder);
|
| | | List<CommonOrderAddResultDTO> commonOrderList = commonOrderService.addPDDOrder(pddOrderList, uid);
|
| | | hongBaoV2Service.addHongBao(convertCommonOrder(commonOrderList), HongBaoV2.TYPE_SHARE_GOODS);
|
| | | if (isCommonOrderAllAdd(commonOrderList)) {
|
| | | Order order = new Order();
|
| | | order.setOrderId(pddOrder.getOrderSn());
|
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | | } catch (CommonOrderException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | } catch (HongBaoException e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + order.getOrderId());
|
| | | LogHelper.errorDetailInfo(e, "addJDOrder或addHongBao出错", "订单号:" + pddOrder.getOrderId());
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean isShareOrder(CommonOrder commonOrder) {
|
| | | switch (commonOrder.getSourceType()) {
|
| | | case Constant.SOURCE_TYPE_TAOBAO:
|
| | | return isShareOrder(taoBaoOrderService.selectByTradeId(commonOrder.getTradeId()));
|
| | | case Constant.SOURCE_TYPE_JD:
|
| | | return isShareOrder(jdOrderService.selectDetailByOrderId(Long.parseLong(commonOrder.getOrderNo())));
|
| | | case Constant.SOURCE_TYPE_PDD:
|
| | | return isShareOrder(pddOrderService.selectByOrderSn(commonOrder.getOrderNo()).get(0));
|
| | | }
|
| | | return false;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 转为普通订单
|
| | | * |
| | | * @param dtoList
|
| | | * @return
|
| | | */
|
| | | private List<CommonOrder> convertCommonOrder(List<CommonOrderAddResultDTO> dtoList) {
|
| | | List<CommonOrder> commonOrderList = new ArrayList<>();
|
| | | if (dtoList != null)
|
| | | for (CommonOrderAddResultDTO dto : dtoList)
|
| | | commonOrderList.add(dto.getCommonOrder());
|
| | | return commonOrderList;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 是否全是增加
|
| | | * |
| | | * @param list
|
| | | * @return
|
| | | */
|
| | | private boolean isCommonOrderAllAdd(List<CommonOrderAddResultDTO> list) {
|
| | | if (list == null || list.size() == 0)
|
| | | return false;
|
| | | int addCount = 0;
|
| | | if (list != null)
|
| | | for (CommonOrderAddResultDTO dto : list) {
|
| | | if (dto.getType() == CommonOrderAddResultDTO.TYPE_ADD)
|
| | | addCount++;
|
| | | }
|
| | | if (addCount == list.size())
|
| | | return true;
|
| | | else
|
| | | return false;
|
| | | }
|
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void invalidHongBaoV2AndGiveGodenCorn(Long hongBaoId, Long uid, String orderId, int sourceType,
|
| | | String beiZhu) throws Exception {
|
| | | HongBaoV2 v2 = new HongBaoV2(hongBaoId);
|
| | | v2.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | v2.setBeizhu(beiZhu);
|
| | | v2.setUpdateTime(new Date());
|
| | | hongBaoV2Service.updateByPrimaryKeySelective(v2);
|
| | | List<HongBaoV2> children = hongBaoV2Service.listChildrenById(hongBaoId);
|
| | | if (children != null)
|
| | | for (HongBaoV2 child : children) {
|
| | | HongBaoV2 update = new HongBaoV2(child.getId());
|
| | | update.setState(HongBaoV2.STATE_SHIXIAO);
|
| | | update.setBeizhu(beiZhu);
|
| | | update.setUpdateTime(new Date());
|
| | | hongBaoV2Service.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | userSystemCouponService.systemGiveRewardCoupon(uid, 1, orderId, sourceType, "因商家违约未能结算返利或商家已经关店");
|
| | | }
|
| | |
|
| | | @Transactional
|
| | | @Override
|
| | | public void doTaoBaoSellerNotPaid(TaoBaoOrder order) {
|
| | |
|
| | | // 根据交易ID查询
|
| | | if (!StringUtil.isNullOrEmpty(order.getTradeId())) {
|
| | | List<CommonOrder> commonOrderList = commonOrderService
|
| | | .listBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO, order.getTradeId());
|
| | | if (commonOrderList != null)
|
| | | // 查询主订单
|
| | | for (CommonOrder commonOrder : commonOrderList) {
|
| | | // 查询主红包
|
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
|
| | | if (hongBaoOrder != null && hongBaoOrder.getHongBaoV2() != null) {
|
| | | if (hongBaoOrder.getHongBaoV2().getState() == HongBaoV2.STATE_BUKELINGQU) {
|
| | | // 订单失效,赠送金币
|
| | | try {
|
| | | invalidHongBaoV2AndGiveGodenCorn(hongBaoOrder.getHongBaoV2().getId(), hongBaoOrder.getHongBaoV2().getUserInfo().getId(), commonOrder.getOrderNo(), commonOrder.getSourceType(), "订单成功,商家未打款");
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | public void elmeFanli() {
|
| | |
|
| | | }
|
| | |
|
| | | // 饿了么订单
|
| | | @Resource
|
| | | private ElmeHongBaoOrderMapService elmeHongBaoOrderMapService;
|
| | |
|
| | | @Resource
|
| | | private ElmeOrderService elmeOrderService;
|
| | |
|
| | | /**
|
| | | * 获取饿了么可以返利的红包
|
| | | * |
| | | * @return
|
| | | */
|
| | | @Override
|
| | | public List<HongBaoV2> getCanBalanceElmeFanliHongBao() {
|
| | | List<Integer> list = new ArrayList<>();
|
| | | list.add(HongBaoV2.TYPE_ELME);
|
| | | return hongBaoV2Mapper.listCanBalanceHongBaoByTypeAndUid(list, null, 0, 1000);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void elmeFanli(Long hongBaoId) {
|
| | | // 查询详情
|
| | | HongBaoV2 hongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBaoId);
|
| | | if (hongBao.getType() == HongBaoV2.TYPE_ELME && hongBao.getState() == HongBaoV2.STATE_KELINGQU
|
| | | && hongBao.getPreGetTime() != null && System.currentTimeMillis() > hongBao.getPreGetTime().getTime()) {// 可以到账了
|
| | | // 判断用户状态
|
| | | UserInfo user = userInfoMapper.selectByPrimaryKey(hongBao.getUserInfo().getId());
|
| | | if (user == null || user.getState() != UserInfo.STATE_NORMAL)
|
| | | return;
|
| | | ElmeHongBaoOrderMap map = elmeHongBaoOrderMapService.selectByHongBaoId(hongBaoId);
|
| | | if (map == null)
|
| | | return;
|
| | | ElmeOrder order = elmeOrderService.selectByPrimaryKey(map.getElmeOrder().getId());
|
| | | if (order == null)
|
| | | return;
|
| | |
|
| | | // 到账,加数据
|
| | | HongBaoV2 update = new HongBaoV2(hongBao.getId());
|
| | | update.setUpdateTime(new Date());
|
| | | update.setGetTime(new Date());
|
| | | update.setState(HongBaoV2.STATE_YILINGQU);
|
| | | hongBaoV2Mapper.updateByPrimaryKeySelective(update);
|
| | | // 增加资金
|
| | | UserMoneyDetail detail = null;
|
| | | try {
|
| | | detail = UserMoneyDetailFactory.createElmeFanLi(hongBao.getUserInfo().getId(), order.getOrderId(),
|
| | | hongBao.getId(), hongBao.getMoney());
|
| | | } catch (UserMoneyDetailException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | userMoneyService.addUserMoney(hongBao.getUserInfo().getId(), hongBao.getMoney(), detail);
|
| | | BigDecimal balance = userInfoMapper.selectByPrimaryKey(hongBao.getUserInfo().getId()).getMyHongBao();
|
| | | // 添加消息
|
| | | userMoneyMsgNotificationService.elmeFanli(hongBao.getUserInfo().getId(), order.getOrderId(),
|
| | | hongBao.getMoney(), balance);
|
| | | }
|
| | | // 返利到账
|
| | | }
|
| | |
|
| | | }
|