From b6af474c76df575f7bfe2fe89dfdf74853b7e54d Mon Sep 17 00:00:00 2001 From: Jack <46790855@qq.com> Date: Mon, 3 Mar 2025 14:55:18 +0800 Subject: [PATCH] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81bug=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/AccountUserBaseServiceImpl.java | 38 +++---- .../mall/common/constant/CommonConstant.java | 6 ++ .../modules/esign/EsignPlatformInfo.java | 4 +- .../service/EsignPlatformInfoService.java | 7 +- .../esign/service/FileAndTemplateService.java | 6 +- .../impl/EsignPlatformInfoServiceImpl.java | 29 ++++- .../impl/FileAndTemplateServiceImpl.java | 102 +++++++++++++++++- .../admin/ShopMerchEntryAdminController.java | 4 +- .../mobile/ShopMerchEntryController.java | 4 +- .../mapper/ShopMerchEntryMapper.java | 2 +- .../service/ShopMerchEntryService.java | 15 ++- .../impl/ShopMerchEntryServiceImpl.java | 42 +++++++- .../{merch => store}/ShopMerchEntryMapper.xml | 2 +- 13 files changed, 214 insertions(+), 47 deletions(-) rename mall-shop/src/main/java/com/suisung/mall/shop/{merch => store}/controller/admin/ShopMerchEntryAdminController.java (95%) rename mall-shop/src/main/java/com/suisung/mall/shop/{merch => store}/controller/mobile/ShopMerchEntryController.java (96%) rename mall-shop/src/main/java/com/suisung/mall/shop/{merch => store}/mapper/ShopMerchEntryMapper.java (93%) rename mall-shop/src/main/java/com/suisung/mall/shop/{merch => store}/service/ShopMerchEntryService.java (82%) rename mall-shop/src/main/java/com/suisung/mall/shop/{merch => store}/service/impl/ShopMerchEntryServiceImpl.java (89%) rename mall-shop/src/main/resources/mapper/{merch => store}/ShopMerchEntryMapper.xml (80%) diff --git a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java index 0b40285d..7bd14e43 100644 --- a/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java +++ b/mall-account/src/main/java/com/suisung/mall/account/service/impl/AccountUserBaseServiceImpl.java @@ -2362,39 +2362,39 @@ public class AccountUserBaseServiceImpl extends BaseServiceImpl implements EsignPlatformInfoService { /** - * 根据分类获取平台方信息 + * 根据分类和营业执照号获取平台方信息 * - * @param type + * @param type 分类(可选):类型:0-平台方(只能一条记录);1-一级代理;2-二级代理;3-三级代理;4-四级代理; + * @param licenseNumber 营业执照号码(可选) * @return */ @Override - public EsignPlatformInfo getEsignPlatformInfo(Integer type) { - return null; + public EsignPlatformInfo getEsignPlatformInfo(Integer type, String licenseNumber) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + if (ObjectUtils.isEmpty(type)) { + queryWrapper.eq("type", type); + } + + if (StrUtil.isNotBlank(licenseNumber)) { + queryWrapper.eq("license_number", licenseNumber); + } + + List esignPlatformInfos = list(queryWrapper); + if (CollectionUtil.isEmpty(esignPlatformInfos)) { + return null; + } + + return esignPlatformInfos.get(0); } } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/FileAndTemplateServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/FileAndTemplateServiceImpl.java index bd251a84..395d0789 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/FileAndTemplateServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/FileAndTemplateServiceImpl.java @@ -8,18 +8,27 @@ package com.suisung.mall.shop.esign.service.impl; +import cn.hutool.core.util.StrUtil; +import cn.hutool.json.JSONArray; import cn.hutool.json.JSONObject; import cn.hutool.json.JSONUtil; +import com.suisung.mall.common.constant.CommonConstant; import com.suisung.mall.common.modules.esign.EsignContractFillingFile; +import com.suisung.mall.common.modules.esign.EsignPlatformInfo; +import com.suisung.mall.common.modules.merch.ShopMerchEntry; +import com.suisung.mall.shop.esign.service.EsignPlatformInfoService; import com.suisung.mall.shop.esign.service.FileAndTemplateService; import com.suisung.mall.shop.esign.utils.comm.EsignHttpHelper; import com.suisung.mall.shop.esign.utils.comm.EsignHttpResponse; import com.suisung.mall.shop.esign.utils.enums.EsignRequestType; import com.suisung.mall.shop.esign.utils.exception.EsignDemoException; +import com.suisung.mall.shop.store.service.ShopMerchEntryService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; +import org.springframework.util.ObjectUtils; +import javax.annotation.Resource; import java.util.Map; @Slf4j @@ -34,16 +43,99 @@ public class FileAndTemplateServiceImpl implements FileAndTemplateService { @Value("${esign.app_secret}") private String appSecret; + @Resource + private EsignPlatformInfoService esignPlatformInfoService; + + @Resource + private ShopMerchEntryService shopMerchEntryService; /** * 填充合同模版,生成合同文件地址 * - * @param storeId - * @param docTemplateId + * @param mchLicenseNumber 入驻商家(甲方)的营业执照号 + * @param platLicenseNumber 平台方(代理商方)(乙方)营业执照号 * @return */ @Override - public EsignContractFillingFile fillDocTemplate(String storeId, String docTemplateId) { + public EsignContractFillingFile fillDocTemplate(String mchLicenseNumber, String platLicenseNumber) { + // 获取平台方的信息 + EsignPlatformInfo esignPlatformInfo = null; + if (StrUtil.isNotEmpty(platLicenseNumber)) { + esignPlatformInfo = esignPlatformInfoService.getEsignPlatformInfo(null, platLicenseNumber); + } + if (ObjectUtils.isEmpty(esignPlatformInfo)) { + esignPlatformInfo = esignPlatformInfoService.getEsignPlatformInfo(0, ""); + } + + if (ObjectUtils.isEmpty(esignPlatformInfo)) { + log.error("缺少平台方(代理商方)信息"); + return null; + } + + // 获取入驻商家(审批通过的)的信息 + ShopMerchEntry shopMerchEntry = shopMerchEntryService.getShopMerchEntryByLicenseNumber("", mchLicenseNumber, CommonConstant.MCH_APPR_STA_PASS); + if (shopMerchEntry == null) { + log.error("缺少商家入驻信息"); + return null; + } + + String apiaddr = "/v3/files/create-by-doc-template"; + EsignRequestType requestType = EsignRequestType.POST; + + JSONArray templates = JSONUtil.parseArray(esignPlatformInfo.getDoc_template()); + if (ObjectUtils.isEmpty(templates)) { + log.error("缺少平台方(代理商方)合同模版信息"); + return null; + } + + for (Object template : templates) { + JSONObject templateJson = (JSONObject) template; + + // 获取填充模版的数据 + JSONObject fillJson = new JSONObject(); + fillJson.put("docTemplateId", templateJson.getStr("template_id")) + .put("fileName", templateJson.getStr("template_name")); + + String components = "[{'componentKey':'yf_company','componentValue':'桂平厚德贸易有限公司'},{'componentKey':'sign_date','componentValue':'2025-02-20'}]"; + fillJson.put("components", JSONUtil.parseArray(components)); + + String jsonParma = fillJson.toString(); + + //生成签名鉴权方式的的header + Map header = null; + try { + header = EsignHttpHelper.signAndBuildSignAndJsonHeader(appId, appSecret, jsonParma, requestType.name(), apiaddr, true); + //发起接口请求 + EsignHttpResponse createByDocTemplate = EsignHttpHelper.doCommHttp(serverUrl, apiaddr, requestType, jsonParma, header, true); + + log.info("{}", createByDocTemplate); + + EsignContractFillingFile esignContractFillingFile = new EsignContractFillingFile(); + esignContractFillingFile.setDoc_template_id("docTemplateId"); + esignContractFillingFile.setStore_id("storeId"); + esignContractFillingFile.setDoc_template_filling_values(jsonParma); + esignContractFillingFile.setUnsigned_contract_url(createByDocTemplate.getBody()); + esignContractFillingFile.setUnsigned_contract_local_url(createByDocTemplate.getBody()); + esignContractFillingFile.setStatus(1); + return esignContractFillingFile; + + } catch (EsignDemoException e) { + throw new RuntimeException(e); + } + } + + return null; + } + + /** + * 填充合同模版,生成合同文件地址 + * + * @param mchLicenseNumber 入驻商家的营业执照号 + * @param platLicenseNumber 平台方(代理商方)营业执照号 + * @return + */ + // @Override + public EsignContractFillingFile fillDocTemplate1(String mchLicenseNumber, String platLicenseNumber) { // 获取模版文件 String templateId = "b411907d8f4640a1af593bea98c6b6c1"; String apiaddr = "/v3/files/create-by-doc-template"; @@ -73,8 +165,8 @@ public class FileAndTemplateServiceImpl implements FileAndTemplateService { log.info("{}", createByDocTemplate); EsignContractFillingFile esignContractFillingFile = new EsignContractFillingFile(); - esignContractFillingFile.setDoc_template_id(docTemplateId); - esignContractFillingFile.setStore_id(storeId); + esignContractFillingFile.setDoc_template_id("docTemplateId"); + esignContractFillingFile.setStore_id("storeId"); esignContractFillingFile.setDoc_template_filling_values(jsonParma); esignContractFillingFile.setUnsigned_contract_url(createByDocTemplate.getBody()); esignContractFillingFile.setUnsigned_contract_local_url(createByDocTemplate.getBody()); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/merch/controller/admin/ShopMerchEntryAdminController.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopMerchEntryAdminController.java similarity index 95% rename from mall-shop/src/main/java/com/suisung/mall/shop/merch/controller/admin/ShopMerchEntryAdminController.java rename to mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopMerchEntryAdminController.java index bfa07ccf..d4605fb3 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/merch/controller/admin/ShopMerchEntryAdminController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopMerchEntryAdminController.java @@ -6,12 +6,12 @@ * Vestibulum commodo. Ut rhoncus gravida arcu. */ -package com.suisung.mall.shop.merch.controller.admin; +package com.suisung.mall.shop.store.controller.admin; import cn.hutool.json.JSONObject; import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.service.impl.BaseControllerImpl; -import com.suisung.mall.shop.merch.service.ShopMerchEntryService; +import com.suisung.mall.shop.store.service.ShopMerchEntryService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.RequestBody; diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/merch/controller/mobile/ShopMerchEntryController.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/mobile/ShopMerchEntryController.java similarity index 96% rename from mall-shop/src/main/java/com/suisung/mall/shop/merch/controller/mobile/ShopMerchEntryController.java rename to mall-shop/src/main/java/com/suisung/mall/shop/store/controller/mobile/ShopMerchEntryController.java index f783c3b2..59648a00 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/merch/controller/mobile/ShopMerchEntryController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/mobile/ShopMerchEntryController.java @@ -6,12 +6,12 @@ * Vestibulum commodo. Ut rhoncus gravida arcu. */ -package com.suisung.mall.shop.merch.controller.mobile; +package com.suisung.mall.shop.store.controller.mobile; import cn.hutool.json.JSONObject; import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.service.impl.BaseControllerImpl; -import com.suisung.mall.shop.merch.service.ShopMerchEntryService; +import com.suisung.mall.shop.store.service.ShopMerchEntryService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.web.bind.annotation.RequestBody; diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/merch/mapper/ShopMerchEntryMapper.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/mapper/ShopMerchEntryMapper.java similarity index 93% rename from mall-shop/src/main/java/com/suisung/mall/shop/merch/mapper/ShopMerchEntryMapper.java rename to mall-shop/src/main/java/com/suisung/mall/shop/store/mapper/ShopMerchEntryMapper.java index 8f02968b..68c7a32f 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/merch/mapper/ShopMerchEntryMapper.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/mapper/ShopMerchEntryMapper.java @@ -6,7 +6,7 @@ * Vestibulum commodo. Ut rhoncus gravida arcu. */ -package com.suisung.mall.shop.merch.mapper; +package com.suisung.mall.shop.store.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.suisung.mall.common.modules.merch.ShopMerchEntry; diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/merch/service/ShopMerchEntryService.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMerchEntryService.java similarity index 82% rename from mall-shop/src/main/java/com/suisung/mall/shop/merch/service/ShopMerchEntryService.java rename to mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMerchEntryService.java index 24ae482c..bdda3ef9 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/merch/service/ShopMerchEntryService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMerchEntryService.java @@ -6,10 +6,11 @@ * Vestibulum commodo. Ut rhoncus gravida arcu. */ -package com.suisung.mall.shop.merch.service; +package com.suisung.mall.shop.store.service; import cn.hutool.json.JSONObject; import com.suisung.mall.common.api.CommonResult; +import com.suisung.mall.common.modules.merch.ShopMerchEntry; import java.util.List; @@ -78,4 +79,14 @@ public interface ShopMerchEntryService { * @return */ Integer shopMerchEntryApprovalStatus(String loginMobile); -} + + /** + * 根据商家手机号、营业执照、审批状态获取有效的商家入驻申请记录 + * + * @param loginMobile + * @param bizLicenseNumber + * @param approvalStatus + * @return + */ + ShopMerchEntry getShopMerchEntryByLicenseNumber(String loginMobile, String bizLicenseNumber, Integer approvalStatus); +} \ No newline at end of file diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/merch/service/impl/ShopMerchEntryServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMerchEntryServiceImpl.java similarity index 89% rename from mall-shop/src/main/java/com/suisung/mall/shop/merch/service/impl/ShopMerchEntryServiceImpl.java rename to mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMerchEntryServiceImpl.java index 0f30ebe2..05d0c94c 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/merch/service/impl/ShopMerchEntryServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMerchEntryServiceImpl.java @@ -6,7 +6,7 @@ * Vestibulum commodo. Ut rhoncus gravida arcu. */ -package com.suisung.mall.shop.merch.service.impl; +package com.suisung.mall.shop.store.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; @@ -24,8 +24,8 @@ import com.suisung.mall.common.utils.StringUtils; import com.suisung.mall.common.utils.phone.PhoneNumberUtils; import com.suisung.mall.core.web.service.impl.BaseServiceImpl; import com.suisung.mall.shop.base.service.AccountBaseConfigService; -import com.suisung.mall.shop.merch.mapper.ShopMerchEntryMapper; -import com.suisung.mall.shop.merch.service.ShopMerchEntryService; +import com.suisung.mall.shop.store.mapper.ShopMerchEntryMapper; +import com.suisung.mall.shop.store.service.ShopMerchEntryService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -339,4 +339,40 @@ public class ShopMerchEntryServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("status", CommonConstant.Enable).orderByAsc("id"); + if (StrUtil.isNotBlank(loginMobile)) { + queryWrapper.eq("login_mobile", loginMobile); + } + + if (StrUtil.isNotBlank(bizLicenseNumber)) { + queryWrapper.eq("biz_license_number", bizLicenseNumber); + } + + if (ObjectUtil.isEmpty(approvalStatus)) { + queryWrapper.eq("approval_status", approvalStatus); + } + + List recordList = list(queryWrapper); + if (CollectionUtil.isEmpty(recordList)) { + return null; + } + + return recordList.get(0); + } } diff --git a/mall-shop/src/main/resources/mapper/merch/ShopMerchEntryMapper.xml b/mall-shop/src/main/resources/mapper/store/ShopMerchEntryMapper.xml similarity index 80% rename from mall-shop/src/main/resources/mapper/merch/ShopMerchEntryMapper.xml rename to mall-shop/src/main/resources/mapper/store/ShopMerchEntryMapper.xml index 6f09d40a..1004d888 100644 --- a/mall-shop/src/main/resources/mapper/merch/ShopMerchEntryMapper.xml +++ b/mall-shop/src/main/resources/mapper/store/ShopMerchEntryMapper.xml @@ -1,6 +1,6 @@ - + *