admin
2019-09-22 b9f8ef2c4737b6e6be4b12fc8f7bafb033bfcfe5
fanli/src/main/java/com/yeshi/fanli/service/impl/order/CommonOrderServiceImpl.java
@@ -20,6 +20,7 @@
import com.yeshi.fanli.dao.mybatis.order.CommonOrderMapper;
import com.yeshi.fanli.dao.mybatis.order.CommonOrderTradeIdMapMapper;
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
import com.yeshi.fanli.dto.order.CommonOrderAddResultDTO;
import com.yeshi.fanli.dto.pdd.PDDGoodsDetail;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
@@ -45,9 +46,9 @@
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.config.SystemCouponService;
import com.yeshi.fanli.service.inter.goods.CommonGoodsService;
import com.yeshi.fanli.service.inter.hongbao.HongBaoV2Service;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
import com.yeshi.fanli.service.inter.user.UserSystemCouponService;
import com.yeshi.fanli.util.Constant;
@@ -216,9 +217,9 @@
   }
   @Override
   public Map<String, BigDecimal> countByUidAndOrderState(Long uid, Integer type, String startTime, String endTime,
         Integer day, Integer source) {
      return commonOrderMapper.countByUidAndOrderState(uid, type, startTime, endTime, day, source);
   public Long countUserOrderToApp(Long uid, Integer type, String startTime, String endTime,
         Integer day, Integer source, Integer state, Integer stateOrder) {
      return commonOrderMapper.countUserOrderToApp(uid, type, startTime, endTime, day, source, state, stateOrder);
   }
   private BigDecimal getWeiQuanMoney(List<TaoBaoWeiQuanOrder> listWQ, int sourceType, Long uid) {
@@ -645,9 +646,9 @@
      // 1.6.5 是否存在新兑换的券
      if (!hasRewardCoupon && exchangeCoupon) {
         try {
            String downTime = order.getDownTime();
            if (!StringUtil.isNullOrEmpty(downTime)) {
               long downOrderTime = TimeUtil.convertDateToTemp2(downTime);
            Date thirdCreateTime = order.getThirdCreateTime();
            if (thirdCreateTime != null) {
               long downOrderTime = thirdCreateTime.getTime();
               long limitDate = TimeUtil.convertDateToTemp("2019-09-05");
               if (downOrderTime > limitDate)
                  hasRewardCoupon = true;
@@ -680,7 +681,7 @@
         Map<String, Object> jumpLink = new HashMap<String, Object>();
         jumpLink.put("orderNo", order.getOrderNo());
         if (VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
            jumpLink.put("goodsType", order.getSourceType());
            jumpLink.put("goodsType", order.getSourceType()+"");
         }
         Map<String, Object> jump = new HashMap<String, Object>();
@@ -705,7 +706,7 @@
         Map<String, Object> jumpLink = new HashMap<String, Object>();
         jumpLink.put("orderNo", order.getOrderNo());
         if (VersionUtil.greaterThan_1_6_0(acceptData.getPlatform(), acceptData.getVersion())) {
            jumpLink.put("goodsType", order.getSourceType());
            jumpLink.put("goodsType", order.getSourceType()+"");
         }
         Map<String, Object> jump = new HashMap<String, Object>();
@@ -728,8 +729,9 @@
   @Transactional
   @Override
   public List<CommonOrder> addTaoBaoOrder(List<TaoBaoOrder> taoBaoOrders, Long uid) throws CommonOrderException {
      List<CommonOrder> commonOrderList = new ArrayList<>();
   public List<CommonOrderAddResultDTO> addTaoBaoOrder(List<TaoBaoOrder> taoBaoOrders, Long uid)
         throws CommonOrderException {
      List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>();
      // 判断所有的订单状态
      int invalidCount = 0;
      for (TaoBaoOrder tb : taoBaoOrders) {
@@ -789,8 +791,9 @@
   @Transactional
   @Override
   public List<CommonOrder> addPDDOrder(List<PDDOrder> pddOrderList, Long uid) throws CommonOrderException {
      List<CommonOrder> commonOrderList = new ArrayList<>();
   public List<CommonOrderAddResultDTO> addPDDOrder(List<PDDOrder> pddOrderList, Long uid)
         throws CommonOrderException {
      List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>();
      // 判断所有的订单状态
      int invalidCount = 0;
      for (PDDOrder order : pddOrderList) {
@@ -838,8 +841,8 @@
   @Transactional
   @Override
   public List<CommonOrder> addJDOrder(JDOrder jdOrder, Long uid) throws CommonOrderException {
      List<CommonOrder> commonOrderList = new ArrayList<>();
   public List<CommonOrderAddResultDTO> addJDOrder(JDOrder jdOrder, Long uid) throws CommonOrderException {
      List<CommonOrderAddResultDTO> commonOrderList = new ArrayList<>();
      // 判断所有的订单状态
      int invalidCount = 0;
      for (JDOrderItem tb : jdOrder.getOrderItemList()) {
@@ -907,7 +910,7 @@
    * @param commonOrder
    */
   @Transactional
   private CommonOrder addCommonOrder(CommonOrder commonOrder) throws CommonOrderException {
   private CommonOrderAddResultDTO addCommonOrder(CommonOrder commonOrder) throws CommonOrderException {
      // 判断商品是否存在
      if (commonOrder == null)
         throw new CommonOrderException(1, "订单为空");
@@ -950,13 +953,13 @@
         // 插入映射,保证交易ID的完整性
         commonOrderTradeIdMapMapper.insertSelective(new CommonOrderTradeIdMap(commonOrder.getId(),
               commonOrder.getTradeId(), new Date(), commonOrder.getSourceType()));
         return commonOrder;
         return new CommonOrderAddResultDTO(commonOrder, CommonOrderAddResultDTO.TYPE_ADD);
      } else {// 修改
         // 已经结算,已经失效,状态未改变的订单不处理
         if (oldCommonOrder.getState() == CommonOrder.STATE_JS || oldCommonOrder.getState() == CommonOrder.STATE_SX
               || oldCommonOrder.getState() == CommonOrder.STATE_WQ
               || (oldCommonOrder.getState().intValue() == commonOrder.getState())) {
            return oldCommonOrder;
            return new CommonOrderAddResultDTO(oldCommonOrder, CommonOrderAddResultDTO.TYPE_NOUPDATE);
         }
         // 交易ID一致才修改
         if (commonOrder.getTradeId() != null
@@ -972,9 +975,10 @@
            updateCommonOrder.setUpdateTime(new Date());
            updateCommonOrder.setTradeId(commonOrder.getTradeId());
            commonOrderMapper.updateByPrimaryKeySelective(updateCommonOrder);
            return commonOrderMapper.selectByPrimaryKey(updateCommonOrder.getId());
            return new CommonOrderAddResultDTO(commonOrderMapper.selectByPrimaryKey(updateCommonOrder.getId()),
                  CommonOrderAddResultDTO.TYPE_UPDATE);
         } else
            return oldCommonOrder;
            return new CommonOrderAddResultDTO(oldCommonOrder, CommonOrderAddResultDTO.TYPE_NOUPDATE);
      }
   }
@@ -1368,7 +1372,7 @@
   }
   @Override
   public JSONObject getRewardJumpInfo(String orderNo) {
   public JSONObject getRewardJumpInfo(String orderNo, Integer goodsType) {
      JSONObject map = new JSONObject();
      // 订单标识
@@ -1385,6 +1389,7 @@
      Map<String, Object> jumpLink = new HashMap<String, Object>();
      jumpLink.put("orderNo", orderNo);
      jumpLink.put("goodsType", goodsType == null? goodsType: goodsType +"");
      Map<String, Object> jump = new HashMap<String, Object>();
      jump.put("type", 1);
@@ -1451,4 +1456,15 @@
      return commonOrderMapper.getByOrderNo(uid, orderNO);
   }
   @Override
   public CommonOrder selectLatestValidByUid(Long uid) {
      List<Integer> stateList = new ArrayList<>();
      stateList.add(CommonOrder.STATE_FK);
      stateList.add(CommonOrder.STATE_JS);
      List<CommonOrder> commonOrderList = commonOrderMapper.listByUid(uid, stateList, 0, 1);
      if (commonOrderList == null || commonOrderList.size() == 0)
         return null;
      return commonOrderList.get(0);
   }
}