ExpressCompany.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  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/framework
  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 ExpressCompany extends Controller
  22. {
  23. /**
  24. * 指定数据表
  25. * @var string
  26. */
  27. protected $table = 'StoreExpressCompany';
  28. /**
  29. * 快递公司管理
  30. * @throws \think\Exception
  31. * @throws \think\db\exception\DataNotFoundException
  32. * @throws \think\db\exception\ModelNotFoundException
  33. * @throws \think\exception\DbException
  34. * @throws \think\exception\PDOException
  35. */
  36. public function index()
  37. {
  38. $this->title = '快递公司管理';
  39. $query = $this->_query($this->table)->equal('status')->like('express_title,express_code');
  40. $query->dateBetween('create_at')->order('status desc,sort asc,id desc')->page();
  41. }
  42. /**
  43. * 添加快递公司
  44. */
  45. public function add()
  46. {
  47. $this->_form($this->table, 'form');
  48. }
  49. /**
  50. * 编辑快递公司
  51. */
  52. public function edit()
  53. {
  54. $this->_form($this->table, 'form');
  55. }
  56. /**
  57. * 表单数据处理
  58. * @param array $data
  59. */
  60. protected function _form_filter(array $data)
  61. {
  62. if ($this->request->isPost()) {
  63. $where = [['express_code', 'eq', $data['express_code']], ['is_deleted', 'eq', '0']];
  64. if (!empty($data['id'])) $where[] = ['id ', 'neq', $data['id']];
  65. if (Db::name($this->table)->where($where)->count() > 0) {
  66. $this->error('该快递编码已经存在,请使用其它编码!');
  67. }
  68. }
  69. }
  70. /**
  71. * 禁用快递公司
  72. */
  73. public function forbid()
  74. {
  75. $this->_save($this->table, ['status' => '0']);
  76. }
  77. /**
  78. * 启用快递公司
  79. */
  80. public function resume()
  81. {
  82. $this->_save($this->table, ['status' => '1']);
  83. }
  84. /**
  85. * 删除快递公司
  86. */
  87. public function remove()
  88. {
  89. $this->_delete($this->table);
  90. }
  91. }