Ver Fonte

小程序订单列表

yangyb há 2 semanas atrás
pai
commit
bf8f40701c

+ 20 - 11
mall-api/src/main/java/com/txz/mall/constants/Constants.java

@@ -345,17 +345,26 @@ public class Constants {
     public static final String USER_BILL_TYPE_USER_RECHARGE_REFUND = "user_recharge_refund";// 用户充值退款
 
     //订单状态
-    public static final String ORDER_STATUS_ALL = "all"; //所有
-    public static final String ORDER_STATUS_UNPAID = "unPaid"; //未支付
-    public static final String ORDER_STATUS_NOT_SHIPPED = "notShipped"; //未发货
-    public static final String ORDER_STATUS_SPIKE = "spike"; //待收货
-    public static final String ORDER_STATUS_BARGAIN = "bargain"; //已收货待评价
-    public static final String ORDER_STATUS_COMPLETE = "complete"; //交易完成
-    public static final String ORDER_STATUS_TOBE_WRITTEN_OFF = "toBeWrittenOff"; //待核销
-    public static final String ORDER_STATUS_APPLY_REFUNDING = "applyRefund"; //申请退款
-    public static final String ORDER_STATUS_REFUNDING = "refunding"; //退款中
-    public static final String ORDER_STATUS_REFUNDED = "refunded"; //已退款
-    public static final String ORDER_STATUS_DELETED = "deleted"; //已删除
+    public static final int ORDER_STATUS_ALL = 0; //所有
+    public static final int ORDER_STATUS_UNPAID = 1; //未支付
+    public static final int ORDER_STATUS_WAIT_OPEN = 2; // 等待开团
+    public static final int ORDER_STATUS_OPEN_SUCCESS = 3;// 开团成功
+    public static final int ORDER_STATUS_OPEN_FAIL = 4; // 开团失败
+    public static final int ORDER_STATUS_WIN = 5; // 中奖
+    public static final int ORDER_STATUS_NOT_WIN = 6; // 未中奖
+    public static final int ORDER_STATUS_WAIT_DELIVER = 7; //待发货
+    public static final int ORDER_STATUS_WAIT_RECEIVER = 8; //待收货
+    public static final int ORDER_STATUS_RECEIVED_GOOD = 9;  // 已收货
+    public static final int ORDER_STATUS_COMPLETE = 10; //完成
+
+//    public static final Integer ORDER_STATUS_NOT_SHIPPED = "notShipped"; //未发货
+//    public static final Integer ORDER_STATUS_SPIKE = "spike"; //待收货
+//    public static final Integer ORDER_STATUS_BARGAIN = "bargain"; //已收货待评价
+//    public static final Integer ORDER_STATUS_COMPLETE = "complete"; //交易完成
+//    public static final Integer ORDER_STATUS_APPLY_REFUNDING = "applyRefund"; //申请退款
+//    public static final Integer ORDER_STATUS_REFUNDING = "refunding"; //退款中
+//    public static final Integer ORDER_STATUS_REFUNDED = "refunded"; //已退款
+//    public static final Integer ORDER_STATUS_DELETED = "deleted"; //已删除
 
     public static final String ORDER_STATUS_STR_UNPAID = "未支付"; //未支付
     public static final String ORDER_STATUS_STR_NOT_SHIPPED = "未发货"; //未发货

+ 0 - 6
mall-service/src/main/java/com/txz/mall/business/PinkServiceBusiness.java

@@ -28,12 +28,6 @@ public interface PinkServiceBusiness {
      */
     void pinkFail(Long id);
 
-    /**
-     * 天选之子
-     *
-     * @return
-     */
-    void theSelection(Long id);
 
 
 }

+ 0 - 35
mall-service/src/main/java/com/txz/mall/business/impl/PinkServiceBusinessImpl.java

@@ -9,7 +9,6 @@ import com.txz.mall.model.StorePink;
 import com.txz.mall.service.StoreCombinationService;
 import com.txz.mall.service.StoreOrderService;
 import com.txz.mall.service.StorePinkService;
-import com.txz.mall.util.RandomUtil;
 import lombok.AllArgsConstructor;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
@@ -183,38 +182,4 @@ public class PinkServiceBusinessImpl implements PinkServiceBusiness {
 //        userPink.setStatus(3).setStopTime(System.currentTimeMillis());
 //        storePinkService.updateById(userPink);
     }
-
-    @Override
-    public void theSelection(Long id) {
-        // 假设只有1个用户是天选
-        long luckNum = 1;
-
-        Condition condition = new Condition(StorePink.class);
-        Example.Criteria criteria = condition.createCriteria();
-        criteria.andEqualTo("isDelete", 0);
-        // 排除团长
-//        criteria.andEqualTo("kId", 1);
-        // 支付成功的
-
-        criteria.andEqualTo("status", 1);
-        List<StorePink> list = storePinkService.findByCondition(condition);
-        if (CollUtil.isEmpty(list)) {
-            throw new ServiceException("没有拼团订单");
-        }
-        long count = list.stream().filter(i -> i.getLId().equals(1)).count();
-        if (count >= luckNum) {
-            throw new ServiceException("已有天选");
-        }
-
-        List<Long> idCollect = list.stream().map(StorePink::getId).collect(Collectors.toList());
-        List<Long> randomIds = RandomUtil.uniqueRandom(idCollect, (int) luckNum);
-
-        randomIds.forEach(i -> {
-            StorePink luckPink = new StorePink();
-            luckPink.setId(i);
-            luckPink.setLId(1);
-            storePinkService.update(luckPink);
-        });
-    }
-
 }

