Ver código fonte

Merge remote-tracking branch 'origin/feature/asyncOrder' into feature/asyncOrder

# Conflicts:
#	sp-service/async-server/src/main/java/com/pj/feign/AmqpTemplateFeign.java
#	sp-service/async-server/src/main/java/com/pj/task/HtByteTask.java
#	sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupService.java
#	sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserService.java
Mechrevo 1 ano atrás
pai
commit
d15ef024b6
29 arquivos alterados com 1537 adições e 1101 exclusões
  1. 8 0
      sp-core/sp-api/src/main/java/com/pj/api/client/async_server/AsyncServerInterface.java
  2. 6 0
      sp-core/sp-api/src/main/java/com/pj/api/client/async_server/AsyncServerInterfaceFallback.java
  3. 4 0
      sp-core/sp-api/src/main/java/com/pj/api/client/level_one_server/LevelOneServerInterface.java
  4. 5 0
      sp-core/sp-api/src/main/java/com/pj/api/client/level_one_server/LevelOneServerInterfaceFallback.java
  5. 81 0
      sp-core/sp-api/src/main/java/com/pj/api/dto/BorderDTO.java
  6. 96 0
      sp-core/sp-api/src/main/java/com/pj/api/dto/PeopleConfirmDTO.java
  7. 3 2
      sp-core/sp-base/src/main/java/com/pj/utils/ht/AESUtil.java
  8. 9 0
      sp-service/async-server/src/main/java/com/pj/feign/AmqpTemplateController.java
  9. 7 3
      sp-service/async-server/src/main/java/com/pj/feign/AmqpTemplateFeign.java
  10. 0 13
      sp-service/async-server/src/main/java/com/pj/rabbitmq/RabbitMQ.java
  11. 97 44
      sp-service/async-server/src/main/java/com/pj/task/HtByteTask.java
  12. 109 69
      sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlementService.java
  13. 7 0
      sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseService.java
  14. 7 0
      sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsService.java
  15. 87 80
      sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupService.java
  16. 12 1
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrder.java
  17. 26 31
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderController.java
  18. 5 7
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderMapper.xml
  19. 55 31
      sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderService.java
  20. 15 1
      sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleService.java
  21. 242 210
      sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopService.java
  22. 1 0
      sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeArea.java
  23. 236 198
      sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaService.java
  24. 5 42
      sp-service/sp-admin/src/main/java/com/pj/project/app_menu/AppMenuController.java
  25. 1 0
      sp-service/sp-admin/src/main/java/com/pj/project/app_menu/AppMenuMapper.java
  26. 3 10
      sp-service/sp-admin/src/main/java/com/pj/project/app_menu/AppMenuMapper.xml
  27. 1 1
      sp-service/sp-admin/src/main/java/com/pj/project/app_menu/AppMenuService.java
  28. 5 1
      sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUser.java
  29. 404 357
      sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserService.java

+ 8 - 0
sp-core/sp-api/src/main/java/com/pj/api/client/async_server/AsyncServerInterface.java

@@ -5,6 +5,7 @@ import com.pj.api.consts.FeignConsts;
 import com.pj.api.dto.ImportDeclarePeopleDto;
 import com.pj.api.dto.OrderDto;
 import com.pj.api.dto.OrdersDto;
+import com.pj.api.dto.PeopleConfirmDTO;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -39,7 +40,14 @@ public interface AsyncServerInterface {
     @RequestMapping("/async/rpc/sendLevelTwoOrdersDto")
     public void sendLevelTwoOrdersDto(@RequestBody OrdersDto t, @RequestParam("dataType")String dataType);
 
+    /**
+     * 发送边民确认信息
+     */
+    @RequestMapping("async/rpc/sendConfirm")
+    void sendConfirm(@RequestBody PeopleConfirmDTO confirmDTO);
+
     /** 远程调用: 根据便民身份证号 和 进出口结算单号查询[进口申报单边民确认] 将该对象返还航通 */
     @RequestMapping("/HtImportDeclarePeople/rpc/getByIdNoAndPreleportNo")
     public ImportDeclarePeopleDto getByIdNoAndPreleportNo(@RequestParam("idNo")String idNo, @RequestParam("preleportNo")String preleportNo);
+
 }

+ 6 - 0
sp-core/sp-api/src/main/java/com/pj/api/client/async_server/AsyncServerInterfaceFallback.java

@@ -4,6 +4,7 @@ import com.pj.api.client.cfg.SpCfgInterfaceFallback;
 import com.pj.api.dto.ImportDeclarePeopleDto;
 import com.pj.api.dto.OrderDto;
 import com.pj.api.dto.OrdersDto;
+import com.pj.api.dto.PeopleConfirmDTO;
 import feign.hystrix.FallbackFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -33,6 +34,11 @@ public class AsyncServerInterfaceFallback implements FallbackFactory<AsyncServer
             }
 
             @Override
+            public void sendConfirm(PeopleConfirmDTO confirmDTO) {
+
+            }
+
+            @Override
             public ImportDeclarePeopleDto getByIdNoAndPreleportNo(String idNo, String preleportNo) {
                 log.error("边民身份证:{},进出口预申报单号:{}",idNo,preleportNo);
                 return null;

+ 4 - 0
sp-core/sp-api/src/main/java/com/pj/api/client/level_one_server/LevelOneServerInterface.java

@@ -109,4 +109,8 @@ public interface LevelOneServerInterface {
     /** 根据航通主键查询appUser */
     @RequestMapping("/TbPeople/rpc/getAppUserByBorderPutrecNo")
     public AppUserDto getAppUserByBorderPutrecNo(@RequestParam("borderPutrecNo") String borderPutrecNo);
+
+    /** 系统接收到航通接口信息:车辆已出一级市场 ,修改相对应的一级市场订单状态 **/
+    @RequestMapping("/TbOrder/rpc/orderFinish")
+    public boolean orderFinish(@RequestParam("billCode") String billCode);
 }

+ 5 - 0
sp-core/sp-api/src/main/java/com/pj/api/client/level_one_server/LevelOneServerInterfaceFallback.java

@@ -169,6 +169,11 @@ public class LevelOneServerInterfaceFallback implements FallbackFactory<LevelOne
                 log.error("根据航通主键查询appUser错误,当前对象:{},错误信息是:{}",borderPutrecNo,throwable.getMessage());
                 return null;
             }
+
+            @Override
+            public boolean orderFinish(String billCode) {
+                return false;
+            }
         };
     }
 }

+ 81 - 0
sp-core/sp-api/src/main/java/com/pj/api/dto/BorderDTO.java

@@ -0,0 +1,81 @@
+package com.pj.api.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ { "borderNo":"序号",
+ "borderPutrecNo":"边民备案编号",
+ "borderName":"边民姓名",
+ "ciphertextIdno":"边民身份证号",
+ "borderAddr":"户籍地址",
+ "borderTel":"手机号码",
+ "groupId":"本系统中互助组 id"
+ }
+ *
+ */
+public class BorderDTO {
+
+    private String borderNo;
+    private String borderPutrecNo;
+    private String borderName;
+    private String ciphertextIdno;
+    private String borderAddr;
+    private String borderTel;
+    private String groupId;
+
+    public String getBorderNo() {
+        return borderNo;
+    }
+
+    public void setBorderNo(String borderNo) {
+        this.borderNo = borderNo;
+    }
+
+    public String getBorderPutrecNo() {
+        return borderPutrecNo;
+    }
+
+    public void setBorderPutrecNo(String borderPutrecNo) {
+        this.borderPutrecNo = borderPutrecNo;
+    }
+
+    public String getBorderName() {
+        return borderName;
+    }
+
+    public void setBorderName(String borderName) {
+        this.borderName = borderName;
+    }
+
+    public String getCiphertextIdno() {
+        return ciphertextIdno;
+    }
+
+    public void setCiphertextIdno(String ciphertextIdno) {
+        this.ciphertextIdno = ciphertextIdno;
+    }
+
+    public String getBorderAddr() {
+        return borderAddr;
+    }
+
+    public void setBorderAddr(String borderAddr) {
+        this.borderAddr = borderAddr;
+    }
+
+    public String getBorderTel() {
+        return borderTel;
+    }
+
+    public void setBorderTel(String borderTel) {
+        this.borderTel = borderTel;
+    }
+
+    public String getGroupId() {
+        return groupId;
+    }
+
+    public void setGroupId(String groupId) {
+        this.groupId = groupId;
+    }
+}

+ 96 - 0
sp-core/sp-api/src/main/java/com/pj/api/dto/PeopleConfirmDTO.java

@@ -0,0 +1,96 @@
+package com.pj.api.dto;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+
+
+public class PeopleConfirmDTO {
+
+    /**
+     * 边民身份证
+     */
+    private String idno;
+    /**
+     * 边民备案编号(可选)
+     */
+    private String borderPutrecNo;
+    /**
+     * : "边民姓名不能为空"
+     */
+    private String borderName;
+    /**
+     * "结算单号"
+     */
+    private String settleBillNo;
+    /**
+     * "进出口预申报单号",
+     */
+    @JsonProperty("preIeportNo")
+    private String preIeportNo;
+    /**
+     * : "购买申报确认状态:Y->确认购买申报,N->不购买申报",
+     */
+    @JsonProperty("buyConfirmStatus")
+    private String buyConfirmStatus="Y";
+    /**
+     * "支付状态:01->未支付,02->已支付"
+     */
+    @JsonProperty("payStatus")
+    private String payStatus="02";
+
+    public String getIdno() {
+        return idno;
+    }
+
+    public void setIdno(String idno) {
+        this.idno = idno;
+    }
+
+    public String getBorderPutrecNo() {
+        return borderPutrecNo;
+    }
+
+    public void setBorderPutrecNo(String borderPutrecNo) {
+        this.borderPutrecNo = borderPutrecNo;
+    }
+
+    public String getBorderName() {
+        return borderName;
+    }
+
+    public void setBorderName(String borderName) {
+        this.borderName = borderName;
+    }
+
+    public String getSettleBillNo() {
+        return settleBillNo;
+    }
+
+    public void setSettleBillNo(String settleBillNo) {
+        this.settleBillNo = settleBillNo;
+    }
+
+    public String getPreIeportNo() {
+        return preIeportNo;
+    }
+
+    public void setPreIeportNo(String preIeportNo) {
+        this.preIeportNo = preIeportNo;
+    }
+
+    public String getBuyConfirmStatus() {
+        return buyConfirmStatus;
+    }
+
+    public void setBuyConfirmStatus(String buyConfirmStatus) {
+        this.buyConfirmStatus = buyConfirmStatus;
+    }
+
+    public String getPayStatus() {
+        return payStatus;
+    }
+
+    public void setPayStatus(String payStatus) {
+        this.payStatus = payStatus;
+    }
+}

+ 3 - 2
sp-core/sp-base/src/main/java/com/pj/utils/ht/AESUtil.java

@@ -198,7 +198,7 @@ public class AESUtil {
 
         }else {
             LOGGER.info("AES_CBC decrypt: the aesKey is null or error!");
-            return null;
+            return "{}";
         }
     }
 
@@ -233,7 +233,8 @@ public class AESUtil {
 
 边民: CkB9nBTgtwQYyW+/luLX0BdXYHTdcBMnQRnN1BHVWDjXd1Gqt9Yl3M/lI5WxljI39cJa3XTmWT3WH/zQpG4AZsqbSb1TO8f43+UgdQRfJqChYy69B2JZsV0856REEBb7h89mYXyCTHl3eeImf/Ilw8Xq5XQ6cc0WV4/AltZLVj9AiCqi0YV2PY7FXjl6nP/gboh3T+Z+LxNmY/iTk5oUUhaIxt+PFitgkEkOeZrTP3NhLxtaAPwoFxDmPGSZEWWDLgJSdvJeYMUKPz+sL12ybzMVudqo6B2lYUDCWpcQ4L6pGJaXH7qBwUPyOxFn2Nf7FTHNxC3UkIrVNLeAfxf0CctLnnmJALY97bRQu7iuAcojh/zvQV91u3L4lek0xyiKSiVcNSdBbPG4zNPnv/ocWouphcV6IY2ncoP0RBQFVqsD9q5l5kC05q6XWqDkE3BM/WkqeWvh49epGb9SwUzoD0NpQXqqQAUpW0dE+KLWwb7QdWOi626epPZ9XxyJcyDS
 
-商铺: CkB9nBTgtwQYyW+/luLX0P7AN7AG9vhXlSNzkpfp33/HoZX6MjrrBrQnRJkKy1nOeahRTV90bkIZYymuy9iUlegyIOwF/W2eEBQTJqBde3zTZT9BLDiua1cdaS3vFsOuzB4VZ+jwkcmwppw18uscw8DDT0Ay/YHCXCalecLrlqYKu9Ahi3bX/0QqoKoI2x0Rx1rAObdsK22eBrbw+U82M4Jm+B5wPoKVbyotP2WN3RecYkG7LxuXphob2HtJYM8ot86y3PqqactXBWF/10FHSWdyAhTT1eDeA2TCsTQmAoHUIvVUT5j9eLB9BkuEPBXDokkZTrTEJ2T+ntU7YOS3eOeLhhc80EKjIw+RULHlD4y2HKrL5F7rSU2bFfpz53sghDdlyTmSNqrz9Fd3K/FpJ68DLSRhTDJxDwqXD+W6rgiS+LaYjIli+pGq/cFHxGkv9HU7wtbQXbWcuh2wBp7aXTVdlt0qrWQbiozu6K+KDFn2I/ySYzaqW41KuLlHkxFoxXdZ+EjGz3fp/OuYWybuF8JBnbvyU/B8uuKt/WM4nBgJpa3+pALVV8w4xF/UJTAahqJX195MlNmOWhN4clj7SHY6m5ludW1onuEkeZNiC8iY814v+htzubqfyBs4vQ5USLRk7SMRGXwvwLHTkUt/rZfX3nlwEMn5fLziL/2Md7+79nAr+3rivVxBF14Puqbgz0NADFKgfaNoP53vkw0QlWZH/P4Mqjw2wCqGeF4Uk0Cng8+9hG9bMVha7+97ZM0ZHUpRizga57NsZ/8QmnCM8C0dnHEwqBNBHI7AF6POZiAApZ+72vwS5zSY/k/lM+t2ci9UZbvnddImuHJUqLuDq6fKnNKm8tkFx5+WUfreD0Y=
+商铺:
+CkB9nBTgtwQYyW+/luLX0P7AN7AG9vhXlSNzkpfp33/HoZX6MjrrBrQnRJkKy1nOeahRTV90bkIZYymuy9iUlegyIOwF/W2eEBQTJqBde3zTZT9BLDiua1cdaS3vFsOuzB4VZ+jwkcmwppw18uscw8DDT0Ay/YHCXCalecLrlqYKu9Ahi3bX/0QqoKoI2x0Rx1rAObdsK22eBrbw+U82M4Jm+B5wPoKVbyotP2WN3RecYkG7LxuXphob2HtJYM8ot86y3PqqactXBWF/10FHSWdyAhTT1eDeA2TCsTQmAoHUIvVUT5j9eLB9BkuEPBXDokkZTrTEJ2T+ntU7YOS3eOeLhhc80EKjIw+RULHlD4y2HKrL5F7rSU2bFfpz53sghDdlyTmSNqrz9Fd3K/FpJ68DLSRhTDJxDwqXD+W6rgiS+LaYjIli+pGq/cFHxGkv9HU7wtbQXbWcuh2wBp7aXTVdlt0qrWQbiozu6K+KDFn2I/ySYzaqW41KuLlHkxFoxXdZ+EjGz3fp/OuYWybuF8JBnbvyU/B8uuKt/WM4nBgJpa3+pALVV8w4xF/UJTAahqJX195MlNmOWhN4clj7SHY6m5ludW1onuEkeZNiC8iY814v+htzubqfyBs4vQ5USLRk7SMRGXwvwLHTkUt/rZfX3nlwEMn5fLziL/2Md7+79nAr+3rivVxBF14Puqbgz0NADFKgfaNoP53vkw0QlWZH/P4Mqjw2wCqGeF4Uk0Cng8+9hG9bMVha7+97ZM0ZHUpRizga57NsZ/8QmnCM8C0dnHEwqBNBHI7AF6POZiAApZ+72vwS5zSY/k/lM+t2ci9UZbvnddImuHJUqLuDq6fKnNKm8tkFx5+WUfreD0Y=
 
 合作社: CkB9nBTgtwQYyW+/luLX0BtPplfW1jkmOD/o8lfxzhnOP0jYRBRuyQ5rRGy6NeExhu93qxbkDnYIm5+GKCUB2TGqWnQJRS/h/LOG978Qb6AJL4ErgKiLrFVR9oBUm5PlznQdCZYqzXx+iufMnoni+yb5QnHm8yMcvenKyuzL/EvVL7jSau1oYJ5tN8tDWLFxVykBtpdjPuyOIH02yslkc/s+PXpO8YYMu3VK42ILu45bkHfH5TwtEKFE13LhaiRYv0fR/OqNlGogjn+ynW6EP7HvibB1JXKGkHKrmwTrvuZKja3s/B9x905LYMW2UFwL4tI1opP/eCS1byGXFfYuAnOvbPmT4W28ufAnrPWRwhU6Pw5m75WUFivuJpkYXdcr2cUtAWiwAjm54aMniVJ5U31e6XB2I4q+vRV/BamzCj5AEO5faP50sDUjD9Yq8xPF8gjL85kUYvDzH+jlzvAGYqT9wV9gWjQU40Uw9aTN6ElMpOjX3T6eFAWgnIrvdtvGF/UWj/zH+fb8M6CxAvigjts96iMRIiiYNRC8BBqDGob+R3dqCgHlEQmAhu61Wt0Qie7pJGVopr2/xnhwnBjxDSpg1vY9uEGGQVXXXg5Ap7KwYFpHyfOxXQxp2DiVGRrf+Cyg5TCe8huID0nrh97HxYp4GyQ9zcJ/WCcgqHRMD2AiWqDSbpLcBukaCQFvKhnoBPY/l83RGMQqG1pYQ41BvOUtSoqcGwgpMbSnAOoHwYt4lf1nH1k5jzTNrPfe8vrmg/VPXJWihbxzNKZetj0y7NuYQ17CLC3Qn1UJh17QHqLyRBHWfnJN4l2AkaNPzcQFfy0GL82FMGQ2ezb0uLjjHyF87Ve58p+QvcW7hLuRrVjG/PSCx7FukSvrCjzWTyWp9AK8uSu3Rt5xNrepptTQfypZpZP1bwc9j6WlXS8CJ8z1B6Do0BT7CxbMmaY4ngsKpIpgr5mBWSFU3+MME98ECmgBRi6niJzmHibsso6gERdrycIuCulWInW1fNlPqCPc4s0SXaugK6mBJbZ+qC3xZvH0P4XPd+eYrOzbM7DBVXEpifCcOvn8KxjQcfg7W+A2twe+ZlnMrfbUXrPhLHX+wy4+1P1HDWEMgnxYm6nM4wa2RYsN4nvgu98ZN3FAsJFJaUeSRjq6M4bJwrorCbfoL236qgcWwsyuyWgWqC8JbWeTTGzz72813XLTaiwSy8H+nsXvASGN+vCn7cCpWcbaZpuqdfxbHTuQ38XwjNmGACfv9jkbTrFlK//DvfJLJUugc68oR8QHfJThdmPZB5mM/3PEDVB+bYfSBfGYVURtOKi02n4j1cM5GqG//m/TZXvYflKJ5RKJKSMegnSxNgal1RajAdSo3C8vc+puBaP3b7GSPumDWbH+SjuasCUBwRMAh/xXH6wjKjyJC7T0hTc5JR/yPDZRJApKWvT27HjSLhFnNHIlJOAdLQ+NWk8L6hS2
 

+ 9 - 0
sp-service/async-server/src/main/java/com/pj/feign/AmqpTemplateController.java

@@ -3,6 +3,7 @@ package com.pj.feign;
 
 import com.pj.api.dto.OrderDto;
 import com.pj.api.dto.OrdersDto;
+import com.pj.api.dto.PeopleConfirmDTO;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -43,4 +44,12 @@ public class AmqpTemplateController {
         amqpTemplateFeign.sendObject(t,dataType);
     }
 
+    /**
+     * 边民确认-->发给航通
+     * @param confirmDTO
+     */
+    @RequestMapping("rpc/sendConfirm")
+    public void sendConfirm(@RequestBody PeopleConfirmDTO confirmDTO){
+        amqpTemplateFeign.sendObject(confirmDTO,"008");
+    }
 }

+ 7 - 3
sp-service/async-server/src/main/java/com/pj/feign/AmqpTemplateFeign.java

@@ -9,6 +9,7 @@ import com.pj.rabbitmq.RabbitMQ;
 import com.pj.utils.IdWorker;
 import com.pj.utils.MD5;
 import com.pj.utils.ht.AESUtil;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.amqp.core.AmqpTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -21,17 +22,19 @@ import java.util.Date;
  * @Date 2023 08 29 13 08
  **/
 @Service
+@Slf4j
 public class AmqpTemplateFeign {
 
     @Autowired
     private AmqpTemplate amqpTemplate;
 
     /**
-     * 数据加密发送对象至航通
+     * 发送对象至航通
      * @param t
      * @param dataType
      */
-    public<T> void sendObject(T t, String dataType){
+    public <T> void sendObject(T t, String dataType) {
+        log.info("send data to ht:{},{}", dataType,JSON.toJSONString(t));
         //todo: 数据暂时定死
         DataDto dataDto = new DataDto();
         //msgId
@@ -57,7 +60,8 @@ public class AmqpTemplateFeign {
         dataDto.setSign(sign);
 
         //mq发送信息
-        amqpTemplate.convertAndSend(RabbitMQ.TEST_SEND_QUEUE,dataDto);
+        amqpTemplate.convertAndSend(RabbitMQ.TEST_SEND_QUEUE, dataDto);
+        log.info("send mq msg finish:{},{}", dataType,JSON.toJSONString(t));
     }
 
     /**

+ 0 - 13
sp-service/async-server/src/main/java/com/pj/rabbitmq/RabbitMQ.java

@@ -31,21 +31,8 @@ public class RabbitMQ {
      */
     public static final String TEST_ACCEPT_ROUTING_KEY = "testSendKey";
 
-    /**
-     *  发送方MQ地址
-     */
-    public static final String MQ_ADDRESS = "192.168.0.23";
 
     /**
-     *  发送方MQ账号
-     */
-    public static final String MQ_SEND_USERNAME = "hdx";
-
-    /**
-     *  发送方MQ密码
-     */
-    public static final String MQ_SEND_PASSWORD = "hdx";
-    /**
      *  发送方MQ交换机名称
      */
     public static final String MQ_DIRECT_EXCHANGE = "test_exchange";

+ 97 - 44
sp-service/async-server/src/main/java/com/pj/task/HtByteTask.java

@@ -1,9 +1,14 @@
 package com.pj.task;
 
+import cn.hutool.json.JSONUtil;
+import cn.hutool.log.StaticLog;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson2.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.pj.api.client.async_server.AsyncServerInterface;
 import com.pj.api.client.level_one_server.LevelOneServerInterface;
+import com.pj.api.client.transport.TransportInterface;
+import com.pj.api.consts.FeignFactory;
 import com.pj.api.dto.*;
 import com.pj.common.core.exception.ServiceException;
 import com.pj.dto.DataDto;
@@ -11,6 +16,7 @@ import com.pj.api.dto.HtGoodsDto;
 import com.pj.enummj.FinishStatus;
 import com.pj.feign.AmqpTemplateFeign;
 import com.pj.ht_border_buy_goods_list.HtBorderBuyGoodsListMapper;
+import com.pj.ht_borders_list.HtBordersList;
 import com.pj.ht_borders_list.HtBordersListMapper;
 import com.pj.ht_byte.HtByte;
 import com.pj.ht_byte.HtByteMapper;
@@ -18,6 +24,7 @@ import com.pj.ht_import_declare_people.HtImportDeclarePeople;
 import com.pj.ht_import_declare_people.HtImportDeclarePeopleMapper;
 import com.pj.ht_pass_card_record.HtPassCardRecord;
 import com.pj.ht_pass_card_record.HtPassCardRecordMapper;
+import com.pj.ht_sell_goods_list.HtSellGoodsList;
 import com.pj.ht_sell_goods_list.HtSellGoodsListMapper;
 import com.pj.ht_trade_settlement.HtTradeSettlement;
 import com.pj.ht_trade_settlement.HtTradeSettlementMapper;
@@ -32,6 +39,7 @@ import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -50,11 +58,7 @@ public class HtByteTask {
      */
     @Autowired
     private HtByteMapper htByteMapper;
-    /**
-     * 一级市场
-     */
-    @Autowired
-    private LevelOneServerInterface levelOneServerInterface;
+
     /**
      * 交易结算信息
      */
@@ -90,39 +94,33 @@ public class HtByteTask {
      */
     @Autowired
     private HtSellGoodsListMapper htSellGoodsListMapper;
-    /**
-     *
-     */
-    @Autowired
-    private AmqpTemplateFeign amqpTemplateFeign;
 
     /**
      * 启动定时任务
-     *
-     *      * 报文类型
-     *      * 001=边民备案
-     *      * 002=商铺备案
-     *      * 003=边民互助组备案
-     *      * 004=边民合作社备案
-     *      * 005=商品基础信息
-     *      * 006=交易结算信息
-     *      * 007=放行记录(过卡记录)
+     * <p>
+     * * 报文类型
+     * * 001=边民备案
+     * * 002=商铺备案
+     * * 003=边民互助组备案
+     * * 004=边民合作社备案
+     * * 005=商品基础信息
+     * * 006=交易结算信息
+     * * 007=放行记录(过卡记录)
      */
     @Scheduled(cron = "*/9 * * * * ?")  // 测试阶段,每9秒扫描一次
     private void htByteTask(){
         /*  测试mq */
-//        OrderDto orderDtoById = levelOneServerInterface.getOrderDtoById(4L);
+//        OrderDto orderDtoById = levelOneServerInterface.getOrderDtoById(8833342005355478419L);
 //        asyncServerInterface.sendLevelOneOrderDto(orderDtoById, DataType.DATA_TYPE_ONE.getCode());
-
         /*  测试mq */
-//        扫描表内是否有待处理任务
+        //扫描表内是否有待处理任务
         List<HtByte> byteList = htByteMapper.selectList(new LambdaQueryWrapper<HtByte>().eq(HtByte::getFinishStatus, FinishStatus.FINISH_STATUS_ZERO.getCode()));
-//        判断是否有任务,没有则返回
-        if(byteList.size() == 0){
+        //判断是否有任务,没有则返回
+        if (byteList.size() == 0) {
             System.out.println("\n  ---  暂无待处理任务。" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + "\n");
             return;
         }
-//        执行任务处理流程
+        //执行任务处理流程
         byteList.forEach(item -> {
             //对象转换
             DataDto dataDto = JSONObject.parseObject(item.getBody(), DataDto.class);
@@ -136,11 +134,11 @@ public class HtByteTask {
             switch (dataDto.getDataType()){
                 case "001":
                     //对象转换
-                    HtPeopleDto peopleDto = JSONObject.parseObject(body, HtPeopleDto.class);
+                    PeopleDto peopleDto = JSONObject.parseObject(body, PeopleDto.class);
                     //根据其内的身份证,有则新增,无则修改???
-                    flag = levelOneServerInterface.peopleDto(peopleDto);
-                    methodHtByteTask.updateHtByteInfo(flag,item,dataDto);
-                    if(!flag){
+                    flag = FeignFactory.levelOneServerInterface.peopleDto(peopleDto);
+                    methodHtByteTask.updateHtByteInfo(flag, item, dataDto);
+                    if (!flag) {
                         System.out.println("\n边民信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     }else {
                         System.out.println("\n边民信息处理成功。 messageId = " + item.getMessageId() + "\n");
@@ -150,9 +148,9 @@ public class HtByteTask {
                     //商铺备案
                     ShopDto shopDto = JSONObject.parseObject(body, ShopDto.class);
                     //保存
-                    flag = levelOneServerInterface.shopDto(shopDto);
-                    methodHtByteTask.updateHtByteInfo(flag,item,dataDto);
-                    if(!flag){
+                    flag = FeignFactory.levelOneServerInterface.shopDto(shopDto);
+                    methodHtByteTask.updateHtByteInfo(flag, item, dataDto);
+                    if (!flag) {
                         System.out.println("\n店铺信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     }else {
                         System.out.println("\n店铺信息处理完成。 messageId = " + item.getMessageId() + "\n");
@@ -162,9 +160,9 @@ public class HtByteTask {
                     //边民互助组备案
                     GroupDto groupDto = JSONObject.parseObject(body, GroupDto.class);
                     //保存
-                    flag = levelOneServerInterface.groupDto(groupDto);
-                    methodHtByteTask.updateHtByteInfo(flag,item,dataDto);
-                    if(!flag){
+                    flag = FeignFactory.levelOneServerInterface.groupDto(groupDto);
+                    methodHtByteTask.updateHtByteInfo(flag, item, dataDto);
+                    if (!flag) {
                         System.out.println("\n互助组信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     }else {
                         System.out.println("\n互助组信息处理完成。 messageId = " + item.getMessageId() + "\n");
@@ -174,9 +172,9 @@ public class HtByteTask {
                     //边民合作社备案
                     CooperativeDto cooperativeDto = JSONObject.parseObject(body, CooperativeDto.class);
                     //保存
-                    flag = levelOneServerInterface.cooperativeDto(cooperativeDto);
-                    methodHtByteTask.updateHtByteInfo(flag,item,dataDto);
-                    if(!flag){
+                    flag = FeignFactory.levelOneServerInterface.cooperativeDto(cooperativeDto);
+                    methodHtByteTask.updateHtByteInfo(flag, item, dataDto);
+                    if (!flag) {
                         System.out.println("\n边民合作社信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     }else {
                         System.out.println("\n边民合作社信息处理完成。 messageId = " + item.getMessageId() + "\n");
@@ -186,9 +184,9 @@ public class HtByteTask {
                     //商品基础信息
                     HtGoodsDto goodsDto = JSONObject.parseObject(body, HtGoodsDto.class);
                     //保存
-                    flag = levelOneServerInterface.goodsDto(goodsDto);
-                    methodHtByteTask.updateHtByteInfo(flag,item,dataDto);
-                    if(!flag){
+                    flag = FeignFactory.levelOneServerInterface.goodsDto(goodsDto);
+                    methodHtByteTask.updateHtByteInfo(flag, item, dataDto);
+                    if (!flag) {
                         System.out.println("\n海关监管商品信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     }else {
                     System.out.println("\n海关监管商品信息处理完成。 messageId = " + item.getMessageId() + "\n");
@@ -197,6 +195,10 @@ public class HtByteTask {
                 case "006":
                     //交易结算信息
                     HtTradeSettlement importDeclarePeople = JSONObject.parseObject(body, HtTradeSettlement.class);
+                    if (importDeclarePeople==null||!importDeclarePeople.getIEFlag().toLowerCase().contains("i")) {
+                        StaticLog.info("出口商品,暂时忽略:{}", body);
+                        break;
+                    }
                     importDeclarePeople.setFinishStatus(FinishStatus.FINISH_STATUS_ZERO.getCode()); // 默认待处理
                     importDeclarePeople.setCreateTime(new Date());
                     //保存
@@ -208,14 +210,59 @@ public class HtByteTask {
                         //边民购买商品列表
                         List<BorderBuyGoodsListDto> buyGoodsList = JSON.parseArray(importDeclarePeople.getBorderBuyGoodsList(), BorderBuyGoodsListDto.class);
                         //商铺卖货物列表
-//                        List<SellGoodsListDto> htSellGoodsList = JSON.parseArray(importDeclarePeople.getSellGoodsList(), SellGoodsListDto.class);
+                        List<HtSellGoodsList> htSellGoodsList = JSON.parseArray(importDeclarePeople.getSellGoodsList(), HtSellGoodsList.class);
+                        //航通关联主键
+                        String platSeqNo = importDeclarePeople.getPlatSeqNo();
+                        //保存购买边民
+                        List<BordersListDto> bordersListDtoList = new ArrayList<>();
+                        if(bordersLists.size() > 0){
+                            bordersLists.forEach(t -> {
+//                                t.setCreateTime(new Date());
+//                                t.setFinishStatus(FinishStatus.FINISH_STATUS_ZERO.getCode());
+//                                htBordersListMapper.insert(t);
+                                BordersListDto bordersListDto = new BordersListDto();
+                                BeanUtils.copyProperties(t,bordersListDto);
+                                bordersListDtoList.add(bordersListDto);
+                            });
+                        /**
+                         * 接收订单推送消息,边民进行交易确认,支付申请,刷脸认证,系统发起进行交易
+                         */
+                            List<HtBordersList> htBordersLists = htBordersListMapper.selectList(new LambdaQueryWrapper<HtBordersList>().eq(HtBordersList::getPlatSeqNo, platSeqNo));
+                            methodHtByteTask.sendMessageToPeople(htBordersLists);
+                        }
+                        //保存边民购买商品
+                        List<BorderBuyGoodsListDto> borderBuyGoodsListDtoList = new ArrayList<>();
+                        if(buyGoodsList.size() > 0){
+                            buyGoodsList.forEach(t -> {
+//                                t.setCreateTime(new Date());
+//                                t.setFinishStatus(FinishStatus.FINISH_STATUS_ZERO.getCode());
+//                                htBorderBuyGoodsListMapper.insert(t);
+                                BorderBuyGoodsListDto borderBuyGoodsListDto = new BorderBuyGoodsListDto();
+                                BeanUtils.copyProperties(t,borderBuyGoodsListDto);
+                                borderBuyGoodsListDtoList.add(borderBuyGoodsListDto);
+                            });
+                            // ???
+                        }
+                        //保存商铺卖货物
+                        List<SellGoodsListDto> sellGoodsListDtoList = new ArrayList<>();
+                        if(htSellGoodsList.size() > 0){
+                            htSellGoodsList.forEach(t -> {
+//                                t.setCreateTime(new Date());
+//                                t.setFinishStatus(FinishStatus.FINISH_STATUS_ZERO.getCode());
+//                                htSellGoodsListMapper.insert(t);
+                                SellGoodsListDto sellGoodsListDto = new SellGoodsListDto();
+                                BeanUtils.copyProperties(t,sellGoodsListDto);
+                                sellGoodsListDtoList.add(sellGoodsListDto);
+                            });
+                            // ???
+                        }
                         //保存航通监听记录
                         methodHtByteTask.updateHtByteInfo(true,item,dataDto);
                         TradeSettlementDto tradeSettlementDto = new TradeSettlementDto();
                         BeanUtils.copyProperties(importDeclarePeople,tradeSettlementDto);
                         tradeSettlementDto.setId(primarykey);
-                        tradeSettlementDto.setBordersListDtoList(bordersLists);
-                        tradeSettlementDto.setBorderBuyGoodsListDtoList(buyGoodsList);
+                        tradeSettlementDto.setBordersListDtoList(bordersListDtoList);
+                        tradeSettlementDto.setBorderBuyGoodsListDtoList(borderBuyGoodsListDtoList);
                         boolean b = levelOneServerInterface.tradeSettlementDto(tradeSettlementDto);
                         if(!b)throw new ServiceException("添加错误;");
                         System.out.println("\n交易结算信息处理成功。 messageId = " + item.getMessageId() + "\n");
@@ -238,6 +285,12 @@ public class HtByteTask {
                     }else {
                         System.out.println("\n放行记录(过卡记录)信息处理失败。 messageId = " + item.getMessageId() + "\n");
                     }
+
+                    //系统接收到航通过卡记录且卡口类型为'3卡':车辆已出一级市场, 修改相对应的一级市场订单状态
+                    if("3卡".equals(htPassCardRecord.getChannelType())) {
+                        FeignFactory.levelOneServerInterface.orderFinish(htPassCardRecord.getBillCode());
+                    }
+
                     break;
                 case "008":
                     //进口申报单边民确认

+ 109 - 69
sp-service/level-one-server/src/main/java/com/pj/ht_trade_settlement/HtTradeSettlementService.java

@@ -6,101 +6,141 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pj.api.dto.BorderBuyGoodsListDto;
 import com.pj.api.dto.BordersListDto;
 import com.pj.api.dto.TradeSettlementDto;
+import com.pj.current.config.SystemObject;
 import com.pj.enummj.*;
+import com.pj.tb_goods.TbGoods;
+import com.pj.tb_goods.TbGoodsService;
 import com.pj.tb_order.TbOrder;
 import com.pj.tb_order.TbOrderMapper;
 import com.pj.tb_people.TbPeople;
 import com.pj.tb_people.TbPeopleMapper;
+import com.pj.tb_people.TbPeopleService;
+import com.pj.tb_shop.TbShop;
+import com.pj.tb_shop.TbShopService;
+import com.pj.tb_trade_area.TbTradeArea;
+import com.pj.tb_trade_area.TbTradeAreaService;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.util.Date;
 import java.util.List;
 
 /**
  * Service: ht_trade_settlement -- 航通交易结算表
- * @author yzs 
+ *
+ * @author yzs
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
-public class HtTradeSettlementService extends ServiceImpl<HtTradeSettlementMapper, HtTradeSettlement> implements IService<HtTradeSettlement>{
+public class HtTradeSettlementService extends ServiceImpl<HtTradeSettlementMapper, HtTradeSettlement> implements IService<HtTradeSettlement> {
 
-	/** 底层 Mapper 对象 */
-	@Autowired
-	HtTradeSettlementMapper htTradeSettlementMapper;
-	@Autowired
-	private TbPeopleMapper tbPeopleMapper;
-	@Autowired
-	private TbOrderMapper tbOrderMapper;
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    HtTradeSettlementMapper htTradeSettlementMapper;
+    @Autowired
+    private TbPeopleService tbPeopleService;
+    @Autowired
+    private TbOrderMapper tbOrderMapper;
 
-	/** 增 */
-	void add(HtTradeSettlement h){
-		save(h);
-	}
+    @Resource
+    private TbTradeAreaService tbTradeAreaService;
+    @Resource
+    private TbGoodsService tbGoodsService;
+    @Resource
+    private TbShopService tbShopService;
 
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
+    /**
+     * 增
+     */
+    void add(HtTradeSettlement h) {
+        save(h);
+    }
 
-	/** 改 */
-	void update(HtTradeSettlement h){
-		updateById(h);
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
 
-	}
+    /**
+     * 改
+     */
+    void update(HtTradeSettlement h) {
+        updateById(h);
 
-	/** 查 */
-	HtTradeSettlement getById(String platSeqNo){
-		return super.getById(platSeqNo);
-	}
+    }
 
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	List<HtTradeSettlement> getList(SoMap so) { 
-		return htTradeSettlementMapper.getList(so);	
-	}
-	
+    /**
+     * 查
+     */
+    HtTradeSettlement getById(String platSeqNo) {
+        return super.getById(platSeqNo);
+    }
 
-	/** 远程调用: 添加大订单时同事生成小定单 */
-	public boolean tradeSettlementDto(TradeSettlementDto tradeSettlementDto){
-		HtTradeSettlement htTradeSettlement = new HtTradeSettlement();
-		BeanUtils.copyProperties(tradeSettlementDto,htTradeSettlement);
-		int insert = htTradeSettlementMapper.insert(htTradeSettlement);
-		//取出边民小定单集合
-		List<BordersListDto> bordersListDtoList = tradeSettlementDto.getBordersListDtoList();
-		BorderBuyGoodsListDto borderBuyGoodsListDto = tradeSettlementDto.getBorderBuyGoodsListDtoList().get(0);
-		//循环
-		if(bordersListDtoList.size() > 0){
-			bordersListDtoList.forEach(item -> {
-				//开始创建小定单
-				TbOrder tbOrder = new TbOrder();
-				//航通字段
-				BeanUtils.copyProperties(item,tbOrder);
-				//				tbOrder.setTradeNo(); // 订单号...  没确认的参数先跳过
-				//根据身份证查询边民
-				List<TbPeople> tbPeople = tbPeopleMapper.selectList(new LambdaQueryWrapper<TbPeople>().eq(TbPeople::getIdCardNo, item.getIdno()));
-				tbOrder.setCallCarStatus(CallCarStatus.CALL_CAR_STATUS_ZERO.getCode());
-				tbOrder.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
-				tbOrder.setCreateTime(new Date());
-				tbOrder.setResaleStatus(ResaleStatus.RESALE_STATUS_ZERO.getCode());
-				tbOrder.setFinishStatus(OrderStatus.ORDER_STATUS_ZERO.getCode());
-				tbOrder.setSend(DeliverStatus.DELIVER_STATUS_ZERO.getCode());
-				tbOrder.setApply(ApplyStatus.APPLY_STATUS_ZERO.getCode());
-				if(borderBuyGoodsListDto != null){
-					tbOrder.setGoodsNames(borderBuyGoodsListDto.getGoodsName());
-				}
-				if(tbPeople.size() > 0){
-					tbOrder.setBuyUserId(tbPeople.get(0).getId());
-					tbOrder.setBuyUserName(tbPeople.get(0).getBorderName());
-					tbOrder.setGroupId(tbPeople.get(0).getGroupId());
-				}
-				tbOrder.setPreNo(item.getPreNo());
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<HtTradeSettlement> getList(SoMap so) {
+        return htTradeSettlementMapper.getList(so);
+    }
 
-				tbOrderMapper.insert(tbOrder);
-			});
-		}
-		return insert == 1;
-	}
+
+    /**
+     * 远程调用: 添加大订单时同事生成小定单
+     */
+    public boolean tradeSettlementDto(TradeSettlementDto tradeSettlementDto) {
+        HtTradeSettlement htTradeSettlement = new HtTradeSettlement();
+        BeanUtils.copyProperties(tradeSettlementDto, htTradeSettlement);
+        int insert = htTradeSettlementMapper.insert(htTradeSettlement);
+        //取出边民小定单集合
+        List<BordersListDto> bordersListDtoList = tradeSettlementDto.getBordersListDtoList();
+        BorderBuyGoodsListDto borderBuyGoodsListDto = tradeSettlementDto.getBorderBuyGoodsListDtoList().get(0);
+        TbGoods tbGoods = tbGoodsService.findByCode(borderBuyGoodsListDto.getCodeTs());
+        TbTradeArea tbTradeArea = tbTradeAreaService.updateHandler(tradeSettlementDto.getFieldCode(), tradeSettlementDto.getFieldName());
+        TbShop tbShop = tbShopService.findByCode(tradeSettlementDto.getShopNo());
+        if (tbShop != null) {
+            tbShop.setEnterpriseId(tbShop.getEnterpriseId())
+                    .setEnterpriseName(tbShop.getEnterpriseName());
+        }
+        //循环
+        if (bordersListDtoList.size() > 0) {
+            bordersListDtoList.forEach(item -> {
+                //开始创建小定单
+                TbOrder tbOrder = new TbOrder();
+                //航通字段
+                BeanUtils.copyProperties(item, tbOrder);
+                //根据身份证查询边民
+                TbPeople tbPeople = tbPeopleService.findByIdCarNo(item.getIdno());
+                tbOrder.setCallCarStatus(CallCarStatus.CALL_CAR_STATUS_ZERO.getCode());
+                tbOrder.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
+                tbOrder.setCreateTime(new Date())
+                        .setTradeNo(SystemObject.getREFcode("YJSCDD", new Date()))
+                        .setTradeAreaId(tbTradeArea.getId()).setTradeAreaName(tbTradeArea.getName());
+                tbOrder.setResaleStatus(ResaleStatus.RESALE_STATUS_ZERO.getCode());
+                tbOrder.setFinishStatus(OrderStatus.ORDER_STATUS_ZERO.getCode());
+                tbOrder.setSend(DeliverStatus.DELIVER_STATUS_ZERO.getCode());
+                tbOrder.setApply(ApplyStatus.APPLY_STATUS_ZERO.getCode());
+                tbOrder.setGoodsId(tbGoods.getId()).setTotalPrice(borderBuyGoodsListDto.getBuyAmount())
+                        .setTotalWeight(borderBuyGoodsListDto.getGrossWt())
+                        .setGoodsNames(tbGoods.getGName())
+                        .setGoodsUnit(tbGoods.getGUnit());
+                if (tbPeople != null) {
+                    tbOrder.setBuyUserId(tbPeople.getId());
+                    tbOrder.setBuyUserName(tbPeople.getBorderName());
+                    tbOrder.setGroupId(tbPeople.getGroupId());
+                }
+                tbOrder.setPreNo(item.getPreNo());
+
+                tbOrderMapper.insert(tbOrder);
+            });
+        }
+        return insert == 1;
+    }
 }

+ 7 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_enterprise/TbEnterpriseService.java

@@ -1,6 +1,7 @@
 package com.pj.tb_enterprise;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.pj.api.client.admin.AdminInterface;
@@ -384,4 +385,10 @@ public class TbEnterpriseService extends ServiceImpl<TbEnterpriseMapper, TbEnter
         return result;
     }
 
+    public TbEnterprise findBydutyParagraph(String shopSccd) {
+        QueryWrapper<TbEnterprise>ew=new QueryWrapper<>();
+        ew.lambda().eq(TbEnterprise::getDutyParagraph,shopSccd);
+        List<TbEnterprise> list=list(ew);
+        return list.isEmpty()?null:list.get(0);
+    }
 }

+ 7 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_goods/TbGoodsService.java

@@ -10,6 +10,7 @@ import java.util.List;
 import java.util.stream.Collectors;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.pj.api.dto.GoodsDto;
 import com.pj.api.dto.HtGoodsDto;
 import com.pj.enummj.DeleteStatus;
@@ -220,4 +221,10 @@ public class TbGoodsService extends ServiceImpl<TbGoodsMapper, TbGoods> implemen
 
 	}
 
+	public TbGoods findByCode(String codeTs) {
+		QueryWrapper<TbGoods>ew=new QueryWrapper<>();
+		ew.lambda().eq(TbGoods::getHsCode,codeTs);
+		List<TbGoods>list=list(ew);
+		return list.isEmpty()?null:list.get(0);
+	}
 }

+ 87 - 80
sp-service/level-one-server/src/main/java/com/pj/tb_group/TbGroupService.java

@@ -9,8 +9,10 @@ import java.util.Date;
 import java.util.List;
 import java.util.Objects;
 
+import cn.hutool.json.JSONUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.pj.api.dto.BorderDTO;
 import com.pj.api.dto.GroupDto;
 import com.pj.current.satoken.StpUserUtil;
 import com.pj.enummj.DeleteStatus;
@@ -18,6 +20,9 @@ import com.pj.enummj.IsLock;
 import com.pj.tb_goods_transit.TbGoodsTransit;
 import com.pj.tb_people.TbPeople;
 import com.pj.tb_people.TbPeopleMapper;
+import com.pj.tb_people.TbPeopleService;
+import com.pj.tb_trade_area.TbTradeArea;
+import com.pj.tb_trade_area.TbTradeAreaService;
 import com.pj.utils.so.SoMap;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFRow;
@@ -42,94 +47,96 @@ import javax.swing.filechooser.FileSystemView;
 @Transactional(rollbackFor = Exception.class)
 public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implements IService<TbGroup> {
 
-	/**
-	 * 底层 Mapper 对象
-	 */
-	@Autowired
-	TbGroupMapper tbGroupMapper;
-	@Autowired
-	TbPeopleMapper tbPeopleMapper;
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    TbGroupMapper tbGroupMapper;
+    @Autowired
+    TbPeopleService tbPeopleService;
 
-	@Autowired
-	private MethodGroupService methodGroupService;
+    @Autowired
+    private MethodGroupService methodGroupService;
+    @Resource
+    private TbTradeAreaService tbTradeAreaService;
 
-	/**
-	 * 增
-	 */
-	void add(TbGroup t) {
-		t.setCreateTime(new Date())
-				.setCreateName(StpUserUtil.getPCLoginInfo().getLoginName())
-				.setCreateBy(Long.valueOf(StpUserUtil.getPCLoginInfo().getLoginId()))
-				.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode())
-				.setIsLock(IsLock.IS_LOCK_ON.getCode());
-		save(t);
-	}
+    /**
+     * 增
+     */
+    void add(TbGroup t) {
+        t.setCreateTime(new Date())
+                .setCreateName(StpUserUtil.getPCLoginInfo().getLoginName())
+                .setCreateBy(Long.valueOf(StpUserUtil.getPCLoginInfo().getLoginId()))
+                .setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode())
+                .setIsLock(IsLock.IS_LOCK_ON.getCode());
+        save(t);
+    }
 
-	/**
-	 * 删
-	 */
-	void delete(Long id) {
-		removeById(id);
-	}
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
 
-	/**
-	 * 改
-	 */
-	void update(TbGroup t) {
-		t.setUpdateTime(new Date())
-				.setUpdateName(StpUserUtil.getPCLoginInfo().getLoginName())
-				.setUpdateBy(Long.valueOf(StpUserUtil.getPCLoginInfo().getLoginId()));
-		updateById(t);
+    /**
+     * 改
+     */
+    void update(TbGroup t) {
+        t.setUpdateTime(new Date())
+                .setUpdateName(StpUserUtil.getPCLoginInfo().getLoginName())
+                .setUpdateBy(Long.valueOf(StpUserUtil.getPCLoginInfo().getLoginId()));
+        updateById(t);
 
-	}
+    }
 
-	/**
-	 * 查
-	 */
-	TbGroup getById(String id) {
-		return super.getById(id);
-	}
+    /**
+     * 查
+     */
+    TbGroup getById(String id) {
+        return super.getById(id);
+    }
 
-	/**
-	 * 查集合 - 根据条件(参数为空时代表忽略指定条件)
-	 */
-	List<TbGroup> getList(SoMap so) {
-		return tbGroupMapper.getList(so);
-	}
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<TbGroup> getList(SoMap so) {
+        return tbGroupMapper.getList(so);
+    }
 
-	public int setLeader(Long groupId, Long leaderId) {
-		// 获取当前登录用户id
-		Long loginId = StpUserUtil.getLoginIdAsLong();
-		// 获取互助组信息
-		TbGroup tbGroup = tbGroupMapper.selectById(groupId);
-		// 获取边民信息
-		TbPeople tbPeople = tbPeopleMapper.selectById(leaderId);
-		// 如果互助组不存在则抛异常
-		if (Objects.isNull(tbGroup)) {
-			throw new RuntimeException("该互助组不存在");
-		}
-		// 如果边民不存在
-		if (Objects.isNull(tbPeople)) {
-			throw new RuntimeException("该用户不存在");
-		}
-		// 如果互助组被锁定则抛异常
-		if (tbGroup.getIsLock() == 1) {
-			throw new RuntimeException("该互助组已被锁定");
-		}
-		// 如果边民不存在则抛异常
-		if (tbPeople.getIsLock() == 1) {
-			throw new RuntimeException("该用户已被锁定");
-		}
-		// 设置互助组组长
-		tbGroup.setLeaderId(tbPeople.getId());
-		tbGroup.setLeaderName(tbPeople.getName());
-		tbGroup.setLeaderPhone(tbPeople.getPhone());
-		// 写入更新者id
-		tbGroup.setUpdateBy(loginId);
-		// 更新互助组
-		int line = tbGroupMapper.updateById(tbGroup);
-		return line;
-	}
+    public int setLeader(Long groupId, Long leaderId) {
+        // 获取当前登录用户id
+        Long loginId = StpUserUtil.getLoginIdAsLong();
+        // 获取互助组信息
+        TbGroup tbGroup = tbGroupMapper.selectById(groupId);
+        // 获取边民信息
+        TbPeople tbPeople = tbPeopleService.getById(leaderId);
+        // 如果互助组不存在则抛异常
+        if (Objects.isNull(tbGroup)) {
+            throw new RuntimeException("该互助组不存在");
+        }
+        // 如果边民不存在
+        if (Objects.isNull(tbPeople)) {
+            throw new RuntimeException("该用户不存在");
+        }
+        // 如果互助组被锁定则抛异常
+        if (tbGroup.getIsLock() == 1) {
+            throw new RuntimeException("该互助组已被锁定");
+        }
+        // 如果边民不存在则抛异常
+        if (tbPeople.getIsLock() == 1) {
+            throw new RuntimeException("该用户已被锁定");
+        }
+        // 设置互助组组长
+        tbGroup.setLeaderId(tbPeople.getId());
+        tbGroup.setLeaderName(tbPeople.getBorderName());
+        tbGroup.setLeaderPhone(tbPeople.getBorderTel());
+        // 写入更新者id
+        tbGroup.setUpdateBy(loginId);
+        // 更新互助组
+        int line = tbGroupMapper.updateById(tbGroup);
+        return line;
+    }
 
 	public int AddGroupPeople(Long groupId, Long[] peopleIds) {
 		// 获取当前登录用户id

+ 12 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrder.java

@@ -116,8 +116,15 @@ public class TbOrder extends Model<TbOrder> implements Serializable {
 	 * 总重量
 	 */
 	private Double totalWeight;
-
+	/**
+	 * 单证代码
+	 */
 	private String preNo;
+	/**
+	 *进出口预申报
+	 * 单
+	 */
+	private String preIeportNo;
 
 	/**
 	 * 总金额
@@ -363,5 +370,9 @@ public class TbOrder extends Model<TbOrder> implements Serializable {
 	 * 商品单位
 	 */
 	private String goodsUnit;
+	/**
+	 * 结算单号
+	 */
+	private String settleBillNo;
 
 }

+ 26 - 31
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderController.java

@@ -13,7 +13,7 @@ import cn.dev33.satoken.annotation.SaCheckPermission;
 
 /**
  * Controller: tb_order -- 订单表
- * @author loovi 
+ * @author loovi
  */
 @RestController
 @RequestMapping("/TbOrder/")
@@ -22,34 +22,26 @@ public class TbOrderController {
 	/** 底层 Service 对象 */
 	@Autowired
 	TbOrderService tbOrderService;
-//
-//	/** 增 */
-//	@RequestMapping("add")
-//	@SaCheckPermission(TbOrder.PERMISSION_CODE_ADD)
-//	public AjaxJson add(TbOrder t){
-//		tbOrderService.add(t);
-//		t = tbOrderService.getById(SP.publicMapper.getPrimarykey());
-//		return AjaxJson.getSuccessData(t);
-//	}
-
-	/** 删 */  
+
+
+	/** 删 */
 	@RequestMapping("delete")
 	@SaCheckPermission(TbOrder.PERMISSION_CODE_DEL)
 	public AjaxJson delete(Long id){
 		 tbOrderService.delete(id);
 		return AjaxJson.getSuccess();
 	}
-	
-	/** 删 - 根据id列表 */  
+
+	/** 删 - 根据id列表 */
 	@RequestMapping("deleteByIds")
 	@SaCheckPermission(TbOrder.PERMISSION_CODE_DEL)
 	public AjaxJson deleteByIds(){
-		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class); 
+		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class);
 		int line = SP.publicMapper.deleteByIds(TbOrder.TABLE_NAME, ids);
 		return AjaxJson.getByLine(line);
 	}
-	
-	/** 改 */  
+
+	/** 改 */
 	@RequestMapping("update")
 	@SaCheckPermission(TbOrder.PERMISSION_CODE_EDIT)
 	public AjaxJson update(TbOrder t){
@@ -57,37 +49,40 @@ public class TbOrderController {
 		return AjaxJson.getSuccess();
 	}
 
-	/** 查 - 根据id */  
+	/** 查 - 根据id */
 	@RequestMapping("getById")
-		@SaCheckPermission(TbOrder.PERMISSION_CODE)
+	@SaCheckPermission(TbOrder.PERMISSION_CODE)
 	public AjaxJson getById(Long id){
 		TbOrder t = tbOrderService.getById(id);
 		return AjaxJson.getSuccessData(t);
 	}
 
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
+	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
 	@RequestMapping("getList")
-//		@SaCheckPermission(TbOrder.PERMISSION_CODE)
-	public AjaxJson getList() { 
+	@SaCheckPermission(TbOrder.PERMISSION_CODE)
+	public AjaxJson getList() {
 		SoMap so = SoMap.getRequestSoMap();
 		List<TbOrder> list = tbOrderService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
-	
-	
-	
-	/** 改 - 删除状态(0=禁用,1=启用) */  
+
+
+	/** 改 - 删除状态(0=禁用,1=启用) */
 	@RequestMapping("updateDeleteStatus")
 	@SaCheckPermission(TbOrder.PERMISSION_CODE_EDIT)
 	public AjaxJson updateDeleteStatus(Long id, Integer value){
 		int line = SP.publicMapper.updateColumnById(TbOrder.TABLE_NAME, "delete_status", value, id);
 		return AjaxJson.getByLine(line);
 	}
-	
-	
 
-	
-	
-	
+
+
+	/*-----           正常业务逻辑👆👆    rpc远程调用👇👇 -----*/
+
+	/** 系统接收到航通接口信息:车辆已出一级市场 ,相对应的一级市场订单状态修改 **/
+	@RequestMapping("rpc/orderFinish")
+	public boolean orderFinish(@RequestParam("billCode") String billCode) {
+		return tbOrderService.orderFinish(billCode);
+	}
 
 }

+ 5 - 7
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderMapper.xml

@@ -86,6 +86,7 @@
 			<if test=' this.has("peopleConfirmType") '> and people_confirm_type = #{peopleConfirmType} </if>
 			<if test=' this.has("collageOrdersId") '> and collage_orders_id = #{collageOrdersId} </if>
 			<if test=' this.has("applyConfirmStatus") '> and apply_confirm_status = #{applyConfirmStatus} </if>
+			<if test=' this.has("cooperEntrustStatus") '> and cooper_entrust_status = #{cooperEntrustStatus} </if>
 		</where>
 		order by
 		<choose>
@@ -143,13 +144,10 @@
 		</choose>
 	</select>
 
-
-
-
-
-
-
-
+	<select id="getConfirmStatus" resultType="com.pj.tb_order.vo.ConfirmVo">
+		select id orderId,people_confirm_status,cooper_entrust_status,apply_confirm_status from tb_order
+		where id = #{orderId}
+	</select>
 
 
 </mapper>

+ 55 - 31
sp-service/level-one-server/src/main/java/com/pj/tb_order/TbOrderService.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.pj.api.client.admin.AdminInterface;
 import com.pj.api.client.async_server.AsyncServerInterface;
 import com.pj.api.client.level_one_server.LevelOneServerInterface;
+import com.pj.api.consts.FeignFactory;
 import com.pj.api.dto.*;
 import com.pj.common.core.exception.ServiceException;
 import com.pj.current.dto.APPLoginUserInfo;
@@ -25,7 +26,10 @@ import com.pj.tb_order_people_confirm.TbOrderPeopleConfirm;
 import com.pj.tb_order_people_confirm.TbOrderPeopleConfirmMapper;
 import com.pj.tb_people.TbPeople;
 import com.pj.tb_people.TbPeopleMapper;
+import com.pj.tb_people.TbPeopleService;
+import com.pj.utils.sg.AjaxError;
 import com.pj.utils.so.SoMap;
+import org.apache.poi.ss.formula.functions.T;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -47,7 +51,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
 
 	/** 互市组 */
 	@Autowired
-	private TbPeopleMapper tbPeopleMapper;
+	private TbPeopleService tbPeopleService;
 	@Autowired
 	TbOrderPeopleConfirmMapper tbOrderPeopleConfirmMapper;
 	@Autowired
@@ -258,7 +262,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
 		}
 
 		// 获取组内所有边民
-		List<TbPeople> peopleList = tbPeopleMapper.getList(so);
+		List<TbPeople> peopleList = tbPeopleService.getList(so);
 		for (TbPeople people : peopleList) {
 			PeopleConfirmVo peopleConfirmVo = new PeopleConfirmVo();
 			peopleConfirmVo.setOrderId(so.getLong("orderId"));
@@ -345,6 +349,10 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
 	 * @param orderId 一级市场订单表ID
 	 */
 	public boolean confirmOrder(Long orderId){
+		TbOrder tbOrder=this.getById(orderId);
+		if (tbOrder==null){
+			throw new AjaxError("订单不存在");
+		}
 		// TODO: 2023/8/28 边民发起支付申请,调用银行接口:验证边民支付信息,将货款先存入银行第三方账户,并给出回执
 		// 银行返回支付回执为"交易成功"时,方法往下执行
 
@@ -362,10 +370,7 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
 		boolean result = update(wrapper);
 
 		// TODO: 2023/8/29 调用航通008接口,发送信息
-		OrderDto tbOrderDto = new OrderDto();
-		BeanUtils.copyProperties(tbOrderMapper.selectById(orderId),tbOrderDto);
-		asyncServerInterface.sendLevelOneOrderDto(tbOrderDto,DataType.DATA_TYPE_ONE.getCode()); // 发送至航通
-
+		sendConfirmMsgToHt(tbOrder);
 		return result;
 	}
 
@@ -374,6 +379,10 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
 	 * @param orderId 一级市场订单表ID
 	 */
 	public boolean applyOrder(Long orderId){
+		TbOrder tbOrder=this.getById(orderId);
+		if (tbOrder==null){
+			throw new AjaxError("订单不存在");
+		}
 		//获取登录人
 		APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
 
@@ -389,14 +398,24 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
 		boolean result = update(wrapper);
 
 		// TODO: 2023/8/29 调用航通008接口,发送信息
-		OrderDto tbOrderDto = new OrderDto();
-		BeanUtils.copyProperties(tbOrderMapper.selectById(orderId),tbOrderDto);
-		asyncServerInterface.sendLevelOneOrderDto(tbOrderDto,DataType.DATA_TYPE_TWO.getCode());
-
+		sendConfirmMsgToHt(tbOrder);
 		return result;
 	}
 
 	/**
+	 * 发送008信息到航通
+	 */
+	private void sendConfirmMsgToHt(TbOrder tbOrder){
+		TbPeople tbPeople=tbPeopleService.getById(tbOrder.getBuyUserId());
+		PeopleConfirmDTO peopleConfirmDTO=new PeopleConfirmDTO();
+		peopleConfirmDTO.setBorderName(tbOrder.getBuyUserName());
+		peopleConfirmDTO.setIdno(tbPeople.getIdCardNo());
+		peopleConfirmDTO.setSettleBillNo(tbOrder.getSettleBillNo());
+		peopleConfirmDTO.setPreIeportNo(tbOrder.getPreIeportNo());
+		FeignFactory.asyncServerInterface.sendConfirm(peopleConfirmDTO);
+	}
+
+	/**
 	 *  互助委托申报确认
 	 * @param orderId 一级市场订单表ID
 	 */
@@ -418,17 +437,24 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
 		return result;
 	}
 
+
+	/*-----           正常业务逻辑👆👆    rpc远程调用👇👇 -----*/
+
+
 	// TODO: 2023/8/28 系统接收到航通接口信息:车辆已出一级市场
-	public void orderFinish(Long[] ids){
+	public boolean orderFinish(String billCode){
 		//1、todo: 调用银行接口发起划扣:将边民划扣至银行第三方账户的货款,支付至外籍商户的账户
 		//收到划扣成功回执后,方法往下制行
 
 		//2、修改一级市场订单支付状态为已支付,修改一级市场订单完成状态为已完成
 		//获取登录人
 		APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
-		TbOrder order = new TbOrder();
-		for (Long id : ids) {
-			order.setId(id);
+		//获取出了一级市场的所有边民订单
+		LambdaQueryWrapper<TbOrder> wrapper = new LambdaQueryWrapper<>();
+		wrapper.eq(TbOrder::getPreNo, billCode);
+		List<TbOrder> tbOrders = tbOrderMapper.selectList(wrapper);
+
+		tbOrders.forEach(order -> {
 			order.setTradeStatus(TradeStatus.TRADE_STATUS_ONE.getCode()); //已支付
 			order.setTradeTime(new Date()); //支付时间
 			order.setPayType(0); //支付类型
@@ -439,26 +465,24 @@ public class TbOrderService extends ServiceImpl<TbOrderMapper, TbOrder> implemen
 			order.setUpdateTime(new Date());
 
 			boolean result = updateById(order);
-			if(!result) throw new RuntimeException("当前订单状态修改失败,请联系管理员!");
-
-			//todo:通知边民转售已经采购的商品;边民上架商品,初步定价
-			TbOrder t = getById(id);
-			MessageDto dto = new MessageDto();
-			dto.setUrl("/pages/market/one/leader/order");
-			dto.setUserId(t.getBuyUserId());
-			dto.setContents("你采购的《" + t.getGoodsNames() + "》订单已完成。请及时上架商品到二级市场。");
-			adminInterface.messageSave(dto);
-		}
-
-		//3、todo: 调用航通接口,发送划扣成功回执信息给航通(只发送)
-		OrderDto tbOrderDto = new OrderDto();
-		BeanUtils.copyProperties(order,tbOrderDto);
-		asyncServerInterface.sendLevelOneOrderDto(tbOrderDto,DataType.DATA_TYPE_THREE.getCode());
-	}
+			//修改失败记录是否应该存表??
+			//if(!result) throw new RuntimeException("当前订单状态修改失败,请联系管理员!");
+
+			if(result) {
+				//todo:通知边民转售已经采购的商品;边民上架商品,初步定价
+				MessageDto dto = new MessageDto();
+				dto.setUrl("/pages/market/one/leader/order");
+				dto.setUserId(order.getBuyUserId());
+				dto.setContents("你采购的《" + order.getGoodsNames() + "》订单已完成。请及时上架商品到二级市场。");
+				adminInterface.messageSave(dto);
+			}
+		});
 
+		//3、todo: 调用航通接口,发送划扣成功回执信息给航通(只发送),航通暂未提供此接口
 
+		return true;
+	}
 
-	/*-----           正常业务逻辑👆👆    rpc远程调用👇👇 -----*/
 
 	/** 远程调用:根据时间和登陆人查询订单 */
 	public List<OrderDto> selectOrderList( Long appUserId){

+ 15 - 1
sp-service/level-one-server/src/main/java/com/pj/tb_people/TbPeopleService.java

@@ -119,7 +119,7 @@ public class TbPeopleService extends ServiceImpl<TbPeopleMapper, TbPeople> imple
 	}
 
 	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
-	List<TbPeople> getList(SoMap so) {
+	public List<TbPeople> getList(SoMap so) {
 		return tbPeopleMapper.getList(so);
 	}
 
@@ -616,4 +616,18 @@ public class TbPeopleService extends ServiceImpl<TbPeopleMapper, TbPeople> imple
 		return null;
 	}
 
+	public List<TbPeople> getMemberListByGroupId(SoMap startPage) {
+		return tbPeopleMapper.getMemberListByGroupId(startPage);
+	}
+
+	public List<TbPeople> getMemberListByLeaderId(SoMap startPage) {
+		return tbPeopleMapper.getMemberListByLeaderId(startPage);
+	}
+
+	public TbPeople findByIdCarNo(String idNo) {
+		QueryWrapper<TbPeople>ew=new QueryWrapper<>();
+		ew.lambda().eq(TbPeople::getIdCardNo,idNo);
+		List<TbPeople>list=list(ew);
+		return list.isEmpty()?null:list.get(0);
+	}
 }

+ 242 - 210
sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopService.java

@@ -9,6 +9,7 @@ import java.util.Date;
 import java.util.List;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.pj.api.client.admin.AdminInterface;
 import com.pj.api.dto.EnterpriseDto;
 import com.pj.api.dto.ShopDto;
@@ -17,6 +18,9 @@ import com.pj.enummj.*;
 import com.pj.project4sp.SP;
 import com.pj.tb_enterprise.TbEnterprise;
 import com.pj.tb_enterprise.TbEnterpriseMapper;
+import com.pj.tb_enterprise.TbEnterpriseService;
+import com.pj.tb_trade_area.TbTradeArea;
+import com.pj.tb_trade_area.TbTradeAreaService;
 import com.pj.utils.so.SoMap;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.hssf.usermodel.HSSFRow;
@@ -31,245 +35,273 @@ import org.springframework.transaction.annotation.Propagation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.annotation.Resource;
 import javax.swing.filechooser.FileSystemView;
 
 /**
  * Service: tb_shop -- 铺位
- * @author qzy 
+ *
+ * @author qzy
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
-public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements IService<TbShop>{
+public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements IService<TbShop> {
 
-	/** 底层 Mapper 对象 */
-	@Autowired
-	TbShopMapper tbShopMapper;
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    TbShopMapper tbShopMapper;
 
-	@Autowired
-	private MethodShopService methodShopService;
+    @Autowired
+    private MethodShopService methodShopService;
 
-	@Autowired
-	private TbEnterpriseMapper tbEnterpriseMapper;
+    @Autowired
+    private TbEnterpriseMapper tbEnterpriseMapper;
+    @Resource
+    private TbEnterpriseService tbEnterpriseService;
 
-	@Autowired
-	private AdminInterface adminInterface;
+    @Autowired
+    private AdminInterface adminInterface;
+    @Resource
+    private TbTradeAreaService tbTradeAreaService;
 
-	/** 增 */
-	void add(TbShop t){
-		save(t);
-	}
+    /**
+     * 增
+     */
+    void add(TbShop t) {
+        save(t);
+    }
 
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
 
-	/** 改 */
-	void update(TbShop t){
-		updateById(t);
+    /**
+     * 改
+     */
+    void update(TbShop t) {
+        updateById(t);
 
-	}
+    }
 
-	/** 查 */
-	TbShop getById(String id){
-		return super.getById(id);
-	}
+    /**
+     * 查
+     */
+    TbShop getById(String id) {
+        return super.getById(id);
+    }
 
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	List<TbShop> getList(SoMap so) { 
-		return tbShopMapper.getList(so);	
-	}
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<TbShop> getList(SoMap so) {
+        return tbShopMapper.getList(so);
+    }
 
 
-	/**
-	 * 导入
-	 * @param file excel文件
-	 * @return
-	 * @throws IOException
-	 */
-	public String importData(MultipartFile file) throws IOException {
-		System.out.println("\n开始执行文件上传....\n");
+    /**
+     * 导入
+     *
+     * @param file excel文件
+     * @return
+     * @throws IOException
+     */
+    public String importData(MultipartFile file) throws IOException {
+        System.out.println("\n开始执行文件上传....\n");
 
-		//判空
-		if(file.isEmpty()) return "文件为空,无法执行上传...";
-		//获取文件上传数据
-		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
-		//获取第一页sheet
-		HSSFSheet sheet = wb.getSheetAt(0);
-		//定义计数器
-		int count = 0;
-		//定义行对象
-		HSSFRow row = null;
-		//解析数据封装到集合
-		count = methodShopService.importMethod(row, sheet, count);
-		wb.close();
-		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
-		return "上传完成,共上传"  + count + "条"  + "数据。";
-	}
+        //判空
+        if (file.isEmpty()) return "文件为空,无法执行上传...";
+        //获取文件上传数据
+        HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+        //获取第一页sheet
+        HSSFSheet sheet = wb.getSheetAt(0);
+        //定义计数器
+        int count = 0;
+        //定义行对象
+        HSSFRow row = null;
+        //解析数据封装到集合
+        count = methodShopService.importMethod(row, sheet, count);
+        wb.close();
+        System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+        return "上传完成,共上传" + count + "条" + "数据。";
+    }
 
-	/**
-	 * 导出 excel文件
-	 * @param keyword
-	 * @return
-	 */
-	public String outportExcel(String keyword,String filepath) throws IOException {
-		System.out.println("\n开始执行文件导出....\n");
-		//导出的文件的路径
-		if(filepath == null || filepath.trim().equals("")){
-			// 获取当前用户的桌面路径
-			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
-			filepath = fileSystemView.getHomeDirectory().getPath();
-		}
-		filepath = filepath + "\\铺位数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
-		//根据需求查询数据
-		List<TbShop> selectedList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(StringUtils.isNoneBlank(keyword), TbShop::getShopName, keyword));
-		if(selectedList.size() == 0)return "没有可导出的数据。";
-		//建立excel对象封装数据
-		HSSFWorkbook workbook = new HSSFWorkbook();
-		//创建excel表格右下角的sheet页名称
-		HSSFSheet sheet = workbook.createSheet("1");
-		//创建表头
-		HSSFRow row = sheet.createRow(0);
-		row.createCell(0).setCellValue("序号");
-		row.createCell(1).setCellValue("enterprise_id");
-		row.createCell(2).setCellValue("交易地区ID");
-		row.createCell(3).setCellValue("交易地区名称");
-		row.createCell(4).setCellValue("地址");
-		row.createCell(5).setCellValue("地址ID");
-		row.createCell(6).setCellValue("名称");
-		row.createCell(7).setCellValue("编号");
-		row.createCell(8).setCellValue("区域");
-		row.createCell(9).setCellValue("是否可用");
-		row.createCell(10).setCellValue("备注");
-		row.createCell(11).setCellValue("enterprise_name");
+    /**
+     * 导出 excel文件
+     *
+     * @param keyword
+     * @return
+     */
+    public String outportExcel(String keyword, String filepath) throws IOException {
+        System.out.println("\n开始执行文件导出....\n");
+        //导出的文件的路径
+        if (filepath == null || filepath.trim().equals("")) {
+            // 获取当前用户的桌面路径
+            FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+            filepath = fileSystemView.getHomeDirectory().getPath();
+        }
+        filepath = filepath + "\\铺位数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+        //根据需求查询数据
+        List<TbShop> selectedList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(StringUtils.isNoneBlank(keyword), TbShop::getShopName, keyword));
+        if (selectedList.size() == 0) return "没有可导出的数据。";
+        //建立excel对象封装数据
+        HSSFWorkbook workbook = new HSSFWorkbook();
+        //创建excel表格右下角的sheet页名称
+        HSSFSheet sheet = workbook.createSheet("1");
+        //创建表头
+        HSSFRow row = sheet.createRow(0);
+        row.createCell(0).setCellValue("序号");
+        row.createCell(1).setCellValue("enterprise_id");
+        row.createCell(2).setCellValue("交易地区ID");
+        row.createCell(3).setCellValue("交易地区名称");
+        row.createCell(4).setCellValue("地址");
+        row.createCell(5).setCellValue("地址ID");
+        row.createCell(6).setCellValue("名称");
+        row.createCell(7).setCellValue("编号");
+        row.createCell(8).setCellValue("区域");
+        row.createCell(9).setCellValue("是否可用");
+        row.createCell(10).setCellValue("备注");
+        row.createCell(11).setCellValue("enterprise_name");
 
-		row.createCell(28).setCellValue("创建时间");
-		row.createCell(29).setCellValue("创建人编号");
-		row.createCell(30).setCellValue("创建人名称");
-		row.createCell(31).setCellValue("更新时间");
-		row.createCell(32).setCellValue("更新人编号");
-		row.createCell(33).setCellValue("更新人名称");
-		row.createCell(34).setCellValue("删除状态");
+        row.createCell(28).setCellValue("创建时间");
+        row.createCell(29).setCellValue("创建人编号");
+        row.createCell(30).setCellValue("创建人名称");
+        row.createCell(31).setCellValue("更新时间");
+        row.createCell(32).setCellValue("更新人编号");
+        row.createCell(33).setCellValue("更新人名称");
+        row.createCell(34).setCellValue("删除状态");
 
-		//定义计数器
-		int count = 0;
-		//遍历集合
-		for (int i = 0; i < selectedList.size(); i++) {
-			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
-			sheetRow.createCell(0).setCellValue(i + 1);
-			sheetRow.createCell(1).setCellValue((selectedList.get(i).getEnterpriseId() + "").equals("null")? "": selectedList.get(i).getEnterpriseId() + "");
-			sheetRow.createCell(2).setCellValue((selectedList.get(i).getTradeAreaId() + "").equals("null")? "": selectedList.get(i).getTradeAreaId() + "");
-			sheetRow.createCell(3).setCellValue((selectedList.get(i).getTradeAreaName() + "").equals("null")? "": selectedList.get(i).getTradeAreaName() + "");
-			sheetRow.createCell(4).setCellValue((selectedList.get(i).getAddress() + "").equals("null")? "": selectedList.get(i).getAddress() + "");
-			sheetRow.createCell(5).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null")? "": selectedList.get(i).getAddressIds() + "");
-			sheetRow.createCell(6).setCellValue((selectedList.get(i).getShopName() + "").equals("null")? "": selectedList.get(i).getShopName() + "");
-			sheetRow.createCell(7).setCellValue((selectedList.get(i).getShopNo() + "").equals("null")? "": selectedList.get(i).getShopNo() + "");
-			sheetRow.createCell(8).setCellValue((selectedList.get(i).getArea() + "" ).equals("null")? "": selectedList.get(i).getArea() + "");
-			sheetRow.createCell(9).setCellValue((selectedList.get(i).getStatus() + "").equals("null")? "": selectedList.get(i).getStatus() + "");
-			sheetRow.createCell(10).setCellValue((selectedList.get(i).getRemark() + "").equals("null")? "": selectedList.get(i).getRemark() + "");
-			sheetRow.createCell(11).setCellValue((selectedList.get(i).getEnterpriseName() + "").equals("null")? "": selectedList.get(i).getEnterpriseName() + "");
-			//公共字段
-			sheetRow.createCell(12).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
-			sheetRow.createCell(13).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
-			sheetRow.createCell(14).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
-			sheetRow.createCell(15).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
-			sheetRow.createCell(16).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null")? "": selectedList.get(i).getUpdateBy() + "");
-			sheetRow.createCell(17).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null")? "": selectedList.get(i).getUpdateName() + "");
-			sheetRow.createCell(18).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null")? "": selectedList.get(i).getDeleteStatus() + "");
-			count += 1;
-		}
-		//建立输出流,输出文件
-		FileOutputStream fos = new FileOutputStream(filepath);
+        //定义计数器
+        int count = 0;
+        //遍历集合
+        for (int i = 0; i < selectedList.size(); i++) {
+            HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+            sheetRow.createCell(0).setCellValue(i + 1);
+            sheetRow.createCell(1).setCellValue((selectedList.get(i).getEnterpriseId() + "").equals("null") ? "" : selectedList.get(i).getEnterpriseId() + "");
+            sheetRow.createCell(2).setCellValue((selectedList.get(i).getTradeAreaId() + "").equals("null") ? "" : selectedList.get(i).getTradeAreaId() + "");
+            sheetRow.createCell(3).setCellValue((selectedList.get(i).getTradeAreaName() + "").equals("null") ? "" : selectedList.get(i).getTradeAreaName() + "");
+            sheetRow.createCell(4).setCellValue((selectedList.get(i).getAddress() + "").equals("null") ? "" : selectedList.get(i).getAddress() + "");
+            sheetRow.createCell(5).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null") ? "" : selectedList.get(i).getAddressIds() + "");
+            sheetRow.createCell(6).setCellValue((selectedList.get(i).getShopName() + "").equals("null") ? "" : selectedList.get(i).getShopName() + "");
+            sheetRow.createCell(7).setCellValue((selectedList.get(i).getShopNo() + "").equals("null") ? "" : selectedList.get(i).getShopNo() + "");
+            sheetRow.createCell(8).setCellValue((selectedList.get(i).getArea() + "").equals("null") ? "" : selectedList.get(i).getArea() + "");
+            sheetRow.createCell(9).setCellValue((selectedList.get(i).getStatus() + "").equals("null") ? "" : selectedList.get(i).getStatus() + "");
+            sheetRow.createCell(10).setCellValue((selectedList.get(i).getRemark() + "").equals("null") ? "" : selectedList.get(i).getRemark() + "");
+            sheetRow.createCell(11).setCellValue((selectedList.get(i).getEnterpriseName() + "").equals("null") ? "" : selectedList.get(i).getEnterpriseName() + "");
+            //公共字段
+            sheetRow.createCell(12).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null") ? "" : selectedList.get(i).getCreateTime() + "");
+            sheetRow.createCell(13).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null") ? "" : selectedList.get(i).getCreateBy() + "");
+            sheetRow.createCell(14).setCellValue((selectedList.get(i).getCreateName() + "").equals("null") ? "" : selectedList.get(i).getCreateName() + "");
+            sheetRow.createCell(15).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null") ? "" : selectedList.get(i).getUpdateTime() + "");
+            sheetRow.createCell(16).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null") ? "" : selectedList.get(i).getUpdateBy() + "");
+            sheetRow.createCell(17).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null") ? "" : selectedList.get(i).getUpdateName() + "");
+            sheetRow.createCell(18).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null") ? "" : selectedList.get(i).getDeleteStatus() + "");
+            count += 1;
+        }
+        //建立输出流,输出文件
+        FileOutputStream fos = new FileOutputStream(filepath);
 
-		workbook.write(fos);
-		fos.flush();
-		//关闭输出流
-		fos.close();
-		workbook.close();
-		System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
-		return "数据导出完成!共导出 " + count + " 条数据。";
-	}
+        workbook.write(fos);
+        fos.flush();
+        //关闭输出流
+        fos.close();
+        workbook.close();
+        System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
+        return "数据导出完成!共导出 " + count + " 条数据。";
+    }
 
-	/** 远程调用方法 */
-	public boolean shopDto(ShopDto shopDto) throws Exception {
-		TbShop tbShop = new TbShop();
-		BeanUtils.copyProperties(shopDto,tbShop);
-		//根据编号进行事务处理
-		List<TbShop> tbShopList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(TbShop::getPlatSeqNo, shopDto.getPlatSeqNo()));
-		if(tbShopList.size() == 0){
-			//去重
-			List<TbShop> tbShops = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>().eq(TbShop::getPlatSeqNo, shopDto.getPlatSeqNo()));
-			if(tbShops.size() != 0)throw new ServiceException("\n该店铺已存在。platSeqNo = " + shopDto.getPlatSeqNo() + "\n");
-			//无则新增商铺
-			tbShop.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认可用
-			tbShop.setCreateTime(new Date()); // 创建时间
-			tbShop.setCreateName("航通"); // 创建人
-			tbShop.setStatus(Status.STATUS_ONE.getCode()); // 可用状态
-			int insert = tbShopMapper.insert(tbShop);
-			long primarykey = SP.publicMapper.getPrimarykey();
-			//新增外籍商户
-			if(insert == 1){
-				//去重
-				List<TbEnterprise> tbEnterpriseList = tbEnterpriseMapper.selectList(new LambdaQueryWrapper<TbEnterprise>().eq(TbEnterprise::getPlatSeqNo, shopDto.getPlatSeqNo()));
-				if(tbEnterpriseList.size() != 0)throw new ServiceException("\n该外籍商户信息已存在。 platSeqNo = " + shopDto.getPlatSeqNo() + "\n");
-				TbEnterprise enterprise = new TbEnterprise();
-				BeanUtils.copyProperties(tbShop,enterprise);
-				//设置基本属性
-				enterprise.setOwnerName(shopDto.getOwnerName()); // 个人姓名
-				enterprise.setDeleteStatus(Long.valueOf(DeleteStatus.DELETE_STATUS_ON.getCode())); // 逻辑删除,默认未删除
-				enterprise.setJudgeStatus(JudgeStatus.JUDGE_STATUS_ONE.getCode());  // 审核状态,默认审核通过
-				enterprise.setJudgeTime(new Date()); // 审核时间
-				enterprise.setShopId(primarykey); // 关联自己旗下的店铺  店铺ID
-				enterprise.setShopName(shopDto.getShopName()); // 店铺ID
-				enterprise.setBankAccount(shopDto.getBankAccount()); // 银行账户
-				enterprise.setBank(shopDto.getBank()); // 银行名称
-				enterprise.setAddress(shopDto.getAddress()); // 地址
-				enterprise.setType(null);  //  商户分类(自营商铺=自营商铺,劳务商铺=劳务商铺)
-				enterprise.setIsLock(IsLock.IS_LOCK_ON.getCode()); // 默认未被锁定
-				//保存
-				int insert1 = tbEnterpriseMapper.insert(enterprise);
-				if(insert1 == 1){
-					//创建商家保存对象
-					EnterpriseDto enterpriseDto = new EnterpriseDto();
-					//查询数据库内的商家
-					List<TbEnterprise> tbEnterprises = tbEnterpriseMapper.selectList(new LambdaQueryWrapper<TbEnterprise>().eq(TbEnterprise::getPlatSeqNo, enterprise.getPlatSeqNo()));
-					//将数据拷贝至enterpriseDto
-					BeanUtils.copyProperties(tbEnterprises.get(0),enterpriseDto);
-					//远程调用生成商家账户方法
-					int i = 1;
-					i = adminInterface.generateEnterpriseAccount(enterpriseDto);
+    /**
+     * 远程调用方法
+     */
+    public boolean shopDto(ShopDto shopDto) throws Exception {
+        String tradeCode = shopDto.getFieldCode();
+        TbTradeArea tbTradeArea = tbTradeAreaService.updateHandler(tradeCode, shopDto.getFieldName());
+        TbShop tbShop = this.findByCode(shopDto.getShopNo());
+        if (tbShop == null) {
+            tbShop = new TbShop();
+            tbShop.setCreateTime(new Date());
+        }
+        BeanUtils.copyProperties(shopDto, tbShop, "id");
+        //无则新增商铺
+        tbShop.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认可用
+        tbShop.setTradeAreaId(tbTradeArea.getId())
+                .setTradeAreaName(tbTradeArea.getName()); // 创建时间
+        tbShop.setCreateName("航通"); // 创建人
+        tbShop.setStatus(Status.STATUS_ONE.getCode()); // 可用状态
+        this.saveOrUpdate(tbShop);
+        TbEnterprise enterprise = tbEnterpriseService.findBydutyParagraph(shopDto.getShopSccd());
+        boolean isNew = false;
+        if (enterprise == null) {
+            isNew = true;
+            enterprise = new TbEnterprise();
+        }
+        BeanUtils.copyProperties(tbShop, enterprise, "id");
+        //设置基本属性
+        enterprise.setOwnerName(shopDto.getOwnerName()); // 个人姓名
+        enterprise.setDeleteStatus(Long.valueOf(DeleteStatus.DELETE_STATUS_ON.getCode())); // 逻辑删除,默认未删除
+        enterprise.setJudgeStatus(JudgeStatus.JUDGE_STATUS_ONE.getCode());  // 审核状态,默认审核通过
+        enterprise.setJudgeTime(new Date()); // 审核时间
+        enterprise.setShopId(Long.valueOf(tbShop.getId())); // 关联自己旗下的店铺  店铺ID
+        enterprise.setShopName(shopDto.getShopName()); // 店铺ID
+        enterprise.setBankAccount(shopDto.getBankAccount()); // 银行账户
+        enterprise.setBank(shopDto.getBank()); // 银行名称
+        enterprise.setAddress(shopDto.getAddress()); // 地址
+        enterprise.setType(null);  //  商户分类(自营商铺=自营商铺,劳务商铺=劳务商铺)
+        enterprise.setIsLock(IsLock.IS_LOCK_ON.getCode()); // 默认未被锁定
+        enterprise.setTradeAreaId(tbTradeArea.getId()).setTradeAreaName(tbTradeArea.getName());
+        tbEnterpriseService.saveOrUpdate(enterprise);
+        tbShop.setEnterpriseId(enterprise.getId()).setEnterpriseName(enterprise.getOwnerName());
+        this.updateById(tbShop);
+        //新增外籍商户
+        if (isNew) {
+            //创建商家保存对象
+            EnterpriseDto enterpriseDto = new EnterpriseDto();
+            //查询数据库内的商家
+            //将数据拷贝至enterpriseDto
+            BeanUtils.copyProperties(enterprise, enterpriseDto);
+            //远程调用生成商家账户方法
+            adminInterface.generateEnterpriseAccount(enterpriseDto);
+            return true;
+        }
+        return true;
+    }
 
-					if(i != 1)
-						throw new RuntimeException("\n添加商铺时,保存店铺内的外籍商户信息错误。 id = " + tbEnterprises.get(0).getId() + "\n");
-					return true;
-				}
-			}
-		}
-		//修改
-		// todo: 现在同步生成外籍商户信息和appUser信息,当商铺电话发生修改时,对应的外籍商户电话和appUser账号同步修改???
-		BeanUtils.copyProperties(tbShopList.get(0),tbShop);
-		BeanUtils.copyProperties(shopDto,tbShop);
-		int i = tbShopMapper.updateById(tbShop);
-		return i == 1;
-	}
+    /**
+     * 根据编号查询
+     *
+     * @param shopNo
+     * @return
+     */
+    public TbShop findByCode(String shopNo) {
+        QueryWrapper<TbShop> ew = new QueryWrapper<>();
+        ew.lambda().eq(TbShop::getShopNo, shopNo);
+        List<TbShop> list = list(ew);
+        return list.isEmpty() ? null : list.get(0);
+    }
 
-	/** 远程调用: 根据电话查询商铺 */
-	public List<ShopDto> getShopDtoListByPhone(String phone){
-		List<TbShop> tbShopList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>()
-				.eq(TbShop::getOwnerTel, phone)
+    /**
+     * 远程调用: 根据电话查询商铺
+     */
+    public List<ShopDto> getShopDtoListByPhone(String phone) {
+        List<TbShop> tbShopList = tbShopMapper.selectList(new LambdaQueryWrapper<TbShop>()
+                        .eq(TbShop::getOwnerTel, phone)
 //				.eq(TbShop::getStatus, Status.STATUS_ONE.getCode())
 //				.eq(TbShop::getDeleteStatus,DeleteStatus.DELETE_STATUS_ON.getCode())
 //				.eq(TbShop::getEDStatus, HtDeleteStatus.DELETE_STATUS_ONE.getCode())
-		);
-		List<ShopDto> result = new ArrayList<>();
-		if(tbShopList.size() > 0){
-			tbShopList.forEach(item -> {
-				ShopDto shopDto = new ShopDto();
-				BeanUtils.copyProperties(item,shopDto);
-				result.add(shopDto);
-			});
-		}
-		return result;
-	}
+        );
+        List<ShopDto> result = new ArrayList<>();
+        if (tbShopList.size() > 0) {
+            tbShopList.forEach(item -> {
+                ShopDto shopDto = new ShopDto();
+                BeanUtils.copyProperties(item, shopDto);
+                result.add(shopDto);
+            });
+        }
+        return result;
+    }
 
 }

+ 1 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeArea.java

@@ -79,6 +79,7 @@ public class TbTradeArea extends Model<TbTradeArea> implements Serializable {
 	 * 创建者id 
 	 */
 	private String createBy;	
+	private String code;
 
 	/**
 	 * 创建者名称 

+ 236 - 198
sp-service/level-one-server/src/main/java/com/pj/tb_trade_area/TbTradeAreaService.java

@@ -7,7 +7,9 @@ import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.pj.api.consts.FeignFactory;
 import com.pj.api.dto.DistrictDTO;
 import com.pj.current.satoken.StpUserUtil;
@@ -31,208 +33,244 @@ import javax.swing.filechooser.FileSystemView;
 
 /**
  * Service: tb_trade_area -- 贸易区域
- * @author qzy 
+ *
+ * @author qzy
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
-public class TbTradeAreaService extends ServiceImpl<TbTradeAreaMapper, TbTradeArea> implements IService<TbTradeArea>{
-
-	/** 底层 Mapper 对象 */
-	@Autowired
-	TbTradeAreaMapper tbTradeAreaMapper;
-	@Autowired
-	TbGoodsMapper tbGoodsMapper;
-	@Autowired
-	private MethodTradeAreaService methodTradeAreaService;
-
-	/** 增 */
-	void add(TbTradeArea t){
-		List<DistrictDTO>districtDTOS= FeignFactory.adminInterface.getDistrictList(t.getAddressIds());
-		t.setAddress(districtDTOS.stream().map(DistrictDTO::getDistrict).collect(Collectors.joining()))
-				.setCreateTime(new Date()).setCreateName(StpUserUtil.getPCLoginInfo().getLoginName());
-		save(t);
-	}
-
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
-
-	/** 改 */
-	void update(TbTradeArea t){
-		List<DistrictDTO>districtDTOS= FeignFactory.adminInterface.getDistrictList(t.getAddressIds());
-		t.setAddress(districtDTOS.stream().map(DistrictDTO::getDistrict).collect(Collectors.joining()))
-				.setUpdateTime(new Date()).setUpdateName(StpUserUtil.getPCLoginInfo().getLoginName());
-		updateById(t);
-
-	}
-
-	/** 查 */
-	TbTradeArea getById(String id){
-		return super.getById(id);
-	}
-
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
-	List<TbTradeArea> getList(SoMap so) { 
-		return tbTradeAreaMapper.getList(so);	
-	}
-
-	/**
-	 *
-	 *向商品分类添加商品
-	 * @author loovi
-	 * @date
-	 */
-	public int addGoodsToTradeArea(Long tradeAreaId,Long [] goodsIds){
-		// 获取当前登录用户id
+public class TbTradeAreaService extends ServiceImpl<TbTradeAreaMapper, TbTradeArea> implements IService<TbTradeArea> {
+
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    TbTradeAreaMapper tbTradeAreaMapper;
+    @Autowired
+    TbGoodsMapper tbGoodsMapper;
+    @Autowired
+    private MethodTradeAreaService methodTradeAreaService;
+
+    /**
+     * 增
+     */
+    void add(TbTradeArea t) {
+        List<DistrictDTO> districtDTOS = FeignFactory.adminInterface.getDistrictList(t.getAddressIds());
+        t.setAddress(districtDTOS.stream().map(DistrictDTO::getDistrict).collect(Collectors.joining()))
+                .setCreateTime(new Date()).setCreateName(StpUserUtil.getPCLoginInfo().getLoginName());
+        save(t);
+    }
+
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
+
+    /**
+     * 改
+     */
+    void update(TbTradeArea t) {
+        List<DistrictDTO> districtDTOS = FeignFactory.adminInterface.getDistrictList(t.getAddressIds());
+        t.setAddress(districtDTOS.stream().map(DistrictDTO::getDistrict).collect(Collectors.joining()))
+                .setUpdateTime(new Date()).setUpdateName(StpUserUtil.getPCLoginInfo().getLoginName());
+        updateById(t);
+
+    }
+
+    /**
+     * 查
+     */
+    TbTradeArea getById(String id) {
+        return super.getById(id);
+    }
+
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<TbTradeArea> getList(SoMap so) {
+        return tbTradeAreaMapper.getList(so);
+    }
+
+    /**
+     * 向商品分类添加商品
+     *
+     * @author loovi
+     * @date
+     */
+    public int addGoodsToTradeArea(Long tradeAreaId, Long[] goodsIds) {
+        // 获取当前登录用户id
 //		Long loginId = StpUserUtil.getLoginIdAsLong();
-		int line = 0;
-		// 获取互市区信息
-		TbTradeArea tbTradeArea = tbTradeAreaMapper.selectById(tradeAreaId);
-		// 如果互市区不存在则抛异常
-		if (Objects.isNull(tbTradeArea)){
-			throw new RuntimeException("该商品类型不存在");
-		}
-		List<Long> list = Arrays.asList(goodsIds);
-		// 添加商品到互市区
-		for (Long goodsId : list) {
-			TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
-			if(Objects.isNull(tbGoods)){
-				throw new RuntimeException("该商品不存在");
-			}
-			int i =tbTradeAreaMapper.addGoodsToTradeArea(tradeAreaId,goodsId);
-			line = i+1;
-		}
-		return line;
-
-	}
-	/**
-	 *删除商品分类中的商品
-	 *
-	 * @author loovi
-	 * @date
-	 */
-	public int delGoodsFromTradeArea(Long tradeAreaId,Long [] goodsIds){
-
-		// 获取当前登录用户id
+        int line = 0;
+        // 获取互市区信息
+        TbTradeArea tbTradeArea = tbTradeAreaMapper.selectById(tradeAreaId);
+        // 如果互市区不存在则抛异常
+        if (Objects.isNull(tbTradeArea)) {
+            throw new RuntimeException("该商品类型不存在");
+        }
+        List<Long> list = Arrays.asList(goodsIds);
+        // 添加商品到互市区
+        for (Long goodsId : list) {
+            TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
+            if (Objects.isNull(tbGoods)) {
+                throw new RuntimeException("该商品不存在");
+            }
+            int i = tbTradeAreaMapper.addGoodsToTradeArea(tradeAreaId, goodsId);
+            line = i + 1;
+        }
+        return line;
+
+    }
+
+    /**
+     * 删除商品分类中的商品
+     *
+     * @author loovi
+     * @date
+     */
+    public int delGoodsFromTradeArea(Long tradeAreaId, Long[] goodsIds) {
+
+        // 获取当前登录用户id
 //		Long loginId = StpUserUtil.getLoginIdAsLong();
-		int line = 0;
-		// 获取互市区信息
-		TbTradeArea tbTradeArea = tbTradeAreaMapper.selectById(tradeAreaId);
-		// 如果互市区不存在则抛异常
-		if (Objects.isNull(tbTradeArea)){
-			throw new RuntimeException("该商品类型不存在");
-		}
-		List<Long> list = Arrays.asList(goodsIds);
-		// 从互市区删除商品
-		for (Long goodsId : list) {
-			TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
-			if(Objects.isNull(tbGoods)){
-				throw new RuntimeException("该商品不存在");
-			}
-			int i =tbTradeAreaMapper.delGoodsFromTradeArea(tradeAreaId,goodsId);
-			line = i+1;
-		}
-		return line;
-	}
-
-
-
-
-	/**
-	 * 导入
-	 * @param file excel文件
-	 * @return
-	 * @throws IOException
-	 */
-	public String importData(MultipartFile file) throws IOException {
-		System.out.println("\n开始执行文件上传....\n");
-
-		//判空
-		if(file.isEmpty()) return "文件为空,无法执行上传...";
-		//获取文件上传数据
-		HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
-		//获取第一页sheet
-		HSSFSheet sheet = wb.getSheetAt(0);
-		//定义计数器
-		int count = 0;
-		//定义行对象
-		HSSFRow row = null;
-		//解析数据封装到集合
-		count = methodTradeAreaService.importMethod(row, sheet, count);
-		wb.close();
-		System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
-		return "上传完成,共上传"  + count + "条"  + "数据。";
-	}
-
-	/**
-	 * 导出 excel文件
-	 * @param keyword
-	 * @return
-	 */
-	public String outportExcel(String keyword,String filepath) throws IOException {
-		System.out.println("\n开始执行文件导出....\n");
-		//导出的文件的路径
-		if(filepath == null || filepath.trim().equals("")){
-			// 获取当前用户的桌面路径
-			FileSystemView fileSystemView = FileSystemView.getFileSystemView();
-			filepath = fileSystemView.getHomeDirectory().getPath();
-		}
-		filepath = filepath + "\\贸易区域审核数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
-		//根据需求查询数据
-		List<TbTradeArea> selectedList = tbTradeAreaMapper.selectList(new LambdaQueryWrapper<TbTradeArea>().eq(StringUtils.isNoneBlank(keyword), TbTradeArea::getName, keyword));
-		if(selectedList.size() == 0)return "没有可导出的数据。";
-		//建立excel对象封装数据
-		HSSFWorkbook workbook = new HSSFWorkbook();
-		//创建excel表格右下角的sheet页名称
-		HSSFSheet sheet = workbook.createSheet("1");
-		//创建表头
-		HSSFRow row = sheet.createRow(0);
-		row.createCell(0).setCellValue("序号");
-		row.createCell(1).setCellValue("区域名称");
-		row.createCell(2).setCellValue("区域IDs");
-		row.createCell(3).setCellValue("地址详情");
-		row.createCell(4).setCellValue("地址");
-
-		row.createCell(28).setCellValue("创建时间");
-		row.createCell(29).setCellValue("创建人编号");
-		row.createCell(30).setCellValue("创建人名称");
-		row.createCell(31).setCellValue("更新时间");
-		row.createCell(32).setCellValue("更新人编号");
-		row.createCell(33).setCellValue("更新人名称");
-		row.createCell(34).setCellValue("删除状态");
-
-		//定义计数器
-		int count = 0;
-		//遍历集合
-		for (int i = 0; i < selectedList.size(); i++) {
-			HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
-			sheetRow.createCell(0).setCellValue(i + 1);
-			sheetRow.createCell(1).setCellValue((selectedList.get(i).getName() + "").equals("null")? "": selectedList.get(i).getName() + "");
-			sheetRow.createCell(2).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null")? "": selectedList.get(i).getAddressIds() + "");
-			sheetRow.createCell(3).setCellValue((selectedList.get(i).getDetailAddress() + "").equals("null")? "": selectedList.get(i).getDetailAddress() + "");
-			sheetRow.createCell(4).setCellValue((selectedList.get(i).getAddress() + "").equals("null")? "": selectedList.get(i).getAddress() + "");
-
-			//公共字段
-			sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null")? "": selectedList.get(i).getCreateTime() + "");
-			sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null")? "": selectedList.get(i).getCreateBy() + "");
-			sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null")? "": selectedList.get(i).getCreateName() + "");
-			sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null")? "": selectedList.get(i).getUpdateTime() + "");
-			sheetRow.createCell(26).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null")? "": selectedList.get(i).getUpdateBy() + "");
-			sheetRow.createCell(27).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null")? "": selectedList.get(i).getUpdateName() + "");
-			sheetRow.createCell(28).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null")? "": selectedList.get(i).getDeleteStatus() + "");
-			count += 1;
-		}
-		//建立输出流,输出文件
-		FileOutputStream fos = new FileOutputStream(filepath);
-
-		workbook.write(fos);
-		fos.flush();
-		//关闭输出流
-		fos.close();
-		workbook.close();
-		System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
-		return "数据导出完成!共导出 " + count + " 条数据。";
-	}
+        int line = 0;
+        // 获取互市区信息
+        TbTradeArea tbTradeArea = tbTradeAreaMapper.selectById(tradeAreaId);
+        // 如果互市区不存在则抛异常
+        if (Objects.isNull(tbTradeArea)) {
+            throw new RuntimeException("该商品类型不存在");
+        }
+        List<Long> list = Arrays.asList(goodsIds);
+        // 从互市区删除商品
+        for (Long goodsId : list) {
+            TbGoods tbGoods = tbGoodsMapper.selectById(goodsId);
+            if (Objects.isNull(tbGoods)) {
+                throw new RuntimeException("该商品不存在");
+            }
+            int i = tbTradeAreaMapper.delGoodsFromTradeArea(tradeAreaId, goodsId);
+            line = i + 1;
+        }
+        return line;
+    }
+
+
+    /**
+     * 导入
+     *
+     * @param file excel文件
+     * @return
+     * @throws IOException
+     */
+    public String importData(MultipartFile file) throws IOException {
+        System.out.println("\n开始执行文件上传....\n");
+
+        //判空
+        if (file.isEmpty()) return "文件为空,无法执行上传...";
+        //获取文件上传数据
+        HSSFWorkbook wb = new HSSFWorkbook(file.getInputStream());
+        //获取第一页sheet
+        HSSFSheet sheet = wb.getSheetAt(0);
+        //定义计数器
+        int count = 0;
+        //定义行对象
+        HSSFRow row = null;
+        //解析数据封装到集合
+        count = methodTradeAreaService.importMethod(row, sheet, count);
+        wb.close();
+        System.out.println("\n文件上传完成,共上传 " + count + "条 " + "数据...\n");
+        return "上传完成,共上传" + count + "条" + "数据。";
+    }
+
+    /**
+     * 导出 excel文件
+     *
+     * @param keyword
+     * @return
+     */
+    public String outportExcel(String keyword, String filepath) throws IOException {
+        System.out.println("\n开始执行文件导出....\n");
+        //导出的文件的路径
+        if (filepath == null || filepath.trim().equals("")) {
+            // 获取当前用户的桌面路径
+            FileSystemView fileSystemView = FileSystemView.getFileSystemView();
+            filepath = fileSystemView.getHomeDirectory().getPath();
+        }
+        filepath = filepath + "\\贸易区域审核数据表_" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx";
+        //根据需求查询数据
+        List<TbTradeArea> selectedList = tbTradeAreaMapper.selectList(new LambdaQueryWrapper<TbTradeArea>().eq(StringUtils.isNoneBlank(keyword), TbTradeArea::getName, keyword));
+        if (selectedList.size() == 0) return "没有可导出的数据。";
+        //建立excel对象封装数据
+        HSSFWorkbook workbook = new HSSFWorkbook();
+        //创建excel表格右下角的sheet页名称
+        HSSFSheet sheet = workbook.createSheet("1");
+        //创建表头
+        HSSFRow row = sheet.createRow(0);
+        row.createCell(0).setCellValue("序号");
+        row.createCell(1).setCellValue("区域名称");
+        row.createCell(2).setCellValue("区域IDs");
+        row.createCell(3).setCellValue("地址详情");
+        row.createCell(4).setCellValue("地址");
+
+        row.createCell(28).setCellValue("创建时间");
+        row.createCell(29).setCellValue("创建人编号");
+        row.createCell(30).setCellValue("创建人名称");
+        row.createCell(31).setCellValue("更新时间");
+        row.createCell(32).setCellValue("更新人编号");
+        row.createCell(33).setCellValue("更新人名称");
+        row.createCell(34).setCellValue("删除状态");
+
+        //定义计数器
+        int count = 0;
+        //遍历集合
+        for (int i = 0; i < selectedList.size(); i++) {
+            HSSFRow sheetRow = sheet.createRow(sheet.getLastRowNum() + 1);
+            sheetRow.createCell(0).setCellValue(i + 1);
+            sheetRow.createCell(1).setCellValue((selectedList.get(i).getName() + "").equals("null") ? "" : selectedList.get(i).getName() + "");
+            sheetRow.createCell(2).setCellValue((selectedList.get(i).getAddressIds() + "").equals("null") ? "" : selectedList.get(i).getAddressIds() + "");
+            sheetRow.createCell(3).setCellValue((selectedList.get(i).getDetailAddress() + "").equals("null") ? "" : selectedList.get(i).getDetailAddress() + "");
+            sheetRow.createCell(4).setCellValue((selectedList.get(i).getAddress() + "").equals("null") ? "" : selectedList.get(i).getAddress() + "");
+
+            //公共字段
+            sheetRow.createCell(22).setCellValue((selectedList.get(i).getCreateTime() + "").equals("null") ? "" : selectedList.get(i).getCreateTime() + "");
+            sheetRow.createCell(23).setCellValue((selectedList.get(i).getCreateBy() + "").equals("null") ? "" : selectedList.get(i).getCreateBy() + "");
+            sheetRow.createCell(24).setCellValue((selectedList.get(i).getCreateName() + "").equals("null") ? "" : selectedList.get(i).getCreateName() + "");
+            sheetRow.createCell(25).setCellValue((selectedList.get(i).getUpdateTime() + "").equals("null") ? "" : selectedList.get(i).getUpdateTime() + "");
+            sheetRow.createCell(26).setCellValue((selectedList.get(i).getUpdateBy() + "").equals("null") ? "" : selectedList.get(i).getUpdateBy() + "");
+            sheetRow.createCell(27).setCellValue((selectedList.get(i).getUpdateName() + "").equals("null") ? "" : selectedList.get(i).getUpdateName() + "");
+            sheetRow.createCell(28).setCellValue((selectedList.get(i).getDeleteStatus() + "").equals("null") ? "" : selectedList.get(i).getDeleteStatus() + "");
+            count += 1;
+        }
+        //建立输出流,输出文件
+        FileOutputStream fos = new FileOutputStream(filepath);
+
+        workbook.write(fos);
+        fos.flush();
+        //关闭输出流
+        fos.close();
+        workbook.close();
+        System.out.println("\n数据导出完成!共导出 " + count + " 条数据。");
+        return "数据导出完成!共导出 " + count + " 条数据。";
+    }
+
+    public TbTradeArea findByCode(String tradeCode) {
+        QueryWrapper<TbTradeArea> ew = new QueryWrapper<>();
+        ew.lambda().eq(TbTradeArea::getCode, tradeCode);
+        List<TbTradeArea> list = this.list(ew);
+        return list.isEmpty() ? null : list.get(0);
+    }
 
+    public TbTradeArea updateHandler(String tradeCode, String fieldName) {
+        TbTradeArea tbTradeArea = this.findByCode(tradeCode);
+        if (tbTradeArea == null) {
+            tbTradeArea = new TbTradeArea();
+            tbTradeArea.setCode(tradeCode).setName(fieldName).setCreateTime(new Date()).setCreateBy("async");
+            this.save(tbTradeArea);
+        } else {
+            if (!StrUtil.isEmpty(fieldName)){
+                tbTradeArea.setName(fieldName)
+                        .setUpdateTime(new Date()).setUpdateBy("async");
+                this.updateById(tbTradeArea);
+            }
+        }
+        return tbTradeArea;
+    }
 }

+ 5 - 42
sp-service/sp-admin/src/main/java/com/pj/project/app_menu/AppMenuController.java

@@ -27,57 +27,20 @@ public class AppMenuController {
 	@Autowired
 	AppMenuService appMenuService;
 
-	/** 增 */  
-	@RequestMapping("add")
-//	@SaCheckPermission(AppMenu.PERMISSION_CODE_ADD)
-	public AjaxJson add(AppMenu a){
-		appMenuService.add(a);
-		a = appMenuService.getById(SP.publicMapper.getPrimarykey());
-		return AjaxJson.getSuccessData(a);
-	}
-
-	/** 删 */  
-	@RequestMapping("delete")
-//	@SaCheckPermission(AppMenu.PERMISSION_CODE_DEL)
-	public AjaxJson delete(Long id){
-		 appMenuService.delete(id);
-		return AjaxJson.getSuccess();
-	}
-	
-	/** 删 - 根据id列表 */  
-	@RequestMapping("deleteByIds")
-//	@SaCheckPermission(AppMenu.PERMISSION_CODE_DEL)
-	public AjaxJson deleteByIds(){
-		List<Long> ids = SoMap.getRequestSoMap().getListByComma("ids", long.class); 
-		int line = SP.publicMapper.deleteByIds(AppMenu.TABLE_NAME, ids);
-		return AjaxJson.getByLine(line);
-	}
-	
-	/** 改 */  
-	@RequestMapping("update")
-//	@SaCheckPermission(AppMenu.PERMISSION_CODE_EDIT)
-	public AjaxJson update(AppMenu a){
-		appMenuService.update(a);
-		return AjaxJson.getSuccess();
-	}
 
-	/** 查 - 根据id */  
-	@RequestMapping("getById")
-//		@SaCheckPermission(AppMenu.PERMISSION_CODE)
-	public AjaxJson getById(Long id){
-		AppMenu a = appMenuService.getById(id);
-		return AjaxJson.getSuccessData(a);
-	}
 
 	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */  
 	@RequestMapping("getList")
-//		@SaCheckPermission(AppMenu.PERMISSION_CODE)
 	public AjaxJson getList() {
 		SoMap so = SoMap.getRequestSoMap();
+		so.put("sortType","5");
+		so.put("enable","1");
 		List<AppMenu> list = appMenuService.getList(so.startPage());
 		return AjaxJson.getPageData(so.getDataCount(), list);
 	}
-	
+
+
+
 	
 	
 	/** 改 - 状态(0=禁用,1=启用) */  

+ 1 - 0
sp-service/sp-admin/src/main/java/com/pj/project/app_menu/AppMenuMapper.java

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
 
 import com.pj.utils.so.*;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 /**

+ 3 - 10
sp-service/sp-admin/src/main/java/com/pj/project/app_menu/AppMenuMapper.xml

@@ -42,7 +42,7 @@
 			<when test='sortType == 2'> path desc </when>
 			<when test='sortType == 3'> menu_name desc </when>
 			<when test='sortType == 4'> icon desc </when>
-			<when test='sortType == 5'> sort desc </when>
+			<when test='sortType == 5'> sort asc </when>
 			<when test='sortType == 6'> enable desc </when>
 			<when test='sortType == 7'> auth desc </when>
 			<when test='sortType == 8'> create_time desc </when>
@@ -54,14 +54,7 @@
 			<otherwise> id desc </otherwise>
 		</choose>
 	</select>
-	
-	
-	
-	
-	
-	
-	
-	
-	
+
+
 
 </mapper>

+ 1 - 1
sp-service/sp-admin/src/main/java/com/pj/project/app_menu/AppMenuService.java

@@ -45,6 +45,6 @@ public class AppMenuService extends ServiceImpl<AppMenuMapper, AppMenu> implemen
 	List<AppMenu> getList(SoMap so) { 
 		return appMenuMapper.getList(so);	
 	}
-	
+
 
 }

+ 5 - 1
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUser.java

@@ -80,7 +80,11 @@ public class AppUser extends Model<AppUser> implements Serializable {
 	/**
 	 * 人证时间 
 	 */
-	private String authTime;	
+	private String authTime;
+	/**
+	 *人脸库ID
+	 */
+	private String faceId;
 
 	/**
 	 * 登录次数 

+ 404 - 357
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserService.java

@@ -8,6 +8,8 @@ import java.util.stream.Collectors;
 
 import cn.dev33.satoken.spring.SpringMVCUtil;
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.json.JSONUtil;
+import cn.hutool.log.StaticLog;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.pj.api.client.admin.AdminInterface;
 import com.pj.api.client.level_one_server.LevelOneServerInterface;
@@ -50,155 +52,181 @@ import org.springframework.transaction.annotation.Transactional;
  */
 @Service
 @Transactional(rollbackFor = Exception.class)
-public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implements IService<AppUser>{
-
-	/** 底层 Mapper 对象 */
-	@Autowired
-	AppUserMapper appUserMapper;
-	/** 密码加密模式 */
-	@Autowired
-	private PasswordEncoder passwordEncoder;
-	//权限字符
-	@Autowired
-	private ReRoleMenuMapper reRoleMenuMapper;
-	/** 方法抽取 */
-	@Autowired
-	private MethodAppUserService methodAppUserService;
-	/** 阿里云验证码 */
-	@Autowired
-	private SmsRetryService smsRetryService;
-	@Autowired
-	private LevelOneServerInterface levelOneServerInterface;
-	@Autowired
-	private TransportInterface transportInterface;
-	@Autowired
-	AppUserLoginLogService appUserLoginLogService;
-
-	/** 验证码前缀 */
-	String PREFIX = "app_user:phone:sms_code:";
-
-
-
-
-	/** 增 */
-	void add(AppUser t){
-		save(t);
-	}
+public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implements IService<AppUser> {
 
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
+    /**
+     * 底层 Mapper 对象
+     */
+    @Autowired
+    AppUserMapper appUserMapper;
+    /**
+     * 密码加密模式
+     */
+    @Autowired
+    private PasswordEncoder passwordEncoder;
+    //权限字符
+    @Autowired
+    private ReRoleMenuMapper reRoleMenuMapper;
+    /**
+     * 方法抽取
+     */
+    @Autowired
+    private MethodAppUserService methodAppUserService;
+    /**
+     * 阿里云验证码
+     */
+    @Autowired
+    private SmsRetryService smsRetryService;
+    @Autowired
+    private LevelOneServerInterface levelOneServerInterface;
+    @Autowired
+    private TransportInterface transportInterface;
+    @Autowired
+    AppUserLoginLogService appUserLoginLogService;
 
-	/** 改 */
-	void update(AppUser a){
-		a.setUpdateTime(new Date());
-		updateById(a);
+    /**
+     * 验证码前缀
+     */
+    String PREFIX = "app_user:phone:sms_code:";
 
-	}
 
-	/** 查 */
-	AppUser getById(Long id){
-		return super.getById(id);
-	}
+    /**
+     * 增
+     */
+    void add(AppUser t) {
+        save(t);
+    }
 
-	/**
-	 * 个人中心-个人详细信息
-	 * @return
-	 */
-	AppUserVo getSelfInfo(){
-		//查询当前人
-		AppUser appUser = appUserMapper.selectById(StpAPPUserUtil.getAPPLoginInfo().getLoginId());
-		if(appUser == null)throw new ServiceException("当前用户信息异常!");
-		//获取当前组
-		//创建返回值对象
-		AppUserVo appUserVo = new AppUserVo();
-		//根据身份获取不同名称
-		appUserVo.setFk(appUser.getFkId());
-		methodAppUserService.getRoleName(appUserVo,appUser.getUserType());
-		//设置属性
-		appUserVo.setPhone(appUser.getPhone());
-		appUserVo.setName(appUser.getName());
-
-		return appUserVo;
-	}
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
 
-	/** 查询单个APP有效用户 */
-	public AppUserDto getUserById(Long id){
-		//查单个
-		AppUser appUser = appUserMapper.selectById(id);
-		if (appUser == null)return null;
-		//判断有效性
-		if(!appUser.getStatus().equals("0") && appUser.getDeleteStatus() != 0){
-			AppUserDto appUserDto = new AppUserDto();
-			BeanUtils.copyProperties(appUser,appUserDto);
-			return appUserDto;
-		}
-		return null;
-	}
+    /**
+     * 改
+     */
+    void update(AppUser a) {
+        a.setUpdateTime(new Date());
+        updateById(a);
 
-	/** 查集合 - 根据条件(参数为空时代表忽略指定条件) */
-	List<AppUser> getList(SoMap so) {
-		return appUserMapper.getList(so);
-	}
+    }
 
-	/** 启/停边民的app账号登陆限制 */
-	int isLock(String id, Integer type, Integer status){
-		//查询
-		LambdaQueryWrapper<AppUser> queryWrapper = new LambdaQueryWrapper<>();
-		queryWrapper.eq(AppUser::getFkId,id);
-		queryWrapper.eq(AppUser::getUserType,type);
-		AppUser appUser1 = appUserMapper.selectList(queryWrapper).get(0);
-		if(appUser1 == null)throw new RuntimeException("您进行修改的用户不存在!");
-		//设置状态
-		appUser1.setStatus(String.valueOf(status));
-		//保存
-		int i = appUserMapper.updateById(appUser1);
-		return i;
-	}
+    /**
+     * 查
+     */
+    AppUser getById(Long id) {
+        return super.getById(id);
+    }
 
-	/** 注册 */
-	boolean register(RegisterDto registerDto){
-		if(registerDto == null)return false;
-		//手机号去重
-		String phone = registerDto.getPhone();
-		if(appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone,phone).eq(AppUser::getDeleteStatus,DeleteStatus.DELETE_STATUS_ON.getCode())).size() != 0)
-			throw new RuntimeException("当前手机号已被注册!");
-		//开始进行实际注册
-		//1. 查询数据库内是否存在逻辑删除
-		List<Long> collect = appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, phone).eq(AppUser::getDeleteStatus, DeleteStatus.DELETE_STATUS_OFF.getCode())).stream().map(AppUser::getId).collect(Collectors.toList());
-		//删除旧数据
-		if(collect.size() > 0)appUserMapper.deleteBatchIds(collect);
-		//2.校验密码
-		if(!registerDto.getPassword().equals(registerDto.getRePassword()))throw new RuntimeException("两次密码校验不通过!");
-		//3.校验短信验证码
-		String smsCode = RedisUtil.get(PREFIX + registerDto.getPhone());
-		if(smsCode == null)throw new RuntimeException("验证码已过期,请重新发送!");
-		//比对验证码
-		if(!registerDto.getSmsCode().toString().equals(smsCode))throw new SecurityException("验证码输入错误,请检查!");
-		//4.开始新增
-		AppUser appUser = new AppUser();
-		//手机号
-		appUser.setPhone(phone);
-		//注册身份
-		appUser.setUserType(registerDto.getType());
-		//加密并设置登陆密码
-		String password = registerDto.getPassword();
-		String encode = passwordEncoder.encode(password);
-		appUser.setPassword(encode);
-		//创建单位
-		appUser.setCreateUnit("数据分中心");
-		//昵称
-		appUser.setName(registerDto.getNickName());
-		//创建时间
-		appUser.setCreateTime(new Date());
-		//默认可用
-		appUser.setStatus("1");
-		appUser.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
-		//保存
-		int insert = appUserMapper.insert(appUser);
-		return insert == 1;
-	}
+    /**
+     * 个人中心-个人详细信息
+     *
+     * @return
+     */
+    AppUserVo getSelfInfo() {
+        //查询当前人
+        AppUser appUser = appUserMapper.selectById(StpAPPUserUtil.getAPPLoginInfo().getLoginId());
+        if (appUser == null) throw new ServiceException("当前用户信息异常!");
+        //获取当前组
+        //创建返回值对象
+        AppUserVo appUserVo = new AppUserVo();
+        //根据身份获取不同名称
+        appUserVo.setFk(appUser.getFkId());
+        methodAppUserService.getRoleName(appUserVo, appUser.getUserType());
+        //设置属性
+        appUserVo.setPhone(appUser.getPhone());
+        appUserVo.setName(appUser.getName());
+
+        return appUserVo;
+    }
+
+    /**
+     * 查询单个APP有效用户
+     */
+    public AppUserDto getUserById(Long id) {
+        //查单个
+        AppUser appUser = appUserMapper.selectById(id);
+        if (appUser == null) return null;
+        //判断有效性
+        if (!appUser.getStatus().equals("0") && appUser.getDeleteStatus() != 0) {
+            AppUserDto appUserDto = new AppUserDto();
+            BeanUtils.copyProperties(appUser, appUserDto);
+            return appUserDto;
+        }
+        return null;
+    }
+
+    /**
+     * 查集合 - 根据条件(参数为空时代表忽略指定条件)
+     */
+    List<AppUser> getList(SoMap so) {
+        return appUserMapper.getList(so);
+    }
+
+    /**
+     * 启/停边民的app账号登陆限制
+     */
+    int isLock(String id, Integer type, Integer status) {
+        //查询
+        LambdaQueryWrapper<AppUser> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(AppUser::getFkId, id);
+        queryWrapper.eq(AppUser::getUserType, type);
+        AppUser appUser1 = appUserMapper.selectList(queryWrapper).get(0);
+        if (appUser1 == null) throw new RuntimeException("您进行修改的用户不存在!");
+        //设置状态
+        appUser1.setStatus(String.valueOf(status));
+        //保存
+        int i = appUserMapper.updateById(appUser1);
+        return i;
+    }
+
+    /**
+     * 注册
+     */
+    boolean register(RegisterDto registerDto) {
+        if (registerDto == null) return false;
+        //手机号去重
+        String phone = registerDto.getPhone();
+        if (appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, phone).eq(AppUser::getDeleteStatus, DeleteStatus.DELETE_STATUS_ON.getCode())).size() != 0)
+            throw new RuntimeException("当前手机号已被注册!");
+        //开始进行实际注册
+        //1. 查询数据库内是否存在逻辑删除
+        List<Long> collect = appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, phone).eq(AppUser::getDeleteStatus, DeleteStatus.DELETE_STATUS_OFF.getCode())).stream().map(AppUser::getId).collect(Collectors.toList());
+        //删除旧数据
+        if (collect.size() > 0) appUserMapper.deleteBatchIds(collect);
+        //2.校验密码
+        if (!registerDto.getPassword().equals(registerDto.getRePassword()))
+            throw new RuntimeException("两次密码校验不通过!");
+        //3.校验短信验证码
+        String smsCode = RedisUtil.get(PREFIX + registerDto.getPhone());
+        if (smsCode == null) throw new RuntimeException("验证码已过期,请重新发送!");
+        //比对验证码
+        if (!registerDto.getSmsCode().toString().equals(smsCode)) throw new SecurityException("验证码输入错误,请检查!");
+        //4.开始新增
+        AppUser appUser = new AppUser();
+        //手机号
+        appUser.setPhone(phone);
+        //注册身份
+        appUser.setUserType(registerDto.getType());
+        //加密并设置登陆密码
+        String password = registerDto.getPassword();
+        String encode = passwordEncoder.encode(password);
+        appUser.setPassword(encode);
+        //创建单位
+        appUser.setCreateUnit("数据分中心");
+        //昵称
+        appUser.setName(registerDto.getNickName());
+        //创建时间
+        appUser.setCreateTime(new Date());
+        //默认可用
+        appUser.setStatus("1");
+        appUser.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
+        //保存
+        int insert = appUserMapper.insert(appUser);
+        return insert == 1;
+    }
 
     /**
      * 用户登录
@@ -230,13 +258,13 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
         //比对密码
         String userPassword = appUser.getPassword();
         boolean matches = passwordEncoder.matches(dto.getPassword(), userPassword);
-        if (!matches){
+        if (!matches) {
             loginLog.setStatus("1");
             appUserLoginLogService.save(loginLog);
             return AjaxJson.getError("密码校验错误,请检查!");
         }
         //判断是否停用
-        if (appUser.getStatus().equals("0")){
+        if (appUser.getStatus().equals("0")) {
             loginLog.setStatus(IsLock.IS_LOCK_OFF.getCode() + "");
             appUserLoginLogService.save(loginLog);
             return AjaxJson.getError("该账户 " + appUser.getPhone() + " 已停用!");
@@ -248,110 +276,112 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
         //保存
         appUserMapper.updateById(appUser);
 
-		//开始执行登录
-		StpAPPUserUtil.login(appUser.getId());
-		// 组织返回参数,直接拿过来用的,然后自己改吧改吧
-		SoMap map = new SoMap();
-		//敏感信息置空
-		appUser.setPassword(null);
-		//执行
-		map.put("appUser", appUser);
-		//获取当前用户角色权限字符
-		List<ReRoleMenu> reRoleMenus = reRoleMenuMapper.selectList(new LambdaQueryWrapper<ReRoleMenu>().eq(ReRoleMenu::getAppRoleId, appUser.getUserType()));
-		//使用stream流对其reRoleMenus集合的权限字符进行过滤顺便转成String类型
-		List<String> per_list = reRoleMenus.stream().map(ReRoleMenu::getAppMenuId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.toList());
+        //开始执行登录
+        StpAPPUserUtil.login(appUser.getId());
+        // 组织返回参数,直接拿过来用的,然后自己改吧改吧
+        SoMap map = new SoMap();
+        //敏感信息置空
+        appUser.setPassword(null);
+        //执行
+        map.put("appUser", appUser);
+        //获取当前用户角色权限字符
+        List<ReRoleMenu> reRoleMenus = reRoleMenuMapper.selectList(new LambdaQueryWrapper<ReRoleMenu>().eq(ReRoleMenu::getAppRoleId, appUser.getUserType()));
+        //使用stream流对其reRoleMenus集合的权限字符进行过滤顺便转成String类型
+        List<String> per_list = reRoleMenus.stream().map(ReRoleMenu::getAppMenuId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.toList());
 //		if(reRoleMenus.size() == 0)return AjaxJson.getError("当前职务暂无权限!");
-		//过滤出权限字符
-		map.put("per_list", per_list);
-		map.put("tokenInfo", StpAPPUserUtil.getTokenInfo());
+        //过滤出权限字符
+        map.put("per_list", per_list);
+        map.put("tokenInfo", StpAPPUserUtil.getTokenInfo());
 //		StpAPPUserUtil.cachePerList(per_list);
-		APPLoginUserInfo info=new APPLoginUserInfo();
-		//获取区域
-		switch (appUser.getUserType()){
-			case 1:
-				PeopleDto rpcById = levelOneServerInterface.getRpcById(appUser.getFkId());
-				if(rpcById != null) {
-					info.setTradeAreaId(rpcById.getTradeAreaId());
-					info.setTradeAreaName(rpcById.getTradeAreaName());
-				}
-				break;
-			case 2:
-				PeopleDto leader = levelOneServerInterface.getRpcById(appUser.getFkId());
-				if(leader != null) {
-					info.setTradeAreaId(leader.getTradeAreaId());
-					info.setTradeAreaName(leader.getTradeAreaName());
-				}
-				break;
-			case 3:
-				System.out.println("收购商无互市区字段");
-				break;
-			case 4:
-				DriverDto driver = transportInterface.getByDriverId(appUser.getFkId());
-				if(driver != null) {
-					info.setTradeAreaId(driver.getTradeAreaId());
-					info.setTradeAreaName(driver.getTradeAreaName());
-				}
-				break;
-			case 5:
-				EnterpriseDto enterprise = levelOneServerInterface.getEnterpriseById(appUser.getFkId());
-				if(enterprise != null) {
-					info.setTradeAreaId(enterprise.getTradeAreaId());
-					info.setTradeAreaName(enterprise.getTradeAreaName());
-				}
-				break;
-			case 6:
-				CooperativeDto cooperative = levelOneServerInterface.getCooperativeById(appUser.getFkId());
-				if(cooperative != null) {
-					info.setTradeAreaId(cooperative.getTradeAreaId());
-					info.setTradeAreaName(cooperative.getTradeAreaName());
-				}
-				break;
-			default:
-				throw new SecurityException("身份信息有误");
-		}
+        APPLoginUserInfo info = new APPLoginUserInfo();
+        //获取区域
+        switch (appUser.getUserType()) {
+            case 1:
+                PeopleDto rpcById = levelOneServerInterface.getRpcById(appUser.getFkId());
+                if (rpcById != null) {
+                    info.setTradeAreaId(rpcById.getTradeAreaId());
+                    info.setTradeAreaName(rpcById.getTradeAreaName());
+                }
+                break;
+            case 2:
+                PeopleDto leader = levelOneServerInterface.getRpcById(appUser.getFkId());
+                if (leader != null) {
+                    info.setTradeAreaId(leader.getTradeAreaId());
+                    info.setTradeAreaName(leader.getTradeAreaName());
+                }
+                break;
+            case 3:
+                System.out.println("收购商无互市区字段");
+                break;
+            case 4:
+                DriverDto driver = transportInterface.getByDriverId(appUser.getFkId());
+                if (driver != null) {
+                    info.setTradeAreaId(driver.getTradeAreaId());
+                    info.setTradeAreaName(driver.getTradeAreaName());
+                }
+                break;
+            case 5:
+                EnterpriseDto enterprise = levelOneServerInterface.getEnterpriseById(appUser.getFkId());
+                if (enterprise != null) {
+                    info.setTradeAreaId(enterprise.getTradeAreaId());
+                    info.setTradeAreaName(enterprise.getTradeAreaName());
+                }
+                break;
+            case 6:
+                CooperativeDto cooperative = levelOneServerInterface.getCooperativeById(appUser.getFkId());
+                if (cooperative != null) {
+                    info.setTradeAreaId(cooperative.getTradeAreaId());
+                    info.setTradeAreaName(cooperative.getTradeAreaName());
+                }
+                break;
+            default:
+                throw new SecurityException("身份信息有误");
+        }
 
-		info.setLoginId(appUser.getId());
-		info.setLoginName(appUser.getName());
-		info.setFk(appUser.getFkId());
-		info.setUserType(appUser.getUserType());
-		StpAPPUserUtil.cacheAPPLoginInfo(info);
-		return AjaxJson.getSuccessData(map);
-	}
+        info.setLoginId(appUser.getId());
+        info.setLoginName(appUser.getName());
+        info.setFk(appUser.getFkId());
+        info.setUserType(appUser.getUserType());
+        StpAPPUserUtil.cacheAPPLoginInfo(info);
+        return AjaxJson.getSuccessData(map);
+    }
 
 
-	/** 忘记密码 */
-	AjaxJson forgetPassword(ForgetPasswordDto forgetPasswordDto){
-		//进行查询
-		List<AppUser> appUserList = appUserMapper.selectList
-				  (new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, forgetPasswordDto.getPhone())
-													.eq(AppUser::getDeleteStatus, DeleteStatus.DELETE_STATUS_ON.getCode())
-													.eq(AppUser::getStatus, IsLock.IS_LOCK_ON.getCode()));
-		//判断其手机号码可能存在的异常情况
-		if(appUserList.size() > 1)
-			return AjaxJson.getError("当前账户存在异常,请联系客服进行处理!");
-		if(appUserList.size() == 0)throw new RuntimeException("您当前手机号尚未进行注册!");
-		//获取当前手机号对象
-		AppUser appUser = appUserList.get(0);
-		//从缓存中获取验证码
-		String smsCode = RedisUtil.get(PREFIX + forgetPasswordDto.getPhone());
-		if(smsCode == null)return AjaxJson.getError("验证码已过期!");
-		//比对用户输入的验证码
-		boolean result = smsCode.equals(forgetPasswordDto.getSmsCode());
-		//进行验证码校验完成后的流程
-		if(result){
-			//密码校验
-			boolean equals = forgetPasswordDto.getPassword().equals(forgetPasswordDto.getRePassword());
-			//验证码匹配成功,执行修改密码逻辑
-			//1.判断其密码验证
-			if(equals){
-				//1.1 密码校验正确,设置新密码
-				String encode = passwordEncoder.encode(forgetPasswordDto.getRePassword());
-				appUser.setPassword(encode);
-				//1.2  执行保存
-				int i = appUserMapper.updateById(appUser);
-				if(i != 1)return AjaxJson.getError("密码重置失败!");
-				return AjaxJson.getSuccess("密码找回成功!");
-			}else {
+    /**
+     * 忘记密码
+     */
+    AjaxJson forgetPassword(ForgetPasswordDto forgetPasswordDto) {
+        //进行查询
+        List<AppUser> appUserList = appUserMapper.selectList
+                (new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, forgetPasswordDto.getPhone())
+                        .eq(AppUser::getDeleteStatus, DeleteStatus.DELETE_STATUS_ON.getCode())
+                        .eq(AppUser::getStatus, IsLock.IS_LOCK_ON.getCode()));
+        //判断其手机号码可能存在的异常情况
+        if (appUserList.size() > 1)
+            return AjaxJson.getError("当前账户存在异常,请联系客服进行处理!");
+        if (appUserList.size() == 0) throw new RuntimeException("您当前手机号尚未进行注册!");
+        //获取当前手机号对象
+        AppUser appUser = appUserList.get(0);
+        //从缓存中获取验证码
+        String smsCode = RedisUtil.get(PREFIX + forgetPasswordDto.getPhone());
+        if (smsCode == null) return AjaxJson.getError("验证码已过期!");
+        //比对用户输入的验证码
+        boolean result = smsCode.equals(forgetPasswordDto.getSmsCode());
+        //进行验证码校验完成后的流程
+        if (result) {
+            //密码校验
+            boolean equals = forgetPasswordDto.getPassword().equals(forgetPasswordDto.getRePassword());
+            //验证码匹配成功,执行修改密码逻辑
+            //1.判断其密码验证
+            if (equals) {
+                //1.1 密码校验正确,设置新密码
+                String encode = passwordEncoder.encode(forgetPasswordDto.getRePassword());
+                appUser.setPassword(encode);
+                //1.2  执行保存
+                int i = appUserMapper.updateById(appUser);
+                if (i != 1) return AjaxJson.getError("密码重置失败!");
+                return AjaxJson.getSuccess("密码找回成功!");
+            } else {
 
 				return AjaxJson.getError("两次密码校验不匹配,请重新尝试!");
 
@@ -363,93 +393,103 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
 		return AjaxJson.getError("验证码输入错误,请检查!");
 	}
 
-	/** 获取验证码 */
-	boolean getPhoneSmsCode(String phone) throws Exception {
-		//生成4位随机数
-		Random random = new Random();
-		int randomNumber = random.nextInt(9000) + 1000;
-		//保存到缓存,默认1分钟 todo:届时放开手机验证码 randomNumber
-		RedisUtil.setByMINUTES(PREFIX + phone,123 + "", 1);
-		//发送验证码短信
-		return true;
+    /**
+     * 获取验证码
+     */
+    boolean getPhoneSmsCode(String phone) throws Exception {
+        //生成4位随机数
+        Random random = new Random();
+        int randomNumber = random.nextInt(9000) + 1000;
+        //保存到缓存,默认1分钟 todo:届时放开手机验证码 randomNumber
+        RedisUtil.setByMINUTES(PREFIX + phone, 123 + "", 1);
+        //发送验证码短信
+        return true;
 
-	}
+    }
 
 
-	/** 更换角色 */
-	AjaxJson updateRole(String appRoleId){
-		// 获取当前用户角色权限字符
-		List<ReRoleMenu> reRoleMenus = reRoleMenuMapper.selectList(new LambdaQueryWrapper<ReRoleMenu>().eq(ReRoleMenu::getAppRoleId, appRoleId));
-		// 使用stream流对其reRoleMenus集合的权限字符进行过滤顺便转成String类型
-		List<String> per_list = reRoleMenus.stream().map(ReRoleMenu::getAppMenuId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.toList());
-		if(reRoleMenus.size() == 0)return AjaxJson.getError("当前用户角色暂无权限!");
+    /**
+     * 更换角色
+     */
+    AjaxJson updateRole(String appRoleId) {
+        // 获取当前用户角色权限字符
+        List<ReRoleMenu> reRoleMenus = reRoleMenuMapper.selectList(new LambdaQueryWrapper<ReRoleMenu>().eq(ReRoleMenu::getAppRoleId, appRoleId));
+        // 使用stream流对其reRoleMenus集合的权限字符进行过滤顺便转成String类型
+        List<String> per_list = reRoleMenus.stream().map(ReRoleMenu::getAppMenuId).collect(Collectors.toList()).stream().map(String::valueOf).collect(Collectors.toList());
+        if (reRoleMenus.size() == 0) return AjaxJson.getError("当前用户角色暂无权限!");
 
-		SoMap map = new SoMap();
-		map.put("per_list", per_list);
-		StpUserUtil.cachePerList(per_list);
+        SoMap map = new SoMap();
+        map.put("per_list", per_list);
+        StpUserUtil.cachePerList(per_list);
 
-		return AjaxJson.getSuccessData(map);
-	}
+        return AjaxJson.getSuccessData(map);
+    }
 
-	/**
-	 * 退出登录
-	 * @param appUserId appUser表主键
-	 * @return
-	 */
-	public String logout(Object appUserId){
-		if(appUserId == null || appUserId.toString().trim().equals(""))
-			throw new ServiceException("退出信息异常!");
-		StpAPPUserUtil.logout(appUserId);
-		return "退出登录成功!";
-	}
+    /**
+     * 退出登录
+     *
+     * @param appUserId appUser表主键
+     * @return
+     */
+    public String logout(Object appUserId) {
+        if (appUserId == null || appUserId.toString().trim().equals(""))
+            throw new ServiceException("退出信息异常!");
+        StpAPPUserUtil.logout(appUserId);
+        return "退出登录成功!";
+    }
 
-	/**
-	 * 修改密码
-	 * @param oldPassword 旧密码
-	 * @param newPassword 新密码
-	 * @param rePassword 确认密码
-	 * @return
-	 */
-	public boolean modifyPassword(String oldPassword,String newPassword,String rePassword){
-		//对比新密码和确认密码
-		if(!newPassword.equals(rePassword))throw new ServiceException("新密码和确认密码不一致!");
-
-		//获取user
-		APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
-		AppUser appUser = appUserMapper.selectById(appLoginInfo.getLoginId());
-		if(appUser == null)throw new SecurityException("当前账户信息异常!");
-		//旧密码比对
-		boolean result = passwordEncoder.matches(oldPassword,appUser.getPassword());
-		if(!result)throw new SecurityException("旧密码输入错误!");
-		//新密码进行编码
-		String password = passwordEncoder.encode(newPassword);
-		//执行修改
-		appUser.setPassword(password);
-		//设置基本属性
-		appUser.setUpdateTime(new Date());
-		//保存
-		return 1 == appUserMapper.updateById(appUser);
-	}
+    /**
+     * 修改密码
+     *
+     * @param oldPassword 旧密码
+     * @param newPassword 新密码
+     * @param rePassword  确认密码
+     * @return
+     */
+    public boolean modifyPassword(String oldPassword, String newPassword, String rePassword) {
+        //对比新密码和确认密码
+        if (!newPassword.equals(rePassword)) throw new ServiceException("新密码和确认密码不一致!");
+
+        //获取user
+        APPLoginUserInfo appLoginInfo = StpAPPUserUtil.getAPPLoginInfo();
+        AppUser appUser = appUserMapper.selectById(appLoginInfo.getLoginId());
+        if (appUser == null) throw new SecurityException("当前账户信息异常!");
+        //旧密码比对
+        boolean result = passwordEncoder.matches(oldPassword, appUser.getPassword());
+        if (!result) throw new SecurityException("旧密码输入错误!");
+        //新密码进行编码
+        String password = passwordEncoder.encode(newPassword);
+        //执行修改
+        appUser.setPassword(password);
+        //设置基本属性
+        appUser.setUpdateTime(new Date());
+        //保存
+        return 1 == appUserMapper.updateById(appUser);
+    }
 
-	/** 远程调用: 收购商认证 */
-	public AppUserDto getByPhoneAndUserType(String phone,Integer userType){
-		List<AppUser> appUsers = appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, phone).eq(AppUser::getUserType, userType).eq(AppUser::getDeleteStatus, DeleteStatus.DELETE_STATUS_ON.getCode()).eq(AppUser::getStatus, 1));
-		if(appUsers.size() != 1)throw new ServiceException("用户信息有误。");
-		AppUserDto appUserDto = new AppUserDto();
-		BeanUtils.copyProperties(appUsers.get(0),appUserDto);
-		return appUserDto;
-	}
+    /**
+     * 远程调用: 收购商认证
+     */
+    public AppUserDto getByPhoneAndUserType(String phone, Integer userType) {
+        List<AppUser> appUsers = appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, phone).eq(AppUser::getUserType, userType).eq(AppUser::getDeleteStatus, DeleteStatus.DELETE_STATUS_ON.getCode()).eq(AppUser::getStatus, 1));
+        if (appUsers.size() != 1) throw new ServiceException("用户信息有误。");
+        AppUserDto appUserDto = new AppUserDto();
+        BeanUtils.copyProperties(appUsers.get(0), appUserDto);
+        return appUserDto;
+    }
 
-	/** 远程调用: 保存appUser信息 */
-	public boolean saveAppUserInfo(AppUserDto appUser){
-		AppUser user = new AppUser();
-		BeanUtils.copyProperties(appUser,user);
-		int update = appUserMapper.updateById(user);
-		return update == 1;
-	}
+    /**
+     * 远程调用: 保存appUser信息
+     */
+    public boolean saveAppUserInfo(AppUserDto appUser) {
+        AppUser user = new AppUser();
+        BeanUtils.copyProperties(appUser, user);
+        int update = appUserMapper.updateById(user);
+        return update == 1;
+    }
 
 	/** 远程调用: 当从航通导入数据时,自动给边民生成账号 */
-	public boolean generatePeopleAccount(HtPeopleDto peopleDto) throws Exception {
+	public boolean generatePeopleAccount(PeopleDto peopleDto) throws Exception {
 		//检查是否重复注册
 		List<AppUser> appUsers = appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, peopleDto.getBorderTel()));
 		if(appUsers.size() != 0)throw new ServiceException("\n该用户已注册! phone = " + peopleDto.getBorderTel() + "\n");
@@ -479,53 +519,60 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
 			//todo: 届时放开注释
 //			boolean msg = smsRetryService.sendSmsRegisteMsg(null, "您好,您已成功注册[边民互市]app账号。账号:" + peopleDto.getBorderTel() + ", 初始密码:" + password + "。可前往app进行修改");
 //			return msg;
-			System.out.println("注册成功! 账户 = " + peopleDto.getBorderTel() + " password = " + password);
-			return true;
-		}
-		throw new RuntimeException("同步航通信息时,边民注册app信息失败,边民手机号为: " + peopleDto.getBorderTel() + "。 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
-	}
+            System.out.println("注册成功! 账户 = " + peopleDto.getBorderTel() + " password = " + password);
+            return true;
+        }
+        throw new RuntimeException("同步航通信息时,边民注册app信息失败,边民手机号为: " + peopleDto.getBorderTel() + "。 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+    }
 
-	/** 远程调用: 当从航通导入数据时,自动给外籍商户生成账号 */
-	public int generateEnterpriseAccount(EnterpriseDto enterpriseDto) throws Exception {
-		//判断是否已被注册
-		List<AppUser> appUsers = appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, enterpriseDto.getOwnerTel()));
-		if(appUsers.size() != 0)throw new ServiceException("\n该用户已注册! phone = " + enterpriseDto.getOwnerTel() + "\n");
-		//创建保存对象
-		AppUser appUser = new AppUser();
-		//设置基本属性
-		appUser.setAuth(1 + ""); // 默认已认证
-		appUser.setUserType(5); // 用户类型 1
-		appUser.setCreateTime(new Date()); // 创建时间
-		appUser.setPhone(enterpriseDto.getOwnerTel()); // 电话
-		appUser.setStatus(Status.STATUS_ONE.getCode() + ""); // 可用状态
-		appUser.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认可用
-		appUser.setAuthTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // 认证时间
-		appUser.setName(enterpriseDto.getOwnerName()); // 昵称
-		appUser.setFkId(enterpriseDto.getId()); // 外键
-		appUser.setCreateUnit("航通"); // 创建单位
-		//随机生成6位数密码
-		int password = (int) (Math.random() * (999999 - 100000 + 1) + 100000);
-		//密码加密
-		String encodePassword = passwordEncoder.encode(password + "");
-		//设置密码
-		appUser.setPassword(encodePassword);
-		//保存
-		int insert = appUserMapper.insert(appUser);
-		//发送短信
-		if(insert == 1){
-			//查询外籍商户和商铺是否存在,不存在则删除app user信息 ownTel
+    /**
+     * 远程调用: 当从航通导入数据时,自动给外籍商户生成账号
+     */
+    public int generateEnterpriseAccount(EnterpriseDto enterpriseDto) throws Exception {
+        //判断是否已被注册
+        List<AppUser> appUsers = appUserMapper.selectList(new LambdaQueryWrapper<AppUser>().eq(AppUser::getPhone, enterpriseDto.getOwnerTel()));
+        if (appUsers.size() != 0) {
+            StaticLog.error("用户手机号已被注册:{},{}", enterpriseDto.getOwnerTel(), JSONUtil.toJsonStr(enterpriseDto));
+            return 0;
+        }
+        //创建保存对象
+        AppUser appUser = new AppUser();
+        //设置基本属性
+        appUser.setAuth(1 + ""); // 默认已认证
+        appUser.setUserType(5); // 用户类型 1
+        appUser.setCreateTime(new Date()); // 创建时间
+        appUser.setPhone(enterpriseDto.getOwnerTel()); // 电话
+        appUser.setStatus(Status.STATUS_ONE.getCode() + ""); // 可用状态
+        appUser.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认可用
+        appUser.setAuthTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // 认证时间
+        appUser.setName(enterpriseDto.getOwnerName()); // 昵称
+        appUser.setFkId(enterpriseDto.getId()); // 外键
+        appUser.setCreateUnit("航通"); // 创建单位
+        //随机生成6位数密码
+        //int password = (int) (Math.random() * (999999 - 100000 + 1) + 100000);
+        String password = appUser.getPhone();
+        //密码加密
+        String encodePassword = passwordEncoder.encode(password + "");
+        //设置密码
+        appUser.setPassword(encodePassword);
+        //保存
+        int insert = appUserMapper.insert(appUser);
+        //发送短信
+        if (insert == 1) {
+            //查询外籍商户和商铺是否存在,不存在则删除app user信息 ownTel
 //			List<ShopDto> shopDtoListByPhone = levelOneServerInterface.getShopDtoListByPhone(appUser.getPhone());
 //			List<EnterpriseDto> enterpriseDtoListByPhone = levelOneServerInterface.getEnterpriseDtoListByPhone(appUser.getPhone());
 //			if(shopDtoListByPhone.size() != 1 && enterpriseDtoListByPhone.size() != 1)
 //				throw new ServiceException("当航通同步商铺信息时,商铺或者外籍商户信息入库发生异常,故在自动创建appUser时抛出异常回滚数据。");
-			//todo: 届时放开注释
+            //todo: 届时放开注释
 //			boolean msg = smsRetryService.sendSmsRegisteMsg(null, "您好,您已成功注册[边民互市]app账号。账号:" + peopleDto.getBorderTel() + ", 初始密码:" + password + "。可前往app进行修改");
 //			return msg;
-			System.out.println("\n注册成功! 账户 = " + enterpriseDto.getOwnerTel() + " password = " + password + "\n");
-			return 1;
-		}
-		throw new RuntimeException("同步航通信息时,边民注册app信息失败,边民手机号为: " + enterpriseDto.getOwnerTel() + "。 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
-	}
+            System.out.println("\n注册成功! 账户 = " + enterpriseDto.getOwnerTel() + " password = " + password + "\n");
+            return 1;
+        }
+        StaticLog.error("同步航通信息时,边民注册app信息失败,边民手机号为: " + enterpriseDto.getOwnerTel() + "。 时间: " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
+        return 1;
+    }
 
 
 }