From da24e3dfd209f74be2cfa403c12ad96b32a9488f Mon Sep 17 00:00:00 2001 From: Jack <46790855@qq.com> Date: Fri, 27 Jun 2025 01:08:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=BA=97=E9=93=BA?= =?UTF-8?q?=EF=BC=8C=E5=8E=BB=E6=8E=89=E4=BA=8B=E5=8A=A1=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.MD | 8 ++ .../common/service/UniCloudPushService.java | 2 +- .../service/impl/UniCloudPushServiceImpl.java | 47 +++++----- .../quartz/job/UpdateOrderRefundJob.java | 3 - .../service/impl/LakalaApiServiceImpl.java | 23 +++-- .../lakala/service/impl/LklTkServiceImpl.java | 33 +++---- .../admin/ShopStoreBaseController.java | 7 ++ .../store/service/ShopMchEntryService.java | 26 ++++++ .../store/service/ShopStoreBaseService.java | 9 ++ .../service/impl/ShopMchEntryServiceImpl.java | 85 +++++++++++++++++++ .../impl/ShopStoreBaseServiceImpl.java | 28 ++++-- 11 files changed, 211 insertions(+), 60 deletions(-) diff --git a/README.MD b/README.MD index ec991b94..ea6c8d89 100644 --- a/README.MD +++ b/README.MD @@ -72,4 +72,12 @@ find /data/docker/overlay2 -type f \( \ -o -name "*.gz" \ -o -name "*mysql*" \ \) -mtime +7 -delete +``` + +```shell +# 截断所有容器日志 +docker ps -q | while read container_id; do + log_file=$(docker inspect --format='{{.LogPath}}' "$container_id") + [ -f "$log_file" ] && truncate -s 0 "$log_file" +done ``` \ No newline at end of file diff --git a/mall-common/src/main/java/com/suisung/mall/common/service/UniCloudPushService.java b/mall-common/src/main/java/com/suisung/mall/common/service/UniCloudPushService.java index f09505ac..706a0ae3 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/service/UniCloudPushService.java +++ b/mall-common/src/main/java/com/suisung/mall/common/service/UniCloudPushService.java @@ -18,7 +18,7 @@ public interface UniCloudPushService { /** * 向多个客户端ID批量发送推送消息 * - * @param clientIds 目标客户端ID列表 + * @param clientIds 目标客户端 ID 列表 注意:超过500个,直接忽略 * @param title 推送标题 * @param content 推送内容 * @param payload 附加数据(JSON对象) diff --git a/mall-common/src/main/java/com/suisung/mall/common/service/impl/UniCloudPushServiceImpl.java b/mall-common/src/main/java/com/suisung/mall/common/service/impl/UniCloudPushServiceImpl.java index 8a1b49c3..da221c74 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/service/impl/UniCloudPushServiceImpl.java +++ b/mall-common/src/main/java/com/suisung/mall/common/service/impl/UniCloudPushServiceImpl.java @@ -8,6 +8,8 @@ package com.suisung.mall.common.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.service.UniCloudPushService; @@ -29,6 +31,7 @@ import java.util.List; @Slf4j @Service public class UniCloudPushServiceImpl implements UniCloudPushService { + @Lazy @Resource private RestTemplate restTemplate; @@ -37,7 +40,7 @@ public class UniCloudPushServiceImpl implements UniCloudPushService { /** * 向多个客户端ID批量发送推送消息 * - * @param clientIds 目标客户端ID列表 + * @param clientIds 目标客户端 ID 列表 注意:超过500个,直接忽略 * @param title 推送标题 * @param content 推送内容 * @param payload 附加数据(JSON对象) @@ -45,13 +48,23 @@ public class UniCloudPushServiceImpl implements UniCloudPushService { */ @Override public Pair sendBatchPush(String cloudFunctionUrl, List clientIds, String title, String content, JSONObject payload) { - // 参数校验 - validatePushParams(clientIds, title, content); + if (StrUtil.isBlank(cloudFunctionUrl) || clientIds == null || clientIds.isEmpty() || StrUtil.isBlank(content)) { + return Pair.of(false, "缺少必要参数"); + } - // 构建请求体 - JSONObject requestBody = buildPushRequest(clientIds, title, content, payload); + if (clientIds.size() > 500) { + log.warn("批量推送消息时,CIDs 数量超过限制"); + return Pair.of(false, "推送客户端超出500限额"); + } + + if (StrUtil.isBlank(title)) { + title = "小发同城:您有新的消息"; + } try { + // 构建请求体 + JSONObject requestBody = buildPushRequest(clientIds, title, content, payload); + // 执行HTTP请求 ResponseEntity response = executeHttpRequest(cloudFunctionUrl, requestBody); @@ -68,23 +81,6 @@ public class UniCloudPushServiceImpl implements UniCloudPushService { } } - /** - * 验证推送参数有效性 - */ - private void validatePushParams(List clientIds, String title, String content) { - if (clientIds == null || clientIds.isEmpty()) { - throw new IllegalArgumentException("客户端ID列表不能为空"); - } - - if (title == null || title.trim().isEmpty()) { - throw new IllegalArgumentException("推送标题不能为空"); - } - - if (content == null || content.trim().isEmpty()) { - throw new IllegalArgumentException("推送内容不能为空"); - } - } - /** * 构建推送请求体 */ @@ -103,6 +99,13 @@ public class UniCloudPushServiceImpl implements UniCloudPushService { requestBody.put("message", message); + JSONArray platform = new JSONArray(); + platform.add("web"); + platform.add("app-ios"); + platform.add("app-android"); + platform.add("mp-weixin"); + requestBody.put("platform", platform); + //消息有效期设置,单位毫秒,-1表示不设离线。默认是 2 小时,取值范围:-1 ~ 3 * 24 * 3600 * 1000(3天)之间 requestBody.put("settings", new JSONObject().set("ttl", 3 * 24 * 3600 * 1000)); diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/components/quartz/job/UpdateOrderRefundJob.java b/mall-shop/src/main/java/com/suisung/mall/shop/components/quartz/job/UpdateOrderRefundJob.java index fef995b5..e3e9bf24 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/components/quartz/job/UpdateOrderRefundJob.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/components/quartz/job/UpdateOrderRefundJob.java @@ -5,8 +5,6 @@ import com.suisung.mall.shop.config.SpringUtil; import com.suisung.mall.shop.order.service.ShopOrderReturnService; import org.quartz.JobExecutionContext; import org.quartz.JobExecutionException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.core.env.Environment; import org.springframework.scheduling.quartz.QuartzJobBean; @@ -27,7 +25,6 @@ public class UpdateOrderRefundJob extends QuartzJobBean { return; } - Logger logger = LoggerFactory.getLogger(UpdateOrderRefundJob.class); ShopOrderReturnService orderReturnService = SpringUtil.getBean(ShopOrderReturnService.class); // 获取支付宝/微信退款订单 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 bf9e267f..8a1f10f2 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 @@ -588,6 +588,9 @@ public class LakalaApiServiceImpl implements LakalaApiService { return Pair.of(true, I18nUtil._("商家已经申请过了!")); } + // 检查更新店铺初始化状态 + shopMchEntryService.checkMchEntryStoreStatus(shopMchEntry.getId(), shopMchEntry); + // 1. 配置初始化 initLKLSDK(); @@ -732,12 +735,20 @@ public class LakalaApiServiceImpl implements LakalaApiService { return respData; } - if ("COMPLETED".equals(lklLedgerEc.getEc_status())) { - respData.put("code", "SUCCESS"); - respData.put("message", "操作成功!"); - log.info("商户入网电子合同申请回调:已处理成功,不需再重新处理"); - return respData; - } +// if ("COMPLETED".equals(lklLedgerEc.getEc_status())) { +// ShopMchEntry shopMchEntry = shopMchEntryService.shopMerchEntryById(lklLedgerEc.getMch_id()); +// if (shopMchEntry != null +// ) { +// log.error("入网电子合同申请回调:找不到对应商户信息"); +// respData.put("message", "找不到对应商户信息!"); +// return respData; +// } +// +// respData.put("code", "SUCCESS"); +// respData.put("message", "操作成功!"); +// log.info("商户入网电子合同申请回调:已处理成功,不需再重新处理"); +// return respData; +// } // 把 base64 合同文件,上传到 cos 服务器,返回 url 地址 Pair ecFilePair = ledgerMerEcDownload(ecApplyId); 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 54b9033a..df6e7db2 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 @@ -641,27 +641,20 @@ public class LklTkServiceImpl { if (shopEntry != null && !CommonConstant.Enable.equals(shopEntry.getStore_status())) { String mchMobile = shopEntry.getLogin_mobile(); - try { - // 包含了更改 merchEntryInfo 的状态 - Pair retPair = shopStoreBaseService.merchEntryInfo2StoreInfo(mchMobile, true); - - if (retPair.getFirst() <= 0) { - logger.error("初始化店铺失败: mchMobile={}, reason={}", mchMobile, retPair.getSecond()); - } - - logger.info("商家进件:初始化店铺成功!mchMobile={}", mchMobile); - -// boolean updateSuccess = shopMchEntryService.updateMulStatus(mchMobile, "", 0, 0, 1, 0, 0, 0, CommonConstant.MCH_APPR_STA_LKL_PADDING); -// if (!updateSuccess) { -// logger.warn("更新店铺状态失败: mchMobile={}", mchMobile); -// } else { -// logger.info("商家进件:初始化店铺成功!mchMobile={}", mchMobile); -// } - - } catch (Exception e) { - // 捕获所有异常,防止事务中断 - logger.error("初始化店铺时发生异常", e); + // 包含了更改 merchEntryInfo 的状态 + Pair retPair = shopStoreBaseService.covMerchEntryInfo2StoreInfo(mchMobile, false); + if (retPair.getFirst() <= 0) { + logger.error("初始化店铺失败: mchMobile={}, reason={}", mchMobile, retPair.getSecond()); } + + logger.info("初始化店铺成功!mchMobile={}", mchMobile); + +// boolean updateSuccess = shopMchEntryService.updateMulStatus(mchMobile, "", 0, 0, 1, 0, 0, 0, CommonConstant.MCH_APPR_STA_LKL_PADDING); +// if (!updateSuccess) { +// logger.warn("更新店铺状态失败: mchMobile={}", mchMobile); +// } else { +// logger.info("商家进件:初始化店铺成功!mchMobile={}", mchMobile); +// } } // 1、(电子合同)给商家申请分账功能使用;务必检查是否申请过?申请过忽略 diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopStoreBaseController.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopStoreBaseController.java index 9f88d25a..ce363ded 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopStoreBaseController.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/controller/admin/ShopStoreBaseController.java @@ -13,11 +13,13 @@ import com.suisung.mall.common.modules.store.ShopStoreCompany; import com.suisung.mall.common.service.impl.BaseControllerImpl; import com.suisung.mall.common.utils.CheckUtil; import com.suisung.mall.shop.base.service.ShopBaseStoreGradeService; +import com.suisung.mall.shop.store.service.ShopMchEntryService; import com.suisung.mall.shop.store.service.ShopStoreBaseService; import com.suisung.mall.shop.store.service.ShopStoreSameCityTransportBaseService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Lazy; import org.springframework.data.util.Pair; import org.springframework.web.bind.annotation.*; @@ -50,6 +52,10 @@ public class ShopStoreBaseController extends BaseControllerImpl { @Autowired private ShopStoreSameCityTransportBaseService transportBaseService; + @Lazy + @Autowired + private ShopMchEntryService shopMchEntryService; + @ApiOperation(value = "店铺基础信息表-分页列表查询", notes = "店铺基础信息表-分页列表查询") @RequestMapping(value = "/list", method = RequestMethod.GET) public CommonResult list(ShopStoreBase shopStoreBase, @@ -271,6 +277,7 @@ public class ShopStoreBaseController extends BaseControllerImpl { if (result.getFirst().equals(0)) { return CommonResult.failed(result.getSecond()); } + return CommonResult.success(); } } diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMchEntryService.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMchEntryService.java index dba2562c..dad88ef0 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMchEntryService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopMchEntryService.java @@ -98,6 +98,15 @@ public interface ShopMchEntryService { */ ShopMchEntry shopMerchEntryApprovalInfo(String loginMobile); + /** + * 根据商户 ID 获取商户入驻信息 + * + * @param mchId + * @return + */ + ShopMchEntry shopMerchEntryById(Long mchId); + + /** * 根据商家手机号、营业执照、审批状态获取有效的商家入驻申请记录 * @@ -240,6 +249,15 @@ public interface ShopMchEntryService { Boolean updateMulStatus(String merchantMobile, String merchantCupNo, Integer hasEcSigned, Integer hasApplyMerchant, Integer storeStatus, Integer hasApplySplit, Integer hasApplyReceiver, Integer hasBindReceiver, Integer approvalStatus); + /** + * 检查更新商户入驻店铺初始化状态 + * + * @param shopMchEntryId + * @param shopMchEntry + * @return + */ + Boolean checkMchEntryStoreStatus(Long shopMchEntryId, ShopMchEntry shopMchEntry); + /** * 更新商家入网电子合同结果通知地址 * @@ -257,4 +275,12 @@ public interface ShopMchEntryService { * @return */ Boolean checkMerchEntryFinished(String merchantMobile, String merchantCupNo); + + /** + * 检查更新商户入驻店铺初始化状态 + * + * @param storeId + * @return + */ + Boolean checkMchEntryStoreStatus(Integer storeId); } \ No newline at end of file diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreBaseService.java b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreBaseService.java index 8571b06a..bd5f142d 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreBaseService.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/store/service/ShopStoreBaseService.java @@ -155,6 +155,15 @@ public interface ShopStoreBaseService extends IBaseService { */ Pair merchEntryInfo2StoreInfo(String mchMobile, Boolean allowThrown); + /** + * (重要)入驻审批通过并且合同盖章完结之后,把商家入驻信息转换成店铺信息,正式生成店铺所需的数据 + * + * @param mchMobile + * @param allowThrown 是否允许抛出异常? + * @return + */ + Pair covMerchEntryInfo2StoreInfo(String mchMobile, Boolean allowThrown); + /** * 根据店铺名称判断店铺是否存在 * 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 56fc12a2..bb634be0 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 @@ -798,6 +798,17 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("store_status", CommonConstant.Enable); + updateWrapper.eq("id", shopMchEntryId); + return update(updateWrapper); + } + + return false; + + } catch (Exception e) { + // 7. 异常处理:记录异常信息,避免程序中断 + log.error("更新商户店铺初始化状态失败", e); + return false; // 发生异常时返回 false + } + } + + /** + * 检查更新商户入驻店铺初始化状态 + * + * @param storeId + * @return + */ + @Override + public Boolean checkMchEntryStoreStatus(Integer storeId) { + try { + // 1. 参数校验:商户号和商家手机号不能同时为空 + if (storeId == null || storeId <= 0) { + log.warn("缺少必要参数"); + return false; + } + + ShopMchEntry shopMchEntry = getOne(new QueryWrapper().eq("store_id", storeId)); + + if (shopMchEntry == null) { + return false; + } + + if (!CommonConstant.Enable.equals(shopMchEntry.getStore_status())) { + UpdateWrapper updateWrapper = new UpdateWrapper<>(); + updateWrapper.set("store_status", CommonConstant.Enable); + updateWrapper.eq("id", shopMchEntry.getId()); + return update(updateWrapper); + } + + return false; + + } catch (Exception e) { + // 7. 异常处理:记录异常信息,避免程序中断 + log.error("更新商户店铺初始化状态失败", 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 b5f5858c..6a9a1f34 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 @@ -70,7 +70,6 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.data.util.Pair; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.ServletRequestAttributes; @@ -3009,9 +3008,21 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl merchEntryInfo2StoreInfo(String mchMobile, Boolean allowThrown) { + return covMerchEntryInfo2StoreInfo(mchMobile, allowThrown); + } + + /** + * 重要)入驻审批通过并且合同盖章完结之后,把商家入驻信息转换成店铺信息,正式生成店铺所需的数据 + * + * @param mchMobile + * @param allowThrown 是否允许抛出异常? + * @return + */ + @Override + public Pair covMerchEntryInfo2StoreInfo(String mchMobile, Boolean allowThrown) { if (StrUtil.isBlank(mchMobile)) { logger.error("生成店铺:商家手机号不能为空"); return Pair.of(0, "商家手机不能为空"); @@ -3030,10 +3041,10 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl