初始化店铺,去掉事务。

This commit is contained in:
Jack 2025-06-27 01:08:47 +08:00
parent d8bca69767
commit da24e3dfd2
11 changed files with 211 additions and 60 deletions

View File

@ -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
```

View File

@ -18,7 +18,7 @@ public interface UniCloudPushService {
/**
* 向多个客户端ID批量发送推送消息
*
* @param clientIds 目标客户端ID列表
* @param clientIds 目标客户端 ID 列表 注意超过500个直接忽略
* @param title 推送标题
* @param content 推送内容
* @param payload 附加数据(JSON对象)

View File

@ -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<Boolean, String> sendBatchPush(String cloudFunctionUrl, List<String> 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<String> response = executeHttpRequest(cloudFunctionUrl, requestBody);
@ -68,23 +81,6 @@ public class UniCloudPushServiceImpl implements UniCloudPushService {
}
}
/**
* 验证推送参数有效性
*/
private void validatePushParams(List<String> 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));

View File

@ -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);
// 获取支付宝/微信退款订单

View File

@ -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<String, String> ecFilePair = ledgerMerEcDownload(ecApplyId);

View File

@ -641,27 +641,20 @@ public class LklTkServiceImpl {
if (shopEntry != null && !CommonConstant.Enable.equals(shopEntry.getStore_status())) {
String mchMobile = shopEntry.getLogin_mobile();
try {
// 包含了更改 merchEntryInfo 的状态
Pair<Integer, String> 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<Integer, String> 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电子合同给商家申请分账功能使用务必检查是否申请过申请过忽略

View File

@ -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();
}
}

View File

@ -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);
}

View File

@ -155,6 +155,15 @@ public interface ShopStoreBaseService extends IBaseService<ShopStoreBase> {
*/
Pair<Integer, String> merchEntryInfo2StoreInfo(String mchMobile, Boolean allowThrown);
/**
* (重要入驻审批通过并且合同盖章完结之后把商家入驻信息转换成店铺信息正式生成店铺所需的数据
*
* @param mchMobile
* @param allowThrown 是否允许抛出异常
* @return
*/
Pair<Integer, String> covMerchEntryInfo2StoreInfo(String mchMobile, Boolean allowThrown);
/**
* 根据店铺名称判断店铺是否存在
*

View File

@ -798,6 +798,17 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
return record;
}
/**
* 根据商户 ID 获取商户入驻信息
*
* @param mchId
* @return
*/
@Override
public ShopMchEntry shopMerchEntryById(Long mchId) {
return get(mchId);
}
/**
* 根据商家手机号营业执照审批状态获取有效的商家入驻申请记录
*
@ -1394,4 +1405,78 @@ public class ShopMchEntryServiceImpl extends BaseServiceImpl<ShopMchEntryMapper,
return false; // 发生异常时返回 false
}
}
/**
* 检查更新商户入驻店铺初始化状态
*
* @param shopMchEntryId
* @param shopMchEntry
* @return
*/
@Override
public Boolean checkMchEntryStoreStatus(Long shopMchEntryId, ShopMchEntry shopMchEntry) {
try {
// 1. 参数校验商户号和商家手机号不能同时为空
if (shopMchEntryId == null || shopMchEntryId <= 0) {
log.error("缺少必要参数");
return false;
}
if (shopMchEntry == null) {
shopMchEntry = getById(shopMchEntryId);
}
if (shopMchEntry != null && StrUtil.isNotBlank(shopMchEntry.getStore_id()) && !CommonConstant.Enable.equals(shopMchEntry.getStore_status())) {
UpdateWrapper<ShopMchEntry> 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<ShopMchEntry>().eq("store_id", storeId));
if (shopMchEntry == null) {
return false;
}
if (!CommonConstant.Enable.equals(shopMchEntry.getStore_status())) {
UpdateWrapper<ShopMchEntry> 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
}
}
}

View File

@ -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<ShopStoreBaseMappe
* @param allowThrown 是否允许抛出异常
* @return 店铺Id
*/
@Transactional(propagation = Propagation.REQUIRES_NEW)
@Transactional
@Override
public Pair<Integer, String> merchEntryInfo2StoreInfo(String mchMobile, Boolean allowThrown) {
return covMerchEntryInfo2StoreInfo(mchMobile, allowThrown);
}
/**
* 重要入驻审批通过并且合同盖章完结之后把商家入驻信息转换成店铺信息正式生成店铺所需的数据
*
* @param mchMobile
* @param allowThrown 是否允许抛出异常
* @return
*/
@Override
public Pair<Integer, String> covMerchEntryInfo2StoreInfo(String mchMobile, Boolean allowThrown) {
if (StrUtil.isBlank(mchMobile)) {
logger.error("生成店铺:商家手机号不能为空");
return Pair.of(0, "商家手机不能为空");
@ -3030,10 +3041,10 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
return Pair.of(0, "入驻信息不能为空");
}
// if (isExistsByStoreName(shopMchEntry.getStore_name())) {
// logger.error("生成店铺:店铺名称已存在");
// return Pair.of(0, "店铺名称已存在");
// }
if (isExistsByStoreName(shopMchEntry.getStore_name())) {
logger.error("生成店铺:店铺名称已存在");
return Pair.of(0, "店铺名称已存在,请使用另一个名称");
}
// 校验店铺状态
if (CommonConstant.Enable.equals(shopMchEntry.getStore_status())) {
@ -3107,13 +3118,14 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
shopStoreInfo.setStore_tel(shopMchEntry.getLogin_mobile());
shopStoreInfo.setStore_banner(storeFacadeImage);
String websiteXFTC = "https://www.gpsxcs.cn";
JSONArray list = new JSONArray();
if (StrUtil.isNotBlank(storeFacadeImage)) {
JSONObject slide = new JSONObject();
slide.put("img", storeFacadeImage);
slide.put("name", "店铺门面照片");
slide.put("check", true);
slide.put("url", "https://www.gpsxcs.cn");
slide.put("url", websiteXFTC);
list.put(slide);
}
if (StrUtil.isNotBlank(shopMchEntry.getEnvironment_image())) {
@ -3121,7 +3133,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
slide.put("img", shopMchEntry.getEnvironment_image());
slide.put("name", "店铺环境照片");
slide.put("check", true);
slide.put("url", "https://www.gpsxcs.cn");
slide.put("url", websiteXFTC);
list.put(slide);
}
shopStoreInfo.setStore_slide(list.toString());