Commit 4259abb4 by ping.wu

购物车加入数量限制

parent c814fa9f
...@@ -351,6 +351,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -351,6 +351,8 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
if (cartGoods == null) { if (cartGoods == null) {
throw new ServiceException(ResponseResult.SHOPPING_CART_UPDATE_ERROR); throw new ServiceException(ResponseResult.SHOPPING_CART_UPDATE_ERROR);
} }
//购物车添加数量限制
limitGoodsQty(qty,appId);
// 检查购物车商品库存数量 // 检查购物车商品库存数量
checkUpdateStock(updateShoppingCartGoodsQtyRequestVo, cartGoods); checkUpdateStock(updateShoppingCartGoodsQtyRequestVo, cartGoods);
...@@ -1646,27 +1648,23 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService { ...@@ -1646,27 +1648,23 @@ public class ShoppingCartNewServiceImpl implements ShoppingCartNewService {
*/ */
public void limitGoodsQty(Integer qty,String appid){ public void limitGoodsQty(Integer qty,String appid){
String redisKey = "ecology:kgd:wxappconfig:open_platform_partner_wxapp_config:appkey_"+appid; String redisKey = "ecology:kgd:wxappconfig:open_platform_partner_wxapp_config:appkey_"+appid;
BoundHashOperations<String, String, List<OpenPlatformPartnerWxappConfig>> operations = redisTemplate.boundHashOps(redisKey);
Object value = redisCache.hashGet(redisKey, "2"); Object value = redisCache.hashGet(redisKey, "2");
List<AssortmentOpenPlatformPartnerWxappConfig> configs = null; List<AssortmentOpenPlatformPartnerWxappConfig> configs = null;
if (value == null) { if (value == null) {
return ; return ;
} else { } else {
String json = JSONObject.toJSONString(value); JSONArray jsonArray = (JSONArray)value;
configs = JSONArray.parseArray(json, AssortmentOpenPlatformPartnerWxappConfig.class);
}
List<OpenPlatformPartnerWxappConfig> configs2 = operations.get("2");
if(CollectionUtils.isNotEmpty(configs)){
int cartLimitFlag = 0; int cartLimitFlag = 0;
int cartLimitCount = 0; int cartLimitCount = 0;
for (AssortmentOpenPlatformPartnerWxappConfig config : configs){ for (Object object : jsonArray){
if("cartLimitFlag".equals(config.getAppKey())){ JSONObject jsonObject = (JSONObject)object;
cartLimitFlag= Integer.parseInt(config.getAppValue()); HashMap hashMap = JSONObject.parseObject(jsonObject.toJSONString(),HashMap.class);
if("cartLimitFlag".equals(hashMap.get("appKey"))){
cartLimitFlag = Integer.parseInt((String)hashMap.get("appValue"));
} }
if("cartLimitCount".equals(config.getAppKey())){ if("cartLimitCount".equals(hashMap.get("appKey"))){
cartLimitCount= Integer.parseInt(config.getAppValue()); cartLimitCount = Integer.parseInt((String)hashMap.get("appValue"));
} }
} }
if(cartLimitFlag == 1 && cartLimitCount != 0 && qty > cartLimitCount){ if(cartLimitFlag == 1 && cartLimitCount != 0 && qty > cartLimitCount){
......
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