首页上半,
This commit is contained in:
@@ -37,6 +37,8 @@ public class LoginFilter implements Filter {
|
||||
"css/**",
|
||||
"js/**",
|
||||
"cashierService/phoneValidateCode",//验证码
|
||||
"cashierService/home/homePageUp",//首页上半
|
||||
"cashierService/home",//首页
|
||||
"cashierService/login/**"//登录部分接口不校验
|
||||
);
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto;
|
||||
import com.chaozhanggui.system.cashierservice.service.HomePageService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/home")
|
||||
@RequiredArgsConstructor
|
||||
public class HomeController {
|
||||
|
||||
@Resource
|
||||
private HomePageService homePageService;
|
||||
|
||||
@PostMapping
|
||||
public Result homePage(@RequestBody HomeDto homeDto){
|
||||
return homePageService.homePage(homeDto);
|
||||
}
|
||||
@PostMapping("/homePageUp")
|
||||
public Result homePageUp(@RequestHeader("environment") String environment){
|
||||
return homePageService.homePageUp(environment);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (TbPlatformDict)表数据库访问层
|
||||
*
|
||||
* @author lyf
|
||||
* @since 2024-04-01 14:38:09
|
||||
*/
|
||||
public interface TbPlatformDictMapper {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
TbPlatformDict queryById(Integer id);
|
||||
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @param tbPlatformDict 查询条件
|
||||
* @param pageable 分页对象
|
||||
* @return 对象列表
|
||||
*/
|
||||
List<TbPlatformDict> queryAllByLimit(TbPlatformDict tbPlatformDict, @Param("pageable") Pageable pageable);
|
||||
|
||||
List<TbPlatformDict> queryAllByType(@Param("type") String type,@Param("environment") String environment);
|
||||
/**
|
||||
* 统计总行数
|
||||
*
|
||||
* @param tbPlatformDict 查询条件
|
||||
* @return 总行数
|
||||
*/
|
||||
long count(TbPlatformDict tbPlatformDict);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param tbPlatformDict 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insert(TbPlatformDict tbPlatformDict);
|
||||
|
||||
/**
|
||||
* 批量新增数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<TbPlatformDict> 实例对象列表
|
||||
* @return 影响行数
|
||||
*/
|
||||
int insertBatch(@Param("entities") List<TbPlatformDict> entities);
|
||||
|
||||
/**
|
||||
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
|
||||
*
|
||||
* @param entities List<TbPlatformDict> 实例对象列表
|
||||
* @return 影响行数
|
||||
* @throws org.springframework.jdbc.BadSqlGrammarException 入参是空List的时候会抛SQL语句错误的异常,请自行校验入参
|
||||
*/
|
||||
int insertOrUpdateBatch(@Param("entities") List<TbPlatformDict> entities);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param tbPlatformDict 实例对象
|
||||
* @return 影响行数
|
||||
*/
|
||||
int update(TbPlatformDict tbPlatformDict);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteById(Integer id);
|
||||
|
||||
}
|
||||
|
||||
@@ -31,4 +31,6 @@ public interface TbProductSkuMapper {
|
||||
void updateAddStockById(@Param("skuId") String skuId, @Param("num") Integer num);
|
||||
|
||||
List<TbProductSku> selectAll();
|
||||
|
||||
List<TbProductSku> selectDownSku(@Param("list") List<Integer> productId);
|
||||
}
|
||||
@@ -1,9 +1,14 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopInfo;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.HomeVO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.UserDutyVo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
@Mapper
|
||||
public interface TbShopInfoMapper {
|
||||
@@ -24,4 +29,8 @@ public interface TbShopInfoMapper {
|
||||
TbShopInfo selectByQrCode(String qrcode);
|
||||
|
||||
TbShopInfo selectByPhone(String phone);
|
||||
|
||||
List<HomeVO> selectShopInfo(@Param("page")Integer page, @Param("size")Integer size);
|
||||
|
||||
List<UserDutyVo> searchUserDutyDetail(@Param("list") List<Integer> productId);
|
||||
}
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* (TbPlatformDict)实体类
|
||||
*
|
||||
* @author lyf
|
||||
* @since 2024-04-01 14:42:50
|
||||
*/
|
||||
public class TbPlatformDict implements Serializable {
|
||||
private static final long serialVersionUID = -34581903392247717L;
|
||||
|
||||
private Integer id;
|
||||
/**
|
||||
* 描述 同类型下 name唯一
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* homeDistrict--金刚区(首页) carousel--轮播图 tag--标签
|
||||
*/
|
||||
private String type;
|
||||
/**
|
||||
* 封面图
|
||||
*/
|
||||
private String coverImg;
|
||||
/**
|
||||
* 分享图
|
||||
*/
|
||||
private String shareImg;
|
||||
/**
|
||||
* 视频URL地址
|
||||
*/
|
||||
private String video;
|
||||
/**
|
||||
* 视频封面图
|
||||
*/
|
||||
private String videoCoverImg;
|
||||
/**
|
||||
* 相对跳转地址
|
||||
*/
|
||||
private String relUrl;
|
||||
/**
|
||||
* 绝对跳转地址
|
||||
*/
|
||||
private String absUrl;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Long createdAt;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Long updatedAt;
|
||||
/**
|
||||
* 收银端展示 0:不展示 1:展示
|
||||
*/
|
||||
private Integer isShowCash;
|
||||
/**
|
||||
* 小程序端展示 0:不展示 1:展示
|
||||
*/
|
||||
private Integer isShowMall;
|
||||
/**
|
||||
* APP端展示 0:不展示 1:展示
|
||||
*/
|
||||
private Integer isShowApp;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getCoverImg() {
|
||||
return coverImg;
|
||||
}
|
||||
|
||||
public void setCoverImg(String coverImg) {
|
||||
this.coverImg = coverImg;
|
||||
}
|
||||
|
||||
public String getShareImg() {
|
||||
return shareImg;
|
||||
}
|
||||
|
||||
public void setShareImg(String shareImg) {
|
||||
this.shareImg = shareImg;
|
||||
}
|
||||
|
||||
public String getVideo() {
|
||||
return video;
|
||||
}
|
||||
|
||||
public void setVideo(String video) {
|
||||
this.video = video;
|
||||
}
|
||||
|
||||
public String getVideoCoverImg() {
|
||||
return videoCoverImg;
|
||||
}
|
||||
|
||||
public void setVideoCoverImg(String videoCoverImg) {
|
||||
this.videoCoverImg = videoCoverImg;
|
||||
}
|
||||
|
||||
public String getRelUrl() {
|
||||
return relUrl;
|
||||
}
|
||||
|
||||
public void setRelUrl(String relUrl) {
|
||||
this.relUrl = relUrl;
|
||||
}
|
||||
|
||||
public String getAbsUrl() {
|
||||
return absUrl;
|
||||
}
|
||||
|
||||
public void setAbsUrl(String absUrl) {
|
||||
this.absUrl = absUrl;
|
||||
}
|
||||
|
||||
public Long getCreatedAt() {
|
||||
return createdAt;
|
||||
}
|
||||
|
||||
public void setCreatedAt(Long createdAt) {
|
||||
this.createdAt = createdAt;
|
||||
}
|
||||
|
||||
public Long getUpdatedAt() {
|
||||
return updatedAt;
|
||||
}
|
||||
|
||||
public void setUpdatedAt(Long updatedAt) {
|
||||
this.updatedAt = updatedAt;
|
||||
}
|
||||
|
||||
public Integer getIsShowCash() {
|
||||
return isShowCash;
|
||||
}
|
||||
|
||||
public void setIsShowCash(Integer isShowCash) {
|
||||
this.isShowCash = isShowCash;
|
||||
}
|
||||
|
||||
public Integer getIsShowMall() {
|
||||
return isShowMall;
|
||||
}
|
||||
|
||||
public void setIsShowMall(Integer isShowMall) {
|
||||
this.isShowMall = isShowMall;
|
||||
}
|
||||
|
||||
public Integer getIsShowApp() {
|
||||
return isShowApp;
|
||||
}
|
||||
|
||||
public void setIsShowApp(Integer isShowApp) {
|
||||
this.isShowApp = isShowApp;
|
||||
}
|
||||
|
||||
public Integer getSort() {
|
||||
return sort;
|
||||
}
|
||||
|
||||
public void setSort(Integer sort) {
|
||||
this.sort = sort;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
/**
|
||||
* @author 12847
|
||||
*/
|
||||
public class HomeDto {
|
||||
/**
|
||||
* 地址
|
||||
*/
|
||||
private String address;
|
||||
/**
|
||||
* 品类
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 1.理我最近 2.销量优先 3.价格优先
|
||||
*/
|
||||
private Integer orderBy;
|
||||
/**
|
||||
* 附近1KM 1 0
|
||||
*/
|
||||
private Integer distance;
|
||||
|
||||
private Integer page;
|
||||
|
||||
private Integer size;
|
||||
|
||||
public String getAddress() {
|
||||
return address;
|
||||
}
|
||||
|
||||
public void setAddress(String address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Integer getOrderBy() {
|
||||
return orderBy;
|
||||
}
|
||||
|
||||
public void setOrderBy(Integer orderBy) {
|
||||
this.orderBy = orderBy;
|
||||
}
|
||||
|
||||
public Integer getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(Integer distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public Integer getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(Integer page) {
|
||||
this.page = page;
|
||||
}
|
||||
|
||||
public Integer getSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
public void setSize(Integer size) {
|
||||
this.size = size;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.vo;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
public class DistrictVO {
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
private String icon;
|
||||
/**
|
||||
* 菜单名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 跳转地址
|
||||
*/
|
||||
private String relUrl;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.vo;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Data
|
||||
public class HomeUpVO {
|
||||
/**
|
||||
* 轮播图
|
||||
*/
|
||||
List<TbPlatformDict> carousel;
|
||||
/**
|
||||
* 金刚区
|
||||
*/
|
||||
List<TbPlatformDict> district;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,128 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
public class HomeVO {
|
||||
/**
|
||||
* 店铺名称
|
||||
*/
|
||||
private String shopName;
|
||||
/**
|
||||
* 距离
|
||||
*/
|
||||
private String distance;
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
private String productName;
|
||||
/**
|
||||
* 商品图片
|
||||
*/
|
||||
private String image;
|
||||
/**
|
||||
* 原价
|
||||
*/
|
||||
private BigDecimal originPrice;
|
||||
/**
|
||||
* 现价
|
||||
*/
|
||||
private BigDecimal salePrice;
|
||||
/**
|
||||
* 折扣
|
||||
*/
|
||||
private BigDecimal discount;
|
||||
/**
|
||||
* 共省金额
|
||||
*/
|
||||
private BigDecimal save;
|
||||
|
||||
/**
|
||||
* 销量
|
||||
*/
|
||||
private BigDecimal realSalesNumber;
|
||||
|
||||
private Integer productId;
|
||||
|
||||
public Integer getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Integer productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
|
||||
public String getShopName() {
|
||||
return shopName;
|
||||
}
|
||||
|
||||
public void setShopName(String shopName) {
|
||||
this.shopName = shopName;
|
||||
}
|
||||
|
||||
public String getDistance() {
|
||||
return distance;
|
||||
}
|
||||
|
||||
public void setDistance(String distance) {
|
||||
this.distance = distance;
|
||||
}
|
||||
|
||||
public String getProductName() {
|
||||
return productName;
|
||||
}
|
||||
|
||||
public void setProductName(String productName) {
|
||||
this.productName = productName;
|
||||
}
|
||||
|
||||
public String getImage() {
|
||||
return image;
|
||||
}
|
||||
|
||||
public void setImage(String image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
public BigDecimal getOriginPrice() {
|
||||
return originPrice;
|
||||
}
|
||||
|
||||
public void setOriginPrice(BigDecimal originPrice) {
|
||||
this.originPrice = originPrice;
|
||||
}
|
||||
|
||||
public BigDecimal getSalePrice() {
|
||||
return salePrice;
|
||||
}
|
||||
|
||||
public void setSalePrice(BigDecimal salePrice) {
|
||||
this.salePrice = salePrice;
|
||||
}
|
||||
|
||||
public BigDecimal getDiscount() {
|
||||
return discount;
|
||||
}
|
||||
|
||||
public void setDiscount(BigDecimal discount) {
|
||||
this.discount = discount;
|
||||
}
|
||||
|
||||
public BigDecimal getSave() {
|
||||
return save;
|
||||
}
|
||||
|
||||
public void setSave(BigDecimal save) {
|
||||
this.save = save;
|
||||
}
|
||||
|
||||
public BigDecimal getRealSalesNumber() {
|
||||
return realSalesNumber;
|
||||
}
|
||||
|
||||
public void setRealSalesNumber(BigDecimal realSalesNumber) {
|
||||
this.realSalesNumber = realSalesNumber;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.vo;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
public class UserDutyVo {
|
||||
|
||||
private BigDecimal number;
|
||||
|
||||
private Integer productId;
|
||||
|
||||
public BigDecimal getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(BigDecimal number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public Integer getProductId() {
|
||||
return productId;
|
||||
}
|
||||
|
||||
public void setProductId(Integer productId) {
|
||||
this.productId = productId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.vo;
|
||||
|
||||
/**
|
||||
* 轮播图
|
||||
* @author lyf
|
||||
*/
|
||||
public class carouselVO {
|
||||
/**
|
||||
* 封面图
|
||||
*/
|
||||
private String coverImg;
|
||||
/**
|
||||
* 跳转地址
|
||||
*/
|
||||
private String relUrl;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbProductSkuMapper;
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbShopInfoMapper;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbPlatformDict;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbProductSku;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.HomeDto;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.HomeUpVO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.HomeVO;
|
||||
import com.chaozhanggui.system.cashierservice.entity.vo.UserDutyVo;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author lyf
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class HomePageService {
|
||||
@Resource
|
||||
private TbShopInfoMapper shopInfoMapper;
|
||||
@Resource
|
||||
private TbProductSkuMapper productSkuMapper;
|
||||
@Resource
|
||||
private TbPlatformDictMapper platformDictMapper;
|
||||
|
||||
|
||||
public Result homePage(HomeDto homeDto){
|
||||
int beginNo;
|
||||
if(homeDto.getPage() <=0){
|
||||
beginNo = 0;
|
||||
}else{
|
||||
beginNo = (homeDto.getPage() - 1) * homeDto.getSize();
|
||||
}
|
||||
List<HomeVO> homeVO = shopInfoMapper.selectShopInfo(beginNo,homeDto.getSize());
|
||||
List<Integer> objects = new ArrayList<>();
|
||||
for (HomeVO o :homeVO) {
|
||||
objects.add(o.getProductId());
|
||||
}
|
||||
//原价现价
|
||||
List<TbProductSku> tbProductSkus = productSkuMapper.selectDownSku(objects);
|
||||
//销量
|
||||
List<UserDutyVo> userDutyVos = shopInfoMapper.searchUserDutyDetail(objects);
|
||||
//组装数据
|
||||
for (HomeVO o :homeVO) {
|
||||
for (TbProductSku sku :tbProductSkus) {
|
||||
if (o.getProductId().toString().equals(sku.getProductId())){
|
||||
o.setOriginPrice(sku.getOriginPrice() == null?BigDecimal.ZERO:sku.getOriginPrice());
|
||||
o.setSalePrice(sku.getSalePrice() == null?BigDecimal.ZERO:sku.getSalePrice());
|
||||
}
|
||||
}
|
||||
if (userDutyVos == null){
|
||||
o.setRealSalesNumber(BigDecimal.ZERO);
|
||||
}else {
|
||||
for (UserDutyVo duty : userDutyVos) {
|
||||
if (o.getProductId().equals(duty.getProductId())) {
|
||||
o.setRealSalesNumber(duty.getNumber());
|
||||
}else {
|
||||
o.setRealSalesNumber(BigDecimal.ZERO);
|
||||
}
|
||||
}
|
||||
}
|
||||
//共省金额
|
||||
o.setSave(o.getOriginPrice().subtract(o.getSalePrice()));
|
||||
if (o.getOriginPrice().compareTo(BigDecimal.ZERO) == 0){
|
||||
o.setDiscount(null);
|
||||
}else {
|
||||
o.setDiscount(o.getSalePrice().divide(o.getOriginPrice(), 2, RoundingMode.DOWN).multiply(new BigDecimal("10")));
|
||||
}
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS,homeVO);
|
||||
}
|
||||
|
||||
public Result homePageUp(String environment){
|
||||
HomeUpVO homeUpVO = new HomeUpVO();
|
||||
//轮播图
|
||||
List<TbPlatformDict> carouselList = platformDictMapper.queryAllByType("carousel",environment);
|
||||
homeUpVO.setCarousel(carouselList);
|
||||
//金刚区
|
||||
List<TbPlatformDict> districtList = platformDictMapper.queryAllByType("homeDistrict",environment);
|
||||
homeUpVO.setDistrict(districtList);
|
||||
return Result.success(CodeEnum.SUCCESS,homeUpVO);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user