作者 潘浩文
1 个管道 的构建 通过 耗费 1 秒

XIAOPAN

@@ -13,6 +13,7 @@ use app\portal\model\EquipmentModel; @@ -13,6 +13,7 @@ use app\portal\model\EquipmentModel;
13 use app\portal\model\OrderModel; 13 use app\portal\model\OrderModel;
14 use cmf\controller\AdminBaseController; 14 use cmf\controller\AdminBaseController;
15 use EasyWeChat\Payment\Order; 15 use EasyWeChat\Payment\Order;
  16 +use think\Db;
16 17
17 /** 18 /**
18 * Class AdminOrderController 19 * Class AdminOrderController
@@ -63,4 +64,13 @@ class AdminOrderController extends AdminBaseController{ @@ -63,4 +64,13 @@ class AdminOrderController extends AdminBaseController{
63 $this->assign('end_number', isset($param['end_number']) ? $param['end_number'] : ''); 64 $this->assign('end_number', isset($param['end_number']) ? $param['end_number'] : '');
64 return $this->fetch(); 65 return $this->fetch();
65 } 66 }
  67 +
  68 + //更改订单状态
  69 + public function endOrder(){
  70 + $param=$this->request->param();
  71 + Db::name('order')
  72 + ->where('id',$param['id'])
  73 + ->update(['state'=>3]);
  74 + $this->success('完成订单成功');
  75 + }
66 } 76 }
@@ -218,9 +218,7 @@ class UsersController extends HomeBaseController{ @@ -218,9 +218,7 @@ class UsersController extends HomeBaseController{
218 * @author 董瑞恩 218 * @author 董瑞恩
219 * @url /portal/users/getOrderById1 219 * @url /portal/users/getOrderById1
220 * @method GET 220 * @method GET
221 - *  
222 * @param name:users_id type:String require:1 default:无 other: desc:用户id 221 * @param name:users_id type:String require:1 default:无 other: desc:用户id
223 - *  
224 * @return order_no:订单号 222 * @return order_no:订单号
225 * @return users_id:用户id 223 * @return users_id:用户id
226 * @return start_time:开始使用时间 224 * @return start_time:开始使用时间
@@ -233,7 +231,12 @@ class UsersController extends HomeBaseController{ @@ -233,7 +231,12 @@ class UsersController extends HomeBaseController{
233 231
234 public function getOrderById1(){ 232 public function getOrderById1(){
235 $users_id=$this->request->param('users_id'); 233 $users_id=$this->request->param('users_id');
236 - $order= Db::name('order')->field('order_no,users_id,start_time')->where(['users_id'=>$users_id,'state'=>1,'type'=>1])->find(); 234 + $order= Db::name('order')
  235 + ->alias('o')
  236 + ->join('equipment e','o.eq_name=e.name')
  237 + ->field('o.order_no,o.users_id,o.start_time,e.serial_number')
  238 + ->where(['o.users_id'=>$users_id,'o.state'=>1,'o.type'=>1,'e.is_delete'=>0])
  239 + ->find();
237 if (empty($order)){ 240 if (empty($order)){
238 $this->apiResponse(200,'没有未完成订单'); 241 $this->apiResponse(200,'没有未完成订单');
239 } 242 }
@@ -270,7 +273,12 @@ class UsersController extends HomeBaseController{ @@ -270,7 +273,12 @@ class UsersController extends HomeBaseController{
270 273
271 public function getOrderById2(){ 274 public function getOrderById2(){
272 $users_id=$this->request->param('users_id'); 275 $users_id=$this->request->param('users_id');
273 - $order= Db::name('order')->where(['users_id'=>$users_id,'state'=>2,'type'=>'1'])->find(); 276 + $order= Db::name('order')
  277 + ->alias('o')
  278 + ->join('equipment e','o.eq_name=e.name')
  279 + ->where(['o.users_id'=>$users_id,'o.state'=>2,'o.type'=>'1','e.is_delete'=>0])
  280 + ->field('o.*,e.serial_number')
  281 + ->find();
274 if (empty($order)){ 282 if (empty($order)){
275 $this->apiResponse(200,'没有未支付订单'); 283 $this->apiResponse(200,'没有未支付订单');
276 } 284 }
@@ -36,6 +36,7 @@ @@ -36,6 +36,7 @@
36 <th>使用时长</th> 36 <th>使用时长</th>
37 <th>使用费用</th> 37 <th>使用费用</th>
38 <th>支付状态</th> 38 <th>支付状态</th>
  39 + <th>操作</th>
39 </tr> 40 </tr>
40 </thead> 41 </thead>
41 <foreach name="data" item="vo"> 42 <foreach name="data" item="vo">
@@ -52,6 +53,10 @@ @@ -52,6 +53,10 @@
52 <else /> 53 <else />
53 已支付 54 已支付
54 </eq></td> 55 </eq></td>
  56 + <td><eq name="vo.state" value="2">
  57 + <a href="{:url('AdminOrder/endOrder',array('id'=>$vo['id']))}" class="js-ajax-dialog-btn">完成订单</a>
  58 + </eq>
  59 + </td>
55 </tr> 60 </tr>
56 </foreach> 61 </foreach>
57 </table> 62 </table>