package com.zanxiang.game.module.sdk.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zanxiang.game.module.mybatis.entity.GameBackLog;
import com.zanxiang.game.module.mybatis.mapper.GameBackLogMapper;
import com.zanxiang.game.module.sdk.service.IGameBackLogService;
import com.zanxiang.module.util.JsonUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @author : lingfeng
 * @time : 2023-08-02
 * @description : 游戏回传日志
 */
@Slf4j
@Service
public class GameBackLogServiceImpl extends ServiceImpl<GameBackLogMapper, GameBackLog> implements IGameBackLogService {

    @Override
    public void addLog(Long userId, String orderId, String describe, String param) {
        try {
            super.save(GameBackLog.builder()
                    .userId(userId)
                    .orderId(orderId)
                    .remark(describe)
                    .callBackParam(JsonUtil.toString(param))
                    .createTime(LocalDateTime.now())
                    .build());
        } catch (Exception e) {
            log.error("回传接口日志保存异常, param : {}, e : {}", param, e.getMessage());
        }
    }
}
