Authored by Rock Zhang

修复h5友盟添加记录方式

Code Review By Rock Zhang
... ... @@ -360,9 +360,10 @@ class CartData
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量或为空
* @param string $skuList 购买限购商品时需要传递的参数
* @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList)
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $userAgent)
{
$param = Yohobuy::param();
$param['debug'] = 'Y';
... ... @@ -398,7 +399,7 @@ class CartData
$param['uid'] = $uid;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
return Yohobuy::get(Yohobuy::API_URL, $param, false, false, 5, $userAgent);
}
/**
... ...
... ... @@ -628,9 +628,10 @@ class CartModel
* @param string $couponCode 优惠券码
* @param mixed $yohoCoin 使用的YOHO币数量或为空
* @param string $skuList 购买限购商品时需要传递的参数
* @param string|null $userAgent 联盟过来用户下单时需要的User-Agent信息
* @return array 接口返回的数据
*/
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList)
public static function orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $userAgent = null)
{
$result = array('code' => 400, 'message' => '出错啦');
... ... @@ -644,7 +645,7 @@ class CartModel
$result['code'] = 403;
$result['message'] = '请选择配送方式';
} else {
$orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList);
$orderSubRes = CartData::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $userAgent);
if ($orderSubRes && isset($orderSubRes['code'])) {
$result = $orderSubRes;
}
... ...
<?php
use Action\AbstractAction;
use Hood\Core\Security\AuthCode;
use Index\CartModel;
use Index\UserModel;
use Plugin\Helpers;
... ... @@ -445,7 +446,19 @@ class IndexController extends AbstractAction
$couponCode = $this->post('couponCode', null);
$yohoCoin = $this->post('yohoCoin', 1);
$skuList = $this->post('skuList', '');
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList);
/* 判断是否是友盟过来的用户 */
$userAgent = null;
if (!empty($_COOKIE['_QYH_UNION'])) {
/* 解密客户端联盟信息 */
$unionKey = AuthCode::decode($_COOKIE['_QYH_UNION'], 'q_union_yohobuy');
/* 检查联盟参数是否有效 */
$unionInfo = empty($unionKey) ? array() : json_decode($unionKey, true);
/* 模拟APP的User-Agent */
$userAgent = isset($unionInfo['client_id']) ? 'YOHO!Buy/3.8.2.259(Model/PC;Channel/' . $unionInfo['client_id'] . ';uid/' . $uid . ')' : null;
}
$result = CartModel::orderSub($uid, $addressId, $cartType, $deliveryTime, $deliveryWay, $invoiceTitle, $invoiceId, $paymentId, $paymentType, $remark, $couponCode, $yohoCoin, $skuList, $userAgent);
// 记录下单异常的数据
if (empty($result)) {
... ... @@ -462,13 +475,13 @@ class IndexController extends AbstractAction
$this->echoJson($result);
}
if ($uid && !empty($result['data'])) {
/*if ($uid && !empty($result['data'])) {
try {
UnionTrans::set($uid, $result['data']['order_code'], $result['data']['order_amount']);
} catch (Exception $e) {
// do nothing
}
}
}*/
} else {
echo ' ';
}
... ...