更新sql和代码规范修改
This commit is contained in:
@ -37,7 +37,6 @@ public class StoreCartController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
@GetMapping("/page")
|
||||
@Operation(summary = "获得购物车分页")
|
||||
@PreAuthorize("@ss.hasPermission('cart:store-cart:query')")
|
||||
@ -46,5 +45,4 @@ public class StoreCartController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -2,15 +2,16 @@ package co.yixiang.yshop.module.cart.controller.admin.storecart.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* 购物车 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
* 购物车 Base VO,提供给添加、修改、详细的子 VO 使用
|
||||
* 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成
|
||||
*/
|
||||
@Data
|
||||
public class StoreCartBaseVO {
|
||||
|
||||
|
||||
@ -1,10 +1,13 @@
|
||||
package co.yixiang.yshop.module.cart.controller.admin.storecart.vo;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import co.yixiang.yshop.framework.common.pojo.PageParam;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import static co.yixiang.yshop.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||
|
||||
@ -2,6 +2,7 @@ package co.yixiang.yshop.module.cart.controller.admin.storecart.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Schema(description = "管理后台 - 购物车 Response VO")
|
||||
@ -16,7 +17,7 @@ public class StoreCartRespVO extends StoreCartBaseVO {
|
||||
@Schema(description = "添加时间", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED )
|
||||
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private String storeName;
|
||||
|
||||
@Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
|
||||
@ -64,10 +64,10 @@ public class AppCartController {
|
||||
@PreAuthenticated
|
||||
@GetMapping("/count")
|
||||
@Operation(summary = "获取数量")
|
||||
public CommonResult<Map<String,Object>> count(){
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
public CommonResult<Map<String, Object>> count() {
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
Long uid = getLoginUserId();
|
||||
map.put("count",appStoreCartService.getUserCartNum(uid));
|
||||
map.put("count", appStoreCartService.getUserCartNum(uid));
|
||||
return success(map);
|
||||
}
|
||||
|
||||
@ -78,21 +78,21 @@ public class AppCartController {
|
||||
@PostMapping("/add")
|
||||
@Operation(summary = "添加购物车")
|
||||
|
||||
public CommonResult<Map<String,Object>> add(@Validated @RequestBody AppCartParam cartParam){
|
||||
public CommonResult<Map<String, Object>> add(@Validated @RequestBody AppCartParam cartParam) {
|
||||
Long uid = getLoginUserId();
|
||||
if(OrderTypeEnum.CAMPAIGN_ORDER.getValue().equals(cartParam.getOrderType())){
|
||||
if (OrderTypeEnum.CAMPAIGN_ORDER.getValue().equals(cartParam.getOrderType())) {
|
||||
// 判断是否重复参加拼团
|
||||
if(ObjectUtil.isNotEmpty(cartParam.getTeamworkId()))
|
||||
if (ObjectUtil.isNotEmpty(cartParam.getTeamworkId()))
|
||||
teamworkInfoService.joinJudge(uid, cartParam.getTeamworkId());
|
||||
// 活动商品购买数量限制
|
||||
appCampaignInfoService.numberJudge(new CampaignNumberJudgeVO
|
||||
(cartParam.getUniqueId(), uid, cartParam.getCartNum()));
|
||||
}
|
||||
// 加入购物车并返回购物车id
|
||||
Map<String,Object> map = new LinkedHashMap<>();
|
||||
map.put("cartId",appStoreCartService.addCart(uid,cartParam.getProductId(),cartParam.getCartNum(),
|
||||
cartParam.getUniqueId(),cartParam.getIsNew(),cartParam.getCombinationId(),
|
||||
cartParam.getSecKillId(),cartParam.getBargainId()));
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("cartId", appStoreCartService.addCart(uid, cartParam.getProductId(), cartParam.getCartNum(),
|
||||
cartParam.getUniqueId(), cartParam.getIsNew(), cartParam.getCombinationId(),
|
||||
cartParam.getSecKillId(), cartParam.getBargainId()));
|
||||
return success(map);
|
||||
}
|
||||
|
||||
@ -103,9 +103,9 @@ public class AppCartController {
|
||||
@PreAuthenticated
|
||||
@GetMapping("/cart/list")
|
||||
@Operation(summary = "购物车列表")
|
||||
public CommonResult<Map<String,Object>> getList(){
|
||||
public CommonResult<Map<String, Object>> getList() {
|
||||
Long uid = getLoginUserId();
|
||||
return success(appStoreCartService.getUserProductCartList(uid,"",null));
|
||||
return success(appStoreCartService.getUserProductCartList(uid, "", null));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,9 +114,9 @@ public class AppCartController {
|
||||
@PreAuthenticated
|
||||
@PostMapping("/num")
|
||||
@Operation(summary = "修改产品数量")
|
||||
public CommonResult<Boolean> cartNum(@Validated @RequestBody AppCartNumParam param){
|
||||
public CommonResult<Boolean> cartNum(@Validated @RequestBody AppCartNumParam param) {
|
||||
Long uid = getLoginUserId();
|
||||
appStoreCartService.changeUserCartNum(param.getId(), param.getNumber(),uid);
|
||||
appStoreCartService.changeUserCartNum(param.getId(), param.getNumber(), uid);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ public class AppCartController {
|
||||
@PreAuthenticated
|
||||
@PostMapping("/cart/del")
|
||||
@Operation(summary = "购物车删除产品")
|
||||
public CommonResult<Boolean> cartDel(@Validated @RequestBody AppCartIdsParm parm){
|
||||
public CommonResult<Boolean> cartDel(@Validated @RequestBody AppCartIdsParm parm) {
|
||||
Long uid = getLoginUserId();
|
||||
appStoreCartService.removeUserCart(uid, parm.getIds());
|
||||
return success(true);
|
||||
@ -138,9 +138,9 @@ public class AppCartController {
|
||||
@PreAuthenticated
|
||||
@PostMapping("/cart/changeSku")
|
||||
@Operation(summary = "购物车更换产品规格")
|
||||
public CommonResult<Boolean> changeSku(@Validated @RequestBody AppCartChangeSkuParam param){
|
||||
public CommonResult<Boolean> changeSku(@Validated @RequestBody AppCartChangeSkuParam param) {
|
||||
Long uid = getLoginUserId();
|
||||
appStoreCartService.changeSku(uid,param);
|
||||
appStoreCartService.changeSku(uid, param);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
@ -152,7 +152,5 @@ public class AppCartController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -18,8 +18,8 @@ import javax.validation.constraints.NotNull;
|
||||
@Schema(description = "用户 APP - 购物车数量参数")
|
||||
public class AppCartNumParam {
|
||||
|
||||
@Min(value = 1,message = "数量不在合法范围内")
|
||||
@Max(value = 9999,message = "数量不在合法范围内")
|
||||
@Min(value = 1, message = "数量不在合法范围内")
|
||||
@Max(value = 9999, message = "数量不在合法范围内")
|
||||
@Schema(description = "购物车数量", required = true)
|
||||
private Integer number;
|
||||
|
||||
|
||||
@ -19,8 +19,8 @@ import javax.validation.constraints.NotNull;
|
||||
@Schema(description = "用户 APP - 添加购物车参数")
|
||||
public class AppCartParam {
|
||||
|
||||
@Min(value = 1,message = "数量不在合法范围内")
|
||||
@Max(value = 9999,message = "数量不在合法范围内")
|
||||
@Min(value = 1, message = "数量不在合法范围内")
|
||||
@Max(value = 9999, message = "数量不在合法范围内")
|
||||
@Schema(description = "购物车数量", required = true)
|
||||
private Integer cartNum;
|
||||
|
||||
|
||||
@ -1,9 +1,11 @@
|
||||
package co.yixiang.yshop.module.cart.dal.dataobject.storecart;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import co.yixiang.yshop.framework.mybatis.core.dataobject.BaseDO;
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ public interface StoreCartMapper extends BaseMapperX<StoreCartDO> {
|
||||
"where sc.deleted = 0 " +
|
||||
"<if test =\"nickname !='' and nickname != null \">and su.nickname like CONCAT('%', #{nickname}, '%')</if>" +
|
||||
"order by sc.create_time desc</script>")
|
||||
Long pageListCount( @Param("nickname") String nickname);
|
||||
Long pageListCount(@Param("nickname") String nickname);
|
||||
|
||||
@Select("select IFNULL(sum(ysc.cart_num),0) from yshop_store_cart as ysc " +
|
||||
"inner join yshop_store_product_attr_value as yspav on ysc.product_attr_unique = yspav.`unique` " +
|
||||
|
||||
@ -18,6 +18,7 @@ public interface AppStoreCartService extends IService<StoreCartDO> {
|
||||
|
||||
/**
|
||||
* 返回当前用户购物车总数量
|
||||
*
|
||||
* @param uid 用户id
|
||||
* @return int
|
||||
*/
|
||||
@ -25,51 +26,54 @@ public interface AppStoreCartService extends IService<StoreCartDO> {
|
||||
|
||||
/**
|
||||
* 添加购物车
|
||||
* @param uid 用户id
|
||||
* @param productId 普通产品编号
|
||||
* @param cartNum 购物车数量
|
||||
*
|
||||
* @param uid 用户id
|
||||
* @param productId 普通产品编号
|
||||
* @param cartNum 购物车数量
|
||||
* @param productAttrUnique 属性唯一值
|
||||
* @param isNew 1 加入购物车直接购买 0 加入购物车
|
||||
* @param combinationId 拼团id
|
||||
* @param seckillId 秒杀id
|
||||
* @param bargainId 砍价id
|
||||
* @param isNew 1 加入购物车直接购买 0 加入购物车
|
||||
* @param combinationId 拼团id
|
||||
* @param seckillId 秒杀id
|
||||
* @param bargainId 砍价id
|
||||
* @return 购物车id
|
||||
*/
|
||||
long addCart(Long uid,Long productId,Integer cartNum, String productAttrUnique,
|
||||
Integer isNew,Long combinationId,Long seckillId,Long bargainId);
|
||||
long addCart(Long uid, Long productId, Integer cartNum, String productAttrUnique,
|
||||
Integer isNew, Long combinationId, Long seckillId, Long bargainId);
|
||||
|
||||
|
||||
/**
|
||||
* 检测商品/秒杀/砍价/拼团库存
|
||||
* @param uid 用户ID
|
||||
* @param productId 产品ID
|
||||
* @param cartNum 购买数量
|
||||
* @param productAttrUnique 商品属性Unique
|
||||
*
|
||||
* @param uid 用户ID
|
||||
* @param productId 产品ID
|
||||
* @param cartNum 购买数量
|
||||
* @param productAttrUnique 商品属性Unique
|
||||
*/
|
||||
void checkProductStock(Long uid, Long productId, Integer cartNum, String productAttrUnique);
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 购物车列表
|
||||
* @param uid 用户id
|
||||
*
|
||||
* @param uid 用户id
|
||||
* @param cartIds 购物车id,多个逗号隔开
|
||||
* @param status 0-购购物车列表,2-活动商品
|
||||
* @param status 0-购购物车列表,2-活动商品
|
||||
* @return map valid-有效购物车 invalid-失效购物车
|
||||
*/
|
||||
Map<String,Object> getUserProductCartList(Long uid, String cartIds, Integer status);
|
||||
Map<String, Object> getUserProductCartList(Long uid, String cartIds, Integer status);
|
||||
|
||||
/**
|
||||
* 改购物车数量
|
||||
* @param cartId 购物车id
|
||||
*
|
||||
* @param cartId 购物车id
|
||||
* @param cartNum 数量
|
||||
* @param uid uid
|
||||
* @param uid uid
|
||||
*/
|
||||
void changeUserCartNum(Long cartId,int cartNum,Long uid);
|
||||
void changeUserCartNum(Long cartId, int cartNum, Long uid);
|
||||
|
||||
/**
|
||||
* 删除购物车
|
||||
*
|
||||
* @param uid uid
|
||||
* @param ids 购物车id集合
|
||||
*/
|
||||
@ -77,7 +81,8 @@ public interface AppStoreCartService extends IService<StoreCartDO> {
|
||||
|
||||
/**
|
||||
* 修改购物车支付状态
|
||||
* @param cartIds 购物车id列表
|
||||
*
|
||||
* @param cartIds 购物车id列表
|
||||
*/
|
||||
void updateCartPayStatus(List<String> cartIds);
|
||||
|
||||
@ -86,7 +91,7 @@ public interface AppStoreCartService extends IService<StoreCartDO> {
|
||||
* @param uid 用户id
|
||||
* @param param 修改参数
|
||||
*/
|
||||
void changeSku(Long uid,AppCartChangeSkuParam param);
|
||||
void changeSku(Long uid, AppCartChangeSkuParam param);
|
||||
|
||||
/**
|
||||
* 查询购物车可用优惠券
|
||||
|
||||
@ -20,7 +20,7 @@ import co.yixiang.yshop.module.product.dal.dataobject.storeproduct.StoreProductD
|
||||
import co.yixiang.yshop.module.product.dal.dataobject.storeproductattrvalue.StoreProductAttrValueDO;
|
||||
import co.yixiang.yshop.module.product.service.campaigninfo.AppCampaignInfoService;
|
||||
import co.yixiang.yshop.module.product.service.productcouponrelation.AppCouponRelationService;
|
||||
import co.yixiang.yshop.module.product.service.productcouponrelation.dto.CartCouponDto;
|
||||
import co.yixiang.yshop.module.product.service.productcouponrelation.dto.CartCouponDTO;
|
||||
import co.yixiang.yshop.module.product.service.storeproduct.AppStoreProductService;
|
||||
import co.yixiang.yshop.module.product.service.storeproductattrvalue.StoreProductAttrValueService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@ -190,7 +190,7 @@ public class AppStoreCartServiceImpl extends ServiceImpl<StoreCartMapper, StoreC
|
||||
Map<Long, AppStoreProductRespVo> productMap = null;
|
||||
Map<String, StoreProductAttrValueDO> skuMap = null;
|
||||
Map<String, CampaignSkuVO> campaignSkuVOMap = null;
|
||||
if(CollectionUtils.isNotEmpty(carts)){
|
||||
if (CollectionUtils.isNotEmpty(carts)) {
|
||||
// 查询商品列表
|
||||
List<Long> productIds = carts.stream().map(StoreCartDO::getProductId).collect(Collectors.toList());
|
||||
List<AppStoreProductRespVo> products = appStoreProductService.getStoreProductByIds(productIds);
|
||||
@ -352,9 +352,9 @@ public class AppStoreCartServiceImpl extends ServiceImpl<StoreCartMapper, StoreC
|
||||
Long uid = getLoginUserId();
|
||||
Map<String, Object> cartGroup = getUserProductCartList(uid, cartIds, ShopConstants.YSHOP_ONE_NUM);
|
||||
List<AppStoreCartQueryVo> cartInfo = (List<AppStoreCartQueryVo>) cartGroup.get("valid");
|
||||
List<CartCouponDto> cartCouponDtoList = new ArrayList<>();
|
||||
List<CartCouponDTO> cartCouponDtoList = new ArrayList<>();
|
||||
for (AppStoreCartQueryVo vo : cartInfo) {
|
||||
cartCouponDtoList.add(new CartCouponDto(vo.getProductId(), vo.getProductAttrUnique(), NumberUtil.mul(vo.getTruePrice(), vo.getCartNum())));
|
||||
cartCouponDtoList.add(new CartCouponDTO(vo.getProductId(), vo.getProductAttrUnique(), NumberUtil.mul(vo.getTruePrice(), vo.getCartNum())));
|
||||
}
|
||||
return couponRelationService.searchCartCoupon(cartCouponDtoList, null);
|
||||
}
|
||||
|
||||
@ -29,5 +29,4 @@ public interface StoreCartService {
|
||||
PageResult<StoreCartRespVO> getStoreCartPage(StoreCartPageReqVO pageReqVO);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -44,7 +44,7 @@ public class StoreCartServiceImpl implements StoreCartService {
|
||||
|
||||
@Override
|
||||
public PageResult<StoreCartRespVO> getStoreCartPage(StoreCartPageReqVO pageReqVO) {
|
||||
List<StoreCartRespVO> list = storeCartMapper.pageList(new Page<>(pageReqVO.getPageNo(),pageReqVO.getPageSize()),
|
||||
List<StoreCartRespVO> list = storeCartMapper.pageList(new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()),
|
||||
pageReqVO.getNickname());
|
||||
|
||||
return new PageResult<>(list, storeCartMapper.pageListCount(pageReqVO.getNickname()));
|
||||
|
||||
Reference in New Issue
Block a user