Browse Source

8.17 完善二级市场收购商认证相关

Mechrevo 1 year ago
parent
commit
047147c6de

+ 0 - 2
sp-core/sp-api/src/main/java/com/pj/api/FeignInterceptor.java

@@ -8,9 +8,7 @@ import feign.RequestTemplate;
 
 /**
  * feign拦截器, 在feign请求发出之前,加入一些操作
- * 
  * @author kong
- *
  */
 @Component
 public class FeignInterceptor implements RequestInterceptor {

+ 8 - 0
sp-core/sp-api/src/main/java/com/pj/api/client/level_two_server/LevelTwoServerInterface.java

@@ -18,6 +18,14 @@ import org.springframework.web.bind.annotation.RequestParam;
         fallbackFactory = LevelTwoServerInterfaceFallback.class	// 服务降级
 )
 public interface LevelTwoServerInterface {
+    /**
+     * 根据手机号和身份证查询收购商
+     * @param phone 手机号
+     * @param idCard 身份证
+     * @return
+     */
+    @RequestMapping("rpc/getByPhoneAndIdCard")
+    public PurchaserDto getByPhoneAndIdCard(@RequestParam("phone") String phone,@RequestParam("idCard")String idCard);
 
     @RequestMapping("/app/TbPurchaser/rpc/getByPurchaserId")
     public PurchaserDto getByPurchaserId(@RequestParam("id") Long id);

+ 6 - 0
sp-core/sp-api/src/main/java/com/pj/api/client/level_two_server/LevelTwoServerInterfaceFallback.java

@@ -20,6 +20,12 @@ public class LevelTwoServerInterfaceFallback implements FallbackFactory<LevelTwo
     public LevelTwoServerInterface create(Throwable throwable) {
         return new LevelTwoServerInterface() {
             @Override
+            public PurchaserDto getByPhoneAndIdCard(String phone, String idCard) {
+                log.error("错误的手机号:{},身份证:{},降级类型:{}", phone, idCard, "熔断");
+                return null;
+            }
+
+            @Override
             public PurchaserDto getByPurchaserId(Long id) {
                 System.out.println(throwable.getMessage());
                 log.error("国内商家信息查询错误:{},错误信息是{}",id,throwable.getMessage());

+ 11 - 1
sp-core/sp-api/src/main/java/com/pj/api/dto/PurchaserDto.java

@@ -16,9 +16,19 @@ public class PurchaserDto {
      * 名称
      */
     private String name;
+    private Long id;
 
-    public PurchaserDto(String name, Integer age, String legalPerson, String idCard, String contact, String businessLicense, String bankNo, String bankName, String bankAccount, String dutyParagraph, String addressIds, String address, Integer judgeStatus, String judgeContent, Date judgeTime, Date registerTime, String personId, Date createTime, String createBy, String createName, Date updateTime, String updateBy, String updateName, Integer deleteStatus, Integer isLock) {
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public PurchaserDto(String name, Long id, Integer age, String legalPerson, String idCard, String contact, String businessLicense, String bankNo, String bankName, String bankAccount, String dutyParagraph, String addressIds, String address, Integer judgeStatus, String judgeContent, Date judgeTime, Date registerTime, String personId, Date createTime, String createBy, String createName, Date updateTime, String updateBy, String updateName, Integer deleteStatus, Integer isLock) {
         this.name = name;
+        this.id = id;
         this.age = age;
         this.legalPerson = legalPerson;
         this.idCard = idCard;

+ 1 - 0
sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaserAppController.java

@@ -59,4 +59,5 @@ public class TbPurchaserAppController {
 		return byPurchaserId;
 	}
 
+
 }

+ 16 - 2
sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaserController.java

@@ -5,8 +5,10 @@ import java.util.List;
 
 import com.pj.api.dto.PurchaserDto;
 import com.pj.common.core.utils.poi.ExcelUtil;
+import com.pj.tb_purchaser.param.PurchaserParam;
 import com.pj.utils.so.SoMap;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
 import com.pj.utils.sg.*;
@@ -134,9 +136,9 @@ public class TbPurchaserController {
 	/** 收购商审核 */
 	@RequestMapping("audit")
 	@SaCheckPermission(TbPurchaser.PERMISSION_CODE_EDIT)
-	public AjaxJson audit(@RequestBody TbPurchaserDto purchaserDto){
+	public AjaxJson audit(@RequestBody @Validated PurchaserParam purchaserParam,Boolean flag,String reason){
 
-		int line = tbPurchaserService.audit(purchaserDto);
+		int line = tbPurchaserService.audit(purchaserParam,flag,reason);
 		return AjaxJson.getByLine(line);
 	}
 
@@ -157,4 +159,16 @@ public class TbPurchaserController {
 		return b;
 	}
 
+	/**
+	 * 根据手机号和身份证查询收购商
+	 * @param phone 手机号
+	 * @param idCard 身份证
+	 * @return
+	 */
+	@RequestMapping("rpc/getByPhoneAndIdCard")
+	public PurchaserDto getByPhoneAndIdCard(@RequestParam("phone") String phone,@RequestParam("idCard")String idCard){
+		PurchaserDto byPurchaserId = tbPurchaserService.getByPhoneAndIdCard(phone,idCard);
+		return byPurchaserId;
+	}
+
 }

+ 58 - 17
sp-service/level-two-server/src/main/java/com/pj/tb_purchaser/TbPurchaserService.java

@@ -15,7 +15,11 @@ import java.util.Objects;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.pj.api.client.admin.AdminInterface;
+import com.pj.api.client.level_two_server.LevelTwoServerInterface;
+import com.pj.api.dto.AppUserDto;
+import com.pj.api.dto.MessageDto;
 import com.pj.api.dto.PurchaserDto;
+import com.pj.common.core.exception.ServiceException;
 import com.pj.current.satoken.StpUserUtil;
 import com.pj.enummj.DeleteStatus;
 import com.pj.enummj.IsLock;
@@ -55,6 +59,10 @@ public class TbPurchaserService extends ServiceImpl<TbPurchaserMapper, TbPurchas
 	@Autowired
 	private MethodPurchaserService methodPurchaserService;
 
+	@Autowired
+	private LevelTwoServerInterface levelTwoServerInterface;
+
+
 	/** 增 */
 	void add(TbPurchaser t){
 		save(t);
@@ -101,24 +109,47 @@ public class TbPurchaserService extends ServiceImpl<TbPurchaserMapper, TbPurchas
 		return insert == 1;
 	}
 
-	/** 收购商审核 */
-	public int audit(TbPurchaserDto purchaserDto){
-
-		// 获取当前登录用户id
-		Long loginId = StpUserUtil.getLoginIdAsLong();
-
-		// 根据id获取收购商
-		TbPurchaser purchaser = tbPurchaserMapper.selectById(purchaserDto.getId());
-		// 如果收购商不存在则抛出异常
-		if(Objects.isNull(purchaser)){
-			throw new RuntimeException("该收购商不存在");
+	/**
+	 *  收购商审核
+	 * @param purchaserParam
+	 * @param flag true=审核通过  false=审核失败
+	 * @param reason 审核备注
+	 * @return
+	 */
+	public int audit(PurchaserParam purchaserParam,Boolean flag,String reason){
+		//审核不通过
+		if(!flag){
+			//发送通知给收购商
+			MessageDto dto = new MessageDto();
+			dto.setUrl("/pages/market/one/merchant/order/list");
+			dto.setUserId(purchaserParam.getLoginUserId());
+			dto.setContents("您发起的收购商认证审核不通过,原因是: " + reason);
+			adminInterface.messageSave(dto);
 		}
-		BeanUtils.copyProperties(purchaserDto,purchaser);
-		// 写入更新者id
-		purchaser.setUpdateBy(String.valueOf(loginId));
-		// 更新收购商审核状态
-		int line = tbPurchaserMapper.updateById(purchaser);
-		return line;
+		//审核通过,开始创建
+		TbPurchaser purchaser = new TbPurchaser();
+		//数据拷贝
+		BeanUtils.copyProperties(purchaserParam,purchaser);
+		purchaser.setName(purchaserParam.getName());
+		purchaser.setDutyParagraph(purchaserParam.getDutyParagraph());
+		purchaser.setLegalPerson(purchaserParam.getCorporateName());
+		purchaser.setIdCard(purchaserParam.getCorporateIdCard());
+		purchaser.setContact(purchaserParam.getLinkPhone());
+		//公共属性设置
+		purchaser.setCreateBy(StpUserUtil.getLoginIdAsString());
+		purchaser.setCreateName(StpUserUtil.getLoginName());
+		purchaser.setCreateTime(new Date());
+		purchaser.setDeleteStatus(DeleteStatus.DELETE_STATUS_ON.getCode());
+		int insert = tbPurchaserMapper.insert(purchaser);
+		if(insert != 1)throw new ServiceException("审核失败!");
+		//审核同构且完成数据插入则进行关联
+		AppUserDto appUser = adminInterface.getAppUserById(purchaserParam.getLoginUserId());
+		if(appUser == null)throw new ServiceException("审核过程异常!");
+		PurchaserDto purchaserDto = levelTwoServerInterface.getByPhoneAndIdCard(purchaser.getContact(), purchaser.getIdCard());
+		//设置关联属性
+		appUser.setFkId(String.valueOf(purchaserDto.getId()));
+		appUser.setAuth(1 + "");  // 1=审核通过
+		return 3;
 	}
 
 	/** 是否锁住收购商 */
@@ -279,4 +310,14 @@ public class TbPurchaserService extends ServiceImpl<TbPurchaserMapper, TbPurchas
 		BeanUtils.copyProperties(byId,purchaserDto);
 		return purchaserDto;
 	}
+
+	/** 远程调用: 根据手机号和身份证号查询二级市场商户 */
+	public PurchaserDto getByPhoneAndIdCard(String phone,String idCard){
+		List<TbPurchaser> purchasers = tbPurchaserMapper.selectList(new LambdaQueryWrapper<TbPurchaser>().eq(TbPurchaser::getContact, phone).eq(TbPurchaser::getIdCard, idCard).eq(TbPurchaser::getDeleteStatus, DeleteStatus.DELETE_STATUS_ON.getCode()));
+		if(purchasers.size() == 0)throw new ServiceException("服务器繁忙~");
+		//数据拷贝
+		PurchaserDto purchaserDto = new PurchaserDto();
+		BeanUtils.copyProperties(purchasers.get(0),purchaserDto);
+		return purchaserDto;
+	}
 }

+ 0 - 1
sp-service/sp-admin/src/main/java/com/pj/project/app_user/AppUserService.java

@@ -413,5 +413,4 @@ public class AppUserService extends ServiceImpl<AppUserMapper, AppUser> implemen
 	}
 
 
-
 }