package com.zfire.jiasm.syncdata.download.order;

import com.zfire.jiasm.syncdata.constant.TaskConfigEnum;
import com.zfire.jiasm.syncdata.service.AddInstallBusiness;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 自建工单用户完工评价回复，生成平价信息 + 差评申诉信息
 */
@Slf4j
@Component
public class SaleOrderEvaluate {
    @Value("${smsinselfc}")
    private String smsinselfc = "";

    @Resource
    AddInstallBusiness addInstallBusiness;


    // 自建工单短信回复 生成评价信息 + 申诉
    @Scheduled(fixedDelayString = "${smsinself}")
    public void orderAppraise() {
        if (smsinselfc.equals(TaskConfigEnum.FALSE.getCode())){
            return;
        }

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

        log.info("自建工单完工评价短信开始处理: \uF0B7{}",sdf.format(new Date()));

        try{
            addInstallBusiness.getOrderAppraiseSelf();
        } catch (Exception ex) {
            ex.printStackTrace();
            log.info("自建工单完工评价短信处理失败: \uF0B7{}",sdf.format(new Date()));
        }
        log.info("自建工单完工评价短信处理完成: \uF0B7{}",sdf.format(new Date()));
    }

}
