master
RIceWqy 2 years ago
parent 582905f25b
commit 2c3dfdb00d

@ -96,15 +96,17 @@ public class MyOrderController {
orderShopDto.setCreateTime(order.getCreateTime()); orderShopDto.setCreateTime(order.getCreateTime());
orderShopDto.setRemarks(order.getRemarks()); orderShopDto.setRemarks(order.getRemarks());
orderShopDto.setStatus(order.getStatus()); orderShopDto.setStatus(order.getStatus());
orderShopDto.setActualTotalScore(order.getActualTotalScore());
double total = 0.0; /* double total = 0.0;
Integer totalNum = 0; Integer totalNum = 0;
for (OrderItemDto orderItem : orderShopDto.getOrderItemDtos()) { for (OrderItemDto orderItem : orderShopDto.getOrderItemDtos()) {
if (orderItem.getProductType() != 2) {
total = Arith.add(total, orderItem.getProductTotalAmount()); total = Arith.add(total, orderItem.getProductTotalAmount());
totalNum += orderItem.getProdCount();
} }
orderShopDto.setTotal(total); totalNum += orderItem.getProdCount();
orderShopDto.setTotalNum(totalNum); }*/
orderShopDto.setTotal(order.getTotal());
orderShopDto.setTotalNum(order.getProductNums());
return ServerResponseEntity.success(orderShopDto); return ServerResponseEntity.success(orderShopDto);
} }

