‘linchangsheng’ 2 周之前
父节点
当前提交
951e7163a2

+ 4 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/bean/order/WorkerOrderDetail.java

@@ -13,4 +13,8 @@ public class WorkerOrderDetail extends WorkerOrder {
 
     @ApiModelProperty(value = "子订单信息")
     private List<WorkerOrderItem> workerOrderItems;
+
+
+    @ApiModelProperty(value = "是否可以取消")
+    private Boolean ifCancel;
 }

+ 2 - 2
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/pay/PayOrderController.java

@@ -52,7 +52,7 @@ public class PayOrderController {
 
     @PostMapping("/orderPage")
     @ApiOperation(value = "订单列表")
-    public ResponseHelper<Page<WorkerOrder>> orderPage(
+    public ResponseHelper<Page<WorkerOrderDetail>> orderPage(
             @ApiParam(required = false, value = "商品类型 M=辅材 P=配件") @RequestParam(required = false) String goodsType,
             @ApiParam(required = false, value = "订单号") @RequestParam(required = false) String orderId,
             @ApiParam(required = false, value = "工单号") @RequestParam(required = false) String workerOrderId,
@@ -64,7 +64,7 @@ public class PayOrderController {
             @ApiParam(value = "页号", required = true) @RequestParam Integer pageNum,
             @ApiParam(value = "页大小", required = true) @RequestParam Integer pageSize
     ) throws Exception {
-        Page<WorkerOrder> workerOrderVOPage = payOrderLogic.orderPage(workerOrderId,yearMonth, settlementType, goodsType, orderId, startTime, endTime, payStatus, pageNum, pageSize);
+        Page<WorkerOrderDetail> workerOrderVOPage = payOrderLogic.orderPage(workerOrderId,yearMonth, settlementType, goodsType, orderId, startTime, endTime, payStatus, pageNum, pageSize);
         return ResponseHelper.success(workerOrderVOPage);
     }
 

+ 80 - 16
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/order/PayOrderLogic.java

@@ -394,7 +394,33 @@ public class PayOrderLogic {
         if(workerOrder == null){
             return null;
         }
+
         WorkerOrderDetail workerOrderDetail = BeanUtil.toBean(workerOrder, WorkerOrderDetail.class);
+
+        workerOrderDetail.setIfCancel(true);
+        if (!StringUtil.isEmpty(workerOrder.getWorkerOrderId())) {
+            Integer count = workerOrderService.lambdaQuery()
+                    .eq(WorkerOrder::getTotalAmount, workerOrder.getTotalAmount())
+                    .isNotNull(WorkerOrder::getGreeOrderId)
+                    .eq(WorkerOrder::getWorkerOrderId, workerOrder.getWorkerOrderId())
+                    .count();
+            if (count > 0){
+                Integer countWait = workerOrderService.lambdaQuery()
+                        .eq(WorkerOrder::getTotalAmount, workerOrder.getTotalAmount())
+                        .eq(WorkerOrder::getPayStatus, PayStatusEnum.WAIT.getKey())
+                        .eq(WorkerOrder::getWorkerOrderId, workerOrder.getWorkerOrderId())
+                        .count();
+
+                if (countWait < 2){
+                    workerOrderDetail.setIfCancel(false);
+                }
+
+            }
+        }
+
+
+
+
         workerOrderDetail.setWorkerOrderItems(workerOrderItemService.lambdaQuery()
         .eq(WorkerOrderItem::getOrderId,orderId).list());
         return workerOrderDetail;
@@ -865,7 +891,7 @@ public class PayOrderLogic {
 
     }
 
-    public Page<WorkerOrder> orderPage(String workerOrderId,String yearMonth,String settlementType,String goodsType, String orderId, String startTime, String endTime, String payStatus, Integer pageNum, Integer pageSize) {
+    public Page<WorkerOrderDetail> orderPage(String workerOrderId,String yearMonth,String settlementType,String goodsType, String orderId, String startTime, String endTime, String payStatus, Integer pageNum, Integer pageSize) {
 
         CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
         String startMonTime = null;
@@ -879,24 +905,62 @@ public class PayOrderLogic {
         if (StringUtil.isEmpty(currentCompanyWechat.getUser().getWorkerNumber()) && StringUtil.isEmpty(currentCompanyWechat.getUser().getIdCard()))
             return new Page<>();
 
-        return workerOrderService.lambdaQuery()
-                .eq(!StringUtil.isEmpty(goodsType),WorkerOrder::getGoodsType,goodsType)
-                .like(!StringUtil.isEmpty(settlementType),WorkerOrder::getSettlementType,settlementType)
-                .eq(!StringUtil.isEmpty(orderId),WorkerOrder::getOrderId,orderId)
-                .eq(!StringUtil.isEmpty(workerOrderId),WorkerOrder::getWorkerOrderId,workerOrderId)
-                .and(!StringUtil.isEmpty(payStatus),item -> item
-                .eq(!StringUtil.isEmpty(payStatus),WorkerOrder::getPayStatus,payStatus)
+        Page<WorkerOrder> page = workerOrderService.lambdaQuery()
+                .eq(!StringUtil.isEmpty(goodsType), WorkerOrder::getGoodsType, goodsType)
+                .like(!StringUtil.isEmpty(settlementType), WorkerOrder::getSettlementType, settlementType)
+                .eq(!StringUtil.isEmpty(orderId), WorkerOrder::getOrderId, orderId)
+                .eq(!StringUtil.isEmpty(workerOrderId), WorkerOrder::getWorkerOrderId, workerOrderId)
+                .and(!StringUtil.isEmpty(payStatus), item -> item
+                        .eq(!StringUtil.isEmpty(payStatus), WorkerOrder::getPayStatus, payStatus)
 
-                .or(!StringUtil.isEmpty(payStatus) && payStatus.equals(PayStatusEnum.CANCEL.getKey()),
-                        iter -> iter.eq(WorkerOrder::getRefundStatus, IsYesNoEnum.YES.getKey()))
+                        .or(!StringUtil.isEmpty(payStatus) && payStatus.equals(PayStatusEnum.CANCEL.getKey()),
+                                iter -> iter.eq(WorkerOrder::getRefundStatus, IsYesNoEnum.YES.getKey()))
                 )
-                .eq(!StringUtil.isEmpty(payStatus) && payStatus.equals(MaterialExamineStatusEnum.PAID.getKey()),WorkerOrder::getRefundStatus, IsYesNoEnum.NO.getKey())
-                .eq(!StringUtil.isEmpty(currentCompanyWechat.getUser().getWorkerNumber()),WorkerOrder::getWorkerNumber,currentCompanyWechat.getUser().getWorkerNumber())
-                .eq(StringUtil.isEmpty(currentCompanyWechat.getUser().getWorkerNumber()),WorkerOrder::getIdentity,currentCompanyWechat.getUser().getIdCard())
-                .between(!StringUtil.isEmpty(startTime),WorkerOrder::getCreateTime,startTime,endTime)
-                .in(WorkerOrder::getCompanyWechatId,currentCompanyWechat.getCompanyWechatId())
+                .eq(!StringUtil.isEmpty(payStatus) && payStatus.equals(MaterialExamineStatusEnum.PAID.getKey()), WorkerOrder::getRefundStatus, IsYesNoEnum.NO.getKey())
+                .eq(!StringUtil.isEmpty(currentCompanyWechat.getUser().getWorkerNumber()), WorkerOrder::getWorkerNumber, currentCompanyWechat.getUser().getWorkerNumber())
+                .eq(StringUtil.isEmpty(currentCompanyWechat.getUser().getWorkerNumber()), WorkerOrder::getIdentity, currentCompanyWechat.getUser().getIdCard())
+                .between(!StringUtil.isEmpty(startTime), WorkerOrder::getCreateTime, startTime, endTime)
+                .in(WorkerOrder::getCompanyWechatId, currentCompanyWechat.getCompanyWechatId())
                 .orderByDesc(WorkerOrder::getCreateTime)
-                .page(new Page<>(pageNum,pageSize));
+                .page(new Page<>(pageNum, pageSize));
+
+        Page<WorkerOrderDetail> workerOrderDetailPage = new Page<>();
+
+
+        workerOrderDetailPage.setTotal(page.getTotal());
+        workerOrderDetailPage.setCurrent(page.getCurrent());
+
+        List<WorkerOrderDetail> workerOrderDetails = new ArrayList<>();
+        for (WorkerOrder record : page.getRecords()) {
+            WorkerOrderDetail workerOrderDetail = BeanUtil.toBean(record, WorkerOrderDetail.class);
+
+            workerOrderDetail.setIfCancel(true);
+            if (!StringUtil.isEmpty(workerOrderDetail.getWorkerOrderId())) {
+                Integer count = workerOrderService.lambdaQuery()
+                        .eq(WorkerOrder::getTotalAmount, workerOrderDetail.getTotalAmount())
+                        .isNotNull(WorkerOrder::getGreeOrderId)
+                        .eq(WorkerOrder::getWorkerOrderId, workerOrderDetail.getWorkerOrderId())
+                        .count();
+                if (count > 0){
+                    Integer countWait = workerOrderService.lambdaQuery()
+                            .eq(WorkerOrder::getTotalAmount, workerOrderDetail.getTotalAmount())
+                            .eq(WorkerOrder::getPayStatus, PayStatusEnum.WAIT.getKey())
+                            .eq(WorkerOrder::getWorkerOrderId, workerOrderDetail.getWorkerOrderId())
+                            .count();
+
+                    if (countWait < 2){
+                        workerOrderDetail.setIfCancel(false);
+                    }
+
+                }
+            }
+
+            workerOrderDetails.add(workerOrderDetail);
+        }
+
+        workerOrderDetailPage.setRecords(workerOrderDetails);
+
+        return workerOrderDetailPage;
 
     }