Authored by 郭成尧

order-ensure-ok

@@ -374,9 +374,10 @@ class CartData @@ -374,9 +374,10 @@ class CartData
374 * @param string $skuList 购买限购商品时需要传递的参数 374 * @param string $skuList 购买限购商品时需要传递的参数
375 * @param string $qhyUnion 友盟有关信息 375 * @param string $qhyUnion 友盟有关信息
376 * @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息 376 * @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息
  377 + * @param $times
377 * @return array 接口返回的数据 378 * @return array 接口返回的数据
378 */ 379 */
379 - public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnion, $userAgent) 380 + public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnion, $userAgent, $times)
380 { 381 {
381 $param = Yohobuy::param(); 382 $param = Yohobuy::param();
382 $param['debug'] = 'Y'; 383 $param['debug'] = 'Y';
@@ -391,6 +392,13 @@ class CartData @@ -391,6 +392,13 @@ class CartData
391 $param['delivery_time'] = $deliveryTime; 392 $param['delivery_time'] = $deliveryTime;
392 $param['delivery_way'] = $deliveryWay; 393 $param['delivery_way'] = $deliveryWay;
393 394
  395 + /* tar add 161130 结算优化 */
  396 + if ($times === 2) {
  397 + $param['is_continue_buy'] = 'Y';
  398 + } else {
  399 + $param['is_continue_buy'] = 'N';
  400 + }
  401 +
394 if (!empty($invoices['invoices_type_id'])) { 402 if (!empty($invoices['invoices_type_id'])) {
395 //发票内容id--图书:1 403 //发票内容id--图书:1
396 $param['invoice_content'] = $invoices['invoices_type_id']; 404 $param['invoice_content'] = $invoices['invoices_type_id'];
@@ -430,6 +438,23 @@ class CartData @@ -430,6 +438,23 @@ class CartData
430 $param['uid'] = $uid; 438 $param['uid'] = $uid;
431 $param['client_secret'] = Sign::getSign($param); 439 $param['client_secret'] = Sign::getSign($param);
432 440
  441 + /* TODO TAR DELETE!!! */
  442 +// return array(
  443 +// 'code' => 200,
  444 +// 'data' => array(
  445 +// 'activityAmount' => 0,
  446 +// 'hintInfo' => array(
  447 +// 'lastLine' => '继续结算剩余商品',
  448 +// 'prefix' => '',
  449 +// 'suffix' => '已被抢光',
  450 +// 'productName' => 'Life.After Life 字母印花织带休闲裤【吴亦凡亲身试着】'
  451 +// ),
  452 +// 'isOpenTicket' => 'N',
  453 +// 'is_hint' => 'Y',
  454 +// 'offline_submit_goods' => array(),
  455 +// 'shippingCost' => 0
  456 +// )
  457 +// );
433 return Yohobuy::get(API_URL, $param, false, false, 5, $userAgent); 458 return Yohobuy::get(API_URL, $param, false, false, 5, $userAgent);
434 } 459 }
435 460
@@ -331,7 +331,7 @@ function submitOrder(times) { @@ -331,7 +331,7 @@ function submitOrder(times) {
331 window.setCookie('order-info', ''); 331 window.setCookie('order-info', '');
332 window.location.href = url; 332 window.location.href = url;
333 } else if (res.code === 409) { 333 } else if (res.code === 409) {
334 - richTip.show(res.msg, res.btns); 334 + richTip.show(res.message, res.buttons);
335 } else if (res.message) { 335 } else if (res.message) {
336 tip.show(res.message); 336 tip.show(res.message);
337 } 337 }
@@ -798,9 +798,10 @@ class CartModel @@ -798,9 +798,10 @@ class CartModel
798 * @param string $skuList 购买限购商品时需要传递的参数 798 * @param string $skuList 购买限购商品时需要传递的参数
799 * @param string $qhyUnio 友盟有关信息 799 * @param string $qhyUnio 友盟有关信息
800 * @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息 800 * @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息
  801 + * @param int $times
801 * @return array 接口返回的数据 802 * @return array 接口返回的数据
802 */ 803 */
803 - public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnio = '', $userAgent = null) 804 + public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnio = '', $userAgent = null, $times = 1)
804 { 805 {
805 $result = array('code' => 400, 'message' => '出错啦'); 806 $result = array('code' => 400, 'message' => '出错啦');
806 807
@@ -816,11 +817,33 @@ class CartModel @@ -816,11 +817,33 @@ class CartModel
816 UdpLog::info('【结算信息】配送方式参数校验','deliveryWay为空'); 817 UdpLog::info('【结算信息】配送方式参数校验','deliveryWay为空');
817 $result['code'] = 403; 818 $result['code'] = 403;
818 $result['message'] = '请选择配送方式'; 819 $result['message'] = '请选择配送方式';
819 - }  
820 - else {  
821 - $orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnio, $userAgent); 820 + } else {
  821 + $orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $qhyUnio, $userAgent, $times);
