package com.kmall.api.api.quotalInquiry;

import com.alibaba.fastjson.JSONObject;
import com.kmall.api.annotation.LoginUser;
import com.kmall.api.entity.UserVo;
import com.kmall.api.service.quotalInquiry.ApiQuotalInquiryService;
import com.kmall.api.util.ApiBaseAction;
import com.kmall.manager.dto.CrossBoundaryQuotalDto;
import com.kmall.manager.dto.CrossQuotalInquiryResponseDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 跨境额度查询
 * @author huangyq
 * @version 1.0
 * 2019-12-17 15:35
 */
@RestController
@RequestMapping("/api/quotalInquiry")
public class CrossBoundaryQueryController extends ApiBaseAction {
    @Autowired
    private ApiQuotalInquiryService apiQuotalInquiryService;

    @PostMapping("getCrossBoundaryQuotaQuery")
    public Object getCrossBoundaryQuotaQuery(@LoginUser UserVo loginUser) {
        JSONObject json = this.getJsonRequest();
        CrossBoundaryQuotalDto crossBoundaryQuotalDto = new CrossBoundaryQuotalDto();
        crossBoundaryQuotalDto.setIdCard(json.getString("idCard"));
        crossBoundaryQuotalDto.setName(json.getString("name"));
        crossBoundaryQuotalDto.setMerchId(json.getString("merchId"));
        Long storeId = json.getLong("storeId");
        CrossQuotalInquiryResponseDto crossQuotalInquiryResponseDto = apiQuotalInquiryService.
                getCrossBoundaryQuotaQuery(crossBoundaryQuotalDto, storeId, getUserId());
        return toResponsSuccess(crossQuotalInquiryResponseDto);
    }
}
