Ethan 1 mesiac pred
rodič
commit
ac5b8300af

+ 41 - 0
app/controller/workspace_controller.go

@@ -273,6 +273,47 @@ func (t WorkspaceController) GetDefault(c *gin.Context) {
 	returnSuccess(c, 20000, resultMap)
 }
 
+// 合作待办-任务邀约
+func (t WorkspaceController) GetTaskInvite(c *gin.Context) {
+	param := &vo.CommonParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "Parameter Error: "+err.Error())
+		return
+	}
+	projectToDo, err1 := service.ProjectService{}.GetTaskInviteToDo(param.EnterpriseId, param.SubAccountId)
+	if err1 != nil {
+		logrus.Errorf("[ProjectService] call Show err:%+v\n", err1)
+		returnError(c, 40000, err1.Error())
+		return
+	}
+	localLifeToDo, err2 := service.LocalLifeService{}.GetTaskInviteToDo(param.EnterpriseId, param.SubAccountId)
+	if err2 != nil {
+		logrus.Errorf("[ProjectService] call Show err:%+v\n", err2)
+		returnError(c, 40000, err2.Error())
+		return
+	}
+	resultMap := make(map[string]*map[string]map[string]int64)
+	resultMap["projectToDo"] = &projectToDo
+	resultMap["localLifeToDo"] = &localLifeToDo
+	returnSuccess(c, 20000, resultMap)
+}
+
+// 合作待办-入库邀约
+func (t WorkspaceController) GetWarehouseInvite(c *gin.Context) {
+	param := &vo.CommonParam{}
+	err := c.BindJSON(param)
+	if err != nil {
+		logrus.Errorf("Request bind err:%+v\n", err)
+		returnError(c, 40000, "Parameter Error: "+err.Error())
+		return
+	}
+	resultMap := make(map[string]int64)
+	resultMap["inviteConfirming"] = 0
+	returnSuccess(c, 20000, resultMap)
+}
+
 // 财务待办-充值与发票
 func (t WorkspaceController) GetFinance(c *gin.Context) {
 	param := &vo.CommonParam{}

+ 80 - 0
app/dao/local_life_dao.go

@@ -591,3 +591,83 @@ func (d LocalLifeDao) GetLocalLifeFinished(enterpriseId string, invoiceStatus in
 	}
 	return localLifeAmount, err
 }
