package com.bonus.core.account.v3.app.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.core.account.v3.app.dto.AccRechargeForAppDTO;
import com.bonus.core.account.v3.app.dto.AppRechargeResultDTO;
import com.bonus.core.account.v3.app.dto.AppTradeDetailListDTO;
import com.bonus.core.account.v3.app.service.AppAccService;
import com.bonus.core.account.v3.app.vo.AppAccTradePageVO;
import com.bonus.core.account.v3.app.vo.AppRechargeResultVO;
import com.bonus.core.common.page.PageVO;
import com.bonus.core.pay.common.vo.MobilePayVO;
import com.github.pagehelper.page.PageMethod;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.bonus.core.common.utils.HeaderFetchUtil;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;
import java.util.Map;

@RestController
@Api(
        value = "ly_小程序账户控制器V3",
        tags = {"ly_小程序账户控制器V3"}
)
@RequestMapping({"/api/v3/app/accInfo"})
public class AppAccController extends BaseController {
    private static final Logger log = LoggerFactory.getLogger(AppAccController.class);
    @Resource
    private AppAccService appAccService;


    @ApiOperation("分页查询账户充值记录")
    @PostMapping({"/queryTradeAppPage"})
    public Page<AppAccTradePageVO>  queryTradeAppPage(@RequestBody @Valid AppTradeDetailListDTO dto) {
        try {
            Page<AppAccTradePageVO> pages = this.appAccService.queryTradeAppPage(dto);
            return pages;
        } catch (Exception e) {
            log.error(e.toString(), e);
            return null;
        }
    }
    @ApiOperation("小程序个人钱包充值")
    @PostMapping({"/personalRechargeForApp"})
    public AjaxResult personalRecharge(@RequestBody @Valid AccRechargeForAppDTO o) {
        MobilePayVO mobilePayVO = this.appAccService.accRechargeForApp(o);
        return AjaxResult.success(mobilePayVO);
    }

    @ApiOperation("充值超时重新查询充值结果")
    @PostMapping({"/recharge/overtime/query-result"})
    public AjaxResult queryAppRechargePayOvertimeResult(@RequestBody @Valid AppRechargeResultDTO dto) {
        return AjaxResult.success(this.appAccService.queryAppRechargePayOvertimeResult(dto));
    }

    @ApiOperation("充值后直接查询充值结果")
    @PostMapping({"/personalRecharge/result"})
    public AjaxResult queryAppRechargeResult(@RequestBody @Valid AppRechargeResultDTO request) {
        return AjaxResult.success(this.appAccService.queryAppRechargeResult(request));
    }
}
