Преглед изворни кода

Merge remote-tracking branch 'origin/develop' into develop

FengChaoYu пре 1 недеља
родитељ
комит
a9f59d317b

+ 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);
     }
 

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

@@ -394,7 +394,31 @@ public class PayOrderLogic {
         if(workerOrder == null){
             return null;
         }
+
         WorkerOrderDetail workerOrderDetail = BeanUtil.toBean(workerOrder, WorkerOrderDetail.class);
+
+        workerOrderDetail.setIfCancel(true);
+        if (!StringUtil.isEmpty(workerOrder.getWorkerOrderId())) {
+            WorkerOrder workerOrderOne = workerOrderService.lambdaQuery()
+                    .isNotNull(WorkerOrder::getGreeOrderId)
+                    .eq(WorkerOrder::getWorkerOrderId, workerOrderDetail.getWorkerOrderId())
+                    .last("limit 1").one();
+            if (workerOrderOne != null){
+                Integer countWait = workerOrderService.lambdaQuery()
+                        .ge(WorkerOrder::getTotalAmount, workerOrderOne.getTotalAmount())
+                        .in(WorkerOrder::getPayStatus, PayStatusEnum.WAIT.getKey(),PayStatusEnum.PAID.getKey())
+                        .eq(WorkerOrder::getWorkerOrderId, workerOrderDetail.getWorkerOrderId())
+                        .count();
+
+                if (countWait < 2){
+                    workerOrderDetail.setIfCancel(false);
+                }
+            }
+        }
+
+
+
+
         workerOrderDetail.setWorkerOrderItems(workerOrderItemService.lambdaQuery()
         .eq(WorkerOrderItem::getOrderId,orderId).list());
         return workerOrderDetail;
@@ -865,7 +889,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 +903,61 @@ 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())) {
+                WorkerOrder workerOrder = workerOrderService.lambdaQuery()
+                        .isNotNull(WorkerOrder::getGreeOrderId)
+                        .eq(WorkerOrder::getWorkerOrderId, workerOrderDetail.getWorkerOrderId())
+                        .last("limit 1").one();
+                if (workerOrder != null){
+                    Integer countWait = workerOrderService.lambdaQuery()
+                            .ge(WorkerOrder::getTotalAmount, workerOrder.getTotalAmount())
+                            .in(WorkerOrder::getPayStatus, PayStatusEnum.WAIT.getKey(),PayStatusEnum.PAID.getKey())
+                            .eq(WorkerOrder::getWorkerOrderId, workerOrderDetail.getWorkerOrderId())
+                            .count();
+
+                    if (countWait < 2){
+                        workerOrderDetail.setIfCancel(false);
+                    }
+
+                }
+            }
+
+            workerOrderDetails.add(workerOrderDetail);
+        }
+
+        workerOrderDetailPage.setRecords(workerOrderDetails);
+
+        return workerOrderDetailPage;
 
     }
 
@@ -1061,13 +1122,36 @@ public class PayOrderLogic {
 
     }
 
