소스 검색

no message

FengChaoYu 3 달 전
부모
커밋
0b9f71a037

+ 9 - 4
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/controller/user/WorkerController.java

@@ -8,10 +8,7 @@ import com.gree.mall.miniapp.bean.policy.PolicyOrderDetail;
 import com.gree.mall.miniapp.bean.policy.WorkerRemind;
 import com.gree.mall.miniapp.helper.ResponseHelper;
 import com.gree.mall.miniapp.logic.policy.WorkerLogic;
-import com.gree.mall.miniapp.plus.entity.AdminWebsit;
-import com.gree.mall.miniapp.plus.entity.Agreement;
-import com.gree.mall.miniapp.plus.entity.Policy;
-import com.gree.mall.miniapp.plus.entity.PolicyOrder;
+import com.gree.mall.miniapp.plus.entity.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -155,4 +152,12 @@ public class WorkerController {
         return ResponseHelper.success(result);
     }
 
+    @PostMapping("/sign/confirm")
+    @ApiOperation(value = "师傅签名确认书")
+    public ResponseHelper<List<WorkerSignConfirm>> signConfirm(
+    ) throws Exception {
+        List<WorkerSignConfirm> result = workerLogic.signConfirm();
+        return ResponseHelper.success(result);
+    }
+
 }

+ 11 - 4
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/common/CommonLogic.java

@@ -264,10 +264,17 @@ public class CommonLogic {
             return null;
         }
 
-        String uploadFilePath = file.getOriginalFilename().replaceAll("\\\\", "/");
-        String uploadFileName = uploadFilePath.substring(
-                uploadFilePath.lastIndexOf('/') + 1, uploadFilePath.lastIndexOf('.'));
-        String uploadFileSuffix = uploadFilePath.substring(uploadFilePath.lastIndexOf('.') + 1, uploadFilePath.length());
+        String uploadFileSuffix = "";
+        String uploadFileName = "";
+        if (StringUtils.isNotBlank(file.getOriginalFilename())) {
+            String uploadFilePath = file.getOriginalFilename().replaceAll("\\\\", "/");
+            uploadFileName = uploadFilePath.substring(
+                    uploadFilePath.lastIndexOf('/') + 1, uploadFilePath.lastIndexOf('.'));
+            uploadFileSuffix = uploadFilePath.substring(uploadFilePath.lastIndexOf('.') + 1, uploadFilePath.length());
+        } else {
+            uploadFileName = "未定义";
+            uploadFileSuffix = "png";
+        }
         if (StringUtils.isNotBlank(uploadFileSuffix) && uploadFileSuffix.equals("quicktime")) {
             uploadFileSuffix = "mp4";
         }

+ 34 - 17
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/policy/WorkerLogic.java

@@ -3,7 +3,6 @@ package com.gree.mall.miniapp.logic.policy;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -12,6 +11,7 @@ import com.gree.mall.miniapp.bean.policy.PolicyDetail;
 import com.gree.mall.miniapp.bean.policy.PolicyOrderDetail;
 import com.gree.mall.miniapp.bean.policy.WorkerRemind;
 import com.gree.mall.miniapp.bean.user.CurrentCompanyWechat;
+import com.gree.mall.miniapp.constant.Constant;
 import com.gree.mall.miniapp.enums.ExamineWorkerStatusEnum;
 import com.gree.mall.miniapp.enums.IsYesNoEnum;
 import com.gree.mall.miniapp.enums.PolicyOrderStutasEnum;
