fuint-application/application-service/src/main/java/com/fuint/application/service/cart/CartServiceImpl.java
(开头部分) 4KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package com.fuint.application.service.cart;
import com.fuint.application.dao.entities.MtCart;
import com.fuint.application.dao.entities.MtGoodsSku;
import com.fuint.application.dao.repositories.MtCartRepository;
import com.fuint.application.dao.repositories.MtGoodsSkuRepository;
import org.springframework.data.jpa.domain.Specification;
import com.fuint.exception.BusinessCheckException;
import com.fuint.application.enums.StatusEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* 购物车业务实现类
* Created by FSQ
* Contact wx fsq_better
* Site https://www.fuint.cn
*/
@Service
public class CartServiceImpl implements CartService {
@Autowired
private MtCartRepository cartRepository;
@Autowired
private MtGoodsSkuRepository goodsSkuRepository;
/**
* 保存购物车
*
* @param reqDto
* @throws BusinessCheckException
*/
@Override
public Integer saveCart(MtCart reqDto, String action) throws BusinessCheckException {
MtCart mtCart = new MtCart();
Integer cartId = 1;
if (reqDto.getGoodsId() > 0) {
mtCart.setGoodsId(reqDto.getGoodsId());
}
if (reqDto.getUserId() > 0) {
mtCart.setUserId(reqDto.getUserId());
}
// 数量为0,删除购物车
if (reqDto.getNum() == 0 && reqDto.getId() > 0) {
this.removeCart(reqDto.getId()+"");
} else if (reqDto.getNum() == 0 && action.equals("-")) {
cartRepository.deleteCartItem(reqDto.getUserId(), reqDto.getGoodsId(), reqDto.getSkuId());
}
// 校验skuId是否正确
if (reqDto.getSkuId() != null) {
if (reqDto.getSkuId() > 0) {
Map<String, Object> param = new HashMap<>();
param.put("EQ_goodsId", reqDto.getGoodsId().toString());
param.put("EQ_id", reqDto.getSkuId().toString());
后面还有 91 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。