+    @Transactional(rollbackFor = Exception.class)
     public void cancel(String orderId) {
         if (workerOrderService.lambdaQuery().eq(WorkerOrder::getOrderId,orderId)
                 .eq(WorkerOrder::getPayStatus,"WAIT").count() < 1){
             throw new RemoteServiceException("订单不属于未支付不可取消");
         }
+        WorkerOrder workerOrder = workerOrderService.getById(orderId);
+
         workerOrderService.lambdaUpdate().eq(WorkerOrder::getOrderId,orderId)
                 .set(WorkerOrder::getPayStatus,"CANCEL").update();
+
+        if (!StringUtil.isEmpty(workerOrder.getWorkerOrderId())) {
+            WorkerOrder workerOrderOne = workerOrderService.lambdaQuery()
+                    .isNotNull(WorkerOrder::getGreeOrderId)
+                    .eq(WorkerOrder::getWorkerOrderId, workerOrder.getWorkerOrderId())
+                    .last("limit 1").one();
+            if (workerOrderOne != null){
+
+                Integer countWait = workerOrderService.lambdaQuery()
+                        .ge(WorkerOrder::getTotalAmount, workerOrder.getTotalAmount())
+                        .in(WorkerOrder::getPayStatus, PayStatusEnum.WAIT.getKey(),PayStatusEnum.PAID.getKey())
+                        .eq(WorkerOrder::getWorkerOrderId, workerOrder.getWorkerOrderId())
+                        .count();
+
+                if (countWait < 1)
+                    throw new RemoteServiceException("存在4.0辅材支付单,请必须支付");
+            }
+        }
+
+
     }
 
     public List<SysDictCompany> sysDict(String dictType, String status) {

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/logic/common/WechatLogic.java

@@ -649,7 +649,7 @@ public class WechatLogic {
         if (!StringUtils.equals(settlementOrder.getPayStatus(), PayStatusEnum.PAID.getKey())) {
             throw new RemoteServiceException("未支付订单不可结算");
         }
-        if (!StringUtils.equals(settlementOrder.getStatus(), "WAIT")) {
+        if (StringUtils.equals(settlementOrder.getStatus(), "OK")) {
             log.error("非待结算状态不可结算,id:{}", settlementOrder.getOrderId());
             return;
         }

+ 6 - 1
mall-server-api/src/main/java/com/gree/mall/manager/logic/websit/SettlementOrderLogic.java

@@ -212,7 +212,7 @@ public class SettlementOrderLogic {
     public void settlement(List<String> id) throws WxPayException {
         if (settlementOrderService.lambdaQuery()
                 .in(SettlementOrder::getSettlementOrderId, id)
-                .notIn(SettlementOrder::getStatus, SettlementStatusEnum.WAIT.getKey())
+                .notIn(SettlementOrder::getStatus, SettlementStatusEnum.WAIT.getKey(),"YC")
                 .count() > 0) {
             throw new RemoteServiceException("存在非待结算得结算");
         }
@@ -222,6 +222,11 @@ public class SettlementOrderLogic {
 
         for (SettlementOrder settlementOrder : settlementOrders) {
             wechatLogic.shareSettlementAmount(settlementOrder);
+
+            settlementOrderService.lambdaUpdate()
+                    .set(SettlementOrder::getIsQuery,null)
+                    .eq(SettlementOrder::getSettlementOrderId,settlementOrder.getSettlementOrderId())
+                    .update();
         }
 
 

+ 6 - 4
mall-server-api/src/main/java/com/gree/mall/manager/logic/worker/WorkerWarrantyLogic.java

@@ -224,9 +224,9 @@ public class WorkerWarrantyLogic {
 
             workerWarranty.setWaitAmount(workerWarranty.getShouldAmount().subtract(workerWarranty.getPayableAmount() == null?BigDecimal.ZERO:workerWarranty.getPayableAmount()));
 
-            if (workerWarranty.getWaitAmount().doubleValue() < 0)
+  /*          if (workerWarranty.getWaitAmount().doubleValue() < 0)
                 throw new RemoteServiceException("第"+rowIndex+"行"+"缴纳金额超过应缴纳金额");
-
+*/
             if (workerWarranty.getRefundAmount() != null && workerWarranty.getRefundAmount().doubleValue() > workerWarranty.getPayableAmount().doubleValue()) {
                 throw new RemoteServiceException("总退金额大于了缴纳金额");
             }
@@ -251,12 +251,14 @@ public class WorkerWarrantyLogic {
             if (row.size() < (2 * i + 14))
                 break;
             String payAmount = (String) row.get(2 * i + 13);
-            String payAmountTime = (String) row.get(2 * i + 14);
-
             if (StringUtils.isBlank(payAmount)) {
                 continue;
             }
 
+            String payAmountTime = (String) row.get(2 * i + 14);
+
+
+
             if (StringUtil.isEmpty(payAmountTime))
                 throw new RemoteServiceException("第"+index+"行"+"缴纳时间未填");
 

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/schedule/OrderBaseSchedule.java

@@ -80,7 +80,7 @@ public class OrderBaseSchedule {
      * 每天五点结算所有结算单
      */
     @Transactional
-    @Scheduled(cron = "0 0 17 * * ?")
+    @Scheduled(cron = "20 17 * * *")
   //  @Scheduled(fixedDelay = 60  * 1000)
     public void fenzhang() throws WxPayException {
         List<SettlementOrder> settlementOrders = settlementOrderService.lambdaQuery().in(SettlementOrder::getStatus, "WAIT").list();