Authored by Rock Zhang

修复配送方式与配送时间不能保存的bug

@@ -306,7 +306,7 @@ class CartModel @@ -306,7 +306,7 @@ class CartModel
306 // cookie保存的数据 306 // cookie保存的数据
307 if (!empty($cookieData)) { 307 if (!empty($cookieData)) {
308 $orderInfo = json_decode($cookieData, true); 308 $orderInfo = json_decode($cookieData, true);
309 - $orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentTypeId'], $orderInfo['couponCode'], $orderInfo['yohoCoin']); 309 +// $orderCompute = self::orderCompute($uid, $cartType, $orderInfo['deliveryId'], $orderInfo['paymentTypeId'], $orderInfo['couponCode'], $orderInfo['yohoCoin']);
310 } 310 }
311 311
312 // 根据地址id查询地址信息 312 // 根据地址id查询地址信息
@@ -326,32 +326,50 @@ class CartModel @@ -326,32 +326,50 @@ class CartModel
326 326
327 // 配送方式 327 // 配送方式
328 if (isset($payReturn['delivery_way'])) { 328 if (isset($payReturn['delivery_way'])) {
  329 + $idArr = array();
  330 + $defaultKey = 0;
329 $oneDeliv = array(); 331 $oneDeliv = array();
330 - foreach ($payReturn['delivery_way'] as $val) { 332 + foreach ($payReturn['delivery_way'] as $key => $val) {
331 $oneDeliv = array(); 333 $oneDeliv = array();
332 $oneDeliv['id'] = $val['delivery_way_id']; 334 $oneDeliv['id'] = $val['delivery_way_id'];
333 $oneDeliv['name'] = $val['delivery_way_name']; 335 $oneDeliv['name'] = $val['delivery_way_name'];
  336 + ($val['default'] === 'Y') && $defaultKey = $key;
334 337
335 - isset($orderInfo['deliveryId']) && $orderInfo['deliveryId'] === $oneDeliv['id'] && $oneDeliv['isSelected'] = true; 338 + $idArr[$key] = $oneDeliv['id'];
336 339
337 - !isset($oneDeliv['isSelected']) && $oneDeliv['isSelected'] = ($val['default'] === 'Y'); 340 + $result['dispatchMode'][$key] = $oneDeliv;
  341 + }
338 342
339 - $result['dispatchMode'][] = $oneDeliv; 343 + if (isset($orderInfo['deliveryId'])) {
  344 + $flag = array_search($orderInfo['deliveryId'], $idArr);
  345 + $flag !== false && $result['dispatchMode'][$flag]['isSelected'] = true;
  346 + } else {
  347 + $result['dispatchMode'][$defaultKey]['isSelected'] = true;
340 } 348 }
341 } 349 }
342 350
343 // 配送时间 351 // 配送时间
344 if (isset($payReturn['delivery_time'])) { 352 if (isset($payReturn['delivery_time'])) {
  353 + $idArr = array();
  354 + $defaultKey = 0;
345 $oneDelivTime = array(); 355 $oneDelivTime = array();
346 - foreach ($payReturn['delivery_time'] as $one) { 356 + foreach ($payReturn['delivery_time'] as $key => $one) {
347 $oneDelivTime = array(); 357 $oneDelivTime = array();
348 $oneDelivTime['id'] = $one['delivery_time_id']; 358 $oneDelivTime['id'] = $one['delivery_time_id'];
349 $oneDelivTime['name'] = $one['delivery_time_string']; 359 $oneDelivTime['name'] = $one['delivery_time_string'];
350 - $oneDelivTime['default'] = ($one['default'] === 'Y');  
351 - isset($orderInfo['deliveryTimeId']) && $orderInfo['deliveryTimeId'] === $oneDelivTime['id'] && $oneDeliv['isSelected'] = true; 360 + ($one['default'] === 'Y') && $defaultKey = $key;
  361 +
  362 + $idArr[$key] = $oneDelivTime['id'];
352 363
353 $result['dispatchTime'][] = $oneDelivTime; 364 $result['dispatchTime'][] = $oneDelivTime;
354 } 365 }
  366 +
  367 + if (isset($orderInfo['deliveryTimeId'])) {
  368 + $flag = array_search($orderInfo['deliveryTimeId'], $idArr);
  369 + $flag !== false && $result['dispatchTime'][$flag]['isSelected'] = true;
  370 + } else {
  371 + $result['dispatchTime'][$defaultKey]['isSelected'] = true;
  372 + }
355 } 373 }
356 374
357 // 订单商品 375 // 订单商品