package com.kym.admin.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.kym.common.R;
import com.kym.common.annotation.SysLog;
import com.kym.entity.queryParams.CommonQueryParam;
import com.kym.service.PayLogService;
import com.kym.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户相关信息
 *
 * @author skyline
 * @since 2023-08-18
 */
@RestController
@RequestMapping("/custom")
public class CustomController {

    private final UserService customUserService;
    private final PayLogService payLogService;


    public CustomController(UserService customUserService, PayLogService payLogService) {
        this.customUserService = customUserService;
        this.payLogService = payLogService;
    }

    @SaCheckPermission("account.list")
    @SysLog("查询用户列表")
    @GetMapping("/listUser")
    public R<?> listUser(@ModelAttribute CommonQueryParam params) {
        return R.success(customUserService.listCustomUser(params));
    }

    @SysLog("充值记录列表")
    @GetMapping("/listRecharge")
    public R<?> listRecharge(@ModelAttribute CommonQueryParam params) {
        return R.success(payLogService.listRecharge(params));
    }

    @SysLog("充值记录详情")
    @GetMapping("/payLog/{id}")
    public R<?> payLogDetail(@PathVariable Long id) {
        return R.success(payLogService.getById(id));
    }

    @SysLog("充值记录详情(按商户订单号)")
    @GetMapping("/payLog/byOutTradeNo/{outTradeNo}")
    public R<?> payLogDetailByOutTradeNo(@PathVariable String outTradeNo) {
        return R.success(payLogService.getByOutTradeNo(outTradeNo));
    }

}
