package com.cweb.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.BsCompany;
import com.hai.entity.HighAgent;
import com.hai.entity.OutRechargePrice;
import com.hai.entity.SecRegion;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.BsCompanyService;
import com.hai.service.CommonService;
import com.hai.service.OutRechargePriceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
    @RequestMapping(value = "/outRechargePrice")
@Api(value = "查询充值金额接口")
public class OutRechargePriceController {

    private static Logger log = LoggerFactory.getLogger(HighMerchantStoreController.class);

    @Autowired
    private UserCenter userCenter;

    @Resource
    private OutRechargePriceService outRechargePriceService;

    @Resource
    private BsCompanyService bsCompanyService;

    @Resource
    private CommonService commonService;

    @RequestMapping(value = "/getListOutRechargePrice", method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "查询充值金额列表")
    public ResponseData getListOutRechargePrice(
            @RequestParam(value = "type", required = false) Integer type,
            @RequestParam(name = "regionId", required = true) String regionId,
            @RequestParam(name = "showType", required = true) Integer showType,
            @RequestParam(name = "rechargeType", required = false) Integer rechargeType
    ) {
        try {
            Map<String, String> map = new HashMap<>();

            SecRegion region = commonService.getParentByRegion(Long.parseLong(regionId));
            if (region != null) {
                BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString());
                map.put("companyId", String.valueOf(bsCompany.getId()));
            }

            if (showType != null ) {
                map.put("showType", String.valueOf(showType));
            }

            if (rechargeType != null ) {
                map.put("rechargeType", String.valueOf(rechargeType));
            }

            if (type != null ) {
                map.put("type", String.valueOf(type));
            }

            return   ResponseMsgUtil.success( outRechargePriceService.getListRechargePriceC(map));
        } catch (Exception e) {
            log.error("OutRechargePriceController --> getListUser() error!", e);
            return ResponseMsgUtil.exception(e);
        }
    }


}
