Biddings.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace app\admin\controller\demand;
  3. use app\common\controller\Backend;
  4. use app\common\service\DemandBiddingService;
  5. use app\common\service\DemandService;
  6. use think\exception\HttpResponseException;
  7. /**
  8. * 需求投标管理
  9. *
  10. * @icon fa fa-circle-o
  11. */
  12. class Biddings extends Backend
  13. {
  14. /**
  15. * Biddings模型对象
  16. * @var \app\common\model\demand\Biddings
  17. */
  18. protected $model = null;
  19. public function _initialize()
  20. {
  21. parent::_initialize();
  22. $this->model = new \app\common\model\demand\Biddings;
  23. $this->view->assign("biddingStatusList", $this->model->getBiddingStatusList());
  24. $this->view->assign("processStatusList", $this->model->getProcessStatusList());
  25. }
  26. /**
  27. * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个基础方法、destroy/restore/recyclebin三个回收站方法
  28. * 因此在当前控制器中可不用编写增删改查的代码,除非需要自己控制这部分逻辑
  29. * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
  30. */
  31. /**
  32. * 设为中标
  33. */
  34. public function win($ids)
  35. {
  36. $row = $this->model->get(['id' => $ids]);
  37. if (!$row) {
  38. $this->error(__('No Results were found'));
  39. }
  40. if ($this->request->isAjax()) {
  41. try {
  42. DemandBiddingService::setWin($row);
  43. $this->success("设为中标成功", null);
  44. } catch (\Exception $e) {
  45. if ($e instanceof HttpResponseException) {
  46. throw $e;
  47. }
  48. $this->error('操作失败:' . $e->getMessage());
  49. }
  50. }
  51. $this->view->assign("row", $row->toArray());
  52. return $this->view->fetch();
  53. }
  54. }