package com.fs.erp.service.impl;

import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.fs.common.annotation.DataSource;
import com.fs.common.config.FSSysConfig;
import com.fs.common.constant.Constants;
import com.fs.common.constant.UserConstants;
import com.fs.common.core.domain.R;
import com.fs.common.core.redis.RedisCache;
import com.fs.common.core.text.Convert;
import com.fs.common.enums.DataSourceType;
import com.fs.common.exception.CustomException;
import com.fs.common.utils.StringUtils;
import com.fs.erp.dto.ErpShopResponse;
import com.fs.erp.service.IErpShopService;
import com.fs.erp.utils.CommonUtils;
import com.fs.system.domain.SysConfig;
import com.fs.system.mapper.SysConfigMapper;
import com.fs.system.service.ISysConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.Collection;
import java.util.List;

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

 */
    @Service
public class ErpShopServiceImpl implements IErpShopService
{

    @Autowired
    FSSysConfig sysConfig;
    @Override
    public ErpShopResponse getShop(String code) {
        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;
    }
}
