小程序店铺信息获取相关

This commit is contained in:
张松
2025-02-27 14:31:02 +08:00
parent 2bce1acb69
commit 2bca77252c
7 changed files with 112 additions and 10 deletions

View File

@@ -4,9 +4,7 @@ import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.czg.account.dto.PageDTO;
import com.czg.account.dto.shopinfo.ShopInfoAddDTO;
import com.czg.account.dto.shopinfo.ShopInfoByCodeDTO;
import com.czg.account.dto.shopinfo.ShopInfoEditDTO;
import com.czg.account.dto.shopinfo.*;
import com.czg.account.entity.*;
import com.czg.account.service.*;
import com.czg.enums.StatusEnum;
@@ -24,7 +22,10 @@ import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* @author Administrator
@@ -40,6 +41,8 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
private ShopTableService shopTableService;
@Resource
private ShopUserService shopUserService;
@Resource
private ShopExtendService shopExtendService;
private ShopInfo getShopInfo(Long shopId) {
ShopInfo shopInfo = getById(shopId);
@@ -121,7 +124,7 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
}
@Override
public ShopInfo detail(Integer id) {
public ShopDetailDTO detail(Integer id) {
ShopInfo shopInfo = queryChain().eq(ShopInfo::getId, id == null ? StpKit.USER.getShopId() : id).one();
if (shopInfo == null) {
throw new ApiNotPrintException("店铺信息不存在");
@@ -131,8 +134,10 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
throw new ApiNotPrintException("店铺信息不存在");
}
ShopDetailDTO shopDetailDTO = BeanUtil.copyProperties(shopInfo, ShopDetailDTO.class);
SysUser sysUser = sysUserService.getById(shopInfo.getId());
return shopInfo;
shopDetailDTO.setAccount(sysUser.getAccount());
return shopDetailDTO;
}
@Override
@@ -156,4 +161,12 @@ public class ShopInfoServiceImpl extends ServiceImpl<ShopInfoMapper, ShopInfo> i
ShopUser shopUser = shopUserService.queryChain().eq(ShopUser::getShopId, shopInfo.getId()).eq(ShopUser::getUserId, StpKit.USER.getLoginIdAsLong()).one();
return new ShopInfoByCodeDTO(distance, shopInfo, shopTable, shopUser != null && shopUser.getIsVip() != null && shopUser.getIsVip() == 1);
}
@Override
public ShopInfoDetailDTO getDetail(Long shopId) {
ShopInfo shopInfo = getShopInfo(shopId);
List<ShopExtend> shopExtends = shopExtendService.listInfo(shopId, null);
Map<String, ShopExtend> shopExtendMap = shopExtends.stream().collect(Collectors.toMap(ShopExtend::getAutoKey, i -> i));
return new ShopInfoDetailDTO(shopInfo, shopExtendMap);
}
}