package org.dromara.payment.sys.controller;

import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.payment.merchant.domain.vo.BusMerchantVo;
import org.dromara.payment.sys.domain.bo.ProInfoCommonBo;
import org.dromara.payment.sys.domain.vo.ProInfoCommonVo;
import org.dromara.payment.sys.domain.vo.SysSydVo;
import org.dromara.payment.sys.service.IProInfoCommonService;
import org.dromara.system.api.domain.vo.RemoteDictDataVo;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author sunzexing
 * @version 1.0
 * @title ProInfoCommonController
 * @description
 * @create 2024-04-24 17:42
 */

@Validated
@RequiredArgsConstructor
@RestController
@RequestMapping("/proInfo")
public class ProInfoCommonController extends BaseController {


    @Resource
    private IProInfoCommonService  commonService;


    /**
     * 查询不同角色-产品列表
     */
//    @SaCheckPermission("payment:proInfo:list")
    @GetMapping("/list")
    @Log(title = "查询不同角色-产品列表", businessType = BusinessType.OTHER)
    public TableDataInfo<ProInfoCommonVo> list(ProInfoCommonBo bo, PageQuery pageQuery) {
        return commonService.queryPageList(bo, pageQuery);
    }

    /**
     * 查询不同角色-企业列表
     */
//    @SaCheckPermission("payment:proInfo:list")
    @GetMapping("/listMer")
    @Log(title = "查询不同角色-企业列表", businessType = BusinessType.OTHER)
    public R<List<BusMerchantVo>> listMer(ProInfoCommonBo bo) {
        return R.ok(commonService.selectMerchantList(bo));
    }





    @GetMapping("/listServ")
    @Log(title = "根据企业查询对应的服务商", businessType = BusinessType.OTHER)
    public R<List<SysSydVo>>  selServiceInfoByMerInfo(BusMerchantVo merchantVo){
        return R.ok(commonService.selectServiceInfoByMerInfo(merchantVo));
    }



    /***
     * 查询不同角色的业务类型
     * @return
     */
    @GetMapping("/selBusType")
    @Log(title = "查询不同角色的业务类型", businessType = BusinessType.OTHER)
    public R<List<Integer>>  selDifRoleBusType(){
        return R.ok(commonService.selDifRoleBusType());
    }






    /**
     * @Param
     * @Return
     * @Author sunzexing
     * @Date 2024-04-25 9:46
     * 说明：给企业分配产品，对应的服务商查询，过滤已经分配过的服务商
     **/
    @GetMapping("/selAgentService")
    @Log(title = "给企业分配产品，对应的服务商查询，过滤已经分配过的服务商", businessType = BusinessType.OTHER)
    public R<List<Map>>  selectAgentService(ProInfoCommonBo commonBo){
        return R.ok(commonService.selectAgentService(commonBo));

    }



    @GetMapping("/selBtByMs")
    @Log(title = "根据企业，服务商信息查询对应的业务类型", businessType = BusinessType.OTHER)
    public R<List<Integer>> selectBusTypeByMerSerInfo(Long merId, Long sydId){
        return R.ok(commonService.selectBusTypeByMerSerInfo(merId,sydId));
    }



    @GetMapping("/selBtByMsName")
    @Log(title = "根据企业，服务商信息查询对应的业务类型", businessType = BusinessType.OTHER)
    public R<List<RemoteDictDataVo>> selectBusTypeByMerSerInfoName(Long merId, Long sydId){
        if(merId == null && sydId == null){
            return R.ok(new ArrayList<>());
        }
        return R.ok(commonService.selectBusTypeByMerSerInfoName(merId,sydId));
    }


}
