Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9c82661351 | ||
|
|
6792450f6b | ||
|
|
22c04c61f5 |
@@ -0,0 +1,40 @@
|
||||
package com.chaozhanggui.system.cashierservice.controller;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopAd;
|
||||
import com.chaozhanggui.system.cashierservice.entity.dto.TbShopAdDto;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbShopAdService;
|
||||
import com.chaozhanggui.system.cashierservice.sign.CodeEnum;
|
||||
import com.chaozhanggui.system.cashierservice.sign.Result;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
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;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (TbShopAd)表控制层
|
||||
*
|
||||
* @author GYJ
|
||||
* @since 2024-08-19 14:25:09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("tbShopAd")
|
||||
public class TbShopAdController {
|
||||
|
||||
private final TbShopAdService tbShopAdService;
|
||||
|
||||
public TbShopAdController(@Qualifier("tbShopAdServiceImpl") TbShopAdService tbShopAdService) {
|
||||
this.tbShopAdService = tbShopAdService;
|
||||
}
|
||||
|
||||
|
||||
@GetMapping("/list")
|
||||
public Result list(@RequestParam(value = "shopId") Integer shopId) {
|
||||
List<TbShopAd> tbShopAds = tbShopAdService.shopAdList(shopId);
|
||||
return Result.success(CodeEnum.ENCRYPT, TbShopAdDto.convertShopAdDoToDtoList(tbShopAds));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.chaozhanggui.system.cashierservice.dao;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopAd;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (TbShopAd)表数据库访问层
|
||||
*
|
||||
* @author GYJ
|
||||
* @since 2024-08-19 14:25:09
|
||||
*/
|
||||
public interface TbShopAdDao {
|
||||
/**
|
||||
* 查询指定行数据
|
||||
*
|
||||
* @return 对象列表
|
||||
*/
|
||||
@Select("select * from fycashier.tb_shop_ad where (shop_id = #{songId} or shop_id = 1) and status=1")
|
||||
List<TbShopAd> shopAdList(Integer shopId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* (TbShopAd)实体类
|
||||
*
|
||||
* @author GYJ
|
||||
* @since 2024-08-19 14:25:09
|
||||
*/
|
||||
@Data
|
||||
public class TbShopAd implements Serializable {
|
||||
private static final long serialVersionUID = -34028307481923067L;
|
||||
/**
|
||||
* 自增id
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 店铺id,如果是通用广告则为0
|
||||
*/
|
||||
private Integer shopId;
|
||||
/**
|
||||
* 广告图片地址
|
||||
*/
|
||||
private String imgUrl;
|
||||
/**
|
||||
* 跳转页面路径
|
||||
*/
|
||||
private String linkPath;
|
||||
/**
|
||||
* 广告展示圆角
|
||||
*/
|
||||
private Integer borderRadius;
|
||||
/**
|
||||
* 弹窗展示位置:home首页,make_order点餐页
|
||||
*/
|
||||
private String showPosition;
|
||||
/**
|
||||
* 显示频率:only_one 仅首次展示, every_show 每次打开都展示,every_day 每天展示一次,three_day 每三天展示一次, seven_day 每七天展示一次, thirty_day 没30天展示一次
|
||||
*/
|
||||
private String frequency;
|
||||
/**
|
||||
* 广告状态:0未启用,1已启用
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updateTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.chaozhanggui.system.cashierservice.entity.dto;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopAd;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author GYJ
|
||||
*/
|
||||
@Data
|
||||
public class TbShopAdDto {
|
||||
private Integer id;
|
||||
/**
|
||||
* 店铺id,如果是通用广告则为0
|
||||
*/
|
||||
private Integer shopId;
|
||||
/**
|
||||
* 广告图片地址
|
||||
*/
|
||||
private String imgUrl;
|
||||
/**
|
||||
* 跳转页面路径
|
||||
*/
|
||||
private String linkPath;
|
||||
/**
|
||||
* 广告展示圆角
|
||||
*/
|
||||
private Integer borderRadius;
|
||||
/**
|
||||
* 弹窗展示位置:home首页,make_order点餐页
|
||||
*/
|
||||
private String showPosition;
|
||||
/**
|
||||
* 显示频率:only_one 仅首次展示, every_show 每次打开都展示,every_day 每天展示一次,three_day 每三天展示一次, seven_day 每七天展示一次, thirty_day 没30天展示一次
|
||||
*/
|
||||
private String frequency;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Long updateTime;
|
||||
|
||||
public static List<TbShopAdDto> convertShopAdDoToDtoList(List<TbShopAd> adList) {
|
||||
return adList.stream().map(TbShopAdDto::convertShopAdDoToDto).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static TbShopAdDto convertShopAdDoToDto(TbShopAd ad) {
|
||||
TbShopAdDto dto = new TbShopAdDto();
|
||||
dto.setId(ad.getId());
|
||||
dto.setShopId(ad.getShopId());
|
||||
dto.setImgUrl(ad.getImgUrl());
|
||||
dto.setLinkPath(ad.getLinkPath());
|
||||
dto.setBorderRadius(ad.getBorderRadius());
|
||||
dto.setShowPosition(ad.getShowPosition());
|
||||
dto.setFrequency(ad.getFrequency());
|
||||
dto.setUpdateTime(ad.getUpdateTime().getTime());
|
||||
return dto;
|
||||
}
|
||||
}
|
||||
@@ -374,6 +374,7 @@ public class ProductService {
|
||||
// HashSet<String> specSet = new HashSet<>();
|
||||
AtomicDouble sum = new AtomicDouble(0.0);
|
||||
BigDecimal lowerPrice = null;
|
||||
BigDecimal lowMemberPrice = null;
|
||||
for (TbProductSku item : tbProductSkus) {
|
||||
if (item.getRealSalesNumber() != null) {
|
||||
sum.addAndGet(item.getRealSalesNumber());
|
||||
@@ -381,45 +382,24 @@ public class ProductService {
|
||||
if (lowerPrice == null || lowerPrice.compareTo(item.getSalePrice()) > 0) {
|
||||
lowerPrice = item.getSalePrice();
|
||||
}
|
||||
|
||||
String specSnap = item.getSpecSnap();
|
||||
// if (specSnap != null) {
|
||||
// specSet.addAll(Arrays.asList(specSnap.split(",")));
|
||||
// }
|
||||
if (lowMemberPrice == null || lowMemberPrice.compareTo(item.getMemberPrice()) > 0) {
|
||||
lowMemberPrice = item.getMemberPrice();
|
||||
}
|
||||
}
|
||||
//销量
|
||||
// 销量
|
||||
it.setStockNumber(sum.intValue());
|
||||
|
||||
// 售价
|
||||
if (lowerPrice == null) {
|
||||
lowerPrice = BigDecimal.ZERO;
|
||||
}
|
||||
//售价
|
||||
it.setLowPrice(lowerPrice);
|
||||
// String tagSnap = skuResult != null ? skuResult.getTagSnap() : null;
|
||||
// if (tagSnap != null) {
|
||||
// JSONArray tagSnaps = JSONObject.parseArray(tagSnap);
|
||||
// JSONObject snapJSON;
|
||||
// JSONArray finalSnap = new JSONArray();
|
||||
// for (Object snap : tagSnaps) {
|
||||
// snapJSON = (JSONObject) snap;
|
||||
// String values = snapJSON.getString("value");
|
||||
// String finalValues = "";
|
||||
// if (StrUtil.isNotBlank(values)) {
|
||||
// String[] valueList = values.split(",");
|
||||
// for (String value : valueList) {
|
||||
// if (specSet.contains(value)) {
|
||||
// finalValues = finalValues + (value) + ",";
|
||||
// }
|
||||
// }
|
||||
// if (StrUtil.isNotBlank(finalValues)) {
|
||||
// finalValues = StrUtil.removeSuffix(finalValues, ",");
|
||||
// snapJSON.put("value", finalValues);
|
||||
// finalSnap.add(snapJSON);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// //sku Result
|
||||
// skuResult.setTagSnap(finalSnap.toJSONString());
|
||||
// }
|
||||
|
||||
// 会员价
|
||||
if (lowMemberPrice == null) {
|
||||
lowMemberPrice = BigDecimal.ZERO;
|
||||
}
|
||||
it.setLowMemberPrice(lowMemberPrice);
|
||||
it.setProductSkuResult(skuResult);
|
||||
});
|
||||
return products;
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.chaozhanggui.system.cashierservice.service;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopAd;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (TbShopAd)表服务接口
|
||||
*
|
||||
* @author GYJ
|
||||
* @since 2024-08-19 14:25:17
|
||||
*/
|
||||
public interface TbShopAdService {
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @return 查询结果
|
||||
*/
|
||||
List<TbShopAd> shopAdList(Integer shopId);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.chaozhanggui.system.cashierservice.service.impl;
|
||||
|
||||
import com.chaozhanggui.system.cashierservice.dao.TbShopAdDao;
|
||||
import com.chaozhanggui.system.cashierservice.entity.TbShopAd;
|
||||
import com.chaozhanggui.system.cashierservice.service.TbShopAdService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* (TbShopAd)表服务实现类
|
||||
*
|
||||
* @author GYJ
|
||||
* @since 2024-08-19 14:25:17
|
||||
*/
|
||||
@Service
|
||||
public class TbShopAdServiceImpl implements TbShopAdService {
|
||||
@Autowired
|
||||
private TbShopAdDao tbShopAdDao;
|
||||
|
||||
@Override
|
||||
public List<TbShopAd> shopAdList(Integer shopId) {
|
||||
System.out.println("shopId = " + shopId);
|
||||
return tbShopAdDao.shopAdList(shopId);
|
||||
}
|
||||
}
|
||||
22
src/main/resources/mapper/TbShopAdDao.xml
Normal file
22
src/main/resources/mapper/TbShopAdDao.xml
Normal file
@@ -0,0 +1,22 @@
|
||||
<?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.TbShopAdDao">
|
||||
|
||||
<resultMap type="com.chaozhanggui.system.cashierservice.entity.TbShopAd" id="TbShopAdMap">
|
||||
<result property="id" column="id" jdbcType="INTEGER"/>
|
||||
<result property="shopId" column="shop_id" jdbcType="INTEGER"/>
|
||||
<result property="imgUrl" column="img_url" jdbcType="VARCHAR"/>
|
||||
<result property="linkPath" column="link_path" jdbcType="VARCHAR"/>
|
||||
<result property="borderRadius" column="border_radius" jdbcType="INTEGER"/>
|
||||
<result property="showPosition" column="show_position" jdbcType="VARCHAR"/>
|
||||
<result property="frequency" column="frequency" jdbcType="VARCHAR"/>
|
||||
<result property="status" column="status" jdbcType="INTEGER"/>
|
||||
<result property="sort" column="sort" jdbcType="INTEGER"/>
|
||||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
|
||||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
|
||||
</resultMap>
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user