diff --git a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopInfoController.java b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopInfoController.java index 680cbb32..614a0d74 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopInfoController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/admin/ShopInfoController.java @@ -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 detail(Integer id) { + public CzgResult detail(Integer id) { return CzgResult.success(shopInfoService.detail(id)); } diff --git a/cash-api/account-server/src/main/java/com/czg/controller/user/UShopExtendController.java b/cash-api/account-server/src/main/java/com/czg/controller/user/UShopExtendController.java new file mode 100644 index 00000000..6560131f --- /dev/null +++ b/cash-api/account-server/src/main/java/com/czg/controller/user/UShopExtendController.java @@ -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 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))); + } +} diff --git a/cash-api/account-server/src/main/java/com/czg/controller/user/UShopInfoController.java b/cash-api/account-server/src/main/java/com/czg/controller/user/UShopInfoController.java index 5425ac77..752efea3 100644 --- a/cash-api/account-server/src/main/java/com/czg/controller/user/UShopInfoController.java +++ b/cash-api/account-server/src/main/java/com/czg/controller/user/UShopInfoController.java @@ -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 getByCode(@RequestParam @NotEmpty String tableCode, String lat, String lng) { return CzgResult.success(shopInfoService.getByCode(tableCode, lat, lng, true)); } + + /** + * 获取店铺详细信息 + * @return 店铺信息 + */ + @GetMapping("/detail") + public CzgResult get(Long shopId) { + return CzgResult.success(shopInfoService.getDetail(shopId == null ? StpKit.USER.getShopId() : shopId)); + } } diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/dto/shopinfo/ShopDetailDTO.java b/cash-common/cash-common-service/src/main/java/com/czg/account/dto/shopinfo/ShopDetailDTO.java new file mode 100644 index 00000000..716b0f15 --- /dev/null +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/dto/shopinfo/ShopDetailDTO.java @@ -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; +} diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/dto/shopinfo/ShopInfoDetailDTO.java b/cash-common/cash-common-service/src/main/java/com/czg/account/dto/shopinfo/ShopInfoDetailDTO.java new file mode 100644 index 00000000..5cfaf3be --- /dev/null +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/dto/shopinfo/ShopInfoDetailDTO.java @@ -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 shopExtend; +} diff --git a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopInfoService.java b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopInfoService.java index c2dc5c8e..8bd581bb 100644 --- a/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopInfoService.java +++ b/cash-common/cash-common-service/src/main/java/com/czg/account/service/ShopInfoService.java @@ -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 { 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); } diff --git a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopInfoServiceImpl.java b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopInfoServiceImpl.java index ed6d3258..08e19912 100644 --- a/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopInfoServiceImpl.java +++ b/cash-service/account-service/src/main/java/com/czg/service/account/service/impl/ShopInfoServiceImpl.java @@ -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 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 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 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 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 shopExtends = shopExtendService.listInfo(shopId, null); + Map shopExtendMap = shopExtends.stream().collect(Collectors.toMap(ShopExtend::getAutoKey, i -> i)); + return new ShopInfoDetailDTO(shopInfo, shopExtendMap); + } }