package org.dromara.zhishu.util;



import org.dromara.common.core.domain.model.LoginUser;
import org.dromara.zhishu.domain.bo.TaskBo;
import org.dromara.zhishu.service.IPddService;
import org.dromara.zhishu.service.ITaskService;
import org.dromara.zhishu.service.IZhishuShopGoodsService;
import org.springframework.context.ApplicationContext;

import java.util.Map;

public class TaskRunnable implements Runnable {

    private final ITaskService taskService;
    private ApplicationContext applicationContext;

    private final Map map;
    private final TaskBo taskBo;
    private final LoginUser user;
    private final String type;



    public TaskRunnable(ITaskService taskService, Map map, TaskBo taskBo, LoginUser user,ApplicationContext applicationContext,String type) {
        this.taskService = taskService;
        this.map = map;
        this.taskBo = taskBo;
        this.user = user;
        this.applicationContext = applicationContext;
        this.type = type;
    }
    @Override
    public void run() {
        ITaskService taskService = applicationContext.getBean(ITaskService.class);
        if(type.equals("1")){
            // 发布任务
            taskService.addGoods(map,taskBo,user.getUserId());
        }else if(type.equals("2")){
            //表格更新价格任务
            taskService.editGoodsPrice(map,taskBo,user.getUserId());
        }else if(type.equals("4")){
            //表格更新库存
            taskService.editGoodsStock(map,taskBo,user.getUserId());
        }else if(type.equals("5")){
            //修改商品上下架状态
            taskService.editGoodsIsOnSale(map,taskBo,user.getUserId());
        }else if(type.equals("6")){
            //手动同步库存任务
            taskService.stockSynchronize(map,taskBo,user.getUserId());
        }else if (type.equals("7")){
            //更新商品数据
            taskService.updateGoodsTask(map,taskBo,user.getUserId());
        } else{
            //核价任务
            taskService.addGoodsCenter(map,taskBo,user.getUserId());
        }
    }
}


