Commit 4259abb4 by ping.wu

购物车加入数量限制

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