@@ -28,11 +28,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.util.CollectionUtils;
-import org.springframework.util.FileCopyUtils;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
-import java.io.File;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Date;
@@ -86,6 +84,9 @@ public class WorkerLogic {
     @Autowired
     OCRUtil ocrUtil;
 
+    @Autowired
+    WorkerSignConfirmService workerSignConfirmService;
+
 
 
     public List<WorkerRemind> remind() {
@@ -621,22 +622,22 @@ public class WorkerLogic {
         if (!user.getType().equals(UserTypeEnum.WORKER.getKey())) {
             throw new RemoteServiceException("非“师傅”类型账号, 操作失败");
         }
-        String path = System.getProperty("user.dir");
+//        String path = System.getProperty("user.dir");
         // 生成的文件的存放路径
 
-        String mkdir = path + "/tmp/ocr/";
-        if (!FileUtil.exist(path + "/tmp/ocr/")) {
-            FileUtil.mkdir(path + "/tmp/ocr/");
-        }
+//        String mkdir = path + "/tmp/ocr/";
+//        if (!FileUtil.exist(path + "/tmp/ocr/")) {
+//            FileUtil.mkdir(path + "/tmp/ocr/");
+//        }
 
         // 创建文件
-        final String signFilePath = mkdir + signFile.getOriginalFilename();
+//        final String signFilePath = mkdir + joinFile.getOriginalFilename();
 //        File outputFile = new File(mkdir + "r" +signFile.getOriginalFilename());
-        File uploadFile = new File(signFilePath);
-        uploadFile.createNewFile();
+//        File uploadFile = new File(signFilePath);
+//        uploadFile.createNewFile();
 
         // 将文件写入磁盘
-        FileCopyUtils.copy(signFile.getBytes(), uploadFile);
+//        FileCopyUtils.copy(joinFile.getBytes(), uploadFile);
 
 //        Thumbnails.of(uploadFile).scale(1).rotate(-90).toFile(outputFile);
 //
@@ -657,15 +658,31 @@ public class WorkerLogic {
         if (!StrUtil.equals(name, user.getNickName().replace(" ", ""))) {
             return false;
         }
+
         final CommonFile commonFile = commonLogic.uploadFile(joinFile);
 
-        userService.lambdaUpdate()
-                .set(type.equals("gz"), User::getWorkerSignGz, commonFile.getUrl())
-                .set(type.equals("fs"), User::getWorkerSignFs, commonFile.getUrl())
-                .eq(User::getUserId, user.getUserId())
-                .update();
+        WorkerSignConfirm confirm = new WorkerSignConfirm();
+        confirm.setCompanyWechatId(currentCompanyWechat.getCompanyWechatId())
+                .setBelongCompanyCode(type.equals("gz") ? Constant.gree.GUANGZHOUXIAOSI : Constant.gree.FOSHANXIAOSI)
+                .setBelongCompanyName(type.equals("gz") ? "广州" : "佛山")
+                .setWorkerNumber(user.getWorkerNumber())
+                .setName(type.equals("gz") ? "广州嘉讯茂辅材费用确认书" : "佛山嘉讯茂辅材费用确认书")
+                .setUrl(commonFile.getUrl())
+                .insert();
+//        userService.lambdaUpdate()
+//                .set(type.equals("gz"), User::getWorkerSignGz, commonFile.getUrl())
+//                .set(type.equals("fs"), User::getWorkerSignFs, commonFile.getUrl())
+//                .eq(User::getUserId, user.getUserId())
+//                .update();
 
         return true;
     }
 
+    public List<WorkerSignConfirm> signConfirm() {
+        CurrentCompanyWechat currentCompanyWechat = commonLogic.getCurrentCompanyWechat();
+        return workerSignConfirmService.lambdaQuery()
+                .eq(WorkerSignConfirm::getCompanyWechatId, currentCompanyWechat.getCurrentCompanyWechatId())
+                .eq(WorkerSignConfirm::getWorkerNumber, currentCompanyWechat.getUser().getWorkerNumber())
+                .list();
+    }
 }

+ 20 - 5
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/user/UserLogic.java

@@ -131,6 +131,9 @@ public class UserLogic {
     @Autowired
     WorkerWarrantyRefundService workerWarrantyRefundService;
 
+    @Autowired
+    WorkerSignConfirmService workerSignConfirmService;
+
     /**
      * 微信小程序授权
      *
@@ -1026,18 +1029,30 @@ public class UserLogic {
                         .groupBy(AdminWebsit::getBelongCompanyCode)
                         .list();
                 if (CollectionUtil.isNotEmpty(adminWebsitList)) {
+                    final List<WorkerSignConfirm> signConfirms = workerSignConfirmService.lambdaQuery()
+                            .eq(WorkerSignConfirm::getCompanyWechatId, currentCompanyWechat.getCurrentCompanyWechatId())
+                            .eq(WorkerSignConfirm::getWorkerNumber, currentCompanyWechat.getUser().getWorkerNumber())
+                            .list();
+                    Map<String, WorkerSignConfirm> confirmMap = new HashMap<>();
+                    if (CollectionUtil.isNotEmpty(signConfirms)) {
+                        confirmMap = signConfirms.stream()
+                                .collect(Collectors.toMap(WorkerSignConfirm::getBelongCompanyCode, Function.identity()));
+                    }
                     final List<String> companyCodeList = adminWebsitList
                             .stream()
                             .map(AdminWebsit::getBelongCompanyCode)
                             .collect(Collectors.toList());
                     for (String code : companyCodeList) {
-                        if (code.equals(Constant.gree.GUANGZHOUXIAOSI) && StringUtils.isBlank(user.getWorkerSignGz())) {
+                        final WorkerSignConfirm signConfirm = confirmMap.get(code);
+                        if (Objects.isNull(signConfirm)) {
+                            if (code.equals(Constant.gree.GUANGZHOUXIAOSI)) {
 //                            throw new RemoteServiceException(ResponseHelper.ResponseCode_NOT_SIGN_G_PAY_CONFIRM, "广州未签支付确认书");
-                            userWxBean.setIsGZSign(true);
-                        }
-                        if (code.equals(Constant.gree.FOSHANXIAOSI) && StringUtils.isBlank(user.getWorkerSignFs())) {
+                                userWxBean.setIsGZSign(true);
+                            }
+                            if (code.equals(Constant.gree.FOSHANXIAOSI)) {
 //                            throw new RemoteServiceException(ResponseHelper.ResponseCode_NOT_SIGN_F_PAY_CONFIRM, "佛山未签支付确认书");
-                            userWxBean.setIsFSSign(true);
+                                userWxBean.setIsFSSign(true);
+                            }
                         }
                     }
                 }