qzyReal 1 rok temu
rodzic
commit
2ecb991b39

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

@@ -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
 

+ 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.enummj.DeleteStatus;
 import com.pj.enummj.Status;
@@ -217,4 +218,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);
+	}
 }

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

@@ -382,6 +382,9 @@ public class TbGroupService extends ServiceImpl<TbGroupMapper, TbGroup> implemen
             if (tbPeople==null){
                 tbPeople=new TbPeople();
             }
+            tbPeople.setGroupName(tbGroup.getOrgName()).setGroupId(tbGroup.getId()).setTradeAreaId(tbTradeArea.getId())
+                    .setTradeAreaName(tbTradeArea.getName()).setUpdateTime(new Date());
+            tbPeopleService.saveOrUpdate(tbPeople);
             //todo 继续同步边民信息
         });
         //修改

+ 65 - 64
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,7 @@ 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;
@@ -56,6 +58,8 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
 
     @Autowired
     private TbEnterpriseMapper tbEnterpriseMapper;
+    @Resource
+    private TbEnterpriseService tbEnterpriseService;
 
     @Autowired
     private AdminInterface adminInterface;
@@ -215,71 +219,68 @@ public class TbShopService extends ServiceImpl<TbShopMapper, TbShop> implements
      */
     public boolean shopDto(ShopDto shopDto) throws Exception {
         String tradeCode = shopDto.getFieldCode();
-       TbTradeArea tbTradeArea= tbTradeAreaService.updateHandler(tradeCode,shopDto.getFieldName());
-        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())
-                    .setTradeAreaId(tbTradeArea.getId())
-                    .setTradeAreaName(tbTradeArea.getName()); // 创建时间
-            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()); // 默认未被锁定
-                enterprise.setTradeAreaId(tbTradeArea.getId()).setTradeAreaName(tbTradeArea.getName());
-                //保存
-                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);
-
-                    if (i != 1)
-                        throw new RuntimeException("\n添加商铺时,保存店铺内的外籍商户信息错误。 id = " + tbEnterprises.get(0).getId() + "\n");
-                    return true;
-                }
-            }
+        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();
         }
-        //修改
-        // todo: 现在同步生成外籍商户信息和appUser信息,当商铺电话发生修改时,对应的外籍商户电话和appUser账号同步修改???
-        BeanUtils.copyProperties(tbShopList.get(0), tbShop);
-        BeanUtils.copyProperties(shopDto, tbShop);
-        int i = tbShopMapper.updateById(tbShop);
-        return i == 1;
+        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;
+    }
+
+    /**
+     * 根据编号查询
+     *
+     * @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);
     }
 
     /**

+ 470 - 419
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;
@@ -46,159 +48,186 @@ import org.springframework.transaction.annotation.Transactional;
 
 /**
  * Service: app_user -- 移动端账号
+ *
  * @author qzy
  */
 @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);
-	}
-
-	/** 删 */
-	void delete(Long id){
-		removeById(id);
-	}
-
-	/** 改 */
-	void update(AppUser a){
-		a.setUpdateTime(new Date());
-		updateById(a);
-
-	}
-
-	/** 查 */
-	AppUser getById(Long id){
-		return super.getById(id);
-	}
-
-	/**
-	 * 个人中心-个人详细信息
-	 * @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;
-	}
+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);
+    }
+
+    /**
+     * 删
+     */
+    void delete(Long id) {
+        removeById(id);
+    }
+
+    /**
+     * 改
+     */
+    void update(AppUser a) {
+        a.setUpdateTime(new Date());
+        updateById(a);
+
+    }
+
+    /**
+     * 查
+     */
+    AppUser getById(Long id) {
+        return super.getById(id);
+    }
+
+    /**
+     * 个人中心-个人详细信息
+     *
+     * @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 +259,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,284 +277,306 @@ 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("身份信息有误");
-		}
-
-		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 {
-
-				return AjaxJson.getError("两次密码校验不匹配,请重新尝试!");
-
-			}
-
-		}
-
-		//验证码匹配错误
-		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;
-
-	}
-
-
-	/** 更换角色 */
-	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);
-
-		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 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;
-	}
-
-	/** 远程调用: 保存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(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");
-		//创建保存对象
-		AppUser appUser = new AppUser();
-		//设置基本属性
-		appUser.setAuth(1 + ""); // 默认已认证
-		appUser.setUserType(1); // 用户类型 1
-		appUser.setCreateTime(new Date()); // 创建时间
-		appUser.setPhone(peopleDto.getBorderTel()); // 电话
-		appUser.setStatus("1"); // 可用状态
-		appUser.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认可用
-		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);
-		//密码加密
-		String encodePassword = passwordEncoder.encode(password + "");
-		//设置密码
-		appUser.setPassword(encodePassword);
-		//保存
-		int insert = appUserMapper.insert(appUser);
-		//发送短信
-		if(insert == 1){
-			//todo: 届时放开注释
+        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);
+    }
+
+
+    /**
+     * 忘记密码
+     */
+    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("两次密码校验不匹配,请重新尝试!");
+
+            }
+
+        }
+
+        //验证码匹配错误
+        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;
+
+    }
+
+
+    /**
+     * 更换角色
+     */
+    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);
+
+        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 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;
+    }
+
+    /**
+     * 远程调用: 保存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(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");
+        //创建保存对象
+        AppUser appUser = new AppUser();
+        //设置基本属性
+        appUser.setAuth(1 + ""); // 默认已认证
+        appUser.setUserType(1); // 用户类型 1
+        appUser.setCreateTime(new Date()); // 创建时间
+        appUser.setPhone(peopleDto.getBorderTel()); // 电话
+        appUser.setStatus("1"); // 可用状态
+        appUser.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode()); // 默认可用
+        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);
+        //密码加密
+        String encodePassword = passwordEncoder.encode(password + "");
+        //设置密码
+        appUser.setPassword(encodePassword);
+        //保存
+        int insert = appUserMapper.insert(appUser);
+        //发送短信
+        if (insert == 1) {
+            //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()));
-	}
-
-	/** 远程调用: 当从航通导入数据时,自动给外籍商户生成账号 */
-	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
+            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) {
+            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;
+    }
 
 
 }