<?php

namespace app\product\controller;

use fastphp\base\Controller;
use app\product\model\ProductAccount as AccountModel;

class Account extends Controller
{
    public function updatePasswd(){
        $data = json_decode(file_get_contents("php://input"),true);
        if(!$data){
            die;
        }

        $where = [
            'ProductId' => $data['productId'],
            'DeleteTag' => 0,
            'Account' => ['IN', explode(',', $data['accounts'])]
        ];

        $account_model = new AccountModel;

        $account_model->updateOne($where, ['Pwd' => $data['pwd']]);

        if ($data['productId'] == 18) {
            $url = "http://rds-api.juip.com/api/agent/changeManyPasswd/accts/".$data['accounts'].'/pass/'.$data['pwd'];
        } elseif ($data['productId'] == 29) {
            $url = "http://124.236.113.166:18702/api/agent/changeManyPasswd/apikey/80cf4f64e990b78a9fc5eb/accts/".$data['accounts'].'/pass/'.$data['pwd'];
        } elseif ($data['productId'] == 3 || $data['productId'] == 26) {
            $url = "http://106.119.166.87:18702/api/agent/changeManyPasswd/apikey/80cf4f64e990b78a9fc5eb/accts/".$data['accounts'].'/pass/'.$data['pwd'];
        }
        linkcurl($url,'GET',[],[],0);
        echo  json_encode(['Code'=>10000,]);
    }
}
