pad点餐详情修改

This commit is contained in:
张松 2025-04-07 10:55:32 +08:00
parent 89f57add06
commit 882a36fb94
7 changed files with 91 additions and 29 deletions

View File

@ -1,6 +1,7 @@
package com.czg.account.dto.pad;
import com.czg.product.entity.Product;
import com.czg.product.vo.ProductVO;
import lombok.Data;
import java.util.List;
@ -13,5 +14,5 @@ public class PadDetailDTO {
private Long id;
private Long padLayoutId;
private List<Long> productIdList;
private List<Product> productList;
private List<ProductVO> productList;
}

View File

@ -5,6 +5,7 @@ import com.czg.product.entity.Product;
import com.czg.product.entity.ProductStockFlow;
import com.czg.product.param.*;
import com.czg.product.vo.ProductStatisticsVo;
import com.czg.product.vo.ProductVO;
import com.mybatisflex.core.paginate.Page;
import com.mybatisflex.core.service.IService;
@ -127,4 +128,7 @@ public interface ProductService extends IService<Product> {
* @param records 商品数据集合
*/
void refreshProductStock(ProductDTO param, List<ProductDTO> records);
List<ProductVO> listAndLowPrice(Long shopId, List<Long> productIds);
}

View File

@ -0,0 +1,16 @@
package com.czg.product.vo;
import com.czg.product.entity.Product;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.math.BigDecimal;
/**
* @author Administrator
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class ProductVO extends Product {
private BigDecimal lowPrice;
}

View File

@ -6,6 +6,7 @@ import com.czg.account.service.*;
import com.czg.exception.ApiNotPrintException;
import com.czg.product.entity.Product;
import com.czg.product.service.ProductService;
import com.czg.product.vo.ProductVO;
import com.czg.service.account.mapper.PadProductCategoryDetailMapper;
import com.czg.utils.JoinQueryWrapper;
import com.czg.utils.PageUtil;
@ -57,7 +58,7 @@ public class PadProdServiceImpl implements PadProdService {
List<Long> productIds = padProductCategoryDetailMapper.selectListByQuery(new QueryWrapper().eq(PadProductCategoryDetail::getPadProductCategoryId, padProductCategory)).stream().map(PadProductCategoryDetail::getProductId).toList();
padDetailDTO.setProductIdList(productIds);
if (!productIds.isEmpty()) {
List<Product> products = productService.list(new QueryWrapper().in(Product::getId, productIds).eq(Product::getShopId, shopId));
List<ProductVO> products = productService.listAndLowPrice(shopId, productIds);
padDetailDTO.setProductList(products);
}

View File

@ -2,6 +2,7 @@ package com.czg.service.product.mapper;
import com.czg.product.dto.ProductDTO;
import com.czg.product.entity.Product;
import com.czg.product.vo.ProductVO;
import com.czg.product.vo.RecommendProVO;
import com.czg.product.vo.ShopProductInfoVo;
import com.czg.product.vo.ShopProductVo;
@ -47,4 +48,5 @@ public interface ProductMapper extends BaseMapper<Product> {
String getShopName(@Param("shopId") Long shopId);
List<ProductVO> productList(@Param("shopId") Long shopId, @Param("productIds") List<Long> productIds);
}

View File

@ -22,6 +22,7 @@ import com.czg.product.service.ProductService;
import com.czg.product.service.ProductStockFlowService;
import com.czg.product.service.SensitiveOperationService;
import com.czg.product.vo.ProductStatisticsVo;
import com.czg.product.vo.ProductVO;
import com.czg.sa.StpKit;
import com.czg.service.product.mapper.*;
import com.czg.utils.PageUtil;
@ -645,4 +646,9 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
record.setStockNumber(stock.getOrDefault(record.getId(), 0));
});
}
@Override
public List<ProductVO> listAndLowPrice(Long shopId, List<Long> productIds) {
return mapper.productList(shopId, productIds);
}
}

View File

@ -79,7 +79,7 @@
t2.member_price,
t1.cover_img,
t1.images,
t3.name as unit_name,
t3.name as unit_name,
t1.is_sold_stock,
t1.stock_number,
t1.type,
@ -88,25 +88,28 @@
t1.start_time,
t1.end_time,
t1.is_hot,
ifnull(t2.suit_num, 1) as suit_num,
ifnull(t2.suit_num, 1) as suit_num,
t1.select_spec_info,
t1.group_snap,
t1.pack_fee,
ifnull(t4.sales_volume, 0) as sales_volume
from tb_product t1
left join (select x.product_id,
x.id as sku_id,
MIN(x.sale_price) as sale_price,
x.origin_price,
x.member_price,
x.suit_num
from tb_prod_sku x
where x.is_del = 0
and x.is_grounding = 1
and x.shop_id = #{shopId}
group by x.product_id) t2 on t1.id = t2.product_id
left join tb_shop_prod_unit t3 on t1.unit_id = t3.id
left join (select product_id,sum(num) as sales_volume from tb_order_detail where pay_amount is not null group by product_id) t4 on t1.id = t4.product_id
left join (select x.product_id,
x.id as sku_id,
MIN(x.sale_price) as sale_price,
x.origin_price,
x.member_price,
x.suit_num
from tb_prod_sku x
where x.is_del = 0
and x.is_grounding = 1
and x.shop_id = #{shopId}
group by x.product_id) t2 on t1.id = t2.product_id
left join tb_shop_prod_unit t3 on t1.unit_id = t3.id
left join (select product_id, sum(num) as sales_volume
from tb_order_detail
where pay_amount is not null
group by product_id) t4 on t1.id = t4.product_id
</sql>
<select id="selectProductPage" resultType="com.czg.product.dto.ProductDTO">
<include refid="productQuery"/>
@ -155,8 +158,13 @@
</select>
<select id="selectCouponProBySaleNum" resultType="com.czg.product.vo.RecommendProVO">
SELECT a.name, b.origin_price, b.sale_price, a.cover_img, a.id,
b.real_sales_number saleNum, round(b.sale_price / b.origin_price, 2) * 10 discount
SELECT a.name,
b.origin_price,
b.sale_price,
a.cover_img,
a.id,
b.real_sales_number saleNum,
round(b.sale_price / b.origin_price, 2) * 10 discount
FROM tb_product AS a
LEFT JOIN tb_prod_sku AS b ON a.id = b.product_id
WHERE a.type = 'coupon'
@ -167,8 +175,8 @@
<select id="selectRecommendProductList" resultType="com.czg.product.vo.RecommendProVO">
select ifnull(
ROUND(ST_Distance_Sphere(POINT(b.lng, b.lat), POINT(#{lng}, #{lat})) / 1000, 2), 0) AS distance,
c.name, a.origin_price, a.sale_price, b.shop_name, b.districts, c.cover_img, b.logo, c.id,
a.real_sales_number saleNum, (round(a.sale_price / a.origin_price, 2) * 10) AS discount,
c.name, a.origin_price, a.sale_price, b.shop_name, b.districts, c.cover_img, b.logo, c.id,
a.real_sales_number saleNum, (round(a.sale_price / a.origin_price, 2) * 10) AS discount,
c.id productId, a.id skuId, b.id shopId
from tb_prod_sku as a
left join tb_product c on c.id=a.product_id
@ -208,17 +216,41 @@
</select>
<select id="getTodayProInfo" resultType="com.czg.product.vo.RecommendProVO">
select 1000 AS distance,
c.name, a.origin_price, a.sale_price, b.shop_name, b.districts, c.cover_img, b.logo, c.id,
a.real_sales_number saleNum, round(a.sale_price / a.origin_price, 2) * 10 discount,
c.id productId, a.id skuId, b.id shopId
select 1000 AS distance,
c.name,
a.origin_price,
a.sale_price,
b.shop_name,
b.districts,
c.cover_img,
b.logo,
c.id,
a.real_sales_number saleNum,
round(a.sale_price / a.origin_price, 2) * 10 discount,
c.id productId,
a.id skuId,
b.id shopId
from tb_prod_sku as a
left join tb_product c on c.id=a.product_id
left join tb_shop_info as b on a.shop_id=b.id
where c.group_category_id is not null and c.group_category_id != '[]' and c.create_time >= date_format(now(), '%Y-%m-%d 00:00:00')
left join tb_product c on c.id = a.product_id
left join tb_shop_info as b on a.shop_id = b.id
where c.group_category_id is not null
and c.group_category_id != '[]'
and c.create_time >= date_format(now(), '%Y-%m-%d 00:00:00')
</select>
<select id="getShopName" resultType="java.lang.String">
select shop_name from tb_shop_info where id = #{shopId}
select shop_name
from tb_shop_info
where id = #{shopId}
</select>
<select id="productList" resultType="com.czg.product.vo.ProductVO">
select a.*, min(b.sale_price) as lowPrice
from tb_product as a
left join tb_prod_sku as b on a.id = b.product_id
where a.shop_id = #{shopId}
<foreach collection="productIds" item="id" open="(" close=")" separator=",">
#{id}
</foreach>
GROUP BY a.id
</select>
<update id="updateProductStockNum">
update tb_product