Plantask.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace app\index\controller;
  3. use think\Controller;
  4. use think\Db;
  5. use think\Cache;
  6. class Plantask extends Controller
  7. {
  8. //未支付订单,下单N分钟后,自动取消
  9. public function auto_cancel_nopay_order(){
  10. $nowtime = time();
  11. $second = config('site.nopay_order_autocancel_minute') * 60;
  12. $lasttime = $nowtime - $second;
  13. //dump(datetime($lasttime));exit;
  14. $rs = Db::name('wenzhen_order')->where('status',0)->where('createtime','lt',$lasttime)->update([
  15. 'status' => 3,
  16. 'cancel_time' => $nowtime,
  17. 'cancel_reason' => '超时未支付',
  18. 'finish_time' => $nowtime,
  19. ]);
  20. echo $rs;
  21. }
  22. //待接诊订单,医生不操作,支付N分钟后,自动退珍
  23. public function auto_tuizhen_noaccept_order(){
  24. $nowtime = time();
  25. $second = config('site.payorder_noaccept_autotuizhen_minute') * 60;
  26. $lasttime = $nowtime - $second;
  27. //dump(datetime($lasttime));exit;
  28. $rs = Db::name('wenzhen_order')->where('status',10)->where('pay_time','lt',$lasttime)->update([
  29. 'status' => 16,
  30. 'cancel_time' => $nowtime,
  31. 'cancel_reason' => '超时未接诊',
  32. 'finish_time' => $nowtime,
  33. //待退款
  34. 'refund_status' => 1,
  35. ]);
  36. echo $rs;
  37. //不仅改状态,还要自动退款,放到队列处理
  38. }
  39. //视频订单,已拨打,通话N分钟后,自动结束
  40. public function auto_finish_firstvideo_videoorder(){
  41. $nowtime = time();
  42. $second = config('site.firstvideo_videoorder_autofinish_minute') * 60;
  43. $lasttime = $nowtime - $second;
  44. $rs = Db::name('wenzhen_order')->where('status',25)->where('ordertype',2)->where('video_time','lt',$lasttime)->update([
  45. 'status' => 30,
  46. 'finish_time' => $nowtime,
  47. ]);
  48. echo $rs;
  49. }
  50. //图文订单,已接诊,接诊N分钟后,自动结束
  51. public function auto_finish_accept_textorder(){
  52. $nowtime = time();
  53. $second = config('site.accept_textorder_autofinish_minute') * 60;
  54. $lasttime = $nowtime - $second;
  55. $rs = Db::name('wenzhen_order')->where('status',20)->where('ordertype',1)->where('accept_time','lt',$lasttime)->update([
  56. 'status' => 30,
  57. 'finish_time' => $nowtime,
  58. ]);
  59. echo $rs;
  60. }
  61. /////////////////////////////////////////////////////////////////////////
  62. //定时跑用户活跃,改成离线
  63. public function auto_user_active(){
  64. $actitime = time() - 7200;
  65. $sql = 'update `mt_user` set is_active = 0 where is_active = 1 and id in (select user_id from mt_user_active where requesttime < '.$actitime.')';
  66. db()->query($sql);
  67. }
  68. //vip过期的,三个隐私设置改成0
  69. //vip过期的,更新用户表is_vip
  70. public function auto_vipend(){
  71. // $sql = 'update `mt_user_power` set yinsi = 0,yinshen = 0,wuhen = 0 where user_id in (select user_id from mt_user_wallet where vip_endtime > 0 and vip_endtime < '.time().')';
  72. // db()->query($sql);
  73. /*$sql2 = 'update `mt_user` set is_vip = 0 where is_vip = 1 and user_id in (select user_id from mt_user_wallet where vip_endtime > 0 and vip_endtime < '.time().')';
  74. db()->query($sql2);*/
  75. }
  76. }