Browse Source

8.30 调整同步航通数据时自动创建对应身份appUser

Mechrevo 1 year ago
parent
commit
61f19d9daa

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

@@ -85,4 +85,15 @@ public interface LevelOneServerInterface {
 
     @RequestMapping("/app/TbOrder/rpc/updateResaleStatus")
     public boolean updateResaleStatus(@RequestParam("id") Long orderId);
+
+
+    /**
+     * 远程调用: 根据电话查询外籍商户
+     */
+    @RequestMapping("/TbEnterprise/rpc/getEnterpriseDtoListByPhone")
+    public List<com.pj.api.dto.EnterpriseDto> getEnterpriseDtoListByPhone(@RequestParam("phone") String phone);
+
+    /** 远程调用: 根据电话查询商铺 */
+    @RequestMapping("/TbShop/rpc/getShopDtoListByPhone")
+    public List<ShopDto> getShopDtoListByPhone(@RequestParam("phone") String phone);
 }

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

@@ -135,6 +135,20 @@ public class LevelOneServerInterfaceFallback implements FallbackFactory<LevelOne
             public boolean updateResaleStatus(Long orderId) {
                 return false;
             }
+
+            @Override
+            public List<EnterpriseDto> getEnterpriseDtoListByPhone(String phone) {
+                System.out.println(throwable.getMessage());
+                log.error("查询一级市场外籍商户错误,当前电话:{},错误信息是:{}",phone,throwable.getMessage());
+                return new ArrayList<>();
+            }
+
+            @Override
+            public List<ShopDto> getShopDtoListByPhone(String phone) {
+                System.out.println(throwable.getMessage());
+                log.error("查询一级市场商铺错误,当前电话:{},错误信息是:{}",phone,throwable.getMessage());
+                return new ArrayList<>();
+            }
         };
     }
 }

+ 32 - 0
sp-core/sp-api/src/main/java/com/pj/api/dto/AppUserDto.java

