var APIBase = require("../../api.base");
var system = require("../../../system");
const Client = require('aliyun-api-gateway').Client;
const client = new Client('203756933', '1hxwkxz2tyn80i3ucrdbchru59zpxibz');
class TradeTransferAPI extends APIBase {
    constructor() {
        super();
        this.tradetransferSve = system.getObject("service.transfer.tradetransferSve");
        this.notarizationflowSve = system.getObject("service.transfer.notarizationflowSve");

    }

    async acceptOrder(pobj, query) {
        pobj.channelParams.fq_ordernum = pobj.orderNo;
        return await this.tradetransferSve.createtransfer(pobj.channelParams);
    }
    async closeOrder(pobj, query) {
        return await this.tradetransferSve.orderclose(pobj);

    }
    async queryOrderState(pobj, query) {
        return await this.tradetransferSve.ordersel(pobj);
    }
    async queryOrder(pobj, query) {
        return await this.tradetransferSve.querytradeproducelist(pobj);
    }
    async selnotarytype(pobj, query) {
        return await this.notarizationflowSve.selnotarytype(pobj);
    }
    async writecommunicationlog(pobj, query) {
        return await this.tradetransferSve.writecommunicationlog(pobj);
    }

    async uppaymentstatus() {
        return await this.tradetransferSve.uppaymentstatus();
    }

    async m5(p) {
        var keys = p.keys(jsonObj).sort();
        if (keys.length == 0) {
            reqResult.code = -230;
            reqResult.msg = "请求参数信息为空";
            return reqResult;
        }
        for (let k = 0; k < keys.length; k++) {
            const tKey = keys[k];
            if (tKey != "sign" && jsonObj[tKey]) {
                signArr.push(tKey + "=" + jsonObj[tKey]);
            }
        }
        if (signArr.length == 0) {
            reqResult.code = -250;
            reqResult.msg = "请求组装签名参数信息为空";
            return reqResult;
        }
        signArr.push("key=" + pay_key);
        var signStr = signArr.join("&");
        // console.log(signStr, "，signStr.......................");
        var tmpSign = md5(signStr).toUpperCase();
        var signStr = "appid=00000051&body=sdfg&cusid=990581007426001&notify_url=dfgdsfgdf&randomstr=dfghrtjjn&reqsn=1564125456123&returl=sdsd154541&trxamt=100&version=12"
        var tmpSign = md5(signStr).toUpperCase();
        return tmpSign
    }
    async test(pobj, query) {
        var url = 'https://jaxiya.gongsibao.com/orders/refuse';

        var result = await client.post(url, {
            data: {
                "BizId": "trademark_prepayment_pre-cn-o401er9gv01",
                "UserName": "阿里云",
                "Mobile": "18600480430",
                "RegisterNumber": "25559504",
                "Classification": "20",
                "Price": "10"
            },
            headers: {
                accept: 'application/json'
            }
        });
        return result;
        console.log(JSON.stringify(result));
    }
    exam() {
        return "xxx";
    }
    classDesc() {
        return {
            groupName: "auth",
            groupDesc: "认证相关的包",
            name: "AccessAuthAPI",
            desc: "关于认证的类",
            exam: "",
        };
    }
    methodDescs() {
        return [
            {
                methodDesc: "生成访问token",
                methodName: "getAccessKey",
                paramdescs: [
                    {
                        paramDesc: "访问appkey",
                        paramName: "appkey",
                        paramType: "string",
                        defaultValue: "x",
                    },
                    {
                        paramDesc: "访问secret",
                        paramName: "secret",
                        paramType: "string",
                        defaultValue: null,
                    }
                ],
                rtnTypeDesc: "xxxx",
                rtnType: "xxx"
            }
        ];
    }
}
module.exports = TradeTransferAPI;