master
RIceWqy 2 years ago
parent 582905f25b
commit 2c3dfdb00d

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

@ -34,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.validation.Valid;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@ -64,7 +65,7 @@ public class OrderController {
*
*/
@PostMapping("/confirm")
@Operation(summary = "结算,生成订单信息" , description = "传入下单所需要的参数进行下单")
@Operation(summary = "结算,生成订单信息", description = "传入下单所需要的参数进行下单")
public ServerResponseEntity<ShopCartOrderMergerDto> confirm(@Valid @RequestBody OrderParam orderParam) {
String userId = SecurityUtils.getUser().getUserId();
@ -74,7 +75,7 @@ public class OrderController {
// 组装获取用户提交的购物车商品项
List<ShopCartItemDto> shopCartItems = basketService.getShopCartItemsByOrderItems(orderParam.getBasketIds(),orderParam.getOrderItem(),userId);
List<ShopCartItemDto> shopCartItems = basketService.getShopCartItemsByOrderItems(orderParam.getBasketIds(), orderParam.getOrderItem(), userId);
if (CollectionUtil.isEmpty(shopCartItems)) {
throw new YamiShopBindException("请选择您需要的商品加入购物车");
@ -95,6 +96,7 @@ public class OrderController {
double total = 0.0;
int totalCount = 0;
double orderReduce = 0.0;
int totalScore = 0;
for (ShopCartDto shopCart : shopCarts) {
// 每个店铺的订单信息
@ -114,12 +116,13 @@ public class OrderController {
shopCartOrder.setShopCartItemDiscounts(shopCartItemDiscounts);
applicationContext.publishEvent(new ConfirmOrderEvent(shopCartOrder,orderParam,shopAllShopCartItems));
applicationContext.publishEvent(new ConfirmOrderEvent(shopCartOrder, orderParam, shopAllShopCartItems));
actualTotal = Arith.add(actualTotal,shopCartOrder.getActualTotal());
total = Arith.add(total,shopCartOrder.getTotal());
actualTotal = Arith.add(actualTotal, shopCartOrder.getActualTotal());
total = Arith.add(total, shopCartOrder.getTotal());
totalCount = totalCount + shopCartOrder.getTotalCount();
orderReduce = Arith.add(orderReduce,shopCartOrder.getShopReduce());
orderReduce = Arith.add(orderReduce, shopCartOrder.getShopReduce());
totalScore += shopCartOrder.getActualTotalScore();
shopCartOrders.add(shopCartOrder);
@ -130,7 +133,7 @@ public class OrderController {
shopCartOrderMergerDto.setTotalCount(totalCount);
shopCartOrderMergerDto.setShopCartOrders(shopCartOrders);
shopCartOrderMergerDto.setOrderReduce(orderReduce);
shopCartOrderMergerDto.setActualTotalScore(totalScore);
shopCartOrderMergerDto = orderService.putConfirmOrderCache(userId, shopCartOrderMergerDto);
return ServerResponseEntity.success(shopCartOrderMergerDto);
@ -140,7 +143,7 @@ public class OrderController {
* / ,
*/
@PostMapping("/submit")
@Operation(summary = "提交订单,返回支付流水号" , description = "根据传入的参数判断是否为购物车提交订单,同时对购物车进行删除,用户开始进行支付")
@Operation(summary = "提交订单,返回支付流水号", description = "根据传入的参数判断是否为购物车提交订单,同时对购物车进行删除,用户开始进行支付")
public ServerResponseEntity<OrderNumbersDto> submitOrders(@Valid @RequestBody SubmitOrderParam submitOrderParam) {
String userId = SecurityUtils.getUser().getUserId();
ShopCartOrderMergerDto mergerOrder = orderService.getConfirmOrderCache(userId);
@ -162,8 +165,7 @@ public class OrderController {
}
}
List<Order> orders = orderService.submit(userId,mergerOrder);
List<Order> orders = orderService.submit(userId, mergerOrder);
StringBuilder orderNumbers = new StringBuilder();
@ -181,7 +183,7 @@ public class OrderController {
if (basketId != null && basketId != 0) {
isShopCartOrder = true;
}
skuService.removeSkuCacheBySkuId(shopCartItem.getSkuId(),shopCartItem.getProdId());
skuService.removeSkuCacheBySkuId(shopCartItem.getSkuId(), shopCartItem.getProdId());
productService.removeProductCacheByProdId(shopCartItem.getProdId());
}
}

@ -10,6 +10,7 @@
package com.yami.shop.api.controller;
import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.bean.app.dto.ProductDto;
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.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import cn.hutool.core.bean.BeanUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
@ -56,19 +56,16 @@ public class ProdController {
@GetMapping("/pageProd")
@Operation(summary = "通过分类id商品列表信息" , description = "根据分类ID获取该分类下所有的商品列表信息")
@Parameters({
@Parameter(name = "categoryId", description = "分类ID" , required = true),
})
public ServerResponseEntity<IPage<ProductDto>> prodList(
@RequestParam(value = "categoryId") Long categoryId,PageParam<ProductDto> page) {
@Operation(summary = "通过分类id商品列表信息", description = "根据分类ID获取该分类下所有的商品列表信息")
@Parameters({@Parameter(name = "categoryId", description = "分类ID", required = true),})
public ServerResponseEntity<IPage<ProductDto>> prodList(@RequestParam(value = "categoryId") Long categoryId, PageParam<ProductDto> page) {
IPage<ProductDto> productPage = prodService.pageByCategoryId(page, categoryId);
return ServerResponseEntity.success(productPage);
}
@GetMapping("/prodInfo")
@Operation(summary = "商品详情信息" , description = "根据商品IDprodId获取商品信息")
@Parameter(name = "prodId", description = "商品ID" , required = true)
@Operation(summary = "商品详情信息", description = "根据商品IDprodId获取商品信息")
@Parameter(name = "prodId", description = "商品ID", required = true)
public ServerResponseEntity<ProductDto> prodInfo(Long prodId) {
Product product = prodService.getProductByProdId(prodId);
@ -95,7 +92,7 @@ public class ProdController {
}
@GetMapping("/lastedProdPage")
@Operation(summary = "新品推荐" , description = "获取新品推荐商品列表")
@Operation(summary = "新品推荐", description = "获取新品推荐商品列表")
@Parameters({
})
public ServerResponseEntity<IPage<ProductDto>> lastedProdPage(PageParam<ProductDto> page) {
@ -104,18 +101,18 @@ public class ProdController {
}
@GetMapping("/prodListByTagId")
@Operation(summary = "通过分组标签获取商品列表" , description = "通过分组标签idtagId获取商品列表")
@Operation(summary = "通过分组标签获取商品列表", description = "通过分组标签idtagId获取商品列表")
@Parameters({
@Parameter(name = "tagId", description = "当前页默认为1" , required = true),
@Parameter(name = "tagId", description = "当前页默认为1", required = true),
})
public ServerResponseEntity<IPage<ProductDto>> prodListByTagId(
@RequestParam(value = "tagId") Long tagId,PageParam<ProductDto> page) {
@RequestParam(value = "tagId") Long tagId, PageParam<ProductDto> page) {
IPage<ProductDto> productPage = prodService.pageByTagId(page, tagId);
return ServerResponseEntity.success(productPage);
}
@GetMapping("/moreBuyProdList")
@Operation(summary = "每日疯抢" , description = "获取销量最多的商品列表")
@Operation(summary = "每日疯抢", description = "获取销量最多的商品列表")
@Parameters({})
public ServerResponseEntity<IPage<ProductDto>> moreBuyProdList(PageParam<ProductDto> page) {
IPage<ProductDto> productPage = prodService.moreBuyProdList(page);
@ -123,9 +120,22 @@ public class ProdController {
}
@GetMapping("/tagProdList")
@Operation(summary = "首页所有标签商品接口" , description = "获取首页所有标签商品接口")
@Operation(summary = "首页所有标签商品接口", description = "获取首页所有标签商品接口")
public ServerResponseEntity<List<TagProductDto>> getTagProdList() {
List<TagProductDto> productDtoList = prodService.tagProdList();
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.Product;
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.security.api.util.SecurityUtils;
import com.yami.shop.service.BasketService;
import com.yami.shop.service.ProductService;
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.tags.Tag;
import jakarta.validation.Valid;
import lombok.AllArgsConstructor;
import org.springframework.context.ApplicationContext;
import com.yami.shop.common.response.ServerResponseEntity;
import org.springframework.web.bind.annotation.*;
import jakarta.validation.Valid;
import java.util.Collections;
import java.util.List;
import java.util.Map;
@ -63,7 +63,7 @@ public class ShopCartController {
* @return
*/
@PostMapping("/info")
@Operation(summary = "获取用户购物车信息" , description = "获取用户购物车信息,参数为用户选中的活动项数组,以购物车id为key")
@Operation(summary = "获取用户购物车信息", description = "获取用户购物车信息,参数为用户选中的活动项数组,以购物车id为key")
public ServerResponseEntity<List<ShopCartDto>> info(@RequestBody Map<Long, ShopCartParam> basketIdShopCartParamMap) {
String userId = SecurityUtils.getUser().getUserId();
@ -79,7 +79,7 @@ public class ShopCartController {
}
@DeleteMapping("/deleteItem")
@Operation(summary = "删除用户购物车物品" , description = "通过购物车id删除用户购物车物品")
@Operation(summary = "删除用户购物车物品", description = "通过购物车id删除用户购物车物品")
public ServerResponseEntity<Void> deleteItem(@RequestBody List<Long> basketIds) {
String userId = SecurityUtils.getUser().getUserId();
basketService.deleteShopCartItemsByBasketIds(userId, basketIds);
@ -87,7 +87,7 @@ public class ShopCartController {
}
@DeleteMapping("/deleteAll")
@Operation(summary = "清空用户购物车所有物品" , description = "清空用户购物车所有物品")
@Operation(summary = "清空用户购物车所有物品", description = "清空用户购物车所有物品")
public ServerResponseEntity<String> deleteAll() {
String userId = SecurityUtils.getUser().getUserId();
basketService.deleteAllShopCartItems(userId);
@ -143,12 +143,12 @@ public class ShopCartController {
return ServerResponseEntity.showFailMsg("库存不足");
}
// 所有都正常时
basketService.addShopCartItem(param,userId);
basketService.addShopCartItem(param, userId);
return ServerResponseEntity.success("添加成功");
}
@GetMapping("/prodCount")
@Operation(summary = "获取购物车商品数量" , description = "获取所有购物车商品数量")
@Operation(summary = "获取购物车商品数量", description = "获取所有购物车商品数量")
public ServerResponseEntity<Integer> prodCount() {
String userId = SecurityUtils.getUser().getUserId();
List<ShopCartItemDto> shopCartItems = basketService.getShopCartItems(userId);
@ -160,7 +160,7 @@ public class ShopCartController {
}
@GetMapping("/expiryProdList")
@Operation(summary = "获取购物车失效商品信息" , description = "获取购物车失效商品列表")
@Operation(summary = "获取购物车失效商品信息", description = "获取购物车失效商品列表")
public ServerResponseEntity<List<ShopCartExpiryItemDto>> expiryProdList() {
String userId = SecurityUtils.getUser().getUserId();
List<ShopCartItemDto> shopCartItems = basketService.getShopCartExpiryItems(userId);
@ -186,7 +186,7 @@ public class ShopCartController {
}
@DeleteMapping("/cleanExpiryProdList")
@Operation(summary = "清空用户失效商品" , description = "清空用户失效商品")
@Operation(summary = "清空用户失效商品", description = "清空用户失效商品")
public ServerResponseEntity<Void> cleanExpiryProdList() {
String userId = SecurityUtils.getUser().getUserId();
basketService.cleanExpiryProdList(userId);
@ -194,7 +194,7 @@ public class ShopCartController {
}
@PostMapping("/totalPay")
@Operation(summary = "获取选中购物项总计、选中的商品数量" , description = "获取选中购物项总计、选中的商品数量,参数为购物车id数组")
@Operation(summary = "获取选中购物项总计、选中的商品数量", description = "获取选中购物项总计、选中的商品数量,参数为购物车id数组")
public ServerResponseEntity<ShopCartAmountDto> getTotalPay(@RequestBody List<Long> basketIds) {
// 拿到购物车的所有item
@ -204,7 +204,7 @@ public class ShopCartController {
.stream()
.filter(shopCartItemDto -> {
for (Long basketId : basketIds) {
if (Objects.equals(basketId,shopCartItemDto.getBasketId())) {
if (Objects.equals(basketId, shopCartItemDto.getBasketId())) {
return true;
}
}
@ -214,10 +214,10 @@ public class ShopCartController {
// 根据店铺ID划分item
Map<Long, List<ShopCartItemDto>> shopCartMap = chooseShopCartItems.stream().collect(Collectors.groupingBy(ShopCartItemDto::getShopId));
double total = 0.0;
int count = 0;
double reduce = 0.0;
int totalScore = 0;
for (Long shopId : shopCartMap.keySet()) {
//获取店铺的所有商品项
List<ShopCartItemDto> shopCartItemDtoList = shopCartMap.get(shopId);
@ -234,7 +234,12 @@ public class ShopCartController {
for (ShopCartItemDto shopCartItem : shopCartItems) {
count = shopCartItem.getProdCount() + count;
if (shopCartItem.getProductType() != 2) {
total = Arith.add(shopCartItem.getProductTotalAmount(), total);
} else {
totalScore += (shopCartItem.getPayScore() * shopCartItem.getProdCount());
}
}
}
}
@ -242,6 +247,7 @@ public class ShopCartController {
shopCartAmountDto.setCount(count);
shopCartAmountDto.setTotalMoney(total);
shopCartAmountDto.setSubtractMoney(reduce);
shopCartAmountDto.setTotalScore(totalScore);
shopCartAmountDto.setFinalMoney(Arith.sub(shopCartAmountDto.getTotalMoney(), shopCartAmountDto.getSubtractMoney()));
return ServerResponseEntity.success(shopCartAmountDto);

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

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

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

@ -26,83 +26,93 @@ public class ProductDto {
/**
* ID
*/
@Schema(description = "店铺ID" , required = true)
@Schema(description = "店铺ID", required = true)
private Long shopId;
/**
*
*/
@Schema(description = "店铺名称" , required = true)
@Schema(description = "店铺名称", required = true)
private String shopName;
/**
* ID
*/
@Schema(description = "商品ID" , required = true)
@Schema(description = "商品ID", required = true)
private Long prodId;
/**
*
*/
@Schema(description = "商品名称" )
@Schema(description = "商品名称")
private String prodName;
/**
*
*/
@Schema(description = "商品价格" , required = true)
@Schema(description = "商品价格", required = true)
private Double price;
/**
*
*/
@Schema(description = "详细描述" )
@Schema(description = "详细描述")
private String content;
/**
*
*/
@Schema(description = "商品原价" , required = true)
@Schema(description = "商品原价", required = true)
private Double oriPrice;
/**
*
*/
@Schema(description = "库存量" , required = true)
@Schema(description = "库存量", required = true)
private Integer totalStocks;
/**
* ,
*/
@Schema(description = "简要描述,卖点等" , required = true)
@Schema(description = "简要描述,卖点等", required = true)
private String brief;
/**
*
*/
@JsonSerialize(using = ImgJsonSerializer.class)
@Schema(description = "商品主图" , required = true)
@Schema(description = "商品主图", required = true)
private String pic;
@JsonSerialize(using = ImgJsonSerializer.class)
@Schema(description = "商品图片列表,以逗号分割" , required = true)
@Schema(description = "商品图片列表,以逗号分割", required = true)
private String imgs;
/**
*
*/
@Schema(description = "商品分类id" , required = true)
@Schema(description = "商品分类id", required = true)
private Long categoryId;
@Schema(description = "sku列表" )
@Schema(description = "sku列表")
private List<SkuDto> skuList;
@Schema(description = "运费信息" , required = true)
@Schema(description = "运费信息", required = true)
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 = "参与满减活动列表" )
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 = "商品数量" )
private Integer count;
@Schema(description = "支付积分" )
private Integer totalScore;
}

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

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

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

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

@ -120,6 +120,19 @@ public class Product implements Serializable {
*/
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> pageByMember(Page<ProductDto> page);
IPage<ProductDto> pageByScore(Page<ProductDto> page);
}

@ -27,6 +27,9 @@ import java.util.List;
*/
public interface ProductService extends IService<Product> {
/**
*
*
@ -90,6 +93,19 @@ public interface ProductService extends IService<Product> {
* @return
*/
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;
}
shopCartItemDtoList = basketMapper.getShopCartItems(userId);
for (ShopCartItemDto shopCartItemDto : shopCartItemDtoList) {
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);
}
@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
public IPage<SearchProdDto> getSearchProdDtoPageByProdName(Page page, String prodName, Integer sort, Integer orderBy) {
IPage<SearchProdDto> searchProdDtoPage = productMapper.getSearchProdDtoPageByProdName(page, prodName, sort, orderBy);

@ -17,12 +17,26 @@
</resultMap>
<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
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_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
</select>

@ -24,11 +24,11 @@
<insert id="insertBatch">
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,
distribution_card_no,basket_date) VALUES
distribution_card_no,basket_date,pay_score,product_type) VALUES
<foreach collection="list" item="orderItem" separator=",">
(#{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.distributionCardNo},#{orderItem.basketDate})
#{orderItem.distributionCardNo},#{orderItem.basketDate},#{orderItem.payScore},#{orderItem.productType})
</foreach>
</insert>

@ -21,6 +21,9 @@
<result property="createTime" column="create_time"/>
<result property="updateTime" column="update_time"/>
<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 id="tagProductMap" type="com.yami.shop.bean.app.dto.TagProductDto">
@ -45,7 +48,10 @@
</resultMap>
<sql id="productDtoWithNoContent_SQL">
p.`prod_id`,
p
.
`prod_id`
,
p.`shop_id`,
p.`prod_name`,
p.`pic`,
@ -58,7 +64,10 @@
</sql>
<sql id="prodAndShopNameWithNoContent_SQL">
p.prod_id,
p
.
prod_id
,
p.pic,
p.prod_name,
p.price,
@ -67,21 +76,28 @@
</sql>
<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>
<select id="pageByCategoryId" 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.status = 1
where tp.status = 1 and tp.product_type = 0
<if test="categoryId != null">
AND tp.category_id = #{categoryId}
</if>
</select>
<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>
<update id="returnStock">
@ -223,5 +239,20 @@
(SELECT uc.`prod_id` FROM tz_user_collection uc
WHERE uc.user_id = #{userId})
</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>

Loading…
Cancel
Save