package com.sf.payment.controller;

import com.alibaba.fastjson2.JSONObject;
import com.sf.common.core.domain.AjaxResult;
import com.sf.payment.constant.GoodsConstants;
import com.sf.payment.domain.HuaweiPaymentCallback;
import com.sf.payment.domain.HuaweiPurchasesVerifyDTO;
import com.sf.payment.service.IHuaweiPaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author zoukun
 */
@Slf4j
@RestController
@RequestMapping("/payment")
public class HuaweiPaymentController {

    @Autowired
    private IHuaweiPaymentService huaweiPaymentService;


    /**
     * 华为支付回调地址
     */
    @RequestMapping("/callback/huawei")
    public AjaxResult callback(@RequestBody HuaweiPaymentCallback callback) {
        log.info("进入callback： params：" + JSONObject.toJSONString(callback));
        AjaxResult ajax = AjaxResult.success();
        return ajax;
    }


    /**
     * 华为购买验证
     */
    @PostMapping("/huawei/purchases/verify")
    public AjaxResult purchasesVerify(@Validated @RequestBody HuaweiPurchasesVerifyDTO verifyDTO) {
        log.info("进入/huawei/purchases/tokens/verify： params：" + JSONObject.toJSONString(verifyDTO));
        huaweiPaymentService.purchasesVerify(verifyDTO);
        return AjaxResult.success();
    }

}
