Authored by cailing

订单列表添加再次购买

@@ -214,4 +214,20 @@ class OrderData @@ -214,4 +214,20 @@ class OrderData
214 214
215 return Yohobuy::get(Yohobuy::API_URL, $param); 215 return Yohobuy::get(Yohobuy::API_URL, $param);
216 } 216 }
  217 +
  218 + /** 再次购买
  219 + * @param type $uid
  220 + * @param type $orderCode
  221 + * @return type
  222 + */
  223 + public static function reAddData($uid, $orderCode)
  224 + {
  225 + $param = Yohobuy::param();
  226 + $param['method'] = 'app.Shopping.readd';
  227 + $param['uid'] = $uid;
  228 + $param['order_code'] = $orderCode;
  229 + $param['client_secret'] = Sign::getSign($param);
  230 +
  231 + return Yohobuy::get(Yohobuy::API_URL, $param);
  232 + }
217 } 233 }
@@ -112,16 +112,20 @@ @@ -112,16 +112,20 @@
112 {{#if cancelOrder}} 112 {{#if cancelOrder}}
113 <span class="op-item cancel-order">取消订单</span> 113 <span class="op-item cancel-order">取消订单</span>
114 {{^}} 114 {{^}}
115 - {{#if confirmReceived}}  
116 - <span class="op-item confirm-received">确认收货</span> 115 + {{#if reBuy}}
  116 + <span class="op-item rebuy">再次购买</span>
117 {{^}} 117 {{^}}
118 - <a class="op-item{{#if payNow}} pay-now{{/if}}" href="{{href}}" target="_blank">  
119 - {{#if payNow}}  
120 - 立即付款  
121 - {{^}}  
122 - {{name}}  
123 - {{/if}}  
124 - </a> 118 + {{#if confirmReceived}}
  119 + <span class="op-item confirm-received">确认收货</span>
  120 + {{^}}
  121 + <a class="op-item{{#if payNow}} pay-now{{/if}}" href="{{href}}" target="_blank">
  122 + {{#if payNow}}
  123 + 立即付款
  124 + {{^}}
  125 + {{name}}
  126 + {{/if}}
  127 + </a>
  128 + {{/if}}
125 {{/if}} 129 {{/if}}
126 {{/if}} 130 {{/if}}
127 {{/if}} 131 {{/if}}
@@ -268,5 +268,39 @@ class OrdersController extends WebAction @@ -268,5 +268,39 @@ class OrdersController extends WebAction
268 268
269 $this->echoJson($result); 269 $this->echoJson($result);
270 } 270 }
  271 +
  272 + /**
  273 + * 我的订单——再次购买
  274 + */
  275 + public function reAddAction()
  276 + {
  277 + $result = array('code' => 401, 'message' => '商品加入购物车失败', 'data' => '');
  278 +
  279 + do {
  280 + /* 判断是不是AJAX请求 */
  281 + if (!$this->isAjax()) {
  282 + break;
  283 + }
  284 + //获取相关参数
  285 + $uid = $this->getUid(true);
  286 + $orderCode = $this->get('orderCode', '');
  287 + if (!$uid || !$orderCode) {
  288 + $result = array('code' => 400, 'message' => '缺失参数', 'data' => '');
  289 + break;
  290 + }
  291 + $reAddData = OrderData::reAddData($uid, $orderCode);
  292 + if(!isset($reAddData['code']) || $reAddData['code'] != 200){
  293 + break;
  294 + }
  295 + $result = array('code' => 200, 'message' => '商品已重新加入购物车', 'data' => $reAddData['data']);
  296 +
  297 + if (!isset($result['code'])) {
  298 + break;
  299 + }
  300 + }
  301 + while (false);
  302 +
  303 + $this->echoJson($result);
  304 + }
271 305
272 } 306 }