后管页面
This commit is contained in:
parent
fea3bd87e2
commit
314a08f02d
@ -14,6 +14,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@ -65,12 +66,13 @@ public class SystemHelpController {
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST)
|
||||
@PreAuthorize("hasAuthority('admin:helpProblem:delete')")
|
||||
public CommonResult<String> delete(@PathVariable Integer id) {
|
||||
if (helpService.removeById(id)) {
|
||||
public CommonResult<String> delete(@RequestBody Integer[] ids) {
|
||||
System.out.println("111");
|
||||
// if (helpService.removeByIds(Arrays.asList(ids))) {
|
||||
return CommonResult.success();
|
||||
}
|
||||
return CommonResult.failed();
|
||||
// }
|
||||
// return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
@ -242,6 +242,10 @@ public class Constants {
|
||||
public static final String PRODUCT_TYPE_COMPONENT_STR= "组件";
|
||||
public static final Integer PRODUCT_TYPE_GROUP = 0;
|
||||
|
||||
// 购物车类型标识,区分来自哪里的商品加购物车
|
||||
public static final String CART_DEFAULT = "default";
|
||||
public static final String CART_SETMEAL = "setmeal";
|
||||
|
||||
// 楼层渠道
|
||||
public static final Integer HOME_TYPE_1 = 1;
|
||||
public static final Integer HOME_TYPE_2 = 2;
|
||||
|
@ -0,0 +1,33 @@
|
||||
package com.zbkj.common.request;
|
||||
|
||||
import com.zbkj.common.annotation.StringContains;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value="BatchCartRequest对象", description="BatchCartRequest")
|
||||
public class BatchCartRequest {
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "购物车商品信息(cartType=default,必传)")
|
||||
private List<CartRequest> cartList;
|
||||
|
||||
@ApiModelProperty(value = "业务编号")
|
||||
private String business;
|
||||
|
||||
@ApiModelProperty(value = "业务类型(default 默认; setmeal 套餐)", required = true)
|
||||
@StringContains(limitValues = {"default","setmeal"}, message = "未知的类型")
|
||||
private String cartType;
|
||||
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package com.zbkj.common.request;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
|
@ -16,10 +16,19 @@ public class SystemHelpRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID=1L;
|
||||
|
||||
@ApiModelProperty(value = "id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(value = "分类id")
|
||||
private String cid;
|
||||
|
||||
@ApiModelProperty(value = "内容")
|
||||
private String content;
|
||||
|
||||
@ApiModelProperty(value = "标题")
|
||||
private String title;
|
||||
|
||||
@ApiModelProperty(value = "状态 0无效,1有效")
|
||||
private Integer status;
|
||||
|
||||
}
|
||||
|
@ -25,9 +25,6 @@ public class CartInfoResponse implements Serializable {
|
||||
@ApiModelProperty(value = "购物车表ID")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value = "商品包")
|
||||
private List<CartInfoResponse> packCartInfo;
|
||||
|
||||
@ApiModelProperty(value = "商品ID")
|
||||
private Integer productId;
|
||||
|
||||
|
@ -14,15 +14,6 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品详情
|
||||
* +----------------------------------------------------------------------
|
||||
* | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
||||
* +----------------------------------------------------------------------
|
||||
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
|
||||
* +----------------------------------------------------------------------
|
||||
* | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
||||
* +----------------------------------------------------------------------
|
||||
* | Author: CRMEB Team <admin@crmeb.com>
|
||||
* +----------------------------------------------------------------------
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
|
@ -1,12 +1,9 @@
|
||||
package com.zbkj.front.controller;
|
||||
|
||||
import com.zbkj.common.page.CommonPage;
|
||||
import com.zbkj.common.request.CartNumRequest;
|
||||
import com.zbkj.common.request.CartRequest;
|
||||
import com.zbkj.common.request.CartResetRequest;
|
||||
import com.zbkj.common.request.*;
|
||||
import com.zbkj.common.response.CartInfoResponse;
|
||||
import com.zbkj.common.response.CommonResult;
|
||||
import com.zbkj.common.request.PageParamRequest;
|
||||
import com.zbkj.service.service.StoreCartService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@ -51,6 +48,23 @@ public class CartController {
|
||||
return CommonResult.success(restPage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 一键加入
|
||||
* @param storeCartRequest 新增参数
|
||||
*/
|
||||
@ApiOperation(value = "一键加入购物车")
|
||||
@RequestMapping(value = "/batchSave", method = RequestMethod.POST)
|
||||
public CommonResult<HashMap<String, Object>> batchSave(@RequestBody @Validated BatchCartRequest storeCartRequest) {
|
||||
List<String> cartIds = storeCartService.batchSaveCart(storeCartRequest);
|
||||
if (!cartIds.isEmpty()) {
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
result.put("cartIds", cartIds);
|
||||
return CommonResult.success(result);
|
||||
} else {
|
||||
return CommonResult.failed();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增购物车表
|
||||
* @param storeCartRequest 新增参数
|
||||
@ -68,8 +82,6 @@ public class CartController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 删除购物车表
|
||||
* @param ids 购物车ids
|
||||
|
@ -1,29 +1,18 @@
|
||||
package com.zbkj.front.controller;
|
||||
|
||||
|
||||
import com.zbkj.common.page.CommonPage;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.common.model.system.SystemUserLevel;
|
||||
import com.zbkj.common.model.user.User;
|
||||
import com.zbkj.common.model.user.UserExperienceRecord;
|
||||
import com.zbkj.common.model.user.UserIntegralRecord;
|
||||
import com.zbkj.common.request.*;
|
||||
import com.zbkj.common.response.*;
|
||||
import com.zbkj.front.service.UserCenterService;
|
||||
import com.zbkj.service.service.SystemGroupDataService;
|
||||
import com.zbkj.service.service.UserService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户 -- 用户中心
|
||||
|
@ -1,10 +1,7 @@
|
||||
package com.zbkj.service.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zbkj.common.request.CartNumRequest;
|
||||
import com.zbkj.common.request.CartRequest;
|
||||
import com.zbkj.common.request.CartResetRequest;
|
||||
import com.zbkj.common.request.PageParamRequest;
|
||||
import com.zbkj.common.request.*;
|
||||
import com.zbkj.common.response.CartInfoResponse;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import com.zbkj.common.model.cat.StoreCart;
|
||||
@ -40,6 +37,13 @@ public interface StoreCartService extends IService<StoreCart> {
|
||||
*/
|
||||
String saveCate(CartRequest storeCartRequest);
|
||||
|
||||
/**
|
||||
* 批量新增购物车数据
|
||||
* @param storeCartRequest 新增购物车参数
|
||||
* @return 新增结果
|
||||
*/
|
||||
List<String> batchSaveCart(BatchCartRequest storeCartRequest);
|
||||
|
||||
/**
|
||||
* 删除购物车
|
||||
* @param ids 待删除id
|
||||
|
@ -10,10 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zbkj.common.page.CommonPage;
|
||||
import com.zbkj.common.request.CartNumRequest;
|
||||
import com.zbkj.common.request.CartRequest;
|
||||
import com.zbkj.common.request.CartResetRequest;
|
||||
import com.zbkj.common.request.PageParamRequest;
|
||||
import com.zbkj.common.request.*;
|
||||
import com.zbkj.common.constants.Constants;
|
||||
import com.zbkj.common.constants.RedisConstatns;
|
||||
import com.zbkj.common.exception.CrmebException;
|
||||
@ -27,18 +24,23 @@ import com.zbkj.common.model.product.StoreProduct;
|
||||
import com.zbkj.common.model.product.StoreProductAttrValue;
|
||||
import com.zbkj.common.model.system.SystemUserLevel;
|
||||
import com.zbkj.common.model.user.User;
|
||||
import com.zbkj.common.vo.HomeProductVo;
|
||||
import com.zbkj.common.vo.product.ProductAttrValueVo;
|
||||
import com.zbkj.service.dao.StoreCartDao;
|
||||
import com.zbkj.service.service.*;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -63,6 +65,9 @@ public class StoreCartServiceImpl extends ServiceImpl<StoreCartDao, StoreCart> i
|
||||
@Autowired
|
||||
private SystemUserLevelService systemUserLevelService;
|
||||
|
||||
@Autowired
|
||||
private EbHomeService homeService;
|
||||
|
||||
@Autowired
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@ -195,6 +200,58 @@ public class StoreCartServiceImpl extends ServiceImpl<StoreCartDao, StoreCart> i
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> batchSaveCart(BatchCartRequest storeCartRequest) {
|
||||
String cartType = storeCartRequest.getCartType();
|
||||
String business = storeCartRequest.getBusiness();
|
||||
List<CartRequest> cartList = storeCartRequest.getCartList();
|
||||
if (cartType.equals(Constants.CART_SETMEAL)) {
|
||||
SetMealFloorProRequest query = new SetMealFloorProRequest();
|
||||
query.setHomeId(business);
|
||||
PageParamRequest page = new PageParamRequest();
|
||||
page.setPage(1);
|
||||
page.setLimit(999);
|
||||
List<HomeProductVo> list = homeService.selectPageSetMealFloorPro(query, page);
|
||||
cartList = list.stream().map(i -> {
|
||||
CartRequest cart = new CartRequest();
|
||||
cart.setCartNum(1);
|
||||
cart.setProductId(i.getProductId());
|
||||
cart.setProductAttrUnique(((ProductAttrValueVo) i.getProductValue().get(i.getProductAttr().get(0).getAttrValues())).getId() + "");
|
||||
return cart;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
// 普通商品部分(只有普通商品才能添加购物车)
|
||||
// 是否已经有同类型商品在购物车,有则添加数量没有则新增
|
||||
List<String> cartIds = new ArrayList<>();
|
||||
User currentUser = userService.getInfo();
|
||||
for (CartRequest cartRequest : cartList) {
|
||||
if (null == cartRequest.getProductId()) throw new CrmebException("商品id不能为空");
|
||||
if (StringUtils.isEmpty(cartRequest.getProductAttrUnique())) throw new CrmebException("商品属性id不能为空");
|
||||
if (null == cartRequest.getCartNum()) throw new CrmebException("商品数量不能为空");
|
||||
if (cartRequest.getCartNum() < 1) throw new CrmebException("商品数量不能小于1");
|
||||
if (cartRequest.getCartNum() > 99) throw new CrmebException("商品数量不能大于99");
|
||||
StoreCart storeCartPram = new StoreCart();
|
||||
storeCartPram.setProductAttrUnique(cartRequest.getProductAttrUnique());
|
||||
storeCartPram.setUid(currentUser.getUid());
|
||||
List<StoreCart> existCarts = getByEntity(storeCartPram); // 这里仅仅能获取一条以信息
|
||||
if (existCarts.size() > 0) { // 购物车添加数量
|
||||
StoreCart forUpdateStoreCart = existCarts.get(0);
|
||||
forUpdateStoreCart.setCartNum(forUpdateStoreCart.getCartNum() + cartRequest.getCartNum());
|
||||
boolean updateResult = updateById(forUpdateStoreCart);
|
||||
if (!updateResult) throw new CrmebException("添加购物车失败");
|
||||
cartIds.add(forUpdateStoreCart.getId() + "");
|
||||
} else {// 新增购物车数据
|
||||
StoreCart storeCart = new StoreCart();
|
||||
BeanUtils.copyProperties(cartRequest, storeCart);
|
||||
storeCart.setUid(currentUser.getUid());
|
||||
storeCart.setType("product");
|
||||
if (dao.insert(storeCart) <= 0) throw new CrmebException("添加购物车失败");
|
||||
cartIds.add(storeCart.getId() + "");
|
||||
}
|
||||
}
|
||||
return cartIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除购物车信息
|
||||
* @param ids 待删除id
|
||||
|
Loading…
Reference in New Issue
Block a user