package com.fs.erp.service.impl;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.fs.erp.dto.ErpShopResponse;
import com.fs.erp.service.IErpShopService;
import com.fs.erp.utils.CommonUtils;
import com.fs.his.config.FsSysConfig;
import com.fs.his.utils.ConfigUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 参数配置 服务层实现
 *

 */
    @Service
public class ErpShopServiceImpl implements IErpShopService
{

    @Autowired
    ConfigUtil configUtil;
    @Override
    public ErpShopResponse getShop(String code) {
        FsSysConfig sysConfig = configUtil.getSysConfig();
        JSONObject param = JSONUtil.createObj();
        param.set("appkey", sysConfig.getErpAppKey());
        param.set("sessionkey", sysConfig.getErpSessionKey());
        param.set("method", "gy.erp.shop.get");
        param.set("code", code);
        param.set("sign",CommonUtils.sign(param.toString(),sysConfig.getErpSecret()));
        String result = HttpUtil.post(sysConfig.getErpUrl(), param.toString());
        ErpShopResponse response=JSONUtil.toBean(result, ErpShopResponse.class);
        return response;
    }
}
