package com.ruoyi.web.controller.h5;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.system.domain.CreditUser;
import com.ruoyi.common.core.domain.entity.PolicyMenu;
import com.ruoyi.system.domain.UsageRecord;
import com.ruoyi.system.service.ICreditUserService;
import com.ruoyi.system.service.IPolicyMenuService;
import com.ruoyi.system.service.ISettledMerchantsService;
import com.ruoyi.system.service.IUsageRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;
import java.util.List;

/**
 * 入驻商家Controller
 * 
 * @author boman
 * @date 2022-06-10
 */
@RestController
@RequestMapping("/system/h5")
public class H5Controller extends BaseController
{
    @Autowired
    private ISettledMerchantsService settledMerchantsService;

    @Autowired
    private IPolicyMenuService policyMenuService;

    @Autowired
    private ICreditUserService creditUserService;

    @Autowired
    private IUsageRecordService usageRecordService;

    /**
     * 根据政策类别获取入驻商家详细信息
     */
    @GetMapping(value = "/menu/{menuId}")
    public AjaxResult getInfoByMenuId(@PathVariable("menuId") Long menuId)
    {
        return AjaxResult.success(settledMerchantsService.selectSettledMerchantsByMenuId(menuId));
    }


    /**
     * 查询入驻商家列表全部
     */
    @GetMapping("/policy/list")
    public AjaxResult policyList(PolicyMenu policyMenu)
    {
        List<PolicyMenu> list = policyMenuService.selectPolicyMenuList(policyMenu);
        return AjaxResult.success(list);
    }

    /**
     * 获取信用人员详细信息
     */
    @PostMapping(value = "/user/info")
    public AjaxResult getInfo(@RequestBody CreditUser creditUser)
    {
        return AjaxResult.success(creditUserService.selectCreditUser(creditUser));
    }

    /**
     * 查询使用记录列表
     */
    @GetMapping(value = "/record/{creditId}")
    public AjaxResult getRecordList(@PathVariable("creditId") Long creditId)
    {
        return usageRecordService.selectUsageRecordListByRecordId(creditId);
    }
}
