From a030b8cd4ce7a6750e825367a8fa547547bcd87d Mon Sep 17 00:00:00 2001 From: Jack <46790855@qq.com> Date: Sun, 22 Jun 2025 00:58:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=95=86=E5=AE=B6=E5=85=A5=E9=A9=BB=EF=BC=8C?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E4=BC=98=E5=8C=96=EF=BC=8C=20fix=20bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/modules/store/ShopMchEntry.java | 26 +-- .../impl/EsignContractServiceImpl.java | 2 +- .../service/impl/LakalaApiServiceImpl.java | 7 +- .../impl/LklLedgerReceiverServiceImpl.java | 2 +- .../lakala/service/impl/LklTkServiceImpl.java | 5 +- .../order/listener/OrderPayedListener.java | 3 - .../impl/ShopOrderBaseServiceImpl.java | 2 +- .../store/service/ShopMchEntryService.java | 41 +++-- .../service/impl/ShopMchEntryServiceImpl.java | 166 ++++++++++++++---- .../impl/ShopStoreBaseServiceImpl.java | 31 ++-- 10 files changed, 201 insertions(+), 84 deletions(-) diff --git a/mall-common/src/main/java/com/suisung/mall/common/modules/store/ShopMchEntry.java b/mall-common/src/main/java/com/suisung/mall/common/modules/store/ShopMchEntry.java index b7e38ce4..888b47dd 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/modules/store/ShopMchEntry.java +++ b/mall-common/src/main/java/com/suisung/mall/common/modules/store/ShopMchEntry.java @@ -33,13 +33,13 @@ public class ShopMchEntry implements Serializable { @TableId(value = "id", type = IdType.INPUT) private Long id; - @ApiModelProperty(value = "入驻商家的登录手机号") + @ApiModelProperty(value = "入驻商家的登录手机号", required = true) private String login_mobile; @ApiModelProperty(value = "商家店铺的ID") private String store_id; - @ApiModelProperty(value = "商家店铺的名称") + @ApiModelProperty(value = "商家店铺的名称", required = true) private String store_name; @ApiModelProperty(value = "商家店铺LOGO图片") @@ -51,7 +51,7 @@ public class ShopMchEntry implements Serializable { @ApiModelProperty(value = "入驻商家的联系人姓名") private String contact_name; - @ApiModelProperty(value = "商家一级主营类目,用数字表示不同类目") + @ApiModelProperty(value = "商家一级主营类目,用数字表示不同类目", required = true) private Integer biz_category; @ApiModelProperty(value = "商家二级主营类目,用数字表示不同类目") @@ -87,16 +87,16 @@ public class ShopMchEntry implements Serializable { @ApiModelProperty(value = "店铺地区名称,省份/城市/区") private String store_area; - @ApiModelProperty(value = "入驻商家店铺的详细地址") + @ApiModelProperty(value = "入驻商家店铺的详细地址", required = true) private String store_address; - @ApiModelProperty(value = "入驻商家店铺门面正面图片的存储路径") + @ApiModelProperty(value = "入驻商家店铺门面正面图片的存储路径", required = true) private String front_facade_image; - @ApiModelProperty(value = "入驻商家店铺门面环境图片的存储路径") + @ApiModelProperty(value = "入驻商家店铺门面环境图片的存储路径", required = true) private String environment_image; - @ApiModelProperty(value = "入驻主体类型,企业或个人:1-企业;2-个人;") + @ApiModelProperty(value = "入驻主体类型,企业或个人:1-企业;2-个人;", required = true) private Integer entity_type; @ApiModelProperty(value = "企业入驻时的营业执照编号") @@ -165,7 +165,7 @@ public class ShopMchEntry implements Serializable { @ApiModelProperty(value = "个人身份证有效期结束时间") private String individual_id_period_end; - @ApiModelProperty(value = "入驻商家的开户银行名称") + @ApiModelProperty(value = "入驻商家的开户银行名称", required = true) private String bank_name; @ApiModelProperty(value = "结算账户银行卡图片") @@ -174,22 +174,22 @@ public class ShopMchEntry implements Serializable { @ApiModelProperty(value = "结算账号省市区编号 省code/市code/区code,必填项") private String bank_district; - @ApiModelProperty(value = "结算银行地区名称,格式: 省份/城市/区") + @ApiModelProperty(value = "结算银行地区名称,格式: 省份/城市/区", required = true) private String bank_area; - @ApiModelProperty(value = "结算账号类型:57-对公 58-对私") + @ApiModelProperty(value = "结算账号类型:57-对公 58-对私", required = true) private String account_type; - @ApiModelProperty(value = "结算账户⾏号") + @ApiModelProperty(value = "结算账户⾏号", required = true) private String openning_bank_code; @ApiModelProperty(value = "结算账户清算⾏号") private String clearing_bank_code; - @ApiModelProperty(value = "入驻商家的收款账户号码") + @ApiModelProperty(value = "入驻商家的收款账户号码", required = true) private String account_number; - @ApiModelProperty(value = "入驻商家的收款账户姓名") + @ApiModelProperty(value = "入驻商家的收款账户姓名", required = true) private String account_holder_name; @ApiModelProperty(value = "入驻商家的审批状态:1-已通过;2-未通过;3-待审核;4-未申请过;5-已提交审核;") diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractServiceImpl.java index dd191c06..74baa84e 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/esign/service/impl/EsignContractServiceImpl.java @@ -316,7 +316,7 @@ public class EsignContractServiceImpl extends BaseServiceImpl(new JSONObject().put("code", 200).put("msg", "success").toString(), HttpStatus.OK); } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LakalaApiServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LakalaApiServiceImpl.java index c1b31324..eff4e2a6 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LakalaApiServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LakalaApiServiceImpl.java @@ -1019,7 +1019,7 @@ public class LakalaApiServiceImpl implements LakalaApiService { } // 更新商家分账申请状态为已申请(hasApplySplit=1) - shopMchEntryService.updateMulStatus("", merCupNo, 0, 1, 0, 0, 0); + shopMchEntryService.updateMulStatus("", merCupNo, 0, 0, 0, 1, 0, 0, CommonConstant.MCH_APPR_STA_LKL_PADDING); log.debug("商户分账业务申请回调:处理成功,applyId={}", applyId); return JSONUtil.createObj().put("code", "SUCCESS").put("message", "操作成功!"); @@ -1160,7 +1160,7 @@ public class LakalaApiServiceImpl implements LakalaApiService { } // 更新商户分账状态 - shopMchEntryService.updateMulStatus(mchMobile, "", 0, 0, 1, 0, 0); + shopMchEntryService.updateMulStatus(mchMobile, "", 0, 0, 0, 0, 1, 0, CommonConstant.MCH_APPR_STA_LKL_PADDING); return CommonResult.success(receiver, "创建接收方成功!"); } catch (Exception e) { @@ -1385,8 +1385,9 @@ public class LakalaApiServiceImpl implements LakalaApiService { } // 7. 成功后更新商户绑定状态为已绑定 - shopMchEntryService.updateMulStatus("", merCupNo, 0, 0, 0, 1, 0); + shopMchEntryService.updateMulStatus("", merCupNo, 0, 0, 0, 0, 0, 1, CommonConstant.MCH_APPR_STA_PASS); + shopMchEntryService.checkMerchEntryFinished("", merCupNo); // 8. 日志记录并返回成功响应 log.debug("商家绑定分账接收方异步通知处理完成,merCupNo:{}", merCupNo); return JSONUtil.createObj().put("code", "SUCCESS").put("message", "操作成功"); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklLedgerReceiverServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklLedgerReceiverServiceImpl.java index 89e04a32..cf46f1b3 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklLedgerReceiverServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/lakala/service/impl/LklLedgerReceiverServiceImpl.java @@ -243,7 +243,7 @@ public class LklLedgerReceiverServiceImpl extends BaseServiceImpl 0; if (success) { // 更新多个状态 - shopMchEntryService.updateMulStatus("", merCupNo, 0, 0, 1, 0, 0); + shopMchEntryService.updateMulStatus("", merCupNo, 0, 0, 0, 0, 1, 0, CommonConstant.MCH_APPR_STA_LKL_PADDING); } return success; 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 2bb682fa..1b0f6d13 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 @@ -536,7 +536,7 @@ public class LklTkServiceImpl { logger.error("拉卡拉进件异常:{}", e.getMessage()); shopMchEntryService.updateMerchEntryApprovalByMchId(shopMchEntry.getId(), "", CommonConstant.MCH_APPR_STA_LKL_NOPASS, "进件失败:" + e.getMessage()); return Pair.of(false, "进件失败:" + e.getMessage()); - + } return Pair.of(true, "提交进件成功,请等待审核!"); @@ -644,7 +644,8 @@ public class LklTkServiceImpl { Pair retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(mchMobile, false); if (retPair.getFirst() > 0) { - boolean updateSuccess = shopMchEntryService.updateMerchEntryStoreStatus(mchMobile, CommonConstant.Enable); + boolean updateSuccess = shopMchEntryService.updateMulStatus(mchMobile, "", 0, 0, 1, 0, 0, 1, CommonConstant.MCH_APPR_STA_LKL_PADDING); +// boolean updateSuccess = shopMchEntryService.updateMerchEntryStoreStatus(mchMobile, CommonConstant.Enable); if (!updateSuccess) { logger.warn("更新店铺状态失败: mchMobile={}", mchMobile); } else { diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/order/listener/OrderPayedListener.java b/mall-shop/src/main/java/com/suisung/mall/shop/order/listener/OrderPayedListener.java index 7ff49f0a..0181bfd8 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/order/listener/OrderPayedListener.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/order/listener/OrderPayedListener.java @@ -18,7 +18,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.util.Pair; import org.springframework.stereotype.Service; -import javax.annotation.Resource; import java.io.IOException; import java.util.Collections; import java.util.List; @@ -40,7 +39,6 @@ public class OrderPayedListener { // private ShopStorePrinterService shopStorePrinterService; // @Autowired // private MqMessageService mqMessageService; - @Resource @Autowired private SFExpressApiService sfExpressApiService; @@ -114,7 +112,6 @@ public class OrderPayedListener { logger.info("顺丰同城下单成功"); - // 个推推送消息 sfExpressApiService.pushMessageToStoreEmployee(null, orderId, "你有一笔同城订单[" + orderId + "],请及时处理。", ""); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderBaseServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderBaseServiceImpl.java index 070f09d3..90497474 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderBaseServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/order/service/impl/ShopOrderBaseServiceImpl.java @@ -2678,7 +2678,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("status", CommonConstant.Enable).orderByAsc("id"); + + // 3. 使用 OR 连接手机号和商户号的查询条件,只要满足一个条件即可 + queryWrapper.and(qw -> qw.eq(StrUtil.isNotBlank(loginMobile), "login_mobile", loginMobile) + .or().eq(StrUtil.isNotBlank(merchantCupNo), "lkl_mer_cup_no", merchantCupNo)); + + // 4. 执行查询 + List recordList = list(queryWrapper); + + // 5. 处理查询结果 + return CollectionUtil.isNotEmpty(recordList) ? recordList.get(0) : null; + } + /** * 根据商家注册的手机号,更新合同签署状态和合同下载地址 * @@ -1184,56 +1213,121 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl updateWrapper = new UpdateWrapper<>(); - // 设置查询条件 - Optional.ofNullable(mchMobile) - .filter(StrUtil::isNotBlank) - .ifPresent(mobile -> updateWrapper.eq("login_mobile", mobile)); - Optional.ofNullable(merCupNo) - .filter(StrUtil::isNotBlank) - .ifPresent(cupNo -> updateWrapper.eq("lkl_mer_cup_no", cupNo)); + try { + // 2. 根据手机号或商户号获取商户入驻信息 + ShopMchEntry merchantEntry = getShopMerchEntryByMobileOrMerCupNo(merchantMobile, merchantCupNo); + if (merchantEntry == null) { + log.error("检查商户入驻流程完成状态失败:商户不存在, merchantMobile={}, merchantCupNo={}", merchantMobile, merchantCupNo); + return false; + } - // 流式构建更新字段 - Map fieldMap = new LinkedHashMap<>(); - fieldMap.put("has_ec_signed", hasEcSigned); - fieldMap.put("has_apply_split", hasApplySplit); - fieldMap.put("has_apply_receiver", hasApplyReceiver); - fieldMap.put("has_bind_receiver", hasBindReceiver); - fieldMap.put("has_apply_mer", hasApplyMer); + // 3. 检查各项状态是否已完成 + boolean isFinished = CommonConstant.Enable.equals(merchantEntry.getHas_ec_signed()) + && CommonConstant.Enable.equals(merchantEntry.getHas_apply_mer()) + && CommonConstant.Enable.equals(merchantEntry.getStore_status()) + && CommonConstant.Enable.equals(merchantEntry.getHas_apply_split()) + && CommonConstant.Enable.equals(merchantEntry.getHas_apply_receiver()) + && CommonConstant.Enable.equals(merchantEntry.getHas_bind_receiver()); - // 过滤有效字段并设置 - fieldMap.entrySet().stream() - .filter(entry -> entry.getValue() != null && entry.getValue() > 0) - .forEach(entry -> updateWrapper.set(entry.getKey(), entry.getValue())); + // 4. 如果所有状态都已完成,则更新商户入驻信息,简化if嵌套 + if (!isFinished) { + return false; // 返回 false,表示入驻流程未全部完成 + } + ShopMchEntry merchantEntryUpd = new ShopMchEntry(); + merchantEntryUpd.setId(merchantEntry.getId()); + merchantEntryUpd.setApproval_status(CommonConstant.MCH_APPR_STA_PASS); // 设置审批状态为已通过 + merchantEntryUpd.setApproval_remark("入驻流程已全部完成!"); // 设置审批备注 + boolean updateResult = updateById(merchantEntry); // 更新商户入驻信息 + if (!updateResult) { + log.error("更新商户入驻信息状态失败, merchantId={}", merchantEntry.getId()); + } + return true; // 返回 true,表示入驻流程已全部完成 + + } catch (Exception e) { + // 5. 捕获异常并记录错误日志 + log.error("检查商户入驻流程完成状态时发生异常, merchantMobile={}, merchantCupNo={}", merchantMobile, merchantCupNo, e); + return false; // 发生异常时返回 false + } + } + + + /** + * 根据商户号或商家手机号修改商户入驻信息多个状态 + * + * @param merchantMobile 商家手机号 + * @param merchantCupNo 商户号 + * @param hasEcSigned 是否已签署电子合同 + * @param hasApplyMerchant 是否已申请商户进件 + * @param storeStatus 店铺状态 + * @param hasApplySplit 是否已申请分账 + * @param hasApplyReceiver 是否已申请收款方 + * @param hasBindReceiver 是否已绑定收款方 + * @param approvalStatus 审批状态 + * @return 更新结果,true为成功,false为失败 + */ + @Override + public Boolean updateMulStatus(String merchantMobile, String merchantCupNo, Integer hasEcSigned, Integer hasApplyMerchant, Integer storeStatus, + Integer hasApplySplit, Integer hasApplyReceiver, Integer hasBindReceiver, Integer approvalStatus) { + // 1. 参数校验:商户号和商家手机号不能同时为空 + if (StrUtil.isAllBlank(merchantCupNo, merchantMobile)) { + log.error("更新商户多个状态失败:商户号和商家手机号不能同时为空"); + return false; + } try { + // 2. 构建 UpdateWrapper 对象,用于构建更新条件 + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + + // 3. 设置查询条件:优先使用商户手机号,如果为空则使用商户号 + Optional.ofNullable(merchantMobile) + .filter(StrUtil::isNotBlank) + .ifPresent(mobile -> updateWrapper.eq("login_mobile", mobile)); + + Optional.ofNullable(merchantCupNo) + .filter(StrUtil::isNotBlank) + .ifPresent(cupNo -> updateWrapper.eq("lkl_mer_cup_no", cupNo)); + + // 4. 构建需要更新的字段和值的映射关系 + Map updateFieldMap = new LinkedHashMap<>(); + updateFieldMap.put("approval_status", approvalStatus); // 审批状态 + updateFieldMap.put("has_ec_signed", hasEcSigned); // 是否已签署电子合同 + updateFieldMap.put("has_apply_mer", hasApplyMerchant); // 是否已申请商户进件 + updateFieldMap.put("store_status", storeStatus); // 店铺状态 + updateFieldMap.put("has_apply_split", hasApplySplit); // 是否已申请分账 + updateFieldMap.put("has_apply_receiver", hasApplyReceiver); // 是否已申请收款方 + updateFieldMap.put("has_bind_receiver", hasBindReceiver); // 是否已绑定收款方 + + + // 5. 过滤掉值为 null 或小于等于 0 的字段,避免更新无效字段 + updateFieldMap.entrySet().stream() + .filter(entry -> entry.getValue() != null && entry.getValue() > 0) + .forEach(entry -> updateWrapper.set(entry.getKey(), entry.getValue())); + + // 6. 执行更新操作并返回结果 return update(updateWrapper); + } catch (Exception e) { - log.error("更新商家分账业务多个状态失败", e); - return false; + // 7. 异常处理:记录异常信息,避免程序中断 + log.error("更新商户入驻信息多个状态失败", e); + // 可以选择抛出异常,让 Spring 事务管理器进行回滚 + // throw new RuntimeException("更新商户多个状态失败", e); + return false; // 发生异常时返回 false } } } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java index 43f12cb0..112bf4a3 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/impl/ShopStoreBaseServiceImpl.java @@ -3185,21 +3185,24 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("store_id", storeId).eq("user_id", userId); + if (shopStoreEmployeeService.count(queryWrapper) <= 0) { + // shop_store_employee 店铺员工,添加管理员 + ShopStoreEmployee shopStoreEmployee = new ShopStoreEmployee(); + shopStoreEmployee.setStore_id(storeId); + shopStoreEmployee.setUser_id(userId); + shopStoreEmployee.setRights_group_id(""); // 店铺管理员,店铺 + shopStoreEmployee.setEmployee_is_admin(CommonConstant.Enable); + shopStoreEmployee.setEmployee_is_kefu(CommonConstant.Enable); + if (!shopStoreEmployeeService.save(shopStoreEmployee)) { + logger.error("生成店铺:新增店铺员工失败"); + if (allowThrown) { + throw new ApiException(I18nUtil._("新增店铺员工失败")); + } + return Pair.of(0, "新增店铺员工失败"); + } } // 生成店铺的太阳码 2025-03-31