|
@@ -178,8 +178,8 @@ public class GoodsMgrController extends BaseApiController {
|
|
|
@PostMapping("/update")
|
|
|
public AjaxResult channelUpdate(@Validated @RequestBody GoodsParam goodsParam) {
|
|
|
|
|
|
- if (goodsParam.getGoodsId() != null && goodsParam.getGoodsId() != 0) {
|
|
|
- return AjaxResult.error("该商品已存在");
|
|
|
+ if (goodsParam.getGoodsId() == null || goodsParam.getGoodsId() == 0) {
|
|
|
+ return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
}
|
|
|
Goods oldGoods = goodsService.getById(goodsParam.getGoodsId());
|
|
|
if(null == oldGoods || null == oldGoods.getGoodsId()) {
|
|
@@ -245,5 +245,42 @@ public class GoodsMgrController extends BaseApiController {
|
|
|
}
|
|
|
return AjaxResult.success("操作成功");
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除商品(假删)
|
|
|
+ *
|
|
|
+ * @param
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping(value = "/delete")
|
|
|
+ public AjaxResult deleteGoods(@RequestBody JSONObject jsonObject) {
|
|
|
+ String goodsId = jsonObject.getString("goodsId");
|
|
|
+ if (StringUtils.isBlank(goodsId)){
|
|
|
+ return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
+ }
|
|
|
+ Goods goods = goodsService.getById(goodsId);
|
|
|
+ if(null == goods || StringUtils.isBlank(goods.getGoodsId())) {
|
|
|
+ return error(ErrorCodeEnum.ERROR_CODE_1001);
|
|
|
+ }
|
|
|
+ // 商品未下架, 不允许删除
|
|
|
+ if(goods.getStatus().equals("")) {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ GoodsVO goodsVo = new GoodsVO();
|
|
|
+ BeanUtils.copyProperties(goods, goodsVo);
|
|
|
+ // 查询SKU列表
|
|
|
+ List<GoodsSku> skuList = new ArrayList<>();
|
|
|
+ LambdaQueryWrapper<GoodsSku> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(GoodsSku::getGoodsId, goods.getGoodsId());
|
|
|
+ queryWrapper.orderByDesc(GoodsSku::getCreatedTime);
|
|
|
+ skuList = goodsSkuService.list(queryWrapper);
|
|
|
+ if(null != skuList && skuList.size() > 0) {
|
|
|
+ goodsVo.setSkuList(skuList);
|
|
|
+ }
|
|
|
+ return AjaxResult.success(goodsVo);
|
|
|
+ }
|
|
|
|
|
|
}
|