循环依赖问题,太难搞了,fix bug

This commit is contained in:
Jack 2025-07-26 01:42:09 +08:00
parent 38f0feb5b5
commit 3ea6cf91a2
27 changed files with 238 additions and 147 deletions

View File

@ -9,6 +9,7 @@ import com.suisung.mall.shop.activity.service.ShopActivityCutpriceService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@ -27,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/admin/shop/shop-activity-cutprice") @RequestMapping("/admin/shop/shop-activity-cutprice")
public class ShopActivityCutpriceController extends BaseControllerImpl { public class ShopActivityCutpriceController extends BaseControllerImpl {
@Lazy
@Autowired @Autowired
private ShopActivityCutpriceService shopActivityCutpriceService; private ShopActivityCutpriceService shopActivityCutpriceService;

View File

@ -8,6 +8,7 @@ import com.suisung.mall.shop.activity.service.ShopActivityCutpriceHistoryService
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@ -27,6 +28,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/admin/shop/shop-activity-cutprice-history") @RequestMapping("/admin/shop/shop-activity-cutprice-history")
public class ShopActivityCutpriceHistoryController { public class ShopActivityCutpriceHistoryController {
@Lazy
@Autowired @Autowired
private ShopActivityCutpriceHistoryService shopActivityCutpriceHistoryService; private ShopActivityCutpriceHistoryService shopActivityCutpriceHistoryService;

View File

@ -6,6 +6,7 @@ import com.suisung.mall.common.modules.activity.ShopActivityGroupbooking;
import com.suisung.mall.shop.activity.service.ShopActivityGroupbookingService; import com.suisung.mall.shop.activity.service.ShopActivityGroupbookingService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@ -24,6 +25,7 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/admin/shop/shop-activity-groupbooking") @RequestMapping("/admin/shop/shop-activity-groupbooking")
public class ShopActivityGroupbookingController { public class ShopActivityGroupbookingController {
@Lazy
@Autowired @Autowired
private ShopActivityGroupbookingService shopActivityGroupbookingService; private ShopActivityGroupbookingService shopActivityGroupbookingService;

View File

@ -21,6 +21,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
@ -39,21 +40,27 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping("/mobile/shop/userActivity") @RequestMapping("/mobile/shop/userActivity")
public class UserActivityController extends BaseControllerImpl { public class UserActivityController extends BaseControllerImpl {
@Lazy
@Autowired @Autowired
private ShopActivityCutpriceService shopActivityCutpriceService; private ShopActivityCutpriceService shopActivityCutpriceService;
@Lazy
@Autowired @Autowired
private ShopActivityCutpriceHistoryService shopActivityCutpriceHistoryService; private ShopActivityCutpriceHistoryService shopActivityCutpriceHistoryService;
@Lazy
@Autowired @Autowired
private ShopActivityGroupbookingService shopActivityGroupbookingService; private ShopActivityGroupbookingService shopActivityGroupbookingService;
@Lazy
@Autowired @Autowired
private ShopActivityGroupbuyStoreService shopActivityGroupbuyStoreService; private ShopActivityGroupbuyStoreService shopActivityGroupbuyStoreService;
@Lazy
@Autowired @Autowired
private ShopUserVoucherService shopUserVoucherService; private ShopUserVoucherService shopUserVoucherService;
@Lazy
@Autowired @Autowired
private ShopStoreActivityBaseService shopStoreActivityBaseService; private ShopStoreActivityBaseService shopStoreActivityBaseService;

View File

@ -23,6 +23,7 @@ import com.suisung.mall.shop.activity.service.ShopActivityCutpriceHistoryService
import com.suisung.mall.shop.activity.service.ShopActivityCutpriceService; import com.suisung.mall.shop.activity.service.ShopActivityCutpriceService;
import com.suisung.mall.shop.store.service.ShopStoreActivityBaseService; import com.suisung.mall.shop.store.service.ShopStoreActivityBaseService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
@ -45,12 +46,15 @@ import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
@Service @Service
public class ShopActivityCutpriceHistoryServiceImpl extends BaseServiceImpl<ShopActivityCutpriceHistoryMapper, ShopActivityCutpriceHistory> implements ShopActivityCutpriceHistoryService { public class ShopActivityCutpriceHistoryServiceImpl extends BaseServiceImpl<ShopActivityCutpriceHistoryMapper, ShopActivityCutpriceHistory> implements ShopActivityCutpriceHistoryService {
@Lazy
@Autowired @Autowired
private ShopActivityCutpriceService shopActivityCutpriceService; private ShopActivityCutpriceService shopActivityCutpriceService;
@Lazy
@Autowired @Autowired
private ShopStoreActivityBaseService shopStoreActivityBaseService; private ShopStoreActivityBaseService shopStoreActivityBaseService;
@Lazy
@Autowired @Autowired
private AccountService accountService; private AccountService accountService;

View File

@ -34,6 +34,7 @@ import com.suisung.mall.shop.activity.service.ShopActivityGroupbookingService;
import com.suisung.mall.shop.base.service.AccountBaseConfigService; import com.suisung.mall.shop.base.service.AccountBaseConfigService;
import com.suisung.mall.shop.store.service.ShopStoreActivityBaseService; import com.suisung.mall.shop.store.service.ShopStoreActivityBaseService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -56,15 +57,19 @@ import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
@Service @Service
public class ShopActivityCutpriceServiceImpl extends BaseServiceImpl<ShopActivityCutpriceMapper, ShopActivityCutprice> implements ShopActivityCutpriceService { public class ShopActivityCutpriceServiceImpl extends BaseServiceImpl<ShopActivityCutpriceMapper, ShopActivityCutprice> implements ShopActivityCutpriceService {
@Lazy
@Autowired @Autowired
private ShopActivityGroupbookingHistoryService shopActivityGroupbookingHistoryService; private ShopActivityGroupbookingHistoryService shopActivityGroupbookingHistoryService;
@Lazy
@Autowired @Autowired
private ShopActivityGroupbookingService shopActivityGroupbookingService; private ShopActivityGroupbookingService shopActivityGroupbookingService;
@Lazy
@Autowired @Autowired
private ShopStoreActivityBaseService shopStoreActivityBaseService; private ShopStoreActivityBaseService shopStoreActivityBaseService;
@Lazy
@Autowired @Autowired
private AccountService accountService; private AccountService accountService;

View File

@ -34,6 +34,7 @@ import com.suisung.mall.shop.store.service.ShopStoreBaseService;
import com.suisung.mall.shop.user.service.ShopUserVoucherService; import com.suisung.mall.shop.user.service.ShopUserVoucherService;
import io.seata.spring.annotation.GlobalTransactional; import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.Serializable; import java.io.Serializable;
@ -61,6 +62,7 @@ public class ShopActivityGroupbookingServiceImpl extends BaseServiceImpl<ShopAct
@Autowired @Autowired
private ShopActivityGroupbookingService shopActivityGroupbookingService; private ShopActivityGroupbookingService shopActivityGroupbookingService;
@Lazy
@Autowired @Autowired
private ShopStoreActivityBaseService shopStoreActivityBaseService; private ShopStoreActivityBaseService shopStoreActivityBaseService;
@ -70,18 +72,21 @@ public class ShopActivityGroupbookingServiceImpl extends BaseServiceImpl<ShopAct
@Autowired @Autowired
private ShopOrderInfoService shopOrderInfoService; private ShopOrderInfoService shopOrderInfoService;
@Lazy
@Autowired @Autowired
private ShopUserVoucherService shopUserVoucherService; private ShopUserVoucherService shopUserVoucherService;
@Autowired @Autowired
private ShopOrderReturnService shopOrderReturnService; private ShopOrderReturnService shopOrderReturnService;
@Lazy
@Autowired @Autowired
private ShopOrderBaseService shopOrderBaseService; private ShopOrderBaseService shopOrderBaseService;
@Autowired @Autowired
private ShopOrderDataService shopOrderDataService; private ShopOrderDataService shopOrderDataService;
@Lazy
@Autowired @Autowired
private ShopStoreBaseService shopStoreBaseService; private ShopStoreBaseService shopStoreBaseService;

View File

@ -26,7 +26,6 @@ import com.suisung.mall.common.modules.product.ShopProductIndex;
import com.suisung.mall.common.modules.product.ShopProductItem; import com.suisung.mall.common.modules.product.ShopProductItem;
import com.suisung.mall.common.modules.sixun.SxSyncCategory; import com.suisung.mall.common.modules.sixun.SxSyncCategory;
import com.suisung.mall.common.modules.store.ShopStoreActivityItem; import com.suisung.mall.common.modules.store.ShopStoreActivityItem;
import com.suisung.mall.common.modules.store.ShopStoreProductCategory;
import com.suisung.mall.common.modules.user.ShopUserCart; import com.suisung.mall.common.modules.user.ShopUserCart;
import com.suisung.mall.common.pojo.dto.ProductSearchDTO; import com.suisung.mall.common.pojo.dto.ProductSearchDTO;
import com.suisung.mall.common.utils.*; import com.suisung.mall.common.utils.*;
@ -53,9 +52,9 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict; import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable; import org.springframework.cache.annotation.Cacheable;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.Serializable; import java.io.Serializable;
import java.util.*; import java.util.*;
@ -75,74 +74,58 @@ import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
@Service @Service
public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBaseProductCategoryMapper, ShopBaseProductCategory> implements ShopBaseProductCategoryService { public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBaseProductCategoryMapper, ShopBaseProductCategory> implements ShopBaseProductCategoryService {
private final String LANG = "zh_CN"; // todo 多语言动态
@Autowired @Autowired
private UserInfoService userInfoService; private UserInfoService userInfoService;
@Autowired @Autowired
private AccountBaseConfigService accountBaseConfigService; private AccountBaseConfigService accountBaseConfigService;
@Lazy
@Autowired @Autowired
private ShopProductBaseService shopProductBaseService; private ShopProductBaseService shopProductBaseService;
@Autowired @Autowired
private ShopBaseProductAssistService productAssistService; private ShopBaseProductAssistService productAssistService;
@Autowired @Autowired
private ShopBaseProductAssistItemService productAssistItemService; private ShopBaseProductAssistItemService productAssistItemService;
@Autowired @Autowired
private ShopBaseProductBrandService productBrandService; private ShopBaseProductBrandService productBrandService;
@Lazy
@Autowired @Autowired
private ShopUserCartService shopUserCartService; private ShopUserCartService shopUserCartService;
@Lazy
@Autowired @Autowired
private ShopDistributionUserService distributionUserService; private ShopDistributionUserService distributionUserService;
@Autowired @Autowired
private RedisService redisService; private RedisService redisService;
@Autowired @Autowired
private HttpServletRequest request; private HttpServletRequest request;
@Lazy
@Autowired @Autowired
private ShopProductItemService shopProductItemService; private ShopProductItemService shopProductItemService;
@Autowired @Autowired
private ShopBaseDistrictService shopBaseDistrictService; private ShopBaseDistrictService shopBaseDistrictService;
@Lazy
@Autowired @Autowired
private ShopProductIndexService shopProductIndexService; private ShopProductIndexService shopProductIndexService;
@Autowired @Autowired
private ShopBaseProductTagService shopBaseProductTagService; private ShopBaseProductTagService shopBaseProductTagService;
@Autowired @Autowired
private EduService eduService; private EduService eduService;
@Autowired @Autowired
private AccountService accountService; private AccountService accountService;
@Autowired @Autowired
private ShopProductImageService shopProductImageService; private ShopProductImageService shopProductImageService;
@Autowired @Autowired
private ShopStoreActivityItemService shopStoreActivityItemService; private ShopStoreActivityItemService shopStoreActivityItemService;
@Autowired @Autowired
private ShopBaseProductCategoryMapper shopBaseProductCategoryMapper; private ShopBaseProductCategoryMapper shopBaseProductCategoryMapper;
@Autowired @Autowired
private ShopBaseProductTypeService shopBaseProductTypeService; private ShopBaseProductTypeService shopBaseProductTypeService;
@Autowired @Autowired
private SxSyncCategoryService sxSyncCategoryService; private SxSyncCategoryService sxSyncCategoryService;
@Autowired @Autowired
private ShopStoreBaseService shopStoreBaseService; private ShopStoreBaseService shopStoreBaseService;
private final String LANG = "zh_CN"; // todo 多语言动态
@Override @Override
public List<ElTree> tree(QueryWrapper<ShopBaseProductCategory> queryWrapper) { public List<ElTree> tree(QueryWrapper<ShopBaseProductCategory> queryWrapper) {
List<ShopBaseProductCategory> list = find(queryWrapper); List<ShopBaseProductCategory> list = find(queryWrapper);
@ -247,11 +230,11 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBase
@Override @Override
public List<Map> getCategoryTree() { public List<Map> getCategoryTree() {
QueryWrapper<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>(); QueryWrapper<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>();
String redisKey=RedisConstant.Product_Cate_Key; String redisKey = RedisConstant.Product_Cate_Key;
if(getCurrentUser().isStore()){ if (getCurrentUser().isStore()) {
Integer store_id = Convert.toInt(getCurrentUser().getStore_id()); Integer store_id = Convert.toInt(getCurrentUser().getStore_id());
queryWrapper.eq("store_id", store_id); queryWrapper.eq("store_id", store_id);
redisKey=RedisConstant.Product_Cate_Key+":"+store_id; redisKey = RedisConstant.Product_Cate_Key + ":" + store_id;
} }
List<Map> cateTree = Convert.toList(Map.class, redisService.get(redisKey)); List<Map> cateTree = Convert.toList(Map.class, redisService.get(redisKey));
if (CollUtil.isNotEmpty(cateTree)) { if (CollUtil.isNotEmpty(cateTree)) {
@ -946,9 +929,9 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBase
@Override @Override
public Map lists() { public Map lists() {
String storeId=null; String storeId = null;
if(getCurrentUser().isStore()){ if (getCurrentUser().isStore()) {
storeId=getCurrentUser().getStore_id(); storeId = getCurrentUser().getStore_id();
} }
List<ShopBaseProductCategory> shopBaseProductCategories = shopBaseProductCategoryMapper.selectCategoryList(storeId); List<ShopBaseProductCategory> shopBaseProductCategories = shopBaseProductCategoryMapper.selectCategoryList(storeId);
Map map = new HashMap(1); Map map = new HashMap(1);
@ -976,8 +959,8 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBase
if (CheckUtil.isNotEmpty(categoryName)) { if (CheckUtil.isNotEmpty(categoryName)) {
objectQueryWrapper.like("category_name", categoryName); objectQueryWrapper.like("category_name", categoryName);
} }
String storeId=getParameter("store_id"); String storeId = getParameter("store_id");
if(CheckUtil.isNotEmpty(storeId)){ if (CheckUtil.isNotEmpty(storeId)) {
objectQueryWrapper.eq("store_id", storeId); objectQueryWrapper.eq("store_id", storeId);
} }
@ -1038,7 +1021,7 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBase
throw new ApiException(String.format(I18nUtil._("商品编号 【%s】使用此分类不可以删除"), CollUtil.join(product_ids, ","))); throw new ApiException(String.format(I18nUtil._("商品编号 【%s】使用此分类不可以删除"), CollUtil.join(product_ids, ",")));
} }
String storeId= ContextUtil.getCurrentUser().getStore_id(); String storeId = ContextUtil.getCurrentUser().getStore_id();
cleanCategoryCache(storeId); cleanCategoryCache(storeId);
return remove(category_id); return remove(category_id);
@ -1061,8 +1044,8 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBase
if (ObjectUtil.isNotNull(keys)) { if (ObjectUtil.isNotNull(keys)) {
redisService.del(keys); redisService.del(keys);
} }
String manageKey=RedisConstant.Product_Cate_Key;//清除管理员的key String manageKey = RedisConstant.Product_Cate_Key;//清除管理员的key
String storeKey=RedisConstant.Product_Cate_Key+":"+storeId;//清除店铺的key String storeKey = RedisConstant.Product_Cate_Key + ":" + storeId;//清除店铺的key
redisService.del(storeKey); redisService.del(storeKey);
redisService.del(manageKey); redisService.del(manageKey);
@ -1141,7 +1124,7 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBase
* @return * @return
*/ */
@Override @Override
public ShopBaseProductCategory getCategoryByName(String categoryName,String storeId) { public ShopBaseProductCategory getCategoryByName(String categoryName, String storeId) {
QueryWrapper<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>(); QueryWrapper<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("category_name", categoryName); queryWrapper.eq("category_name", categoryName);
queryWrapper.eq("store_id", storeId); queryWrapper.eq("store_id", storeId);
@ -1184,7 +1167,7 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBase
*/ */
@Override @Override
public ShopBaseProductCategory ConvSxCategoryToShopBaseProductCategory(SxSyncCategory sxSyncCategory) { public ShopBaseProductCategory ConvSxCategoryToShopBaseProductCategory(SxSyncCategory sxSyncCategory) {
if(sxSyncCategory==null){ if (sxSyncCategory == null) {
return null; return null;
} }
@ -1265,14 +1248,14 @@ public class ShopBaseProductCategoryServiceImpl extends BaseServiceImpl<ShopBase
if (CollUtil.isEmpty(map)) { if (CollUtil.isEmpty(map)) {
QueryWrapper<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>(); QueryWrapper<ShopBaseProductCategory> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("store_id", storeId); queryWrapper.eq("store_id", storeId);
// queryWrapper.eq("data_source", 2); // queryWrapper.eq("data_source", 2);
List<ShopBaseProductCategory> categoryList = find(queryWrapper); List<ShopBaseProductCategory> categoryList = find(queryWrapper);
// 类似数据可以放到前端整理 // 类似数据可以放到前端整理
List<Map> category_tmp_rows = Convert.toList(Map.class, categoryList); List<Map> category_tmp_rows = Convert.toList(Map.class, categoryList);
map=new HashMap(); map = new HashMap();
for (Map category_row : category_tmp_rows) { for (Map category_row : category_tmp_rows) {
map.put(category_row.get("category_name"),category_row.get("category_id")); map.put(category_row.get("category_name"), category_row.get("category_id"));
map.put(category_row.get("category_id"),category_row.get("type_id")); map.put(category_row.get("category_id"), category_row.get("type_id"));
} }
if (CollUtil.isNotEmpty(map)) redisService.set(cache_key, map, 60 * 60); if (CollUtil.isNotEmpty(map)) redisService.set(cache_key, map, 60 * 60);

View File

@ -14,6 +14,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.connection.CorrelationData; import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.context.ApplicationContext;
import org.springframework.scheduling.quartz.QuartzJobBean; import org.springframework.scheduling.quartz.QuartzJobBean;
import java.util.Date; import java.util.Date;
@ -26,35 +27,51 @@ import java.util.stream.Collectors;
public class RetryMqMsgJob extends QuartzJobBean { public class RetryMqMsgJob extends QuartzJobBean {
@Override @Override
protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException { protected void executeInternal(JobExecutionContext jobExecutionContext) throws JobExecutionException {
Logger logger = LoggerFactory.getLogger(StoreValidTimeJod.class); Logger logger = LoggerFactory.getLogger(RetryMqMsgJob.class);
MqMessageService mqMessageService = SpringUtil.getBean(MqMessageService.class); try {
RabbitTemplate rabbitTemplate = SpringUtil.getBean(RabbitTemplate.class); MqMessageService mqMessageService = SpringUtil.getBean(MqMessageService.class);
// 检查Spring容器是否正在关闭
QueryWrapper<MqMessage> mqMessageQueryWrapper = new QueryWrapper<>(); ApplicationContext applicationContext = SpringUtil.getApplicationContext();
mqMessageQueryWrapper.eq("message_status", MqConstant.FAILURE); if (applicationContext == null) {
mqMessageQueryWrapper.lt("message_count", MqConstant.MAX_COUNT); logger.warn("Application context is null, skipping RetryMqMsgJob execution");
List<MqMessage> mqMessages = mqMessageService.find(mqMessageQueryWrapper); return;
mqMessages.forEach(mqMessage -> {
mqMessage.setMessage_count(mqMessage.getMessage_count() + 1);
if (!mqMessageService.edit(mqMessage)) {
logger.error(I18nUtil._("消息消费次数增加失败!"));
} }
// 重新投递到队列中
rabbitTemplate.convertAndSend(mqMessage.getMessage_to_exchane(), mqMessage.getMessage_routing_key(), mqMessage.getMessage_content(), new CorrelationData(mqMessage.getMessage_id()));
});
// 清理已经消费成功的消息或早于两个月前的消息 RabbitTemplate rabbitTemplate = null;
QueryWrapper<MqMessage> queryWrapper = new QueryWrapper<>(); try {
queryWrapper.eq("message_status", MqConstant.DELIVERED) rabbitTemplate = SpringUtil.getBean(RabbitTemplate.class);
.or().lt("create_time", DateUtil.offsetMonth(new Date(), -2)); } catch (Exception e) {
List<MqMessage> messages = mqMessageService.lists(queryWrapper, 1, 20).getRecords(); logger.warn("Failed to get RabbitTemplate bean, skipping message retry: {}", e.getMessage());
List<String> messageIds = messages.stream().map(MqMessage::getMessage_id).collect(Collectors.toList()); return;
if (CollUtil.isNotEmpty(messageIds)) {
if (!mqMessageService.removeByIds(messageIds)) {
logger.error(I18nUtil._("消息清理失败!"));
} }
QueryWrapper<MqMessage> mqMessageQueryWrapper = new QueryWrapper<>();
mqMessageQueryWrapper.eq("message_status", MqConstant.FAILURE);
mqMessageQueryWrapper.lt("message_count", MqConstant.MAX_COUNT);
List<MqMessage> mqMessages = mqMessageService.find(mqMessageQueryWrapper);
for (MqMessage mqMessage : mqMessages) {
mqMessage.setMessage_count(mqMessage.getMessage_count() + 1);
if (!mqMessageService.edit(mqMessage)) {
logger.error(I18nUtil._("消息消费次数增加失败!"));
}
// 重新投递到队列中
rabbitTemplate.convertAndSend(mqMessage.getMessage_to_exchane(), mqMessage.getMessage_routing_key(), mqMessage.getMessage_content(), new CorrelationData(mqMessage.getMessage_id()));
}
// 清理已经消费成功的消息或早于两个月前的消息
QueryWrapper<MqMessage> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("message_status", MqConstant.DELIVERED)
.or().lt("create_time", DateUtil.offsetMonth(new Date(), -2));
List<MqMessage> messages = mqMessageService.lists(queryWrapper, 1, 20).getRecords();
List<String> messageIds = messages.stream().map(MqMessage::getMessage_id).collect(Collectors.toList());
if (CollUtil.isNotEmpty(messageIds)) {
if (!mqMessageService.removeByIds(messageIds)) {
logger.error(I18nUtil._("消息清理失败!"));
}
}
} catch (Exception e) {
logger.error("Error executing RetryMqMsgJob: {}", e.getMessage(), e);
} }
} }
} }

View File

@ -16,9 +16,9 @@ import com.suisung.mall.common.modules.distribution.ShopDistributionPlantformUse
import com.suisung.mall.common.modules.distribution.ShopDistributionPlantformUserGeneratedCommission; import com.suisung.mall.common.modules.distribution.ShopDistributionPlantformUserGeneratedCommission;
import com.suisung.mall.common.modules.distribution.ShopDistributionUser; import com.suisung.mall.common.modules.distribution.ShopDistributionUser;
import com.suisung.mall.common.modules.distribution.ShopDistributionUserCommission; import com.suisung.mall.common.modules.distribution.ShopDistributionUserCommission;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import com.suisung.mall.common.utils.CheckUtil; import com.suisung.mall.common.utils.CheckUtil;
import com.suisung.mall.common.utils.I18nUtil; import com.suisung.mall.common.utils.I18nUtil;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import com.suisung.mall.shop.base.service.AccountBaseConfigService; import com.suisung.mall.shop.base.service.AccountBaseConfigService;
import com.suisung.mall.shop.distribution.mapper.ShopDistributionPlantformUserMapper; import com.suisung.mall.shop.distribution.mapper.ShopDistributionPlantformUserMapper;
import com.suisung.mall.shop.distribution.service.ShopDistributionPlantformUserGeneratedCommissionService; import com.suisung.mall.shop.distribution.service.ShopDistributionPlantformUserGeneratedCommissionService;
@ -26,6 +26,7 @@ import com.suisung.mall.shop.distribution.service.ShopDistributionPlantformUserS
import com.suisung.mall.shop.distribution.service.ShopDistributionUserCommissionService; import com.suisung.mall.shop.distribution.service.ShopDistributionUserCommissionService;
import com.suisung.mall.shop.distribution.service.ShopDistributionUserService; import com.suisung.mall.shop.distribution.service.ShopDistributionUserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -53,6 +54,7 @@ public class ShopDistributionPlantformUserServiceImpl extends BaseServiceImpl<Sh
@Autowired @Autowired
private ShopDistributionUserService shopDistributionUserService; private ShopDistributionUserService shopDistributionUserService;
@Lazy
@Autowired @Autowired
private ShopDistributionUserCommissionService distributionUserCommissionService; private ShopDistributionUserCommissionService distributionUserCommissionService;

View File

@ -21,6 +21,7 @@ import com.suisung.mall.shop.distribution.service.ShopDistributionUserOrderServi
import com.suisung.mall.shop.distribution.service.ShopDistributionUserWithdrawService; import com.suisung.mall.shop.distribution.service.ShopDistributionUserWithdrawService;
import io.seata.spring.annotation.GlobalTransactional; import io.seata.spring.annotation.GlobalTransactional;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -47,6 +48,7 @@ public class ShopDistributionUserCommissionServiceImpl extends BaseServiceImpl<S
@Autowired @Autowired
private AccountBaseConfigService accountBaseConfigService; private AccountBaseConfigService accountBaseConfigService;
@Lazy
@Autowired @Autowired
private ShopDistributionUserOrderService distributionUserOrderService; private ShopDistributionUserOrderService distributionUserOrderService;

View File

@ -24,6 +24,7 @@ import com.suisung.mall.shop.order.service.ShopOrderBaseService;
import com.suisung.mall.shop.order.service.ShopOrderInfoService; import com.suisung.mall.shop.order.service.ShopOrderInfoService;
import com.suisung.mall.shop.store.service.ShopStoreBaseService; import com.suisung.mall.shop.store.service.ShopStoreBaseService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -54,9 +55,11 @@ public class ShopDistributionUserOrderServiceImpl extends BaseServiceImpl<ShopDi
@Autowired @Autowired
private ShopDistributionUserService shopDistributionUserService; private ShopDistributionUserService shopDistributionUserService;
@Lazy
@Autowired @Autowired
private ShopDistributionPlantformUserService shopDistributionPlantformUserService; private ShopDistributionPlantformUserService shopDistributionPlantformUserService;
@Lazy
@Autowired @Autowired
private ShopOrderBaseService shopOrderBaseService; private ShopOrderBaseService shopOrderBaseService;

View File

@ -57,6 +57,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -91,10 +92,13 @@ public class ShopDistributionUserServiceImpl extends BaseServiceImpl<ShopDistrib
private AccountBaseConfigService accountBaseConfigService; private AccountBaseConfigService accountBaseConfigService;
@Autowired @Autowired
private ShopBaseDistrictService shopBaseDistrictService; private ShopBaseDistrictService shopBaseDistrictService;
@Lazy
@Autowired @Autowired
private ShopDistributionPlantformUserService plantformUserServicel; private ShopDistributionPlantformUserService plantformUserServicel;
@Lazy
@Autowired @Autowired
private ShopDistributionUserCommissionService userCommissionService; private ShopDistributionUserCommissionService userCommissionService;
@Lazy
@Autowired @Autowired
private ShopDistributionUserOrderService userOrderService; private ShopDistributionUserOrderService userOrderService;
@Autowired @Autowired

View File

@ -16,6 +16,7 @@ import com.suisung.mall.shop.message.service.PushMessageService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message; import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener; import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource; import javax.annotation.Resource;
@ -32,6 +33,7 @@ import java.io.IOException;
@Slf4j @Slf4j
public class DelayMessageReceiver { public class DelayMessageReceiver {
@Lazy
@Resource @Resource
private PushMessageService pushMessageService; private PushMessageService pushMessageService;
@ -48,15 +50,7 @@ public class DelayMessageReceiver {
try { try {
// 处理死信消息 // 处理死信消息
boolean result = processDeadMessage(message); processDeadMessage(message, channel, msg);
// 根据处理结果确认或拒绝消息
if (result) {
ackMessage(channel, msg);
} else {
log.warn("处理过期消息失败,消息将重新入队,消息内容: {}", message);
rejectMessage(channel, msg);
}
} catch (Exception e) { } catch (Exception e) {
log.error("处理过期消息时发生异常,消息将重新入队,消息内容: {}", message, e); log.error("处理过期消息时发生异常,消息将重新入队,消息内容: {}", message, e);
rejectMessage(channel, msg); rejectMessage(channel, msg);
@ -69,7 +63,7 @@ public class DelayMessageReceiver {
* @param message 消息内容 * @param message 消息内容
* @return 处理结果 true-成功 false-失败 * @return 处理结果 true-成功 false-失败
*/ */
private boolean processDeadMessage(JSONObject message) { private boolean processDeadMessage(JSONObject message, Channel channel, Message msg) {
log.info("开始处理死信消息: {}", message); log.info("开始处理死信消息: {}", message);
// 检查消息是否为空 // 检查消息是否为空
@ -83,22 +77,25 @@ public class DelayMessageReceiver {
Integer category = message.getInt("category"); Integer category = message.getInt("category");
if (category == null) { if (category == null) {
log.warn("消息分类为空,无法处理消息: {}", message); log.warn("消息分类为空,无法处理消息: {}", message);
ackMessage(channel, msg);
return false; return false;
} }
// 根据消息分类处理不同类型的消息 // 根据消息分类处理不同类型的消息
if (category == MqConstant.DEAD_EVENT_CATE_ORDER_EXPIRED) { if (category == MqConstant.DEAD_EVENT_CATE_ORDER_EXPIRED) {
// 处理订单超时消息 // 处理订单超时消息
return handleOrderExpiredMessage(message); return handleOrderExpiredMessage(message, channel, msg);
} else if (category == MqConstant.DEAD_EVENT_CATE_PRE_ORDER) { } else if (category == MqConstant.DEAD_EVENT_CATE_PRE_ORDER) {
// 处理预订单消息 // 处理预订单消息
return handlePreOrderMessage(message); return handlePreOrderMessage(message);
} else { } else {
log.warn("未知的消息分类: {},消息内容: {}", category, message); log.warn("未知的消息分类: {},消息内容: {}", category, message);
ackMessage(channel, msg);
return false; return false;
} }
} catch (Exception e) { } catch (Exception e) {
log.error("处理死信消息时发生异常,消息内容: {}", message, e); log.error("处理死信消息时发生异常,消息内容: {}", message, e);
ackMessage(channel, msg);
return false; return false;
} }
} }
@ -109,7 +106,7 @@ public class DelayMessageReceiver {
* @param message 消息内容 * @param message 消息内容
* @return 处理结果 * @return 处理结果
*/ */
private boolean handleOrderExpiredMessage(JSONObject message) { private boolean handleOrderExpiredMessage(JSONObject message, Channel channel, Message msg) {
try { try {
String orderId = message.getStr("orderId"); String orderId = message.getStr("orderId");
Integer storeId = message.getInt("storeId"); Integer storeId = message.getInt("storeId");
@ -127,9 +124,11 @@ public class DelayMessageReceiver {
message.getStr("message"), payload); message.getStr("message"), payload);
log.info("订单超时消息处理完成,订单号: {}, 店铺ID: {}", orderId, storeId); log.info("订单超时消息处理完成,订单号: {}, 店铺ID: {}", orderId, storeId);
ackMessage(channel, msg);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
log.error("处理订单超时消息时发生异常,消息内容: {}", message, e); log.error("处理订单超时消息时发生异常,消息内容: {}", message, e);
ackMessage(channel, msg);
return false; return false;
} }
} }

View File

@ -8,6 +8,7 @@ import com.suisung.mall.common.constant.CommonConstant;
import com.suisung.mall.common.constant.MqConstant; import com.suisung.mall.common.constant.MqConstant;
import com.suisung.mall.common.modules.order.ShopOrderInfo; import com.suisung.mall.common.modules.order.ShopOrderInfo;
import com.suisung.mall.common.utils.DateTimeUtils; import com.suisung.mall.common.utils.DateTimeUtils;
import com.suisung.mall.shop.message.service.MqMessageService;
import com.suisung.mall.shop.message.service.PushMessageService; import com.suisung.mall.shop.message.service.PushMessageService;
import com.suisung.mall.shop.order.service.ShopOrderBaseService; import com.suisung.mall.shop.order.service.ShopOrderBaseService;
import com.suisung.mall.shop.order.service.ShopOrderInfoService; import com.suisung.mall.shop.order.service.ShopOrderInfoService;
@ -37,21 +38,24 @@ import java.util.List;
public class OrderPayedListener { public class OrderPayedListener {
private static final Logger logger = LoggerFactory.getLogger(OrderPayedListener.class); private static final Logger logger = LoggerFactory.getLogger(OrderPayedListener.class);
@Autowired
private ShopOrderBaseService shopOrderBaseService;
@Autowired
private ShopOrderInfoService shopOrderInfoService;
// @Autowired
// private ShopStorePrinterService shopStorePrinterService;
// @Autowired
// private MqMessageService mqMessageService;
@Autowired
private SFExpressApiService sfExpressApiService;
@Lazy
@Autowired
private ShopOrderBaseService shopOrderBaseService;
@Lazy
@Autowired
private ShopOrderInfoService shopOrderInfoService;
@Lazy
@Autowired
private SFExpressApiService sfExpressApiService;
@Lazy @Lazy
@Autowired @Autowired
private PushMessageService pushMessageService; private PushMessageService pushMessageService;
@Lazy
@Autowired
private MqMessageService mqMessageService;
@RabbitHandler @RabbitHandler
public void listener(String data, Channel channel, Message message) throws IOException, InterruptedException { public void listener(String data, Channel channel, Message message) throws IOException, InterruptedException {
String messageId = message.getMessageProperties().getMessageId(); String messageId = message.getMessageProperties().getMessageId();
@ -134,7 +138,17 @@ public class OrderPayedListener {
pushMessageService.noticeMerchantEmployeeOrderAction(orderInfoOld.getStore_id(), orderId, title, content, payload); pushMessageService.noticeMerchantEmployeeOrderAction(orderInfoOld.getStore_id(), orderId, title, content, payload);
// 发送 预过期 MQ 的推送消息 // 发送 预过期 MQ 的推送消息
shopOrderBaseService.preSendExpiredSFOrderPushMessage(orderInfoOld.getStore_id(), orderId, 1500L); // 25分钟发出过期消息 // shopOrderBaseService.preSendExpiredSFOrderPushMessage(orderInfoOld.getStore_id(), orderId, 1500L); // 25分钟发出过期消息
JSONObject jsonObject = new JSONObject();
jsonObject.put("category", MqConstant.DEAD_EVENT_CATE_ORDER_EXPIRED); // 消息分类1-订单超时消息
jsonObject.put("orderId", orderId); // 订单ID
jsonObject.put("storeId", orderInfoOld.getStore_id()); // 店铺ID
jsonObject.put("title", "有一笔已超时的订单!"); // 消息标题
jsonObject.put("message", "您有一笔已超时的订单[" + orderId + "],请及时处理。"); // 消息内容
// 发送延迟消息
mqMessageService.sendDelayMessage(jsonObject.toString(), 1500L * 1000); // 转换为毫秒
} }
} }

View File

@ -605,5 +605,5 @@ public interface ShopOrderBaseService extends IBaseService<ShopOrderBase> {
* @param expireSeconds 配送超时的秒数单位秒 * @param expireSeconds 配送超时的秒数单位秒
* @return * @return
*/ */
Boolean preSendExpiredSFOrderPushMessage(Integer storeId, String orderId, Long expireSeconds); // Boolean preSendExpiredSFOrderPushMessage(Integer storeId, String orderId, Long expireSeconds);
} }

View File

@ -111,7 +111,6 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Lazy; import org.springframework.context.annotation.Lazy;
import org.springframework.data.util.Pair; import org.springframework.data.util.Pair;
import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
@ -147,8 +146,10 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
private final Logger logger = LoggerFactory.getLogger(ShopOrderBaseServiceImpl.class); private final Logger logger = LoggerFactory.getLogger(ShopOrderBaseServiceImpl.class);
@Autowired @Autowired
private ShopOrderBaseMapper shopOrderBaseMapper; private ShopOrderBaseMapper shopOrderBaseMapper;
@Lazy
@Autowired @Autowired
private ShopOrderInfoService shopOrderInfoService; private ShopOrderInfoService shopOrderInfoService;
@Lazy
@Autowired @Autowired
private ShopOrderReturnService orderReturnService; private ShopOrderReturnService orderReturnService;
@Autowired @Autowired
@ -157,6 +158,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
private ShopStoreBaseService shopStoreBaseService; private ShopStoreBaseService shopStoreBaseService;
@Autowired @Autowired
private ShopStoreInfoService shopStoreInfoService; private ShopStoreInfoService shopStoreInfoService;
@Lazy
@Autowired @Autowired
private ShopOrderItemService shopOrderItemService; private ShopOrderItemService shopOrderItemService;
@Autowired @Autowired
@ -169,6 +171,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
private ShopOrderChainCodeService orderChainCodeService; private ShopOrderChainCodeService orderChainCodeService;
@Autowired @Autowired
private ShopChainBaseService shopChainBaseService; private ShopChainBaseService shopChainBaseService;
@Lazy
@Autowired @Autowired
private ShopOrderLogisticsService orderLogisticsService; private ShopOrderLogisticsService orderLogisticsService;
@Autowired @Autowired
@ -177,10 +180,13 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
private ShopOrderDeliveryAddressService orderDeliveryAddressService; private ShopOrderDeliveryAddressService orderDeliveryAddressService;
@Autowired @Autowired
private ShopOrderInvoiceService orderInvoiceService; private ShopOrderInvoiceService orderInvoiceService;
@Lazy
@Autowired @Autowired
private ShopProductBaseService shopProductBaseService; private ShopProductBaseService shopProductBaseService;
@Lazy
@Autowired @Autowired
private ShopProductIndexService shopProductIndexService; private ShopProductIndexService shopProductIndexService;
@Lazy
@Autowired @Autowired
private ShopProductItemService shopProductItemService; private ShopProductItemService shopProductItemService;
@Autowired @Autowired
@ -189,12 +195,14 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
private ShopBaseStateCodeService shopBaseStateCodeService; private ShopBaseStateCodeService shopBaseStateCodeService;
@Autowired @Autowired
private ShopProductValidPeriodService validPeriodService; private ShopProductValidPeriodService validPeriodService;
@Lazy
@Autowired @Autowired
private ShopActivityGroupbookingService activityGroupbookingService; private ShopActivityGroupbookingService activityGroupbookingService;
@Autowired @Autowired
private ShopActivityGroupbookingHistoryService groupbookingHistoryService; private ShopActivityGroupbookingHistoryService groupbookingHistoryService;
@Autowired @Autowired
private ShopOrderStateLogService shopOrderStateLogService; private ShopOrderStateLogService shopOrderStateLogService;
@Lazy
@Autowired @Autowired
private InvoicingStockBillService invoicingStockBillService; private InvoicingStockBillService invoicingStockBillService;
@Autowired @Autowired
@ -217,14 +225,17 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
private AccountService accountService; private AccountService accountService;
@Autowired @Autowired
private ShopUserInvoiceService shopUserInvoiceService; private ShopUserInvoiceService shopUserInvoiceService;
@Lazy
@Autowired @Autowired
private ShopUserCartService shopUserCartService; private ShopUserCartService shopUserCartService;
@Lazy
@Autowired @Autowired
private ShopStoreActivityBaseService shopStoreActivityBaseService; private ShopStoreActivityBaseService shopStoreActivityBaseService;
@Autowired @Autowired
private ShopStoreEmployeeService storeEmployeeService; private ShopStoreEmployeeService storeEmployeeService;
@Autowired @Autowired
private ShopUserProductBuyService shopUserProductBuyService; private ShopUserProductBuyService shopUserProductBuyService;
@Lazy
@Autowired @Autowired
private ShopUserVoucherService shopUserVoucherService; private ShopUserVoucherService shopUserVoucherService;
@Autowired @Autowired
@ -235,16 +246,20 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
private ShopActivityPfGroupbuyStoreHistoryService activityPfGroupbuyStoreHistoryService; private ShopActivityPfGroupbuyStoreHistoryService activityPfGroupbuyStoreHistoryService;
@Autowired @Autowired
private ShopActivityCutpriceService activityCutpriceService; private ShopActivityCutpriceService activityCutpriceService;
@Lazy
@Autowired @Autowired
private ShopBaseProductCategoryService shopBaseProductCategoryService; private ShopBaseProductCategoryService shopBaseProductCategoryService;
@Autowired @Autowired
private InvoicingCustomerBaseService invoicingCustomerBaseService; private InvoicingCustomerBaseService invoicingCustomerBaseService;
@Autowired @Autowired
private UserInfoService userInfoService; private UserInfoService userInfoService;
@Lazy
@Autowired @Autowired
private ShopOrderBaseService shopOrderBaseService; private ShopOrderBaseService shopOrderBaseService;
@Lazy
@Autowired @Autowired
private ShopOrderReturnService shopOrderReturnService; private ShopOrderReturnService shopOrderReturnService;
@Lazy
@Autowired @Autowired
private ShopActivityGroupbuyStoreService shopActivityGroupbuyStoreService; private ShopActivityGroupbuyStoreService shopActivityGroupbuyStoreService;
@Autowired @Autowired
@ -279,6 +294,7 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
private EduService eduService; private EduService eduService;
@Autowired @Autowired
private ShopStoreActivityCodeService shopStoreActivityCodeService; private ShopStoreActivityCodeService shopStoreActivityCodeService;
@Lazy
@Autowired @Autowired
private MqMessageService mqMessageService; private MqMessageService mqMessageService;
@Autowired @Autowired
@ -8816,28 +8832,28 @@ public class ShopOrderBaseServiceImpl extends BaseServiceImpl<ShopOrderBaseMappe
* @param expireSeconds 过期时间 * @param expireSeconds 过期时间
* @return 是否发送成功 * @return 是否发送成功
*/ */
@Async // @Async("asyncExecutor")
@Override // @Override
public Boolean preSendExpiredSFOrderPushMessage(Integer storeId, String orderId, Long expireSeconds) { // public Boolean preSendExpiredSFOrderPushMessage(Integer storeId, String orderId, Long expireSeconds) {
try { // try {
// 构建延迟消息内容 // // 构建延迟消息内容
JSONObject jsonObject = new JSONObject(); // JSONObject jsonObject = new JSONObject();
jsonObject.put("category", MqConstant.DEAD_EVENT_CATE_ORDER_EXPIRED); // 消息分类1-订单超时消息 // jsonObject.put("category", MqConstant.DEAD_EVENT_CATE_ORDER_EXPIRED); // 消息分类1-订单超时消息
jsonObject.put("orderId", orderId); // 订单ID // jsonObject.put("orderId", orderId); // 订单ID
jsonObject.put("storeId", storeId); // 店铺ID // jsonObject.put("storeId", storeId); // 店铺ID
jsonObject.put("title", "有一笔已超时的订单!"); // 消息标题 // jsonObject.put("title", "有一笔已超时的订单!"); // 消息标题
jsonObject.put("message", "您有一笔已超时的订单[" + orderId + "],请及时处理。"); // 消息内容 // jsonObject.put("message", "您有一笔已超时的订单[" + orderId + "],请及时处理。"); // 消息内容
//
// 发送延迟消息 // // 发送延迟消息
mqMessageService.sendDelayMessage(jsonObject.toString(), expireSeconds * 1000); // 转换为毫秒 // mqMessageService.sendDelayMessage(jsonObject.toString(), expireSeconds * 1000); // 转换为毫秒
//
return true; // return true;
} catch (Exception e) { // } catch (Exception e) {
log.error("发送延迟订单超时消息失败店铺ID{}订单ID{},过期时间:{}秒", // log.error("发送延迟订单超时消息失败店铺ID{}订单ID{},过期时间:{}秒",
storeId, orderId, expireSeconds, e); // storeId, orderId, expireSeconds, e);
return false; // return false;
} // }
} // }
/** /**
* 取货单号格式化 * 取货单号格式化

View File

@ -140,6 +140,7 @@ public class ShopOrderReturnServiceImpl extends BaseServiceImpl<ShopOrderReturnM
private ShopOrderReturnMapper shopOrderReturnMapper; private ShopOrderReturnMapper shopOrderReturnMapper;
@Autowired @Autowired
private ShopOrderReturnItemService orderReturnItemService; private ShopOrderReturnItemService orderReturnItemService;
@Lazy
@Autowired @Autowired
private ShopStoreBaseService shopStoreBaseService; private ShopStoreBaseService shopStoreBaseService;
@Autowired @Autowired

View File

@ -16,6 +16,7 @@ import com.suisung.mall.shop.product.mapper.ShopProductIndexMapper;
import com.suisung.mall.shop.product.service.ShopProductBaseService; import com.suisung.mall.shop.product.service.ShopProductBaseService;
import com.suisung.mall.shop.product.service.ShopProductIndexService; import com.suisung.mall.shop.product.service.ShopProductIndexService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.Serializable; import java.io.Serializable;
@ -41,6 +42,7 @@ public class ShopProductIndexServiceImpl extends BaseServiceImpl<ShopProductInde
@Autowired @Autowired
private ShopProductIndexMapper shopProductIndexMapper; private ShopProductIndexMapper shopProductIndexMapper;
@Lazy
@Autowired @Autowired
private ShopProductBaseService shopProductBaseService; private ShopProductBaseService shopProductBaseService;

View File

@ -37,6 +37,7 @@ import com.suisung.mall.common.modules.store.ShopStoreActivityBase;
import com.suisung.mall.common.modules.store.ShopStoreActivityItem; import com.suisung.mall.common.modules.store.ShopStoreActivityItem;
import com.suisung.mall.common.modules.store.ShopStoreBase; import com.suisung.mall.common.modules.store.ShopStoreBase;
import com.suisung.mall.common.utils.*; import com.suisung.mall.common.utils.*;
import com.suisung.mall.core.web.service.RedisService;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl; import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import com.suisung.mall.shop.activity.service.*; import com.suisung.mall.shop.activity.service.*;
import com.suisung.mall.shop.base.service.AccountBaseConfigService; import com.suisung.mall.shop.base.service.AccountBaseConfigService;
@ -59,6 +60,7 @@ import com.suisung.mall.shop.user.service.ShopUserVoucherService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -83,18 +85,37 @@ import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
public class ShopStoreActivityBaseServiceImpl extends BaseServiceImpl<ShopStoreActivityBaseMapper, ShopStoreActivityBase> implements ShopStoreActivityBaseService { public class ShopStoreActivityBaseServiceImpl extends BaseServiceImpl<ShopStoreActivityBaseMapper, ShopStoreActivityBase> implements ShopStoreActivityBaseService {
private static final Logger logger = LoggerFactory.getLogger(ShopStoreActivityBaseServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(ShopStoreActivityBaseServiceImpl.class);
@Lazy
@Autowired @Autowired
ShopOrderBaseService shopOrderBaseService; ShopOrderBaseService shopOrderBaseService;
@Autowired @Autowired
ShopUserVoucherService shopUserVoucherService; ShopUserVoucherService shopUserVoucherService;
@Autowired @Autowired
private ShopProductIndexService shopProductIndexService; private ShopStoreActivityBaseMapper shopStoreActivityBaseMapper;
@Lazy
@Autowired @Autowired
private ShopActivityMarketingHistoryService shopActivityMarketingHistoryService; private ShopProductItemService shopProductItemService;
@Lazy
@Autowired
private ShopProductBaseService shopProductBaseService;
@Autowired
private ShopStoreActivityItemService shopStoreActivityItemService;
@Autowired
private ShopBaseActivityTypeService baseActivityTypeService;
@Autowired @Autowired
private ShopStoreBaseService shopStoreBaseService; private ShopStoreBaseService shopStoreBaseService;
@Autowired @Autowired
private ShopBaseActivityTypeService shopBaseActivityTypeService; private ShopProductIndexService shopProductIndexService;
@Autowired
private ShopBaseStateCodeService shopBaseStateCodeService;
@Autowired
private ShopBaseCurrencyService shopBaseCurrencyService;
@Autowired
private ShopProductImageService shopProductImageService;
@Autowired
private RedisService redisService;
@Autowired
private ShopActivityMarketingHistoryService shopActivityMarketingHistoryService;
@Autowired @Autowired
private UserInfoService userInfoService; private UserInfoService userInfoService;
@Autowired @Autowired
@ -108,30 +129,22 @@ public class ShopStoreActivityBaseServiceImpl extends BaseServiceImpl<ShopStoreA
@Autowired @Autowired
private ShopActivityCutpriceService shopActivityCutpriceService; private ShopActivityCutpriceService shopActivityCutpriceService;
@Autowired @Autowired
private ShopProductItemService shopProductItemService;
@Autowired
private ShopBaseCurrencyService shopBaseCurrencyService;
@Autowired
private ShopProductImageService shopProductImageService;
@Autowired
private ShopProductBaseService shopProductBaseService;
@Autowired
private ShopActivityLotteryHistoryService shopActivityLotteryHistoryService; private ShopActivityLotteryHistoryService shopActivityLotteryHistoryService;
@Autowired @Autowired
private ShopStoreActivityItemService shopStoreActivityItemService;
@Autowired
private ShopActivityGroupbuyStoreHistoryService activityGroupbuyStoreHistoryService; private ShopActivityGroupbuyStoreHistoryService activityGroupbuyStoreHistoryService;
@Autowired @Autowired
private ShopActivityGroupbookingService shopActivityGroupbookingService; private ShopActivityGroupbookingService shopActivityGroupbookingService;
@Autowired @Autowired
private ShopBaseStateCodeService shopBaseStateCodeService;
@Autowired
private ShopStoreActivityCodeService shopStoreActivityCodeService; private ShopStoreActivityCodeService shopStoreActivityCodeService;
@Autowired @Autowired
private ShopOrderDataService shopOrderDataService; private ShopOrderDataService shopOrderDataService;
@Autowired @Autowired
private AccountBaseConfigService accountBaseConfigService; private AccountBaseConfigService accountBaseConfigService;
@Lazy
@Autowired
private ShopBaseActivityTypeService shopBaseActivityTypeService;
/** /**
* 返回随机金额数组 分为单位 * 返回随机金额数组 分为单位
* *

View File

@ -11,6 +11,7 @@ import com.suisung.mall.shop.product.service.ShopProductBaseService;
import com.suisung.mall.shop.store.mapper.ShopStoreAnalyticsMapper; import com.suisung.mall.shop.store.mapper.ShopStoreAnalyticsMapper;
import com.suisung.mall.shop.store.service.ShopStoreAnalyticsService; import com.suisung.mall.shop.store.service.ShopStoreAnalyticsService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -30,6 +31,7 @@ import java.util.Map;
@Service @Service
public class ShopStoreAnalyticsServiceImpl extends BaseServiceImpl<ShopStoreAnalyticsMapper, ShopStoreAnalytics> implements ShopStoreAnalyticsService { public class ShopStoreAnalyticsServiceImpl extends BaseServiceImpl<ShopStoreAnalyticsMapper, ShopStoreAnalytics> implements ShopStoreAnalyticsService {
@Lazy
@Autowired @Autowired
private ShopProductBaseService shopProductBaseService; private ShopProductBaseService shopProductBaseService;

View File

@ -133,6 +133,7 @@ public class ShopStoreBaseServiceImpl extends BaseServiceImpl<ShopStoreBaseMappe
private InvoicingWarehouseBaseService invoicingWarehouseBaseService; private InvoicingWarehouseBaseService invoicingWarehouseBaseService;
@Autowired @Autowired
private ShopStoreBaseMapper shopStoreBaseMapper; private ShopStoreBaseMapper shopStoreBaseMapper;
@Lazy
@Autowired @Autowired
private ShopStoreAnalyticsService shopStoreAnalyticsService; private ShopStoreAnalyticsService shopStoreAnalyticsService;
@Autowired @Autowired

View File

@ -14,6 +14,7 @@ import com.suisung.mall.shop.store.service.ShopStoreAnalyticsService;
import com.suisung.mall.shop.store.service.ShopStoreBaseService; import com.suisung.mall.shop.store.service.ShopStoreBaseService;
import com.suisung.mall.shop.store.service.ShopStoreInfoService; import com.suisung.mall.shop.store.service.ShopStoreInfoService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.HashMap; import java.util.HashMap;
@ -43,6 +44,7 @@ public class ShopStoreInfoServiceImpl extends BaseServiceImpl<ShopStoreInfoMappe
@Autowired @Autowired
private ShopStoreBaseService shopStoreBaseService; private ShopStoreBaseService shopStoreBaseService;
@Lazy
@Autowired @Autowired
private ShopStoreAnalyticsService shopStoreAnalyticsService; private ShopStoreAnalyticsService shopStoreAnalyticsService;

View File

@ -55,6 +55,7 @@ import com.suisung.mall.shop.user.service.ShopUserVoucherService;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -83,6 +84,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
private final static Integer CART_TYPE_BUY = 1; //购买 private final static Integer CART_TYPE_BUY = 1; //购买
private final static Integer CART_TYPE_POINT = 2; //赠品 private final static Integer CART_TYPE_POINT = 2; //赠品
private final static Integer CART_TYPE_GIFT = 3; //积分兑换 private final static Integer CART_TYPE_GIFT = 3; //积分兑换
@Lazy
@Autowired @Autowired
private ShopProductItemService shopProductItemService; private ShopProductItemService shopProductItemService;
@Autowired @Autowired
@ -91,10 +93,12 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
private ShopChainBaseService shopChainBaseService; private ShopChainBaseService shopChainBaseService;
@Autowired @Autowired
private ShopChainItemService shopChainItemService; private ShopChainItemService shopChainItemService;
@Lazy
@Autowired @Autowired
private ShopProductBaseService shopProductBaseService; private ShopProductBaseService shopProductBaseService;
@Autowired @Autowired
private ShopStoreTransportTypeService shopStoreTransportTypeService; private ShopStoreTransportTypeService shopStoreTransportTypeService;
@Lazy
@Autowired @Autowired
private ShopStoreActivityBaseService shopStoreActivityBaseService; private ShopStoreActivityBaseService shopStoreActivityBaseService;
@Autowired @Autowired
@ -103,6 +107,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
private AccountService accountService; private AccountService accountService;
@Autowired @Autowired
private ShopStoreProductCategoryService productCategoryService; private ShopStoreProductCategoryService productCategoryService;
@Lazy
@Autowired @Autowired
private ShopProductIndexService productIndexService; private ShopProductIndexService productIndexService;
@Autowired @Autowired
@ -123,6 +128,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
private ShopUserVoucherService shopUserVoucherService; private ShopUserVoucherService shopUserVoucherService;
@Autowired @Autowired
private PayService payService; private PayService payService;
@Lazy
@Autowired @Autowired
private ShopOrderBaseService shopOrderBaseService; private ShopOrderBaseService shopOrderBaseService;
@Autowired @Autowired
@ -139,6 +145,7 @@ public class ShopUserCartServiceImpl extends BaseServiceImpl<ShopUserCartMapper,
private MessageService messageService; private MessageService messageService;
@Autowired @Autowired
private ShopProductInfoService shopProductInfoService; private ShopProductInfoService shopProductInfoService;
@Lazy
@Autowired @Autowired
private ShopProductIndexService shopProductIndexService; private ShopProductIndexService shopProductIndexService;
@Autowired @Autowired

View File

@ -35,6 +35,7 @@ import com.suisung.mall.shop.store.service.ShopStoreBaseService;
import com.suisung.mall.shop.user.mapper.ShopUserVoucherMapper; import com.suisung.mall.shop.user.mapper.ShopUserVoucherMapper;
import com.suisung.mall.shop.user.service.ShopUserVoucherService; import com.suisung.mall.shop.user.service.ShopUserVoucherService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -57,27 +58,24 @@ import static com.suisung.mall.common.utils.ContextUtil.getCurrentUser;
@Service @Service
public class ShopUserVoucherServiceImpl extends BaseServiceImpl<ShopUserVoucherMapper, ShopUserVoucher> implements ShopUserVoucherService { public class ShopUserVoucherServiceImpl extends BaseServiceImpl<ShopUserVoucherMapper, ShopUserVoucher> implements ShopUserVoucherService {
@Autowired
MessageService messageService;
@Autowired @Autowired
private ShopUserVoucherMapper shopUserVoucherMapper; private ShopUserVoucherMapper shopUserVoucherMapper;
@Lazy
@Autowired @Autowired
private ShopStoreActivityBaseService storeActivityBaseService; private ShopStoreActivityBaseService storeActivityBaseService;
@Lazy
@Autowired @Autowired
private ShopStoreBaseService shopStoreBaseService; private ShopStoreBaseService shopStoreBaseService;
@Autowired @Autowired
private ShopBaseCurrencyService shopBaseCurrencyService; private ShopBaseCurrencyService shopBaseCurrencyService;
@Autowired @Autowired
private ShopStoreActivityShareService shopStoreActivityShareService; private ShopStoreActivityShareService shopStoreActivityShareService;
@Autowired @Autowired
private PayService payService; private PayService payService;
@Autowired
MessageService messageService;
@Override @Override
public Map getActivityTotalVoucher(List<Integer> activity_ids, Integer user_id) { public Map getActivityTotalVoucher(List<Integer> activity_ids, Integer user_id) {
Map<String, Object> queryMap = new HashMap<>(); Map<String, Object> queryMap = new HashMap<>();
@ -369,14 +367,10 @@ public class ShopUserVoucherServiceImpl extends BaseServiceImpl<ShopUserVoucherM
shopUserVoucher.setVoucher_state_id(StateCode.VOUCHER_STATE_USED); shopUserVoucher.setVoucher_state_id(StateCode.VOUCHER_STATE_USED);
shopUserVoucher.setUser_voucher_activetime(date); shopUserVoucher.setUser_voucher_activetime(date);
boolean flag = edit(shopUserVoucher); boolean flag = edit(shopUserVoucher);
if (flag) { return flag;
return true;
}
} else { } else {
throw new ApiException(I18nUtil._("核销码无效或已过期,核销失败!")); throw new ApiException(I18nUtil._("核销码无效或已过期,核销失败!"));
} }
return false;
} }

View File

@ -6,5 +6,7 @@ spring:
jackson: jackson:
date-format: yyyy-MM-dd HH:mm:ss date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8 time-zone: GMT+8
# main:
# lazy-initialization: true
file: file:
upload-dir: /tmp/excel_uploads upload-dir: /tmp/excel_uploads