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,6 +112,9 @@ @@ -112,6 +112,9 @@
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 reBuy}}
  116 + <span class="op-item rebuy">再次购买</span>
  117 + {{^}}
115 {{#if confirmReceived}} 118 {{#if confirmReceived}}
116 <span class="op-item confirm-received">确认收货</span> 119 <span class="op-item confirm-received">确认收货</span>
117 {{^}} 120 {{^}}
@@ -125,6 +128,7 @@ @@ -125,6 +128,7 @@
125 {{/if}} 128 {{/if}}
126 {{/if}} 129 {{/if}}
127 {{/if}} 130 {{/if}}
  131 + {{/if}}
128 {{/ operation}} 132 {{/ operation}}
129 </div> 133 </div>
130 </div> 134 </div>
@@ -269,4 +269,38 @@ class OrdersController extends WebAction @@ -269,4 +269,38 @@ class OrdersController extends WebAction
269 $this->echoJson($result); 269 $this->echoJson($result);
270 } 270 }
271 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 + }
  305 +
272 } 306 }