package com.czg.controller;

import com.czg.annotation.Debounce;
import com.czg.order.dto.MkDistributionPayDTO;
import com.czg.resp.CzgResult;
import com.czg.sa.StpKit;
import com.czg.service.order.service.DistributionPayService;
import com.czg.system.service.SysParamsService;
import com.czg.utils.AssertUtil;
import com.czg.utils.ServletUtil;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 分销员开通
 *
 * @author ww
 * @description
 */
@RestController
@RequestMapping("/pay/distribution")
public class DistributionPayController {
    @Resource
    private DistributionPayService payService;
    @DubboReference
    private SysParamsService paramsService;


//    @PostMapping("/cashPay")
//    @Debounce(value = "#payParam.checkOrderPay.orderId")
//    public CzgResult<Object> cashPayOrder(@RequestHeader Long shopId, @Validated @RequestBody MkDistributionPayDTO payParam) {
//        payParam.setShopId(shopId);
//        return payService.cashPayOrder(payParam);
//    }

    /**
     * 小程序支付
     * payType 必填  支付方式，aliPay 支付宝，wechatPay 微信
     * openId  必填
     */
    @PostMapping("/ltPayOrder")
    @Debounce(value = "#payParam.userId")
    public CzgResult<Map<String, Object>> ltPayOrder( HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
        return payService.ltPayOrder(ServletUtil.getClientIP(request), payParam);
    }


    /**
     * 运营端小程序余额充值
     * payType 必填  支付方式，aliPay 支付宝，wechatPay 微信
     */
    @PostMapping("/mchRecharge")
    @Debounce(value = "#payParam.userId")
    public CzgResult<Map<String, String>> mchRecharge(HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
        AssertUtil.isBlank(payParam.getCode(), "微信code不为空");
        return CzgResult.success(payService.mchRecharge(ServletUtil.getClientIP(request), payParam));
    }
//
//    /**
//     * 正扫
//     */
//    @PostMapping("/scanPay")
//    @Debounce(value = "#payParam.checkOrderPay.orderId")
//    public CzgResult<Map<String, Object>> scanPayOrder(@RequestHeader Long shopId, HttpServletRequest request, @Validated @RequestBody MkDistributionPayDTO payParam) {
//        payParam.setShopId(shopId);
//        return payService.scanPayOrder(ServletUtil.getClientIP(request), payParam);
//    }
//
//    /**
//     * 反扫
//     * authCode 必填 扫描码
//     */
//    @PostMapping("/microPay")
//    @Debounce(value = "#payParam.checkOrderPay.orderId")
//    public CzgResult<Map<String, Object>> microPayOrder(@RequestHeader Long shopId, @Validated @RequestBody MkDistributionPayDTO payParam) {
//        payParam.setShopId(shopId);
//        return payService.microPayOrder(payParam);
//    }

}
