Test.php 23 KB

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