package com.ghy.callback;

import com.alibaba.fastjson.JSONObject;
import com.ghy.common.adapay.model.Event;
import com.ghy.payment.domain.DrawCashRecord;
import com.ghy.payment.mapper.DrawCashRecordMapper;
import com.ghy.payment.service.CallBackService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 提现回调
 *
 * @author HH 2022/5/30
 */
@Slf4j
@Service("drawCashCallbackService")
public class DrawCashCallbackService implements CallBackService {

    @Resource
    private DrawCashRecordMapper drawCashRecordMapper;

    @Override
    public void onCallback(Event event) {
        log.info("提现 callback: {}", event.toString());
    }

    @Override
    public void onResponse(JSONObject response) {
        DrawCashRecord record = response.toJavaObject(DrawCashRecord.class);
        drawCashRecordMapper.insert(record);
    }

}
