Authored by cailing

订单列表添加再次购买

... ... @@ -214,4 +214,20 @@ class OrderData
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/** 再次购买
* @param type $uid
* @param type $orderCode
* @return type
*/
public static function reAddData($uid, $orderCode)
{
$param = Yohobuy::param();
$param['method'] = 'app.Shopping.readd';
$param['uid'] = $uid;
$param['order_code'] = $orderCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
... ...
... ... @@ -112,16 +112,20 @@
{{#if cancelOrder}}
<span class="op-item cancel-order">取消订单</span>
{{^}}
{{#if confirmReceived}}
<span class="op-item confirm-received">确认收货</span>
{{#if reBuy}}
<span class="op-item rebuy">再次购买</span>
{{^}}
<a class="op-item{{#if payNow}} pay-now{{/if}}" href="{{href}}" target="_blank">
{{#if payNow}}
立即付款
{{^}}
{{name}}
{{/if}}
</a>
{{#if confirmReceived}}
<span class="op-item confirm-received">确认收货</span>
{{^}}
<a class="op-item{{#if payNow}} pay-now{{/if}}" href="{{href}}" target="_blank">
{{#if payNow}}
立即付款
{{^}}
{{name}}
{{/if}}
</a>
{{/if}}
{{/if}}
{{/if}}
{{/if}}
... ...
... ... @@ -268,5 +268,39 @@ class OrdersController extends WebAction
$this->echoJson($result);
}
/**
* 我的订单——再次购买
*/
public function reAddAction()
{
$result = array('code' => 401, 'message' => '商品加入购物车失败', 'data' => '');
do {
/* 判断是不是AJAX请求 */
if (!$this->isAjax()) {
break;
}
//获取相关参数
$uid = $this->getUid(true);
$orderCode = $this->get('orderCode', '');
if (!$uid || !$orderCode) {
$result = array('code' => 400, 'message' => '缺失参数', 'data' => '');
break;
}
$reAddData = OrderData::reAddData($uid, $orderCode);
if(!isset($reAddData['code']) || $reAddData['code'] != 200){
break;
}
$result = array('code' => 200, 'message' => '商品已重新加入购物车', 'data' => $reAddData['data']);
if (!isset($result['code'])) {
break;
}
}
while (false);
$this->echoJson($result);
}
}
... ...