HandleEnergyOrder.php 67 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  1. <?php
  2. namespace App\Task;
  3. use App\Model\Energy\EnergyWalletTradeList;
  4. use App\Model\Energy\EnergyPlatformPackage;
  5. use App\Model\Energy\EnergyPlatformOrder;
  6. use App\Model\Energy\EnergyPlatform;
  7. use App\Model\Energy\EnergyAiBishu;
  8. use App\Model\Energy\EnergyThirdPart;
  9. use App\Model\Energy\EnergyQuickOrder;
  10. use App\Service\RsaServices;
  11. use App\Library\Log;
  12. class HandleEnergyOrder
  13. {
  14. public function execute()
  15. {
  16. //trx闪租能量
  17. try {
  18. $data = EnergyWalletTradeList::from('energy_wallet_trade_list as a')
  19. ->join('energy_platform_bot as b','a.transferto_address','b.receive_wallet')
  20. ->where('a.process_status',1)
  21. ->where('a.coin_name','trx')
  22. ->select('a.rid','a.transferfrom_address','a.amount','b.poll_group','b.status','b.bot_rid','b.rid as energy_platform_bot_rid')
  23. ->limit(100)
  24. ->get();
  25. if($data->count() > 0){
  26. $time = nowDate();
  27. foreach ($data as $k => $v) {
  28. if($v->status == 1){
  29. $save_data = [];
  30. $save_data['process_status'] = 6; //能量钱包未启用
  31. $save_data['process_comments'] = '能量钱包未启用'; //处理备注
  32. $save_data['process_time'] = $time; //处理时间
  33. $save_data['energy_platform_bot_rid'] = $v->energy_platform_bot_rid;
  34. EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  35. continue;
  36. }
  37. //匹配金额
  38. $res = EnergyPlatformPackage::where('bot_rid',$v->bot_rid)->where('trx_price',$v->amount)->first();
  39. if(empty($res)){
  40. $save_data = [];
  41. $save_data['process_status'] = 7; //金额无对应套餐
  42. $save_data['process_comments'] = '金额无对应套餐'; //处理备注
  43. $save_data['process_time'] = $time; //处理时间
  44. $save_data['energy_platform_bot_rid'] = $v->energy_platform_bot_rid;
  45. EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  46. continue;
  47. }
  48. $energy_amount = $res->energy_amount;
  49. //轮询,自己质押时判断能量是否足够,用平台则判断平台的trx
  50. $model = EnergyPlatform::where('poll_group',$v->poll_group)
  51. ->where('status',0)
  52. ->whereNotNull('platform_apikey')
  53. ->where(function ($query) use($energy_amount) {
  54. $query->where(function ($query1) use($energy_amount){
  55. $query1->where('platform_name', 3)->where('platform_balance', '>=', $energy_amount);
  56. });
  57. $query->orwhere(function ($query2) {
  58. $query2->orwhereIn('platform_name', [1,2,4,5])->where('platform_balance', '>', '0');
  59. });
  60. })
  61. ->orderBy('seq_sn','desc')
  62. ->get();
  63. if($model->count() > 0){
  64. $errorMessage = '';
  65. $rsa_services = new RsaServices();
  66. foreach ($model as $k1 => $v1){
  67. $signstr = $rsa_services->privateDecrypt($v1->platform_apikey);
  68. if(empty($signstr)){
  69. // $save_data = [];
  70. // $save_data['process_status'] = 5; //能量钱包未配置私钥
  71. // $save_data['process_comments'] = '能量钱包未配置私钥2'; //处理备注
  72. // $save_data['process_time'] = $time; //处理时间
  73. // $save_data['energy_platform_rid'] = $v1->rid;
  74. // $save_data['energy_package_rid'] = $res['rid'];
  75. // $save_data['energy_platform_bot_rid'] = $v->energy_platform_bot_rid;
  76. // EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  77. $errorMessage = $errorMessage."能量平台:".$v1->platform_name." 平台私钥为空。";
  78. $save_data = [];
  79. $save_data['process_status'] = 5; //下单失败
  80. $save_data['process_comments'] = $errorMessage; //处理备注
  81. $save_data['process_time'] = $time; //处理时间
  82. $save_data['energy_platform_rid'] = $v1->rid;
  83. $save_data['energy_package_rid'] = $res['rid'];
  84. $save_data['energy_platform_bot_rid'] = $v->energy_platform_bot_rid;
  85. EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  86. continue;
  87. }
  88. $save_data = [];
  89. $save_data['process_status'] = 8; //下单中
  90. $save_data['process_comments'] = '下单中'; //处理备注
  91. $save_data['process_time'] = $time; //处理时间
  92. $save_data['energy_platform_rid'] = $v1->rid;
  93. $save_data['energy_package_rid'] = $res['rid'];
  94. $save_data['energy_platform_bot_rid'] = $v->energy_platform_bot_rid;
  95. EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  96. $energy_day = $res['energy_day'];
  97. //neee.cc平台
  98. if($v1->platform_name == 1){
  99. $header = [
  100. "Content-Type:application/json"
  101. ];
  102. $param = [
  103. "uid" => strval($v1->platform_uid),
  104. "resource_type" => "0", //0能量
  105. "receive_address" => $v->transferfrom_address,
  106. "amount" => strval($energy_amount),
  107. "freeze_day" => strval($energy_day), //0:一小时,1:一天,3:三天
  108. "time" => strval(time())
  109. ];
  110. ksort($param);
  111. reset($param);
  112. foreach($param as $ka => $va){
  113. if($ka != "sign" && $ka != "sign_type" && $va!=''){
  114. $signstr .= $ka.$va;
  115. }
  116. }
  117. $sign = md5($signstr);
  118. $param['sign'] = $sign;
  119. $balance_url = 'https://api.tronqq.com/openapi/v2/order/submit';
  120. $dlres = Get_Pay($balance_url,json_encode($param),$header);
  121. }
  122. //RentEnergysBot平台
  123. elseif($v1->platform_name == 2){
  124. //0:一小时,1:一天,3:三天
  125. switch ($energy_day) {
  126. case 1:
  127. $type = 'day';
  128. break;
  129. case 3:
  130. $type = '3day';
  131. break;
  132. default:
  133. $type = 'hour';
  134. break;
  135. }
  136. //该平台最低33000
  137. $energy_amount = $energy_amount < 33000 ?33000:$energy_amount;
  138. $balance_url = 'https://api.wallet.buzz?api=getEnergy&apikey='.$signstr.'&address='.$v->transferfrom_address.'&amount='.$energy_amount.'&type='.$type;
  139. $dlres = Get_Pay($balance_url);
  140. }
  141. //自己质押代理
  142. elseif($v1->platform_name == 3){
  143. $params = [
  144. 'pri' => $signstr,
  145. 'fromaddress' => $v1->platform_uid,
  146. 'receiveaddress' => $v->transferfrom_address,
  147. 'resourcename' => 'ENERGY',
  148. 'resourceamount' => $energy_amount,
  149. 'resourcetype' => 1,
  150. 'permissionid' => $v1->permission_id
  151. ];
  152. $dlres = Get_Pay(base64_decode('aHR0cHM6Ly90cm9ud2Vibm9kZWpzLndhbGxldGltLnZpcC9kZWxlZ2VhbmR1bmRlbGV0ZQ=='),$params);
  153. }
  154. //trongas.io平台
  155. elseif($v1->platform_name == 4){
  156. //0:一小时,1:一天,3:三天
  157. switch ($energy_day) {
  158. case 1:
  159. $rentTime = 24;
  160. break;
  161. case 3:
  162. $rentTime = 72;
  163. break;
  164. default:
  165. $rentTime = 1;
  166. break;
  167. }
  168. $param = [
  169. "username" => $v1->platform_uid, // 用户名
  170. "password" => $signstr, // 用户密码
  171. "resType" => "ENERGY", // 资源类型,ENERGY:能量,BANDWIDTH:带宽
  172. "payNums" => $energy_amount, // 租用数量
  173. "rentTime" => $rentTime, // 单位小时,只能1时或1到30天按天租用其中不能租用2天
  174. "resLock" => 0, // 租用锁定,0:不锁定,1:锁定。能量租用数量不小于500万且租用时间不小于3天才能锁定。带宽租用数量不小于30万租用时间不小于3天才能锁定
  175. "receiveAddress" => $v->transferfrom_address // 接收资源地址(请勿输入合约地址或没激活地址)
  176. ];
  177. $balance_url = 'https://trongas.io/api/pay';
  178. $dlres = Get_Pay($balance_url,$param);
  179. }
  180. //机器人开发代理
  181. elseif($v1->platform_name == 5){
  182. $balance_url = env('THIRD_URL');
  183. if(empty($balance_url)){
  184. $errorMessage = $errorMessage."使用开发者能量代理时,env中url为空";
  185. $save_data = [];
  186. $save_data['process_status'] = 4; //下单失败
  187. $save_data['process_time'] = $time; //处理时间
  188. $save_data['process_comments'] = $time.$errorMessage; //处理备注
  189. EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  190. continue;
  191. }
  192. //0:一小时,1:一天,3:三天
  193. switch ($energy_day) {
  194. case 1:
  195. $rentTime = 24;
  196. break;
  197. case 3:
  198. $rentTime = 72;
  199. break;
  200. default:
  201. $rentTime = 1;
  202. break;
  203. }
  204. //使用开发者能量代理,仅支持32000 65000能量代理1小时
  205. if($rentTime != 1){
  206. $errorMessage = $errorMessage."使用开发者能量代理时,时长只能为1小时";
  207. $save_data = [];
  208. $save_data['process_status'] = 4; //下单失败
  209. $save_data['process_time'] = $time; //处理时间
  210. $save_data['process_comments'] = $time.$errorMessage; //处理备注
  211. EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  212. continue;
  213. }
  214. $param = [
  215. "tg_uid" => $v1->platform_uid, // 用户名,此处是tg的uid,因为是机器人能量代理模式
  216. "payNums" => $energy_amount, // 租用数量
  217. "rentTime" => $rentTime, // 单位小时,只能1时或1到30天按天租用其中不能租用2天
  218. "receiveAddress" => $v->transferfrom_address // 接收资源地址(请勿输入合约地址或没激活地址)
  219. ];
  220. $balance_url = $balance_url.'/api/thirdpart/shanzuorder';
  221. $dlres = Get_Pay($balance_url,$param);
  222. }
  223. // MeFree.NET 平台
  224. elseif($v1->platform_name == 6){
  225. // API 配置信息
  226. $base_url = "https://api.mefree.net"; // Mefree API 基础地址
  227. $api_key = $v1->platform_uid; // 替换为实际的 API Key
  228. $secret_key = $signstr; // 替换为实际的 Secret Key
  229. // 代理的周期,值可能为:0,1,2,3,4...30。其中0:速充;1:一小时;2:1天;3:3天;4:4天...最多30天。
  230. $period = 1;
  231. $tron_address = $v->transferfrom_address ; // 接收资源地址(请勿输入合约地址或没激活地址)
  232. // 创建订单
  233. $request_path = "/api/order?quantity=$energy_amount&target_address=$tron_address&period=$period"; // API 请求路径
  234. $response = send_request("POST", $request_path, $base_url, $api_key, $secret_key);
  235. $dlres = $response;
  236. }
  237. if(empty($dlres)){
  238. // $save_data = [];
  239. // $save_data['process_status'] = 4; //下单失败
  240. // $save_data['process_comments'] = '下单失败,接口请求空'; //处理备注
  241. // $save_data['process_time'] = $time; //处理时间
  242. // $save_data['energy_platform_rid'] = $v1->rid;
  243. // $save_data['energy_platform_bot_rid'] = $v->energy_platform_bot_rid;
  244. // EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  245. $errorMessage = $errorMessage."能量平台:".$v1->platform_name." 能量平台接口返回为空。";
  246. $save_data = [];
  247. $save_data['process_status'] = 4; //下单失败
  248. $save_data['process_comments'] = $errorMessage; //处理备注
  249. $save_data['process_time'] = $time; //处理时间
  250. $save_data['energy_platform_rid'] = $v1->rid;
  251. $save_data['energy_package_rid'] = $res['rid'];
  252. $save_data['energy_platform_bot_rid'] = $v->energy_platform_bot_rid;
  253. EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  254. continue;
  255. }else{
  256. $dlres = json_decode($dlres,true);
  257. if(
  258. (isset($dlres['status']) && $dlres['status'] == 200 && $v1->platform_name == 1) ||
  259. (isset($dlres['status']) && $dlres['status'] == 'success' && $v1->platform_name == 2) ||
  260. (isset($dlres['code']) && $dlres['code'] == 200 && $v1->platform_name == 3) ||
  261. (isset($dlres['code']) && $dlres['code'] == 10000 && $v1->platform_name == 4) ||
  262. (isset($dlres['code']) && $dlres['code'] == 200 && $v1->platform_name == 5) ||
  263. (isset($dlres['status_code']) && $dlres['status_code'] == 200 && $v1->platform_name == 6)
  264. ){
  265. if($v1->platform_name == 1){
  266. $orderNo = $dlres['data']['order_no'];
  267. $use_trx = 0;
  268. }elseif($v1->platform_name == 2){
  269. $orderNo = $dlres['txid'];
  270. $use_trx = 0;
  271. }elseif($v1->platform_name == 3){
  272. $orderNo = $dlres['data']['txid'];
  273. $use_trx = $dlres['data']['use_trx'];
  274. }elseif($v1->platform_name == 4){
  275. $orderNo = $dlres['data']['orderId'];
  276. $use_trx = $dlres['data']['orderMoney'];
  277. }elseif($v1->platform_name == 5){
  278. $orderNo = $dlres['data']['orderId'];
  279. $use_trx = $dlres['data']['orderMoney'];
  280. }elseif($v1->platform_name == 6){
  281. $orderNo = $dlres['data']['client_order_id'];
  282. $use_trx = $dlres['data']['amount_sun'];
  283. }
  284. $insert_data = [];
  285. $insert_data['energy_platform_rid'] = $v1->rid;
  286. $insert_data['energy_platform_bot_rid'] = $v->energy_platform_bot_rid;
  287. $insert_data['platform_name'] = $v1->platform_name;
  288. $insert_data['platform_uid'] = $v1->platform_uid;
  289. $insert_data['receive_address'] = $v->transferfrom_address;
  290. $insert_data['platform_order_id'] = $orderNo;
  291. $insert_data['energy_amount'] = $energy_amount;
  292. $insert_data['energy_day'] = $energy_day;
  293. $insert_data['energy_time'] = $time;
  294. $insert_data['source_type'] = 2; //自动下单
  295. $insert_data['recovery_status'] = $v1->platform_name == 3 ?2:1; //回收状态:1不用回收,2待回收,3已回收
  296. $insert_data['use_trx'] = $use_trx;
  297. $platform_order_rid = EnergyPlatformOrder::insertGetId($insert_data);
  298. $save_data = [];
  299. $save_data['process_status'] = 9; //下单成功
  300. $save_data['process_comments'] = 'SUCCESS'; //处理备注
  301. $save_data['platform_order_rid'] = $platform_order_rid; //能量订单表ID
  302. $save_data['process_time'] = $time; //处理时间
  303. $save_data['energy_platform_rid'] = $v1->rid;
  304. $save_data['energy_platform_bot_rid'] = $v->energy_platform_bot_rid;
  305. $save_data['tg_notice_status_send'] = 'N'; //重新通知
  306. EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  307. break; //跳出不轮询了
  308. }else{
  309. if($v1->platform_name == 1){
  310. $msg = '下单失败,接口返回:'.$dlres['msg'];
  311. }elseif($v1->platform_name == 2){
  312. $msg = '下单失败,接口返回:'.json_encode($dlres);
  313. }elseif($v1->platform_name == 3){
  314. $msg = '下单失败,检查质押是否足够';
  315. }elseif($v1->platform_name == 4){
  316. $msg = ' 下单失败,接口返回:'.json_encode($dlres);
  317. }elseif($v1->platform_name == 5){
  318. $msg = ' 下单失败,接口返回:'.json_encode($dlres);
  319. }elseif($v1->platform_name == 6){
  320. $msg = ' 下单失败,接口返回:'.json_encode($dlres);
  321. $msg = ' 下单失败,接口返回-aaaa:'.$signstr;
  322. }
  323. $errorMessage = $errorMessage."能量平台:".$v1->platform_name.$msg;
  324. $save_data = [];
  325. $save_data['process_status'] = 4; //下单失败
  326. $save_data['process_comments'] = $errorMessage; //处理备注
  327. $save_data['process_time'] = $time; //处理时间
  328. $save_data['energy_platform_rid'] = $v1->rid;
  329. $save_data['energy_package_rid'] = $res['rid'];
  330. $save_data['energy_platform_bot_rid'] = $v->energy_platform_bot_rid;
  331. EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  332. continue;
  333. }
  334. }
  335. }
  336. }else{
  337. $save_data = [];
  338. $save_data['process_status'] = 4; //下单失败
  339. $save_data['process_comments'] = "机器人无可用能量平台,请质押或者充值平台"; //处理备注
  340. $save_data['process_time'] = $time; //处理时间
  341. EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  342. }
  343. }
  344. }else{
  345. // $this->log('shanduibonus','----------没有数据----------');
  346. }
  347. }catch (\Exception $e){
  348. // $this->log('shanduibonus','----------任务执行报错,请联系管理员。报错原因:----------'.$e->getMessage());
  349. }
  350. //能量快捷余额购买
  351. try {
  352. $data = EnergyQuickOrder::from('energy_quick_order as a')
  353. ->join('energy_platform_bot as b','a.bot_rid','b.bot_rid')
  354. ->where('a.status',1)
  355. ->where('a.energy_amount','>',0)
  356. ->select('a.rid','a.wallet_addr','a.energy_amount','a.energy_day','b.poll_group','b.status','b.bot_rid','b.rid as energy_platform_bot_rid')
  357. ->limit(100)
  358. ->get();
  359. if($data->count() > 0){
  360. $time = nowDate();
  361. foreach ($data as $k => $v) {
  362. if($v->status == 1){
  363. $save_data = [];
  364. $save_data['status'] = 6; //能量钱包未启用
  365. $save_data['comments'] = '能量钱包未启用'; //处理备注
  366. $save_data['process_time'] = $time; //处理时间
  367. EnergyQuickOrder::where('rid',$v->rid)->update($save_data);
  368. continue;
  369. }
  370. $energy_amount = $v->energy_amount;
  371. //轮询,自己质押时判断能量是否足够,用平台则判断平台的trx
  372. $model = EnergyPlatform::where('poll_group',$v->poll_group)
  373. ->where('status',0)
  374. ->whereNotNull('platform_apikey')
  375. ->where(function ($query) use($energy_amount) {
  376. $query->where(function ($query1) use($energy_amount){
  377. $query1->where('platform_name', 3)->where('platform_balance', '>=', $energy_amount);
  378. });
  379. $query->orwhere(function ($query2) {
  380. $query2->orwhereIn('platform_name', [1,2,4,5,6])->where('platform_balance', '>', '0');
  381. });
  382. })
  383. ->orderBy('seq_sn','desc')
  384. ->get();
  385. if($model->count() > 0){
  386. $errorMessage = '';
  387. $rsa_services = new RsaServices();
  388. foreach ($model as $k1 => $v1){
  389. $signstr = $rsa_services->privateDecrypt($v1->platform_apikey);
  390. if(empty($signstr)){
  391. $errorMessage = $errorMessage."能量平台:".$v1->platform_name." 平台私钥为空。";
  392. $save_data = [];
  393. $save_data['status'] = 5; //下单失败
  394. $save_data['comments'] = $errorMessage; //处理备注
  395. $save_data['process_time'] = $time; //处理时间
  396. EnergyQuickOrder::where('rid',$v->rid)->update($save_data);
  397. continue;
  398. }
  399. $save_data = [];
  400. $save_data['status'] = 8; //下单中
  401. $save_data['comments'] = '下单中'; //处理备注
  402. $save_data['process_time'] = $time; //处理时间
  403. EnergyQuickOrder::where('rid',$v->rid)->update($save_data);
  404. $energy_day = $v->energy_day;
  405. //neee.cc平台
  406. if($v1->platform_name == 1){
  407. $header = [
  408. "Content-Type:application/json"
  409. ];
  410. $param = [
  411. "uid" => strval($v1->platform_uid),
  412. "resource_type" => "0", //0能量
  413. "receive_address" => $v->wallet_addr,
  414. "amount" => strval($energy_amount),
  415. "freeze_day" => strval($energy_day), //0:一小时,1:一天,3:三天
  416. "time" => strval(time())
  417. ];
  418. ksort($param);
  419. reset($param);
  420. foreach($param as $ka => $va){
  421. if($ka != "sign" && $ka != "sign_type" && $va!=''){
  422. $signstr .= $ka.$va;
  423. }
  424. }
  425. $sign = md5($signstr);
  426. $param['sign'] = $sign;
  427. $balance_url = 'https://api.tronqq.com/openapi/v2/order/submit';
  428. $dlres = Get_Pay($balance_url,json_encode($param),$header);
  429. }
  430. //RentEnergysBot平台
  431. elseif($v1->platform_name == 2){
  432. //0:一小时,1:一天,3:三天
  433. switch ($energy_day) {
  434. case 1:
  435. $type = 'day';
  436. break;
  437. case 3:
  438. $type = '3day';
  439. break;
  440. default:
  441. $type = 'hour';
  442. break;
  443. }
  444. //该平台最低33000
  445. $energy_amount = $energy_amount < 33000 ?33000:$energy_amount;
  446. $balance_url = 'https://api.wallet.buzz?api=getEnergy&apikey='.$signstr.'&address='.$v->wallet_addr.'&amount='.$energy_amount.'&type='.$type;
  447. $dlres = Get_Pay($balance_url);
  448. }
  449. //自己质押代理
  450. elseif($v1->platform_name == 3){
  451. $params = [
  452. 'pri' => $signstr,
  453. 'fromaddress' => $v1->platform_uid,
  454. 'receiveaddress' => $v->wallet_addr,
  455. 'resourcename' => 'ENERGY',
  456. 'resourceamount' => $energy_amount,
  457. 'resourcetype' => 1,
  458. 'permissionid' => $v1->permission_id
  459. ];
  460. $dlres = Get_Pay(base64_decode('aHR0cHM6Ly90cm9ud2Vibm9kZWpzLndhbGxldGltLnZpcC9kZWxlZ2VhbmR1bmRlbGV0ZQ=='),$params);
  461. }
  462. //trongas.io平台
  463. elseif($v1->platform_name == 4){
  464. //0:一小时,1:一天,3:三天
  465. switch ($energy_day) {
  466. case 1:
  467. $rentTime = 24;
  468. break;
  469. case 3:
  470. $rentTime = 72;
  471. break;
  472. default:
  473. $rentTime = 1;
  474. break;
  475. }
  476. $param = [
  477. "username" => $v1->platform_uid, // 用户名
  478. "password" => $signstr, // 用户密码
  479. "resType" => "ENERGY", // 资源类型,ENERGY:能量,BANDWIDTH:带宽
  480. "payNums" => $energy_amount, // 租用数量
  481. "rentTime" => $rentTime, // 单位小时,只能1时或1到30天按天租用其中不能租用2天
  482. "resLock" => 0, // 租用锁定,0:不锁定,1:锁定。能量租用数量不小于500万且租用时间不小于3天才能锁定。带宽租用数量不小于30万租用时间不小于3天才能锁定
  483. "receiveAddress" => $v->wallet_addr // 接收资源地址(请勿输入合约地址或没激活地址)
  484. ];
  485. $balance_url = 'https://trongas.io/api/pay';
  486. $dlres = Get_Pay($balance_url,$param);
  487. }
  488. //机器人开发代理
  489. elseif($v1->platform_name == 5){
  490. $balance_url = env('THIRD_URL');
  491. if(empty($balance_url)){
  492. $errorMessage = $errorMessage."使用开发者能量代理时,env中url为空";
  493. $save_data = [];
  494. $save_data['status'] = 4; //下单失败
  495. $save_data['process_time'] = $time; //处理时间
  496. $save_data['comments'] = $time.$errorMessage; //处理备注
  497. EnergyQuickOrder::where('rid',$v->rid)->update($save_data);
  498. continue;
  499. }
  500. //0:一小时,1:一天,3:三天
  501. switch ($energy_day) {
  502. case 1:
  503. $rentTime = 24;
  504. break;
  505. case 3:
  506. $rentTime = 72;
  507. break;
  508. default:
  509. $rentTime = 1;
  510. break;
  511. }
  512. //使用开发者能量代理,仅支持32000 65000能量代理1小时
  513. if($rentTime != 1){
  514. $errorMessage = $errorMessage."使用开发者能量代理时,时长只能为1小时";
  515. $save_data = [];
  516. $save_data['status'] = 4; //下单失败
  517. $save_data['process_time'] = $time; //处理时间
  518. $save_data['comments'] = $time.$errorMessage; //处理备注
  519. EnergyQuickOrder::where('rid',$v->rid)->update($save_data);
  520. continue;
  521. }
  522. $param = [
  523. "tg_uid" => $v1->platform_uid, // 用户名,此处是tg的uid,因为是机器人能量代理模式
  524. "payNums" => $energy_amount, // 租用数量
  525. "rentTime" => $rentTime, // 单位小时,只能1时或1到30天按天租用其中不能租用2天
  526. "receiveAddress" => $v->wallet_addr // 接收资源地址(请勿输入合约地址或没激活地址)
  527. ];
  528. $balance_url = $balance_url.'/api/thirdpart/shanzuorder';
  529. $dlres = Get_Pay($balance_url,$param);
  530. }
  531. // MeFree.NET 平台
  532. elseif($v1->platform_name == 6){
  533. // API 配置信息
  534. $base_url = "https://api.mefree.net"; // Mefree API 基础地址
  535. $api_key = $v1->platform_uid; // 替换为实际的 API Key
  536. $secret_key = $signstr; // 替换为实际的 Secret Key
  537. // 代理的周期,值可能为:0,1,2,3,4...30。其中0:速充;1:一小时;2:1天;3:3天;4:4天...最多30天。
  538. $period = 1;
  539. $tron_address = $v->wallet_addr ; // 接收资源地址(请勿输入合约地址或没激活地址)
  540. // 创建订单
  541. $request_path = "/api/order?quantity=$energy_amount&target_address=$tron_address&period=$period"; // API 请求路径
  542. $response = send_request("POST", $request_path, $base_url, $api_key, $secret_key);
  543. $dlres = $response['response']; // $dlres 为json格式,与其他统一共用
  544. }
  545. if(empty($dlres)){
  546. $errorMessage = $errorMessage."能量平台:".$v1->platform_name." 能量平台接口返回为空。";
  547. $save_data = [];
  548. $save_data['status'] = 4; //下单失败
  549. $save_data['comments'] = $errorMessage; //处理备注
  550. $save_data['process_time'] = $time; //处理时间
  551. EnergyQuickOrder::where('rid',$v->rid)->update($save_data);
  552. continue;
  553. }else{
  554. $dlres = json_decode($dlres,true);
  555. if(
  556. (isset($dlres['status']) && $dlres['status'] == 200 && $v1->platform_name == 1) ||
  557. (isset($dlres['status']) && $dlres['status'] == 'success' && $v1->platform_name == 2) ||
  558. (isset($dlres['code']) && $dlres['code'] == 200 && $v1->platform_name == 3) ||
  559. (isset($dlres['code']) && $dlres['code'] == 10000 && $v1->platform_name == 4) ||
  560. (isset($dlres['code']) && $dlres['code'] == 200 && $v1->platform_name == 5) ||
  561. (isset($response['status_code']) && $response['status_code'] == 200 && $v1->platform_name == 6)
  562. ){
  563. if($v1->platform_name == 1){
  564. $orderNo = $dlres['data']['order_no'];
  565. $use_trx = 0;
  566. }elseif($v1->platform_name == 2){
  567. $orderNo = $dlres['txid'];
  568. $use_trx = 0;
  569. }elseif($v1->platform_name == 3){
  570. $orderNo = $dlres['data']['txid'];
  571. $use_trx = $dlres['data']['use_trx'];
  572. }elseif($v1->platform_name == 4){
  573. $orderNo = $dlres['data']['orderId'];
  574. $use_trx = $dlres['data']['orderMoney'];
  575. }elseif($v1->platform_name == 5){
  576. $orderNo = $dlres['data']['orderId'];
  577. $use_trx = $dlres['data']['orderMoney'];
  578. }elseif($v1->platform_name == 6){
  579. $orderNo = $dlres['data']['client_order_id'];
  580. $use_trx = $dlres['data']['amount_sun'];
  581. }
  582. $insert_data = [];
  583. $insert_data['energy_platform_rid'] = $v1->rid;
  584. $insert_data['energy_platform_bot_rid'] = $v->energy_platform_bot_rid;
  585. $insert_data['platform_name'] = $v1->platform_name;
  586. $insert_data['platform_uid'] = $v1->platform_uid;
  587. $insert_data['receive_address'] = $v->wallet_addr;
  588. $insert_data['platform_order_id'] = $orderNo;
  589. $insert_data['energy_amount'] = $energy_amount;
  590. $insert_data['energy_day'] = $energy_day;
  591. $insert_data['energy_time'] = $time;
  592. $insert_data['source_type'] = 2; //自动下单
  593. $insert_data['recovery_status'] = $v1->platform_name == 3 ?2:1; //回收状态:1不用回收,2待回收,3已回收
  594. $insert_data['use_trx'] = $use_trx;
  595. $platform_order_rid = EnergyPlatformOrder::insertGetId($insert_data);
  596. $save_data = [];
  597. $save_data['status'] = 9; //下单成功
  598. $save_data['comments'] = 'SUCCESS'; //处理备注
  599. $save_data['process_time'] = $time; //处理时间
  600. $save_data['daili_time'] = $time; //代理时间
  601. $save_data['is_notice'] = 'Y'; //重新通知
  602. EnergyQuickOrder::where('rid',$v->rid)->update($save_data);
  603. break; //跳出不轮询了
  604. }else{
  605. if($v1->platform_name == 1){
  606. $msg = '下单失败,接口返回:'.$dlres['msg'];
  607. }elseif($v1->platform_name == 2){
  608. $msg = '下单失败,接口返回:'.json_encode($dlres);
  609. }elseif($v1->platform_name == 3){
  610. $msg = '下单失败,检查质押是否足够';
  611. }elseif($v1->platform_name == 4){
  612. $msg = ' 下单失败,接口返回:'.json_encode($dlres);
  613. }elseif($v1->platform_name == 5){
  614. $msg = ' 下单失败,接口返回:'.json_encode($dlres);
  615. }elseif($v1->platform_name == 6){
  616. $msg = ' 下单失败,接口返回:'.$response['response'];
  617. }
  618. $errorMessage = "能量平台:".$v1->platform_name.$msg;
  619. $save_data = [];
  620. $save_data['status'] = 4; //下单失败
  621. $save_data['comments'] = $errorMessage; //处理备注
  622. $save_data['process_time'] = $time; //处理时间
  623. EnergyQuickOrder::where('rid',$v->rid)->update($save_data);
  624. continue;
  625. }
  626. }
  627. }
  628. }else{
  629. $save_data = [];
  630. $save_data['status'] = 4; //下单失败
  631. $save_data['comments'] = "机器人无可用能量平台,请质押或者充值平台"; //处理备注
  632. $save_data['process_time'] = $time; //处理时间
  633. EnergyQuickOrder::where('rid',$v->rid)->update($save_data);
  634. }
  635. }
  636. }else{
  637. // $this->log('shanduibonus','----------没有数据----------');
  638. }
  639. }catch (\Exception $e){
  640. // $this->log('shanduibonus','----------任务执行报错,请联系管理员。报错原因:----------'.$e->getMessage());
  641. }
  642. //机器人开发代理-闪租下单
  643. try {
  644. $data = EnergyThirdPart::from('energy_third_part as a')
  645. ->join('energy_platform_bot as b','a.bot_rid','b.bot_rid')
  646. ->where('a.process_status',1)
  647. ->where('a.order_type',2)
  648. ->select('a.rid','a.wallet_addr','a.cishu_energy','b.poll_group','b.status','b.bot_rid','b.rid as energy_platform_bot_rid')
  649. ->limit(100)
  650. ->get();
  651. if($data->count() > 0){
  652. $time = nowDate();
  653. foreach ($data as $k => $v) {
  654. if($v->status == 1){
  655. $save_data = [];
  656. $save_data['process_status'] = 6; //能量钱包未启用
  657. $save_data['process_comments'] = '能量钱包未启用'; //处理备注
  658. $save_data['process_time'] = $time; //处理时间
  659. EnergyThirdPart::where('rid',$v->rid)->update($save_data);
  660. continue;
  661. }
  662. $energy_amount = $v->cishu_energy;
  663. //轮询,自己质押时判断能量是否足够,用平台则判断平台的trx
  664. $model = EnergyPlatform::where('poll_group',$v->poll_group)
  665. ->where('status',0)
  666. ->whereNotNull('platform_apikey')
  667. ->where(function ($query) use($energy_amount) {
  668. $query->where(function ($query1) use($energy_amount){
  669. $query1->where('platform_name', 3)->where('platform_balance', '>=', $energy_amount);
  670. });
  671. $query->orwhere(function ($query2) {
  672. $query2->orwhereIn('platform_name', [1,2,4])->where('platform_balance', '>', '0'); //这里不能有5这个平台
  673. });
  674. })
  675. ->orderBy('seq_sn','desc')
  676. ->get();
  677. if($model->count() > 0){
  678. $errorMessage = '';
  679. $rsa_services = new RsaServices();
  680. foreach ($model as $k1 => $v1){
  681. $signstr = $rsa_services->privateDecrypt($v1->platform_apikey);
  682. if(empty($signstr)){
  683. $errorMessage = $errorMessage."能量平台:".$v1->platform_name." 平台私钥为空。";
  684. $save_data = [];
  685. $save_data['process_status'] = 5; //下单失败
  686. $save_data['process_comments'] = $errorMessage; //处理备注
  687. $save_data['process_time'] = $time; //处理时间
  688. EnergyThirdPart::where('rid',$v->rid)->update($save_data);
  689. continue;
  690. }
  691. $save_data = [];
  692. $save_data['process_status'] = 8; //下单中
  693. $save_data['process_comments'] = '下单中'; //处理备注
  694. $save_data['process_time'] = $time; //处理时间
  695. EnergyThirdPart::where('rid',$v->rid)->update($save_data);
  696. $energy_day = 0; //该方式下单只能是1小时
  697. //neee.cc平台
  698. if($v1->platform_name == 1){
  699. $header = [
  700. "Content-Type:application/json"
  701. ];
  702. $param = [
  703. "uid" => strval($v1->platform_uid),
  704. "resource_type" => "0", //0能量
  705. "receive_address" => $v->wallet_addr,
  706. "amount" => strval($energy_amount),
  707. "freeze_day" => strval($energy_day), //0:一小时,1:一天,3:三天
  708. "time" => strval(time())
  709. ];
  710. ksort($param);
  711. reset($param);
  712. foreach($param as $ka => $va){
  713. if($ka != "sign" && $ka != "sign_type" && $va!=''){
  714. $signstr .= $ka.$va;
  715. }
  716. }
  717. $sign = md5($signstr);
  718. $param['sign'] = $sign;
  719. $balance_url = 'https://api.tronqq.com/openapi/v2/order/submit';
  720. $dlres = Get_Pay($balance_url,json_encode($param),$header);
  721. }
  722. //RentEnergysBot平台
  723. elseif($v1->platform_name == 2){
  724. //0:一小时,1:一天,3:三天
  725. switch ($energy_day) {
  726. case 1:
  727. $type = 'day';
  728. break;
  729. case 3:
  730. $type = '3day';
  731. break;
  732. default:
  733. $type = 'hour';
  734. break;
  735. }
  736. //该平台最低33000
  737. $energy_amount = $energy_amount < 33000 ?33000:$energy_amount;
  738. $balance_url = 'https://api.wallet.buzz?api=getEnergy&apikey='.$signstr.'&address='.$v->wallet_addr.'&amount='.$energy_amount.'&type='.$type;
  739. $dlres = Get_Pay($balance_url);
  740. }
  741. //自己质押代理
  742. elseif($v1->platform_name == 3){
  743. $params = [
  744. 'pri' => $signstr,
  745. 'fromaddress' => $v1->platform_uid,
  746. 'receiveaddress' => $v->wallet_addr,
  747. 'resourcename' => 'ENERGY',
  748. 'resourceamount' => $energy_amount,
  749. 'resourcetype' => 1,
  750. 'permissionid' => $v1->permission_id
  751. ];
  752. $dlres = Get_Pay(base64_decode('aHR0cHM6Ly90cm9ud2Vibm9kZWpzLndhbGxldGltLnZpcC9kZWxlZ2VhbmR1bmRlbGV0ZQ=='),$params);
  753. }
  754. //trongas.io平台
  755. elseif($v1->platform_name == 4){
  756. //0:一小时,1:一天,3:三天
  757. switch ($energy_day) {
  758. case 1:
  759. $rentTime = 24;
  760. break;
  761. case 3:
  762. $rentTime = 72;
  763. break;
  764. default:
  765. $rentTime = 1;
  766. break;
  767. }
  768. $param = [
  769. "username" => $v1->platform_uid, // 用户名
  770. "password" => $signstr, // 用户密码
  771. "resType" => "ENERGY", // 资源类型,ENERGY:能量,BANDWIDTH:带宽
  772. "payNums" => $energy_amount, // 租用数量
  773. "rentTime" => $rentTime, // 单位小时,只能1时或1到30天按天租用其中不能租用2天
  774. "resLock" => 0, // 租用锁定,0:不锁定,1:锁定。能量租用数量不小于500万且租用时间不小于3天才能锁定。带宽租用数量不小于30万租用时间不小于3天才能锁定
  775. "receiveAddress" => $v->wallet_addr // 接收资源地址(请勿输入合约地址或没激活地址)
  776. ];
  777. $balance_url = 'https://trongas.io/api/pay';
  778. $dlres = Get_Pay($balance_url,$param);
  779. }
  780. // MeFree.NET 平台
  781. elseif($v1->platform_name == 6){
  782. // API 配置信息
  783. $base_url = "https://api.mefree.net"; // Mefree API 基础地址
  784. $api_key = $v1->platform_uid; // 替换为实际的 API Key
  785. $secret_key = $v1->platform_apikey; // 替换为实际的 Secret Key
  786. // 代理的周期,值可能为:0,1,2,3,4...30。其中0:速充;1:一小时;2:1天;3:3天;4:4天...最多30天。
  787. $period = 1;
  788. $tron_address = $v->transferfrom_address ; // 接收资源地址(请勿输入合约地址或没激活地址)
  789. // 创建订单
  790. $request_path = "/api/order?quantity=$energy_amount&target_address=$tron_address&period=$period"; // API 请求路径
  791. $response = send_request("POST", $request_path, $base_url, $api_key, $secret_key);
  792. $dlres = $response;
  793. }
  794. if(empty($dlres)){
  795. $errorMessage = $errorMessage."能量平台:".$v1->platform_name." 能量平台接口返回为空。";
  796. $save_data = [];
  797. $save_data['process_status'] = 4; //下单失败
  798. $save_data['process_comments'] = $errorMessage; //处理备注
  799. $save_data['process_time'] = $time; //处理时间
  800. EnergyThirdPart::where('rid',$v->rid)->update($save_data);
  801. continue;
  802. }else{
  803. $dlres = json_decode($dlres,true);
  804. if(
  805. (isset($dlres['status']) && $dlres['status'] == 200 && $v1->platform_name == 1) ||
  806. (isset($dlres['status']) && $dlres['status'] == 'success' && $v1->platform_name == 2) ||
  807. (isset($dlres['code']) && $dlres['code'] == 200 && $v1->platform_name == 3) ||
  808. (isset($dlres['code']) && $dlres['code'] == 10000 && $v1->platform_name == 4) ||
  809. (isset($dlres['status_code']) && $dlres['status_code'] == 200 && $v1->platform_name == 6)
  810. ){
  811. if($v1->platform_name == 1){
  812. $orderNo = $dlres['data']['order_no'];
  813. $use_trx = 0;
  814. }elseif($v1->platform_name == 2){
  815. $orderNo = $dlres['txid'];
  816. $use_trx = 0;
  817. }elseif($v1->platform_name == 3){
  818. $orderNo = $dlres['data']['txid'];
  819. $use_trx = $dlres['data']['use_trx'];
  820. }elseif($v1->platform_name == 4){
  821. $orderNo = $dlres['data']['orderId'];
  822. $use_trx = $dlres['data']['orderMoney'];
  823. }elseif($v1->platform_name == 6){
  824. $orderNo = $dlres['data']['client_order_id'];
  825. $use_trx = $dlres['data']['amount_sun'];
  826. }
  827. $insert_data = [];
  828. $insert_data['energy_platform_rid'] = $v1->rid;
  829. $insert_data['energy_platform_bot_rid'] = $v->energy_platform_bot_rid;
  830. $insert_data['platform_name'] = $v1->platform_name;
  831. $insert_data['platform_uid'] = $v1->platform_uid;
  832. $insert_data['receive_address'] = $v->wallet_addr;
  833. $insert_data['platform_order_id'] = $orderNo;
  834. $insert_data['energy_amount'] = $energy_amount;
  835. $insert_data['energy_day'] = $energy_day;
  836. $insert_data['energy_time'] = $time;
  837. $insert_data['source_type'] = 2; //自动下单
  838. $insert_data['recovery_status'] = $v1->platform_name == 3 ?2:1; //回收状态:1不用回收,2待回收,3已回收
  839. $insert_data['use_trx'] = $use_trx;
  840. $platform_order_rid = EnergyPlatformOrder::insertGetId($insert_data);
  841. $save_data = [];
  842. $save_data['process_status'] = 9; //下单成功
  843. $save_data['process_comments'] = 'SUCCESS'; //处理备注
  844. $save_data['process_time'] = $time; //处理时间
  845. // $save_data['tg_notice_status_send'] = 'N'; //重新通知
  846. EnergyThirdPart::where('rid',$v->rid)->update($save_data);
  847. break; //跳出不轮询了
  848. }else{
  849. if($v1->platform_name == 1){
  850. $msg = '下单失败,接口返回:'.$dlres['msg'];
  851. }elseif($v1->platform_name == 2){
  852. $msg = '下单失败,接口返回:'.json_encode($dlres);
  853. }elseif($v1->platform_name == 3){
  854. $msg = '下单失败,检查质押是否足够';
  855. }elseif($v1->platform_name == 4){
  856. $msg = ' 下单失败,接口返回:'.json_encode($dlres);
  857. }elseif($v1->platform_name == 6){
  858. $msg = ' 下单失败,接口返回:'.json_encode($dlres);
  859. }
  860. $errorMessage = $errorMessage."能量平台:".$v1->platform_name.$msg;
  861. $save_data = [];
  862. $save_data['process_status'] = 4; //下单失败
  863. $save_data['process_comments'] = $errorMessage; //处理备注
  864. $save_data['process_time'] = $time; //处理时间
  865. EnergyThirdPart::where('rid',$v->rid)->update($save_data);
  866. continue;
  867. }
  868. }
  869. }
  870. }else{
  871. $save_data = [];
  872. $save_data['process_status'] = 4; //下单失败
  873. $save_data['process_comments'] = "机器人无可用能量平台,请质押或者充值平台"; //处理备注
  874. $save_data['process_time'] = $time; //处理时间
  875. EnergyThirdPart::where('rid',$v->rid)->update($save_data);
  876. }
  877. }
  878. }else{
  879. // $this->log('shanduibonus','----------没有数据----------');
  880. }
  881. }catch (\Exception $e){
  882. // $this->log('shanduibonus','----------任务执行报错,请联系管理员。报错原因:----------'.$e->getMessage());
  883. }
  884. //usdt笔数套餐
  885. try {
  886. $data = EnergyWalletTradeList::from('energy_wallet_trade_list as a')
  887. ->join('energy_platform_bot as b','a.transferto_address','b.receive_wallet')
  888. ->leftJoin('telegram_bot as c','b.bot_rid','c.rid')
  889. ->where('a.process_status',1)
  890. ->where('a.coin_name','usdt')
  891. ->select('a.rid','a.transferfrom_address','a.amount','b.bot_rid','b.per_bishu_usdt_price','b.tg_notice_obj_send','c.bot_token','c.bot_username','c.bot_admin_username')
  892. ->limit(100)
  893. ->get();
  894. if($data->count() > 0){
  895. $time = nowDate();
  896. foreach ($data as $k => $v) {
  897. //查询笔数套餐钱包是否存在
  898. $energyAiBishu = EnergyAiBishu::where('wallet_addr',$v->transferfrom_address)->first();
  899. if($energyAiBishu){
  900. $save_data = [];
  901. $save_data['total_buy_usdt'] = $energyAiBishu->total_buy_usdt + $v->amount;
  902. $save_data['max_buy_quantity'] = $energyAiBishu->max_buy_quantity + floor($v->amount / $v->per_bishu_usdt_price);
  903. EnergyAiBishu::where('rid',$energyAiBishu->rid)->update($save_data);
  904. }else{
  905. $insert_data = [];
  906. $insert_data['bot_rid'] = $v->bot_rid;
  907. $insert_data['wallet_addr'] = $v->transferfrom_address;
  908. $insert_data['status'] = 0;
  909. $insert_data['total_buy_usdt'] = $v->amount;
  910. $insert_data['max_buy_quantity'] = floor($v->amount / $v->per_bishu_usdt_price);
  911. $insert_data['create_time'] = $time;
  912. EnergyAiBishu::insert($insert_data);
  913. }
  914. $save_data = [];
  915. $save_data['process_status'] = 9; //下单成功
  916. $save_data['process_comments'] = "成功,笔数套餐增加:".floor($v->amount / $v->per_bishu_usdt_price); //处理备注
  917. $save_data['process_time'] = $time; //处理时间
  918. EnergyWalletTradeList::where('rid',$v->rid)->update($save_data);
  919. //通知到群
  920. if(!empty($v->tg_notice_obj_send) && $v->tg_notice_obj_send != ''){
  921. $replytext = "<b>✳️笔数套餐购买成功</b> \n"
  922. ."➖➖➖➖➖➖➖➖\n"
  923. ."<b>下单模式</b>:笔数套餐\n"
  924. ."<b>免费转账</b>:". floor($v->amount / $v->per_bishu_usdt_price) ." 次\n"
  925. ."<b>下单地址</b>:".mb_substr($v->transferfrom_address,0,8).'****'.mb_substr($v->transferfrom_address,-8,8) ."\n\n"
  926. ."<b>笔数套餐转账不扣TRX,智能监控地址补足能量</b>\n"
  927. ."发送 /buyenergy 继续购买能量!\n"
  928. ."➖➖➖➖➖➖➖➖";
  929. //内联按钮
  930. $keyboard = [
  931. 'inline_keyboard' => [
  932. [
  933. ['text' => '能量闪租', 'url' => 'https://t.me/'.$v->bot_username],
  934. ['text' => '笔数套餐', 'url' => 'https://t.me/'.$v->bot_username]
  935. ],
  936. [
  937. ['text' => '联系客服', 'url' => 'https://t.me/'.mb_substr($v->bot_admin_username,1)],
  938. ['text' => 'TRX闪兑', 'url' => 'https://t.me/'.$v->bot_username]
  939. ]
  940. ]
  941. ];
  942. $encodedKeyboard = json_encode($keyboard);
  943. $sendlist = explode(',',$v->tg_notice_obj_send);
  944. foreach ($sendlist as $x => $y) {
  945. $sendmessageurl = 'https://api.telegram.org/bot'.$v->bot_token.'/sendMessage?chat_id='.$y.'&text='.urlencode($replytext).'&parse_mode=HTML&reply_markup='.urlencode($encodedKeyboard);
  946. Get_Pay($sendmessageurl);
  947. }
  948. }
  949. }
  950. }else{
  951. // $this->log('shanduibonus','----------没有数据----------');
  952. }
  953. }catch (\Exception $e){
  954. // $this->log('shanduibonus','----------任务执行报错,请联系管理员。报错原因:----------'.$e->getMessage());
  955. }
  956. }
  957. /**
  958. * 记入日志
  959. * @param $log_title [日志路径]
  960. * @param $message [内容,不支持数组]
  961. * @param $remarks [备注]
  962. */
  963. protected function log($log_title,$message,$remarks='info'){
  964. Log::get($remarks,$log_title)->info($message);
  965. }
  966. }