CallController.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Administrator
  5. * Date: 2020-09-29
  6. * Time: 8:45
  7. */
  8. namespace app\back\controller;
  9. use app\back\model\JsCallModel;
  10. use cmf\controller\AdminBaseController;
  11. use app\back\model\JsOrderModel;
  12. use think\Db;
  13. class CallController extends AdminBaseController
  14. {
  15. public function index()
  16. {
  17. $where = [];
  18. $pw = [];
  19. $page = $this->request->param('page',1);
  20. $admin_is_look = $this->request->param('admin_is_look');
  21. if($admin_is_look || $admin_is_look != ''){
  22. $where['admin_is_look'] = $admin_is_look;
  23. $pw['admin_is_look'] = $admin_is_look;
  24. $this->assign('admin_is_look',$admin_is_look);
  25. }
  26. $agency_is_look = $this->request->param('agency_is_look');
  27. if($agency_is_look || $agency_is_look != ''){
  28. $where['agency_is_look'] = $agency_is_look;
  29. $pw['agency_is_look'] = $agency_is_look;
  30. $this->assign('agency_is_look',$agency_is_look);
  31. }
  32. $list = Db::name('js_call')->where($where)
  33. ->field('t.*,t1.mobile as user_mobile,t1.user_nickname,t2.order_sn,t2.district,t2.address1,t2.delete_time as order_delete_time')
  34. ->alias('t')
  35. ->join('user t1','t.user_id = t1.id','left')
  36. ->join('js_order t2','t.order_id = t2.id AND t2.delete_time is NULL','left')
  37. ->order('t.id','desc')
  38. ->paginate(30,false,array($page,url('index'),'query'=>$pw));
  39. $this->assign('list',$list);
  40. $this->assign('action',$this->request->action());
  41. $this->assign('page',$list->render());
  42. return $this->fetch();
  43. }
  44. public function look()
  45. {
  46. $id = $this->request->param('id');
  47. $info = JsCallModel::get($id,['jsorder'=>['project','xiadanUser'],'user.js']);
  48. // $info->jsorder->project;
  49. // $info->jsorder->xiadanUser;
  50. // $info->user->js;
  51. $this->assign('info',$info);
  52. return $this->fetch();
  53. }
  54. public function lookPost()
  55. {
  56. $id = $this->request->param('id');
  57. $JsCallModel = new JsCallModel();
  58. $JsCallModel->allowField(true)->isUpdate(true)->save(['admin_is_look_time'=>time(),'admin_is_look'=>1],['id'=>$id]);
  59. $this->success('操作成功');
  60. }
  61. public function num()
  62. {
  63. $num = $this->request->param('num');
  64. $JsCallModel = new JsCallModel();
  65. $shishi_num = $JsCallModel::where('admin_is_look',0)->count();
  66. if($shishi_num > $num){
  67. return ['code'=>1,'shishi_num'=>$shishi_num];
  68. }else{
  69. return ['code'=>0];
  70. }
  71. }
  72. public function neworder()
  73. {
  74. $last_time = file_exists('lasttime.log')?file_get_contents('lasttime.log'):time()-360*24*60*60;
  75. file_put_contents('lasttime.log',time());
  76. $JsOrderModel = new JsOrderModel();
  77. $shishi_num = $JsOrderModel::where('create_time','>',$last_time)->count();
  78. if($shishi_num > 0){
  79. return ['code'=>1,'shishi_num'=>$shishi_num];
  80. }else{
  81. return ['code'=>0];
  82. }
  83. }
  84. }