package com.clx.performance.controller.thirdparty;

import com.alibaba.fastjson.JSON;
import com.nbopen.api.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping(value="/nbbank")
@Api(tags = "宁波银行回调")
public class NbBankController {

    @ApiOperation(value = "notify", notes = "<br>By:艾庆国")
    @RequestMapping(value = "/notify", method = RequestMethod.POST)
    public void bankNotify(String message) throws Exception {
        log.info("宁波银行回调, data:{}", message);

        RequestApiData requestApiData = new RequestApiData();
        requestApiData.setAppkey("77667c76_3503_4c04_95f7_fc10938c7942");
        requestApiData.setData(message);

        RequestHead requestHead = new RequestHead();
        requestHead.setRqsJrnlNo(NBOpenSDK.getRandom());

        SDKRequest request = new SDKRequest();
        request.setData(requestApiData);
        request.setHead(requestHead);

        System.out.println("SDK请求内容: "+ JSON.toJSONString(request));
        SDKResponse result = NBOpenSDK.decryptMessage(request);
        System.out.println("SDK响应结果: "+JSON.toJSONString(result));



//        HashMap hashMap = new HashMap();
//        hashMap.put("errorCode", "000000");
//        hashMap.put("errorMsg", "000000");


    }

}
