Convert.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace app\store\controller;
  3. use library\Controller;
  4. use think\Db;
  5. /**
  6. * 积分兑换
  7. * Class Order
  8. * @package app\store\controller
  9. */
  10. class Convert extends Controller
  11. {
  12. protected $table = "IntegralConvert";
  13. /**
  14. * 订单列表
  15. * @auth true
  16. * @menu true
  17. */
  18. public function index()
  19. {
  20. $this->title = '列表';
  21. $this->sh_status_desc = ['待审核','审核通过','审核拒绝'];
  22. $query = $this->_query($this->table);
  23. if($this->request->request('phone')) $where[]= ['m.phone','like','%'.$this->request->request('phone').'%'];;
  24. $this->sh_status = $this->request->request('sh_status',-1);
  25. if($this->sh_status > -1 ) $where[]= ['o.sh_status','=',$this->request->request('sh_status')];
  26. $query->alias('o')
  27. ->field('o.* ,m.headimg,m.name,m.phone')
  28. ->join('store_member m',' m.id = o.user_id ','LEFT');
  29. if(!empty($where)) $query->where($where);
  30. $query ->order('o.sh_status asc ,o.id desc')->page();
  31. }
  32. /**
  33. * 订单审核
  34. * @auth true
  35. * @menu true
  36. */
  37. public function audit()
  38. {
  39. $this->title = '审核';
  40. $this->_form($this->table, 'form');
  41. }
  42. protected function _form_filter(&$data)
  43. {
  44. // 查看
  45. if($this->request->isGet() && $this->request->action() == 'audit')
  46. {
  47. $this->user = Db::table('store_member')
  48. ->field('headimg,name,phone')
  49. ->find($data['user_id']);
  50. }
  51. // 积分赠送integral_info
  52. if($this->request->isPost() && $this->request->action() == 'audit') {
  53. $ck = Db::table('order_shift')->find($data['id']);
  54. if($ck['sh_status'] != 1 && $data['sh_status'] == 1 && $data['integral'] > 0 && $data['user_id']) {
  55. update_user_integral($data['user_id'],$data['integral'],10,'恭喜亲通过兑换获得'.$data['integral'].'积分',$data['id']);
  56. }
  57. if($ck['sh_status'] != 1 && $data['sh_status'] == 1 && $data['growth'] > 0 && $data['user_id']) {
  58. update_user_growth($data['user_id'],$data['growth'],10,'恭喜亲通过兑换获得'.$data['growth'].'成长值',$data['id']);
  59. }
  60. $data['ck_time'] = date("Y-m-d H:i:s");
  61. }
  62. }
  63. }