Test.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725
  1. <?php
  2. namespace app\api\controller;
  3. use app\api\logic\WelfareLoginc;
  4. use app\common\logic\BscApi;
  5. use app\common\logic\MyBscApi;
  6. use app\common\logic\TeamRewards;
  7. use app\common\model\AnnouncementModel;
  8. use app\common\model\LedgerSmhChangeModel;
  9. use app\common\model\LedgerUsdtChangeModel;
  10. use app\common\model\OfflineRechargeRecordModel;
  11. use app\api\logic\MarketLogic;
  12. use app\common\model\ParametersModel;
  13. use app\common\model\ProductOrder;
  14. use app\common\model\ProductsModel;
  15. use app\common\model\RwaExchangeRecordModel;
  16. use app\common\model\UserModel;
  17. use app\common\model\UserPathModel;
  18. use app\common\model\LedgerWalletModel;
  19. use app\common\model\ProductTransfer;
  20. use fast\Action;
  21. use fast\Asset;
  22. use fast\Http;
  23. use fast\RechargeStatus;
  24. use think\Db;
  25. use think\Exception;
  26. use think\Log;
  27. use think\Model;
  28. class Test
  29. {
  30. //取消寄售
  31. public function copy_user(ProductTransfer $productTransfer, ProductOrder $productOrder, MarketLogic $marketLogic)
  32. {
  33. $list = $productTransfer::where('status', ProductTransfer::Normal)->where('order_no', '')->select();
  34. $i = 0;
  35. foreach ($list as $item) {
  36. $check_pro = $productOrder
  37. ->where('id', $item['order_id'])
  38. ->find();
  39. if (!empty($check_pro)) {
  40. if($check_pro['type_id'] == 1 && $check_pro['status'] == 2){
  41. $i++;
  42. //取消转让订单
  43. $productOrder->where('id', $item['order_id'])->update(['status'=> 1]);
  44. //修改:类型状态
  45. $item->status = 0;
  46. $item->save();
  47. }elseif($check_pro['type_id'] == 1 && $check_pro['status'] == 4){
  48. //修改:类型状态
  49. $item->status = 0;
  50. $item->save();
  51. }
  52. else{
  53. dump('订单:' . $item['order_id'] . '的type_id为:' . $check_pro['type_id'] . ',status为:' . $check_pro['status']);
  54. }
  55. }else{
  56. dump('订单:' . $item['order_id'] . '无此订单');
  57. }
  58. }
  59. dump('完成了' . $i . '个订单');
  60. }
  61. /*
  62. * 更新上级
  63. */
  64. public function change_parent()
  65. {
  66. //1.从主表复制到备份表,需手动插入上级信息
  67. // dump('从主表复制到备份表');
  68. // $user_list = Db::name('user')
  69. // ->fetchSql(false)
  70. // ->field('u.*,p.distance')
  71. // ->alias('u')
  72. // ->join('user_path p', 'u.id = p.user_id')
  73. // ->where('p.parent_id', 101985)
  74. // //->where('u.id','>', 103931)
  75. // ->select();
  76. //
  77. // $i = 0;
  78. // foreach ($user_list as $user){
  79. // $is = Db::table('user_1')
  80. // ->insert($user);
  81. // $i++;
  82. // }
  83. // halt($i);
  84. //*2.更新备份表上级地址
  85. // dump('更新上级地址');
  86. // $user_list = Db::name('user_1')
  87. // ->whereNull('parent_address')
  88. // ->select();
  89. // $i = 0;
  90. // foreach ($user_list as $user){
  91. // $parent_info = (new UserModel())
  92. // ->where('id', $user['parent_id'])
  93. // ->find();
  94. // if(!empty($parent_info)){
  95. // $is = Db::table('user_1')
  96. // ->where('id', $user['id'])
  97. // ->update([
  98. // 'parent_address' => $parent_info['address']
  99. // ]);
  100. // $i++;
  101. // }
  102. // }
  103. // halt($i);
  104. //3.更新主表会员上级
  105. dump('重建网体');
  106. $user_list = Db::table('user_1')
  107. ->order('distance')
  108. ->select();
  109. $i = 0;
  110. foreach ($user_list as $user){
  111. $parent_info = (new UserModel())
  112. ->where('address', $user['parent_address'])
  113. ->find();
  114. if(!empty($parent_info)){
  115. $is = Db::table('user')
  116. ->where('id', $user['id'])
  117. ->update([
  118. 'parent_id' => $parent_info['id']
  119. ]);
  120. //删除网体
  121. (new UserPathModel())
  122. ->where('user_id', $user['id'])
  123. ->delete();
  124. // 创建网体
  125. (new UserPathModel())->createPath($user['id'], $parent_info['id']);
  126. $i++;
  127. } else{
  128. dump($user['id'] . '--无上级');
  129. }
  130. }
  131. halt($i);
  132. }
  133. /*
  134. * 更新上级
  135. *
  136. * 更改给定ID的上级,并把它的直推一并更改
  137. */
  138. public function resetParent()
  139. {
  140. //3.更新主表会员上级
  141. dump('重建网体');
  142. $parent_id = 100100;
  143. $user_id = 101134;
  144. $user = (new UserModel())
  145. ->fetchSql(false)
  146. ->where('id', $user_id)
  147. ->update([
  148. 'parent_id' => $parent_id
  149. ]);
  150. dump($user, true, '更新状态');
  151. //删除网体
  152. (new UserPathModel())
  153. ->where('user_id', $user_id)
  154. ->delete();
  155. // 创建网体
  156. (new UserPathModel())->createPath($user_id, $parent_id);
  157. $user_list = (new UserModel())
  158. ->where('parent_id', $user_id)
  159. ->select();
  160. $i = 0;
  161. foreach ($user_list as $user){
  162. //删除网体
  163. (new UserPathModel())
  164. ->where('user_id', $user['id'])
  165. ->delete();
  166. // 创建网体
  167. (new UserPathModel())->createPath($user['id'], $user['parent_id']);
  168. $i++;
  169. }
  170. halt($i);
  171. }
  172. /**
  173. 导入数据表生成 sql
  174. CREATE TABLE dao_ru AS SELECT
  175. u.id,
  176. u.parent_id,
  177. u.address,
  178. u.team_power,
  179. u.team_num,
  180. w.power,
  181. w.rental_power,
  182. w.usdt
  183. FROM
  184. `user` u
  185. LEFT JOIN ledger_wallet w ON u.id = w.user_id
  186. WHERE
  187. id IN ( SELECT user_id FROM `user_path` WHERE parent_id = 1012 )
  188. OR id = 1012
  189. ORDER BY
  190. id
  191. */
  192. public function daoru()
  193. {
  194. die;
  195. $daoru_list = Db::table('user_base')
  196. //->where('is_dao', 1)
  197. ->select();
  198. $i = 0;
  199. $j = 0;
  200. //重建钱包
  201. foreach ($daoru_list as $key => $info) {
  202. $user = (new UserModel())->getByAddress($info['address']);
  203. if (!empty($user)) { // 已存在
  204. // 更新总算力和账变
  205. (new LedgerWalletModel)->changeWalletAccount($user['id'], Asset::POWER, $info['power'], Action::Reversal, 0);
  206. // 更新自己(有效会员时间)和所有上级的信息(有效直推人数和团队总算力)
  207. (new UserModel())->updateForRental($user['id'], $info['power']);
  208. $j++;
  209. continue;
  210. }
  211. }
  212. //重建用户
  213. // foreach ($daoru_list as $key => $info) {
  214. //
  215. // $parent_user = (new UserModel())->getByAddress($info['parent_address']);
  216. // if(empty($parent_user)){
  217. // dump('没有上级');
  218. // dump($info);
  219. // continue;
  220. // }
  221. //
  222. // $user = (new UserModel())->getByAddress($info['address']);
  223. // if (!empty($user)) { // 已存在
  224. // dump($info['id'] . ' - ' . $info['address'] . ' - 已存在');
  225. //
  226. // $is = Db::table('user')
  227. // ->where('id', $user['id'])
  228. // ->update([
  229. // 'parent_id' => $parent_user['id']
  230. // ]);
  231. // $j++;
  232. // continue;
  233. // }
  234. //
  235. // unset($info['id']);
  236. // unset($info['parent_address']);
  237. // unset($info['is_dao']);
  238. // $info['parent_id'] = $parent_user['id'];
  239. // // 创建用户
  240. // $newUserID = (new UserModel())->insertGetId($info);
  241. // // 创建钱包
  242. // (new LedgerWalletModel())->insertGetId([
  243. // 'user_id' => $newUserID,
  244. // ]);
  245. //
  246. // // 创建网体
  247. // (new UserPathModel())->createPath($newUserID, $parent_user['id']);
  248. //
  249. // $i++;
  250. //
  251. // }
  252. dump($i);
  253. dump($j);
  254. }
  255. public function updaetWallet()
  256. {
  257. $daoru_list = Db::table('ledger_wallet_1')
  258. ->whereNotNull('address')
  259. ->select();
  260. $i = 0;
  261. foreach ($daoru_list as $key => $info) {
  262. dump($info);
  263. $user = (new UserModel())->getByAddress($info['address']);
  264. if (empty($user)) {
  265. dump($info['user_id'] . ' - ' . $info['address'] . ' - 不存在');
  266. continue;
  267. }
  268. unset($info['user_id']);
  269. unset($info['address']);
  270. //更新钱包
  271. $is_up = (new LedgerWalletModel())
  272. ->where('user_id', $user['id'])
  273. ->update($info);
  274. dump($user['id'] . '更新' . $is_up);
  275. $i++;
  276. }
  277. dump($i);
  278. }
  279. /**
  280. * 手段向某会员报单算力
  281. * @return void
  282. * @throws \think\db\exception\DataNotFoundException
  283. * @throws \think\db\exception\ModelNotFoundException
  284. * @throws \think\exception\DbException
  285. */
  286. public function updateOrder()
  287. {
  288. //算力租赁订单处理
  289. // 查询兑换比例
  290. $usdtToPower = (new ParametersModel)->getValue('usdtToPowerRate');
  291. $usdtToPowerFloat = floatval($usdtToPower);
  292. if (is_null($usdtToPower) || $usdtToPowerFloat <= 0) {
  293. return '获取USDT兑换算力的比例失败';
  294. }
  295. $orderInfo = (new OfflineRechargeRecordModel())
  296. ->where('id', 4)
  297. ->find();
  298. if(empty($orderInfo)){
  299. halt('订单信息不存在');
  300. }
  301. $uid = $orderInfo['user_id'];
  302. $fee = $orderInfo['amount'];
  303. $power = bcmul($fee, $usdtToPowerFloat, 6); // 该用户兑得的算力
  304. // 启动事务
  305. Db::startTrans();
  306. try {
  307. // 更新总算力和账变
  308. (new LedgerWalletModel)->changeWalletAccount($uid, Asset::POWER, $power, Action::PowerRentalPower, $orderInfo['id']);
  309. // 更新服务器算力,不账变
  310. (new LedgerWalletModel)->changeWalletOnly($uid, Asset::RENTAL_POWER, $power);
  311. // 更新自己(有效会员时间)和所有上级的信息(有效直推人数和团队总算力)
  312. (new UserModel())->updateForRental($uid, $power);
  313. // 发放直推USDT收益
  314. (new LedgerWalletModel)->sendUsdtProfit($uid, $fee);
  315. // 发放直推算力收益
  316. (new LedgerWalletModel)->sendDirectProfit($uid, $power);
  317. // 发代数收益
  318. (new LedgerWalletModel)->sendGenerateProfit($uid, $fee);
  319. // 发放见点奖
  320. (new LedgerWalletModel)->sendRegBonus($uid, $fee);
  321. // 更新购买(充值)记录
  322. (new OfflineRechargeRecordModel())->updateOrderStatus($orderInfo['id'], RechargeStatus::StatusAuthSuccess, 0, $power);
  323. // 提交事务
  324. Db::commit();
  325. } catch (Exception $e) {
  326. // 回滚事务
  327. Db::rollback();
  328. return $e->getMessage();
  329. }
  330. }
  331. //重算团队业绩和直推人数
  332. public function reset_team()
  333. {
  334. set_time_limit(0);
  335. //先清空
  336. $update = Db::table('user')
  337. ->where('id', '>', 0)
  338. ->update([
  339. 'team_power' => 0,
  340. 'team_num' => 0,
  341. 'direct_num' => 0
  342. ]);
  343. $up_power = Db::table('ledger_wallet')
  344. ->field('u.id')
  345. ->alias('w')
  346. ->join('user u', 'w.user_id = u.id')
  347. ->where('u.effective_time','>',0)
  348. ->where('w.rental_power', 0)
  349. ->select();
  350. foreach ($up_power as $item){
  351. $update = Db::table('ledger_wallet')
  352. ->where('user_id', $item['id'])
  353. ->update([
  354. 'rental_power' => 0.01
  355. ]);
  356. }
  357. $power_list = Db::table('ledger_wallet')
  358. ->where('rental_power', '>', 0)
  359. ->select();
  360. $info_list = 0;
  361. $bad_list = [];
  362. foreach ($power_list as $key => $info) {
  363. dump('正在处理ID:' . $info['user_id']);
  364. $parent_ids = (new UserPathModel())
  365. ->where('user_id',$info['user_id'])
  366. ->order('distance')
  367. ->select();
  368. foreach ($parent_ids as $item) {
  369. $data = [
  370. 'team_power' => Db::raw('team_power + ' . $info['rental_power']),
  371. 'team_num' => Db::raw('team_num + 1'),
  372. ];
  373. if ($item['distance'] == 1) {
  374. $data['direct_num'] = Db::raw('direct_num+1');
  375. }
  376. $update = Db::table('user')
  377. ->where('id', $item['parent_id'])
  378. ->update($data);
  379. if (!$update) {
  380. $bad_list[] = $info;
  381. } else {
  382. $info_list++;
  383. }
  384. }
  385. }
  386. dump('成功数量');
  387. dump($info_list);
  388. dump('失败数量');
  389. dump($bad_list);
  390. }
  391. //累加新增团队业绩
  392. public function addTeamPower()
  393. {
  394. set_time_limit(0);
  395. $uid = 100702;
  396. $num = 1429;
  397. $parentIDs = (new UserPathModel())->getAllParentIDs($uid);
  398. $parentIDs[] = $uid;
  399. dump($parentIDs, true, 'ID列表');
  400. $update = (new UserModel())
  401. ->where('id', 'in', $parentIDs)
  402. ->update([
  403. 'team_power' => Db::raw('team_power + ' . $num)
  404. ]);
  405. dump($update, true, '影响行数');
  406. }
  407. public function resetUserPath()
  408. {
  409. $ratio = 0.05;//直推奖励
  410. $info_list = (new OfflineRechargeRecordModel())
  411. ->where('status', OfflineRechargeRecordModel::StatusFail)
  412. ->order('id', 'ASC')
  413. ->select();
  414. dump('本次数据共有:' . count($info_list));
  415. foreach ($info_list as $info) {
  416. $user = (new UserModel())->get($info['user_id']);
  417. if (empty($user) || $user['parent_id'] == 0) {
  418. continue;
  419. }
  420. $check = (new LedgerUsdtChangeModel())
  421. ->where('user_id', $user['parent_id'])
  422. ->where('action', Action::UsdtShareBonus)
  423. ->where('from_id', $info['user_id'])
  424. ->count();
  425. if($check == 0){
  426. (new LedgerWalletModel())->changeWalletAccount($user['parent_id'], Asset::USDT, $info['amount'] * $ratio, Action::UsdtShareBonus, $info['user_id']);
  427. dump('订单ID:' . $info['id'] . '处理成功,奖金:' . $info['amount'] * $ratio);
  428. }else{
  429. dump('订单ID:' . $info['id'] . '处理失败,奖金已存在');
  430. }
  431. }
  432. }
  433. /**
  434. * 补发直推奖
  435. * @return void
  436. */
  437. public function resetShareBonus()
  438. {
  439. $users = (new UserModel())->order('id', 'ASC')->select();
  440. foreach ($users as $v) {
  441. (new UserPathModel())->createPath($v['id'], $v['parent_id']);
  442. }
  443. }
  444. /**
  445. * @return string
  446. *
  447. * 返回结果
  448. * {
  449. "status": "1",
  450. "message": "OK",
  451. "result": {
  452. "status": "1"
  453. }
  454. }
  455. */
  456. public function getStatusByHaxh()
  457. {
  458. $url = "https://api.bscscan.com/api?module=transaction&action=gettxreceiptstatus&txhash=0x30f4190a8237c7744a0981a2895728bab93acf4cb78b03c192ed5ac387405c54&apikey=VTCKIP346DCRWB6JNS4KDANUJJEQN9VAKW";
  459. $body = Http::get($url);
  460. if (empty($body)) {
  461. return "api返回内容为空";
  462. }
  463. dump($body);
  464. // 转成数组
  465. $rsArr = json_decode($body, true);
  466. dump($rsArr);
  467. if (empty($rsArr) || !is_array($rsArr)) {
  468. return "状态api返回数据异常";
  469. }
  470. if ($rsArr['status'] != '1') {
  471. return '状态api返回status不为1,错误信息:' . $rsArr['message'];
  472. }
  473. if ($rsArr['result']['status'] != 1) {
  474. return '状态api返回result中的status不为1,错误信息:' . $rsArr['message'];
  475. }
  476. }
  477. public function AllocateEtc()
  478. {
  479. $url = "https://www.binance.com/api/v1/klines?symbol=ETCUSDT&limit=1&interval=3m";
  480. $body = Http::get($url);
  481. if (empty($body)) {
  482. return "api返回内容为空";
  483. }
  484. dump($body);
  485. // 转成数组
  486. $rsArr = json_decode($body, true);
  487. dump($rsArr[0][2]);
  488. $body = Http::get($url);
  489. if (empty($body)) {
  490. return "api返回内容为空";
  491. }
  492. dump($body);
  493. // 转成数组
  494. $rsArr = json_decode($body, true);
  495. dump($rsArr);
  496. if (empty($rsArr) || !is_array($rsArr)) {
  497. return "状态api返回数据异常";
  498. }
  499. if ($rsArr['status'] != '1') {
  500. return '状态api返回status不为1,错误信息:' . $rsArr['message'];
  501. }
  502. if ($rsArr['result']['status'] != 1) {
  503. return '状态api返回result中的status不为1,错误信息:' . $rsArr['message'];
  504. }
  505. }
  506. public function debug()
  507. {
  508. $coin = $this->request->post('coin'); // 代币
  509. $coin_from_address = $this->request->post('coin_from_address'); // 代码转入地址
  510. $usdt_from_address = $this->request->post('usdt_from_address'); // U转入地址
  511. if (empty($coin) || empty($coin_from_address) || empty($usdt_from_address)) {
  512. $this->error(__('Parameter error'));
  513. }
  514. //检查区块链地址是否合法
  515. if(!(isErc20AddressValid($coin_from_address) && isErc20AddressValid($usdt_from_address))){
  516. $this->error(__('Invalid parameters'));
  517. }
  518. $welfare_config = config('welfare_rede');
  519. if (!in_array($coin, $welfare_config['welfare_rede']['currency'])) {
  520. $this->error(__('Invalid parameters'));
  521. }
  522. $BscApi = new BscApi($welfare_config['welfare_rede']['contract_address'][$coin]);
  523. $result_coin = $BscApi->getTransactionRecordsByAddress($coin_from_address, $welfare_config['welfare_rede']['transfer_address'], 49990000);
  524. if ($result_coin['code'] == 0) {
  525. $this->error($result_coin['msg']);
  526. }
  527. $coin_list = [];
  528. foreach ($result_coin['data'] as $value) {
  529. if ($value['amount'] == $welfare_config['welfare_rede']['currency_price'][$coin]) {
  530. $coin_list[] = $value;
  531. }
  532. }
  533. if (empty($coin_list)) {
  534. $this->error('未识别到代币转入记录');
  535. }
  536. $coin_data = [];
  537. foreach ($coin_list as $item) {
  538. $check_info = (new RwaExchangeRecordModel())->where('tx_hash', $item['hash'])->find();
  539. if (empty($check_info)) {
  540. $coin_data = $item;
  541. break;
  542. }
  543. }
  544. if (empty($coin_data)) {
  545. $this->error('未识别到新代币转入记录');
  546. }
  547. $BscApi = new BscApi($welfare_config['welfare_rede']['contract_address']['USDT']);
  548. $result_usdt = $BscApi->getTransactionRecordsByAddress($usdt_from_address, $welfare_config['welfare_rede']['transfer_address'], 49990000);
  549. if ($result_usdt['code'] == 0) {
  550. $this->error($result_usdt['msg']);
  551. }
  552. $usdt_list = [];
  553. foreach ($usdt_list['data'] as $value) {
  554. if ($value['amount'] == $welfare_config['welfare_rede']['currency_price']['USDT']) {
  555. $usdt_list[] = $value;
  556. }
  557. }
  558. if (empty($usdt_list)) {
  559. $this->error('未识别到USDT转入记录');
  560. }
  561. $usdt_data = [];
  562. foreach ($usdt_list as $item) {
  563. $check_info = (new RwaExchangeRecordModel())->where('tx_hash', $item['hash'])->find();
  564. if (empty($check_info)) {
  565. $usdt_data = $item;
  566. break;
  567. }
  568. }
  569. if (empty($usdt_data)) {
  570. $this->error('未识别到新USDT转入记录');
  571. }
  572. $order_no = date('YmdHis') . rand(1000, 9999);
  573. $inster_data = [
  574. [
  575. 'order_no' => $order_no,
  576. 'tx_hash' => $coin_data['hash'],
  577. 'user_id' => $this->auth->id,
  578. 'symbol' => $coin,
  579. 'amount' => $coin_data['amount'],
  580. 'product_id' => $welfare_config['welfare_rede']['product_id'],
  581. 'from_address' => $coin_data['from'],
  582. 'to_address' => $coin_data['to'],
  583. 'status' => 200,
  584. 'create_time' => time(),
  585. ],
  586. [
  587. 'order_no' => $order_no,
  588. 'tx_hash' => $usdt_data['hash'],
  589. 'user_id' => $this->auth->id,
  590. 'symbol' => 'USDT',
  591. 'amount' => $usdt_data['amount'],
  592. 'product_id' => $welfare_config['welfare_rede']['product_id'],
  593. 'from_address' => $usdt_data['from'],
  594. 'to_address' => $usdt_data['to'],
  595. 'status' => 200,
  596. 'create_time' => time(),
  597. ]
  598. ];
  599. $product_id = $welfare_config['welfare_rede']['product_id'];
  600. $product_info = (new ProductsModel())->where('id', $product_id)->find();
  601. if (empty($product_info)) {
  602. $this->error('产品不存在');
  603. }
  604. try {
  605. Db::startTrans();
  606. (new RwaExchangeRecordModel())->saveAll($inster_data);
  607. $rs = WelfareLoginc::setUserProductOrder(1, false, $order_no, $product_info['price'], $product_info['product_id'], $this->auth->id, ProductOrder::Exchange);
  608. if($rs && $product_info['price'] >= config('min_rwa_price')){
  609. (new UserModel())->updateForRwaNum($this->auth->id, UserModel::getByParentId($user_id), 1, '+');
  610. }
  611. Db::commit();
  612. $this->success('ok', $order_no);
  613. } catch (Exception $e) {
  614. Db::rollback();
  615. $this->error($e->getMessage(), null, $e->getCode());
  616. }
  617. }
  618. public function resetAirdrop()
  619. {
  620. $order_list = (new ProductOrder())
  621. ->where('type_id', 3)
  622. ->group('user_id')
  623. ->column('user_id');
  624. dump($order_list);
  625. $order_list_send = (new ProductOrder())
  626. ->where('type_id', 4)
  627. ->group('user_id')
  628. ->column('user_id');
  629. dump($order_list_send);
  630. $order_list = array_diff($order_list, $order_list_send);
  631. dump($order_list);
  632. $rs = (new ProductOrder())
  633. ->where('type_id', 3)
  634. ->where('user_id', 'in', $order_list)
  635. ->update([
  636. 'create_time' => 1745942400
  637. ]);
  638. dump($rs);
  639. }
  640. public function updateNews()
  641. {
  642. $en_news = DB::name('announcement_cope')->select();
  643. foreach ($en_news as $info) {
  644. if(strlen($info['en_title']) > 3){
  645. $rs = (new AnnouncementModel())
  646. ->save([
  647. 'type_id' => $info['type_id'],
  648. 'title' => $info['en_body'],
  649. 'introduction' => $info['en_introduction'],
  650. 'body' => $info['en_body'],
  651. 'img_url' => $info['img_url'],
  652. 'to_lang' => 1,
  653. 'status' => $info['status'],
  654. 'created_by' => $info['created_by'],
  655. 'createtime' => $info['createtime'],
  656. ]);
  657. }
  658. }
  659. dump($rs);
  660. }
  661. }