@@ -25,6 +25,38 @@ public class AppUserDto {
      * 姓名
      */
     private String name;
+    /**
+     * 创建单位
+     */
+    private String createUnit;
+
+    public AppUserDto(Long id, String phone, String name, String createUnit, String userType, String fkId, String status, String auth, String authTime, Long loginCount, String lastLoginTime, Date createTime, String updateById, String updateByName, Date updateTime, Integer deleteStatus, String password) {
+        this.id = id;
+        this.phone = phone;
+        this.name = name;
+        this.createUnit = createUnit;
+        this.userType = userType;
+        this.fkId = fkId;
+        this.status = status;
+        this.auth = auth;
+        this.authTime = authTime;
+        this.loginCount = loginCount;
+        this.lastLoginTime = lastLoginTime;
+        this.createTime = createTime;
+        this.updateById = updateById;
+        this.updateByName = updateByName;
+        this.updateTime = updateTime;
+        this.deleteStatus = deleteStatus;
+        this.password = password;
+    }
+
+    public String getCreateUnit() {
+        return createUnit;
+    }
+
+    public void setCreateUnit(String createUnit) {
+        this.createUnit = createUnit;
+    }
 
     /**
      * 类型(1=边民,2=组长,3=商户,4=收购商,5=司机)

+ 28 - 0
sp-core/sp-base/src/main/java/com/pj/enummj/HtDeleteStatus.java

@@ -0,0 +1,28 @@
+package com.pj.enummj;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 08 30 11 45
+ **/
+@Getter
+@AllArgsConstructor
+public enum HtDeleteStatus {
+
+    /**
+     * 航通基础信息的逻辑删除状态
+     */
+
+    DELETE_STATUS_ONE(1,"启用"),
+    DELETE_STATUS_TWO(2,"禁用"),
+    HT_DELETE_STATUS_THREE(3,"注销");
+
+    private Integer code;
+
+    private String msg;
+
+
+
+}

+ 27 - 0
sp-core/sp-base/src/main/java/com/pj/enummj/Status.java

@@ -0,0 +1,27 @@
+package com.pj.enummj;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @Author Mechrevo
+ * @Date 2023 08 30 10 11
+ **/
+@Getter
+@AllArgsConstructor
+public enum Status {
+
+    /**
+     * 可用状态
+     */
+
+    STATUS_ZERO(0,"禁用"),
+    STATUS_ONE(1,"可用");
+
+    private Integer code;
+
+    private String msg;
+
+
+
+}

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

@@ -24,12 +24,12 @@ public class AmqpTemplateController {
     /**
      * 发送对象至航通
      * @param t
-     * @param <T>
+     * @param
      */
     @RequestMapping("rpc/sendLevelOneOrderDto")
     public void sendLevelOneOrderDto(@RequestBody OrderDto t, @RequestParam("dataType")String dataType){
         //发送
-        amqpTemplateFeign.sendLevelOneOrderDto(t,dataType);
+        amqpTemplateFeign.sendObject(t,dataType);
     }
 
     /**
@@ -40,7 +40,7 @@ public class AmqpTemplateController {
     @RequestMapping("rpc/sendLevelTwoOrdersDto")
     public void sendLevelTwoOrdersDto(@RequestBody OrdersDto t, @RequestParam("dataType") String dataType){
         //发送
-        amqpTemplateFeign.sendLevelTwoOrdersDto(t,dataType);
+        amqpTemplateFeign.sendObject(t,dataType);
     }
 
 }

+ 2 - 35
sp-service/async-server/src/main/java/com/pj/feign/AmqpTemplateFeign.java

@@ -25,13 +25,12 @@ public class AmqpTemplateFeign {
     @Autowired
     private AmqpTemplate amqpTemplate;
 
-
     /**
      * 发送对象至航通
      * @param t
      * @param dataType
      */
-    public void sendLevelOneOrderDto(OrderDto t, String dataType){
+    public<T> void sendObject(T t, String dataType){
         //todo: 数据暂时定死
         DataDto dataDto = new DataDto();
         //msgId
@@ -39,7 +38,7 @@ public class AmqpTemplateFeign {
         Long msgId = new IdWorker().nextId();
         dataDto.setMsgId(msgId + "");
         //appId
-        String appId = "shop01";
+        String appId = "sjf01";
         dataDto.setAppId(appId);
         //dataType
         dataDto.setDataType(dataType);
@@ -60,37 +59,5 @@ public class AmqpTemplateFeign {
         amqpTemplate.convertAndSend(RabbitMQ.TEST_SEND_QUEUE,dataDto);
     }
 
-    /**
-     * 发送对象至航通
-     * @param t
-     * @param dataType
-     */
-    public void sendLevelTwoOrdersDto(OrdersDto t, String dataType){
-        //todo: 数据暂时定死
-        DataDto dataDto = new DataDto();
-        //msgId
-        String msgId = "msgid";
-        dataDto.setMsgId(msgId);
-        //appId
-        String appId = "shop01";
-        dataDto.setAppId(appId);
-        //dataType
-        dataDto.setDataType(dataType);
-        //data
-        //加密
-        String jsonString = JSON.toJSONString(t);
-        String encryptCBC = AESUtil.encryptCBC(jsonString, RabbitMQ.ACC_KEY);
-        dataDto.setData(encryptCBC);
-        //msgTime
-        String msgTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date());
-        dataDto.setMsgTime(msgTime);
-        //sign
-        String signString = "msgId=" + msgId + "&appId=" + appId + "&dataType=" + dataType + "&msgTime=" + msgTime + "&data=" + encryptCBC;
-        String sign = MD5.getMd5(signString, 32);
-        dataDto.setSign(sign);
-
-        //mq发送信息
-        amqpTemplate.convertAndSend(RabbitMQ.TEST_SEND_QUEUE,dataDto);
-    }
 
 }

+ 6 - 1
sp-service/async-server/src/main/java/com/pj/listen/BaseInfoListen.java

@@ -31,6 +31,7 @@ public class BaseInfoListen {
 
     /**
      * 接收: 信息同步
+     * 测试已通过
      * @param json
      */
     @RabbitListener(queuesToDeclare = @Queue(RabbitMQ.TEST_ACCEPT_QUEUE))
@@ -47,10 +48,14 @@ public class BaseInfoListen {
 
     /**
      * 测试接收
+     * 测试已通过
      */
     @RabbitListener(queuesToDeclare = @Queue(RabbitMQ.TEST_SEND_QUEUE))
-    public void sendMessage(DataDto dataDto){
+    public void sendMessage(Message dataDto1){
         System.out.println("\n测试:接收信息\n");
+        byte[] body = dataDto1.getBody();
+        String s = new String(body);
+        DataDto dataDto = JSONObject.parseObject(s, DataDto.class);
         String cbc = AESUtil.decryptCBC(dataDto.getData(), RabbitMQ.ACC_KEY);
         OrderDto orderDto = JSONObject.parseObject(cbc, OrderDto.class);
         System.out.println("\n" + orderDto.toString() + "\n");

+ 123 - 118
sp-service/async-server/src/main/java/com/pj/task/HtByteTask.java

@@ -1,15 +1,24 @@
 package com.pj.task;
 
+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.dto.*;
+import com.pj.dto.DataDto;
 import com.pj.enummj.DataType;
+import com.pj.enummj.FinishStatus;
+import com.pj.ht_byte.HtByte;
 import com.pj.ht_byte.HtByteMapper;
+import com.pj.rabbitmq.RabbitMQ;
+import com.pj.utils.ht.AESUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.annotation.EnableScheduling;
 import org.springframework.scheduling.annotation.Scheduled;
 
+import java.util.List;
+
 
 /**
  * @Author Mechrevo
@@ -50,125 +59,121 @@ public class HtByteTask {
     @Scheduled(cron = "*/9 * * * * ?")  // 测试阶段,每9秒扫描一次
     private void htByteTask(){
         /*  测试mq */
-//        List<HtByte> htBytes = htByteMapper.selectList(new LambdaQueryWrapper<HtByte>().eq(HtByte::getFinishStatus, 2));
-        OrderDto orderDtoById = levelOneServerInterface.getOrderDtoById(8833342005355478419L);
-        asyncServerInterface.sendLevelOneOrderDto(orderDtoById, DataType.DATA_TYPE_ONE.getCode());
+//        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)System.out.println("\n暂无待处理任务。\n");
-//        //执行任务处理流程
-//        byteList.forEach(item -> {
-//            //对象转换
-//            DataDto dataDto = JSONObject.parseObject(item.getBody(), DataDto.class);
-//            //数据解析
-//            String body = AESUtil.decryptCBC(dataDto.getData(), RabbitMQ.ACC_KEY);
-//            //控制台输出
-//            dataDto.setData(body);
-////            System.out.println("开始处理数据: " + dataDto);
-//            //数据处理完成状态
-//            boolean flag = false;
-//            // 根据类型匹配对象
-//            switch (dataDto.getDataType()){
-//                case "001":
-//                    //对象转换
-//                    PeopleDto peopleDto = JSONObject.parseObject(body, PeopleDto.class);
-//                    //根据其内的身份证,有则新增,无则修改???
-//                    flag = levelOneServerInterface.peopleDto(peopleDto);
-//                    if(flag){
-//                        //将完成状态设置成 2 , 表示处理失败
-//                        item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
-//                        item.setMessageId(dataDto.getMsgId());
-//                        //保存
-//                        htByteMapper.updateById(item);
-//                        System.out.println("\n边民信息处理完成。 messageId = " + item.getMessageId() + "\n");
-//                        //todo: 发送失败信息给管理员
-//
-//                        break;
-//                    }
-//                    item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
-//                    item.setMessageId(dataDto.getMsgId());
-//                    htByteMapper.updateById(item);
-//                    System.out.println("\n边民信息处理失败。 messageId = " + item.getMessageId() + "\n");
-//                    break;
-//                case "002":
-//                    //商铺备案
-//                    ShopDto shopDto = JSONObject.parseObject(body, ShopDto.class);
-//                    //保存
-//                    flag = levelOneServerInterface.shopDto(shopDto);
-//                    if(!flag){
-//                        //将完成状态设置成 2 , 表示处理失败
-//                        item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
-//                        item.setMessageId(dataDto.getMsgId());
-//                        //保存
-//                        htByteMapper.updateById(item);
-//                        System.out.println("\n店铺信息处理失败。 messageId = " + item.getMessageId() + "\n");
-//                        //todo: 发送失败信息给管理员
-//
-//                        break;
-//                    }
-//                    item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
-//                    item.setMessageId(dataDto.getMsgId());
-//                    htByteMapper.updateById(item);
-//                    System.out.println("\n店铺信息处理完成。 messageId = " + item.getMessageId() + "\n");
-//                    break;
-//                case "003":
-//                    //边民互助组备案
-//                    GroupDto groupDto = JSONObject.parseObject(body, GroupDto.class);
-//                    //保存
-//                    flag = levelOneServerInterface.groupDto(groupDto);
-//                    if(!flag){
-//                        //将完成状态设置成 2 , 表示处理失败
-//                        item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
-//                        item.setMessageId(dataDto.getMsgId());
-//                        //保存
-//                        htByteMapper.updateById(item);
-//                        System.out.println("\n互助组信息处理失败。 messageId = " + item.getMessageId() + "\n");
-//                        //todo: 发送失败信息给管理员
-//
-//                        break;
-//                    }
-//                    item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
-//                    item.setMessageId(dataDto.getMsgId());
-//                    htByteMapper.updateById(item);
-//                    System.out.println("\n互助组信息处理完成。 messageId = " + item.getMessageId() + "\n");
-//                    break;
-//                case "004":
-//                    //边民合作社备案
-//                    CooperativeDto cooperativeDto = JSONObject.parseObject(body, CooperativeDto.class);
-//                    //保存
-//                    flag = levelOneServerInterface.cooperativeDto(cooperativeDto);
-//                    if(!flag){
-//                        //将完成状态设置成 2 , 表示处理失败
-//                        item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
-//                        item.setMessageId(dataDto.getMsgId());
-//                        //保存
-//                        htByteMapper.updateById(item);
-//                        System.out.println("\n边民合作社信息处理失败。 messageId = " + item.getMessageId() + "\n");
-//                        //todo: 发送失败信息给管理员
-//
-//                        break;
-//                    }
-//                    item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
-//                    item.setMessageId(dataDto.getMsgId());
-//                    htByteMapper.updateById(item);
-//                    System.out.println("\n边民合作社信息处理完成。 messageId = " + item.getMessageId() + "\n");
-//                    break;
-//                case "005":
-//                    //车辆
-//
-//                    break;
-//                case "006":
-//                    //进境申报单
-//
-//                    break;
-//                case "007":
-//                    //进口申报单
-//
-//                    break;
-//            }
-//        });
+        //扫描表内是否有待处理任务
+        List<HtByte> byteList = htByteMapper.selectList(new LambdaQueryWrapper<HtByte>().eq(HtByte::getFinishStatus, FinishStatus.FINISH_STATUS_ZERO.getCode()));
+        //判断是否有任务,没有则返回
+        if(byteList.size() == 0)System.out.println("\n  ---  暂无待处理任务。\n");
+        //执行任务处理流程
+        byteList.forEach(item -> {
+            //对象转换
+            DataDto dataDto = JSONObject.parseObject(item.getBody(), DataDto.class);
+            //数据解析
+            String body = AESUtil.decryptCBC(dataDto.getData(), RabbitMQ.ACC_KEY);
+            //数据处理完成状态
+            boolean flag = false;
+            // 根据类型匹配对象
+            switch (dataDto.getDataType()){
+                case "001":
+                    //对象转换
+                    PeopleDto peopleDto = JSONObject.parseObject(body, PeopleDto.class);
+                    //根据其内的身份证,有则新增,无则修改???
+                    flag = levelOneServerInterface.peopleDto(peopleDto);
+                    if(flag){
+                        //将完成状态设置成 2 , 表示处理失败
+                        item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
+                        item.setMessageId(dataDto.getMsgId());
+                        //保存
+                        htByteMapper.updateById(item);
+                        System.out.println("\n边民信息处理完成。 messageId = " + item.getMessageId() + "\n");
+                        //todo: 发送失败信息给管理员
+
+                        break;
+                    }
+                    item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
+                    item.setMessageId(dataDto.getMsgId());
+                    htByteMapper.updateById(item);
+                    System.out.println("\n边民信息处理失败。 messageId = " + item.getMessageId() + "\n");
+                    break;
+                case "002":
+                    //商铺备案
+                    ShopDto shopDto = JSONObject.parseObject(body, ShopDto.class);
+                    //保存
+                    flag = levelOneServerInterface.shopDto(shopDto);
+                    if(!flag){
+                        //将完成状态设置成 2 , 表示处理失败
+                        item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
+                        item.setMessageId(dataDto.getMsgId());
+                        //保存
+                        htByteMapper.updateById(item);
+                        System.out.println("\n店铺信息处理失败。 messageId = " + item.getMessageId() + "\n");
+                        //todo: 发送失败信息给管理员
+
+                        break;
+                    }
+                    item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
+                    item.setMessageId(dataDto.getMsgId());
+                    htByteMapper.updateById(item);
+                    System.out.println("\n店铺信息处理完成。 messageId = " + item.getMessageId() + "\n");
+                    break;
+                case "003":
+                    //边民互助组备案
+                    GroupDto groupDto = JSONObject.parseObject(body, GroupDto.class);
+                    //保存
+                    flag = levelOneServerInterface.groupDto(groupDto);
+                    if(!flag){
+                        //将完成状态设置成 2 , 表示处理失败
+                        item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
+                        item.setMessageId(dataDto.getMsgId());
+                        //保存
+                        htByteMapper.updateById(item);
+                        System.out.println("\n互助组信息处理失败。 messageId = " + item.getMessageId() + "\n");
+                        //todo: 发送失败信息给管理员
+
+                        break;
+                    }
+                    item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
+                    item.setMessageId(dataDto.getMsgId());
+                    htByteMapper.updateById(item);
+                    System.out.println("\n互助组信息处理完成。 messageId = " + item.getMessageId() + "\n");
+                    break;
+                case "004":
+                    //边民合作社备案
+                    CooperativeDto cooperativeDto = JSONObject.parseObject(body, CooperativeDto.class);
+                    //保存
+                    flag = levelOneServerInterface.cooperativeDto(cooperativeDto);
+                    if(!flag){
+                        //将完成状态设置成 2 , 表示处理失败
+                        item.setFinishStatus(FinishStatus.FINISH_STATUS_TWO.getCode());
+                        item.setMessageId(dataDto.getMsgId());
+                        //保存
+                        htByteMapper.updateById(item);
+                        System.out.println("\n边民合作社信息处理失败。 messageId = " + item.getMessageId() + "\n");
+                        //todo: 发送失败信息给管理员
+
+                        break;
+                    }
+                    item.setFinishStatus(FinishStatus.FINISH_STATUS_ONE.getCode());
+                    item.setMessageId(dataDto.getMsgId());
+                    htByteMapper.updateById(item);
+                    System.out.println("\n边民合作社信息处理完成。 messageId = " + item.getMessageId() + "\n");
+                    break;
+                case "005":
+                    //车辆
+
+                    break;
+                case "006":
+                    //进境申报单
+
+                    break;
+                case "007":
+                    //进口申报单
+
+                    break;
+            }
+        });
 
     }
 

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

@@ -186,4 +186,14 @@ public class TbEnterpriseController {
 		return b;
 	}
 
+
+	/**
+	 * 远程调用: 根据电话查询外籍商户
+	 */
+	@RequestMapping("rpc/getEnterpriseDtoListByPhone")
+	public List<com.pj.api.dto.EnterpriseDto> getEnterpriseDtoListByPhone(@RequestParam("phone") String phone){
+		List<EnterpriseDto> byPhone = tbEnterpriseService.getEnterpriseDtoListByPhone(phone);
+		return byPhone;
+	}
+
 }

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

@@ -7,11 +7,11 @@ import com.pj.api.client.admin.AdminInterface;
 import com.pj.api.consts.FeignFactory;
 import com.pj.api.dto.DistrictDTO;
 import com.pj.api.dto.EnterpriseAuditDto;
+import com.pj.common.core.exception.ServiceException;
 import com.pj.current.dto.APPLoginUserInfo;
 import com.pj.current.satoken.StpAPPUserUtil;
 import com.pj.current.satoken.StpUserUtil;
-import com.pj.enummj.DeleteStatus;
-import com.pj.enummj.People;
+import com.pj.enummj.*;
 import com.pj.tb_enterprise.dto.EnterpriseDto;
 import com.pj.tb_enterprise.vo.OrdersVo;
 import com.pj.tb_order.TbOrder;
@@ -33,6 +33,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
@@ -386,4 +387,26 @@ public class TbEnterpriseService extends ServiceImpl<TbEnterpriseMapper, TbEnter
         return enterpriseDto;
     }
 
+    /**
+     * 远程调用: 根据电话查询外籍商户
+     */
+    public List<com.pj.api.dto.EnterpriseDto> getEnterpriseDtoListByPhone(String phone){
+        List<TbEnterprise> tbEnterprises = tbEnterpriseMapper.selectList(new LambdaQueryWrapper<TbEnterprise>()
+                .eq(TbEnterprise::getOwnerTel, phone)
+//                .eq(TbEnterprise::getIsLock, IsLock.IS_LOCK_ON.getCode())
+//                .eq(TbEnterprise::getDeleteStatus,DeleteStatus.DELETE_STATUS_ON.getCode())
+//                .eq(TbEnterprise::getJudgeStatus, JudgeStatus.JUDGE_STATUS_ONE.getCode())
+//                .eq(TbEnterprise::getEDStatus, HtDeleteStatus.DELETE_STATUS_ONE.getCode())
+                );
+        List<com.pj.api.dto.EnterpriseDto> result = new ArrayList<>();
+        if(tbEnterprises.size() > 0){
+            tbEnterprises.forEach(item -> {
+                com.pj.api.dto.EnterpriseDto enterpriseDto = new com.pj.api.dto.EnterpriseDto();
+                BeanUtils.copyProperties(item,enterpriseDto);
+                result.add(enterpriseDto);
+            });
+        }
+        return result;
+    }
+
 }

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

@@ -527,8 +527,12 @@ public class TbPeopleService extends ServiceImpl<TbPeopleMapper, TbPeople> imple
 		//数据拷贝
 		BeanUtils.copyProperties(peopleDto,tbPeople);
 		//设置基本信息
-		tbPeople.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
-		tbPeople.setCreateTime(new Date());
+		tbPeople.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 逻辑删除,默认可用
+		tbPeople.setCreateTime(new Date()); // 创建时间
+		tbPeople.setCreateName("航通"); // 创建人
+		tbPeople.setStatus(Status.STATUS_ONE.getCode());  // 可用状态
+		tbPeople.setIsLock(IsLock.IS_LOCK_ON.getCode());  // 为被锁定状态
+		tbPeople.setJudgeStatus(JudgeStatus.JUDGE_STATUS_ONE.getCode()); // 默认审核通过
 		List<TbPeople> peopleList = tbPeopleMapper.selectList(new LambdaQueryWrapper<TbPeople>().eq(TbPeople::getPlatSeqNo, peopleDto.getPlatSeqNo()));
 		if(peopleList.size() == 0){
 			//新增
@@ -543,7 +547,7 @@ public class TbPeopleService extends ServiceImpl<TbPeopleMapper, TbPeople> imple
 				return aBoolean;
 			}
 		}
-		//修改
+		//todo: 当航通信息同步时,边民信息比如电话发生修改,对应其appUser的登陆账号发生修改???
 		BeanUtils.copyProperties(peopleList.get(0),tbPeople);
 		int i = tbPeopleMapper.updateById(tbPeople);
 		return i == 1;

+ 8 - 0
sp-service/level-one-server/src/main/java/com/pj/tb_shop/TbShopController.java

@@ -137,4 +137,12 @@ public class TbShopController {
 	}
 
 
+	/** 远程调用: 根据电话查询商铺 */
+	@RequestMapping("rpc/getShopDtoListByPhone")
+	public List<ShopDto> getShopDtoListByPhone(@RequestParam("phone") String phone){
+		List<ShopDto> byPhone = tbShopService.getShopDtoListByPhone(phone);
+		return byPhone;
+	}
+
+
 }

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

@@ -4,6 +4,7 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
 
@@ -12,8 +13,7 @@ import com.pj.api.client.admin.AdminInterface;
 import com.pj.api.dto.EnterpriseDto;
 import com.pj.api.dto.ShopDto;
 import com.pj.common.core.exception.ServiceException;
-import com.pj.enummj.DeleteStatus;
-import com.pj.enummj.JudgeStatus;
+import com.pj.enummj.*;
 import com.pj.project4sp.SP;
 import com.pj.tb_enterprise.TbEnterprise;
 import com.pj.tb_enterprise.TbEnterpriseMapper;
@@ -191,7 +191,6 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
 	}
 
 	/** 远程调用方法 */
-	@Transactional(propagation = Propagation.REQUIRES_NEW)
 	public boolean shopDto(ShopDto shopDto) throws Exception {
 		TbShop tbShop = new TbShop();
 		BeanUtils.copyProperties(shopDto,tbShop);
@@ -202,8 +201,10 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
 			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.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();
 			//新增外籍商户
@@ -214,16 +215,17 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
 				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);
-				enterprise.setShopName(shopDto.getShopName());
-				enterprise.setBankAccount(shopDto.getBankAccount());
-				enterprise.setBank(shopDto.getBank());
-				enterprise.setAddress(shopDto.getAddress());
-				enterprise.setType(null);
+				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){
@@ -234,7 +236,9 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
 					//将数据拷贝至enterpriseDto
 					BeanUtils.copyProperties(tbEnterprises.get(0),enterpriseDto);
 					//远程调用生成商家账户方法
-					int i = adminInterface.generateEnterpriseAccount(enterpriseDto);
+					int i = 1;
+					i = adminInterface.generateEnterpriseAccount(enterpriseDto);
+
 					if(i != 1)
 						throw new RuntimeException("\n添加商铺时,保存店铺内的外籍商户信息错误。 id = " + tbEnterprises.get(0).getId() + "\n");
 					return true;
@@ -242,9 +246,29 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
 			}
 		}
 		//修改
