package com.gic.haoban.manage.service.service.out.impl.content.task;

import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.haoban.manage.api.service.content.task.CommissionTaskApiService;
import com.gic.haoban.manage.api.dto.qdto.content.ClerkCashNotifyQDTO;
import com.gic.haoban.manage.service.pojo.bo.commission.ClerkCommissionStaticsBO;
import com.gic.haoban.manage.service.service.commission.CommissionNotifyInnerService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author MUSI
 * @Date 2023/6/7 2:16 PM
 * @Description
 * @Version
 **/
@Component("commissionTaskApiService")
public class CommissionTaskApiServiceImpl implements CommissionTaskApiService {

    @Autowired
    private CommissionNotifyInnerService commissionNotifyInnerService;

    private static final Logger log = LoggerFactory.getLogger(CommissionTaskApiService.class);

    /**
     * 处理佣金消息通知
     *
     * @param params
     */
    @Override
    public ServiceResponse<Void> handlerCommissionNotify(String params) {
        if (StringUtils.isBlank(params)) {
            log.info("处理导购佣金消息通知, 参数为空 {}", params);
            return ServiceResponse.success();
        }
        ClerkCommissionStaticsBO commissionStaticsBO = JSON.parseObject(params, ClerkCommissionStaticsBO.class);
        commissionNotifyInnerService.handlerCommissionNotify(commissionStaticsBO);
        return ServiceResponse.success();
    }

    @Override
    public ServiceResponse<Void> handlerCashNotify(String params) {
        if (StringUtils.isBlank(params)) {
            log.info("处理导购提现消息通知, 参数为空 {}", params);
            return ServiceResponse.success();
        }
        ClerkCashNotifyQDTO clerkCashNotifyQDTO = JSON.parseObject(params, ClerkCashNotifyQDTO.class);
        commissionNotifyInnerService.handlerCashNotify(clerkCashNotifyQDTO);
        return ServiceResponse.success();
    }
}
