首页上半,
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);
|
||||
}
|
||||
}
|
||||
248
src/main/resources/mapper/TbPlatformDictMapper.xml
Normal file
248
src/main/resources/mapper/TbPlatformDictMapper.xml
Normal file
@@ -0,0 +1,248 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.chaozhanggui.system.cashierservice.dao.TbPlatformDictMapper">
|
||||
|
||||
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbPlatformDict" id="TbPlatformDictMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="name" column="name" jdbcType="VARCHAR"/>
|
||||
<result property="type" column="type" jdbcType="VARCHAR"/>
|
||||
<result property="coverImg" column="cover_img" jdbcType="VARCHAR"/>
|
||||
<result property="shareImg" column="share_img" jdbcType="VARCHAR"/>
|
||||
<result property="video" column="video" jdbcType="VARCHAR"/>
|
||||
<result property="videoCoverImg" column="video_cover_img" jdbcType="VARCHAR"/>
|
||||
<result property="relUrl" column="rel_url" jdbcType="VARCHAR"/>
|
||||
<result property="absUrl" column="abs_url" jdbcType="VARCHAR"/>
|
||||
<result property="createdAt" column="created_at" jdbcType="INTEGER"/>
|
||||
<result property="updatedAt" column="updated_at" jdbcType="INTEGER"/>
|
||||
<result property="isShowCash" column="is_show_cash" jdbcType="INTEGER"/>
|
||||
<result property="isShowMall" column="is_show_mall" jdbcType="INTEGER"/>
|
||||
<result property="isShowApp" column="is_show_app" jdbcType="INTEGER"/>
|
||||
<result property="sort" column="sort" jdbcType="INTEGER"/>
|
||||
</resultMap>
|
||||
|
||||
<!--查询单个-->
|
||||
<select id="queryById" resultMap="TbPlatformDictMap">
|
||||
select
|
||||
id, name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort
|
||||
from tb_platform_dict
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<!--查询指定行数据-->
|
||||
<select id="queryAllByLimit" resultMap="TbPlatformDictMap">
|
||||
select
|
||||
id, name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort
|
||||
from tb_platform_dict
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name = #{name}
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
and type = #{type}
|
||||
</if>
|
||||
<if test="coverImg != null and coverImg != ''">
|
||||
and cover_img = #{coverImg}
|
||||
</if>
|
||||
<if test="shareImg != null and shareImg != ''">
|
||||
and share_img = #{shareImg}
|
||||
</if>
|
||||
<if test="video != null and video != ''">
|
||||
and video = #{video}
|
||||
</if>
|
||||
<if test="videoCoverImg != null and videoCoverImg != ''">
|
||||
and video_cover_img = #{videoCoverImg}
|
||||
</if>
|
||||
<if test="relUrl != null and relUrl != ''">
|
||||
and rel_url = #{relUrl}
|
||||
</if>
|
||||
<if test="absUrl != null and absUrl != ''">
|
||||
and abs_url = #{absUrl}
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
and created_at = #{createdAt}
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
and updated_at = #{updatedAt}
|
||||
</if>
|
||||
<if test="isShowCash != null">
|
||||
and is_show_cash = #{isShowCash}
|
||||
</if>
|
||||
<if test="isShowMall != null">
|
||||
and is_show_mall = #{isShowMall}
|
||||
</if>
|
||||
<if test="isShowApp != null">
|
||||
and is_show_app = #{isShowApp}
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
and sort = #{sort}
|
||||
</if>
|
||||
</where>
|
||||
limit #{pageable.offset}, #{pageable.pageSize}
|
||||
</select>
|
||||
|
||||
<!--统计总行数-->
|
||||
<select id="count" resultType="java.lang.Long">
|
||||
select count(1)
|
||||
from tb_platform_dict
|
||||
<where>
|
||||
<if test="id != null">
|
||||
and id = #{id}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name = #{name}
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
and type = #{type}
|
||||
</if>
|
||||
<if test="coverImg != null and coverImg != ''">
|
||||
and cover_img = #{coverImg}
|
||||
</if>
|
||||
<if test="shareImg != null and shareImg != ''">
|
||||
and share_img = #{shareImg}
|
||||
</if>
|
||||
<if test="video != null and video != ''">
|
||||
and video = #{video}
|
||||
</if>
|
||||
<if test="videoCoverImg != null and videoCoverImg != ''">
|
||||
and video_cover_img = #{videoCoverImg}
|
||||
</if>
|
||||
<if test="relUrl != null and relUrl != ''">
|
||||
and rel_url = #{relUrl}
|
||||
</if>
|
||||
<if test="absUrl != null and absUrl != ''">
|
||||
and abs_url = #{absUrl}
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
and created_at = #{createdAt}
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
and updated_at = #{updatedAt}
|
||||
</if>
|
||||
<if test="isShowCash != null">
|
||||
and is_show_cash = #{isShowCash}
|
||||
</if>
|
||||
<if test="isShowMall != null">
|
||||
and is_show_mall = #{isShowMall}
|
||||
</if>
|
||||
<if test="isShowApp != null">
|
||||
and is_show_app = #{isShowApp}
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
and sort = #{sort}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
<select id="queryAllByType" resultType="com.chaozhanggui.system.cashierservice.entity.TbPlatformDict">
|
||||
select
|
||||
id, name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort
|
||||
from tb_platform_dict
|
||||
<where>
|
||||
<if test="type != null and type != ''">
|
||||
type = #{type}
|
||||
</if>
|
||||
<if test="environment == app">
|
||||
and is_show_mall = 1
|
||||
</if>
|
||||
<if test="environment == wx">
|
||||
and is_show_app = 1
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!--新增所有列-->
|
||||
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_platform_dict(name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort)
|
||||
values (#{name}, #{type}, #{coverImg}, #{shareImg}, #{video}, #{videoCoverImg}, #{relUrl}, #{absUrl}, #{createdAt}, #{updatedAt}, #{isShowCash}, #{isShowMall}, #{isShowApp}, #{sort})
|
||||
</insert>
|
||||
|
||||
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_platform_dict(name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.name}, #{entity.type}, #{entity.coverImg}, #{entity.shareImg}, #{entity.video}, #{entity.videoCoverImg}, #{entity.relUrl}, #{entity.absUrl}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.isShowCash}, #{entity.isShowMall}, #{entity.isShowApp}, #{entity.sort})
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
|
||||
insert into tb_platform_dict(name, type, cover_img, share_img, video, video_cover_img, rel_url, abs_url, created_at, updated_at, is_show_cash, is_show_mall, is_show_app, sort)
|
||||
values
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(#{entity.name}, #{entity.type}, #{entity.coverImg}, #{entity.shareImg}, #{entity.video}, #{entity.videoCoverImg}, #{entity.relUrl}, #{entity.absUrl}, #{entity.createdAt}, #{entity.updatedAt}, #{entity.isShowCash}, #{entity.isShowMall}, #{entity.isShowApp}, #{entity.sort})
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
name = values(name),
|
||||
type = values(type),
|
||||
cover_img = values(cover_img),
|
||||
share_img = values(share_img),
|
||||
video = values(video),
|
||||
video_cover_img = values(video_cover_img),
|
||||
rel_url = values(rel_url),
|
||||
abs_url = values(abs_url),
|
||||
created_at = values(created_at),
|
||||
updated_at = values(updated_at),
|
||||
is_show_cash = values(is_show_cash),
|
||||
is_show_mall = values(is_show_mall),
|
||||
is_show_app = values(is_show_app),
|
||||
sort = values(sort)
|
||||
</insert>
|
||||
|
||||
<!--通过主键修改数据-->
|
||||
<update id="update">
|
||||
update tb_platform_dict
|
||||
<set>
|
||||
<if test="name != null and name != ''">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
type = #{type},
|
||||
</if>
|
||||
<if test="coverImg != null and coverImg != ''">
|
||||
cover_img = #{coverImg},
|
||||
</if>
|
||||
<if test="shareImg != null and shareImg != ''">
|
||||
share_img = #{shareImg},
|
||||
</if>
|
||||
<if test="video != null and video != ''">
|
||||
video = #{video},
|
||||
</if>
|
||||
<if test="videoCoverImg != null and videoCoverImg != ''">
|
||||
video_cover_img = #{videoCoverImg},
|
||||
</if>
|
||||
<if test="relUrl != null and relUrl != ''">
|
||||
rel_url = #{relUrl},
|
||||
</if>
|
||||
<if test="absUrl != null and absUrl != ''">
|
||||
abs_url = #{absUrl},
|
||||
</if>
|
||||
<if test="createdAt != null">
|
||||
created_at = #{createdAt},
|
||||
</if>
|
||||
<if test="updatedAt != null">
|
||||
updated_at = #{updatedAt},
|
||||
</if>
|
||||
<if test="isShowCash != null">
|
||||
is_show_cash = #{isShowCash},
|
||||
</if>
|
||||
<if test="isShowMall != null">
|
||||
is_show_mall = #{isShowMall},
|
||||
</if>
|
||||
<if test="isShowApp != null">
|
||||
is_show_app = #{isShowApp},
|
||||
</if>
|
||||
<if test="sort != null">
|
||||
sort = #{sort},
|
||||
</if>
|
||||
</set>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<!--通过主键删除-->
|
||||
<delete id="deleteById">
|
||||
delete from tb_platform_dict where id = #{id}
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -355,4 +355,19 @@
|
||||
<select id="selectAll" resultType="com.chaozhanggui.system.cashierservice.entity.TbProductSku">
|
||||
select * from tb_product_sku
|
||||
</select>
|
||||
<select id="selectDownSku" resultType="com.chaozhanggui.system.cashierservice.entity.TbProductSku">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
tb_product_sku
|
||||
WHERE
|
||||
product_id IN
|
||||
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
GROUP BY
|
||||
product_id
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -617,4 +617,31 @@
|
||||
<select id="selectByPhone" resultMap="BaseResultMap">
|
||||
select * from tb_shop_info where account=#{phone}
|
||||
</select>
|
||||
<select id="selectShopInfo" resultType="com.chaozhanggui.system.cashierservice.entity.vo.HomeVO">
|
||||
SELECT
|
||||
shop.shop_name shopName,
|
||||
product.`name` productName,
|
||||
product.cover_img image,
|
||||
product.id productId
|
||||
FROM
|
||||
tb_shop_info shop
|
||||
LEFT JOIN tb_product product ON shop.id = product.shop_id
|
||||
WHERE
|
||||
product.is_hot = 1
|
||||
Limit #{page}, #{size}
|
||||
</select>
|
||||
<select id="searchUserDutyDetail" resultType="com.chaozhanggui.system.cashierservice.entity.vo.UserDutyVo">
|
||||
SELECT
|
||||
sum( num ),
|
||||
product_id
|
||||
FROM
|
||||
tb_shop_user_duty_detail
|
||||
WHERE
|
||||
product_id IN
|
||||
<foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
</foreach>
|
||||
GROUP BY
|
||||
product_id
|
||||
</select>
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user