+		// todo: 现在同步生成外籍商户信息和appUser信息,当商铺电话发生修改时,对应的外籍商户电话和appUser账号同步修改???
 		BeanUtils.copyProperties(tbShopList.get(0),tbShop);
 		int i = tbShopMapper.updateById(tbShop);
 		return i == 1;
 	}
 
+	/** 远程调用: 根据电话查询商铺 */
+	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;
+	}
+
 }

+ 4 - 0
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUser.java

@@ -133,4 +133,8 @@ public class AppUser extends Model<AppUser> implements Serializable {
 	 */
 	private Date faceTime;
 
+	/**
+	 * 创建单位
+	 */
+	private String createUnit;
 }

+ 12 - 2
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserService.java

@@ -20,6 +20,7 @@ import com.pj.current.satoken.StpAPPUserUtil;
 import com.pj.current.satoken.StpUserUtil;
 import com.pj.enummj.DeleteStatus;
 import com.pj.enummj.IsLock;
+import com.pj.enummj.Status;
 import com.pj.project.app_user.dto.ForgetPasswordDto;
 import com.pj.project.app_user.dto.LoginDto;
 import com.pj.project.app_user.dto.RegisterDto;
@@ -70,9 +71,9 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
 	private LevelOneServerInterface levelOneServerInterface;
 	@Autowired
 	private TransportInterface transportInterface;
-
 	@Autowired
 	AppUserLoginLogService appUserLoginLogService;
+
 	/** 验证码前缀 */
 	String PREFIX = "app_user:phone:sms_code:";
 
@@ -185,6 +186,8 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
 		String password = registerDto.getPassword();
 		String encode = passwordEncoder.encode(password);
 		appUser.setPassword(encode);
+		//创建单位
+		appUser.setCreateUnit("数据分中心");
 		//昵称
 		appUser.setName(registerDto.getNickName());
 		//创建时间
@@ -462,6 +465,7 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
 		appUser.setAuthTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); // 认证时间
 		appUser.setName(peopleDto.getBorderName()); // 昵称
 		appUser.setFkId(peopleDto.getId()); // 外键
+		appUser.setCreateUnit("航通");
 		//随机生成6位数密码
 		int password = (int) (Math.random() * (999999 - 100000 + 1) + 100000);
 		//密码加密
@@ -493,11 +497,12 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
 		appUser.setUserType(5); // 用户类型 1
 		appUser.setCreateTime(new Date()); // 创建时间
 		appUser.setPhone(enterpriseDto.getOwnerTel()); // 电话
-		appUser.setStatus("1"); // 可用状态
+		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);
 		//密码加密
@@ -508,6 +513,11 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
 		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: 届时放开注释
 //			boolean msg = smsRetryService.sendSmsRegisteMsg(null, "您好,您已成功注册[边民互市]app账号。账号:" + peopleDto.getBorderTel() + ", 初始密码:" + password + "。可前往app进行修改");
 //			return msg;