822 UdpLog::info('【结算信息】接口返回','orderSubRes'.json_encode($orderSubRes)); 822 UdpLog::info('【结算信息】接口返回','orderSubRes'.json_encode($orderSubRes));
823 - if ($orderSubRes && isset($orderSubRes['code'])) { 823 +
  824 + if (isset($orderSubRes['data'])
  825 + && isset($orderSubRes['data']['is_hint'])
  826 + && $orderSubRes['data']['is_hint'] === 'Y') {
  827 +
  828 + $result['code'] = 409;
  829 +
  830 + if (isset($orderSubRes['data']['hintInfo'])) {
  831 + $result['message'] = array(
  832 + $orderSubRes['data']['hintInfo']['productName'] . $orderSubRes['data']['hintInfo']['suffix'],
  833 + $orderSubRes['data']['hintInfo']['lastLine']
  834 + );
  835 + }
  836 +
  837 + $result['buttons'] = array(
  838 + array(
  839 + 'href' => Helpers::url('/cart/index'),
  840 + 'text' => '重新选择商品',
  841 + ),
  842 + array(
  843 + 'text' => '继续结算',
  844 + 'class' => 'order-tip-btnred'
  845 + ));
  846 + } else if ($orderSubRes && isset($orderSubRes['code'])) {
824 $result = $orderSubRes; 847 $result = $orderSubRes;
825 } 848 }
826 } 849 }
@@ -624,22 +624,6 @@ class IndexController extends AbstractAction @@ -624,22 +624,6 @@ class IndexController extends AbstractAction
624 */ 624 */
625 public function orderSubAction() 625 public function orderSubAction()
626 { 626 {
627 - /* TODO TAR DELETE THIS !!! */  
628 -// $this->echoJson(array(  
629 -// 'code' => 409,  
630 -// 'msg' => array('XXX 商品已被抢光,', '继续结算剩余商品。'),  
631 -// 'btns' => array(  
632 -// // array(  
633 -// // 'href' => '/',  
634 -// // 'text' => '重新选择商品',  
635 -// // 'color' => '',  
636 -// // ),  
637 -// array(  
638 -// 'href' => '',  
639 -// 'text' => '知道了',  
640 -// 'class' => 'order-tip-btnred'  
641 -// )),  
642 -// ));exit;  
643 if ($this->isAjax()) { 627 if ($this->isAjax()) {
644 $uid = $this->getUid(true); 628 $uid = $this->getUid(true);
645 $addressId = $this->post('addressId', null); 629 $addressId = $this->post('addressId', null);
@@ -654,6 +638,8 @@ class IndexController extends AbstractAction @@ -654,6 +638,8 @@ class IndexController extends AbstractAction
654 $yohoCoin = $this->post('yohoCoin', 1); 638 $yohoCoin = $this->post('yohoCoin', 1);
655 $skuList = $this->post('skuList', ''); 639 $skuList = $this->post('skuList', '');
656 $cookieData = $this->getCookie('order-info', null); //获取电子发票信息 640 $cookieData = $this->getCookie('order-info', null); //获取电子发票信息
  641 + $times = $this->post('times', 1);
  642 +
657 //电子发票信息数组 643 //电子发票信息数组
658 $invoices = array(); 644 $invoices = array();
659 if (!empty($cookieData)) { 645 if (!empty($cookieData)) {
@@ -692,7 +678,7 @@ class IndexController extends AbstractAction @@ -692,7 +678,7 @@ class IndexController extends AbstractAction
692 /* 模拟APP的User-Agent */ 678 /* 模拟APP的User-Agent */
693 $userAgent = isset($unionInfo['client_id']) ? 'YOHO!Buy/3.8.2.259(Model/PC;Channel/' . $unionInfo['client_id'] . ';uid/' . $uid . ')' : null; 679 $userAgent = isset($unionInfo['client_id']) ? 'YOHO!Buy/3.8.2.259(Model/PC;Channel/' . $unionInfo['client_id'] . ';uid/' . $uid . ')' : null;
694 } 680 }
695 - $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $unionKey, $userAgent); 681 + $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoices, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $unionKey, $userAgent, $times);
696 682
697 $result['data']['unionCookie'] = $unionInfo; 683 $result['data']['unionCookie'] = $unionInfo;
698 684
@@ -703,8 +689,8 @@ class IndexController extends AbstractAction @@ -703,8 +689,8 @@ class IndexController extends AbstractAction
703 . ',paymentId:' . $paymentId . ',paymentType:' . $paymentType . ',remark:' . $remark . ',couponCode:' . $couponCode . "\n"; 689 . ',paymentId:' . $paymentId . ',paymentType:' . $paymentType . ',remark:' . $remark . ',couponCode:' . $couponCode . "\n";
704 error_log($message, 3, '/Data/logs/php/h5_error/order.' . date('Ym') . '.log'); 690 error_log($message, 3, '/Data/logs/php/h5_error/order.' . date('Ym') . '.log');
705 UdpLog::info('【下单】下单异常数据', 'message:' . $message, '返回:' . json_encode($result)); 691 UdpLog::info('【下单】下单异常数据', 'message:' . $message, '返回:' . json_encode($result));
706 - } // 返回数据  
707 - else { 692 + } else {
  693 + // 返回数据
708 // 提交成功清除Cookie 694 // 提交成功清除Cookie
709 $this->setCookie('order-info', null); 695 $this->setCookie('order-info', null);
710 696