Authored by Rock Zhang

添加对修改购物车商品数据以及数目接口对传递商品sku以及sku的验证

Code Review By Rock Zhang
@@ -311,11 +311,17 @@ class CartModel @@ -311,11 +311,17 @@ class CartModel
311 { 311 {
312 $result = array('code' => 400, 'message' => '出错啦~'); 312 $result = array('code' => 400, 'message' => '出错啦~');
313 313
314 - $modify = CartData::modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey);  
315 - if ($modify && isset($modify['code'])) {  
316 - $result['code'] = $modify['code'];  
317 - $result['message'] = $modify['message'];  
318 - } 314 + do {
  315 + if (empty($sku)) {
  316 + braek;
  317 + }
  318 +
  319 + $modify = CartData::modifyProductNum($uid, $sku, $increaseNum, $decreaseNum, $shoppingKey);
  320 + if ($modify && isset($modify['code'])) {
  321 + $result['code'] = $modify['code'];
  322 + $result['message'] = $modify['message'];
  323 + }
  324 + }while(0);
319 325
320 return $result; 326 return $result;
321 } 327 }
@@ -332,14 +338,20 @@ class CartModel @@ -332,14 +338,20 @@ class CartModel
332 { 338 {
333 $result = array('code' => 400, 'message' => '出错啦~'); 339 $result = array('code' => 400, 'message' => '出错啦~');
334 340
335 - // 处理要更改的数据  
336 - $swapData = json_encode(array($param)); 341 + do {
  342 + if (empty($param['old_product_sku']) || empty($param['new_product_sku'])) {
  343 + break;
  344 + }
337 345
338 - $modify = CartData::modifyCartProduct($uid, $swapData, $shoppingKey);  
339 - if ($modify && isset($modify['code'])) {  
340 - $result['code'] = $modify['code'];  
341 - $result['message'] = $modify['message'];  
342 - } 346 + // 处理要更改的数据
  347 + $swapData = json_encode(array($param));
  348 +
  349 + $modify = CartData::modifyCartProduct($uid, $swapData, $shoppingKey);
  350 + if ($modify && isset($modify['code'])) {
  351 + $result['code'] = $modify['code'];
  352 + $result['message'] = $modify['message'];
  353 + }
  354 + }while(0);
343 355
344 return $result; 356 return $result;
345 } 357 }