master:用户进货车功能;
parent
5cb0a8e0bf
commit
ccc632394c
|
|
@ -0,0 +1,92 @@
|
|||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.XktBaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.Page;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.web.controller.xkt.vo.userShoppingCart.ShopCartDetailResVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.userShoppingCart.ShopCartEditVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.userShoppingCart.ShopCartPageVO;
|
||||
import com.ruoyi.web.controller.xkt.vo.userShoppingCart.ShopCartVO;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.ShopCartPageDTO;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.ShopCartPageResDTO;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.ShoppingCartDTO;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.ShoppingCartEditDTO;
|
||||
import com.ruoyi.xkt.service.IShoppingCartService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 用户进货车Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-03-26
|
||||
*/
|
||||
@Api(tags = "用户进货车(只有电商卖家可操作)")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/rest/v1/shopping-carts")
|
||||
public class ShoppingCartController extends XktBaseController {
|
||||
|
||||
final IShoppingCartService shopCartService;
|
||||
|
||||
/**
|
||||
* 电商卖家添加商品到进货车
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:cart:add')")
|
||||
@ApiOperation(value = "电商卖家添加商品到进货车", httpMethod = "POST", response = R.class)
|
||||
@Log(title = "电商卖家添加商品到进货车", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R<Integer> create(@Validated @RequestBody ShopCartVO shopCartVO) {
|
||||
return R.ok(shopCartService.create(BeanUtil.toBean(shopCartVO, ShoppingCartDTO.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 电商卖家编辑进货车商品
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:store:edit')")
|
||||
@ApiOperation(value = "电商卖家编辑进货车商品", httpMethod = "PUT", response = R.class)
|
||||
@Log(title = "电商卖家编辑进货车商品", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R<Integer> edit(@Validated @RequestBody ShopCartEditVO editVO) {
|
||||
return R.ok(shopCartService.update(BeanUtil.toBean(editVO, ShoppingCartEditDTO.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户进货车列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:cart:list')")
|
||||
@ApiOperation(value = "获取用户进货车列表", httpMethod = "POST", response = R.class)
|
||||
@PostMapping("/page")
|
||||
public R<Page<ShopCartPageResDTO>> page(@Validated @RequestBody ShopCartPageVO pageVO) {
|
||||
return R.ok(shopCartService.page(BeanUtil.toBean(pageVO, ShopCartPageDTO.class)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户进货车列表点击编辑
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:cart:list')")
|
||||
@ApiOperation(value = "用户进货车列表点击编辑", httpMethod = "GET", response = R.class)
|
||||
@GetMapping("/{shoppingCartId}")
|
||||
public R<ShopCartDetailResVO> getInfo(@PathVariable Long shoppingCartId) {
|
||||
return R.ok(BeanUtil.toBean(shopCartService.getInfo(shoppingCartId), ShopCartDetailResVO.class));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 用户删除进货车商品
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:sale:remove')")
|
||||
@ApiOperation(value = "用户进货车列表点击编辑", httpMethod = "DELETE", response = R.class)
|
||||
@Log(title = "用户删除进货车商品", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{shoppingCartId}")
|
||||
public R<Integer> remove(@PathVariable Long shoppingCartId) {
|
||||
return R.ok(shopCartService.delete(shoppingCartId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,91 +0,0 @@
|
|||
package com.ruoyi.web.controller.xkt;
|
||||
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.XktBaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.xkt.domain.UserShoppingCart;
|
||||
import com.ruoyi.xkt.service.IUserShoppingCartService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户进货车Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-03-26
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/rest/v1/user-carts")
|
||||
public class UserShoppingCartController extends XktBaseController {
|
||||
@Autowired
|
||||
private IUserShoppingCartService userShoppingCartService;
|
||||
|
||||
/**
|
||||
* 查询用户进货车列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:cart:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(UserShoppingCart userShoppingCart) {
|
||||
startPage();
|
||||
List<UserShoppingCart> list = userShoppingCartService.selectUserShoppingCartList(userShoppingCart);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出用户进货车列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:cart:export')")
|
||||
@Log(title = "用户进货车", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, UserShoppingCart userShoppingCart) {
|
||||
List<UserShoppingCart> list = userShoppingCartService.selectUserShoppingCartList(userShoppingCart);
|
||||
ExcelUtil<UserShoppingCart> util = new ExcelUtil<UserShoppingCart>(UserShoppingCart.class);
|
||||
util.exportExcel(response, list, "用户进货车数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户进货车详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:cart:query')")
|
||||
@GetMapping(value = "/{userShopCartId}")
|
||||
public R getInfo(@PathVariable("userShopCartId") Long userShopCartId) {
|
||||
return success(userShoppingCartService.selectUserShoppingCartByUserShopCartId(userShopCartId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户进货车
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:cart:add')")
|
||||
@Log(title = "用户进货车", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public R add(@RequestBody UserShoppingCart userShoppingCart) {
|
||||
return success(userShoppingCartService.insertUserShoppingCart(userShoppingCart));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户进货车
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:cart:edit')")
|
||||
@Log(title = "用户进货车", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public R edit(@RequestBody UserShoppingCart userShoppingCart) {
|
||||
return success(userShoppingCartService.updateUserShoppingCart(userShoppingCart));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户进货车
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('system:cart:remove')")
|
||||
@Log(title = "用户进货车", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{userShopCartIds}")
|
||||
public R remove(@PathVariable Long[] userShopCartIds) {
|
||||
return success(userShoppingCartService.deleteUserShoppingCartByUserShopCartIds(userShopCartIds));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,75 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("档口商品详情返回数据")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ShopCartDetailResVO {
|
||||
|
||||
@ApiModelProperty("档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "大小码加价")
|
||||
private Integer overPrice;
|
||||
@ApiModelProperty(value = "档口商品尺码库存列表")
|
||||
private List<StoreProdColorVO> colorList;
|
||||
@ApiModelProperty(value = "标准尺码")
|
||||
private List<Integer> standardSizeList;
|
||||
@ApiModelProperty(value = "进货车明细列表")
|
||||
List<SCDDetailVO> detailList;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "档口商品基本信息")
|
||||
@Accessors(chain = true)
|
||||
public static class SCDDetailVO {
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "商品数量")
|
||||
private Integer quantity;
|
||||
}
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "档口商品基本信息")
|
||||
@Accessors(chain = true)
|
||||
public static class StoreProdColorVO {
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "档口颜色ID")
|
||||
private Long storeColorId;
|
||||
@ApiModelProperty(value = "颜色名称")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer orderNum;
|
||||
@ApiModelProperty(value = "档口商品定价")
|
||||
private BigDecimal price;
|
||||
@ApiModelProperty(value = "商品尺码及库存")
|
||||
List<StoreProdSizeStockVO> sizeStockList;
|
||||
}
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "档口商品尺码及库存")
|
||||
@Accessors(chain = true)
|
||||
public static class StoreProdSizeStockVO {
|
||||
@ApiModelProperty(value = "商品尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "尺码库存")
|
||||
private Integer stock;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("电商卖家新增进货车")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ShopCartEditVO {
|
||||
|
||||
@ApiModelProperty(value = "进货车ID, 新增不传,编辑必传")
|
||||
@NotNull(message = "进货车ID不能为空!")
|
||||
private Long shoppingCartId;
|
||||
@NotNull(message = "档口ID不能为空!")
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@NotNull(message = "档口商品ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@NotBlank(message = "商品货号不能为空!")
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@Valid
|
||||
@NotNull(message = "进货车明细列表不能为空!")
|
||||
@ApiModelProperty(value = "进货车明细列表")
|
||||
List<SCDetailVO> detailList;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "档口优惠列表")
|
||||
public static class SCDetailVO {
|
||||
@NotNull(message = "档口商品颜色ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@NotNull(message = "尺码不能为空!")
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@NotNull(message = "档口商品颜色ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeColorId;
|
||||
@NotBlank(message = "颜色名称不能为空!")
|
||||
@ApiModelProperty(value = "颜色名称")
|
||||
private String colorName;
|
||||
@NotNull(message = "商品数量不能为空!")
|
||||
@ApiModelProperty(value = "商品数量")
|
||||
private Integer quantity;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.ruoyi.web.controller.xkt.vo.BasePageVO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("电商卖家进货车列表")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ShopCartPageVO extends BasePageVO {
|
||||
|
||||
@NotNull(message = "商品状态不可为空!")
|
||||
@ApiModelProperty(value = "商品状态,在售传:2, 已失效传:4,5")
|
||||
List<Integer> statusList;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "档口名称")
|
||||
private String storeName;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("电商卖家进货车数据")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ShopCartResVO {
|
||||
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(value = "档口名称")
|
||||
private String storeName;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "进货车明细列表")
|
||||
List<SCDetailVO> detailList;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "档口优惠列表")
|
||||
public static class SCDetailVO {
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeColorId;
|
||||
@ApiModelProperty(value = "颜色名称")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "商品数量")
|
||||
private Integer quantity;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,58 @@
|
|||
package com.ruoyi.web.controller.xkt.vo.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("电商卖家新增进货车")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ShopCartVO {
|
||||
|
||||
@NotNull(message = "档口ID不能为空!")
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@NotNull(message = "档口商品ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@NotBlank(message = "商品货号不能为空!")
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@Valid
|
||||
@NotNull(message = "进货车明细列表不能为空!")
|
||||
@ApiModelProperty(value = "进货车明细列表")
|
||||
List<SCDetailVO> detailList;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "档口优惠列表")
|
||||
public static class SCDetailVO {
|
||||
@NotNull(message = "档口商品颜色ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@NotNull(message = "尺码不能为空!")
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@NotNull(message = "档口商品颜色ID不能为空!")
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeColorId;
|
||||
@NotBlank(message = "颜色名称不能为空!")
|
||||
@ApiModelProperty(value = "颜色名称")
|
||||
private String colorName;
|
||||
@NotNull(message = "商品数量不能为空!")
|
||||
@ApiModelProperty(value = "商品数量")
|
||||
private Integer quantity;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import com.ruoyi.common.annotation.Excel;
|
|||
import com.ruoyi.common.core.domain.XktBaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
|
|
@ -16,7 +17,8 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
|||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class UserShoppingCart extends XktBaseEntity {
|
||||
@Accessors(chain = true)
|
||||
public class ShoppingCart extends XktBaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
|
|
@ -36,24 +38,16 @@ public class UserShoppingCart extends XktBaseEntity {
|
|||
*/
|
||||
@Excel(name = "store.id")
|
||||
private Long storeId;
|
||||
|
||||
/**
|
||||
* store_prod_color.id
|
||||
*/
|
||||
@Excel(name = "store_prod_color.id")
|
||||
private Long storeProdColorId;
|
||||
|
||||
/**
|
||||
* store_prod.id
|
||||
*/
|
||||
@Excel(name = "store_prod.id")
|
||||
private Long storeProdId;
|
||||
|
||||
/**
|
||||
* 商品数量
|
||||
* 商品货号
|
||||
*/
|
||||
@Excel(name = "商品数量")
|
||||
private Integer quantity;
|
||||
@Excel(name = "商品货号")
|
||||
private String prodArtNum;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -62,9 +56,6 @@ public class UserShoppingCart extends XktBaseEntity {
|
|||
.append("id", getId())
|
||||
.append("userId", getUserId())
|
||||
.append("storeId", getStoreId())
|
||||
.append("storeProdColorId", getStoreProdColorId())
|
||||
.append("storeProdId", getStoreProdId())
|
||||
.append("quantity", getQuantity())
|
||||
.append("version", getVersion())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
package com.ruoyi.xkt.domain;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.XktBaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
/**
|
||||
* 用户进货车对象 user_shopping_cart
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-03-26
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ShoppingCartDetail extends XktBaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 用户进货车ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* shoppingCart.id
|
||||
*/
|
||||
@Excel(name = "shoppingCart.id")
|
||||
private Long shoppingCartId;
|
||||
/**
|
||||
* store_prod_color.id
|
||||
*/
|
||||
@Excel(name = "store_prod_color.id")
|
||||
private Long storeProdColorId;
|
||||
|
||||
/**
|
||||
* 尺码
|
||||
*/
|
||||
private Integer size;
|
||||
|
||||
/**
|
||||
* 档口颜色ID
|
||||
*/
|
||||
private Long storeColorId;
|
||||
/**
|
||||
* 颜色名称
|
||||
*/
|
||||
@Excel(name = "颜色名称")
|
||||
private String colorName;
|
||||
|
||||
/**
|
||||
* 商品数量
|
||||
*/
|
||||
@Excel(name = "商品数量")
|
||||
private Integer quantity;
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("storeProdColorId", getStoreProdColorId())
|
||||
.append("quantity", getQuantity())
|
||||
.append("version", getVersion())
|
||||
.append("delFlag", getDelFlag())
|
||||
.append("createBy", getCreateBy())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("updateBy", getUpdateBy())
|
||||
.append("updateTime", getUpdateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
package com.ruoyi.xkt.dto.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("档口商品详情返回数据")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
@Accessors(chain = true)
|
||||
public class ShopCartDetailResDTO {
|
||||
|
||||
@ApiModelProperty("档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "档口商品尺码库存列表")
|
||||
private List<SCDStoreProdColorDTO> colorList;
|
||||
@ApiModelProperty(value = "标准尺码")
|
||||
private List<Integer> standardSizeList;
|
||||
@ApiModelProperty(value = "进货车明细列表")
|
||||
List<SCDDetailDTO> detailList;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "档口商品基本信息")
|
||||
@Accessors(chain = true)
|
||||
public static class SCDDetailDTO {
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "商品数量")
|
||||
private Integer quantity;
|
||||
}
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "档口商品基本信息")
|
||||
@Accessors(chain = true)
|
||||
public static class SCDStoreProdColorDTO {
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "档口颜色ID")
|
||||
private Long storeColorId;
|
||||
@ApiModelProperty(value = "颜色名称")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer orderNum;
|
||||
@ApiModelProperty(value = "档口商品定价")
|
||||
private BigDecimal price;
|
||||
@ApiModelProperty(value = "商品尺码及库存")
|
||||
List<SCDStoreProdSizeStockDTO> sizeStockList;
|
||||
}
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "档口商品尺码及库存")
|
||||
@Accessors(chain = true)
|
||||
public static class SCDStoreProdSizeStockDTO {
|
||||
@ApiModelProperty(value = "商品尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "尺码库存")
|
||||
private Integer stock;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.ruoyi.xkt.dto.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.ruoyi.xkt.dto.BasePageDTO;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ApiModel("电商卖家新增进货车")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ShopCartPageDTO extends BasePageDTO {
|
||||
|
||||
@ApiModelProperty(value = "userId")
|
||||
private Long userId;
|
||||
@ApiModelProperty(value = "商品状态,在售传:2, 已失效传:4,5")
|
||||
List<Integer> statusList;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "档口名称")
|
||||
private String storeName;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.ruoyi.xkt.dto.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("电商卖家进货车列表返回数据")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ShopCartPageDetailResDTO {
|
||||
|
||||
@ApiModelProperty(value = "进货车明细ID")
|
||||
private Long shoppingCartDetailId;
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeColorId;
|
||||
@ApiModelProperty(value = "颜色名称")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "商品数量")
|
||||
private Integer quantity;
|
||||
@ApiModelProperty(value = "标注尺码")
|
||||
private String standardSize;
|
||||
@ApiModelProperty(value = "颜色价格")
|
||||
private BigDecimal price;
|
||||
@ApiModelProperty(value = "总金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
package com.ruoyi.xkt.dto.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("电商卖家进货车列表返回数据")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ShopCartPageResDTO {
|
||||
|
||||
@ApiModelProperty(value = "主图")
|
||||
private String mainPicUrl;
|
||||
@ApiModelProperty(value = "进货单ID")
|
||||
private Long shoppingCartId;
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(value = "档口名称")
|
||||
private String storeName;
|
||||
@ApiModelProperty(name = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(name = "商品标题")
|
||||
private String prodTitle;
|
||||
@ApiModelProperty(value = "进货车明细列表")
|
||||
List<ShopCartPageDetailResDTO> detailList;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
package com.ruoyi.xkt.dto.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("电商卖家新增进货车")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ShoppingCartDTO {
|
||||
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "进货车明细列表")
|
||||
List<SCDetailDTO> detailList;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "档口优惠列表")
|
||||
public static class SCDetailDTO {
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeColorId;
|
||||
@ApiModelProperty(value = "颜色名称")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "商品数量")
|
||||
private Integer quantity;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package com.ruoyi.xkt.dto.userShoppingCart;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel("电商卖家新增进货车")
|
||||
@Data
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ShoppingCartEditDTO {
|
||||
|
||||
@ApiModelProperty(value = "进货车ID,编辑必传")
|
||||
private Long shoppingCartId;
|
||||
@ApiModelProperty(value = "档口ID")
|
||||
private Long storeId;
|
||||
@ApiModelProperty(value = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
@ApiModelProperty(value = "商品货号")
|
||||
private String prodArtNum;
|
||||
@ApiModelProperty(value = "进货车明细列表")
|
||||
List<SCDetailDTO> detailList;
|
||||
|
||||
@Data
|
||||
@ApiModel(value = "档口优惠列表")
|
||||
public static class SCDetailDTO {
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeProdColorId;
|
||||
@ApiModelProperty(value = "尺码")
|
||||
private Integer size;
|
||||
@ApiModelProperty(value = "档口商品颜色ID")
|
||||
private Long storeColorId;
|
||||
@ApiModelProperty(value = "颜色名称")
|
||||
private String colorName;
|
||||
@ApiModelProperty(value = "商品数量")
|
||||
private Integer quantity;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
package com.ruoyi.xkt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.xkt.domain.ShoppingCartDetail;
|
||||
|
||||
/**
|
||||
* 用户进货车Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-03-26
|
||||
*/
|
||||
public interface ShoppingCartDetailMapper extends BaseMapper<ShoppingCartDetail> {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
package com.ruoyi.xkt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.xkt.domain.ShoppingCart;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.ShopCartPageDTO;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.ShopCartPageResDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户进货车Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-03-26
|
||||
*/
|
||||
public interface ShoppingCartMapper extends BaseMapper<ShoppingCart> {
|
||||
|
||||
/**
|
||||
* 查询用户进货车列表
|
||||
* @param pageDTO 进货单列表查询入参
|
||||
* @return List<ShopCartPageResDTO>
|
||||
*/
|
||||
List<ShopCartPageResDTO> selectShopCartPage(ShopCartPageDTO pageDTO);
|
||||
|
||||
}
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
package com.ruoyi.xkt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.ruoyi.xkt.domain.UserShoppingCart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户进货车Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-03-26
|
||||
*/
|
||||
public interface UserShoppingCartMapper extends BaseMapper<UserShoppingCart> {
|
||||
/**
|
||||
* 查询用户进货车
|
||||
*
|
||||
* @param id 用户进货车主键
|
||||
* @return 用户进货车
|
||||
*/
|
||||
public UserShoppingCart selectUserShoppingCartByUserShopCartId(Long id);
|
||||
|
||||
/**
|
||||
* 查询用户进货车列表
|
||||
*
|
||||
* @param userShoppingCart 用户进货车
|
||||
* @return 用户进货车集合
|
||||
*/
|
||||
public List<UserShoppingCart> selectUserShoppingCartList(UserShoppingCart userShoppingCart);
|
||||
|
||||
/**
|
||||
* 新增用户进货车
|
||||
*
|
||||
* @param userShoppingCart 用户进货车
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertUserShoppingCart(UserShoppingCart userShoppingCart);
|
||||
|
||||
/**
|
||||
* 修改用户进货车
|
||||
*
|
||||
* @param userShoppingCart 用户进货车
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUserShoppingCart(UserShoppingCart userShoppingCart);
|
||||
|
||||
/**
|
||||
* 删除用户进货车
|
||||
*
|
||||
* @param id 用户进货车主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserShoppingCartByUserShopCartId(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除用户进货车
|
||||
*
|
||||
* @param userShopCartIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserShoppingCartByUserShopCartIds(Long[] userShopCartIds);
|
||||
}
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
package com.ruoyi.xkt.service;
|
||||
|
||||
import com.ruoyi.common.core.page.Page;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.*;
|
||||
|
||||
/**
|
||||
* 用户进货车Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-03-26
|
||||
*/
|
||||
public interface IShoppingCartService {
|
||||
|
||||
/**
|
||||
* 用户往进货车新增商品
|
||||
*
|
||||
* @param shoppingCartDTO
|
||||
* @return Integer
|
||||
*/
|
||||
Integer create(ShoppingCartDTO shoppingCartDTO);
|
||||
|
||||
/**
|
||||
* 用户进货车列表
|
||||
*
|
||||
* @param pageDTO 查询列表入参
|
||||
* @return Page<ShopCartListResDTO>
|
||||
*/
|
||||
Page<ShopCartPageResDTO> page(ShopCartPageDTO pageDTO);
|
||||
|
||||
/**
|
||||
* 根据购物车ID 获取购物车详情
|
||||
*
|
||||
* @param shoppingCartId 购物车ID
|
||||
* @return ShopCartDetailResDTO
|
||||
*/
|
||||
ShopCartDetailResDTO getInfo(Long shoppingCartId);
|
||||
|
||||
/**
|
||||
* 用户编辑进货车商品
|
||||
*
|
||||
* @param cartDTO 编辑进货车商品入参
|
||||
* @return
|
||||
*/
|
||||
Integer update(ShoppingCartEditDTO cartDTO);
|
||||
|
||||
/**
|
||||
* 用户删除进货车商品
|
||||
*
|
||||
* @param shoppingCartId 进货车ID
|
||||
* @return
|
||||
*/
|
||||
Integer delete(Long shoppingCartId);
|
||||
}
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
package com.ruoyi.xkt.service;
|
||||
|
||||
import com.ruoyi.xkt.domain.UserShoppingCart;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户进货车Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-03-26
|
||||
*/
|
||||
public interface IUserShoppingCartService {
|
||||
/**
|
||||
* 查询用户进货车
|
||||
*
|
||||
* @param userShopCartId 用户进货车主键
|
||||
* @return 用户进货车
|
||||
*/
|
||||
public UserShoppingCart selectUserShoppingCartByUserShopCartId(Long userShopCartId);
|
||||
|
||||
/**
|
||||
* 查询用户进货车列表
|
||||
*
|
||||
* @param userShoppingCart 用户进货车
|
||||
* @return 用户进货车集合
|
||||
*/
|
||||
public List<UserShoppingCart> selectUserShoppingCartList(UserShoppingCart userShoppingCart);
|
||||
|
||||
/**
|
||||
* 新增用户进货车
|
||||
*
|
||||
* @param userShoppingCart 用户进货车
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertUserShoppingCart(UserShoppingCart userShoppingCart);
|
||||
|
||||
/**
|
||||
* 修改用户进货车
|
||||
*
|
||||
* @param userShoppingCart 用户进货车
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateUserShoppingCart(UserShoppingCart userShoppingCart);
|
||||
|
||||
/**
|
||||
* 批量删除用户进货车
|
||||
*
|
||||
* @param userShopCartIds 需要删除的用户进货车主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserShoppingCartByUserShopCartIds(Long[] userShopCartIds);
|
||||
|
||||
/**
|
||||
* 删除用户进货车信息
|
||||
*
|
||||
* @param userShopCartId 用户进货车主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteUserShoppingCartByUserShopCartId(Long userShopCartId);
|
||||
}
|
||||
|
|
@ -0,0 +1,369 @@
|
|||
package com.ruoyi.xkt.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.domain.model.LoginUser;
|
||||
import com.ruoyi.common.core.page.Page;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.xkt.domain.*;
|
||||
import com.ruoyi.xkt.dto.storeProductFile.StoreProdMainPicDTO;
|
||||
import com.ruoyi.xkt.dto.userShoppingCart.*;
|
||||
import com.ruoyi.xkt.enums.FileType;
|
||||
import com.ruoyi.xkt.enums.ProductSizeStatus;
|
||||
import com.ruoyi.xkt.mapper.*;
|
||||
import com.ruoyi.xkt.service.IShoppingCartService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.ruoyi.common.constant.Constants.*;
|
||||
|
||||
/**
|
||||
* 用户进货车Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-03-26
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ShoppingCartServiceImpl implements IShoppingCartService {
|
||||
|
||||
final ShoppingCartMapper shopCartMapper;
|
||||
final ShoppingCartDetailMapper shopCartDetailMapper;
|
||||
final StoreProductColorSizeMapper prodColorSizeMapper;
|
||||
final SysFileMapper fileMapper;
|
||||
final StoreHomepageMapper storeHomeMapper;
|
||||
final StoreMapper storeMapper;
|
||||
final StoreProductMapper storeProdMapper;
|
||||
final StoreProductDetailMapper prodDetailMapper;
|
||||
final StoreProductColorMapper prodColorMapper;
|
||||
final StoreProductStockMapper prodStockMapper;
|
||||
final StoreProductColorPriceMapper prodColorPriceMapper;
|
||||
final StoreProductFileMapper prodFileMapper;
|
||||
final StoreProductCategoryAttributeMapper prodCateAttrMapper;
|
||||
final StoreCertificateMapper storeCertMapper;
|
||||
|
||||
|
||||
/**
|
||||
* 用户往进货车新增商品
|
||||
*
|
||||
* @param shoppingCartDTO 新增入参
|
||||
* @return Integer
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer create(ShoppingCartDTO shoppingCartDTO) {
|
||||
// 判断当前登录用户角色 只有电商卖家才可操作
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
|
||||
// TODO 判断当前登录用户角色,只有电商卖家才可操作,其它角色不允许操作,直接报错
|
||||
// TODO 判断当前登录用户角色,只有电商卖家才可操作,其它角色不允许操作,直接报错
|
||||
// TODO 判断当前登录用户角色,只有电商卖家才可操作,其它角色不允许操作,直接报错
|
||||
// TODO 判断当前登录用户角色,只有电商卖家才可操作,其它角色不允许操作,直接报错
|
||||
|
||||
// 判断当前商品是否已添加过进货车
|
||||
List<ShoppingCart> existList = this.shopCartMapper.selectList(new LambdaQueryWrapper<ShoppingCart>()
|
||||
.eq(ShoppingCart::getUserId, loginUser.getUserId()).eq(ShoppingCart::getStoreProdId, shoppingCartDTO.getStoreProdId())
|
||||
.eq(ShoppingCart::getDelFlag, Constants.UNDELETED));
|
||||
if (CollectionUtils.isNotEmpty(existList)) {
|
||||
throw new ServiceException("商品已经添加到进货单了,不可重复添加喔!", HttpStatus.ERROR);
|
||||
}
|
||||
ShoppingCart shoppingCart = BeanUtil.toBean(shoppingCartDTO, ShoppingCart.class).setUserId(loginUser.getUserId());
|
||||
int count = this.shopCartMapper.insert(shoppingCart);
|
||||
List<ShoppingCartDetail> cartDetailList = shoppingCartDTO.getDetailList().stream().map(x -> BeanUtil.toBean(x, ShoppingCartDetail.class)
|
||||
.setShoppingCartId(shoppingCart.getId())).collect(Collectors.toList());
|
||||
this.shopCartDetailMapper.insert(cartDetailList);
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户进货车列表
|
||||
*
|
||||
* @param pageDTO 查询列表入参
|
||||
* @return Page<ShopCartListResDTO>
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public Page<ShopCartPageResDTO> page(ShopCartPageDTO pageDTO) {
|
||||
// 获取当前登录用户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
pageDTO.setUserId(loginUser.getUserId());
|
||||
PageHelper.startPage(pageDTO.getPageNum(), pageDTO.getPageSize());
|
||||
List<ShopCartPageResDTO> shoppingCartList = this.shopCartMapper.selectShopCartPage(pageDTO);
|
||||
// 查找排名第一个商品主图列表
|
||||
List<StoreProdMainPicDTO> mainPicList = this.prodFileMapper.selectMainPicByStoreProdIdList(shoppingCartList.stream()
|
||||
.map(ShopCartPageResDTO::getStoreProdId).collect(Collectors.toList()), FileType.MAIN_PIC.getValue(), ORDER_NUM_1);
|
||||
Map<Long, String> mainPicMap = CollectionUtils.isEmpty(mainPicList) ? new HashMap<>() : mainPicList.stream()
|
||||
.collect(Collectors.toMap(StoreProdMainPicDTO::getStoreProdId, StoreProdMainPicDTO::getFileUrl));
|
||||
// 获取所有标准尺码
|
||||
List<StoreProductColorSize> standardSizeList = this.prodColorSizeMapper.selectList(new LambdaQueryWrapper<StoreProductColorSize>()
|
||||
.in(StoreProductColorSize::getStoreProdId, shoppingCartList.stream().map(ShopCartPageResDTO::getStoreProdId).collect(Collectors.toList()))
|
||||
.eq(StoreProductColorSize::getDelFlag, Constants.UNDELETED).eq(StoreProductColorSize::getStandard, ProductSizeStatus.STANDARD.getValue()));
|
||||
if (CollectionUtils.isEmpty(standardSizeList)) {
|
||||
return Page.convert(new PageInfo<>(shoppingCartList));
|
||||
}
|
||||
// 以storeProdId为key, 取标准尺码的最大值和最小值组成字符串 eg: 34 - 40
|
||||
Map<Long, String> minAndMaxSizeMap = standardSizeList.stream().collect(Collectors.groupingBy(
|
||||
StoreProductColorSize::getStoreProdId,
|
||||
Collectors.collectingAndThen(
|
||||
Collectors.mapping(StoreProductColorSize::getSize, Collectors.toList()),
|
||||
sizeList -> {
|
||||
if (sizeList.isEmpty()) {
|
||||
return ""; // 处理空列表的情况,返回空字符串或其他默认值
|
||||
}
|
||||
int minSize = Collections.min(sizeList);
|
||||
int maxSize = Collections.max(sizeList);
|
||||
return minSize + "-" + maxSize;
|
||||
})));
|
||||
// 设置标准尺码
|
||||
shoppingCartList.forEach(x -> {
|
||||
x.setMainPicUrl(mainPicMap.getOrDefault(x.getStoreProdId(), null));
|
||||
x.getDetailList()
|
||||
.forEach(detail -> detail.setStandardSize(minAndMaxSizeMap.getOrDefault(x.getStoreProdId(), "")));
|
||||
});
|
||||
return Page.convert(new PageInfo<>(shoppingCartList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据购物车ID 获取购物车详情
|
||||
*
|
||||
* @param shoppingCartId 购物车ID
|
||||
* @return ShopCartDetailResDTO
|
||||
*/
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ShopCartDetailResDTO getInfo(Long shoppingCartId) {
|
||||
// 获取当前登录用户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
ShoppingCart shoppingCart = Optional.ofNullable(this.shopCartMapper.selectOne(new LambdaQueryWrapper<ShoppingCart>()
|
||||
.eq(ShoppingCart::getId, shoppingCartId).eq(ShoppingCart::getDelFlag, Constants.UNDELETED)
|
||||
.eq(ShoppingCart::getUserId, loginUser.getUserId())))
|
||||
.orElseThrow(() -> new ServiceException("用户购物车不存在!", HttpStatus.ERROR));
|
||||
// 获取进货车明细
|
||||
List<ShoppingCartDetail> detailList = this.shopCartDetailMapper.selectList(new LambdaQueryWrapper<ShoppingCartDetail>()
|
||||
.eq(ShoppingCartDetail::getShoppingCartId, shoppingCartId).eq(ShoppingCartDetail::getDelFlag, Constants.UNDELETED));
|
||||
// 获取标准尺码
|
||||
List<StoreProductColorSize> standardSizeList = this.prodColorSizeMapper.selectList(new LambdaQueryWrapper<StoreProductColorSize>()
|
||||
.eq(StoreProductColorSize::getStoreProdId, shoppingCart.getStoreProdId()).eq(StoreProductColorSize::getDelFlag, Constants.UNDELETED)
|
||||
.eq(StoreProductColorSize::getStandard, ProductSizeStatus.STANDARD.getValue()));
|
||||
Map<String, List<StoreProductColorSize>> colorSizeMap = standardSizeList.stream().collect(Collectors
|
||||
.groupingBy(x -> x.getStoreProdId().toString() + x.getStoreColorId().toString()));
|
||||
// 获取商品颜色列表
|
||||
List<StoreProductColor> colorList = this.prodColorMapper.selectList(new LambdaQueryWrapper<StoreProductColor>()
|
||||
.eq(StoreProductColor::getStoreProdId, shoppingCart.getStoreProdId()).eq(StoreProductColor::getDelFlag, Constants.UNDELETED));
|
||||
// 档口商品颜色价格列表
|
||||
List<StoreProductColorPrice> colorPriceList = this.prodColorPriceMapper.selectList(new LambdaQueryWrapper<StoreProductColorPrice>()
|
||||
.eq(StoreProductColorPrice::getStoreProdId, shoppingCart.getStoreProdId()).eq(StoreProductColorPrice::getDelFlag, Constants.UNDELETED));
|
||||
Map<String, StoreProductColorPrice> colorPriceMap = colorPriceList.stream().collect(Collectors
|
||||
.toMap(x -> x.getStoreProdId().toString() + x.getStoreColorId().toString(), Function.identity()));
|
||||
// 根据标准尺码去找对应尺码的库存数量
|
||||
List<StoreProductStock> prodStockList = this.prodStockMapper.selectList(new LambdaQueryWrapper<StoreProductStock>()
|
||||
.eq(StoreProductStock::getStoreProdId, shoppingCart.getStoreProdId())
|
||||
.in(StoreProductStock::getStoreProdColorId, colorList.stream().map(StoreProductColor::getId).distinct().collect(Collectors.toList()))
|
||||
.eq(StoreProductStock::getDelFlag, Constants.UNDELETED));
|
||||
// 获取档口颜色尺码的库存数量
|
||||
Map<String, List<ShopCartDetailResDTO.SCDStoreProdSizeStockDTO>> colorSizeStockMap = this.convertSizeStock(prodStockList, standardSizeList);
|
||||
List<ShopCartDetailResDTO.SCDStoreProdColorDTO> colorSizeStockList = colorList.stream()
|
||||
.map(color -> BeanUtil.toBean(color, ShopCartDetailResDTO.SCDStoreProdColorDTO.class)
|
||||
.setStoreProdColorId(color.getId())
|
||||
// 获取颜色设定的价格
|
||||
.setPrice(colorPriceMap.containsKey(color.getStoreProdId().toString() + color.getStoreColorId().toString())
|
||||
? colorPriceMap.get(color.getStoreProdId().toString() + color.getStoreColorId().toString()).getPrice() : null)
|
||||
// 设定库存
|
||||
.setSizeStockList(colorSizeMap.containsKey(color.getStoreProdId().toString() + color.getStoreColorId().toString())
|
||||
? colorSizeStockMap.get(color.getStoreProdId().toString() + color.getStoreColorId().toString()) : null))
|
||||
.collect(Collectors.toList());
|
||||
return new ShopCartDetailResDTO() {{
|
||||
setProdArtNum(shoppingCart.getProdArtNum()).setStoreProdId(shoppingCart.getStoreProdId())
|
||||
.setStandardSizeList(standardSizeList.stream().map(StoreProductColorSize::getSize)
|
||||
.sorted(Comparator.comparing(Function.identity()))
|
||||
.collect(Collectors.toList()))
|
||||
.setColorList(colorSizeStockList)
|
||||
.setDetailList(BeanUtil.copyToList(detailList, ShopCartDetailResDTO.SCDDetailDTO.class));
|
||||
}};
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户编辑进货车商品
|
||||
*
|
||||
* @param editDTO 编辑进货车商品入参
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer update(ShoppingCartEditDTO editDTO) {
|
||||
// 获取当前用户
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
ShoppingCart shoppingCart = Optional.ofNullable(this.shopCartMapper.selectOne(new LambdaQueryWrapper<ShoppingCart>()
|
||||
.eq(ShoppingCart::getId, editDTO.getShoppingCartId()).eq(ShoppingCart::getDelFlag, Constants.UNDELETED)
|
||||
.eq(ShoppingCart::getUserId, loginUser.getUserId())))
|
||||
.orElseThrow(() -> new ServiceException("用户购物车不存在!", HttpStatus.ERROR));
|
||||
// 找到当前购物车明细
|
||||
List<ShoppingCartDetail> oldDetailList = this.shopCartDetailMapper.selectList(new LambdaQueryWrapper<ShoppingCartDetail>()
|
||||
.eq(ShoppingCartDetail::getShoppingCartId, editDTO.getShoppingCartId()).eq(ShoppingCartDetail::getDelFlag, Constants.UNDELETED));
|
||||
oldDetailList.forEach(x -> x.setDelFlag(Constants.DELETED));
|
||||
this.shopCartDetailMapper.updateById(oldDetailList);
|
||||
// 再新增购物车明细
|
||||
List<ShoppingCartDetail> cartDetailList = editDTO.getDetailList().stream().map(x -> BeanUtil.toBean(x, ShoppingCartDetail.class)
|
||||
.setShoppingCartId(shoppingCart.getId())).collect(Collectors.toList());
|
||||
this.shopCartDetailMapper.insert(cartDetailList);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户删除进货车商品
|
||||
*
|
||||
* @param shoppingCartId 进货车ID
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public Integer delete(Long shoppingCartId) {
|
||||
LoginUser loginUser = SecurityUtils.getLoginUser();
|
||||
ShoppingCart shopCart = Optional.ofNullable(this.shopCartMapper.selectOne(new LambdaQueryWrapper<ShoppingCart>()
|
||||
.eq(ShoppingCart::getId, shoppingCartId).eq(ShoppingCart::getDelFlag, Constants.UNDELETED)
|
||||
.eq(ShoppingCart::getUserId, loginUser.getUserId())))
|
||||
.orElseThrow(() -> new ServiceException("用户购物车不存在!", HttpStatus.ERROR));
|
||||
shopCart.setDelFlag(Constants.DELETED);
|
||||
int count = this.shopCartMapper.updateById(shopCart);
|
||||
// 找到进货车明细
|
||||
List<ShoppingCartDetail> detailList = this.shopCartDetailMapper.selectList(new LambdaQueryWrapper<ShoppingCartDetail>()
|
||||
.eq(ShoppingCartDetail::getShoppingCartId, shoppingCartId).eq(ShoppingCartDetail::getDelFlag, Constants.UNDELETED));
|
||||
detailList.forEach(x -> x.setDelFlag(Constants.DELETED));
|
||||
this.shopCartDetailMapper.updateById(detailList);
|
||||
return count;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取档口商品颜色尺码的库存
|
||||
*
|
||||
* @param stockList 库存数量
|
||||
* @param standardSizeList 当前商品的标准尺码
|
||||
* @return Map<Long, Map < Integer, Integer>>
|
||||
*/
|
||||
private Map<String, List<ShopCartDetailResDTO.SCDStoreProdSizeStockDTO>> convertSizeStock(List<StoreProductStock> stockList, List<StoreProductColorSize> standardSizeList) {
|
||||
Map<String, List<ShopCartDetailResDTO.SCDStoreProdSizeStockDTO>> colorSizeStockMap = new HashMap<>();
|
||||
if (CollectionUtils.isEmpty(stockList)) {
|
||||
return colorSizeStockMap;
|
||||
}
|
||||
// 标准尺码map
|
||||
Map<Integer, StoreProductColorSize> standardSizeMap = standardSizeList.stream().collect(Collectors.toMap(StoreProductColorSize::getSize, Function.identity()));
|
||||
Map<String, List<StoreProductStock>> map = stockList.stream().collect(Collectors.groupingBy(x -> x.getStoreProdId().toString() + x.getStoreColorId().toString()));
|
||||
map.forEach((unionId, tempStockList) -> {
|
||||
List<ShopCartDetailResDTO.SCDStoreProdSizeStockDTO> sizeStockList = new ArrayList<>();
|
||||
Integer size30Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize30(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_30)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_30);
|
||||
setStock(size30Stock);
|
||||
}});
|
||||
}
|
||||
Integer size31Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize31(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_31)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_31);
|
||||
setStock(size31Stock);
|
||||
}});
|
||||
}
|
||||
Integer size32Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize32(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_32)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_32);
|
||||
setStock(size32Stock);
|
||||
}});
|
||||
}
|
||||
Integer size33Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize33(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_33)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_33);
|
||||
setStock(size33Stock);
|
||||
}});
|
||||
}
|
||||
Integer size34Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize34(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_34)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_34);
|
||||
setStock(size34Stock);
|
||||
}});
|
||||
}
|
||||
Integer size35Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize35(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_35)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_35);
|
||||
setStock(size35Stock);
|
||||
}});
|
||||
}
|
||||
Integer size36Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize36(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_36)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_36);
|
||||
setStock(size36Stock);
|
||||
}});
|
||||
}
|
||||
Integer size37Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize37(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_37)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_37);
|
||||
setStock(size37Stock);
|
||||
}});
|
||||
}
|
||||
Integer size38Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize38(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_38)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_38);
|
||||
setStock(size38Stock);
|
||||
}});
|
||||
}
|
||||
Integer size39Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize39(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_39)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_39);
|
||||
setStock(size39Stock);
|
||||
}});
|
||||
}
|
||||
Integer size40Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize40(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_40)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_40);
|
||||
setStock(size40Stock);
|
||||
}});
|
||||
}
|
||||
Integer size41Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize41(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_41)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_41);
|
||||
setStock(size41Stock);
|
||||
}});
|
||||
}
|
||||
Integer size42Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize42(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_42)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_42);
|
||||
setStock(size42Stock);
|
||||
}});
|
||||
}
|
||||
Integer size43Stock = tempStockList.stream().map(x -> ObjectUtils.defaultIfNull(x.getSize43(), 0)).reduce(0, Integer::sum);
|
||||
if (standardSizeMap.containsKey(SIZE_43)) {
|
||||
sizeStockList.add(new ShopCartDetailResDTO.SCDStoreProdSizeStockDTO() {{
|
||||
setSize(SIZE_43);
|
||||
setStock(size43Stock);
|
||||
}});
|
||||
}
|
||||
colorSizeStockMap.put(unionId, sizeStockList);
|
||||
});
|
||||
return colorSizeStockMap;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
package com.ruoyi.xkt.service.impl;
|
||||
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import com.ruoyi.xkt.domain.UserShoppingCart;
|
||||
import com.ruoyi.xkt.mapper.UserShoppingCartMapper;
|
||||
import com.ruoyi.xkt.service.IUserShoppingCartService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 用户进货车Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2025-03-26
|
||||
*/
|
||||
@Service
|
||||
public class UserShoppingCartServiceImpl implements IUserShoppingCartService {
|
||||
@Autowired
|
||||
private UserShoppingCartMapper userShoppingCartMapper;
|
||||
|
||||
/**
|
||||
* 查询用户进货车
|
||||
*
|
||||
* @param userShopCartId 用户进货车主键
|
||||
* @return 用户进货车
|
||||
*/
|
||||
@Override
|
||||
public UserShoppingCart selectUserShoppingCartByUserShopCartId(Long userShopCartId) {
|
||||
return userShoppingCartMapper.selectUserShoppingCartByUserShopCartId(userShopCartId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询用户进货车列表
|
||||
*
|
||||
* @param userShoppingCart 用户进货车
|
||||
* @return 用户进货车
|
||||
*/
|
||||
@Override
|
||||
public List<UserShoppingCart> selectUserShoppingCartList(UserShoppingCart userShoppingCart) {
|
||||
return userShoppingCartMapper.selectUserShoppingCartList(userShoppingCart);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增用户进货车
|
||||
*
|
||||
* @param userShoppingCart 用户进货车
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertUserShoppingCart(UserShoppingCart userShoppingCart) {
|
||||
userShoppingCart.setCreateTime(DateUtils.getNowDate());
|
||||
return userShoppingCartMapper.insertUserShoppingCart(userShoppingCart);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改用户进货车
|
||||
*
|
||||
* @param userShoppingCart 用户进货车
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateUserShoppingCart(UserShoppingCart userShoppingCart) {
|
||||
userShoppingCart.setUpdateTime(DateUtils.getNowDate());
|
||||
return userShoppingCartMapper.updateUserShoppingCart(userShoppingCart);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除用户进货车
|
||||
*
|
||||
* @param userShopCartIds 需要删除的用户进货车主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteUserShoppingCartByUserShopCartIds(Long[] userShopCartIds) {
|
||||
return userShoppingCartMapper.deleteUserShoppingCartByUserShopCartIds(userShopCartIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除用户进货车信息
|
||||
*
|
||||
* @param userShopCartId 用户进货车主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteUserShoppingCartByUserShopCartId(Long userShopCartId) {
|
||||
return userShoppingCartMapper.deleteUserShoppingCartByUserShopCartId(userShopCartId);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,85 @@
|
|||
<?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.ruoyi.xkt.mapper.ShoppingCartMapper">
|
||||
|
||||
<resultMap type="ShoppingCart" id="UserShoppingCartResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="storeId" column="store_id" />
|
||||
<result property="storeProdColorSizeId" column="store_prod_color_size_id" />
|
||||
<result property="storeProdId" column="store_prod_id" />
|
||||
<result property="quantity" column="quantity" />
|
||||
<result property="version" column="version" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 主 resultMap -->
|
||||
<resultMap id="shopCartPageResultMap" type="com.ruoyi.xkt.dto.userShoppingCart.ShopCartPageResDTO">
|
||||
<!-- 映射主表字段 -->
|
||||
<id property="shoppingCartId" column="shopping_cart_id"/>
|
||||
<result property="storeId" column="store_id"/>
|
||||
<result property="storeProdId" column="store_prod_id"/>
|
||||
<result property="storeName" column="store_name"/>
|
||||
<result property="prodArtNum" column="prod_art_num"/>
|
||||
<result property="prodTitle" column="prod_title"/>
|
||||
|
||||
<!-- 使用 collection 映射 detailList -->
|
||||
<collection property="detailList" ofType="com.ruoyi.xkt.dto.userShoppingCart.ShopCartPageDetailResDTO">
|
||||
<id property="shoppingCartDetailId" column="shopping_cart_detail_id"/>
|
||||
<result property="storeProdColorId" column="store_prod_color_id"/>
|
||||
<result property="size" column="size"/>
|
||||
<result property="storeColorId" column="store_color_id"/>
|
||||
<result property="colorName" column="color_name"/>
|
||||
<result property="quantity" column="quantity"/>
|
||||
<result property="standardSize" column="standard_size"/>
|
||||
<result property="price" column="price"/>
|
||||
<result property="amount" column="amount"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<!-- 查询语句 -->
|
||||
<select id="selectShopCartPage" resultMap="shopCartPageResultMap">
|
||||
SELECT
|
||||
sc.id AS shopping_cart_id,
|
||||
s.id AS store_id,
|
||||
sc.store_prod_id,
|
||||
s.store_name,
|
||||
sp.prod_art_num,
|
||||
sp.prod_title,
|
||||
scd.id AS shopping_cart_detail_id,
|
||||
scd.store_prod_color_id,
|
||||
scd.store_color_id,
|
||||
scd.color_name,
|
||||
scd.size,
|
||||
scd.quantity,
|
||||
spcp.price,
|
||||
(scd.quantity * spcp.price) AS amount,
|
||||
FROM
|
||||
shopping_cart sc
|
||||
LEFT JOIN shopping_cart_detail scd ON sc.id = scd.shopping_cart_id
|
||||
LEFT JOIN store_product sp ON sc.store_prod_id = sp.id
|
||||
LEFT JOIN store_product_color_price spcp ON scd.store_prod_color_id = spcp.id
|
||||
LEFT JOIN store s ON sc.store_id = s.id
|
||||
WHERE
|
||||
sc.del_flag = 0
|
||||
AND sc.user_id = #{userId}
|
||||
AND sp.prod_status IN
|
||||
<foreach item="status" collection="statusList" open="(" separator="," close=")">
|
||||
#{status}
|
||||
</foreach>
|
||||
<if test="prodArtNum != null and prodArtNum != ''">
|
||||
AND sp.prod_art_num = #{prodArtNum}
|
||||
</if>
|
||||
<if test="storeName != null and storeName != ''">
|
||||
AND s.store_name = #{storeName}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
||||
|
|
@ -1,101 +0,0 @@
|
|||
<?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.ruoyi.xkt.mapper.UserShoppingCartMapper">
|
||||
|
||||
<resultMap type="UserShoppingCart" id="UserShoppingCartResult">
|
||||
<result property="id" column="id" />
|
||||
<result property="userId" column="user_id" />
|
||||
<result property="storeId" column="store_id" />
|
||||
<result property="storeProdColorSizeId" column="store_prod_color_size_id" />
|
||||
<result property="storeProdId" column="store_prod_id" />
|
||||
<result property="quantity" column="quantity" />
|
||||
<result property="version" column="version" />
|
||||
<result property="delFlag" column="del_flag" />
|
||||
<result property="createBy" column="create_by" />
|
||||
<result property="createTime" column="create_time" />
|
||||
<result property="updateBy" column="update_by" />
|
||||
<result property="updateTime" column="update_time" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectUserShoppingCartVo">
|
||||
select id, user_id, store_id, store_prod_color_size_id, store_prod_id, quantity, version, del_flag, create_by, create_time, update_by, update_time from user_shopping_cart
|
||||
</sql>
|
||||
|
||||
<select id="selectUserShoppingCartList" parameterType="UserShoppingCart" resultMap="UserShoppingCartResult">
|
||||
<include refid="selectUserShoppingCartVo"/>
|
||||
<where>
|
||||
<if test="userId != null "> and user_id = #{userId}</if>
|
||||
<if test="storeId != null "> and store_id = #{storeId}</if>
|
||||
<if test="storeProdColorSizeId != null "> and store_prod_color_size_id = #{storeProdColorSizeId}</if>
|
||||
<if test="storeProdId != null "> and store_prod_id = #{storeProdId}</if>
|
||||
<if test="quantity != null "> and quantity = #{quantity}</if>
|
||||
<if test="version != null "> and version = #{version}</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectUserShoppingCartByUserShopCartId" parameterType="Long" resultMap="UserShoppingCartResult">
|
||||
<include refid="selectUserShoppingCartVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertUserShoppingCart" parameterType="UserShoppingCart" useGeneratedKeys="true" keyProperty="userShopCartId">
|
||||
insert into user_shopping_cart
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="storeId != null">store_id,</if>
|
||||
<if test="storeProdColorSizeId != null">store_prod_color_size_id,</if>
|
||||
<if test="storeProdId != null">store_prod_id,</if>
|
||||
<if test="quantity != null">quantity,</if>
|
||||
<if test="version != null">version,</if>
|
||||
<if test="delFlag != null">del_flag,</if>
|
||||
<if test="createBy != null">create_by,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
<if test="updateBy != null">update_by,</if>
|
||||
<if test="updateTime != null">update_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="storeId != null">#{storeId},</if>
|
||||
<if test="storeProdColorSizeId != null">#{storeProdColorSizeId},</if>
|
||||
<if test="storeProdId != null">#{storeProdId},</if>
|
||||
<if test="quantity != null">#{quantity},</if>
|
||||
<if test="version != null">#{version},</if>
|
||||
<if test="delFlag != null">#{delFlag},</if>
|
||||
<if test="createBy != null">#{createBy},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
<if test="updateBy != null">#{updateBy},</if>
|
||||
<if test="updateTime != null">#{updateTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateUserShoppingCart" parameterType="UserShoppingCart">
|
||||
update user_shopping_cart
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="userId != null">user_id = #{userId},</if>
|
||||
<if test="storeId != null">store_id = #{storeId},</if>
|
||||
<if test="storeProdColorSizeId != null">store_prod_color_size_id = #{storeProdColorSizeId},</if>
|
||||
<if test="storeProdId != null">store_prod_id = #{storeProdId},</if>
|
||||
<if test="quantity != null">quantity = #{quantity},</if>
|
||||
<if test="version != null">version = #{version},</if>
|
||||
<if test="delFlag != null">del_flag = #{delFlag},</if>
|
||||
<if test="createBy != null">create_by = #{createBy},</if>
|
||||
<if test="createTime != null">create_time = #{createTime},</if>
|
||||
<if test="updateBy != null">update_by = #{updateBy},</if>
|
||||
<if test="updateTime != null">update_time = #{updateTime},</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteUserShoppingCartByUserShopCartId" parameterType="Long">
|
||||
delete from user_shopping_cart where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteUserShoppingCartByUserShopCartIds" parameterType="String">
|
||||
delete from user_shopping_cart where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue