admin
2020-11-09 2147d023563a7c9d05d97547c00d6b0162c0644c
fanli/src/main/java/com/yeshi/fanli/service/impl/order/tb/TaoBaoWeiQuanOrderServiceImpl.java
@@ -6,6 +6,9 @@
import javax.annotation.Resource;
import com.yeshi.fanli.exception.money.TeamRewardDebtException;
import com.yeshi.fanli.exception.order.TaoBaoOrderException;
import com.yeshi.fanli.service.manger.order.TeamRewardManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -35,10 +38,8 @@
   private TaoBaoWeiQuanOrderMapper taoBaoWeiQuanOrderMapper;
   @Resource
   private UserOrderMsgNotificationService userOrderMsgNotificationService;
    private TeamRewardManager teamRewardManager;
   @Resource
   private MsgOrderDetailService msgOrderDetailService;
   @Resource
   private CommonOrderService commonOrderService;
@@ -79,16 +80,7 @@
         isUpdate = true;
         try {
            if (order.getState().contains("维权成功")) {
               // 更改CommonOrder的状态
               CommonOrder commonOrder = commonOrderService
                     .selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO, order.getOrderItemId());
               if (commonOrder != null) {
                  CommonOrder updateCommonOrder = new CommonOrder(commonOrder.getId());
                  updateCommonOrder.setState(CommonOrder.STATE_WQ);
                  updateCommonOrder.setUpdateTime(new Date());
                  commonOrderService.updateByPrimaryKeySelective(updateCommonOrder);
                  userOrderWeiQuanRecordService.addTaoBaoWeiQuan(taoBaoWeiQuanOrder);
               }
                    weiQuanSuccess(order);
            }
         } catch (Exception e) {
@@ -100,16 +92,7 @@
         id = order.getId();
         isAdd = true;
         if (order.getState().contains("维权成功")) {
            // 更改CommonOrder的状态
            CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
                  order.getOrderItemId());
            if (commonOrder != null) {
               CommonOrder updateCommonOrder = new CommonOrder(commonOrder.getId());
               updateCommonOrder.setState(CommonOrder.STATE_WQ);
               updateCommonOrder.setUpdateTime(new Date());
               commonOrderService.updateByPrimaryKeySelective(updateCommonOrder);
               userOrderWeiQuanRecordService.addTaoBaoWeiQuan(order);
            }
                weiQuanSuccess(order);
         }
      }
@@ -126,6 +109,33 @@
   }
    /**
     * 维权成功
     *
     * @param order
     */
    private void weiQuanSuccess(TaoBaoWeiQuanOrder order) {
        // 更改CommonOrder的状态
        CommonOrder commonOrder = commonOrderService.selectBySourceTypeAndTradeId(Constant.SOURCE_TYPE_TAOBAO,
                order.getOrderItemId());
        if (commonOrder != null) {
            CommonOrder updateCommonOrder = new CommonOrder(commonOrder.getId());
            updateCommonOrder.setState(CommonOrder.STATE_WQ);
            updateCommonOrder.setUpdateTime(new Date());
            commonOrderService.updateByPrimaryKeySelective(updateCommonOrder);
            userOrderWeiQuanRecordService.addTaoBaoWeiQuan(order);
            try {
                teamRewardManager.weiQuan(order.getOrderId(), Constant.SOURCE_TYPE_TAOBAO, order.getOrderItemId());
            } catch (TaoBaoOrderException e) {
                e.printStackTrace();
            } catch (TeamRewardDebtException e) {
                e.printStackTrace();
            }
        }
    }
   @Override
   public List<TaoBaoWeiQuanOrder> getWeiQuanSuccessOrders(String orderId) {
      return taoBaoWeiQuanOrderMapper.selectListByOrderIdAndState(orderId, "维权成功");