Bladeren bron

no message

FengChaoYu 3 maanden geleden
bovenliggende
commit
109d123b02

+ 1 - 1
mall-server-api/src/main/java/com/gree/mall/manager/bean/quality/QualityFeedbackVO.java

@@ -42,7 +42,7 @@ public class QualityFeedbackVO {
     private String websitName;
 
     @ZfireField(hide = true)
-    @ApiModelProperty(value = "反馈时间")
+    @ApiModelProperty(value = "创建时间")
     private Date createTime;
 
     @ApiModelProperty(value = "云售后4.0工单号")

+ 17 - 6
mall-server-api/src/main/java/com/gree/mall/manager/controller/quality/QualityFeedbackController.java

@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.locks.Lock;
 
@@ -73,33 +74,43 @@ public class QualityFeedbackController {
 
     @PostMapping("/add")
     @ApiOperation("新增")
-    public ResponseHelper add(@RequestBody QualityFeedbackCountBean bean) throws RemoteServiceException {
+    public ResponseHelper add(@RequestBody QualityFeedbackBean bean) throws RemoteServiceException {
         qualityFeedbackLogic.add(bean);
         return ResponseHelper.success();
     }
 
     @PostMapping("/update")
     @ApiOperation("修改")
-    public ResponseHelper update(@RequestBody QualityFeedbackCountBean bean) throws RemoteServiceException {
+    public ResponseHelper update(@RequestBody QualityFeedbackBean bean) throws RemoteServiceException {
         qualityFeedbackLogic.update(bean);
         return ResponseHelper.success();
     }
 
+    @PostMapping("/update/upload")
+    @ApiOperation("已录入总部状态")
+    public ResponseHelper manualConfirm(
+            @ApiParam(value = "id", required = true) @RequestParam List<String> ids
+    ) throws Exception {
+        qualityFeedbackLogic.updateUpload(ids);
+        return ResponseHelper.success();
+    }
+
     @PostMapping("/confirm")
     @ApiOperation("中心审核")
-    public ResponseHelper manualConfirm(
+    public ResponseHelper confirm(
             @ApiParam(value = "id", required = true) @RequestParam String id,
-            @ApiParam(value = "状态 OK=通过 FAIL=驳回", required = true) @RequestParam ExamineQualityFeedbackStatusEnum status
+            @ApiParam(value = "审核备注", required = true) @RequestParam String remark,
+            @ApiParam(value = "状态 OK=通过 FAIL=驳回不可修改 REJECT=驳回可修改", required = true) @RequestParam ExamineQualityFeedbackStatusEnum status
     ) throws Exception {
         Lock obtain = redisLockRegistry.obtain(Constant.RedisPrefix.LOCK_ORDER + id);
         if (!obtain.tryLock(10, TimeUnit.SECONDS)) {
             throw new RemoteServiceException("记录冻结中");
         }
         try {
-            qualityFeedbackLogic.confirm(id, status);
+            qualityFeedbackLogic.confirm(id, remark, status);
             return ResponseHelper.success();
         } catch (Exception e) {
-            log.error("【人工审核处理】失败", e);
+            log.error("【审核处理】失败", e);
             throw e;
         } finally {
             obtain.unlock();

+ 19 - 0
mall-server-api/src/main/java/com/gree/mall/manager/enums/quality/QualityFeedbackTypeEnum.java

@@ -0,0 +1,19 @@
+package com.gree.mall.manager.enums.quality;
+
+import com.gree.mall.manager.enums.base.BaseEnum;
+import lombok.Getter;
+
+@Getter
+public enum QualityFeedbackTypeEnum implements BaseEnum {
+    INSIDE_CODE("INSIDE_CODE","内机条码"),
+    OUT_CODE("OUT_CODE","外机条码"),
+    OTHER("OTHER","其它"),
+    FILE("FILE","附件"),
+    ;
+
+    QualityFeedbackTypeEnum(String key, String remark) {
+        this.key=key;this.remark = remark;
+    }
+    private String key;
+    private String remark;
+}

+ 185 - 3
mall-server-api/src/main/java/com/gree/mall/manager/logic/quality/QualityFeedbackLogic.java

@@ -1,6 +1,7 @@
 package com.gree.mall.manager.logic.quality;
 
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.date.DateUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gree.mall.manager.bean.admin.AdminUserCom;
@@ -9,19 +10,27 @@ import com.gree.mall.manager.bean.quality.QualityFeedbackCountBean;
 import com.gree.mall.manager.bean.quality.QualityFeedbackVO;
 import com.gree.mall.manager.commonmapper.CommonMapper;
 import com.gree.mall.manager.enums.quality.ExamineQualityFeedbackStatusEnum;
+import com.gree.mall.manager.enums.quality.QualityFeedbackTypeEnum;
+import com.gree.mall.manager.exception.RemoteServiceException;
 import com.gree.mall.manager.logic.common.CommonLogic;
 import com.gree.mall.manager.plus.entity.QualityFeedback;
 import com.gree.mall.manager.plus.entity.QualityFeedbackItem;
+import com.gree.mall.manager.plus.service.AdminWebsitService;
 import com.gree.mall.manager.plus.service.QualityFeedbackItemService;
 import com.gree.mall.manager.plus.service.QualityFeedbackService;
 import com.gree.mall.manager.zfire.bean.ZfireParamBean;
 import com.gree.mall.manager.zfire.util.FieldUtils;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 @Service
 @Slf4j
@@ -32,6 +41,7 @@ public class QualityFeedbackLogic {
     private final CommonMapper commonMapper;
     private final QualityFeedbackService qualityFeedbackService;
     private final QualityFeedbackItemService qualityFeedbackItemService;
+    private final AdminWebsitService adminWebsitService;
 
     public IPage<QualityFeedbackVO> list(ZfireParamBean zfireParamBean) {
         AdminUserCom adminUser = commonLogic.getAdminUser();
@@ -74,12 +84,184 @@ public class QualityFeedbackLogic {
         return bean;
     }
 
-    public void add(QualityFeedbackCountBean bean) {
+    public void add(QualityFeedbackBean bean) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        this.checkRequireParams(bean);
+        bean.setStatus(ExamineQualityFeedbackStatusEnum.SAVE.getKey());
+        bean.insert();
+        for (QualityFeedbackItem item : bean.getItems()) {
+            item.setQualityFeedbckId(bean.getId());
+        }
+        qualityFeedbackItemService.saveBatch(bean.getItems());
+    }
+
+    private void checkRequireParams(QualityFeedbackBean bean) {
+        if (StringUtils.isBlank(bean.getWebsitId()) || StringUtils.isBlank(bean.getWebsitName())) {
+            throw new RemoteServiceException("反馈网点不能为空");
+        }
+        if (StringUtils.isBlank(bean.getTitle())) {
+            throw new RemoteServiceException("反馈主题不能为空");
+        }
+        if (StringUtils.isBlank(bean.getOrderNo())) {
+            throw new RemoteServiceException("云售后4.0工单号不能为空");
+        }
+        if (StringUtils.isBlank(bean.getWorkerName())) {
+            throw new RemoteServiceException("工程师名称不能为空");
+        }
+        if (StringUtils.isBlank(bean.getWorkerMobie())) {
+            throw new RemoteServiceException("工程师电话不能为空");
+        }
+        if (StringUtils.isBlank(bean.getCustomerName())) {
+            throw new RemoteServiceException("客户名称不能为空");
+        }
+        if (StringUtils.isBlank(bean.getCustomerMobile())) {
+            throw new RemoteServiceException("客户电话不能为空");
+        }
+        if (StringUtils.isBlank(bean.getProvince())) {
+            throw new RemoteServiceException("省份不能为空");
+        }
+        if (StringUtils.isBlank(bean.getCity())) {
+            throw new RemoteServiceException("城市不能为空");
+        }
+        if (StringUtils.isBlank(bean.getArea())) {
+            throw new RemoteServiceException("县区不能为空");
+        }
+        if (StringUtils.isBlank(bean.getStreet())) {
+            throw new RemoteServiceException("街道不能为空");
+        }
+        if (StringUtils.isBlank(bean.getAddress())) {
+            throw new RemoteServiceException("详细地址不能为空");
+        }
+        if (StringUtils.isBlank(bean.getMainId()) || StringUtils.isBlank(bean.getMainName())) {
+            throw new RemoteServiceException("产品大类不能为空");
+        }
+        if (StringUtils.isBlank(bean.getSmallId()) || StringUtils.isBlank(bean.getSmallName())) {
+            throw new RemoteServiceException("产品小类不能为空");
+        }
+        if (StringUtils.isBlank(bean.getSeriesName())) {
+            throw new RemoteServiceException("系列名称不能为空");
+        }
+        if (StringUtils.isBlank(bean.getProductName())) {
+            throw new RemoteServiceException("机型名称不能为空");
+        }
+        if (StringUtils.isBlank(bean.getInsideCode())) {
+            throw new RemoteServiceException("内机条码不能为空");
+        }
+        Integer count = qualityFeedbackService.lambdaQuery()
+                .eq(QualityFeedback::getInsideCode, bean.getInsideCode())
+                .ne(StringUtils.isNotBlank(bean.getId()), QualityFeedback::getId, bean.getId())
+                .count();
+        if (count > 0) {
+            throw new RemoteServiceException("内机条码在系统里已存在");
+        }
+        if ("空调,空气能热水器".contains(bean.getMainName()) && StringUtils.isBlank(bean.getOutCode())) {
+            throw new RemoteServiceException("外机条码不能为空");
+        }
+        if ("空调,空气能热水器".contains(bean.getMainName())) {
+            count = qualityFeedbackService.lambdaQuery()
+                    .eq(QualityFeedback::getOutCode, bean.getOutCode())
+                    .ne(StringUtils.isNotBlank(bean.getId()), QualityFeedback::getId, bean.getId())
+                    .count();
+            if (count > 0) {
+                throw new RemoteServiceException("外机条码在系统里已存在");
+            }
+        }
+        if (Objects.isNull(bean.getNum())) {
+            throw new RemoteServiceException("发生数量不能为空");
+        }
+        if (Objects.isNull(bean.getUseDate())) {
+            throw new RemoteServiceException("安装或使用日期不能为空");
+        }
+        if (Objects.isNull(bean.getRepairDate())) {
+            throw new RemoteServiceException("报修或发生日期不能为空");
+        }
+        if (Objects.isNull(bean.getIsPartSend())) {
+            throw new RemoteServiceException("有无配件寄回不能为空");
+        }
+        if (StringUtils.isBlank(bean.getBugPartCode())) {
+            throw new RemoteServiceException("故障代码不能为空");
+        }
+        if (Objects.isNull(bean.getIsNeedPlan())) {
+            throw new RemoteServiceException("是否需要处理方案不能为空");
+        }
+        if (Objects.isNull(bean.getSupplyDate())) {
+            throw new RemoteServiceException("要求提供日期不能为空");
+        }
+        if (StringUtils.isBlank(bean.getBugRemark())) {
+            throw new RemoteServiceException("故障描述不能为空");
+        }
+        if (StringUtils.isBlank(bean.getWebsitAnalyse())) {
+            throw new RemoteServiceException("网点人析不能为空");
+        }
+        if (StringUtils.isBlank(bean.getWebsitHandleMethod())) {
+            throw new RemoteServiceException("网点处理方法不能为空");
+        }
+        if (CollectionUtil.isEmpty(bean.getItems())) {
+            throw new RemoteServiceException("明细不能为空");
+        }
+        final Map<String, QualityFeedbackItem> itemMap = bean.getItems().stream()
+                .collect(Collectors.toMap(QualityFeedbackItem::getType, Function.identity(), (key1, key2) -> key2));
+        if (!itemMap.containsKey(QualityFeedbackTypeEnum.INSIDE_CODE.getKey())) {
+            throw new RemoteServiceException("上传图片内机条码图不能为空");
+        }
+        if ("空调,空气能热水器".contains(bean.getMainName())
+                && !itemMap.containsKey(QualityFeedbackTypeEnum.INSIDE_CODE.getKey())) {
+            throw new RemoteServiceException("上传图片外机条码图不能为空");
+        }
     }
 
-    public void update(QualityFeedbackCountBean bean) {
+    public void update(QualityFeedbackBean bean) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        QualityFeedback old = qualityFeedbackService.getById(bean.getId());
+
+        if (old.getStatus().equals(ExamineQualityFeedbackStatusEnum.WAIT.getKey())
+                || old.getStatus().equals(ExamineQualityFeedbackStatusEnum.OK.getKey())
+                || old.getStatus().equals(ExamineQualityFeedbackStatusEnum.FAIL.getKey())) {
+            throw new RemoteServiceException("单据状态非“保存”或“驳回可修改”不能修改");
+        }
+
+        if (bean.getStatus().equals(ExamineQualityFeedbackStatusEnum.WAIT.getKey())) {
+            bean.setSubmitBy(adminUser.getNickName())
+                    .setSubmitTime(DateUtil.date());
+        }
+        bean.updateById();
+        qualityFeedbackService.lambdaUpdate()
+                .set(QualityFeedback::getConfirmBy, null)
+                .set(QualityFeedback::getConfirmTime, null)
+                .eq(QualityFeedback::getId, bean.getId())
+                .update();
+        qualityFeedbackItemService.lambdaUpdate()
+                .eq(QualityFeedbackItem::getQualityFeedbckId, bean.getId())
+                .remove();
+        for (QualityFeedbackItem item : bean.getItems()) {
+            item.setQualityFeedbckId(bean.getId());
+        }
+        qualityFeedbackItemService.saveBatch(bean.getItems());
+    }
+
+    public void confirm(String id, String remark, ExamineQualityFeedbackStatusEnum status) {
+        AdminUserCom adminUser = commonLogic.getAdminUser();
+        if (adminUser.getType().equals(1)) {
+            throw new RemoteServiceException("非中心账号,审核失败");
+        }
+        if (status.getKey().equals(ExamineQualityFeedbackStatusEnum.SAVE.getKey())
+                || status.getKey().equals(ExamineQualityFeedbackStatusEnum.WAIT.getKey()) ) {
+            throw new RemoteServiceException("审核异常");
+        }
+        qualityFeedbackService.lambdaUpdate()
+                .set(QualityFeedback::getConfirmBy, adminUser.getNickName())
+                .set(QualityFeedback::getConfirmTime, DateUtil.date())
+                .set(QualityFeedback::getRemark, remark)
+                .eq(QualityFeedback::getId, id)
+                .eq(QualityFeedback::getStatus, ExamineQualityFeedbackStatusEnum.WAIT.getKey())
+                .update();
     }
 
-    public void confirm(String id, ExamineQualityFeedbackStatusEnum status) {
+    public void updateUpload(List<String> ids) {
+        qualityFeedbackService.lambdaUpdate()
+                .set(QualityFeedback::getId, ids)
+                .set(QualityFeedback::getIsUpload, true)
+                .ne(QualityFeedback::getStatus, ExamineQualityFeedbackStatusEnum.SAVE.getKey())
+                .update();
     }
 }