Third.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace app\api\controller\v1;
  3. use app\api\controller\Base;
  4. use app\common\model\Config;
  5. use app\hander\HelpHander;
  6. use think\App;
  7. use think\Db;
  8. use think\Exception;
  9. use think\exception\Handle;
  10. use think\Controller;
  11. class Third extends Controller {
  12. //发起订单
  13. public function add() {
  14. $this->model = new \app\common\model\Orders();
  15. $userId = 187;
  16. $userOrg = Db::name('user_org')
  17. ->where('user_id',$userId)
  18. ->find();
  19. $userDep = Db::name('user_dep')
  20. ->where('user_id',$userId)
  21. ->find();
  22. $json = [
  23. 'user_id'=>$userId,
  24. 'org_id'=>$userOrg?$userOrg['org_id']:0,
  25. 'dep_id'=>$userDep?$userDep['dep_id']:0,
  26. 'images'=>input('images',''),
  27. 'videos'=>input('videos',''),
  28. 'voices'=>input('voices',''),
  29. 'content'=>input('content',''),
  30. 'work_type_mode'=>input('workTypeMode/d',1),
  31. 'repair_priority'=>input('repairPriority',2),
  32. ];
  33. if(!in_array($json['work_type_mode'],[1])){
  34. HelpHander::error('workTypeMode参数值错误');
  35. }
  36. $res = $this->model->addSave($json);
  37. if (!$res) {
  38. HelpHander::error($this->model->getError());
  39. }
  40. HelpHander::success('操作成功');
  41. }
  42. }