记得上下班打卡 | git大法好,push需谨慎

Commit 806f4d06 authored by 张国柄's avatar 张国柄

~API:完善逻辑校验;

parent 2e749112
...@@ -176,7 +176,9 @@ public class GoblinStoreMgtCategoryController { ...@@ -176,7 +176,9 @@ public class GoblinStoreMgtCategoryController {
updateStoreGoodsCategoryVo.setSort(null == sort ? 1 : sort); updateStoreGoodsCategoryVo.setSort(null == sort ? 1 : sort);
updateStoreGoodsCategoryVo.setUpdatedBy(currentUid); updateStoreGoodsCategoryVo.setUpdatedBy(currentUid);
updateStoreGoodsCategoryVo.setUpdatedAt(LocalDateTime.now()); updateStoreGoodsCategoryVo.setUpdatedAt(LocalDateTime.now());
return ResponseDto.success(goblinStoreMgtCategoryService.edit(updateStoreGoodsCategoryVo, storeGoodsCategoryVosCache));
boolean result = goblinStoreMgtCategoryService.edit(updateStoreGoodsCategoryVo, storeGoodsCategoryVosCache);
return result ? ResponseDto.success(result) : ResponseDto.failure();
} }
@ApiOperationSupport(order = 4) @ApiOperationSupport(order = 4)
...@@ -192,6 +194,7 @@ public class GoblinStoreMgtCategoryController { ...@@ -192,6 +194,7 @@ public class GoblinStoreMgtCategoryController {
if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) { if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002")); return ResponseDto.failure(ErrorMapping.get("149002"));
} }
return ResponseDto.success(goblinStoreMgtCategoryService.del(currentUid, storeId, cateid)); boolean resultFlg = goblinStoreMgtCategoryService.del(currentUid, storeId, cateid);
return resultFlg ? ResponseDto.success() : ResponseDto.failure();
} }
} }
...@@ -123,8 +123,8 @@ public class GoblinStoreMgtCouponController { ...@@ -123,8 +123,8 @@ public class GoblinStoreMgtCouponController {
@ApiOperation(value = "优惠券管理") @ApiOperation(value = "优惠券管理")
@PostMapping("action") @PostMapping("action")
public ResponseDto<Object> action(@Valid @RequestBody GoblinStoreMgtCouponActionParam mgtCouponActionParam) { public ResponseDto<Object> action(@Valid @RequestBody GoblinStoreMgtCouponActionParam mgtCouponActionParam) {
String currentUid = CurrentUtil.getCurrentUid(); String currentUid = CurrentUtil.getCurrentUid(), storeId = mgtCouponActionParam.getStoreId();
if (!goblinRedisUtils.hasStoreId(currentUid, mgtCouponActionParam.getStoreId())) { if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002")); return ResponseDto.failure(ErrorMapping.get("149002"));
} }
List<String> storeCouponIdList = mgtCouponActionParam.getStoreCouponIdList(); List<String> storeCouponIdList = mgtCouponActionParam.getStoreCouponIdList();
...@@ -142,6 +142,10 @@ public class GoblinStoreMgtCouponController { ...@@ -142,6 +142,10 @@ public class GoblinStoreMgtCouponController {
if (null == storeCouponVo) { if (null == storeCouponVo) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数有误:优惠券不存在"); return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数有误:优惠券不存在");
} }
if (!storeCouponVo.getStoreId().equals(storeId)) {
log.warn("商铺活动:优惠券管理:启用警告:非本店铺活动,无权操作[UID={},storeCouponId={}]", currentUid, storeCouponId);
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "非本店铺活动,无权操作");
}
if (!storeCouponVo.getState().equals("3")) {// 只针对停用的优惠券 if (!storeCouponVo.getState().equals("3")) {// 只针对停用的优惠券
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "只限已停用状态执行该操作"); return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "只限已停用状态执行该操作");
} }
...@@ -154,6 +158,10 @@ public class GoblinStoreMgtCouponController { ...@@ -154,6 +158,10 @@ public class GoblinStoreMgtCouponController {
if (null == storeCouponVo) { if (null == storeCouponVo) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数有误:优惠券不存在"); return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数有误:优惠券不存在");
} }
if (!storeCouponVo.getStoreId().equals(storeId)) {
log.warn("商铺活动:优惠券管理:停用警告:非本店铺活动,无权操作[UID={},storeCouponId={}]", currentUid, storeCouponId);
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "非本店铺活动,无权操作");
}
// if (storeCouponVo.getState().equals("1")) {// 该优惠券活动中 // if (storeCouponVo.getState().equals("1")) {// 该优惠券活动中
// return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "该优惠券活动中不可停用"); // return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "该优惠券活动中不可停用");
// } // }
...@@ -169,6 +177,10 @@ public class GoblinStoreMgtCouponController { ...@@ -169,6 +177,10 @@ public class GoblinStoreMgtCouponController {
if (null == storeCouponVo) { if (null == storeCouponVo) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数有误:优惠券不存在"); return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数有误:优惠券不存在");
} }
if (!storeCouponVo.getStoreId().equals(storeId)) {
log.warn("商铺活动:优惠券管理:删除警告:非本店铺活动,无权操作[UID={},storeCouponId={}]", currentUid, storeCouponId);
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "非本店铺活动,无权操作");
}
if (storeCouponVo.getState().equals("1")) {// 活动中不可删除 if (storeCouponVo.getState().equals("1")) {// 活动中不可删除
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "活动中不允许删除,请停用或活动结束后操作"); return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "活动中不允许删除,请停用或活动结束后操作");
} }
...@@ -273,7 +285,8 @@ public class GoblinStoreMgtCouponController { ...@@ -273,7 +285,8 @@ public class GoblinStoreMgtCouponController {
String storeCouponId = mgtCouponEditParam.getStoreCouponId(); String storeCouponId = mgtCouponEditParam.getStoreCouponId();
GoblinStoreCouponVo storeCouponVo; GoblinStoreCouponVo storeCouponVo;
if (StringUtils.isBlank(storeCouponId) if (StringUtils.isBlank(storeCouponId)
|| null == (storeCouponVo = goblinRedisUtils.getStoreCouponVo(storeCouponId)) || !storeId.equals(storeCouponVo.getStoreId())) { || null == (storeCouponVo = goblinRedisUtils.getStoreCouponVo(storeCouponId))
|| !storeId.equals(storeCouponVo.getStoreId())) {
return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数无效:优惠券ID"); return ResponseDto.failure(ErrorCode.HTTP_PARAM_ERROR.getCode(), "参数无效:优惠券ID");
} }
if (!storeCouponVo.getType().equals(mgtCouponEditParam.getType())) { if (!storeCouponVo.getType().equals(mgtCouponEditParam.getType())) {
......
...@@ -8,6 +8,7 @@ import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtCategoryServic ...@@ -8,6 +8,7 @@ import com.liquidnet.service.goblin.service.manage.IGoblinStoreMgtCategoryServic
import com.liquidnet.service.goblin.util.GoblinMongoUtils; import com.liquidnet.service.goblin.util.GoblinMongoUtils;
import com.liquidnet.service.goblin.util.GoblinRedisUtils; import com.liquidnet.service.goblin.util.GoblinRedisUtils;
import com.liquidnet.service.goblin.util.QueueUtils; import com.liquidnet.service.goblin.util.QueueUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -15,8 +16,8 @@ import org.springframework.util.CollectionUtils; ...@@ -15,8 +16,8 @@ import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Optional;
@Slf4j
@Service @Service
public class GoblinStoreMgtCategoryServiceImpl implements IGoblinStoreMgtCategoryService { public class GoblinStoreMgtCategoryServiceImpl implements IGoblinStoreMgtCategoryService {
@Autowired @Autowired
...@@ -89,8 +90,11 @@ public class GoblinStoreMgtCategoryServiceImpl implements IGoblinStoreMgtCategor ...@@ -89,8 +90,11 @@ public class GoblinStoreMgtCategoryServiceImpl implements IGoblinStoreMgtCategor
SqlMapping.get("goblin_store_goods_category.remove", SqlMapping.get("goblin_store_goods_category.remove",
uid, now, uid, now, storeId, cateId) uid, now, uid, now, storeId, cateId)
); );
return true;
} }
} else {
log.warn("###店铺商品分类管理:删除:分类不存在[uid={},storeId={},cateId={}]", uid, storeId, cateId);
} }
return true; return false;
} }
} }
...@@ -225,7 +225,7 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi ...@@ -225,7 +225,7 @@ public class GoblinStoreMgtGoodsServiceImpl implements IGoblinstoreMgtGoodsServi
public GoblinStoreMgtGoodsInfoVo goodsInfo(String storeId, String spuId) { public GoblinStoreMgtGoodsInfoVo goodsInfo(String storeId, String spuId) {
GoblinStoreMgtGoodsInfoVo vo = GoblinStoreMgtGoodsInfoVo.getNew(); GoblinStoreMgtGoodsInfoVo vo = GoblinStoreMgtGoodsInfoVo.getNew();
GoblinGoodsInfoVo goodsInfoVo = goblinRedisUtils.getGoodsInfoVo(spuId); GoblinGoodsInfoVo goodsInfoVo = goblinRedisUtils.getGoodsInfoVo(spuId);
if (null != goodsInfoVo && goodsInfoVo.getDelFlg().equals("0")) { if (null != goodsInfoVo && goodsInfoVo.getStoreId().equals(storeId) && goodsInfoVo.getDelFlg().equals("0")) {
vo.setGoodsInfoVo(goodsInfoVo); vo.setGoodsInfoVo(goodsInfoVo);
List<String> skuIdList = goodsInfoVo.getSkuIdList(); List<String> skuIdList = goodsInfoVo.getSkuIdList();
if (!CollectionUtils.isEmpty(skuIdList)) { if (!CollectionUtils.isEmpty(skuIdList)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment