123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- namespace App\Task;
- use App\Model\Telegram\FmsWalletTradeList;
- use App\Model\Telegram\FmsRechargeOrder;
- use App\Model\Telegram\TelegramBotUser;
- use App\Model\Telegram\TelegramBot;
- use App\Library\Log;
- class HandleRechargeOrder
- {
- public function execute()
- {
- try {
-
- $data = FmsWalletTradeList::from('fms_wallet_trade_list as a')
- ->where('a.process_status',1)
- ->select('a.rid','a.transferfrom_address','a.amount','a.coin_name','a.tx_hash')
- ->limit(100)
- ->get();
- if($data->count() > 0){
- foreach ($data as $k => $v) {
- $time = nowDate();
-
-
- $res = FmsRechargeOrder::where('recharge_coin_name',$v->coin_name)->where('need_pay_price',$v->amount)->where('status',0)->first();
-
- if(empty($res)){
- $save_data = [];
- $save_data['process_status'] = 7;
- $save_data['process_comments'] = '金额无对应套餐';
- $save_data['process_time'] = $time;
- FmsWalletTradeList::where('rid',$v->rid)->update($save_data);
- continue;
- }
-
-
- $botUser = TelegramBotUser::where('bot_rid',$res['bot_rid'])->where('tg_uid',$res['recharge_tg_uid'])->first();
-
- if(empty($botUser)){
- $save_data = [];
- $save_data['process_status'] = 3;
- $save_data['process_comments'] = '找不到用户';
- $save_data['process_time'] = $time;
- FmsWalletTradeList::where('rid',$v->rid)->update($save_data);
- continue;
- }
-
- $save_data = [];
- $save_data['status'] = 1;
- $save_data['complete_time'] = $time;
- $save_data['tx_hash'] = $v->tx_hash;
- FmsRechargeOrder::where('rid',$res['rid'])->update($save_data);
-
- $save_data = [];
- $save_data['cash_trx'] = $botUser['cash_trx'] + ($v->coin_name == 'trx' ?$res['recharge_pay_price']:0);
- $save_data['cash_usdt'] = $botUser['cash_usdt'] + ($v->coin_name == 'usdt' ?$res['recharge_pay_price']:0);
- $save_data['total_recharge_trx'] = $botUser['total_recharge_trx'] + ($v->coin_name == 'trx' ?$res['recharge_pay_price']:0);
- $save_data['total_recharge_usdt'] = $botUser['total_recharge_usdt'] + ($v->coin_name == 'usdt' ?$res['recharge_pay_price']:0);
- TelegramBotUser::where('rid',$botUser['rid'])->update($save_data);
- $save_data = [];
- $save_data['process_status'] = 9;
- $save_data['process_comments'] = '充值成功';
- $save_data['process_time'] = $time;
- $save_data['recharge_order_rid'] = $res['rid'];
- FmsWalletTradeList::where('rid',$v->rid)->update($save_data);
-
- $bot = TelegramBot::where('rid',$res['bot_rid'])->first();
- if(!empty($bot)){
- $replytext = "✅您的充值订单已成功!\n"
- ."➖➖➖➖➖➖➖➖\n"
- ."<b>订单号:</b>".$v->rid."\n"
- ."<b>充值币种:</b>".$v->coin_name."\n"
- ."<b>充值金额:</b>".$res['recharge_pay_price']."\n";
-
-
- $sendmessageurl = 'https://api.telegram.org/bot'.$bot['bot_token'].'/sendMessage?chat_id='.$res['recharge_tg_uid'].'&text='.urlencode($replytext).'&parse_mode=HTML';
-
- Get_Pay($sendmessageurl);
- }
- }
- }else{
-
- }
- }catch (\Exception $e){
-
- }
- }
-
- protected function log($log_title,$message,$remarks='info'){
- Log::get($remarks,$log_title)->info($message);
- }
- }
|