添加用户端接口

This commit is contained in:
gong
2025-12-18 18:27:20 +08:00
parent c0a958579c
commit 9a7256b82c
4 changed files with 141 additions and 51 deletions

View File

@@ -15,15 +15,13 @@ import com.czg.market.vo.PpPackagePageReqVo;
import com.czg.market.vo.PpPackageVO;
import com.czg.sa.StpKit;
import com.czg.service.market.mapper.PpPackageMapper;
import com.czg.service.market.mapper.PpPackageOrderMapper;
import com.czg.utils.AssertUtil;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.core.update.UpdateChain;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -40,16 +38,11 @@ import java.util.List;
@Service
public class PpPackageServiceImpl extends ServiceImpl<PpPackageMapper, PpPackage> implements PpPackageService {
@Resource
private PpPackageOrderMapper ppPackageOrderMapper;
@DubboReference
private ShopInfoService shopInfoService;
@DubboReference
private ShopConfigService shopConfigService;
@Autowired
private PpPackageMapper ppPackageMapper;
@Override
public Integer getPackagePromotionSwitch() {
@@ -59,8 +52,8 @@ public class PpPackageServiceImpl extends ServiceImpl<PpPackageMapper, PpPackage
@Override
@Transactional
public boolean updatePackagePromotionSwitch(Integer status) {
Long shopId = StpKit.USER.getShopId();
@CacheEvict(cacheNames = "shopInfo", key = "#shopId")
public boolean updatePackagePromotionSwitch(Integer status, Long shopId) {
ShopConfig shopConfig = new ShopConfig();
shopConfig.setIsPackagePromotion(status);
boolean update = shopConfigService.update(shopConfig, QueryWrapper.create().eq(ShopConfig::getId, shopId));
@@ -90,13 +83,8 @@ public class PpPackageServiceImpl extends ServiceImpl<PpPackageMapper, PpPackage
throw new CzgException("名称已存在");
}
ppPackage = BeanUtil.copyProperties(packageVO, PpPackage.class);
ppPackage = getEntityFromDto(packageVO);
ppPackage.setShopId(shopId);
ppPackage.setPackageContent(JSONArray.toJSONString(packageVO.getPackageContent()));
ppPackage.setUseWeeks(JSONArray.toJSONString(packageVO.getUseWeeks()));
ppPackage.setTieredDiscount(JSONArray.toJSONString(packageVO.getTieredDiscount()));
ppPackage.setImages(JSONArray.toJSONString(packageVO.getImages()));
ppPackage.setDetailImages(JSONArray.toJSONString(packageVO.getDetailImages()));
save(ppPackage);
}
@@ -115,17 +103,13 @@ public class PpPackageServiceImpl extends ServiceImpl<PpPackageMapper, PpPackage
throw new CzgException("无权限");
}
ppPackage = BeanUtil.copyProperties(packageVO, PpPackage.class);
ppPackage.setPackageContent(JSONArray.toJSONString(packageVO.getPackageContent()));
ppPackage.setUseWeeks(JSONArray.toJSONString(packageVO.getUseWeeks()));
ppPackage.setTieredDiscount(JSONArray.toJSONString(packageVO.getTieredDiscount()));
ppPackage.setImages(JSONArray.toJSONString(packageVO.getImages()));
ppPackage = getEntityFromDto(packageVO);
updateById(ppPackage);
}
@Override
@Transactional
public long deletePackage(Long id) {
public boolean deletePackage(Long id) {
Long shopId = StpKit.USER.getShopId();
PpPackage ppPackage = getPackageById(id);
@@ -134,26 +118,32 @@ public class PpPackageServiceImpl extends ServiceImpl<PpPackageMapper, PpPackage
throw new RuntimeException("无权限");
}
QueryWrapper wrapper = QueryWrapper.create().eq(PpPackageOrder::getPackageId, id)
.eq(PpPackageOrder::getStatus, PpPackageConstants.OrderStatus.PROCESSING);
long orderCount = ppPackageMapper.selectCountByQuery(wrapper);
if (orderCount > 0) {
return orderCount;
}
cancelProgressingPackageOrder(StpKit.USER.getShopId(), id);
ppPackage.setIsDel(1);
updateById(ppPackage);
return 0L;
ppPackage.setIsDel(SystemConstants.OneZero.ONE);
return updateById(ppPackage);
}
@Override
@Transactional
public void sureDeletePackage(Long id) {
PpPackage ppPackage = getPackageById(id);
ppPackage.setIsDel(1);
updateById(ppPackage);
public boolean updateOnlineStatus(Long id, Integer onlineStatus) {
if (!SystemConstants.OneZero.ZERO.equals(onlineStatus) && !SystemConstants.OneZero.ONE.equals(onlineStatus)) {
throw new CzgException("参数错误");
}
Long shopId = StpKit.USER.getShopId();
cancelProgressingPackageOrder(StpKit.USER.getShopId(), id);
PpPackage ppPackage = getPackageById(id);
if (!ppPackage.getShopId().equals(shopId)) {
throw new RuntimeException("无权限");
}
if (SystemConstants.OneZero.ZERO.equals(onlineStatus)) {
cancelProgressingPackageOrder(StpKit.USER.getShopId(), id);
}
ppPackage.setOnlineStatus(onlineStatus);
return updateById(ppPackage);
}
@Override
@@ -242,4 +232,14 @@ public class PpPackageServiceImpl extends ServiceImpl<PpPackageMapper, PpPackage
.eq(PpPackageOrder::getStatus, PpPackageConstants.OrderStatus.PROCESSING)
.update();
}
public PpPackage getEntityFromDto(PpPackageVO packageVO) {
PpPackage ppPackage = BeanUtil.copyProperties(packageVO, PpPackage.class);
ppPackage.setPackageContent(JSONArray.toJSONString(packageVO.getPackageContent()));
ppPackage.setUseWeeks(JSONArray.toJSONString(packageVO.getUseWeeks()));
ppPackage.setTieredDiscount(JSONArray.toJSONString(packageVO.getTieredDiscount()));
ppPackage.setImages(JSONArray.toJSONString(packageVO.getImages()));
ppPackage.setDetailImages(JSONArray.toJSONString(packageVO.getDetailImages()));
return ppPackage;
}
}