package com.sqx.modules.pay.controller.app;

import cn.hutool.core.map.MapUtil;
import com.sqx.common.utils.Result;
import com.sqx.modules.pay.service.NewPayService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

@Slf4j
@Api(value = "新支付", tags = {"新支付"})
@RestController
@RequestMapping("app/new-pay")
@RequiredArgsConstructor
public class NewPayController {

    private final NewPayService payService;

    @GetMapping("enable-new-pay")
    @ApiOperation("是否启用新支付")
    public Result enableNewPay() {
        boolean flag = payService.enableNewPay();
        Map<String, Object> enable = MapUtil.<String, Object>builder()
                .put("enable", flag)
                .build();
        return Result.success(enable);
    }

    @PostMapping("wechat-pay/notify")
    @ApiOperation("RTH微信支付回调")
    public String wechatPayNotify(@RequestBody String reqJsonData) {
        return payService.wechatPayNotify(reqJsonData);
    }
}
