修复h5友盟添加记录方式
Code Review By Rock Zhang
Showing
3 changed files
with
22 additions
and
7 deletions
@@ -360,9 +360,10 @@ class CartData | @@ -360,9 +360,10 @@ class CartData | ||
360 | * @param string $couponCode 优惠券码 | 360 | * @param string $couponCode 优惠券码 |
361 | * @param mixed $yohoCoin 使用的YOHO币数量或为空 | 361 | * @param mixed $yohoCoin 使用的YOHO币数量或为空 |
362 | * @param string $skuList 购买限购商品时需要传递的参数 | 362 | * @param string $skuList 购买限购商品时需要传递的参数 |
363 | + * @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息 | ||
363 | * @return array 接口返回的数据 | 364 | * @return array 接口返回的数据 |
364 | */ | 365 | */ |
365 | - public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList) | 366 | + public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $userAgent) |
366 | { | 367 | { |
367 | $param = Yohobuy::param(); | 368 | $param = Yohobuy::param(); |
368 | $param['debug'] = 'Y'; | 369 | $param['debug'] = 'Y'; |
@@ -398,7 +399,7 @@ class CartData | @@ -398,7 +399,7 @@ class CartData | ||
398 | $param['uid'] = $uid; | 399 | $param['uid'] = $uid; |
399 | $param['client_secret'] = Sign::getSign($param); | 400 | $param['client_secret'] = Sign::getSign($param); |
400 | 401 | ||
401 | - return Yohobuy::get(Yohobuy::API_URL, $param); | 402 | + return Yohobuy::get(Yohobuy::API_URL, $param, false, false, 5, $userAgent); |
402 | } | 403 | } |
403 | 404 | ||
404 | /** | 405 | /** |
@@ -628,9 +628,10 @@ class CartModel | @@ -628,9 +628,10 @@ class CartModel | ||
628 | * @param string $couponCode 优惠券码 | 628 | * @param string $couponCode 优惠券码 |
629 | * @param mixed $yohoCoin 使用的YOHO币数量或为空 | 629 | * @param mixed $yohoCoin 使用的YOHO币数量或为空 |
630 | * @param string $skuList 购买限购商品时需要传递的参数 | 630 | * @param string $skuList 购买限购商品时需要传递的参数 |
631 | + * @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息 | ||
631 | * @return array 接口返回的数据 | 632 | * @return array 接口返回的数据 |
632 | */ | 633 | */ |
633 | - public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList) | 634 | + public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $userAgent = null) |
634 | { | 635 | { |
635 | $result = array('code' => 400, 'message' => '出错啦'); | 636 | $result = array('code' => 400, 'message' => '出错啦'); |
636 | 637 | ||
@@ -644,7 +645,7 @@ class CartModel | @@ -644,7 +645,7 @@ class CartModel | ||
644 | $result['code'] = 403; | 645 | $result['code'] = 403; |
645 | $result['message'] = '请选择配送方式'; | 646 | $result['message'] = '请选择配送方式'; |
646 | } else { | 647 | } else { |
647 | - $orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList); | 648 | + $orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $userAgent); |
648 | if ($orderSubRes && isset($orderSubRes['code'])) { | 649 | if ($orderSubRes && isset($orderSubRes['code'])) { |
649 | $result = $orderSubRes; | 650 | $result = $orderSubRes; |
650 | } | 651 | } |
1 | <?php | 1 | <?php |
2 | 2 | ||
3 | use Action\AbstractAction; | 3 | use Action\AbstractAction; |
4 | +use Hood\Core\Security\AuthCode; | ||
4 | use Index\CartModel; | 5 | use Index\CartModel; |
5 | use Index\UserModel; | 6 | use Index\UserModel; |
6 | use Plugin\Helpers; | 7 | use Plugin\Helpers; |
@@ -445,7 +446,19 @@ class IndexController extends AbstractAction | @@ -445,7 +446,19 @@ class IndexController extends AbstractAction | ||
445 | $couponCode = $this->post('couponCode', null); | 446 | $couponCode = $this->post('couponCode', null); |
446 | $yohoCoin = $this->post('yohoCoin', 1); | 447 | $yohoCoin = $this->post('yohoCoin', 1); |
447 | $skuList = $this->post('skuList', ''); | 448 | $skuList = $this->post('skuList', ''); |
448 | - $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList); | 449 | + |
450 | + /* 判断是否是友盟过来的用户 */ | ||
451 | + $userAgent = null; | ||
452 | + if (!empty($_COOKIE['_QYH_UNION'])) { | ||
453 | + /* 解密客户端联盟信息 */ | ||
454 | + $unionKey = AuthCode::decode($_COOKIE['_QYH_UNION'], 'q_union_yohobuy'); | ||
455 | + /* 检查联盟参数是否有效 */ | ||
456 | + $unionInfo = empty($unionKey) ? array() : json_decode($unionKey, true); | ||
457 | + /* 模拟APP的User-Agent */ | ||
458 | + $userAgent = isset($unionInfo['client_id']) ? 'YOHO!Buy/3.8.2.259(Model/PC;Channel/' . $unionInfo['client_id'] . ';uid/' . $uid . ')' : null; | ||
459 | + } | ||
460 | + | ||
461 | + $result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $userAgent); | ||
449 | 462 | ||
450 | // 记录下单异常的数据 | 463 | // 记录下单异常的数据 |
451 | if (empty($result)) { | 464 | if (empty($result)) { |
@@ -462,13 +475,13 @@ class IndexController extends AbstractAction | @@ -462,13 +475,13 @@ class IndexController extends AbstractAction | ||
462 | $this->echoJson($result); | 475 | $this->echoJson($result); |
463 | } | 476 | } |
464 | 477 | ||
465 | - if ($uid && !empty($result['data'])) { | 478 | + /*if ($uid && !empty($result['data'])) { |
466 | try { | 479 | try { |
467 | UnionTrans::set($uid, $result['data']['order_code'], $result['data']['order_amount']); | 480 | UnionTrans::set($uid, $result['data']['order_code'], $result['data']['order_amount']); |
468 | } catch (Exception $e) { | 481 | } catch (Exception $e) { |
469 | // do nothing | 482 | // do nothing |
470 | } | 483 | } |
471 | - } | 484 | + }*/ |
472 | } else { | 485 | } else { |
473 | echo ' '; | 486 | echo ' '; |
474 | } | 487 | } |
-
Please register or login to post a comment