1. 程式人生 > >查詢訂單(訂單包含多件商品)

查詢訂單(訂單包含多件商品)

跨域請求介面

//如果前端不跨域請求,可以加上4行header頭
header('content-type:application:json;charset=utf8');
header('Access-Control-Allow-Origin:*');
header('Access-Control-Allow-Methods:POST');
header('Access-Control-Allow-Headers:x-requested-with,content-type');
public function Alloreder(){
$userid=addslashes($_REQUEST['otherId'
]); $callback=addslashes($_REQUEST['callback']); $page=addslashes($_REQUEST['page']); if(empty($userid)){ $response = array( 'code' => 204, 'message' => '引數不足', ); }else{ $m=M('d_orders'); $limit =5; $start = ($page-1)*$limit; $rs= $m->field('wst_orders.orderNo as orderNo,wst_orders.shopId as shopId,wst_orders.orderId as orderId,wst_orders.userName as userName,wst_orders.userPhone as userPhone,wst_orders.userAddress as userAddress,wst_d_orders.p_status as p_status'
)->join('wst_orders ON wst_d_orders.orderId = wst_orders.orderId')->where("wst_d_orders.deliveryId=$userid and wst_orders.orderFlag=1")->order('wst_d_orders.porderId desc')->limit($start,$limit)->select(); foreach ($rs as $k=>$v){ $rs[$k]['goodsList']= M('order_goods')->field('goodsId,goodsNums,goodsName,goodsThums,goodsPrice'
)->where("orderId=".$v['orderId'])->select(); } if(empty($rs)){ $response = array( 'code' => 201, 'message' => '無資料', ); }else{ $response = array( 'code' => 200, 'message' => '成功', 'data'=>$rs, ); } } //echo json_encode($response); echo $callback.'('.json_encode($response).')'; }