ImportChannel.php 1.4 KB
<?php
/**
 * @remark :
 * @name   :ImportChannel.php
 * @author :lyh
 * @method :post
 * @time   :2023/9/25 15:31
 */

namespace App\Console\Commands;
use App\Helper\OaGlobalsoApi;
use App\Models\Channel\Channel;
use App\Models\Project\Project;
use Illuminate\Console\Command;
class ImportChannel extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'import_channel';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '更新渠道信息';

    /**
     * @remark :导入5.0管理员数据
     * @name   :handle
     * @author :lyh
     * @method :post
     * @time   :2023/8/7 17:49
     */
    public function handle(){
        $projectModel = new Project();
        $map = [
            'channel'=>['like','%"user_id": "0"%'],
        ];
        $lists = $projectModel->list($map);
//        var_dump($lists);
//        die();
        foreach ($lists as $k => $v){
            $order_id = $v['notice_order_id'];
            $api = new OaGlobalsoApi();
            $data = $api->order_info($order_id);
            $data = $data['data'];
            $channel = Channel::getProjectChannel($data['company_id'], $data['username_sales']);
            $projectModel->edit(['channel'=>$channel],['id'=>$v['id']]);
        }
        return 1;
    }
}