Plantask.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. 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. }
  21. //待接诊订单,医生不操作,支付N分钟后,自动退珍
  22. public function auto_tuizhen_noaccept_order(){
  23. $nowtime = time();
  24. $second = config('site.payorder_noaccept_autotuizhen_minute') * 60;
  25. $lasttime = $nowtime - $second;
  26. //dump(datetime($lasttime));exit;
  27. Db::name('wenzhen_order')->where('status',10)->where('pay_time','lt',$lasttime)->update([
  28. 'status' => 16,
  29. 'cancel_time' => $nowtime,
  30. 'cancel_reason' => '超时未接诊',
  31. 'finish_time' => $nowtime,
  32. //待退款
  33. 'refund_status' => 1,
  34. ]);
  35. //不仅改状态,还要自动退款,放到队列处理
  36. }
  37. //视频订单,已拨打,通话N分钟后,自动结束
  38. public function auto_finish_firstvideo_videoorder(){
  39. $nowtime = time();
  40. $second = config('site.firstvideo_videoorder_autofinish_minute') * 60;
  41. $lasttime = $nowtime - $second;
  42. Db::name('wenzhen_order')->where('status',25)->where('ordertype',2)->where('video_time','lt',$lasttime)->update([
  43. 'status' => 30,
  44. 'finish_time' => $nowtime,
  45. ]);
  46. }
  47. //图文订单,已接诊,接诊N分钟后,自动结束
  48. public function auto_finish_accept_textorder(){
  49. $nowtime = time();
  50. $second = config('site.accept_textorder_autofinish_minute') * 60;
  51. $lasttime = $nowtime - $second;
  52. Db::name('wenzhen_order')->where('status',20)->where('ordertype',1)->where('accept_time','lt',$lasttime)->update([
  53. 'status' => 30,
  54. 'finish_time' => $nowtime,
  55. ]);
  56. }
  57. /////////////////////////////////////////////////////////////////////////
  58. //定时跑用户活跃,改成离线
  59. public function auto_user_active(){
  60. $actitime = time() - 7200;
  61. $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.')';
  62. db()->query($sql);
  63. }
  64. //vip过期的,三个隐私设置改成0
  65. //vip过期的,更新用户表is_vip
  66. public function auto_vipend(){
  67. // $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().')';
  68. // db()->query($sql);
  69. /*$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().')';
  70. db()->query($sql2);*/
  71. }
  72. }