小程序店铺信息获取相关

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

@ -1,6 +1,7 @@
package com.czg.controller.admin;
import com.czg.account.dto.PageDTO;
import com.czg.account.dto.shopinfo.ShopDetailDTO;
import com.czg.account.dto.shopinfo.ShopInfoAddDTO;
import com.czg.account.dto.shopinfo.ShopInfoEditDTO;
import com.czg.account.entity.ShopInfo;
@ -42,7 +43,7 @@ public class ShopInfoController {
*/
@SaAdminCheckPermission("shopInfo:detail")
@GetMapping("/detail")
public CzgResult<ShopInfo> detail(Integer id) {
public CzgResult<ShopDetailDTO> detail(Integer id) {
return CzgResult.success(shopInfoService.detail(id));
}

View File

@ -0,0 +1,34 @@
package com.czg.controller.user;
import com.czg.account.entity.ShopExtend;
import com.czg.account.service.ShopExtendService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.mybatisflex.core.query.QueryWrapper;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
/**
* 店铺拓展信息
* @author Administrator
*/
@RestController
@RequestMapping("/user/shopExtend")
public class UShopExtendController {
@Resource
private ShopExtendService shopExtendService;
/**
* 根据key获取拓展信息
* @param shopId 店铺id
* @param autoKey key index_bg 首页 my_bg 个人中心 member_bg 会员卡 shopinfo_bg 商品列表 ticket_logo 小票logo
* @return 详细信息
*/
@GetMapping
public CzgResult<ShopExtend> get(Long shopId, @RequestParam String autoKey) {
return CzgResult.success(shopExtendService.getOne(new QueryWrapper().eq(ShopExtend::getShopId, shopId == null ? StpKit.USER.getShopId() : shopId).eq(ShopExtend::getAutoKey, autoKey)));
}
}

View File

@ -1,8 +1,10 @@
package com.czg.controller.user;
import com.czg.account.dto.shopinfo.ShopInfoByCodeDTO;
import com.czg.account.dto.shopinfo.ShopInfoDetailDTO;
import com.czg.account.service.ShopInfoService;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import jakarta.annotation.Resource;
import jakarta.validation.constraints.NotEmpty;
import org.springframework.web.bind.annotation.GetMapping;
@ -28,4 +30,13 @@ public class UShopInfoController {
public CzgResult<ShopInfoByCodeDTO> getByCode(@RequestParam @NotEmpty String tableCode, String lat, String lng) {
return CzgResult.success(shopInfoService.getByCode(tableCode, lat, lng, true));
}
/**
* 获取店铺详细信息
* @return 店铺信息
*/
@GetMapping("/detail")
public CzgResult<ShopInfoDetailDTO> get(Long shopId) {
return CzgResult.success(shopInfoService.getDetail(shopId == null ? StpKit.USER.getShopId() : shopId));
}
}

View File

@ -0,0 +1,14 @@
package com.czg.account.dto.shopinfo;
import com.czg.account.entity.ShopInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* @author Administrator
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class ShopDetailDTO extends ShopInfo {
private String account;
}

View File

@ -0,0 +1,29 @@
package com.czg.account.dto.shopinfo;
import com.czg.account.entity.ShopExtend;
import com.czg.account.entity.ShopInfo;
import com.czg.account.entity.ShopTable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
/**
* @author Administrator
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ShopInfoDetailDTO {
/**
* 店铺信息
*/
private ShopInfo shopInfo;
/**
* 店铺拓展信息列表主要为首页用户页面背景配置
*/
private Map<String, ShopExtend> shopExtend;
}

View File

@ -1,9 +1,7 @@
package com.czg.account.service;
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.ShopInfo;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
@ -18,7 +16,9 @@ public interface ShopInfoService extends IService<ShopInfo> {
Boolean edit(ShopInfoEditDTO shopInfoEditDTO);
ShopInfo detail(Integer id);
ShopDetailDTO detail(Integer id);
ShopInfoByCodeDTO getByCode(String tableCode, String lat, String lng, boolean checkState);
ShopInfoDetailDTO getDetail(Long shopId);
}

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