BillApply.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace app\synth\controller;
  3. use app\common\model\ActivityApply;
  4. use app\common\model\StoreOrderRefund;
  5. use library\Controller;
  6. use think\Db;
  7. class BillApply extends Controller
  8. {
  9. protected $table = 'BillApply';
  10. /**
  11. * 列表
  12. * @auth true
  13. * @menu true
  14. * @throws \think\Exception
  15. * @throws \think\db\exception\DataNotFoundException
  16. * @throws \think\db\exception\ModelNotFoundException
  17. * @throws \think\exception\DbException
  18. * @throws \think\exception\PDOException
  19. */
  20. public function index()
  21. {
  22. $this->title = '列表';
  23. $query = $this->_query($this->table);
  24. $this->type_arr = \app\common\model\BillType::getType();
  25. $where= [];
  26. $were[] = ['i.is_deleted','=',0];
  27. if($this->request->request('user_name')) $where[]= ['i.name','like','%'.$this->request->request('user_name').'%'];
  28. if($this->request->request('header')) $where[]= ['i.header','like','%'.$this->request->request('header').'%'];
  29. if($this->request->request('type')) $where[]= ['i.type','=',$this->request->request('type')];
  30. $query->alias('i')->field('i.* ,b.title type_name,m.headimg,m.name as user_name,m.phone')
  31. ->Leftjoin('store_member m',' m.id = i.user_id ')
  32. ->join('bill_type b',' b.id = i.type ','LEFT');
  33. if(!empty($where)) $query->where($where);
  34. $query ->order('i.id desc')->page();
  35. }
  36. protected function _index_page_filter(array &$data)
  37. {
  38. }
  39. /**
  40. * 删除
  41. * @auth true
  42. * @menu true
  43. * @param array $data
  44. * @throws \think\db\exception\DataNotFoundException
  45. * @throws \think\db\exception\ModelNotFoundException
  46. * @throws \think\exception\DbException
  47. */
  48. public function remove()
  49. {
  50. $this->_save($this->table, ['is_deleted' => '1']);
  51. }
  52. /**
  53. * 编辑
  54. * @auth true
  55. * @menu true
  56. * @throws \think\Exception
  57. * @throws \think\db\exception\DataNotFoundException
  58. * @throws \think\db\exception\ModelNotFoundException
  59. * @throws \think\exception\DbException
  60. * @throws \think\exception\PDOException
  61. */
  62. public function edit()
  63. {
  64. $this->title = '编辑';
  65. $this->_form($this->table, 'form');
  66. }
  67. /**
  68. * 表单数据处理
  69. * @auth true
  70. * @menu true
  71. * @param array $data
  72. */
  73. protected function _form_filter(&$data)
  74. {
  75. if ($this->request->isGet() && $this->request->action() == 'edit'){
  76. // 退款金额
  77. $refund_money = StoreOrderRefund::getRefundMoney($data['order_id'],1);
  78. $data['refund_money'] = $refund_money;
  79. $order_info = ActivityApply::where('id',$data['order_id'])->find()->toArray();
  80. $data['order_info'] = $order_info;
  81. if($data['address_info']) $data['address_info'] = json_decode($data['address_info'],true);
  82. $this->data = $data;
  83. }
  84. if ($this->request->isPost() && $this->request->action() == 'deliver') {
  85. $express_company = Db::name('express_company')->field('id,express_title')->find($data['express_company_id']);
  86. $data['express_company_title'] = $express_company['express_title'] ? $express_company['express_title'] : '';
  87. $data['express_send_at'] = date("Y-m-d H:i:s");
  88. $data['express_state'] = 1;
  89. }
  90. }
  91. }