SSM实现校园超市管理系统
之前寒假写的一个小项目,idea写的,用了maven工程,Spring+SpringMVC+MyBatis框架技术实现校园超市系统。
之前加的人有点多,源码+sql+jar已上传到 https://download.csdn.net/download/qq_38663663/11076831
里边的sql放错了,正确的:链接:https://pan.baidu.com/s/1rhUfNyA4LmHpjTsxzVbvcw
提取码:3760
这是之前发布的小项目,还差购物车和订单页面没有实现,这次将会补齐,新增添加收货地址,新增支付宝和微信支付。
1、数据库表新增购物车、订单、订单类目、收货信息表,sql文件会给出
2.1、POJO层新加 Cart
public class Cart {
/*购物车主键id*/
private Integer id;
/*客户id*/
private Integer customerId;
/*商品对象*/
private Product product;
/*商品数量*/
private Integer productNum;
/*商品加入购物车的时间*/
private Date createTime;
/*商品总价*/
private Double totalPrice;
private Integer status;
}
2.2、Oder
public class Order {
/*订单id*/
private Integer id;
/*订单编号*/
private String orderNumber;
/*客户对象*/
private Customer customer;
/*商品总价*/
private Double price;
/*订单的创建时间*/
private Date createDate;
/*商品数量*/
private Integer productNumber;
/**
*功能描述:订单的状态
* 0 表示未支付
* 1 表示已经付未发货
* 2 表示已支付已发货
* 3 表示已发货未收货
* 4 表示交易完成
* 5 表示客户删除的订单,设置为无效
*/
private Integer status;
/*收货地址*/
private String address;
}
2.3、OderItem
public class OrderItem implements Serializable{
/*订单类目id*/
private Integer id;
/*商品数量*/
private Integer num;
/*商品小计*/
private Double price;
/*商品对象*/
private Product product;
/*所属于哪个订单,订单对象*/
private Order order;
}
2.4、Shipping
public class Shipping {
/*主键id*/
private Integer id;
/*客户id*/
private Integer customerId;
/*收货人姓名*/
private String receiverName;
/*收货人的座机号码*/
private String receiverPhone;
/*收货人的手机号码*/
private String receiverMobile;
/*省份名称*/
private String receiverProvince;
/*城市名称*/
private String receiverCity;
/*区 县*/
private String receiverDistrict;
/*邮政编码*/
private String zipCode;
/*详细地址内容*/
private String addressDetail;
/*创建时间*/
private Date createTime;
/*更新时间*/
private Date updateTime;
/*收货地址的状态:默认为0,如果设置为默认地址后则修改为1*/
private Integer status;
}
3.1、CartDao
public interface CartDao {
int insertCart(Cart cart);
List<Cart> selectAllCartByCustomerId(Integer customerId);
Cart selectCartByCustomerIdAndCartId(@Param("customerId") Integer customerId,@Param("cartId") Integer cartId);
Cart selectCartByCustomerIdAndProductId(@Param("customerId") Integer customerId,@Param("productId") Integer productId);
Cart selectRedirectCartByCustomerIdAndProductId(@Param("customerId") Integer customerId,@Param("productId") Integer productId);
int updateCartNumAndTotalPriceById(@Param("id") Integer id, @Param("productNum") Integer num,@Param("totalPrice") Double price);
int deleteCartById(Integer id);
int updateCartStatusByCustomerId(@Param("customerId") Integer id,@Param("status") Integer status);
int updateCartStatusByCartIdAndCustomerId(@Param("cartId") Integer cartId,
@Param("customerId") Integer id,
@Param("status")Integer status);
int updateCartStatusByCartIdAndCustomerIds(@Param("cartIds") Integer[] cartIds,
@Param("customerId") Integer customerId,
@Param("status") Integer status);
int updateProductNumAndPriceByCartIdAndCustomerIdAndStatus(@Param("cartId") Integer cartId,
@Param("productNum") Integer productNum,
@Param("customerId") Integer id,
@Param("status") int status,
@Param("totalPrice")Double totalPrice);
List<Cart> selectCartByCartIdsAndCustomerId(@Param("cartIds") Integer[] orderCartIds,
@Param("customerId") Integer id,
@Param("status") int status);
List<Cart> selectRedirectCartByCartIdsAndCustomerId(@Param("cartIds") Integer[] orderCartIds,
@Param("customerId") Integer id,
@Param("status") int status);
}
3.2、OrderDao
public interface OrderDao {
int insertOrder(Order order);
Order selectOrderIdByOrderNoAndCustomerId(@Param("orderNo") String orderNo, @Param("customerId") Integer id);
List<Order> selectAllOrderByCustomerId(@Param("customerId") Integer id);
int updateOrderStatusByCustomerIdAndOrderId(@Param("customerId") Integer id,
@Param("orderId") Integer orderId,
@Param("status") Integer status);
List<Order> selectOrdersByCustomerId(@Param("customerId") Integer id,@Param("status") Integer status);
int updateOrderStatusByCustomerIdAndOrderNo(@Param("customerId") Integer id,
@Param("orderNumber") String out_trade_no,
@Param("status") Integer status);
int updateOrderStatusByOrderNo(@Param("orderNumber") String out_trade_no,
@Param("status") Integer status);
Order selectOrderByOutTradeNo(String outTradeNo);
}
3.3、OrderItemDao
public interface OrderItemDao {
int insertOrderItem(OrderItem orderItem);
int insertOrderItemByOrderItems(@Param("orderItemList") List<OrderItem> orderItemList);
List<OrderItem> selectOrderItemsByOrder(Integer orderId);
List<OrderItem> selectOrderItemsByOrderIds();
}
3.4、ShippingDao
public interface ShippingDao {
Shipping selectShippingByCustomerIdAndShippingId(@Param("customerId") Integer customerId,
@Param("shippingId") Integer shippingId);
List<Shipping> selectAllShippings(@Param("customerId") Integer customerId , @Param("status") Integer status);
int insertShipping(Shipping shipping);
int deleteShippingByIdAndCustomerId(@Param("shippingId") Integer shippingId,
@Param("customerId") Integer customerId,
@Param("status") int status,
@Param("updateTime") Date updateTime);
int updateByShipping(Shipping shipping);
}
4.1、CartMapper
【Mybatis 配置文件各类参数】
A、resultType和resultMap的区别
如果你搜索只是返回一个值,比如说String ,或者是int,那你直接用resultType就行了。 但是你如果是返回一个复杂的对象,就必须定义好这个对象的resultMap。
其实reultType也可以返回对象,但是须返回这个对象所有信息了,适用用普通的完整返回。 因为resultmap那段是我们自己指定的,可能指定的属性只是User的一部分,而且还可以设置默认值,这是result type做不到的。
B、parameterType为输入参数,parameterType有基本数据类型和复杂的数据类型配置。
1.基本数据类型,如输入参数只有一个,其数据类型可以是基本的数据类型,也可以是
自己定的类类型。包括int,String,Integer,Date,如下:
2.复杂数据类型:包含java实体类,map。
3.另外MyBatis还提供了一个使用注解来传入多个参数的方式。这种方式需要在接口的参数上添加@Param注解
C、 useGeneratedKeys 参数只针对 insert 语句生效,默认为 false。当设置为 true 时,表示如果插入的表以自增列为主键,则允许 JDBC 支持自动生成主键,并可将自动生成的主键返回。
D、根据ids(多个id)查询用户信息。比如查询id为16 /22 /26/28 /29这五个id的用户信息。
使用in+foreach来处理
<foreach collection="list" item="item" open="(" close=")" separator="," index="">
#{item.studentId}
</foreach>
解释含义:
foreach的主要用在构建in条件中,它可以在SQL语句中进行迭代一个集合。
foreach元素的属性主要有 item,index,collection,open,separator,close。
item集合中每一个元素进行迭代时的别名,
index表示在迭代过程中,每次迭代到的位置,
open该语句以什么开始,
separator在每次进行迭代之间以什么符号作为分隔 符,
close以什么结束,
在使用foreach的时候最关键的也是最容易出错的就是collection属性,
该属性是必须指定的,但是在不同情况 下,该属性的值是不一样的,
主要有一下3种情况:
1. 如果传入的是单参数且参数类型是一个List的时候,collection属性值为list
2. 如果传入的是单参数且参数类型是一个array数组的时候,collection的属性值为array
3. 如果传入的参数是多个的时候,我们就需要把它们封装成一个Map了
<?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">
<!--设置dao接口-->
<mapper namespace="com.xmlvhy.shop.dao.CartDao">
<resultMap id="CartMap" type="Cart">
<id column="id" property="id"/>
<result column="customer_id" property="customerId"/>
<result column="product_num" property="productNum"/>
<result column="total_price" property="totalPrice"/>
<result column="status" property="status"/>
<result column="create_time" property="createTime"/>
<association property="product" javaType="Product" column="product_id">
<id property="id" column="p.id"/>
<result property="name" column="name"/>
<result property="price" column="price"/>
<result property="image" column="image"/>
</association>
</resultMap>
<sql id="CartColumn">
id,
customer_id,
product_id,
product_num,
total_price,
status,
create_time
</sql>
<select id="selectCartByCustomerIdAndCartId" resultMap="CartMap">
select t.id,t.customer_id,t.product_num,t.total_price,t.status, t.create_time,p.id 'p.id',p.name,p.image,p.price
from t_cart t
left join t_product p
on t.product_id = p.id
where t.id = #{cartId} and customer_id = #{customerId} and status = 1
</select>
<select id="selectCartByCustomerIdAndProductId" resultType="Cart">
select
<include refid="CartColumn"/>
from t_cart
where customer_id = #{customerId} and product_id = #{productId} and status = 1
</select>
<select id="selectRedirectCartByCustomerIdAndProductId" resultType="Cart">
select
<include refid="CartColumn"/>
from t_cart
where customer_id = #{customerId} and product_id = #{productId} and status = 2
</select>
<insert id="insertCart" parameterType="Cart" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
insert into t_cart
(customer_id, product_id, product_num,total_price,status,create_time)
values
(#{customerId},#{product.id},#{productNum},#{totalPrice},#{status},#{createTime})
</insert>
<select id="selectAllCartByCustomerId" parameterType="integer" resultMap="CartMap">
select t.id,t.customer_id,t.product_num,t.total_price,t.status, t.create_time,p.id 'p.id',p.name,p.image,p.price
from t_cart t
left join t_product p
on t.product_id = p.id
where customer_id = #{customerId} and status = 1
</select>
<select id="selectCartByCartIdsAndCustomerId" resultMap="CartMap">
select t.id,t.customer_id,t.product_num,t.total_price,t.status, t.create_time,p.id 'p.id',p.name,p.image,p.price
from t_cart t
left join t_product p
on t.product_id = p.id
where t.id in
<if test="cartIds != null and cartIds.length > 0">
<foreach collection="cartIds" item="cartId" open="(" separator="," close=")">
#{cartId}
</foreach>
</if>
and customer_id = #{customerId} and status = #{status}
</select>
<select id="selectRedirectCartByCartIdsAndCustomerId" resultMap="CartMap">
select t.id,t.customer_id,t.product_num,t.total_price,t.status, t.create_time,p.id 'p.id',p.name,p.image,p.price
from t_cart t
left join t_product p
on t.product_id = p.id
where t.id in
<if test="cartIds != null and cartIds.length > 0">
<foreach collection="cartIds" item="cartId" open="(" separator="," close=")">
#{cartId}
</foreach>
</if>
and customer_id = #{customerId} and status = #{status}
</select>
<update id="updateCartNumAndTotalPriceById">
update t_cart
set product_num = #{productNum},
total_price = #{totalPrice}
where id = #{id}
</update>
<update id="updateCartStatusByCustomerId">
update t_cart
set status = #{status}
where customer_id = #{customerId}
</update>
<update id="updateCartStatusByCartIdAndCustomerId">
update t_cart
set status = #{status}
where id = #{cartId} and customer_id = #{customerId}
</update>
<!--TODO: 更新数据,当条件是一个整型的数组的时候,使用 foreach 语句-->
<update id="updateCartStatusByCartIdAndCustomerIds">
update t_cart
set status = #{status}
where id in
<if test="cartIds != null and cartIds.length > 0">
<foreach collection="cartIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
and customer_id = #{customerId}
</update>
<update id="updateProductNumAndPriceByCartIdAndCustomerIdAndStatus">
update t_cart
set product_num = #{productNum},
total_price = #{totalPrice}
where id = #{cartId} and customer_id = #{customerId} and status = #{status}
</update>
<delete id="deleteCartById" parameterType="integer">
delete from t_cart
where id = #{id}
</delete>
</mapper>
5.1、CartServiceImpl
/**
* Author: jx
* Date: 2019-03-19 16:07
* Description: 购物车业务实现类
*/
@Service
@Transactional(propagation = Propagation.REQUIRED,rollbackFor = Exception.class)
public class CartServiceImpl implements CartService {
@Autowired
private CartDao cartDao;
@Autowired
private ProductDao productDao;
/**
*功能描述: 添加商品到购物车
* @Author jx
* @Date 17:09 2019/03/19
* @Param [cartVo]
* @return java.lang.Boolean
*/
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
@Override
public Boolean saveToCart(CartVo cartVo) {
Cart cartResult = cartDao.selectCartByCustomerIdAndProductId(cartVo.getCustomerId(), cartVo.getProductId());
//先查询一下购物车中是否有此商品,没有则插入保存,有的话就更新购物车的商品数量就可以了
if (cartResult == null) {
Cart cart = new Cart();
Product product = productDao.selectProductById(cartVo.getProductId());
//计算总价
Double totalPrice = product.getPrice() * cartVo.getProductNum();
BeanUtils.copyProperties(cartVo,cart);
cart.setTotalPrice(totalPrice);
cart.setProduct(product);
//设置状态,默认是有效的
cart.setStatus(CartConstant.CART_PRODUCT_STATUS_VALID);
cart.setCreateTime(new Date());
int rows = cartDao.insertCart(cart);
if (rows >= 1) {
return true;
}else{
return false;
}
}
//更新购物车的商品数量
int productSums = cartResult.getProductNum() + cartVo.getProductNum();
Product pd = productDao.selectProductById(cartVo.getProductId());
//更新商品总价格
Double priceSum = pd.getPrice() * productSums;
int rows = cartDao.updateCartNumAndTotalPriceById(cartResult.getId(), productSums,priceSum);
if (rows >= 1) {
return true;
}
return false;
}
/**
*功能描述: 根据客户 id 查找他所有购物车信息
* @Author jx
* @Date 19:54 2019/03/19
* @Param [customerId]
* @return java.util.List<com.xmlvhy.shop.pojo.Cart>
*/
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
@Override
public List<Cart> findCustomerAllCarts(Integer customerId) {
return cartDao.selectAllCartByCustomerId(customerId);
}
/**
*功能描述: 清空用户的购物车
* @Author jx
* @Date 19:22 2019/03/20
* @Param [id]
* @return java.lang.Boolean
*/
@Override
public Boolean modifyCartStatus(Integer id) {
int rows = cartDao.updateCartStatusByCustomerId(id, CartConstant.CART_PRODUCT_STATUS_ISVALID);
if (rows >= 1) {
return true;
}
return false;
}
/**
*功能描述: 从购物车中移除某一商品
* @Author jx
* @Date 10:42 2019/03/21
* @Param [cartId, id]
* @return java.lang.Boolean
*/
@Override
public Boolean modifyCartStatusByCartIdAndCustomerId(Integer cartId, Integer id) {
int rows = cartDao.updateCartStatusByCartIdAndCustomerId(cartId, id, CartConstant.CART_PRODUCT_STATUS_ISVALID);
if (rows >= 1) {
return true;
}
return false;
}
/**
*功能描述: 从购物车中移除选中的商品
* @Author jx
* @Date 13:01 2019/03/21
* @Param [cartIds, customerId]
* @return java.lang.Boolean
*/
@Override
public Boolean modifyCartStatusByCartIdAndCustomerIds(Integer[] cartIds, Integer customerId) {
int rows = cartDao.updateCartStatusByCartIdAndCustomerIds(cartIds, customerId, CartConstant.CART_PRODUCT_STATUS_ISVALID);
if (rows >= 1) {
return true;
}
return false;
}
/**
*功能描述: 购物车页面修改商品数量 以及总价格更新
* @Author jx
* @Date 15:25 2019/03/22
* @Param [cartId, productNum, id]
* @return java.lang.Boolean
*/
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
@Override
public Boolean modifyNumAndPriceByCartIdAndCustomerIdAndStatus(Integer cartId, Integer productNum, Integer id) {
//拿到该商品信息,计算修改数量后的总价格
Cart cart = cartDao.selectCartByCustomerIdAndCartId(id, cartId);
Double totalPrice = (cart.getProduct().getPrice()) * productNum;
int rows = cartDao.updateProductNumAndPriceByCartIdAndCustomerIdAndStatus(cartId, productNum,
id, CartConstant.CART_PRODUCT_STATUS_VALID,totalPrice);
if (rows >= 1) {
return true;
}
return false;
}
/**
*功能描述: 根据客户选中购物车多个物品项进行查询
* @Author jx
* @Date 15:25 2019/03/22
* @Param [orderCartIds, id]
* @return java.util.List<com.xmlvhy.shop.pojo.Cart>
*/
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
@Override
public List<Cart> findCartByCartIdsAndCustomerId(Integer[] orderCartIds, Integer id) throws OrderCartNotFoundException {
List<Cart> cartList = cartDao.selectCartByCartIdsAndCustomerId(orderCartIds, id, CartConstant.CART_PRODUCT_STATUS_VALID);
if (cartList.size() == 0) {
throw new OrderCartNotFoundException("购物车信息不存在");
}
return cartList;
}
@Override
public List<Cart> findRedirectCartByCartIdsAndCustomerId(Integer[] orderCartIds, Integer id) {
List<Cart> cartList = cartDao.selectRedirectCartByCartIdsAndCustomerId(orderCartIds, id, CartConstant.CART_PRODUCT_REDIRECT_TO_CART);
if (cartList.size() == 0) {
throw new OrderCartNotFoundException("购物车信息不存在");
}
return cartList;
}
/**
*功能描述: 直接购买,产生一个购物车,返回购物车id
* @Author jx
* @Date 10:42 2019/04/03
* @Param [cart]
* @return int
*/
@Override
public int redirectToCart(CartVo cartVo) {
Cart cartResult = cartDao.selectRedirectCartByCustomerIdAndProductId(cartVo.getCustomerId(), cartVo.getProductId());
//先查询一下购物车中是否有此商品,没有则插入保存,有的话就更新购物车的商品数量就可以了
if (cartResult == null) {
Cart cart = new Cart();
Product product = productDao.selectProductById(cartVo.getProductId());
//计算总价
Double totalPrice = product.getPrice() * cartVo.getProductNum();
BeanUtils.copyProperties(cartVo,cart);
cart.setTotalPrice(totalPrice);
cart.setProduct(product);
//直接购买放入购物车
cart.setStatus(CartConstant.CART_PRODUCT_REDIRECT_TO_CART);
cart.setCreateTime(new Date());
int rows = cartDao.insertCart(cart);
if (rows >= 1) {
return cart.getId();
}else{
return 0;
}
}
//直接购买,这里没有叠加,更新购物车的商品数量
int productSums = cartVo.getProductNum();
Product pd = productDao.selectProductById(cartVo.getProductId());
//更新商品总价格
Double priceSum = pd.getPrice() * productSums;
int rows = cartDao.updateCartNumAndTotalPriceById(cartResult.getId(), productSums,priceSum);
if (rows >= 1) {
return cartResult.getId();
}
return 0;
}
}
6.1、CarControlelr
/**
* Author: jx
* Date: 2019-03-13 0:24
* Description:<描述>
*/
@Controller
@RequestMapping("/front/cart")
@Slf4j
public class CarController {
@Autowired
private ProductService productService;
@Autowired
private CartService cartService;
/**
* 功能描述: 清空购物车后展示此页面
*
* @return java.lang.String
* @Author jx
* @Date 19:50 2019/03/20
* @Param []
*/
@RequestMapping("showEmptyCart")
public String showEmptyCart() {
return "emptyCart";
}
/**
* 功能描述: 购物车展示
*
* @return java.lang.String
* @Author jx
* @Date 21:14 2019/03/19
* @Param [session, model]
*/
@RequestMapping("myCarts")
public String myCars(HttpSession session, Model model) {
Customer customer = (Customer) session.getAttribute("customer");
if (customer != null) {
List<Cart> cartList = cartService.findCustomerAllCarts(customer.getId());
model.addAttribute("cartList", cartList);
}
return "car";
}
/**
* 功能描述: 添加商品到购物车
*
* @return com.xmlvhy.shop.common.utils.ResponseResult
* @Author jx
* @Date 16:02 2019/03/19
* @Param [id, session]
*/
@RequestMapping("addToCart")
@ResponseBody
public ResponseResult addToCart(Integer id, Integer textBox, HttpSession session) {
Customer customer = (Customer) session.getAttribute("customer");
if (ObjectUtils.isEmpty(customer)) {
//用户没有登录,则提示让他登录
return ResponseResult.deny("还请客官先登录哦~");
} else {
CartVo cartVo = new CartVo();
cartVo.setCustomerId(customer.getId());
cartVo.setProductId(id);
cartVo.setProductNum(textBox);
if (cartService.saveToCart(cartVo)) {
//此session用于标志购物车非空
//session.setAttribute("emptyCart",0);
return ResponseResult.success("商品成功加入购物车");
} else {
return ResponseResult.fail("商品加入购物车失败");
}
}
}
/**
* 功能描述: 清空购物车操作
*
* @return com.xmlvhy.shop.common.utils.ResponseResult
* @Author jx
* @Date 19:24 2019/03/20
* @Param [session]
*/
@RequestMapping("clearAllProductFromCart")
@ResponseBody
public ResponseResult clearAllProductFromCart(HttpSession session) {
Customer customer = (Customer) session.getAttribute("customer");
if (!ObjectUtils.isEmpty(customer)) {
if (cartService.modifyCartStatus(customer.getId())) {
//此session用于标志购物车为空
//session.setAttribute("emptyCart",null);
return ResponseResult.success("购物车已清空");
}
} else {
return ResponseResult.fail("请您先登录");
}
return ResponseResult.fail("商品移除失败");
}
/**
* 功能描述: 从购物车中移除某一商品
*
* @return com.xmlvhy.shop.common.utils.ResponseResult
* @Author jx
* @Date 10:49 2019/03/21
* @Param [cartId, session]
*/
@RequestMapping("removeOneProduct")
@ResponseBody
public ResponseResult removeOneProduct(Integer cartId, HttpSession session) {
Customer customer = (Customer) session.getAttribute("customer");
if (ObjectUtils.isEmpty(customer)) {
return ResponseResult.fail("请您先登录");
}
if (cartService.modifyCartStatusByCartIdAndCustomerId(cartId, customer.getId())) {
return ResponseResult.success("该商品移除成功");
}
return ResponseResult.fail();
}
/**
* 功能描述: 从购物车中移除选中的商品
*
* @return com.xmlvhy.shop.common.utils.ResponseResult
* @Author jx
* @Date 11:49 2019/03/21
* @Param [cartIds, session]
*/
@RequestMapping("removeMoreProductFromCart")
@ResponseBody
public ResponseResult removeMoreProductFromCart(Integer[] cartIds, HttpSession session) {
Customer customer = (Customer) session.getAttribute("customer");
if (ObjectUtils.isEmpty(customer)) {
return ResponseResult.fail("请您先登录");
}
if (cartService.modifyCartStatusByCartIdAndCustomerIds(cartIds,customer.getId())) {
return ResponseResult.success("商品移除成功");
}
return ResponseResult.fail("商品移除失败");
}
/**
*功能描述: 购物车页面修改商品的数量
* @Author jx
* @Date 17:15 2019/03/21
* @Param [cartId, productNum, session]
* @return com.xmlvhy.shop.common.utils.ResponseResult
*/
@RequestMapping("inputModifyProductNum")
@ResponseBody
public ResponseResult inputModifyProductNum(Integer cartId, Integer productNum, HttpSession session){
Customer customer = (Customer) session.getAttribute("customer");
if (ObjectUtils.isEmpty(customer)) {
return ResponseResult.fail("客官,还请先登录");
}
if (cartService.modifyNumAndPriceByCartIdAndCustomerIdAndStatus(cartId,productNum,customer.getId())) {
return ResponseResult.success("商品数量已修改");
}
return ResponseResult.fail("商品数量修改失败");
}
/**
*功能描述: 临时将前端发送过来的数据存到 session中去
* @Author jx
* @Date 11:48 2019/03/22
* @Param [count, price, orderCartIds, session]
* @return com.xmlvhy.shop.common.utils.ResponseResult
*/
@RequestMapping("addTempOrderItem")
@ResponseBody
public ResponseResult addTempOrderItem(Integer count, String price, Integer[]orderCartIds, HttpSession session){
Customer customer = (Customer) session.getAttribute("customer");
if (ObjectUtils.isEmpty(customer)) {
return ResponseResult.fail("客官还请先登录");
}
session.setAttribute("count",count);
String[] strings = price.split("¥");
double newPrice = Double.parseDouble(strings[1]);
session.setAttribute("price",newPrice);
session.setAttribute("orderCartIds",orderCartIds);
return ResponseResult.success(session);
}
}
未完成。