@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -95,6 +96,7 @@ public class OrderController {
double total = 0.0; double total = 0.0;
int totalCount = 0; int totalCount = 0;
double orderReduce = 0.0; double orderReduce = 0.0;
int totalScore = 0;
for (ShopCartDto shopCart : shopCarts) { for (ShopCartDto shopCart : shopCarts) {
// 每个店铺的订单信息 // 每个店铺的订单信息
@ -120,6 +122,7 @@ public class OrderController {
total = Arith.add(total, shopCartOrder.getTotal()); total = Arith.add(total, shopCartOrder.getTotal());
totalCount = totalCount + shopCartOrder.getTotalCount(); totalCount = totalCount + shopCartOrder.getTotalCount();
orderReduce = Arith.add(orderReduce, shopCartOrder.getShopReduce()); orderReduce = Arith.add(orderReduce, shopCartOrder.getShopReduce());
totalScore += shopCartOrder.getActualTotalScore();
shopCartOrders.add(shopCartOrder); shopCartOrders.add(shopCartOrder);
@ -130,7 +133,7 @@ public class OrderController {
shopCartOrderMergerDto.setTotalCount(totalCount); shopCartOrderMergerDto.setTotalCount(totalCount);
shopCartOrderMergerDto.setShopCartOrders(shopCartOrders); shopCartOrderMergerDto.setShopCartOrders(shopCartOrders);
shopCartOrderMergerDto.setOrderReduce(orderReduce); shopCartOrderMergerDto.setOrderReduce(orderReduce);
shopCartOrderMergerDto.setActualTotalScore(totalScore);
shopCartOrderMergerDto = orderService.putConfirmOrderCache(userId, shopCartOrderMergerDto); shopCartOrderMergerDto = orderService.putConfirmOrderCache(userId, shopCartOrderMergerDto);
return ServerResponseEntity.success(shopCartOrderMergerDto); return ServerResponseEntity.success(shopCartOrderMergerDto);
@ -165,7 +168,6 @@ public class OrderController {
List<Order> orders = orderService.submit(userId, mergerOrder); List<Order> orders = orderService.submit(userId, mergerOrder);
StringBuilder orderNumbers = new StringBuilder(); StringBuilder orderNumbers = new StringBuilder();
for (Order order : orders) { for (Order order : orders) {
orderNumbers.append(order.getOrderNumber()).append(","); orderNumbers.append(order.getOrderNumber()).append(",");

@ -10,6 +10,7 @@
package com.yami.shop.api.controller; package com.yami.shop.api.controller;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.bean.app.dto.ProductDto; import com.yami.shop.bean.app.dto.ProductDto;
import com.yami.shop.bean.app.dto.TagProductDto; import com.yami.shop.bean.app.dto.TagProductDto;
@ -26,7 +27,6 @@ import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import cn.hutool.core.bean.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
@ -57,11 +57,8 @@ public class ProdController {
@GetMapping("/pageProd") @GetMapping("/pageProd")
@Operation(summary = "通过分类id商品列表信息", description = "根据分类ID获取该分类下所有的商品列表信息") @Operation(summary = "通过分类id商品列表信息", description = "根据分类ID获取该分类下所有的商品列表信息")
@Parameters({ @Parameters({@Parameter(name = "categoryId", description = "分类ID", required = true),})
@Parameter(name = "categoryId", description = "分类ID" , required = true), public ServerResponseEntity<IPage<ProductDto>> prodList(@RequestParam(value = "categoryId") Long categoryId, PageParam<ProductDto> page) {
})
public ServerResponseEntity<IPage<ProductDto>> prodList(
@RequestParam(value = "categoryId") Long categoryId,PageParam<ProductDto> page) {
IPage<ProductDto> productPage = prodService.pageByCategoryId(page, categoryId); IPage<ProductDto> productPage = prodService.pageByCategoryId(page, categoryId);
return ServerResponseEntity.success(productPage); return ServerResponseEntity.success(productPage);
} }
@ -128,4 +125,17 @@ public class ProdController {
List<TagProductDto> productDtoList = prodService.tagProdList(); List<TagProductDto> productDtoList = prodService.tagProdList();
return ServerResponseEntity.success(productDtoList); return ServerResponseEntity.success(productDtoList);
} }
@GetMapping("/prodListByMember")
@Operation(summary = "获取会员专区商品", description = "获取会员专区商品")
public ServerResponseEntity<IPage<ProductDto>> prodListByMember( PageParam<ProductDto> page) {
IPage<ProductDto> productPage = prodService.pageByMember(page);
return ServerResponseEntity.success(productPage);
}
@GetMapping("/prodListByScore")
@Operation(summary = "获取会员专区商品", description = "获取会员专区商品")
public ServerResponseEntity<IPage<ProductDto>> prodListByScore( PageParam<ProductDto> page) {
IPage<ProductDto> productPage = prodService.pageByScore(page);
return ServerResponseEntity.success(productPage);
}
} }

@ -20,19 +20,19 @@ import com.yami.shop.bean.event.ShopCartEvent;
import com.yami.shop.bean.model.Basket; import com.yami.shop.bean.model.Basket;
import com.yami.shop.bean.model.Product; import com.yami.shop.bean.model.Product;
import com.yami.shop.bean.model.Sku; import com.yami.shop.bean.model.Sku;
import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.common.util.Arith; import com.yami.shop.common.util.Arith;
import com.yami.shop.security.api.util.SecurityUtils; import com.yami.shop.security.api.util.SecurityUtils;
import com.yami.shop.service.BasketService; import com.yami.shop.service.BasketService;
import com.yami.shop.service.ProductService; import com.yami.shop.service.ProductService;
import com.yami.shop.service.SkuService; import com.yami.shop.service.SkuService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import com.yami.shop.common.response.ServerResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -214,10 +214,10 @@ public class ShopCartController {
// 根据店铺ID划分item // 根据店铺ID划分item
Map<Long, List<ShopCartItemDto>> shopCartMap = chooseShopCartItems.stream().collect(Collectors.groupingBy(ShopCartItemDto::getShopId)); Map<Long, List<ShopCartItemDto>> shopCartMap = chooseShopCartItems.stream().collect(Collectors.groupingBy(ShopCartItemDto::getShopId));
double total = 0.0; double total = 0.0;
int count = 0; int count = 0;
double reduce = 0.0; double reduce = 0.0;
int totalScore = 0;
for (Long shopId : shopCartMap.keySet()) { for (Long shopId : shopCartMap.keySet()) {
//获取店铺的所有商品项 //获取店铺的所有商品项
List<ShopCartItemDto> shopCartItemDtoList = shopCartMap.get(shopId); List<ShopCartItemDto> shopCartItemDtoList = shopCartMap.get(shopId);
@ -234,7 +234,12 @@ public class ShopCartController {
for (ShopCartItemDto shopCartItem : shopCartItems) { for (ShopCartItemDto shopCartItem : shopCartItems) {
count = shopCartItem.getProdCount() + count; count = shopCartItem.getProdCount() + count;
if (shopCartItem.getProductType() != 2) {
total = Arith.add(shopCartItem.getProductTotalAmount(), total); total = Arith.add(shopCartItem.getProductTotalAmount(), total);
} else {
totalScore += (shopCartItem.getPayScore() * shopCartItem.getProdCount());
}
} }
} }
} }
@ -242,6 +247,7 @@ public class ShopCartController {
shopCartAmountDto.setCount(count); shopCartAmountDto.setCount(count);
shopCartAmountDto.setTotalMoney(total); shopCartAmountDto.setTotalMoney(total);
shopCartAmountDto.setSubtractMoney(reduce); shopCartAmountDto.setSubtractMoney(reduce);
shopCartAmountDto.setTotalScore(totalScore);
shopCartAmountDto.setFinalMoney(Arith.sub(shopCartAmountDto.getTotalMoney(), shopCartAmountDto.getSubtractMoney())); shopCartAmountDto.setFinalMoney(Arith.sub(shopCartAmountDto.getTotalMoney(), shopCartAmountDto.getSubtractMoney()));
return ServerResponseEntity.success(shopCartAmountDto); return ServerResponseEntity.success(shopCartAmountDto);

@ -32,6 +32,7 @@ import org.springframework.stereotype.Component;
/** /**
* *
*
* @author LGH * @author LGH
*/ */
@Component("defaultConfirmOrderListener") @Component("defaultConfirmOrderListener")
@ -68,7 +69,7 @@ public class ConfirmOrderListener {
int totalCount = 0; int totalCount = 0;
double transfee = 0.0; double transfee = 0.0;
int totalScore = 0;
for (ShopCartItemDto shopCartItem : event.getShopCartItems()) { for (ShopCartItemDto shopCartItem : event.getShopCartItems()) {
// 获取商品信息 // 获取商品信息
Product product = productService.getProductByProdId(shopCartItem.getProdId()); Product product = productService.getProductByProdId(shopCartItem.getProdId());
@ -81,19 +82,26 @@ public class ConfirmOrderListener {
throw new YamiShopBindException("商品[" + sku.getProdName() + "]已下架"); throw new YamiShopBindException("商品[" + sku.getProdName() + "]已下架");
} }
totalCount = shopCartItem.getProdCount() + totalCount;
total = Arith.add(shopCartItem.getProductTotalAmount(), total);
// 用户地址如果为空,则表示该用户从未设置过任何地址相关信息 // 用户地址如果为空,则表示该用户从未设置过任何地址相关信息
if (userAddr != null) { if (userAddr != null) {
// 每个产品的运费相加 // 每个产品的运费相加
transfee = Arith.add(transfee, transportManagerService.calculateTransfee(shopCartItem, userAddr)); transfee = Arith.add(transfee, transportManagerService.calculateTransfee(shopCartItem, userAddr));
} }
totalCount = shopCartItem.getProdCount() + totalCount;
shopCartItem.setActualTotal(shopCartItem.getProductTotalAmount()); shopCartItem.setActualTotal(shopCartItem.getProductTotalAmount());
if (shopCartItem.getProductType() != 2) {
total = Arith.add(shopCartItem.getProductTotalAmount(), total);
}else {
totalScore += shopCartItem.getPayScore() * shopCartItem.getProdCount();
}
shopCartOrderDto.setActualTotalScore(totalScore);
shopCartOrderDto.setActualTotal(Arith.add(total, transfee)); shopCartOrderDto.setActualTotal(Arith.add(total, transfee));
shopCartOrderDto.setTotal(total); shopCartOrderDto.setTotal(total);
shopCartOrderDto.setTotalCount(totalCount); shopCartOrderDto.setTotalCount(totalCount);
shopCartOrderDto.setTransfee(transfee); shopCartOrderDto.setTransfee(transfee);
} }
} }
} }

@ -138,7 +138,6 @@ public class SubmitOrderListener {
// 使用雪花算法生成的订单号 // 使用雪花算法生成的订单号
String orderNumber = String.valueOf(snowflake.nextId()); String orderNumber = String.valueOf(snowflake.nextId());
shopCartOrderDto.setOrderNumber(orderNumber); shopCartOrderDto.setOrderNumber(orderNumber);
Long shopId = shopCartOrderDto.getShopId(); Long shopId = shopCartOrderDto.getShopId();
// 订单商品名称 // 订单商品名称
@ -211,6 +210,7 @@ public class SubmitOrderListener {
order.setRemarks(shopCartOrderDto.getRemarks()); order.setRemarks(shopCartOrderDto.getRemarks());
order.setOrderItems(orderItems); order.setOrderItems(orderItems);
order.setActualTotalScore(shopCartOrderDto.getActualTotalScore());
return order; return order;
} }
@ -233,6 +233,8 @@ public class SubmitOrderListener {
orderProdName.append(orderItem.getProdName()).append(","); orderProdName.append(orderItem.getProdName()).append(",");
//推广员卡号 //推广员卡号
orderItem.setDistributionCardNo(shopCartItem.getDistributionCardNo()); orderItem.setDistributionCardNo(shopCartItem.getDistributionCardNo());
orderItem.setProductType(shopCartItem.getProductType());
orderItem.setPayScore(shopCartItem.getPayScore());
return orderItem; return orderItem;
} }

@ -84,4 +84,10 @@ public class OrderShopDto implements Serializable {
*/ */
@Schema(description = "订单状态" , required = true) @Schema(description = "订单状态" , required = true)
private Integer status; private Integer status;
/**
*
*/
@Schema(description = "支付积分" , required = true)
private Integer actualTotalScore;
} }

@ -100,9 +100,19 @@ public class ProductDto {
@Schema(description = "运费信息", required = true) @Schema(description = "运费信息", required = true)
private Transport transport; private Transport transport;
public static interface WithNoContent{} @Schema(description = "商品积分价值", required = false)
private Integer payScore;
@Schema(description = "购买商品赠送积分", required = false)
private Integer giveScore;
public static interface WithContent extends WithNoContent{} @Schema(description = "商品类型", required = true)
private Integer productType;
public static interface WithNoContent {
}
public static interface WithContent extends WithNoContent {
}
} }

