|
|
@@ -2,11 +2,15 @@ package com.ruoyi.agent.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.junziqian.sdk.bean.req.sign.ext.SignatoryReq;
|
|
|
import com.ruoyi.agent.domain.Agent;
|
|
|
+import com.ruoyi.agent.domain.bo.AgentBalanceRecordBo;
|
|
|
import com.ruoyi.agent.domain.bo.AgentBo;
|
|
|
+import com.ruoyi.agent.domain.bo.AgentChangeBalanceBo;
|
|
|
import com.ruoyi.agent.domain.vo.AgentAmountStatisticsVo;
|
|
|
import com.ruoyi.agent.domain.vo.AgentVo;
|
|
|
import com.ruoyi.agent.enums.AgentLevel;
|
|
|
@@ -20,18 +24,24 @@ import com.ruoyi.agent.service.IAgentService;
|
|
|
import com.ruoyi.business.service.IBusinessService;
|
|
|
import com.ruoyi.common.core.domain.PageQuery;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+import com.ruoyi.common.enums.ExceptionEnum;
|
|
|
import com.ruoyi.common.enums.InviteType;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.BeanCopyUtils;
|
|
|
import com.ruoyi.common.utils.ShareCodeUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
-import com.ruoyi.tool.service.ApplySignService;
|
|
|
+import com.ruoyi.info.base.domain.vo.PlatformInfoVo;
|
|
|
+import com.ruoyi.info.base.service.IPlatformInfoService;
|
|
|
+import com.ruoyi.tool.service.JzqService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.Collection;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -47,9 +57,10 @@ import java.util.stream.Collectors;
|
|
|
public class AgentServiceImpl implements IAgentService {
|
|
|
|
|
|
private final AgentMapper baseMapper;
|
|
|
- private final ApplySignService applySignService;
|
|
|
+ private final JzqService jzqService;
|
|
|
private final IAgentBalanceRecordService agentBalanceRecordService;
|
|
|
private final IAgentAccountCodeService agentAccountCodeService;
|
|
|
+ private final IPlatformInfoService platformInfoService;
|
|
|
@Lazy
|
|
|
@Resource
|
|
|
private IBusinessService businessService;
|
|
|
@@ -157,16 +168,16 @@ public class AgentServiceImpl implements IAgentService {
|
|
|
//生成邀请码
|
|
|
String inviteCode = ShareCodeUtils.idToCode(Long.parseLong(add.getPhone()));
|
|
|
add.setInviteCode(InviteType.AGENT.getCode() + inviteCode);
|
|
|
- //签合同
|
|
|
- Boolean signFlag = applySignService.uploadPersSign(bo.getIdCard(), bo.getSignImage());
|
|
|
- if(!signFlag){
|
|
|
- throw new ServiceException(AgentExceptionEnum.Agent_SIGN_FAIL);
|
|
|
- }
|
|
|
- String contractNo = applySignService.applySign();
|
|
|
- if (StringUtils.isEmpty(contractNo)) {
|
|
|
- throw new ServiceException(AgentExceptionEnum.Agent_SIGN_CONTRACT_FAIL);
|
|
|
- }
|
|
|
- add.setContractNo(contractNo);
|
|
|
+ //签合同 TODO
|
|
|
+// Boolean signFlag = jzqService.uploadPersSign(bo.getIdCard(), bo.getSignImage());
|
|
|
+// if(!signFlag){
|
|
|
+// throw new ServiceException(AgentExceptionEnum.Agent_SIGN_FAIL);
|
|
|
+// }
|
|
|
+// String contractNo = jzqService.applySign(buildSignatories(add));
|
|
|
+// if (StringUtils.isEmpty(contractNo)) {
|
|
|
+// throw new ServiceException(AgentExceptionEnum.Agent_SIGN_CONTRACT_FAIL);
|
|
|
+// }
|
|
|
+// add.setContractNo(contractNo);
|
|
|
boolean flag = baseMapper.insert(add) > 0;
|
|
|
if (flag) {
|
|
|
bo.setAgentId(add.getAgentId());
|
|
|
@@ -174,6 +185,41 @@ public class AgentServiceImpl implements IAgentService {
|
|
|
return flag;
|
|
|
}
|
|
|
|
|
|
+ private JSONArray buildSignatories(Agent agent) {
|
|
|
+ /**
|
|
|
+ * 签约方1(个人)
|
|
|
+ */
|
|
|
+ JSONArray signatories = new JSONArray();
|
|
|
+ SignatoryReq sReq = new SignatoryReq();
|
|
|
+ sReq.setFullName(agent.getRealName()); //姓名
|
|
|
+ sReq.setIdentityType(1); //证件类型
|
|
|
+ sReq.setIdentityCard(agent.getIdCard());//身份证号
|
|
|
+ sReq.setMobile(agent.getPhone()); //手机号
|
|
|
+ sReq.setChapteJson("[{\"page\":0,\"chaptes\":[{\"offsetX\":0.3047,\"offsetY\":0.2677}]},{\"page\":4,\"chaptes\":[{\"offsetX\":0.2378,\"offsetY\":0.1681}]}]");//坐标(X Y)定位签字位置
|
|
|
+ // sReq.setSearchKey("服务组件");//关键字定位签字位置
|
|
|
+ sReq.setNoNeedVerify(1); //取消签约前短信校验
|
|
|
+ sReq.setServerCaAuto(0);//是否使用自动签署完成,0或null不使用,1自动(当且只当合同处理方式为部份自动或收集批量签时有效)
|
|
|
+ sReq.setSignLevel(1);//签字类型,标准图形章或公章:0标准图形章,1公章或手写,2公章手写或手写,3个人方形标准章(用户类型是个人且姓名2-4个字符生效,其他情况默认使用系统标准图形章)
|
|
|
+ signatories.add(sReq);
|
|
|
+
|
|
|
+ PlatformInfoVo platformInfoVo = platformInfoService.getInfo();
|
|
|
+ /**
|
|
|
+ * 签约方2(企业)
|
|
|
+ */
|
|
|
+ SignatoryReq eReq = new SignatoryReq();
|
|
|
+ eReq.setFullName(platformInfoVo.getEnterpriseFullName()); //企业姓名
|
|
|
+ eReq.setIdentityType(12); //证件类型
|
|
|
+ eReq.setIdentityCard(platformInfoVo.getUscCode());//统一社会信用代码
|
|
|
+ eReq.setEmail(platformInfoVo.getEmail()); //在君子签注册认证的邮箱
|
|
|
+ eReq.setChapteJson("[{\"page\":4,\"chaptes\":[{\"offsetX\":0.121,\"offsetY\":0.3941}]}]");//坐标(X Y)定位签字位置
|
|
|
+ // eReq.setSearchKey("服务组件");//关键字定位签字位置
|
|
|
+ eReq.setSignLevel(0);
|
|
|
+ eReq.setNoNeedVerify(1);
|
|
|
+ eReq.setServerCaAuto(1);//当前签约方自动签署
|
|
|
+ signatories.add(eReq);
|
|
|
+ return signatories;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改代理
|
|
|
*
|
|
|
@@ -273,4 +319,42 @@ public class AgentServiceImpl implements IAgentService {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void changeAgentBalance(AgentChangeBalanceBo bo) {
|
|
|
+ Agent agent = loadById(bo.getAgentId(), true);
|
|
|
+ BigDecimal entryValue = bo.getEntryValue();
|
|
|
+ if (entryValue.compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ BigDecimal balance = agent.getBalance();
|
|
|
+ if (bo.getIsAdd()) {
|
|
|
+ //收入
|
|
|
+ agent.setBalance(balance.add(entryValue));
|
|
|
+ agent.setTotalAmount(agent.getTotalAmount().add(entryValue));
|
|
|
+ } else {
|
|
|
+ //支出
|
|
|
+ BigDecimal subtract = balance.subtract(entryValue);
|
|
|
+ if (subtract.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ throw new ServiceException(ExceptionEnum.AGENT_BALANCE_IS_LACK);
|
|
|
+ }
|
|
|
+ agent.setBalance(subtract);
|
|
|
+ }
|
|
|
+ this.baseMapper.updateById(agent);
|
|
|
+ //新增积分记录
|
|
|
+ AgentBalanceRecordBo recordBo = new AgentBalanceRecordBo();
|
|
|
+ recordBo.setAgentId(agent.getAgentId());
|
|
|
+ recordBo.setBillType(bo.getIsAdd() ? BillType.INNER : BillType.OUTER);
|
|
|
+ recordBo.setEntryValue(entryValue);
|
|
|
+ // 保存收入积分记录
|
|
|
+ recordBo.setEntryBeforeBalance(balance);
|
|
|
+ recordBo.setEntryAfterBalance(agent.getBalance());
|
|
|
+ recordBo.setCreateTime(new Date());
|
|
|
+ recordBo.setSourceType(bo.getSourceType());
|
|
|
+ recordBo.setSourceId(bo.getSourceId());
|
|
|
+ recordBo.setSourceCode(bo.getSourceCode());
|
|
|
+ recordBo.setRemark(bo.getRemark());
|
|
|
+ agentBalanceRecordService.insertByBo(recordBo);
|
|
|
+ }
|
|
|
+
|
|
|
}
|