Express.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | framework
  4. // +----------------------------------------------------------------------
  5. // | 版权所有 2014~2018 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
  6. // +----------------------------------------------------------------------
  7. // | 官方网站: http://framework.thinkadmin.top
  8. // +----------------------------------------------------------------------
  9. // | 开源协议 ( https://mit-license.org )
  10. // +----------------------------------------------------------------------
  11. // | github开源项目:https://github.com/zoujingli/ThinkAdmin
  12. // +----------------------------------------------------------------------
  13. namespace app\store\controller;
  14. use library\Controller;
  15. use think\Db;
  16. /**
  17. * 快递公司管理
  18. * Class Express
  19. * @package app\store\controller
  20. */
  21. class Express extends Controller
  22. {
  23. /**
  24. * 指定数据表
  25. * @var string
  26. */
  27. protected $table = 'StoreExpress';
  28. /**
  29. * @throws \think\Exception
  30. * @throws \think\db\exception\DataNotFoundException
  31. * @throws \think\db\exception\ModelNotFoundException
  32. * @throws \think\exception\DbException
  33. * @throws \think\exception\PDOException
  34. */
  35. public function index()
  36. {
  37. $this->title = '快递公司管理';
  38. $this->_query($this->table)->equal('status')->like('express_title,express_code')->dateBetween('create_at')->order('status desc,sort asc,id desc')->page();
  39. }
  40. /**
  41. * 添加快递公司
  42. */
  43. public function add()
  44. {
  45. $this->_form($this->table, 'form');
  46. }
  47. /**
  48. * 编辑快递公司
  49. */
  50. public function edit()
  51. {
  52. $this->_form($this->table, 'form');
  53. }
  54. /**
  55. * 表单数据处理
  56. * @param array $data
  57. */
  58. protected function _form_filter(array $data)
  59. {
  60. if ($this->request->isPost()) {
  61. $where = [['express_code', 'eq', $data['express_code']], ['is_deleted', 'eq', '0']];
  62. if (!empty($data['id'])) $where[] = ['id ', 'neq', $data['id']];
  63. if (Db::name($this->table)->where($where)->count() > 0) {
  64. $this->error('该快递编码已经存在,请使用其它编码!');
  65. }
  66. }
  67. }
  68. /**
  69. * 禁用快递公司
  70. */
  71. public function forbid()
  72. {
  73. $this->_save($this->table, ['status' => '0']);
  74. }
  75. /**
  76. * 启用快递公司
  77. */
  78. public function resume()
  79. {
  80. $this->_save($this->table, ['status' => '1']);
  81. }
  82. /**
  83. * 删除快递公司
  84. */
  85. public function del()
  86. {
  87. $this->_delete($this->table);
  88. }
  89. }