+
+// 合作待办-任务邀约
+func (d LocalLifeDao) GetTaskInviteToDo(enterpriseId string, subAccountId int64, platform int64) (map[string]int64, error) {
+	resultMap := make(map[string]int64)
+	var availInvitationNum int64 //
+	var invitingNum int64        //
+	var cooperatingNum int64     //
+	//var localInfos []entity.LocalLifeInfo
+	////query := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and local_platform = ? and local_type = ?", enterpriseId, platform, taskType)
+	//if subAccountId == 0 {
+	//	// 待预约探店时间、探店时间待确认、达人待探店
+	//	query1 := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and local_platform = ? and task_form = ?", enterpriseId, platform, 1)
+	//	err := query1.Where("task_status = ?", 8).Select("local_id").Find(&localInfos).Error
+	//	if err != nil {
+	//		if errors.Is(err, gorm.ErrRecordNotFound) {
+	//			needBook = 0
+	//			needConfirm = 0
+	//			needExplore = 0
+	//		} else {
+	//			return resultMap, err
+	//		}
+	//	} else if len(localInfos) > 0 {
+	//		var localIDs []string
+	//		for _, info := range localInfos {
+	//			localIDs = append(localIDs, info.LocalID)
+	//		}
+	//		if len(localIDs) > 0 {
+	//			err1 := Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id in ? and task_stage = ?", localIDs, 4).Count(&needBook).Error // task_stage=4待预约探店
+	//			if err1 != nil {
+	//				needBook = 0
+	//			}
+	//			err2 := Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id in ? and task_stage = ?", localIDs, 5).Count(&needConfirm).Error // task_stage=4预约确认中
+	//			if err2 != nil {
+	//				needConfirm = 0
+	//			}
+	//			err3 := Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id in ? and book_status = ?", localIDs, 5).Count(&needExplore).Error // book_status=5达人待探店
+	//			if err3 != nil {
+	//				needExplore = 0
+	//			}
+	//		}
+	//	}
+	//} else {
+	//	// 待预约探店时间、探店时间待确认、达人待探店
+	//	query1 := Db.Model(&entity.LocalLifeInfo{}).Where("enterprise_id = ? and local_platform = ? and task_form = ?", enterpriseId, platform, 1)
+	//	err := query1.Where("sub_account_id = ? and task_status = ?", subAccountId, 8).Select("local_id").Find(&localInfos).Error
+	//	if err != nil {
+	//		if errors.Is(err, gorm.ErrRecordNotFound) {
+	//			needBook = 0
+	//			needConfirm = 0
+	//			needExplore = 0
+	//		} else {
+	//			return resultMap, err
+	//		}
+	//	} else if len(localInfos) > 0 {
+	//		var localIDs []string
+	//		for _, info := range localInfos {
+	//			localIDs = append(localIDs, info.LocalID)
+	//		}
+	//		if len(localIDs) > 0 {
+	//			err1 := Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id in ? and task_stage = ?", localIDs, 4).Count(&needBook).Error // task_stage=4待预约探店
+	//			if err1 != nil {
+	//				needBook = 0
+	//			}
+	//			err2 := Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id in ? and task_stage = ?", localIDs, 5).Count(&needConfirm).Error // task_stage=4预约确认中
+	//			if err2 != nil {
+	//				needConfirm = 0
+	//			}
+	//			err3 := Db.Model(&entity.LocalLifeTaskInfo{}).Where("local_id in ? and book_status = ?", localIDs, 5).Count(&needExplore).Error // book_status=5达人待探店
+	//			if err3 != nil {
+	//				needExplore = 0
+	//			}
+	//		}
+	//	}
+	//}
+	resultMap["availInvitationNum"] = availInvitationNum
+	resultMap["invitingNum"] = invitingNum
+	resultMap["cooperatingNum"] = cooperatingNum
+
+	return resultMap, nil
+}

+ 70 - 0
app/dao/project_dao.go

@@ -654,3 +654,73 @@ func (d ProjectDAO) GetProjectFinished(enterpriseId string, invoiceStatus int64)
 	}
 	return projectAmount, err
 }
