CancelUnpaidOrder.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. namespace App\Task;
  3. use App\Model\Premium\PremiumPlatformOrder;
  4. use App\Model\Telegram\FmsRechargeOrder;
  5. use App\Service\RsaServices;
  6. use App\Library\Log;
  7. class CancelUnpaidOrder
  8. {
  9. public function execute()
  10. {
  11. try {
  12. //取消会员订单
  13. $data = PremiumPlatformOrder::from('premium_platform_order as a')
  14. ->Join('telegram_bot as b','a.bot_rid','b.rid')
  15. ->where('a.status',0)
  16. ->where('a.expire_time','<=',nowDate())
  17. ->select('a.rid','a.expire_time','b.bot_token','a.status','a.buy_tg_uid','a.premium_tg_username','a.premium_package_month','a.need_pay_usdt')
  18. ->limit(20)->get();
  19. if($data->count() > 0){
  20. foreach ($data as $k => $v) {
  21. $time = nowDate();
  22. //再次校验过期时间小于当前时间,直接改为已失效并通知用户
  23. if($v->expire_time <= $time && $v->status == 0){
  24. $save_data = [];
  25. $save_data['status'] = 3;
  26. $save_data['update_time'] = $time;
  27. PremiumPlatformOrder::where('rid',$v->rid)->update($save_data);
  28. $replytext = "您的会员订单已过期,请重新发起:\n"
  29. ."➖➖➖➖➖➖➖➖\n"
  30. ."<b>订单号:</b>".$v->rid."\n"
  31. ."<b>开通会员用户名:</b>".$v->premium_tg_username."\n"
  32. ."<b>开通会员月份:</b>".$v->premium_package_month."\n"
  33. ."<b>应支付USDT:</b>".$v->need_pay_usdt."\n\n"
  34. ."<b>请勿继续支付该订单!如已支付请联系客服!</b>";
  35. //通知用户
  36. $sendmessageurl = 'https://api.telegram.org/bot'.$v->bot_token.'/sendMessage?chat_id='.$v->buy_tg_uid.'&text='.urlencode($replytext).'&parse_mode=HTML';
  37. Get_Pay($sendmessageurl);
  38. }
  39. }
  40. }else{
  41. // $this->log('cancelunpaidorder','----------没有数据----------');
  42. }
  43. //取消充值订单
  44. $data = FmsRechargeOrder::from('fms_recharge_order as a')
  45. ->Join('telegram_bot as b','a.bot_rid','b.rid')
  46. ->where('a.status',0)
  47. ->where('a.expire_time','<=',nowDate())
  48. ->select('a.rid','a.expire_time','b.bot_token','a.status','a.recharge_tg_uid','a.need_pay_price','a.recharge_coin_name','a.recharge_pay_price')
  49. ->limit(20)->get();
  50. if($data->count() > 0){
  51. foreach ($data as $k => $v) {
  52. $time = nowDate();
  53. //再次校验过期时间小于当前时间,直接改为已失效并通知用户
  54. if($v->expire_time <= $time && $v->status == 0){
  55. $save_data = [];
  56. $save_data['status'] = 2;
  57. $save_data['update_time'] = $time;
  58. FmsRechargeOrder::where('rid',$v->rid)->update($save_data);
  59. $replytext = "⚠️您的充值订单已过期,请重新发起:\n"
  60. ."➖➖➖➖➖➖➖➖\n"
  61. ."<b>订单号:</b>".$v->rid."\n"
  62. ."<b>充值币种:</b>".$v->recharge_coin_name."\n"
  63. ."<b>充值金额:</b>".$v->recharge_pay_price."\n"
  64. ."<b>应支付金额:</b>".$v->need_pay_price."\n\n"
  65. ."<b>请勿继续支付该订单!如已支付请联系客服!</b>";
  66. //通知用户
  67. $sendmessageurl = 'https://api.telegram.org/bot'.$v->bot_token.'/sendMessage?chat_id='.$v->recharge_tg_uid.'&text='.urlencode($replytext).'&parse_mode=HTML';
  68. Get_Pay($sendmessageurl);
  69. }
  70. }
  71. }else{
  72. // $this->log('cancelunpaidorder','----------没有数据----------');
  73. }
  74. }catch (\Exception $e){
  75. // $this->log('cancelunpaidorder','----------任务执行报错,请联系管理员。报错原因:----------'.$e->getMessage());
  76. }
  77. }
  78. /**
  79. * 记入日志
  80. * @param $log_title [日志路径]
  81. * @param $message [内容,不支持数组]
  82. * @param $remarks [备注]
  83. */
  84. protected function log($log_title,$message,$remarks='info'){
  85. Log::get($remarks,$log_title)->info($message);
  86. }
  87. }