package com.gxwebsoft.common.system.controller;

import com.gxwebsoft.common.core.config.ConfigProperties;
import com.gxwebsoft.common.core.utils.RedisUtil;
import com.gxwebsoft.common.core.utils.RequestUtil;
import com.gxwebsoft.common.core.web.BaseController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * 会员特权购买记录表控制器
 *
 * @author 科技小王子
 * @since 2023-06-20 18:07:50
 */
@Tag(name = "支付")
@RestController
@RequestMapping("/api/system/balance-pay")
public class NotifyByBalancePayController extends BaseController {
  @Value("${spring.profiles.active}")
  String active;
  @Resource
  private RedisUtil redisUtil;
  @Resource
  private RequestUtil requestUtil;
  @Resource
  private ConfigProperties conf;

  @Schema(description = "余额支付通知(未完成)")
  @PostMapping("/notify/{tenantId}")
  public String wxNotify(@RequestHeader Map<String, String> header, @RequestBody String body, @PathVariable("tenantId") Integer tenantId) {
    System.out.println("异步通知*************** = ");

    // 以支付通知回调为例，验签、解密并转换成 Transaction
    try {
      // 推送微信官方支付结果(携带租户ID的POST请求)
//      requestUtil.pushBalancePayNotify();
      return "SUCCESS";
    } catch (Exception $e) {
      System.out.println($e.getMessage());
    }

    return "fail";
  }


}
