优化入驻和合同生成,状态都流程

This commit is contained in:
Jack 2025-03-20 12:08:39 +08:00
parent 7b29201939
commit 9039a35234
9 changed files with 119 additions and 27 deletions

View File

@ -55,9 +55,10 @@ public class CommonConstant {
public static final Integer MCH_ENTITY_TYPE_QY = 1; public static final Integer MCH_ENTITY_TYPE_QY = 1;
public static final Integer MCH_ENTITY_TYPE_GR = 2; public static final Integer MCH_ENTITY_TYPE_GR = 2;
// 合作方签署状态-1预备数据阶段1-等待签署2-已完成所有签署方完成签署3-已撤销发起方撤销签署任务5-已过期签署截止日到期后触发7-已拒签签署方拒绝签署 // 合作方签署状态-1预备数据阶段0-等待签署1-部分已签署2-已完成所有签署方完成签署3-已撤销发起方撤销签署任务5-已过期签署截止日到期后触发7-已拒签签署方拒绝签署
public static final Integer CONTRACT_SIGN_STA_PREPARE = -1; public static final Integer CONTRACT_SIGN_STA_PREPARE = -1;
public static final Integer CONTRACT_SIGN_STA_ING = 1; public static final Integer CONTRACT_SIGN_STA_ING = 0;
public static final Integer CONTRACT_SIGN_STA_PARTIALLY = 1;
public static final Integer CONTRACT_SIGN_STA_FINISH = 2; public static final Integer CONTRACT_SIGN_STA_FINISH = 2;
public static final Integer CONTRACT_SIGN_STA_CANCEL = 3; public static final Integer CONTRACT_SIGN_STA_CANCEL = 3;
public static final Integer CONTRACT_SIGN_STA_EXPIRED = 5; public static final Integer CONTRACT_SIGN_STA_EXPIRED = 5;

View File

@ -23,6 +23,7 @@ import com.suisung.mall.common.modules.esign.EsignContractFillingFile;
import com.suisung.mall.common.modules.esign.EsignPlatformInfo; import com.suisung.mall.common.modules.esign.EsignPlatformInfo;
import com.suisung.mall.common.modules.merch.ShopMerchEntry; import com.suisung.mall.common.modules.merch.ShopMerchEntry;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl; import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import com.suisung.mall.shop.components.TaskService;
import com.suisung.mall.shop.esign.mapper.EsignContractMapper; import com.suisung.mall.shop.esign.mapper.EsignContractMapper;
import com.suisung.mall.shop.esign.service.EsignContractFillingFileService; import com.suisung.mall.shop.esign.service.EsignContractFillingFileService;
import com.suisung.mall.shop.esign.service.EsignContractService; import com.suisung.mall.shop.esign.service.EsignContractService;
@ -34,6 +35,7 @@ import com.suisung.mall.shop.esign.utils.exception.EsignDemoException;
import com.suisung.mall.shop.page.service.OssService; import com.suisung.mall.shop.page.service.OssService;
import com.suisung.mall.shop.store.service.ShopMerchEntryService; import com.suisung.mall.shop.store.service.ShopMerchEntryService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.data.util.Pair; import org.springframework.data.util.Pair;
@ -89,6 +91,10 @@ public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMappe
@Resource @Resource
private OssService ossService; private OssService ossService;
@Autowired
private TaskService taskService;
/*** /***
* 获取请求签名值 * 获取请求签名值
* *
@ -199,7 +205,7 @@ public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMappe
return CommonResult.failed("签署失败,状态码:" + createByDocTemplate.getStatus()); return CommonResult.failed("签署失败,状态码:" + createByDocTemplate.getStatus());
} }
//作方签署状态-1预备数据阶段1-等待签署2 - 已完成所有签署方完成签署3 - 已撤销发起方撤销签署任务5 - 已过期签署截止日到期后触发7 - 已拒签签署方拒绝签署 //同签署状态-1预备数据阶段0-等待签署1-已部分签署2-已完成所有签署方完成签署3-已撤销发起方撤销签署任务5-已过期签署截止日到期后触发7-已拒签签署方拒绝签署
Boolean success = updateContractFlowIdAndFileUrl(esignContract.getId(), signFlowId, CommonConstant.CONTRACT_SIGN_STA_ING, null); Boolean success = updateContractFlowIdAndFileUrl(esignContract.getId(), signFlowId, CommonConstant.CONTRACT_SIGN_STA_ING, null);
if (!success) { if (!success) {
log.error("更新合同流程状态失败"); log.error("更新合同流程状态失败");
@ -238,6 +244,7 @@ public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMappe
return new ResponseEntity<>(new JSONObject().put("code", 400).put("msg", "appId 有误").toString(), HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(new JSONObject().put("code", 400).put("msg", "appId 有误").toString(), HttpStatus.INTERNAL_SERVER_ERROR);
} }
//按照规则进行加密 //按照规则进行加密
String signData = timestamp + requestBody; String signData = timestamp + requestBody;
String mySignature = getSignature(signData, appSecret, "HmacSHA256", "UTF-8"); String mySignature = getSignature(signData, appSecret, "HmacSHA256", "UTF-8");
@ -251,11 +258,22 @@ public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMappe
JSONObject reqBodyJSON = JSONUtil.parseObj(requestBody); JSONObject reqBodyJSON = JSONUtil.parseObj(requestBody);
String action = reqBodyJSON.getStr("action"); String action = reqBodyJSON.getStr("action");
String signFlowId = reqBodyJSON.getStr("signFlowId"); String signFlowId = reqBodyJSON.getStr("signFlowId");
Integer signResult = reqBodyJSON.getInt("signResult");
if (StrUtil.isBlank(action) || StrUtil.isBlank(signFlowId)) { if (StrUtil.isBlank(action) || StrUtil.isBlank(signFlowId)) {
return new ResponseEntity<>(new JSONObject().put("code", 400).put("msg", "返回数据有误").toString(), HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(new JSONObject().put("code", 400).put("msg", "返回数据有误").toString(), HttpStatus.INTERNAL_SERVER_ERROR);
} }
// 获取合同签署记录
EsignContract esignContract = baseMapper.selectOne(new QueryWrapper<EsignContract>().eq("sign_flow_id", signFlowId));
if (esignContract == null) {
return new ResponseEntity<>(new JSONObject().put("code", 400).put("msg", "获取不到合同记录").toString(), HttpStatus.INTERNAL_SERVER_ERROR);
}
log.debug("签署流程结束通知:action >>> {}", action); log.debug("签署流程结束通知:action >>> {}", action);
if (CommonConstant.CONTRACT_SIGN_STA_FINISH.equals(esignContract.getSign_flow_status()) && StrUtil.isNotEmpty(esignContract.getLocal_contract_url())) {
// 已经签署完毕不用在更改状态
return new ResponseEntity<>(new JSONObject().put("code", 200).put("msg", "success").toString(), HttpStatus.OK);
}
// 获取正式盖章合同文件上传到 oss 服务器更状态,保存数据 // 获取正式盖章合同文件上传到 oss 服务器更状态,保存数据
if (action.equals("SIGN_FLOW_COMPLETE")) {// 签署流程完毕 if (action.equals("SIGN_FLOW_COMPLETE")) {// 签署流程完毕
@ -268,13 +286,20 @@ public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMappe
if (success && StrUtil.isNotBlank(downloadUrl)) { if (success && StrUtil.isNotBlank(downloadUrl)) {
return new ResponseEntity<>(new JSONObject().put("code", 200).put("msg", "success").toString(), HttpStatus.OK); return new ResponseEntity<>(new JSONObject().put("code", 200).put("msg", "success").toString(), HttpStatus.OK);
} }
} else if (action.equals("SIGN_MISSON_COMPLETE") && ObjectUtil.isNotEmpty(signResult)) {// 签署方-签署结果含拒签通知
Integer signFlowStatus = 1;
if (signResult.equals(2)) {
signFlowStatus = CommonConstant.CONTRACT_SIGN_STA_PARTIALLY;
} else if (signResult.equals(4)) {
signFlowStatus = CommonConstant.CONTRACT_SIGN_STA_REJECT;
}
// 更新合同流程状态和文件地址
boolean success = updateContractFlowStatusAndFileUrlBySignFlowId(signFlowId, signFlowStatus, "");
if (success) {
return new ResponseEntity<>(new JSONObject().put("code", 200).put("msg", "success").toString(), HttpStatus.OK);
}
} else { } else {
log.debug("签署流程未完成,不做处理"); log.debug("签署流程未完成,不做处理");
// 更新合同流程状态和文件地址
// boolean success = updateContractFlowStatusAndFileUrlBySignFlowId(signFlowId, CommonConstant.CONTRACT_SIGN_STA_FINISH, "");
// if (success) {
// return new ResponseEntity<>(new JSONObject().put("code", 200).put("msg", "success").toString(), HttpStatus.OK);
// }
} }
return new ResponseEntity<>(new JSONObject().put("code", 400).put("msg", "未更新数据!").toString(), HttpStatus.INTERNAL_SERVER_ERROR); return new ResponseEntity<>(new JSONObject().put("code", 400).put("msg", "未更新数据!").toString(), HttpStatus.INTERNAL_SERVER_ERROR);
@ -432,6 +457,7 @@ public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMappe
queryWrapper.set("sign_flow_status", signFlowStatus); queryWrapper.set("sign_flow_status", signFlowStatus);
} }
String localFileUrl;
if (StrUtil.isNotBlank(fileUrl)) { if (StrUtil.isNotBlank(fileUrl)) {
queryWrapper.set("signed_contract_url", fileUrl); queryWrapper.set("signed_contract_url", fileUrl);
@ -442,11 +468,25 @@ public class EsignContractServiceImpl extends BaseServiceImpl<EsignContractMappe
.concat("signed").concat("/") .concat("signed").concat("/")
.concat(esignContract.getContract_file_id()).concat(".pdf"); .concat(esignContract.getContract_file_id()).concat(".pdf");
// 上传到cos服务器 // 上传到cos服务器
String localFileUrl = ossService.uploadObject4OSS(fileUrl, cosFileName); localFileUrl = ossService.uploadObject4OSS(fileUrl, cosFileName);
queryWrapper.set("local_contract_url", localFileUrl); queryWrapper.set("local_contract_url", localFileUrl);
} else {
localFileUrl = "";
} }
return this.update(queryWrapper); Boolean success = this.update(queryWrapper);
if (success) {
// 更改同步合同审核状态和下载地址
taskService.executeTask(() -> {
log.debug("###更改同步合同审核状态和下载地址###");
// 更改同步合同审核状态和下载地址
if (!shopMerchEntryService.updateMerchEntrySignedStatusAndContractDownloadUrl(esignContract.getMch_mobile(), signFlowStatus, localFileUrl)) {
log.error("###更改同步合同审核状态和下载地址失败###");
}
});
}
return success;
} }
/** /**

View File

@ -220,7 +220,7 @@ public class UserOrderController extends BaseControllerImpl {
@ApiOperation(value = "查询移动商家端订单数据(新)", notes = "查询移动商家端订单数据(新)") @ApiOperation(value = "查询移动商家端订单数据(新)", notes = "查询移动商家端订单数据(新)")
@RequestMapping(value = "/mch/order/list", method = RequestMethod.POST) @RequestMapping(value = "/mch/order/list", method = RequestMethod.POST)
public CommonResult selectMchOrderPageList(@RequestBody JSONObject params) { public CommonResult selectMchOrderPageList(@RequestBody JSONObject params) {
return CommonResult.success(shopOrderBaseService.selectMchOrderPageList(params.getInt("storeId"), params.getStr("keyword"), params.getInt("status"), params.getInt("pageNum"), params.getInt("pageSize"))); return CommonResult.success(shopOrderBaseService.selectMchOrderPageList(params.getInt("storeId"), params.getStr("keyword"), params.getInt("status"), 25, params.getInt("pageNum"), params.getInt("pageSize")));
} }
@ApiOperation(value = "查询移动商家端订单详情数据", notes = "查询移动商家端订单详情数据") @ApiOperation(value = "查询移动商家端订单详情数据", notes = "查询移动商家端订单详情数据")

View File

@ -68,5 +68,5 @@ public interface ShopOrderBaseMapper extends BaseMapper<ShopOrderBase> {
* @param status 订单状态 * @param status 订单状态
* @return * @return
*/ */
IPage<MchOrderInfoDTO> selectMchOrderPageList(@Param("storeId") Integer storeId, @Param("keyword") String keyword, @Param("status") Integer status, IPage<MchOrderInfoDTO> page); IPage<MchOrderInfoDTO> selectMchOrderPageList(@Param("storeId") Integer storeId, @Param("keyword") String keyword, @Param("status") Integer status, @Param("expiredMinute") Integer expiredMinute, IPage<MchOrderInfoDTO> page);
} }

