| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\ProductOrder;
- use fast\Asset;
- use app\common\model\LedgerTeacChangeModel;
- use app\common\model\LedgerWalletModel;
- use app\common\model\UserPledge;
- use think\Db;
- /**
- * 首页接口
- */
- class Index extends Api
- {
- protected array $noNeedLogin = ['*'];
- private $loaded = false;
- private $data;
-
- //测试脚本
- public function task(UserPledge $userPledge, ProductOrder $productOrder, LedgerWalletModel $ledgerWalletModel) {
-
- //$rows = UserPledge::where('status', '=', 1)->select();
- $list = $userPledge::alias('a')
- ->join('product_pledge b', 'a.pledge_id = b.id', 'left')
- ->where('a.status', '>', 0)
- ->field('a.*,b.day_num')
- ->select();
- $i = 0;
- $time= time();
- $day = 86400;
- foreach ($list as $item) {
-
- //修改详情订单状态
- $detail = json_decode($item['details'], true);
- $productOrder::where('status', 6)->whereIn('id', array_column($detail, 'id'))->setField('status', ProductOrder::Paid);
- //更新存储订单状态
- $item->last_time = $time;
- $item->status = 0; //关闭
- $item->save();
- $i++;
- }
- $this->success('ok:'. $i);
- }
-
- //去掉重复订单
- public function removeOrder(ProductOrder $productOrder) {
-
- $i = 0;
- $rows = Db::name('product_order')->field('id,order_no,count(*) as count')->group('order_no')->having('count > 1')->limit(500)->select();
-
-
- foreach ($rows as $row) {
- $order = $productOrder::where('id', $row['id'])->order('id asc')->select();
- foreach ($order as $key => $vv) {
- if($key > 0){
- $vv->order_no = $row['order_no']. $key;
- $vv->save();
- $i++;
- }
- }
-
-
- }
- // 如果需要,可以在这里进行一些批量操作
-
- $this->success('ok:'. $i);
- }
-
- }
|