+
+// 寄样物流任务待办
+func (d ProjectDAO) GetTaskInviteToDo(enterpriseId string, subAccountId int64, platform int64) (map[string]int64, error) {
+	resultMap := make(map[string]int64)
+	var availInvitationNum int64
+	var invitingNum int64
+	var cooperatingNum int64
+	//var projectInfos []entity.Project
+	////query := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_platform = ? and project_type = ?", enterpriseId, platform, taskType)
+	//if subAccountId == 0 {
+	//	// 待发货、待签收
+	//	query1 := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_platform = ? and project_form = ?", enterpriseId, platform, 1)
+	//	err := query1.Where("project_status = ?", 8).Select("project_id").Find(&projectInfos).Error
+	//	if err != nil {
+	//		if errors.Is(err, gorm.ErrRecordNotFound) {
+	//			needDelivery = 0
+	//			needReceive = 0
+	//		} else {
+	//			return resultMap, err
+	//		}
+	//	} else if len(projectInfos) > 0 {
+	//		var projectIDs []string
+	//		for _, info := range projectInfos {
+	//			projectIDs = append(projectIDs, info.ProjectId)
+	//		}
+	//		if len(projectIDs) > 0 {
+	//			err1 := Db.Model(&entity.ProjectTaskInfo{}).Where("project_id in ? and task_stage = ?", projectIDs, 4).Count(&needDelivery).Error // task_stage=4待发货
+	//			if err1 != nil {
+	//				needDelivery = 0
+	//			}
+	//			err2 := Db.Model(&entity.ProjectTaskInfo{}).Where("project_id in ? and task_stage = ?", projectIDs, 5).Count(&needReceive).Error // task_stage=5已发货
+	//			if err2 != nil {
+	//				needReceive = 0
+	//			}
+	//		}
+	//	}
+	//} else {
+	//	// 待发货、待签收
+	//	query1 := Db.Model(&entity.Project{}).Where("enterprise_id = ? and project_platform = ? and project_form = ?", enterpriseId, platform, 1)
+	//	err := query1.Where("sub_account_id = ? and project_status = ?", subAccountId, 8).Select("project_id").Find(&projectInfos).Error
+	//	if err != nil {
+	//		if errors.Is(err, gorm.ErrRecordNotFound) {
+	//			needDelivery = 0
+	//			needReceive = 0
+	//		} else {
+	//			return resultMap, err
+	//		}
+	//	} else {
+	//		var projectIDs []string
+	//		for _, info := range projectInfos {
+	//			projectIDs = append(projectIDs, info.ProjectId)
+	//		}
+	//		if len(projectIDs) > 0 {
+	//			err1 := Db.Model(&entity.ProjectTaskInfo{}).Where("project_id in ? and task_stage = ?", projectIDs, 4).Count(&needDelivery).Error // task_stage=4待发货
+	//			if err1 != nil {
+	//				needDelivery = 0
+	//			}
+	//			err2 := Db.Model(&entity.ProjectTaskInfo{}).Where("project_id in ? and task_stage = ?", projectIDs, 5).Count(&needReceive).Error // task_stage=5已发货
+	//			if err2 != nil {
+	//				needReceive = 0
+	//			}
+	//		}
+	//	}
+	//}
+	resultMap["availInvitationNum"] = availInvitationNum
+	resultMap["invitingNum"] = invitingNum
+	resultMap["cooperatingNum"] = cooperatingNum
+
+	return resultMap, nil
+}

+ 42 - 0
app/service/local_life_service.go

@@ -1362,3 +1362,45 @@ func (p LocalLifeService) GetDefaultToDo(enterpriseId string, subAccountId int64
 
 	return res, nil
 }
+
+// 合作待办-任务邀约
+func (p LocalLifeService) GetTaskInviteToDo(enterpriseId string, subAccountId int64) (map[string]map[string]int64, error) {
+	res := make(map[string]map[string]int64)
+	redbook, err1 := dao.LocalLifeDao{}.GetTaskInviteToDo(enterpriseId, subAccountId, 1)
+	if err1 != nil {
+		logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err1)
+		return res, err1
+	}
+	douyin, err2 := dao.LocalLifeDao{}.GetTaskInviteToDo(enterpriseId, subAccountId, 2)
+	if err2 != nil {
+		logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err2)
+		return res, err2
+	}
+	kuaishou, err3 := dao.LocalLifeDao{}.GetTaskInviteToDo(enterpriseId, subAccountId, 4)
+	if err3 != nil {
+		logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err3)
+		return res, err3
+	}
+	weibo, err4 := dao.LocalLifeDao{}.GetTaskInviteToDo(enterpriseId, subAccountId, 3)
+	if err4 != nil {
+		logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err4)
+		return res, err4
+	}
+	bilibili, err5 := dao.LocalLifeDao{}.GetTaskInviteToDo(enterpriseId, subAccountId, 5)
+	if err5 != nil {
+		logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err5)
+		return res, err5
+	}
+	all := make(map[string]int64)
+	all["availInvitationNum"] = redbook["availInvitationNum"] + douyin["availInvitationNum"] + kuaishou["availInvitationNum"] + weibo["availInvitationNum"] + bilibili["availInvitationNum"]
+	all["invitingNum"] = redbook["invitingNum"] + douyin["invitingNum"] + kuaishou["invitingNum"] + weibo["invitingNum"] + bilibili["invitingNum"]
+	all["cooperatingNum"] = redbook["cooperatingNum"] + douyin["cooperatingNum"] + kuaishou["cooperatingNum"] + weibo["cooperatingNum"] + bilibili["cooperatingNum"]
+	res["redbook"] = redbook
+	res["douyin"] = douyin
+	res["kuaishou"] = kuaishou
+	res["weibo"] = weibo
+	res["bilibili"] = bilibili
+	res["all"] = all
+
+	return res, nil
+}

