package com.cpop.mall.business.controller.callback;

import com.cpop.mall.business.service.OrderRefundService;
import com.cpop.mall.business.service.OrderService;
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
import org.springframework.beans.factory.annotation.Autowired;
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;

/**
 * @author DB
 * @createTime 2023/10/27 15:57
 * @description
 */
@RestController
@RequestMapping("/wxPay/callback")
@Deprecated
public class WxPayCallbackController {

    @Autowired
    private OrderRefundService orderRefundService;

    @Autowired
    private OrderService orderService;

    /**
     * @descriptions 微信支付订单通知
     * @author DB
     * @date 2023/10/27 16:04
     * @param xmlData 数据
     * @return: java.lang.String
     */
    @PostMapping("/notify/order")
    public String parseOrderNotifyResult(@RequestBody String xmlData){
        orderService.wxPayNotifyOrder(xmlData);
        return WxPayNotifyResponse.success("成功");
    }

    /**
     * @descriptions 退款回调通知处理
     * @author DB
     * @date 2023/10/27 18:21
     * @param xmlData 数据
     * @return: java.lang.String
     */
    @PostMapping("/notify/refund")
    public String parseRefundNotifyResult(@RequestBody String xmlData){
        orderRefundService.wxPayNotifyRefund(xmlData);
        return WxPayNotifyResponse.success("成功");
    }

}
