后端 + 前端:提交购物车订单
This commit is contained in:
@@ -38,8 +38,9 @@ public interface CartMapper {
|
||||
int updateQuantity(@Param("id") Integer id,
|
||||
@Param("quantityIncr") Integer quantityIncr);
|
||||
|
||||
int updateListSelected(@Param("userId") Integer userId,
|
||||
@Param("skuIds") Collection<Integer> skuIds,
|
||||
@Param("selected") Boolean selected);
|
||||
int updateListByUserIdAndSkuId(@Param("userId") Integer userId,
|
||||
@Param("skuIds") Collection<Integer> skuIds,
|
||||
@Param("selected") Boolean selected,
|
||||
@Param("status") Integer status);
|
||||
|
||||
}
|
||||
|
||||
@@ -116,14 +116,17 @@ public class CartServiceImpl implements CartService {
|
||||
@Override
|
||||
public CommonResult<Boolean> updateSelected(Integer userId, Collection<Integer> skuIds, Boolean selected) {
|
||||
// 更新 CartItemDO 们
|
||||
cartMapper.updateListSelected(userId, skuIds, selected);
|
||||
cartMapper.updateListByUserIdAndSkuId(userId, skuIds, selected, null);
|
||||
// 返回成功
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommonResult<Boolean> delete(Integer userId, List<Integer> skuIds) {
|
||||
return null;
|
||||
public CommonResult<Boolean> deleteList(Integer userId, List<Integer> skuIds) {
|
||||
// 更新 CartItemDO 们
|
||||
cartMapper.updateListByUserIdAndSkuId(userId, skuIds, null, CartItemStatusEnum.DELETE_BY_MANUAL.getValue());
|
||||
// 返回成功
|
||||
return CommonResult.success(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -108,9 +108,16 @@
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updateListSelected">
|
||||
<update id="updateListByUserIdAndSkuId">
|
||||
UPDATE cart_item
|
||||
SET selected = #{selected}
|
||||
<set>
|
||||
<if test="selected != null">
|
||||
selected = #{selected},
|
||||
</if>
|
||||
<if test="status != null">
|
||||
status = #{status},
|
||||
</if>
|
||||
</set>
|
||||
WHERE user_id = #{userId}
|
||||
AND sku_id IN
|
||||
<foreach item="skuId" collection="skuIds" separator="," open="(" close=")" index="">
|
||||
|
||||
Reference in New Issue
Block a user