+ 42 - 0
app/service/project_service.go

@@ -1139,3 +1139,45 @@ func (p ProjectService) GetDefaultToDo(enterpriseId string, subAccountId int64,
 
 	return res, nil
 }
+
+// 合作待办-任务邀约
+func (p ProjectService) GetTaskInviteToDo(enterpriseId string, subAccountId int64) (map[string]map[string]int64, error) {
+	res := make(map[string]map[string]int64)
+	redbook, err1 := dao.ProjectDAO{}.GetTaskInviteToDo(enterpriseId, subAccountId, 1)
+	if err1 != nil {
+		logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err1)
+		return res, err1
+	}
+	douyin, err2 := dao.ProjectDAO{}.GetTaskInviteToDo(enterpriseId, subAccountId, 2)
+	if err2 != nil {
+		logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err2)
+		return res, err2
+	}
+	kuaishou, err3 := dao.ProjectDAO{}.GetTaskInviteToDo(enterpriseId, subAccountId, 4)
+	if err3 != nil {
+		logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err3)
+		return res, err3
+	}
+	weibo, err4 := dao.ProjectDAO{}.GetTaskInviteToDo(enterpriseId, subAccountId, 3)
+	if err4 != nil {
+		logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err4)
+		return res, err4
+	}
+	bilibili, err5 := dao.ProjectDAO{}.GetTaskInviteToDo(enterpriseId, subAccountId, 5)
+	if err5 != nil {
+		logrus.Errorf("[GetTaskInviteToDo service] call GetTaskInviteToDo error,err:%+v", err5)
+		return res, err5
+	}
+	all := make(map[string]int64)
+	all["availInvitationNum"] = redbook["availInvitationNum"] + douyin["availInvitationNum"] + kuaishou["availInvitationNum"] + weibo["availInvitationNum"] + bilibili["availInvitationNum"]
+	all["invitingNum"] = redbook["invitingNum"] + douyin["invitingNum"] + kuaishou["invitingNum"] + weibo["invitingNum"] + bilibili["invitingNum"]
+	all["cooperatingNum"] = redbook["cooperatingNum"] + douyin["cooperatingNum"] + kuaishou["cooperatingNum"] + weibo["cooperatingNum"] + bilibili["cooperatingNum"]
+	res["redbook"] = redbook
+	res["douyin"] = douyin
+	res["kuaishou"] = kuaishou
+	res["weibo"] = weibo
+	res["bilibili"] = bilibili
+	res["all"] = all
+
+	return res, nil
+}

+ 2 - 2
route/init.go

@@ -176,8 +176,8 @@ func InitRoute(r *gin.Engine) {
 		workspace.POST("/explore", controller.WorkspaceController{}.GetExplore)       // 任务待办-探店邀约
 		workspace.POST("/default", controller.WorkspaceController{}.GetDefault)       // 任务待办-违约管理
 		// 合作待办
-		// 合作待办-任务邀约
-		// 合作待办-入库邀约
+		workspace.POST("/taskInvite", controller.WorkspaceController{}.GetTaskInvite)           // 合作待办-任务邀约
+		workspace.POST("/warehouseInvite", controller.WorkspaceController{}.GetWarehouseInvite) // 合作待办-入库邀约
 		// 财务待办
 		workspace.POST("/finance", controller.WorkspaceController{}.GetFinance) // 财务待办-充值与发票