|
@@ -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;
|
|
|
+ }
|
|
|
}
|