View File

@ -538,12 +538,13 @@ public interface ShopOrderBaseService extends IBaseService<ShopOrderBase> {
* 商家版订单列表 * 商家版订单列表
* *
* @param storeId * @param storeId
* @param keyword * @param keyword 订单搜索关键字
* @param status * @param status 查询状态1-进行中时效内2-异常订单已超时的3-退款订单
* @param pageNum * @param expiredMinute 配送超时的分钟数单位分钟
* @param pageSize * @param pageNum 页码
* @param pageSize 页大小
* @return * @return
*/ */
IPage<MchOrderInfoDTO> selectMchOrderPageList(Integer storeId, String keyword, Integer status, Integer pageNum, Integer pageSize); IPage<MchOrderInfoDTO> selectMchOrderPageList(Integer storeId, String keyword, Integer status, Integer expiredMinute, Integer pageNum, Integer pageSize);
} }

View File

@ -8484,17 +8484,21 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
/** /**
* 商家版订单列表 * 商家版订单列表
* *
* @param storeId 店铺Id * @param storeId
* @param keyword * @param keyword 订单搜索关键字
* @param status 1-进行中2-异常配送超时3-退款的 * @param status 查询状态1-进行中时效内2-异常订单已超时的3-退款订单
* @param pageNum 分页页码 * @param expiredMinute 配送超时的分钟数单位分钟
* @param pageSize 分页每页数量 * @param pageNum 页码
* @param pageSize 页大小
* @return * @return
*/ */
@Override @Override
public IPage<MchOrderInfoDTO> selectMchOrderPageList(Integer storeId, String keyword, Integer status, Integer pageNum, Integer pageSize) { public IPage<MchOrderInfoDTO> selectMchOrderPageList(Integer storeId, String keyword, Integer status, Integer expiredMinute, Integer pageNum, Integer pageSize) {
//订单状态(LIST):2011-待订单审核;2013-待财务审核;2020-待配货/待出库审核;2030-待发货;2040-已发货/待收货确认;2060-已完成/已签收;2070-已取消/已作废; // order_state_id 订单状态(LIST):2011-待订单审核;2013-待财务审核;2020-待配货/待出库审核;2030-待发货;2040-已发货/待收货确认;2060-已完成/已签收;2070-已取消/已作废;
Page<MchOrderInfoDTO> page = new Page<>(pageNum, pageSize); Page<MchOrderInfoDTO> page = new Page<>(pageNum, pageSize);
return shopOrderBaseMapper.selectMchOrderPageList(storeId, keyword, status, page); if (expiredMinute == null || expiredMinute <= 0) {
expiredMinute = 25;
}
return shopOrderBaseMapper.selectMchOrderPageList(storeId, keyword, status, expiredMinute, page);
} }
} }

