Explorar el Código

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

‘linchangsheng’ hace 4 meses
padre
commit
7f8bbd3598

+ 1 - 0
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/workorder/OrderBaseLogic.java

@@ -756,6 +756,7 @@ public class OrderBaseLogic {
 
         final List<WorkerTeam> teamList = workerTeamService.lambdaQuery()
                 .eq(WorkerTeam::getCompanyWechatId, orderBase.getCompanyWechatId())
+                .eq(WorkerTeam::getWebsitId, orderBase.getWebsitId())
                 .and(v -> v.eq(WorkerTeam::getMasterWorkerId, workerId)
                         .or()
                         .eq(WorkerTeam::getAssistantWorkerId, workerId))

+ 15 - 2
mall-server-api/src/main/java/com/gree/mall/manager/controller/workerorder/AppraiseApplyController.java

@@ -4,12 +4,14 @@ import cn.hutool.core.lang.TypeReference;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.annotation.ZfireList;
+import com.gree.mall.manager.bean.admin.AdminUserCom;
 import com.gree.mall.manager.bean.workorder.PgAppraiseApplyBean;
 import com.gree.mall.manager.bean.workorder.PgAppraiseApplyVO;
 import com.gree.mall.manager.bean.workorder.PgAppraiseCategoryVO;
 import com.gree.mall.manager.constant.Constant;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.helper.ResponseHelper;
+import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.logic.workorder.AppraiseRelaLogic;
 import com.gree.mall.manager.plus.entity.PgAppraiseCategory;
 import com.gree.mall.manager.plus.entity.PgAppraiseConfig;
@@ -40,6 +42,8 @@ public class AppraiseApplyController {
     AppraiseRelaLogic appraiseRelaLogic;
     @Resource
     RedisLockRegistry redisLockRegistry;
+    @Resource
+    CommonLogic commonLogic;
 
     @PostMapping("/config/list")
     @ApiOperation(value = "评价配置-列表")
@@ -125,8 +129,17 @@ public class AppraiseApplyController {
 
     @PostMapping("/apply/submit")
     @ApiOperation(value = "评价申诉-提交")
-    public ResponseHelper applySubmit(@RequestBody PgAppraiseApplyBean bean) {
-        appraiseRelaLogic.applySubmit(bean);
+    public ResponseHelper applySubmit(@RequestBody PgAppraiseApplyBean bean) throws Exception {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.LOCK_ORDER + adminUser.getAdminUserId());
+        if (!obtain.tryLock(10, TimeUnit.SECONDS)) {
+            throw new RemoteServiceException("处理中,请稍后再试");
+        }
+        try {
+            appraiseRelaLogic.applySubmit(bean);
+        } finally {
+            obtain.unlock();
+        }
         return ResponseHelper.success();
     }
 

+ 24 - 0
mall-server-api/src/main/java/com/gree/mall/manager/enums/workorder/AppraiseApplyStatusEnum.java

@@ -0,0 +1,24 @@
+package com.gree.mall.manager.enums.workorder;
+
+import com.baomidou.mybatisplus.annotation.EnumValue;
+import com.fasterxml.jackson.annotation.JsonValue;
+import com.gree.mall.manager.enums.base.BaseEnum;
+import lombok.AccessLevel;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+@Getter
+@AllArgsConstructor(access = AccessLevel.PRIVATE)
+public enum AppraiseApplyStatusEnum implements BaseEnum {
+
+    WAIT("WAIT","待申诉"),
+    WAIT_CENTER("WAIT_CENTER","待中心审核"),
+    OK("OK","审核通过"),
+    ;
+
+    @JsonValue
+    @EnumValue
+    private final String key;
+    private final String remark;
+
+}

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/logic/worker/WorkerTeamLogic.java

@@ -123,7 +123,7 @@ public class WorkerTeamLogic {
                 .one();
         if (Objects.nonNull(count1)) {
             throw new RemoteServiceException(workerTeam.getWebsitId() + "已存在一组同样师傅的记录" + workerTeam.getMasterWorkerId()
-                    + "," + workerTeam.getAssistantWorkerId() + (count.getStatus().equals(StateEnum.OFF.getKey()) ? ", 请设为“有效”" : ""));
+                    + "," + workerTeam.getAssistantWorkerId() + (count1.getStatus().equals(StateEnum.OFF.getKey()) ? ", 请设为“有效”" : ""));
         }
 
 

+ 54 - 16
mall-server-api/src/main/java/com/gree/mall/manager/logic/workorder/AppraiseRelaLogic.java

@@ -1,5 +1,8 @@
 package com.gree.mall.manager.logic.workorder;
 
+import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -8,6 +11,7 @@ import com.gree.mall.manager.bean.workorder.PgAppraiseApplyBean;
 import com.gree.mall.manager.bean.workorder.PgAppraiseApplyVO;
 import com.gree.mall.manager.bean.workorder.PgAppraiseCategoryVO;
 import com.gree.mall.manager.commonmapper.CommonMapper;
+import com.gree.mall.manager.enums.workorder.AppraiseApplyStatusEnum;
 import com.gree.mall.manager.enums.workorder.AppraiseConfigTypeEnum;
 import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
@@ -179,6 +183,7 @@ public class AppraiseRelaLogic {
     @Transactional
     public void applySubmit(PgAppraiseApplyBean bean) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
+        boolean isAdd = StringUtils.isBlank(bean.getId());
         if (StringUtils.isBlank(bean.getOrderBaseId())) {
             throw new RemoteServiceException("工单编号不能为空");
         }
@@ -210,27 +215,60 @@ public class AppraiseRelaLogic {
 
         // 有驳回可重诉人忽略申诉配置
         if (superCount == 0) {
+            Date overTime = Objects.nonNull(orderBase.getOverTime()) ? orderBase.getOverTime() : orderBase.getWebsitOverTime();
+            DateTime endTime;
             // 1、完工时间超过配置时间的,不可再提交;
-            if (applyCount == 0) {
-                // 首次申诉
-                final PgAppraiseConfig config = pgAppraiseConfigService.lambdaQuery()
-                        .eq(PgAppraiseConfig::getCompanyWechatId, orderBase.getCompanyWechatId())
-                        .eq(PgAppraiseConfig::getType, AppraiseConfigTypeEnum.FIRST_A.getKey())
-                        .one();
+            // 申诉配置
+            final PgAppraiseConfig config = pgAppraiseConfigService.lambdaQuery()
+                    .eq(PgAppraiseConfig::getCompanyWechatId, orderBase.getCompanyWechatId())
+                    .eq(PgAppraiseConfig::getType, applyCount == 0 ? AppraiseConfigTypeEnum.FIRST_A.getKey() : AppraiseConfigTypeEnum.SECOND_A.getKey())
+                    .one();
+
+            final int val = Integer.parseInt(config.getVal());
+            endTime = DateUtil.offsetHour(overTime, val);
+
+            String str = applyCount == 0 ? "首次" : "二次";
+            if (DateUtil.date().after(endTime)) {
+                throw new RemoteServiceException("已超" + str + "申诉时间, 提交失败");
+            }
+        }
 
+        //2、该工单已有中差评申诉数据的,不可再提交;(已申诉、待审核状态的,均不可再创建申诉)
+        Integer waitCount = pgAppraiseApplyService.lambdaQuery()
+                .eq(PgAppraiseApply::getOrderBaseId, bean.getOrderBaseId())
+                .in(PgAppraiseApply::getStatus, AppraiseApplyStatusEnum.WAIT.getKey(), AppraiseApplyStatusEnum.WAIT_CENTER.getKey())
+                .ne(!isAdd, PgAppraiseApply::getId, bean.getId())
+                .count();
+        if (waitCount > 0) {
+            throw new RemoteServiceException("已有中差评申诉记录, 提交失败");
+        }
 
-            }
+        waitCount = pgAppraiseApplyService.lambdaQuery()
+                .eq(PgAppraiseApply::getOrderBaseId, bean.getOrderBaseId())
+                .eq(PgAppraiseApply::getStatus, AppraiseApplyStatusEnum.OK.getKey())
+                .ne(!isAdd, PgAppraiseApply::getId, bean.getId())
+                .count();
+        if (waitCount > 0) {
+            throw new RemoteServiceException("已有中差评申诉“审核通过”记录, 提交失败");
         }
-//        pgOrderBaseService.lambdaQuery()
-//                .eq()
 
-        //2、该工单已有中差评申诉数据的,不可再提交;(含待申诉、已申诉、待审核状态的,均不可再创建申诉)
-        //
-        //
-//        pgAppraiseApplyService.lambdaQuery()
-//                .eq(Pg)
-//                .eq()
-//                .count()
+        if (isAdd) {
+            bean.insert();
+        } else {
+            bean.updateById();
+        }
+
+        if (!isAdd) {
+            // 非新增清空明细
+            pgAppraiseApplyItemService.lambdaUpdate()
+                    .eq(PgAppraiseApplyItem::getPgAppraiseApplyId, bean.getId())
+                    .remove();
+        }
+
+        if (CollectionUtil.isNotEmpty(bean.getItems())) {
+            List<PgAppraiseApplyItem> itemList = bean.getItems().stream().peek(v -> v.setPgAppraiseApplyId(bean.getId())).collect(Collectors.toList());
+            pgAppraiseApplyItemService.saveBatch(itemList);
+        }
     }
 
     public void applyConfirm(PgAppraiseApplyBean bean) {