Purchease.php 910 B

1234567891011121314151617181920212223242526272829
  1. <?php
  2. namespace app\cxinv\controller;
  3. use app\cxinv\model\CgdInfo;
  4. use think\App;
  5. class Purchease extends Base{
  6. public function __construct(App $app) {
  7. parent::__construct($app);
  8. $this->model=new CgdInfo();
  9. }
  10. public function status(){
  11. $param= $this->request->param(['id'=>'','status'=>''],'post','trim');
  12. $valid= $this->validate($param,[
  13. 'id|订单编号'=>'require|number',
  14. 'status|订单状态'=>'require|number|in:0,1,2,3'
  15. ]);
  16. if($valid!==true) return error($valid);
  17. $model= $this->model->findOrEmpty($param['id']);
  18. if($model->isEmpty())return error('订单不存在');
  19. if($model->status==$param['status']) return error('订单状态已更新');
  20. $model->status=$param['status'];
  21. $save = $model->save();
  22. if($save===false)return error('更新失败');
  23. return success('更新成功');
  24. }
  25. }