package com.zfire.jiasm.syncdata.service.impl;

import com.zfire.jiasm.syncdata.service.JdmallService;
import com.zfire.jiasm.syncdata.utils.oss.AddJdueUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Slf4j
@Service
public class JdmallServiceImpl implements JdmallService {
    @Autowired
    private AddJdueUtil addJdueUtil;



    @Override
    public void syncData() {
        processAppointmentModification();

        processAppointSite();

        processCancelOrder();

        processFinish();

        processServicePersonnel();
    }



    private void processAppointmentModification() {
        String[] cols = new String[] { "orderNo", "createBy", "createDate", "bookDate",
                "bookDate2", "remark" };

        addJdueUtil.process("addJdueBookOnDoor", "api/jdueFeedback/addJdueBookOnDoor",
                "itf_addjduebookondoor_req", cols);
    }

    private void processAppointSite() {
        String[] cols = new String[] { "orderNo", "siteNode", "siteName", "createBy", "createDate",
                "contactMan", "siteMobile", "province", "city", "county", "town", "address" };

        addJdueUtil.process("addJdueAppointSite", "api/jdueFeedback/addJdueAppointSite",
                "itf_addjdueappointsite_req", cols);
    }

    private void processCancelOrder() {
        String[] cols = new String[] { "orderNo", "createBy", "createDate", "cancelType","cancelReason"};

        addJdueUtil.process("addJdueCancel", "api/jdueFeedback/addJdueCancel",
                "itf_addjduecancel_req", cols);
    }

    private void processFinish() {
        String[] cols = new String[] { "orderNo", "createBy", "createDate", "barcode1",
                "barcode2", "dealRemark" };

        addJdueUtil.process("addJdueFinish", "api/jdueFeedback/addJdueFinish",
                "itf_addjduefinish_req", cols);
    }


    private void processServicePersonnel() {
        String[] cols = new String[] { "orderNo", "siteNode", "siteName", "createBy", "createDate",
                "engineerCode", "engineerName", "engineerMobile" };

        addJdueUtil.process("addJdueAppointEngineer", "api/jdueFeedback/addJdueAppointEngineer",
                "itf_addjdueappointengineer_req", cols);
    }


}
