src/com/shop/service/OsProductCartService.java
(开头部分) 12KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
package com.shop.service;
import com.shop.dao.OsProductMapper;
import com.shop.dao.OsProductSpecificationMapper;
import com.shop.dao.OsSpecificationAttributeMapper;
import com.shop.po.OsProduct;
import com.shop.po.OsProductSpecification;
import com.shop.po.OsSpecificationAttribute;
import com.shop.vo.CartVO;
import com.shop.vo.ShoppingCartVO;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpSession;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
/**
* @Author 康健
* @Date 2017/8/11 16:15
*/
@Service
public class OsProductCartService {
@Autowired
private OsProductSpecificationMapper osProductSpecificationMapper;
@Autowired
private OsProductMapper osProductMapper;
@Autowired
private OsSpecificationAttributeMapper osSpecificationAttributeMapper;
//添加购物车商品
public CartVO insertProductCart(Long productSpecNumber, HttpSession session) {
OsProductSpecification osProductSpecification = osProductSpecificationMapper.selectByProductSpecNumber(productSpecNumber);
CartVO cartVO = (CartVO) session.getAttribute("cart");
//如果当前商品有规格,规格商品已在购物车 数量加1
if(osProductSpecification != null && (!"".equals(osProductSpecification.getSpec()))) {
Boolean flag = false;
List<ShoppingCartVO> shoppingCartVOs = cartVO.getShoppingCartVOs();
for (ShoppingCartVO vo : shoppingCartVOs) {
if (osProductSpecification.getProductSpecNumber().longValue()==(vo.getProductSpecNumber().longValue())) {
vo.setBuyNumber(vo.getBuyNumber() + 1);
flag = true;
break;
}
}
if (flag == false) {
//如果当前商品不在购物车 新建vo并加入
ShoppingCartVO shoppingCartVO = new ShoppingCartVO();
shoppingCartVO.setProductSpecNumber(osProductSpecification.getProductSpecNumber());
shoppingCartVO.setBuyNumber(1);
shoppingCartVO.setStock(osProductSpecification.getStock());
shoppingCartVO.setSalesVolume(osProductSpecification.getSalesVolume());
shoppingCartVO.setPrice(osProductSpecification.getPrice());
shoppingCartVO.setSpec(osProductSpecification.getSpec());
shoppingCartVO.setProductNumber(osProductMapper.selectProductNumberByProductId(osProductSpecification.getProductId()));
后面还有 196 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。