@ -65,4 +65,11 @@ public class ProductItemDto implements Serializable {
@Schema(description = "参与满减活动列表" ) @Schema(description = "参与满减活动列表" )
private List<DiscountDto> discounts = new ArrayList<>(); private List<DiscountDto> discounts = new ArrayList<>();
@Schema(description = "商品类型" )
private Integer productType;
@Schema(description = "支付需要多少积分" )
private Integer payScore = 1000;
@Schema(description = "购买获得多少积分" )
private Integer giveScore ;
} }

@ -31,4 +31,6 @@ public class ShopCartAmountDto {
@Schema(description = "商品数量" ) @Schema(description = "商品数量" )
private Integer count; private Integer count;
@Schema(description = "支付积分" )
private Integer totalScore;
} }

@ -31,7 +31,8 @@ public class ShopCartOrderDto implements Serializable{
@Schema(description = "实际总值" , required = true) @Schema(description = "实际总值" , required = true)
private Double actualTotal; private Double actualTotal;
@Schema(description = "实际支付积分" , required = true)
private Integer actualTotalScore;
@Schema(description = "商品总值" , required = true) @Schema(description = "商品总值" , required = true)
private Double total; private Double total;

@ -26,7 +26,8 @@ public class ShopCartOrderMergerDto implements Serializable{
@Schema(description = "实际总值" , required = true) @Schema(description = "实际总值" , required = true)
private Double actualTotal; private Double actualTotal;
@Schema(description = "实际总积分" , required = true)
private Integer actualTotalScore;
@Schema(description = "商品总值" , required = true) @Schema(description = "商品总值" , required = true)
private Double total; private Double total;

@ -62,6 +62,10 @@ public class Order implements Serializable {
* *
*/ */
private Double actualTotal; private Double actualTotal;
/**
*
*/
private Integer actualTotalScore;
/** /**
* 1 2 * 1 2

@ -112,4 +112,12 @@ public class OrderItem implements Serializable {
* *
*/ */
private Date basketDate; private Date basketDate;
/**
*
*/
private Integer payScore;
/**
*
*/
private Integer productType;
} }

@ -120,6 +120,19 @@ public class Product implements Serializable {
*/ */
private Date putawayTime; private Date putawayTime;
/**
* 0 1 3
*/
private Integer productType;
/**
*
*/
private Integer payScore;
/**
*
*/
private Integer giveScore;
/** /**
* *
*/ */

@ -127,4 +127,7 @@ public interface ProductMapper extends BaseMapper<Product> {
*/ */
IPage<ProductDto> collectionProds(@Param("page") PageParam page, @Param("userId") String userId); IPage<ProductDto> collectionProds(@Param("page") PageParam page, @Param("userId") String userId);
IPage<ProductDto> pageByMember(Page<ProductDto> page);
IPage<ProductDto> pageByScore(Page<ProductDto> page);
} }

@ -27,6 +27,9 @@ import java.util.List;
*/ */
public interface ProductService extends IService<Product> { public interface ProductService extends IService<Product> {
/** /**
* *
* *
@ -90,6 +93,19 @@ public interface ProductService extends IService<Product> {
* @return * @return
*/ */
IPage<ProductDto> pageByCategoryId(Page<ProductDto> page, Long categoryId); IPage<ProductDto> pageByCategoryId(Page<ProductDto> page, Long categoryId);
/**
*
* @param page
*
* @return
*/
IPage<ProductDto> pageByMember(Page<ProductDto> page);
/**
*
* @param page
* @return
*/
IPage<ProductDto> pageByScore(Page<ProductDto> page);
/** /**
* *

@ -98,6 +98,7 @@ public class BasketServiceImpl extends ServiceImpl<BasketMapper, Basket> impleme
return shopCartItemDtoList; return shopCartItemDtoList;
} }
shopCartItemDtoList = basketMapper.getShopCartItems(userId); shopCartItemDtoList = basketMapper.getShopCartItems(userId);
for (ShopCartItemDto shopCartItemDto : shopCartItemDtoList) { for (ShopCartItemDto shopCartItemDto : shopCartItemDtoList) {
shopCartItemDto.setProductTotalAmount(Arith.mul(shopCartItemDto.getProdCount(), shopCartItemDto.getPrice())); shopCartItemDto.setProductTotalAmount(Arith.mul(shopCartItemDto.getProdCount(), shopCartItemDto.getPrice()));
} }

@ -175,6 +175,16 @@ public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> impl
return productMapper.pageByCategoryId(page, categoryId); return productMapper.pageByCategoryId(page, categoryId);
} }
@Override
public IPage<ProductDto> pageByMember(Page<ProductDto> page) {
return productMapper.pageByMember(page);
}
@Override
public IPage<ProductDto> pageByScore(Page<ProductDto> page) {
return productMapper.pageByScore(page);
}
@Override @Override
public IPage<SearchProdDto> getSearchProdDtoPageByProdName(Page page, String prodName, Integer sort, Integer orderBy) { public IPage<SearchProdDto> getSearchProdDtoPageByProdName(Page page, String prodName, Integer sort, Integer orderBy) {
IPage<SearchProdDto> searchProdDtoPage = productMapper.getSearchProdDtoPageByProdName(page, prodName, sort, orderBy); IPage<SearchProdDto> searchProdDtoPage = productMapper.getSearchProdDtoPageByProdName(page, prodName, sort, orderBy);

@ -17,12 +17,26 @@
</resultMap> </resultMap>
<select id="getShopCartItems" resultType="com.yami.shop.bean.app.dto.ShopCartItemDto"> <select id="getShopCartItems" resultType="com.yami.shop.bean.app.dto.ShopCartItemDto">
SELECT tb.*,tb.basket_count as prod_count,tsd.shop_name,IFNULL(ts.pic,tp.pic)AS pic,ts.price,ts.ori_price,tp.brief,ts.properties,ts.prod_name,ts.sku_name SELECT tb.*,
tb.basket_count as prod_count,
tsd.shop_name,
IFNULL(ts.pic, tp.pic) AS pic,
ts.price,
ts.ori_price,
tp.brief,
ts.properties,
ts.prod_name,
ts.sku_name,
tp.product_type as product_type,
tp.pay_score as pay_score,
tp.give_score as give_score
FROM tz_basket tb FROM tz_basket tb
LEFT JOIN tz_shop_detail tsd ON tb.shop_id = tsd.shop_id LEFT JOIN tz_shop_detail tsd ON tb.shop_id = tsd.shop_id
LEFT JOIN tz_prod tp ON tb.prod_id = tp.prod_id LEFT JOIN tz_prod tp ON tb.prod_id = tp.prod_id
LEFT JOIN tz_sku ts ON tb.sku_id = ts.sku_id LEFT JOIN tz_sku ts ON tb.sku_id = ts.sku_id
WHERE tp.status = 1 AND ts.status =1 AND tb.user_id = #{userId} WHERE tp.status = 1
AND ts.status = 1
AND tb.user_id = #{userId}
ORDER BY tb.`basket_id` DESC ORDER BY tb.`basket_id` DESC
</select> </select>

@ -24,11 +24,11 @@
<insert id="insertBatch"> <insert id="insertBatch">
INSERT INTO `tz_order_item` (shop_id,order_number,prod_id,sku_id,sku_name, INSERT INTO `tz_order_item` (shop_id,order_number,prod_id,sku_id,sku_name,
prod_count,prod_name,pic,price,user_id,product_total_amount,rec_time,comm_sts, prod_count,prod_name,pic,price,user_id,product_total_amount,rec_time,comm_sts,
distribution_card_no,basket_date) VALUES distribution_card_no,basket_date,pay_score,product_type) VALUES
<foreach collection="list" item="orderItem" separator=","> <foreach collection="list" item="orderItem" separator=",">
(#{orderItem.shopId},#{orderItem.orderNumber},#{orderItem.prodId},#{orderItem.skuId},#{orderItem.skuName}, (#{orderItem.shopId},#{orderItem.orderNumber},#{orderItem.prodId},#{orderItem.skuId},#{orderItem.skuName},
#{orderItem.prodCount},#{orderItem.prodName},#{orderItem.pic},#{orderItem.price},#{orderItem.userId},#{orderItem.productTotalAmount},#{orderItem.recTime},#{orderItem.commSts}, #{orderItem.prodCount},#{orderItem.prodName},#{orderItem.pic},#{orderItem.price},#{orderItem.userId},#{orderItem.productTotalAmount},#{orderItem.recTime},#{orderItem.commSts},
#{orderItem.distributionCardNo},#{orderItem.basketDate}) #{orderItem.distributionCardNo},#{orderItem.basketDate},#{orderItem.payScore},#{orderItem.productType})
</foreach> </foreach>
</insert> </insert>

@ -21,6 +21,9 @@
<result property="createTime" column="create_time"/> <result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/> <result property="updateTime" column="update_time"/>
<result property="version" column="version"/> <result property="version" column="version"/>
<result property="payScore" column="pay_score"/>
<result property="giveScore" column="give_score"/>
<result property="productType" column="product_type"/>
</resultMap> </resultMap>
<resultMap id="tagProductMap" type="com.yami.shop.bean.app.dto.TagProductDto"> <resultMap id="tagProductMap" type="com.yami.shop.bean.app.dto.TagProductDto">
@ -45,7 +48,10 @@
</resultMap> </resultMap>
<sql id="productDtoWithNoContent_SQL"> <sql id="productDtoWithNoContent_SQL">
p.`prod_id`, p
.
`prod_id`
,
p.`shop_id`, p.`shop_id`,
p.`prod_name`, p.`prod_name`,
p.`pic`, p.`pic`,
@ -58,7 +64,10 @@
</sql> </sql>
<sql id="prodAndShopNameWithNoContent_SQL"> <sql id="prodAndShopNameWithNoContent_SQL">
p.prod_id, p
.
prod_id
,
p.pic, p.pic,
p.prod_name, p.prod_name,
p.price, p.price,
@ -67,21 +76,28 @@
</sql> </sql>
<update id="updateStocks" parameterType="com.yami.shop.bean.model.Product"> <update id="updateStocks" parameterType="com.yami.shop.bean.model.Product">
update tz_prod set total_stocks = total_stocks - #{prod.totalStocks} ,version = version + 1 where prod_id = #{prod.prodId} and #{prod.totalStocks} &lt;= total_stocks update tz_prod
set total_stocks = total_stocks - #{prod.totalStocks},
version = version + 1
where prod_id = #{prod.prodId}
and #{prod.totalStocks} &lt;= total_stocks
</update> </update>
<select id="pageByCategoryId" resultType="com.yami.shop.bean.app.dto.ProductDto"> <select id="pageByCategoryId" resultType="com.yami.shop.bean.app.dto.ProductDto">
select tp.*,tc.category_name,tsd.shop_name from tz_prod tp select tp.*,tc.category_name,tsd.shop_name from tz_prod tp
left join tz_category tc on tp.category_id = tc.category_id left join tz_category tc on tp.category_id = tc.category_id
left join tz_shop_detail tsd on tp.shop_id = tsd.shop_id left join tz_shop_detail tsd on tp.shop_id = tsd.shop_id
where tp.status = 1 where tp.status = 1 and tp.product_type = 0
<if test="categoryId != null"> <if test="categoryId != null">
AND tp.category_id = #{categoryId} AND tp.category_id = #{categoryId}
</if> </if>
</select> </select>
<select id="getProductByProdNameAndShopId" resultType="com.yami.shop.bean.model.Product"> <select id="getProductByProdNameAndShopId" resultType="com.yami.shop.bean.model.Product">
select * from tz_prod where prod_name = #{prodName} and shop_id = #{shopId} select *
from tz_prod
where prod_name = #{prodName}
and shop_id = #{shopId}
</select> </select>
<update id="returnStock"> <update id="returnStock">
@ -223,5 +239,20 @@
(SELECT uc.`prod_id` FROM tz_user_collection uc (SELECT uc.`prod_id` FROM tz_user_collection uc
WHERE uc.user_id = #{userId}) WHERE uc.user_id = #{userId})
</select> </select>
<select id="pageByMember" resultType="com.yami.shop.bean.app.dto.ProductDto">
select tp.*,tc.category_name,tsd.shop_name from tz_prod tp
left join tz_category tc on tp.category_id = tc.category_id
left join tz_shop_detail tsd on tp.shop_id = tsd.shop_id
where tp.product_type = 1 and tp.status = 1
</select>
<select id="pageByScore" resultType="com.yami.shop.bean.app.dto.ProductDto">
select tp.*,tc.category_name,tsd.shop_name from tz_prod tp
left join tz_category tc on tp.category_id = tc.category_id
left join tz_shop_detail tsd on tp.shop_id = tsd.shop_id
where tp.product_type = 2 and tp.status = 1
</select>
</mapper> </mapper>

Loading…
Cancel
Save