Test.php 23 KB

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