<?php

namespace app\jinyou\controller;

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

class Jinyoudt extends Controller
{
    public function openTxLimit(){
        $data = json_decode(file_get_contents("php://input"),true);
        if(!$data){
            die;
        }
        $where = [
            'ProductId' => $data['productId'],
            'DeleteTag' => 0,
            'Account' => $data['account']
        ];

        $account_model = new AccountModel;

        $im_now = $account_model->getOne($where);

        $im = 1;
        if ($im_now['im']) {
            $im = 0;
        }

        $account_model->updateOne($where, ['im' => $im]);
        
        $jinyou = new Jinyou();
        $status = $jinyou::openTxLimit($data['account']);
        echo  json_encode(['Code'=>30000,]);
    }
}