diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/admin/EsignController.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/admin/EsignAdminController.java similarity index 96% rename from mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/admin/EsignController.java rename to mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/admin/EsignAdminController.java index 93d1d7e9..4ad451ff 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/admin/EsignController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/admin/EsignAdminController.java @@ -26,10 +26,10 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -@Api(tags = "E签宝电子签控制器") +@Api(tags = "E签宝电子签后台控制器") @RestController @RequestMapping("/admin/shop/esign") -public class EsignController extends BaseControllerImpl { +public class EsignAdminController extends BaseControllerImpl { @Resource private EsignContractFillingFileService esignContractFillingFileService; diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/mobile/EsignController.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/mobile/EsignController.java new file mode 100644 index 00000000..ccf2fa5f --- /dev/null +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/controller/mobile/EsignController.java @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2025. Lorem ipsum dolor sit amet, consectetur adipiscing elit. + * Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. + * Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. + * Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. + * Vestibulum commodo. Ut rhoncus gravida arcu. + */ + +package com.suisung.mall.shop.esign.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.esign.service.EsignContractFillingFileService; +import com.suisung.mall.shop.esign.service.EsignContractService; +import com.suisung.mall.shop.esign.service.EsignPlatformInfoService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +@Api(tags = "E签宝电子签前台控制器") +@RestController +@RequestMapping("/mobile/shop/esign") +public class EsignController extends BaseControllerImpl { + + @Resource + private EsignContractFillingFileService esignContractFillingFileService; + + @Resource + private EsignContractService esignContractService; + + @Resource + private EsignPlatformInfoService esignPlatformInfoService; + + @ApiOperation(value = "区域(二级)代理商申请", notes = "区域(二级)代理商申请") + @RequestMapping(value = "/apply/agent", method = RequestMethod.POST) + public CommonResult signFlowCreateByFile(@RequestBody JSONObject paramsJSON) { + return esignContractService.signFlowCreateByFile(paramsJSON.getInt("store_id")); + } + + @ApiOperation(value = "区域(三级)代理商详细信息", notes = "区域(三级)代理商详细信息") + @RequestMapping(value = "/agent/info", method = RequestMethod.POST) + public ResponseEntity signAsyncNotify(HttpServletRequest request, HttpServletResponse response, @RequestBody String requestBody) { + return esignContractService.signAsyncNotify(request, response, requestBody); + } + +} diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignPlatformInfoService.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignPlatformInfoService.java index 1e3c8097..2bcc551f 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignPlatformInfoService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/EsignPlatformInfoService.java @@ -8,6 +8,8 @@ package com.suisung.mall.shop.esign.service; +import cn.hutool.json.JSONObject; +import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.modules.esign.EsignPlatformInfo; import org.springframework.data.util.Pair; @@ -18,6 +20,15 @@ import java.util.List; */ public interface EsignPlatformInfoService { + + /** + * 添加或更新平台方信息 + * + * @param esignPlatformInfo + * @return + */ + Boolean addOrUpdateEsignPlatformInfo(EsignPlatformInfo esignPlatformInfo); + /** * 根据ID获取代理商信息 * @@ -43,6 +54,16 @@ public interface EsignPlatformInfoService { */ EsignPlatformInfo getEsignPlatformInfo(Integer level, String licenseNumber); + /** + * 根据分类和营业执照号和法人身份证号获取平台方信息 + * + * @param level 分类(必选):类型:0-平台方(只能一条记录);1-一级代理;2-二级代理;3-三级代理;4-四级代理; + * @param licenseNumber 营业执照号码(必选) + * @param legalPersonIdCard 法人身份证号(必选) + * @return + */ + EsignPlatformInfo getEsignPlatformInfo(Integer level, String licenseNumber, String legalPersonIdCard); + /** * 是否存在平台方的相关记录信息? * @@ -81,4 +102,12 @@ public interface EsignPlatformInfoService { * @return */ String getSupplierIdByAgentId(Long agentId); + + /** + * 申请二级代理商 + * + * @param paramsJSON + * @return + */ + CommonResult apply2ndAgent(JSONObject paramsJSON); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignPlatformInfoServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignPlatformInfoServiceImpl.java index 7bcb20f6..14f18311 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignPlatformInfoServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignPlatformInfoServiceImpl.java @@ -8,11 +8,14 @@ package com.suisung.mall.shop.esign.service.impl; -import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.suisung.mall.common.api.CommonResult; import com.suisung.mall.common.constant.CommonConstant; +import com.suisung.mall.common.exception.ApiException; import com.suisung.mall.common.modules.esign.EsignPlatformInfo; import com.suisung.mall.common.modules.store.ShopMchEntry; import com.suisung.mall.common.utils.CheckUtil; @@ -20,6 +23,7 @@ import com.suisung.mall.common.utils.phone.PhoneNumberUtils; import com.suisung.mall.core.web.service.impl.BaseServiceImpl; import com.suisung.mall.shop.esign.mapper.EsignPlatformInfoMapper; import com.suisung.mall.shop.esign.service.EsignPlatformInfoService; +import com.suisung.mall.shop.lakala.service.LklLedgerReceiverService; import com.suisung.mall.shop.store.service.ShopMchEntryService; import lombok.extern.slf4j.Slf4j; import org.springframework.context.annotation.Lazy; @@ -28,6 +32,7 @@ import org.springframework.stereotype.Service; import org.springframework.util.ObjectUtils; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -40,6 +45,71 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("id", id) - .gt("level", 0) - .eq("status", CommonConstant.Enable).orderByAsc("level"); - - List esignPlatformInfos = list(queryWrapper); - if (CollectionUtil.isEmpty(esignPlatformInfos)) { - return null; - } - - return esignPlatformInfos.get(0); + return getOne( + new LambdaQueryWrapper() + .eq(EsignPlatformInfo::getId, id) + .gt(EsignPlatformInfo::getLevel, 0) + .eq(EsignPlatformInfo::getStatus, CommonConstant.Enable) + .orderByAsc(EsignPlatformInfo::getLevel), + false + ); } /** @@ -79,12 +146,14 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("level", 0) - .eq("status", CommonConstant.Enable) - .orderByAsc("id"); + EsignPlatformInfo esignPlatformInfo = getOne( + new LambdaQueryWrapper() + .eq(EsignPlatformInfo::getLevel, 0) + .eq(EsignPlatformInfo::getStatus, CommonConstant.Enable) + .orderByAsc(EsignPlatformInfo::getId), + false + ); - EsignPlatformInfo esignPlatformInfo = getOne(queryWrapper, false); if (ObjectUtil.isEmpty(esignPlatformInfo)) { log.error("[获取平台和代理商信息] 未找到有效的平台方记录"); return Collections.emptyList(); @@ -110,12 +179,15 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl() + .eq(EsignPlatformInfo::getId, agent2nd.getParent_id()) + .eq(EsignPlatformInfo::getLevel, CommonConstant.Agent_Level_1st) + .gt(EsignPlatformInfo::getSplit_ratio, 0) + .eq(EsignPlatformInfo::getStatus, CommonConstant.Enable), + false + ); + if (agent1st != null) { esignPlatformInfos.add(agent1st); log.debug("[获取平台和代理商信息] 成功获取一级代理信息,ID: {}", agent1st.getId()); @@ -137,21 +209,34 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("status", CommonConstant.Enable); + LambdaQueryWrapper queryWrapper = + new LambdaQueryWrapper<>(); + queryWrapper.eq(EsignPlatformInfo::getStatus, CommonConstant.Enable); if (!ObjectUtils.isEmpty(level)) { - queryWrapper.eq("level", level); + queryWrapper.eq(EsignPlatformInfo::getLevel, level); } else { - queryWrapper.eq("level", 0); + queryWrapper.eq(EsignPlatformInfo::getLevel, 0); } if (StrUtil.isNotBlank(licenseNumber)) { - queryWrapper.eq("license_number", licenseNumber); + queryWrapper.eq(EsignPlatformInfo::getLicense_number, licenseNumber); } return getOne(queryWrapper, false); } + @Override + public EsignPlatformInfo getEsignPlatformInfo(Integer level, String licenseNumber, String legalPersonIdCard) { + LambdaQueryWrapper queryWrapper = + new LambdaQueryWrapper<>(); + queryWrapper + .eq(EsignPlatformInfo::getLevel, level) + .eq(EsignPlatformInfo::getLicense_number, licenseNumber) + .eq(EsignPlatformInfo::getLegal_person_id_card, legalPersonIdCard); + + return getOne(queryWrapper, false); + } + /** * 是否存在平台方的相关记录信息? * @@ -159,15 +244,12 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("level", 0).eq("status", CommonConstant.Enable); - - EsignPlatformInfo esignPlatformInfo = getOne(queryWrapper); - if (ObjectUtils.isEmpty(esignPlatformInfo)) { - return null; - } - - return esignPlatformInfo; + return getOne( + new LambdaQueryWrapper() + .eq(EsignPlatformInfo::getLevel, 0) + .eq(EsignPlatformInfo::getStatus, CommonConstant.Enable), + false + ); } /** @@ -180,12 +262,18 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("level", 0) - .eq("status", CommonConstant.Enable) - .select("telephone", "license_number", "legal_person_mobile"); + EsignPlatformInfo esignPlatformInfo = getOne( + new LambdaQueryWrapper() + .eq(EsignPlatformInfo::getLevel, 0) + .eq(EsignPlatformInfo::getStatus, CommonConstant.Enable) + .select( + EsignPlatformInfo::getTelephone, + EsignPlatformInfo::getLicense_number, + EsignPlatformInfo::getLegal_person_mobile + ), + false + ); - EsignPlatformInfo esignPlatformInfo = getOne(queryWrapper, false); if (esignPlatformInfo == null) { log.warn("[获取平台方信息] 未找到有效的平台方记录"); return null; @@ -243,31 +331,38 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("level", CommonConstant.Agent_Level_2nd) - .eq("status", CommonConstant.Enable) - .orderByAsc("id"); - EsignPlatformInfo result = null; - // 优先使用指定的分销商ID查询,否则使用区域信息查询 + // 优先使用指定的分销商ID查询 if (shopMchEntry.getDistributor_id() != null && shopMchEntry.getDistributor_id() > 0) { - queryWrapper.eq("id", shopMchEntry.getDistributor_id()); - result = getOne(queryWrapper, false); + result = getOne( + new LambdaQueryWrapper() + .eq(EsignPlatformInfo::getId, shopMchEntry.getDistributor_id()) + .eq(EsignPlatformInfo::getLevel, CommonConstant.Agent_Level_2nd) + .eq(EsignPlatformInfo::getStatus, CommonConstant.Enable) + .orderByAsc(EsignPlatformInfo::getId), + false + ); log.debug("[获取二级代理] 使用指定分销商ID查询,distributorId={}", shopMchEntry.getDistributor_id()); - } + // 如果通过分销商ID未找到,使用区域信息查询 if (result == null && StrUtil.isNotBlank(shopMchEntry.getStore_district())) { // 和商户同地区,并且二级代理商,有配送相关资质 - queryWrapper.eq("license_district_id", shopMchEntry.getStore_district()) - .gt("shipping_fee", 0).ne("supplier_id", "") - .orderByAsc("id"); - result = getOne(queryWrapper, false); + result = getOne( + new LambdaQueryWrapper() + .eq(EsignPlatformInfo::getLevel, CommonConstant.Agent_Level_2nd) + .eq(EsignPlatformInfo::getStatus, CommonConstant.Enable) + .eq(EsignPlatformInfo::getLicense_district_id, shopMchEntry.getStore_district()) + .gt(EsignPlatformInfo::getShipping_fee, 0) + .isNotNull(EsignPlatformInfo::getSupplier_id) + .ne(EsignPlatformInfo::getSupplier_id, "") + .orderByAsc(EsignPlatformInfo::getId), + false + ); log.debug("[获取二级代理] 使用区域信息查询,districtId={}", shopMchEntry.getStore_district()); - } if (result == null) { @@ -284,6 +379,7 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("id", agentId) - .eq("level", CommonConstant.Agent_Level_2nd) - .eq("status", CommonConstant.Enable) - .select("supplier_id"); - // 查询记录 - EsignPlatformInfo result = getOne(queryWrapper); + EsignPlatformInfo result = getOne( + new LambdaQueryWrapper() + .eq(EsignPlatformInfo::getId, agentId) + .eq(EsignPlatformInfo::getLevel, CommonConstant.Agent_Level_2nd) + .eq(EsignPlatformInfo::getStatus, CommonConstant.Enable) + .select(EsignPlatformInfo::getSupplier_id), + false + ); // 检查结果并返回 if (result != null && StrUtil.isNotBlank(result.getSupplier_id())) { @@ -349,4 +445,160 @@ public class EsignPlatformInfoServiceImpl extends BaseServiceImpl applyResult = lklLedgerReceiverService.innerApplyLedgerReceiver(record); + if (!applyResult.getFirst()) { + throw new ApiException("代理商提交第三方失败:" + applyResult.getSecond()); + } + + // 如果 esign_platform_info 记录不存在,新增esign_platform_info 记录 + Boolean result = addOrUpdateEsignPlatformInfo(record); + if (!result) { + throw new ApiException("保存代理商信息失败"); + } + + log.info("[申请二级代理商] 申请成功,代理商ID: {}, 公司名: {}", record.getId(), record.getLicense_company()); + return CommonResult.success(); + } + + } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/LklLedgerReceiverService.java b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/LklLedgerReceiverService.java index 5cf0ed62..fe743007 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/LklLedgerReceiverService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/LklLedgerReceiverService.java @@ -9,8 +9,11 @@ package com.suisung.mall.shop.lakala.service; import cn.hutool.json.JSONArray; +import cn.hutool.json.JSONObject; +import com.suisung.mall.common.modules.esign.EsignPlatformInfo; import com.suisung.mall.common.modules.lakala.LklLedgerReceiver; import com.suisung.mall.core.web.service.IBaseService; +import org.springframework.data.util.Pair; import java.util.List; @@ -48,14 +51,29 @@ public interface LklLedgerReceiverService extends IBaseService innerApplyLedgerReceiver(EsignPlatformInfo esignPlatformInfo); /** * 是否存在平台方的相关记录信息? @@ -115,5 +133,5 @@ public interface LklLedgerReceiverService extends IBaseService queryWrapper = new QueryWrapper<>(); + LambdaQueryWrapper queryWrapper = + new LambdaQueryWrapper<>(); if (StrUtil.isNotBlank(record.getLicense_no())) { - queryWrapper.eq("license_no", record.getLicense_no()); + queryWrapper.eq(LklLedgerReceiver::getLicense_no, record.getLicense_no()); } if (StrUtil.isNotBlank(record.getContact_mobile())) { - queryWrapper.eq("contact_mobile", record.getContact_mobile()); + queryWrapper.eq(LklLedgerReceiver::getContact_mobile, record.getContact_mobile()); } Long platformId = record.getPlatform_id(); if (ObjectUtil.isEmpty(platformId)) { platformId = 0L; } - queryWrapper.eq("platform_id", platformId).eq("status", CommonConstant.Enable); + queryWrapper.eq(LklLedgerReceiver::getPlatform_id, platformId).eq(LklLedgerReceiver::getStatus, CommonConstant.Enable); LklLedgerReceiver existsRecord = getOne(queryWrapper, false); if (ObjectUtil.isNotEmpty(existsRecord)) { @@ -99,11 +102,13 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("receiver_no", receiverNo).eq("status", CommonConstant.Enable); - queryWrapper.orderByAsc("id"); - - return getOne(queryWrapper); + return getOne( + new LambdaQueryWrapper() + .eq(LklLedgerReceiver::getReceiver_no, receiverNo) + .eq(LklLedgerReceiver::getStatus, CommonConstant.Enable) + .orderByAsc(LklLedgerReceiver::getId), + false + ); } /** @@ -118,10 +123,13 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("platform_id", platformId).eq("status", CommonConstant.Enable).orderByAsc("id"); + List lklLedgerReceivers = list( + new LambdaQueryWrapper() + .eq(LklLedgerReceiver::getPlatform_id, platformId) + .eq(LklLedgerReceiver::getStatus, CommonConstant.Enable) + .orderByAsc(LklLedgerReceiver::getId) + ); - List lklLedgerReceivers = list(queryWrapper); if (CollectionUtil.isEmpty(lklLedgerReceivers)) { return null; } @@ -138,7 +146,6 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl esignPlatformInfoList = esignPlatformInfoService.selectAgentAndPlatformByMchId(mchId); if (CollectionUtil.isEmpty(esignPlatformInfoList)) { @@ -147,78 +154,116 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl 0; if (success) { // 更新多个状态 - shopMchEntryService.updateMulStatus(mchId, merCupNo, 0, 0, 0, 0, 1, 0, CommonConstant.MCH_APPR_STA_LKL_PADDING); + shopMchEntryService.updateMulStatus(mchId, "", 0, 0, 0, 0, 1, 0, CommonConstant.MCH_APPR_STA_LKL_PADDING); } return success; } + /** + * 内部调用:申请一个或多个分账接收方(平台方和代理商) + * + * @param esignPlatformInfo + * @return + */ + @Override + public Pair innerApplyLedgerReceiver(EsignPlatformInfo esignPlatformInfo) { + // 商户的分账接收方:平台+代理商 + JSONObject reqParam = buildApplyLedgerReceiverReqParams(esignPlatformInfo); + + if (reqParam == null || reqParam.isEmpty()) { + log.error("平台或代理商信息有误"); + return Pair.of(false, "平台或代理商信息有误"); + } + + // 向拉卡拉申请分账接收方 + CommonResult result = lakalaApiService.applyLedgerReceiver(reqParam); + if (result == null || result.getStatus() != ResultCode.SUCCESS.getStatus()) { + log.error("申请分账接收方失败:{}", result.getMsg()); + return Pair.of(false, result.getMsg()); + } + + return Pair.of(true, ""); + } + + /** * 是否存在平台方的相关记录信息? * @@ -258,10 +330,13 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("platform_id", 0).eq("status", CommonConstant.Enable).orderByAsc("id"); + List lklLedgerReceivers = list( + new LambdaQueryWrapper() + .eq(LklLedgerReceiver::getPlatform_id, 0L) + .eq(LklLedgerReceiver::getStatus, CommonConstant.Enable) + .orderByAsc(LklLedgerReceiver::getId) + ); - List lklLedgerReceivers = list(queryWrapper); if (CollectionUtil.isEmpty(lklLedgerReceivers)) { return null; } @@ -276,9 +351,12 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl selectPlatformAnDistributorList() { - QueryWrapper queryWrapper = new QueryWrapper<>(); - queryWrapper.ge("platform_id", 0).eq("status", CommonConstant.Enable).orderByAsc("platform_id"); - return list(queryWrapper); + return list( + new LambdaQueryWrapper() + .ge(LklLedgerReceiver::getPlatform_id, 0L) + .eq(LklLedgerReceiver::getStatus, CommonConstant.Enable) + .orderByAsc(LklLedgerReceiver::getPlatform_id) + ); } /** @@ -298,16 +376,18 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); + LambdaQueryWrapper queryWrapper = + new LambdaQueryWrapper<>(); + if (StrUtil.isNotBlank(LicenseNo)) { - queryWrapper.eq("license_no", LicenseNo); + queryWrapper.eq(LklLedgerReceiver::getLicense_no, LicenseNo); } if (StrUtil.isNotBlank(ContactMobile)) { - queryWrapper.eq("contact_mobile", ContactMobile); + queryWrapper.eq(LklLedgerReceiver::getContact_mobile, ContactMobile); } - queryWrapper.eq("platform_id", platformId) - .eq("status", CommonConstant.Enable); + queryWrapper.eq(LklLedgerReceiver::getPlatform_id, platformId) + .eq(LklLedgerReceiver::getStatus, CommonConstant.Enable); return getOne(queryWrapper); } @@ -319,15 +399,17 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); + LambdaQueryWrapper queryWrapper = + new LambdaQueryWrapper<>(); + if (StrUtil.isNotBlank(LicenseNo)) { - queryWrapper.eq("license_no", LicenseNo); + queryWrapper.eq(LklLedgerReceiver::getLicense_no, LicenseNo); } if (StrUtil.isNotBlank(ContactMobile)) { - queryWrapper.eq("contact_mobile", ContactMobile); + queryWrapper.eq(LklLedgerReceiver::getContact_mobile, ContactMobile); } - queryWrapper.eq("status", CommonConstant.Enable); + queryWrapper.eq(LklLedgerReceiver::getStatus, CommonConstant.Enable); return list(queryWrapper); } @@ -342,19 +424,21 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); + LambdaQueryWrapper queryWrapper = + new LambdaQueryWrapper<>(); + if (StrUtil.isNotBlank(LicenseNo)) { - queryWrapper.eq("license_no", LicenseNo); + queryWrapper.eq(LklLedgerReceiver::getLicense_no, LicenseNo); } if (StrUtil.isNotBlank(ContactMobile)) { - queryWrapper.eq("contact_mobile", ContactMobile); + queryWrapper.eq(LklLedgerReceiver::getContact_mobile, ContactMobile); } if (ObjectUtil.isNotEmpty(platformId) && platformId > 0) { - queryWrapper.eq("platform_id", platformId); + queryWrapper.eq(LklLedgerReceiver::getPlatform_id, platformId); } - queryWrapper.eq("status", CommonConstant.Enable); + queryWrapper.eq(LklLedgerReceiver::getStatus, CommonConstant.Enable); return count(queryWrapper); } @@ -372,11 +456,13 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("level", 0) - .eq("status", CommonConstant.Enable).orderByAsc("id"); + LklLedgerReceiver platformInfo = findOne( + new LambdaQueryWrapper() + .eq(LklLedgerReceiver::getLevel, 0) + .eq(LklLedgerReceiver::getStatus, CommonConstant.Enable) + .orderByAsc(LklLedgerReceiver::getId) + ); - LklLedgerReceiver platformInfo = findOne(queryWrapper); if (platformInfo == null || platformInfo.getId() == null || platformInfo.getId() <= 0) { log.error("[获取平台和代理商信息] 未找到有效的平台方记录, mchId={}", mchId); return Collections.emptyList(); @@ -402,13 +488,15 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl() + .eq(LklLedgerReceiver::getPlatform_id, agent2nd.getParent_id()) + .eq(LklLedgerReceiver::getLevel, CommonConstant.Agent_Level_1st) + .gt(LklLedgerReceiver::getSplit_ratio, 0) + .eq(LklLedgerReceiver::getStatus, CommonConstant.Enable) + .orderByAsc(LklLedgerReceiver::getId) + ); + if (agent1st != null) { list.add(agent1st); log.debug("[获取平台和代理商信息] 成功获取一级代理信息,ID: {}", agent1st.getId()); @@ -451,26 +539,29 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.eq("level", CommonConstant.Agent_Level_2nd) - .eq("status", CommonConstant.Enable) - .orderByAsc("id"); - LklLedgerReceiver result = null; // 优先使用指定的分销商ID查询,否则使用区域信息查询 if (shopMchEntry.getDistributor_id() != null && shopMchEntry.getDistributor_id() > 0) { - queryWrapper.eq("platform_id", shopMchEntry.getDistributor_id()); - result = findOne(queryWrapper); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(LklLedgerReceiver::getLevel, CommonConstant.Agent_Level_2nd) + .eq(LklLedgerReceiver::getStatus, CommonConstant.Enable) + .eq(LklLedgerReceiver::getPlatform_id, shopMchEntry.getDistributor_id()) + .orderByAsc(LklLedgerReceiver::getId); + result = getOne(queryWrapper, false); log.debug("[获取二级代理] 使用指定分销商ID查询,distributorId={}", shopMchEntry.getDistributor_id()); } if (result == null && StrUtil.isNotBlank(shopMchEntry.getStore_district())) { // 运费代理商 - queryWrapper.eq("license_district_id", shopMchEntry.getStore_district()) - .gt("shipping_fee", 0).ne("supplier_id", "") - .orderByAsc("id"); - result = findOne(queryWrapper); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(LklLedgerReceiver::getLevel, CommonConstant.Agent_Level_2nd) + .eq(LklLedgerReceiver::getStatus, CommonConstant.Enable) + .eq(LklLedgerReceiver::getLicense_district_id, shopMchEntry.getStore_district()) + .gt(LklLedgerReceiver::getShipping_fee, 0) + .isNotNull(LklLedgerReceiver::getSupplier_id) + .ne(LklLedgerReceiver::getSupplier_id, "") + .orderByAsc(LklLedgerReceiver::getId); + result = getOne(queryWrapper, false); log.debug("[获取二级代理] 使用区域信息查询,districtId={}", shopMchEntry.getStore_district()); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklTkServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklTkServiceImpl.java index 054024d9..923fdba1 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklTkServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklTkServiceImpl.java @@ -1139,7 +1139,7 @@ public class LklTkServiceImpl { } // 2:新增一个接收方记录,起码要一个平台方,代理商根据入驻商家由哪个代理商邀请而确定是否新增 - Boolean genSuccess = lklLedgerReceiverService.innerApplyLedgerReceiver(mchId, merCupNo); + Boolean genSuccess = lklLedgerReceiverService.innerApplyLedgerReceiver(mchId); if (!genSuccess) { logger.error("进件、申请分账业务成功已成功,等待拉卡拉审核分账业务请求,但创建分账接收方失败了,请管理员补偿流程"); shopMchEntryService.updateMerchEntryApprovalByMchId(mchId, null, diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMchEntryServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMchEntryServiceImpl.java index 5b783a16..1d63ec6f 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMchEntryServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopMchEntryServiceImpl.java @@ -1715,7 +1715,7 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl