修改空指针报错的问题

This commit is contained in:
gong
2025-12-19 09:56:34 +08:00
parent 809fa0d4cf
commit e959e47e36
3 changed files with 6 additions and 7 deletions

View File

@@ -2,7 +2,6 @@ package com.czg.controller.admin;
import com.alibaba.fastjson2.JSONObject;
import com.czg.annotation.SaAdminCheckPermission;
import com.czg.controller.user.UPpPackageController;
import com.czg.market.service.PpPackageOrderService;
import com.czg.market.service.PpPackageService;
import com.czg.market.vo.PpOrderListVO;
@@ -97,7 +96,7 @@ public class PpPackageController {
@GetMapping("/switch")
@SaAdminCheckPermission(parentName = "套餐推广", value = "market:package:getSwitch", name = "获取套餐推广开关")
public CzgResult<Integer> getPackagePromotionSwitch() {
return CzgResult.success(ppPackageService.getPackagePromotionSwitch());
return CzgResult.success(ppPackageService.getPackagePromotionSwitch(StpKit.USER.getShopId()));
}
/**

View File

@@ -17,7 +17,7 @@ public interface PpPackageService extends IService<PpPackage> {
/**
* 获取套餐推广开关
*/
Integer getPackagePromotionSwitch();
Integer getPackagePromotionSwitch(Long shopId);
/**
* 更新套餐开关

View File

@@ -47,8 +47,8 @@ public class PpPackageServiceImpl extends ServiceImpl<PpPackageMapper, PpPackage
private ShopConfigService shopConfigService;
@Override
public Integer getPackagePromotionSwitch() {
Integer isPackagePromotion = shopConfigService.getById(StpKit.USER.getShopId()).getIsPackagePromotion();
public Integer getPackagePromotionSwitch(Long shopId) {
Integer isPackagePromotion = shopConfigService.getById(shopId).getIsPackagePromotion();
return isPackagePromotion == null ? SystemConstants.OneZero.ZERO : isPackagePromotion;
}
@@ -153,8 +153,8 @@ public class PpPackageServiceImpl extends ServiceImpl<PpPackageMapper, PpPackage
Long shopId = StpKit.USER.getShopId();
// 如果没有开启操作,直接返回空数据
ShopConfig shopConfig = shopConfigService.getById(shopId);
if (SystemConstants.OneZero.ZERO == shopConfig.getIsPackagePromotion()) {
Integer promotionSwitch = getPackagePromotionSwitch(shopId);
if (SystemConstants.OneZero.ZERO == promotionSwitch) {
log.info("没有开启套餐推广");
return new Page<>();
}