View File

@ -107,4 +107,14 @@ public interface ShopMerchEntryService {
* @return * @return
*/ */
ShopMerchEntry getShopMerchEntryByLicenseNumber(String loginMobile, String bizLicenseNumber, Integer approvalStatus); ShopMerchEntry getShopMerchEntryByLicenseNumber(String loginMobile, String bizLicenseNumber, Integer approvalStatus);
/**
* 根据商家注册的手机号更新合同签署状态和合同下载地址
*
* @param loginMobile
* @param signedStatus
* @param contractDownloadUrl
* @return
*/
Boolean updateMerchEntrySignedStatusAndContractDownloadUrl(String loginMobile, Integer signedStatus, String contractDownloadUrl);
} }

View File

@ -363,6 +363,14 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl<ShopMerchEntryMap
if (contractInfo != null) { if (contractInfo != null) {
record.setSigned_status(contractInfo.getFirst()); record.setSigned_status(contractInfo.getFirst());
record.setContract_download_url(contractInfo.getSecond()); record.setContract_download_url(contractInfo.getSecond());
// 更改同步合同审核状态和下载地址失败
taskService.executeTask(() -> {
log.debug("###更改同步合同审核状态和下载地址###");
if (!updateMerchEntrySignedStatusAndContractDownloadUrl(record.getLogin_mobile(), record.getSigned_status(), record.getContract_download_url())) {
log.error("###更改同步合同审核状态和下载地址失败###");
}
});
} }
} }
@ -568,4 +576,32 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl<ShopMerchEntryMap
return recordList.get(0); return recordList.get(0);
} }
/**
* 根据商家注册的手机号更新合同签署状态和合同下载地址
*
* @param loginMobile
* @param signedStatus
* @param contractDownloadUrl
* @return
*/
@Override
public Boolean updateMerchEntrySignedStatusAndContractDownloadUrl(String loginMobile, Integer signedStatus, String contractDownloadUrl) {
if (StrUtil.isBlank(loginMobile) || (ObjectUtil.isEmpty(signedStatus) && StrUtil.isBlank(contractDownloadUrl))) {
return null;
}
UpdateWrapper<ShopMerchEntry> updateWrapper = new UpdateWrapper<>();
updateWrapper.eq("login_mobile", loginMobile);
if (ObjectUtil.isNotEmpty(signedStatus)) {
updateWrapper.eq("signed_status", signedStatus);
}
if (StrUtil.isNotBlank(contractDownloadUrl)) {
updateWrapper.set("contract_download_url", contractDownloadUrl);
}
return update(updateWrapper);
}
} }

View File

@ -697,12 +697,12 @@
<if test="status!=null and status==1"> <if test="status!=null and status==1">
and ob.order_state_id IN (2020, 2030, 2040) and ob.order_state_id IN (2020, 2030, 2040)
and TIMESTAMPADD(MINUTE, 25, oi.order_time) &gt;= NOW() and TIMESTAMPADD(MINUTE, #{expiredMinute}, oi.order_time) &gt;= NOW()
</if> </if>
<if test="status!=null and status==2"> <if test="status!=null and status==2">
and ob.order_state_id IN (2020, 2030, 2040) and ob.order_state_id IN (2020, 2030, 2040)
and TIMESTAMPADD(MINUTE, 25, oi.order_time) &lt;= NOW() and TIMESTAMPADD(MINUTE, #{expiredMinute}, oi.order_time) &lt;= NOW()
</if> </if>
<if test="status!=null and status==3"> <if test="status!=null and status==3">