package com.yn.bftl.thirdparty.modules.business.abstracts;

import com.yn.bftl.thirdparty.common.service.BaseMemberService;
import com.yn.bftl.thirdparty.modules.log.service.LoggerService;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.Map;

/**
 * 业务抽象类
 * 用于继承BaseMemberService类
 * 抽象编写公共的方法使用
 *
 * @author chendehuihuo
 * @date 2021-11-10
 **/
public abstract class AbstractBusinessService extends BaseMemberService {

    @Resource
    LoggerService loggerService;

    protected Map<String, Object> logMap = new HashMap<>();

    /**
     * 记录服务费日志
     *
     * @param message
     * @return BaseAllinpayServiceAbstract
     * @author chendehuihuo
     * @date 2021-11-22
     */
    protected AbstractBusinessService writeCommissionLog(String message) {
        String classname = Thread.currentThread().getStackTrace()[2].getClassName(); //获取被调用者的类名
        String functionName = Thread.currentThread().getStackTrace()[2].getMethodName(); //获取被调用者的方法名
        message = "[记录]" + functionName + message;
        loggerService.commission(message, logMap, classname, functionName, "commission:" + classname + ":" + functionName);
        return this;
    }

    /**
     * 记录分账日志
     *
     * @param message
     * @return BaseAllinpayServiceAbstract
     * @author chendehuihuo
     * @date 2021-11-22
     */
    protected AbstractBusinessService writeSeparateLog(String message) {
        String classname = Thread.currentThread().getStackTrace()[2].getClassName(); //获取被调用者的类名
        String functionName = Thread.currentThread().getStackTrace()[2].getMethodName(); //获取被调用者的方法名
        message = "[记录]" + functionName + message;
        loggerService.separate(message, logMap, classname, functionName, "separate:" + classname + ":" + functionName);
        return this;
    }
}