+ 2 - 2
mall-service/src/main/java/com/txz/mall/controller/OrderController.java

@@ -113,11 +113,11 @@ public class OrderController {
 
     @PostMapping("/app/list")
     @ApiOperation(value = "订单获取列表")
-    public Result<List<StoreOrder>> appList(@RequestBody StoreOrderAppDTO dto, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
+    public Result<List<StoreOrderVO>> appList(@RequestBody StoreOrderAppDTO dto, @RequestParam(defaultValue = "1") Integer page, @RequestParam(defaultValue = "10") Integer size) {
         PageHelper.startPage(page, size);
         PageInfo pageInfo = null;
         try {
-            List<StoreOrder> arrayList = storeOrderService.appList(dto);
+            List<StoreOrderVO> arrayList = storeOrderService.appList(dto);
             pageInfo = new PageInfo(arrayList);
         } catch (Exception e) {
             log.error("查询对象操作异常e:{}", e);

+ 2 - 2
mall-service/src/main/java/com/txz/mall/controller/PinkController.java

@@ -174,8 +174,8 @@ public class PinkController {
      */
     @ApiOperation(value = "天选")
     @PostMapping(value = "/theSelection")
-    public Result theSelection(@RequestParam("id") Long id) {
-        pinkServiceBusiness.theSelection(id);
+    public Result theSelection(@RequestParam("id") String orderId) {
+        storePinkService.theSelection(orderId);
         return Result.success();
     }
 }

+ 39 - 0
mall-service/src/main/java/com/txz/mall/enums/OrderStatusEnum.java

@@ -0,0 +1,39 @@
+package com.txz.mall.enums;
+
+import java.util.Objects;
+
+/**
+ * 订单状态类型枚举
+ */
+public enum OrderStatusEnum {
+
+    ;
+
+    private Integer key;
+    private String value;
+
+    OrderStatusEnum(Integer key, String value) {
+        this.key = key;
+        this.value = value;
+    }
+
+    public static OrderStatusEnum getEnum(Integer inType) {
+        if (inType == null) {
+            return null;
+        }
+        for (OrderStatusEnum temp : values()) {
+            if (Objects.equals(temp.key, inType)) {
+                return temp;
+            }
+        }
+        return null;
+    }
+
+    public Integer getKey() {
+        return key;
+    }
+
+    public String getValue() {
+        return value;
+    }
+}

+ 1 - 1
mall-service/src/main/java/com/txz/mall/service/StoreOrderService.java

@@ -81,7 +81,7 @@ public interface StoreOrderService extends Service<StoreOrder> {
      *
      * @return 订单列表
      */
-    List<StoreOrder> appList(StoreOrderAppDTO dto);
+    List<StoreOrderVO> appList(StoreOrderAppDTO dto);
 
     /**
      * 获取用户当前的拼团订单

+ 7 - 0
mall-service/src/main/java/com/txz/mall/service/StorePinkService.java

@@ -26,6 +26,13 @@ public interface StorePinkService extends Service<StorePink> {
      */
     void pinkSuccess(Long id);
 
+    /**
+     * 天选之子
+     *
+     * @return
+     */
+    void theSelection(String orderId);
+
     /**
      * 已存在拼团列表
      */

+ 70 - 57
mall-service/src/main/java/com/txz/mall/service/impl/StoreOrderServiceImpl.java

@@ -66,10 +66,10 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         response.setAll(getCount(Constants.ORDER_STATUS_ALL, type));
         // 未支付订单
         response.setUnPaid(getCount(Constants.ORDER_STATUS_UNPAID, type));
-        // 发货订单
-        response.setNotShipped(getCount(Constants.ORDER_STATUS_NOT_SHIPPED, type));
+        // 发货订单
+        response.setNotShipped(getCount(Constants.ORDER_STATUS_WAIT_DELIVER, type));
         // 待收货订单
-        response.setSpike(getCount(Constants.ORDER_STATUS_SPIKE, type));
+        response.setSpike(getCount(Constants.ORDER_STATUS_WAIT_RECEIVER, type));
 //        // 待评价订单
 //        response.setBargain(getCount(Constants.ORDER_STATUS_BARGAIN, type));
 //        // 交易完成订单
@@ -78,9 +78,9 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
 //        response.setToBeWrittenOff(getCount(Constants.ORDER_STATUS_TOBE_WRITTEN_OFF, type));
 //        // 退款中订单
 //        response.setRefunding(getCount(Constants.ORDER_STATUS_REFUNDING, type));
-        // 已退款订单
-        response.setRefunded(getCount(Constants.ORDER_STATUS_REFUNDED, type));
-        // 已删除订单
+//        // 已退款订单
+//        response.setRefunded(getCount(Constants.ORDER_STATUS_REFUNDED, type));
+//        // 已删除订单
 //        response.setDeleted(getCount(Constants.ORDER_STATUS_DELETED, type));
         return response;
     }
@@ -877,7 +877,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
     }
 
     @Override
-    public List<StoreOrder> appList(StoreOrderAppDTO dto) {
+    public List<StoreOrderVO> appList(StoreOrderAppDTO dto) {
         Condition condition = new Condition(StoreOrder.class);
         Example.Criteria criteria = condition.createCriteria();
         criteria.andEqualTo("isDelete", 0);
@@ -916,10 +916,43 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
             default:
                 break;
         }
-        List<StoreOrder> orderList = findByCondition(condition);
+        List<StoreOrder> list = findByCondition(condition);
+        List<StoreOrderVO> arrayList = new ArrayList<>();
+        List<StoreOrderInfo> infoArrayList = new ArrayList<>();
+        List<StoreOrderStatus> statusList = new ArrayList<>();
+        List<UserAddress> addressList = new ArrayList<>();
+        if (CollectionUtils.isNotEmpty(list)) {
+            Condition infoCondition = new Condition(StoreOrderInfo.class);
+            Example.Criteria infoCriteria = infoCondition.createCriteria();
+            infoCriteria.andEqualTo("isDelete", 0);
+            infoCriteria.andIn("orderId", list.stream().map(StoreOrder::getId).collect(Collectors.toList()));
+            infoArrayList = storeOrderInfoService.findByCondition(infoCondition);
 
+            Condition statusCondition = new Condition(StoreOrderStatus.class);
+            Example.Criteria statusCriteria = statusCondition.createCriteria();
+            statusCriteria.andIn("oid", list.stream().map(StoreOrder::getId).collect(Collectors.toList()));
+            statusList = storeOrderStatusService.findByCondition(statusCondition);
 
-        return orderList;
+            Condition addressCondition = new Condition(UserAddress.class);
+            Example.Criteria addressCriteria = addressCondition.createCriteria();
+            addressCriteria.andEqualTo("isDelete", 0);
+            addressCriteria.andIn("id", list.stream().map(StoreOrder::getUid).collect(Collectors.toList()));
+            addressList = userAddressService.findByCondition(addressCondition);
+        }
+        List<StoreOrderInfo> finalInfoArrayList = infoArrayList;
+        List<StoreOrderStatus> finalStatusList = statusList;
+        List<UserAddress> finalAddressList = addressList;
+        list.forEach(item -> {
+            StoreOrderVO vo = new StoreOrderVO();
+            BeanUtils.copyProperties(item, vo);
+            List<StoreOrderInfo> infoCollect = finalInfoArrayList.stream().filter(info -> info.getOrderId().equals(item.getId())).collect(Collectors.toList());
+            vo.setOrderInfoVO(infoCollect);
+            vo.setOrderStatusVO(finalStatusList.stream().filter(status -> status.getOid().equals(item.getId())).collect(Collectors.toList()));
+            vo.setBrokerage(BigDecimal.ONE);
+            vo.setOrderAddressVO(finalAddressList.stream().filter(address -> address.getId().equals(item.getUid())).findFirst().orElse(null));
+            arrayList.add(vo);
+        });
+        return arrayList;
     }
 
     @Override
@@ -932,7 +965,7 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
         return this.findByCondition(condition);
     }
 
-    private Integer getCount(String status, Integer type) {
+    private Integer getCount(Integer status, Integer type) {
         //总数只计算时间
         Condition condition = new Condition(StoreOrder.class);
         Example.Criteria criteria = condition.createCriteria();
@@ -950,8 +983,8 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
      *
      * @param status String 类型
      */
-    private void getStatusWhereNew(Example.Criteria criteria, String status) {
-        if (StrUtil.isBlank(status)) {
+    private void getStatusWhereNew(Example.Criteria criteria, Integer status) {
+        if (status == null) {
             return;
         }
         switch (status) {
@@ -962,51 +995,31 @@ public class StoreOrderServiceImpl extends AbstractService<StoreOrder> implement
                 criteria.andEqualTo("status", 0);
                 criteria.andEqualTo("isDelete", 0);
                 break;
-            case Constants.ORDER_STATUS_NOT_SHIPPED:
-                criteria.andEqualTo("paid", 1);
-                criteria.andEqualTo("status", 0);
-                criteria.andEqualTo("refundStatus", 0);
-                criteria.andEqualTo("shippingType", 1);
-                criteria.andEqualTo("isDelete", 0);
-                break;
-            case Constants.ORDER_STATUS_SPIKE:
-                criteria.andEqualTo("paid", 1);
-                criteria.andEqualTo("status", 1);
-                criteria.andEqualTo("refundStatus", 0);
-                criteria.andEqualTo("isDelete", 0);
-                break;
-            case Constants.ORDER_STATUS_BARGAIN:
-                criteria.andEqualTo("paid", 1);
-                criteria.andEqualTo("status", 2);
-                criteria.andEqualTo("refundStatus", 0);
-                criteria.andEqualTo("isDelete", 0);
-                break;
-            case Constants.ORDER_STATUS_COMPLETE:
-                criteria.andEqualTo("paid", 1);
-                criteria.andEqualTo("status", 3);
-                criteria.andEqualTo("refundStatus", 0);
-                criteria.andEqualTo("isDelete", 0);
-                break;
-            case Constants.ORDER_STATUS_TOBE_WRITTEN_OFF:
-                criteria.andEqualTo("paid", 1);
-                criteria.andEqualTo("status", 0);
-                criteria.andEqualTo("refundStatus", 0);
-                criteria.andEqualTo("shippingType", 2);
-                criteria.andEqualTo("isDelete", 0);
-                break;
-            case Constants.ORDER_STATUS_REFUNDING:
-                criteria.andEqualTo("paid", 1);
-                criteria.andIn("refundStatus", Arrays.asList(1, 3));
-                criteria.andEqualTo("isDelete", 0);
-                break;
-            case Constants.ORDER_STATUS_REFUNDED:
-                criteria.andEqualTo("paid", 1);
-                criteria.andEqualTo("refundStatus", 2);
-                criteria.andEqualTo("isDelete", 0);
-                break;
-            case Constants.ORDER_STATUS_DELETED:
-                criteria.andEqualTo("isDelete", 1);
-                break;
+//            case Constants.ORDER_STATUS_WAIT_DELIVER:
+//                criteria.andEqualTo("paid", 1);
+//                criteria.andEqualTo("status", 0);
+//                criteria.andEqualTo("refundStatus", 0);
+//                criteria.andEqualTo("shippingType", 1);
+//                criteria.andEqualTo("isDelete", 0);
+//                break;
+//            case Constants.ORDER_STATUS_WAIT_RECEIVER:
+//                criteria.andEqualTo("paid", 1);
+//                criteria.andEqualTo("status", 1);
+//                criteria.andEqualTo("refundStatus", 0);
+//                criteria.andEqualTo("isDelete", 0);
+//                break;
+//            case Constants.ORDER_STATUS_BARGAIN:
+//                criteria.andEqualTo("paid", 1);
+//                criteria.andEqualTo("status", 2);
+//                criteria.andEqualTo("refundStatus", 0);
+//                criteria.andEqualTo("isDelete", 0);
+//                break;
+//            case Constants.ORDER_STATUS_COMPLETE:
+//                criteria.andEqualTo("paid", 1);
+//                criteria.andEqualTo("status", 3);
+//                criteria.andEqualTo("refundStatus", 0);
+//                criteria.andEqualTo("isDelete", 0);
+//                break;
             default:
                 criteria.andEqualTo("paid", 1);
                 criteria.andNotEqualTo("refundStatus", 2);

+ 39 - 0
mall-service/src/main/java/com/txz/mall/service/impl/StorePinkServiceImpl.java

@@ -1,11 +1,14 @@
 package com.txz.mall.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.txz.mall.core.AbstractService;
+import com.txz.mall.core.ServiceException;
 import com.txz.mall.dao.StorePinkMapper;
 import com.txz.mall.model.StorePink;
 import com.txz.mall.service.StorePinkService;
+import com.txz.mall.util.RandomUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import tk.mybatis.mapper.entity.Condition;
@@ -51,6 +54,42 @@ public class StorePinkServiceImpl extends AbstractService<StorePink> implements
             i.setStopTime(new Date());
             update(i);
         });
+
+        theSelection(teamPink.getOrderId());
+    }
+
+    @Override
+    public void theSelection(String orderId) {
+        // 假设只有1个用户是天选
+        long luckNum = 1;
+
+        Condition condition = new Condition(StorePink.class);
+        Example.Criteria criteria = condition.createCriteria();
+        criteria.andEqualTo("isDelete", 0);
+        criteria.andEqualTo("orderId", orderId);
+        // 排除团长
+//        criteria.andEqualTo("kId", 1);
+        // 支付成功的
+
+        criteria.andEqualTo("status", 1);
+        List<StorePink> list = findByCondition(condition);
+        if (CollUtil.isEmpty(list)) {
+            throw new ServiceException("没有拼团订单");
+        }
+        long count = list.stream().filter(i -> i.getLId().equals(1)).count();
+        if (count >= luckNum) {
+            throw new ServiceException("已有天选");
+        }
+
+        List<Long> idCollect = list.stream().map(StorePink::getId).collect(Collectors.toList());
+        List<Long> randomIds = RandomUtil.uniqueRandom(idCollect, (int) luckNum);
+
+        randomIds.forEach(i -> {
+            StorePink luckPink = new StorePink();
+            luckPink.setId(i);
+            luckPink.setLId(1);
+            update(luckPink);
+        });
     }
 
     @Override