代理商入驻
This commit is contained in:
parent
822b9a1aec
commit
bf74135fef
@ -11,45 +11,43 @@ package com.suisung.mall.shop.esign.controller.mobile;
|
|||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import com.suisung.mall.common.api.CommonResult;
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||||
import com.suisung.mall.shop.esign.service.EsignContractFillingFileService;
|
|
||||||
import com.suisung.mall.shop.esign.service.EsignContractService;
|
|
||||||
import com.suisung.mall.shop.esign.service.EsignPlatformInfoService;
|
import com.suisung.mall.shop.esign.service.EsignPlatformInfoService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.context.annotation.Lazy;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
|
||||||
|
|
||||||
@Api(tags = "E签宝电子签前台控制器")
|
@Api(tags = "E签宝电子签前台控制器")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/mobile/shop/esign")
|
@RequestMapping("/mobile/shop/esign")
|
||||||
public class EsignController extends BaseControllerImpl {
|
public class EsignController extends BaseControllerImpl {
|
||||||
|
|
||||||
@Resource
|
@Lazy
|
||||||
private EsignContractFillingFileService esignContractFillingFileService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private EsignContractService esignContractService;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private EsignPlatformInfoService esignPlatformInfoService;
|
private EsignPlatformInfoService esignPlatformInfoService;
|
||||||
|
|
||||||
@ApiOperation(value = "区域(二级)代理商申请", notes = "区域(二级)代理商申请")
|
|
||||||
@RequestMapping(value = "/apply/agent", method = RequestMethod.POST)
|
@ApiOperation(value = "区域(二级)代理商详细信息", notes = "区域(三级)代理商详细信息")
|
||||||
public CommonResult signFlowCreateByFile(@RequestBody JSONObject paramsJSON) {
|
@RequestMapping(value = "/second/agent/info", method = RequestMethod.POST)
|
||||||
return esignContractService.signFlowCreateByFile(paramsJSON.getInt("store_id"));
|
public CommonResult secondAgentInfo() {
|
||||||
|
return esignPlatformInfoService.get2ndAgentDetailByUserId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "区域(三级)代理商详细信息", notes = "区域(三级)代理商详细信息")
|
@ApiOperation(value = "区域(二级)代理商申请", notes = "区域(二级)代理商申请")
|
||||||
@RequestMapping(value = "/agent/info", method = RequestMethod.POST)
|
@RequestMapping(value = "/apply/2nd/agent", method = RequestMethod.POST)
|
||||||
public ResponseEntity<String> signAsyncNotify(HttpServletRequest request, HttpServletResponse response, @RequestBody String requestBody) {
|
public CommonResult apply2ndAgent(@RequestBody JSONObject paramsJSON) {
|
||||||
return esignContractService.signAsyncNotify(request, response, requestBody);
|
return esignPlatformInfoService.apply2ndAgent(paramsJSON);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "区域(二级)代理商审核", notes = "区域(二级)代理商审核")
|
||||||
|
@RequestMapping(value = "/approval/2nd/agent", method = RequestMethod.POST)
|
||||||
|
public CommonResult approval2ndAgent(@RequestBody JSONObject paramsJSON) {
|
||||||
|
return esignPlatformInfoService.approval2ndAgent(paramsJSON);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,6 +103,14 @@ public interface EsignPlatformInfoService {
|
|||||||
*/
|
*/
|
||||||
String getSupplierIdByAgentId(Long agentId);
|
String getSupplierIdByAgentId(Long agentId);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取二级代理商详情
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CommonResult get2ndAgentDetailByUserId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 申请二级代理商
|
* 申请二级代理商
|
||||||
*
|
*
|
||||||
@ -110,4 +118,12 @@ public interface EsignPlatformInfoService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
CommonResult apply2ndAgent(JSONObject paramsJSON);
|
CommonResult apply2ndAgent(JSONObject paramsJSON);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 审批二级代理商
|
||||||
|
*
|
||||||
|
* @param paramsJSON
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CommonResult approval2ndAgent(JSONObject paramsJSON);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,13 +8,17 @@
|
|||||||
|
|
||||||
package com.suisung.mall.shop.esign.service.impl;
|
package com.suisung.mall.shop.esign.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.hutool.json.JSONObject;
|
import cn.hutool.json.JSONObject;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.suisung.mall.common.api.CommonResult;
|
import com.suisung.mall.common.api.CommonResult;
|
||||||
import com.suisung.mall.common.constant.CommonConstant;
|
import com.suisung.mall.common.constant.CommonConstant;
|
||||||
|
import com.suisung.mall.common.domain.UserDto;
|
||||||
import com.suisung.mall.common.exception.ApiException;
|
import com.suisung.mall.common.exception.ApiException;
|
||||||
import com.suisung.mall.common.modules.esign.EsignPlatformInfo;
|
import com.suisung.mall.common.modules.esign.EsignPlatformInfo;
|
||||||
import com.suisung.mall.common.modules.store.ShopMchEntry;
|
import com.suisung.mall.common.modules.store.ShopMchEntry;
|
||||||
@ -37,6 +41,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformInfoMapper, EsignPlatformInfo> implements EsignPlatformInfoService {
|
public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformInfoMapper, EsignPlatformInfo> implements EsignPlatformInfoService {
|
||||||
@ -49,7 +55,6 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
|||||||
@Resource
|
@Resource
|
||||||
private LklLedgerReceiverService lklLedgerReceiverService;
|
private LklLedgerReceiverService lklLedgerReceiverService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 添加或更新平台方信息
|
* 添加或更新平台方信息
|
||||||
*
|
*
|
||||||
@ -95,17 +100,28 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
|||||||
// 根据等级和营业执照号查询现有记录
|
// 根据等级和营业执照号查询现有记录
|
||||||
EsignPlatformInfo existingRecord = getEsignPlatformInfo(esignPlatformInfo.getLevel(), esignPlatformInfo.getLicense_number());
|
EsignPlatformInfo existingRecord = getEsignPlatformInfo(esignPlatformInfo.getLevel(), esignPlatformInfo.getLicense_number());
|
||||||
|
|
||||||
|
String inviteCode = String.format("%06d", esignPlatformInfo.getId());
|
||||||
if (existingRecord == null) {
|
if (existingRecord == null) {
|
||||||
// 记录不存在,执行新增操作
|
// 记录不存在,执行新增操作
|
||||||
log.debug("[添加平台方信息] 新增平台方信息,等级: {}, 营业执照号: {}",
|
log.debug("[添加平台方信息] 新增平台方信息,等级: {}, 营业执照号: {}",
|
||||||
esignPlatformInfo.getLevel(), esignPlatformInfo.getLicense_number());
|
esignPlatformInfo.getLevel(), esignPlatformInfo.getLicense_number());
|
||||||
return save(esignPlatformInfo);
|
boolean saved = save(esignPlatformInfo);
|
||||||
|
if (saved) {
|
||||||
|
// 保存成功后设置邀请码
|
||||||
|
esignPlatformInfo.setInvite_code(inviteCode);
|
||||||
|
return updateById(esignPlatformInfo);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
} else {
|
} else {
|
||||||
// 记录存在,更新现有记录ID并执行更新操作
|
// 记录存在,更新现有记录ID并执行更新操作
|
||||||
esignPlatformInfo.setId(existingRecord.getId());
|
esignPlatformInfo.setId(existingRecord.getId());
|
||||||
log.debug("[更新平台方信息] 更新平台方信息,ID: {}, 等级: {}, 营业执照号: {}",
|
log.debug("[更新平台方信息] 更新平台方信息,ID: {}, 等级: {}, 营业执照号: {}",
|
||||||
existingRecord.getId(), esignPlatformInfo.getLevel(), esignPlatformInfo.getLicense_number());
|
existingRecord.getId(), esignPlatformInfo.getLevel(), esignPlatformInfo.getLicense_number());
|
||||||
return updateById(esignPlatformInfo);
|
if (StrUtil.isBlank(esignPlatformInfo.getInvite_code())) {
|
||||||
|
esignPlatformInfo.setInvite_code(inviteCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return update(esignPlatformInfo, new LambdaUpdateWrapper<EsignPlatformInfo>().eq(EsignPlatformInfo::getId, existingRecord.getId()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -444,19 +460,29 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public CommonResult apply2ndAgent(JSONObject paramsJSON) {
|
public CommonResult apply2ndAgent(JSONObject paramsJSON) {
|
||||||
log.debug("[申请二级代理商] 开始处理申请,params={}", paramsJSON);
|
log.debug("[申请二级代理商] 开始处理申请,params={}", paramsJSON);
|
||||||
|
|
||||||
|
// TODO 鉴权登录情况
|
||||||
|
|
||||||
|
// 参数校验
|
||||||
if (paramsJSON == null) {
|
if (paramsJSON == null) {
|
||||||
return CommonResult.failed("缺少必要参数错误");
|
return CommonResult.failed("缺少必要参数错误");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UserDto userDto = getCurrentUser();
|
||||||
|
if (userDto == null) {
|
||||||
|
return CommonResult.failed("请先登录");
|
||||||
|
}
|
||||||
|
|
||||||
|
String userId = Convert.toStr(userDto.getId());
|
||||||
|
|
||||||
EsignPlatformInfo record = JSONUtil.toBean(paramsJSON, EsignPlatformInfo.class);
|
EsignPlatformInfo record = JSONUtil.toBean(paramsJSON, EsignPlatformInfo.class);
|
||||||
if (record == null) {
|
if (record == null) {
|
||||||
return CommonResult.failed("参数格式有误");
|
return CommonResult.failed("参数格式有误");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 校验 EsignPlatformInfo 必要关键参数
|
// 校验必要参数
|
||||||
if (StrUtil.hasBlank(
|
if (StrUtil.hasBlank(
|
||||||
record.getLicense_company(),
|
record.getLicense_company(),
|
||||||
record.getLicense_number(),
|
record.getLicense_number(),
|
||||||
@ -476,36 +502,46 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
|||||||
return CommonResult.failed("缺少必要参数");
|
return CommonResult.failed("缺少必要参数");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查是否已存在相同信息的代理商
|
||||||
|
if (CheckUtil.isNotEmpty(record.getId())) {
|
||||||
|
EsignPlatformInfo existRecord = getEsignPlatformInfo(record.getLevel(), record.getLicense_number(), record.getLegal_person_id_card());
|
||||||
|
if (existRecord != null && CheckUtil.isNotEmpty(existRecord.getStatus()) && CommonConstant.Enable.equals(existRecord.getStatus())) {
|
||||||
|
return CommonResult.failed(record.getLicense_company() + " 代理商已经审核通过,无需再申请");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 清算行号和银行账号一致
|
// 设置默认值
|
||||||
record.setRec_acc_clear_bank_no(record.getRec_acc_bank_no());
|
record.setRec_acc_clear_bank_no(record.getRec_acc_bank_no());
|
||||||
record.setRec_acc_type(2); // 款账户账户类型:1-个人(对私);2-企业(对公);
|
record.setRec_acc_type(2); // 款账户账户类型:1-个人(对私);2-企业(对公);
|
||||||
|
record.setStatus(3); // 状态:1-已审核通过;2-审核未通过;3-待审中;
|
||||||
|
|
||||||
// 邀请码,要自动生成
|
if (StrUtil.isBlank(record.getCreated_by())) {
|
||||||
record.setInvite_code("6543");
|
record.setCreated_by(userId);
|
||||||
|
}
|
||||||
|
if (StrUtil.isBlank(record.getUpdated_by())) {
|
||||||
|
record.setUpdated_by(userId);
|
||||||
|
}
|
||||||
|
|
||||||
// 接口只接收二级(区)代理商
|
// 设置代理商等级和邮箱
|
||||||
record.setLevel(CommonConstant.Agent_Level_2nd);
|
record.setLevel(CommonConstant.Agent_Level_2nd);
|
||||||
if (StrUtil.isBlank(record.getEmail())) {
|
if (StrUtil.isBlank(record.getEmail())) {
|
||||||
record.setEmail(record.getTelephone() + "@qq.com");
|
record.setEmail(record.getTelephone() + "@qq.com");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 默认一级代理商ID为0
|
// 设置默认上级代理商ID
|
||||||
if (CheckUtil.isEmpty(record.getParent_id())) {
|
if (CheckUtil.isEmpty(record.getParent_id())) {
|
||||||
record.setParent_id(0L);
|
record.setParent_id(0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 内部配送费
|
// 设置默认配送费和分账比例
|
||||||
if (CheckUtil.isEmpty(record.getShipping_fee())) {
|
if (CheckUtil.isEmpty(record.getShipping_fee())) {
|
||||||
record.setShipping_fee(400);
|
record.setShipping_fee(400);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 默认分账比例1%
|
|
||||||
if (CheckUtil.isEmpty(record.getSplit_ratio())) {
|
if (CheckUtil.isEmpty(record.getSplit_ratio())) {
|
||||||
record.setSplit_ratio(BigDecimal.valueOf(0.01));
|
record.setSplit_ratio(BigDecimal.valueOf(0.01));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果 esign_platform_info 记录不存在,新增esign_platform_info 记录
|
// 保存代理商信息
|
||||||
Boolean result = addOrUpdateEsignPlatformInfo(record);
|
Boolean result = addOrUpdateEsignPlatformInfo(record);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new ApiException("保存代理商信息失败");
|
throw new ApiException("保存代理商信息失败");
|
||||||
@ -515,23 +551,58 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
|||||||
return CommonResult.success();
|
return CommonResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前登录用户的二级代理商信息
|
||||||
|
*
|
||||||
|
* @param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CommonResult get2ndAgentDetailByUserId() {
|
||||||
|
log.debug("[获取二级代理商] 开始处理");
|
||||||
|
|
||||||
|
// 鉴权登录情况
|
||||||
|
UserDto userDto = getCurrentUser();
|
||||||
|
if (userDto == null || CheckUtil.isEmpty(userDto.getId())) {
|
||||||
|
return CommonResult.failed("请先登录");
|
||||||
|
}
|
||||||
|
|
||||||
|
LambdaQueryWrapper<EsignPlatformInfo> queryWrapper = new LambdaQueryWrapper<EsignPlatformInfo>()
|
||||||
|
.eq(EsignPlatformInfo::getCreated_by, userDto.getId())
|
||||||
|
.orderByAsc(EsignPlatformInfo::getId);
|
||||||
|
List<EsignPlatformInfo> records = find(queryWrapper);
|
||||||
|
if (CollUtil.isEmpty(records)) {
|
||||||
|
return CommonResult.failed("您尚未申请代理商入驻");
|
||||||
|
}
|
||||||
|
|
||||||
|
return CommonResult.success(records);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 审批二级代理商
|
* 审批二级代理商
|
||||||
*
|
*
|
||||||
* @param paramsJSON 申请参数JSON
|
* @param paramsJSON 审核的主要信息 JSON
|
||||||
* @return CommonResult 操作结果
|
* @return CommonResult 操作结果
|
||||||
*/
|
*/
|
||||||
|
@Override
|
||||||
public CommonResult approval2ndAgent(JSONObject paramsJSON) {
|
public CommonResult approval2ndAgent(JSONObject paramsJSON) {
|
||||||
log.debug("[申请二级代理商] 开始处理申请,params={}", paramsJSON);
|
log.debug("[审批二级代理商] 开始处理申请,params={}", paramsJSON);
|
||||||
if (paramsJSON == null) {
|
if (paramsJSON == null || paramsJSON.isEmpty()) {
|
||||||
return CommonResult.failed("缺少必要参数错误");
|
return CommonResult.failed("缺少必要参数");
|
||||||
|
}
|
||||||
|
|
||||||
|
Long autoId = paramsJSON.getLong("id", 0L);
|
||||||
|
if (CheckUtil.isEmpty(autoId)) {
|
||||||
|
return CommonResult.failed("缺少必要参数");
|
||||||
|
}
|
||||||
|
|
||||||
|
EsignPlatformInfo existsRecord = get(autoId);
|
||||||
|
if (ObjectUtil.isEmpty(existsRecord)) {
|
||||||
|
return CommonResult.failed("审核记录不存在");
|
||||||
}
|
}
|
||||||
|
|
||||||
EsignPlatformInfo record = JSONUtil.toBean(paramsJSON, EsignPlatformInfo.class);
|
EsignPlatformInfo record = JSONUtil.toBean(paramsJSON, EsignPlatformInfo.class);
|
||||||
if (record == null) {
|
|
||||||
return CommonResult.failed("参数格式有误");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 校验 EsignPlatformInfo 必要关键参数
|
// 校验 EsignPlatformInfo 必要关键参数
|
||||||
if (StrUtil.hasBlank(
|
if (StrUtil.hasBlank(
|
||||||
@ -558,9 +629,6 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
|||||||
record.setRec_acc_clear_bank_no(record.getRec_acc_bank_no());
|
record.setRec_acc_clear_bank_no(record.getRec_acc_bank_no());
|
||||||
record.setRec_acc_type(2); // 款账户账户类型:1-个人(对私);2-企业(对公);
|
record.setRec_acc_type(2); // 款账户账户类型:1-个人(对私);2-企业(对公);
|
||||||
|
|
||||||
// 邀请码,要自动生成
|
|
||||||
record.setInvite_code("6543");
|
|
||||||
|
|
||||||
// 接口只接收二级(区)代理商
|
// 接口只接收二级(区)代理商
|
||||||
record.setLevel(CommonConstant.Agent_Level_2nd);
|
record.setLevel(CommonConstant.Agent_Level_2nd);
|
||||||
if (StrUtil.isBlank(record.getEmail())) {
|
if (StrUtil.isBlank(record.getEmail())) {
|
||||||
@ -591,12 +659,14 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl<EsignPlatformI
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 如果 esign_platform_info 记录不存在,新增esign_platform_info 记录
|
// 如果 esign_platform_info 记录不存在,新增esign_platform_info 记录
|
||||||
|
// 状态:1-已审核通过;2-审核未通过;3-待审中;
|
||||||
|
record.setStatus(CommonConstant.Enable);
|
||||||
Boolean result = addOrUpdateEsignPlatformInfo(record);
|
Boolean result = addOrUpdateEsignPlatformInfo(record);
|
||||||
if (!result) {
|
if (!result) {
|
||||||
throw new ApiException("保存代理商信息失败");
|
throw new ApiException("保存代理商信息失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
log.info("[申请二级代理商] 申请成功,代理商ID: {}, 公司名: {}", record.getId(), record.getLicense_company());
|
log.info("[审批二级代理商] 申请成功,代理商ID: {}, 公司名: {}", record.getId(), record.getLicense_company());
|
||||||
return CommonResult.success();
|
return CommonResult.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user