package org.jeecg.modules.api.teambuyController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.modules.apiBean.PageBean;
import org.jeecg.modules.apiService.AmountService;
import org.jeecg.modules.apiService.LeaderService;
import org.jeecg.modules.teambuyBalanceLog.entity.TeambuyBalanceLog;
import org.jeecg.modules.teambuyCash.entity.TeambuyCash;
import org.jeecg.modules.teambuyTeamLeader.entity.TeambuyTeamLeader;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;

@Api(tags="我的-钱包相关接口")
@RestController
@RequestMapping("/teambuy/amount")
@Slf4j
public class AmountController {
    /******************************************************************************************************************/
    //团长
    @Resource
    private AmountService amountService;
    /******************************************************************************************************************/
    @ApiOperation(value="钱包-提现记录列表", notes="钱包-提现记录列表")
    @RequestMapping(value = "/queryCashoutLog", method = {RequestMethod.GET})
    public Result<?> queryCashoutLog(@RequestHeader("X-Access-Token") String token, PageBean pageBean){
        return amountService.queryCashoutLog(token, pageBean);
    }

    @ApiOperation(value="钱包-提现", notes="钱包-提现")
    @RequestMapping(value = "/cashout", method = {RequestMethod.POST})
    public Result<?> cashout(@RequestHeader("X-Access-Token") String token, String userName, BigDecimal transferAmount){
        return amountService.cashOut(token, userName, transferAmount);
    }

    @ApiOperation(value="钱包-领取提现金额", notes="钱包-领取提现金额")
    @RequestMapping(value = "/getMoney", method = {RequestMethod.POST})
    public Result<?> getMoney(@RequestHeader("X-Access-Token") String token, String id){
        return amountService.getMoney(token, id);
    }

    //充值
    @ApiOperation(value="钱包-充值", notes="钱包-充值")
    @RequestMapping(value = "/cashIn", method = {RequestMethod.POST})
    public Result<?> cashIn(@RequestHeader("X-Access-Token") String token, TeambuyCash teambuyCash){
        return amountService.cashIn(token, teambuyCash);
    }

    //收入明细
    @ApiOperation(value="钱包-收支明细", notes="钱包-收支明细")
    @RequestMapping(value = "/queryAmountLog", method = {RequestMethod.POST})
    public Result<?> queryAmountLog(@RequestHeader("X-Access-Token") String token, TeambuyBalanceLog balanceLog, PageBean pageBean){
        return amountService.queryAmountLog(token, balanceLog, pageBean);
    }

    //充值回调
    @PostMapping("/CashNotify")
    public Object CashNotify(@RequestBody String requestBody){
        return amountService.CashNotify(requestBody);
    }

    //提现回调
    @PostMapping("/cashoutNotify")
    public Object cashoutNotify(@RequestHeader("Wechatpay-Signature") String signature,
                                @RequestHeader("Wechatpay-Timestamp") String timestamp,
                                @RequestHeader("Wechatpay-Nonce") String nonce,
                                @RequestHeader("Wechatpay-Serial") String serial,
                                @RequestBody String requestBody){
        return amountService.cashoutNotify(signature, timestamp, nonce, serial, requestBody);
    }

}
