Browse Source

fix_可邀约列表

Ethan 1 day ago
parent
commit
6f69d57d73
3 changed files with 127 additions and 61 deletions
  1. 30 30
      app/entity/s_local_life.go
  2. 4 0
      app/entity/supplier.go
  3. 93 31
      app/service/cooperation_service.go

+ 30 - 30
app/entity/s_local_life.go

@@ -6,36 +6,36 @@ import (
 )
 
 type SLocalLifeInfo struct {
-	SLocalID            int64     `gorm:"column:s_local_id;primary_key;AUTO_INCREMENT"` // 主键ID
-	LocalID             string    `gorm:"column:local_id"`                              // 被加入商单的原本地生活ID
-	LocalType           int64     `gorm:"column:local_type"`                            // 类型,1代表公开,2代表定向
-	LocalName           string    `gorm:"column:local_name"`                            // 名称
-	LocalPlatform       int64     `gorm:"column:local_platform"`                        // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
-	StoreID             int64     `gorm:"column:store_id"`                              // 门店ID
-	TeamBuyingID        int64     `gorm:"column:team_buying_id"`                        // 关联团购id
-	TaskForm            int64     `gorm:"column:task_form"`                             // 任务形式,1-2分别代表线下探店,素材分发
-	ContentType         int64     `gorm:"column:content_type"`                          // 内容形式,1代表图文,2代表视频
-	TaskStatus          int64     `gorm:"column:task_status"`                           // 项目状态,1-10分别代表创建中、待审核、审核通过、招募中、招募完毕、待支付、已支付、执行中、失效、已结案
-	EnterpriseID        string    `gorm:"column:enterprise_id"`                         // 商家ID
-	SupplierID          int64     `gorm:"column:supplier_id"`                           // 服务商ID
-	ApplyNum            int64     `gorm:"column:apply_num"`                             // 报名人数
-	RecruitNum          int64     `gorm:"column:recruit_num"`                           // 已招募人数
-	SettleNum           int64     `gorm:"column:settle_num;default:0"`                  // 已结算人数
-	SubAccountID        int64     `gorm:"column:sub_account_id"`                        // 服务商子账号ID
-	ServiceCharge       float64   `gorm:"column:service_charge"`                        // 服务商预估可赚服务费
-	ServiceChargeActual float64   `gorm:"column:service_charge_actual"`                 // 服务商实际可赚服务费
-	ServiceChargeSettle float64   `gorm:"column:service_charge_settle"`                 // 服务商已结算服务费
-	OperatorType        int64     `gorm:"column:operator_type;default:0"`               // 添加商单操作人类型,1为服务商主账号,2为服务商子账号
-	SLocalStatus        int64     `gorm:"column:s_local_status;default:0"`              // 服务商本地生活任务状态,1待确认,2已确认,3已拒绝
-	StrategyStatus      int64     `gorm:"column:strategy_status;default:2"`             // 定向本地生活任务是否替换招募策略,1是,2否
-	BOperator           string    `gorm:"column:b_operator"`                            // 商家发起入库邀约人
-	BOperatorType       int64     `gorm:"column:b_operator_type"`                       // 商家发起入库邀约人类型:1主账号 2子账号
-	CreateTime          time.Time `gorm:"column:create_time"`                           // 创建时间
-	CreateStrategyID    int64     `gorm:"column:create_strategy_id"`                    // 服务商替换招募策略操作人ID
-	CreateStrategyType  int64     `gorm:"column:create_strategy_type"`                  // 服务商替换招募策略操作人类型:1服务商主账号,2子账号
-	ShareCode           string    `gorm:"column:share_code"`                            // 分享码url
-	FinishTime          time.Time `gorm:"column:finish_time"`                           // 结案时间
-	SupplierType        int64     `gorm:"column:supplier_type"`                         // 服务商类型,1个人,2企业
+	SLocalID            int64      `gorm:"column:s_local_id;primary_key;AUTO_INCREMENT"` // 主键ID
+	LocalID             string     `gorm:"column:local_id"`                              // 被加入商单的原本地生活ID
+	LocalType           int64      `gorm:"column:local_type"`                            // 类型,1代表公开,2代表定向
+	LocalName           string     `gorm:"column:local_name"`                            // 名称
+	LocalPlatform       int64      `gorm:"column:local_platform"`                        // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	StoreID             int64      `gorm:"column:store_id"`                              // 门店ID
+	TeamBuyingID        int64      `gorm:"column:team_buying_id"`                        // 关联团购id
+	TaskForm            int64      `gorm:"column:task_form"`                             // 任务形式,1-2分别代表线下探店,素材分发
+	ContentType         int64      `gorm:"column:content_type"`                          // 内容形式,1代表图文,2代表视频
+	TaskStatus          int64      `gorm:"column:task_status"`                           // 项目状态,1-10分别代表创建中、待审核、审核通过、招募中、招募完毕、待支付、已支付、执行中、失效、已结案
+	EnterpriseID        string     `gorm:"column:enterprise_id"`                         // 商家ID
+	SupplierID          int64      `gorm:"column:supplier_id"`                           // 服务商ID
+	ApplyNum            int64      `gorm:"column:apply_num"`                             // 报名人数
+	RecruitNum          int64      `gorm:"column:recruit_num"`                           // 已招募人数
+	SettleNum           int64      `gorm:"column:settle_num;default:0"`                  // 已结算人数
+	SubAccountID        int64      `gorm:"column:sub_account_id"`                        // 服务商子账号ID
+	ServiceCharge       float64    `gorm:"column:service_charge"`                        // 服务商预估可赚服务费
+	ServiceChargeActual float64    `gorm:"column:service_charge_actual"`                 // 服务商实际可赚服务费
+	ServiceChargeSettle float64    `gorm:"column:service_charge_settle"`                 // 服务商已结算服务费
+	OperatorType        int64      `gorm:"column:operator_type;default:0"`               // 添加商单操作人类型,1为服务商主账号,2为服务商子账号
+	SLocalStatus        int64      `gorm:"column:s_local_status;default:0"`              // 服务商本地生活任务状态,1待确认,2已确认,3已拒绝
+	StrategyStatus      int64      `gorm:"column:strategy_status;default:2"`             // 定向本地生活任务是否替换招募策略,1是,2否
+	BOperator           string     `gorm:"column:b_operator"`                            // 商家发起入库邀约人
+	BOperatorType       int64      `gorm:"column:b_operator_type"`                       // 商家发起入库邀约人类型:1主账号 2子账号
+	CreateTime          *time.Time `gorm:"column:create_time"`                           // 创建时间
+	CreateStrategyID    int64      `gorm:"column:create_strategy_id"`                    // 服务商替换招募策略操作人ID
+	CreateStrategyType  int64      `gorm:"column:create_strategy_type"`                  // 服务商替换招募策略操作人类型:1服务商主账号,2子账号
+	ShareCode           string     `gorm:"column:share_code"`                            // 分享码url
+	FinishTime          *time.Time `gorm:"column:finish_time"`                           // 结案时间
+	SupplierType        int64      `gorm:"column:supplier_type"`                         // 服务商类型,1个人,2企业
 }
 
 func (m *SLocalLifeInfo) TableName() string {

+ 4 - 0
app/entity/supplier.go

@@ -4,6 +4,8 @@ type Supplier struct {
 	SupplierID      int64  `gorm:"column:supplier_id"`      // 服务商ID
 	SupplierName    string `gorm:"column:supplier_name"`    // 服务商名称
 	PhoneNumber     string `gorm:"column:phone_number"`     // 手机号
+	WechatNumber    string `gorm:"column:wechat_number"`    // 微信号
+	WechatQrcode    string `gorm:"column:wechat_qrcode"`    // 微信二维码
 	BusinessLicense string `gorm:"column:business_license"` // 营业执照url
 	USCI            string `gorm:"column:usci"`             // 统一社会信用代码
 	CompanyName     string `gorm:"column:company_name"`     // 公司名称
@@ -13,6 +15,8 @@ type Supplier struct {
 	Name            string `gorm:"column:name"`             // 姓名
 	UserID          int64  `gorm:"column:user_id"`          // 用户表中的用户ID
 	SupplierType    int64  `gorm:"column:supplier_type"`    // 服务商用户类型,1为个人PR,2为机构
+	Avatar          string `gorm:"column:avatar"`           // 头像url
+	ReviewStatus    int64  `gorm:"column:review_status"`    // 认证状态,1未认证,2已认证
 }
 
 func (Supplier) TableName() string {

+ 93 - 31
app/service/cooperation_service.go

@@ -23,7 +23,7 @@ func (s CooperationService) SearchSupplier(param *vo.SupplierSearchParam) ([]*vo
 		exist, _ := dao.EnterpriseSupplierCooperateDao{}.EnterpriseDatabaseCheck(param.EnterpriseId, supplier.SupplierID)
 		reSupplierPreview := &vo.ReSupplierPreview{
 			SupplierId:   supplier.SupplierID,
-			HeadUrl:      "",
+			HeadUrl:      supplier.Avatar,
 			SupplierName: supplier.SupplierName,
 			SupplierType: supplier.SupplierType,
 			CompanyName:  supplier.CompanyName,
@@ -98,7 +98,7 @@ func (s CooperationService) GetEnterprisePoolList(param *vo.SupplierSearchInPool
 		}
 		supplierPreview := &vo.ReSupplierPreview{
 			SupplierId:   supplier.SupplierID,
-			HeadUrl:      "",
+			HeadUrl:      supplier.Avatar,
 			SupplierName: supplier.SupplierName,
 			SupplierType: supplier.SupplierType,
 			CompanyName:  supplier.CompanyName,
@@ -108,8 +108,8 @@ func (s CooperationService) GetEnterprisePoolList(param *vo.SupplierSearchInPool
 		reSupplierPoolInfo := &vo.ReSupplierPoolInfo{
 			SupplierPreview:    supplierPreview,
 			PhoneNumber:        supplier.PhoneNumber,
-			WechatId:           "",
-			WechatUrl:          "",
+			WechatId:           supplier.WechatNumber,
+			WechatUrl:          supplier.WechatQrcode,
 			CooperateNum:       enterpriseSupplierCooperate.CooperateNum,
 			UploadTalentNum:    enterpriseSupplierCooperate.UploadTalentNum,
 			CooperateTalentNum: enterpriseSupplierCooperate.CooperateTalentNum,
@@ -164,24 +164,25 @@ func (s CooperationService) GetSupplierConfirmingList(param *vo.SupplierConfirmi
 		if err == nil {
 			supplierPreview = &vo.ReSupplierPreview{
 				SupplierId:   supplier.SupplierID,
-				HeadUrl:      "",
+				HeadUrl:      supplier.Avatar,
 				SupplierName: supplier.SupplierName,
 				SupplierType: supplier.SupplierType,
 				CompanyName:  supplier.CompanyName,
 				Name:         supplier.Name,
 			}
 			phoneNumber = supplier.PhoneNumber
+			reSupplierConfirmingInfo := &vo.ReSupplierConfirmingInfo{
+				SupplierPreview:    supplierPreview,
+				PhoneNumber:        phoneNumber,
+				WechatId:           supplier.WechatNumber,
+				WechatUrl:          supplier.WechatQrcode,
+				CreateTime:         enterpriseSupplierCooperate.CreateTime.Format("2006-01-02 15:04:05"),
+				Status:             enterpriseSupplierCooperate.CooperateStatus,
+				EnterpriseOperator: enterpriseOperator,
+			}
+			reSupplierConfirmingInfos = append(reSupplierConfirmingInfos, reSupplierConfirmingInfo)
 		}
-		reSupplierConfirmingInfo := &vo.ReSupplierConfirmingInfo{
-			SupplierPreview:    supplierPreview,
-			PhoneNumber:        phoneNumber,
-			WechatId:           "",
-			WechatUrl:          "",
-			CreateTime:         enterpriseSupplierCooperate.CreateTime.Format("2006-01-02 15:04:05"),
-			Status:             enterpriseSupplierCooperate.CooperateStatus,
-			EnterpriseOperator: enterpriseOperator,
-		}
-		reSupplierConfirmingInfos = append(reSupplierConfirmingInfos, reSupplierConfirmingInfo)
+
 	}
 	result = vo.ResultVO{
 		Page:     param.Page,
@@ -227,6 +228,31 @@ func (s CooperationService) GetSupplierInTargetTaskList(param *vo.SupplierSearch
 	var enterpriseOperator string
 	if param.Status == 1 { // 可邀约
 		enterpriseSupplierCooperates, total, _ = dao.EnterpriseSupplierCooperateDao{}.GetSupplierByEnterprise(param.EnterpriseId, param.Page, param.PageSize)
+		if param.TaskType == 2 {
+			// 品牌种草
+			// 去除当前project_id、supplier_id已在 s_project_info中的数据
+			var resEnterpriseSuppliers []*entity.EnterpriseSupplierCooperate
+			for _, enterpriseSupplier := range enterpriseSupplierCooperates {
+				var sProject *entity.SProjectInfo
+				_ = dao.Db.Model(&entity.SProjectInfo{}).Where("project_id = ? and supplier_id = ?", param.TaskId, enterpriseSupplier.SupplierId).Find(&sProject).Error
+				if sProject == nil {
+					resEnterpriseSuppliers = append(resEnterpriseSuppliers, enterpriseSupplier)
+				}
+			}
+			enterpriseSupplierCooperates = resEnterpriseSuppliers
+		} else if param.TaskType == 3 {
+			// 本地生活
+			// 去除当前 local_id、supplier_id 已在 s_local_info中的数据
+			var resEnterpriseSuppliers []*entity.EnterpriseSupplierCooperate
+			for _, enterpriseSupplier := range enterpriseSupplierCooperates {
+				var sLocalLifeInfo *entity.SLocalLifeInfo
+				_ = dao.Db.Model(&entity.SLocalLifeInfo{}).Where("local_id = ? and supplier_id = ?", param.TaskId, enterpriseSupplier.SupplierId).Find(&sLocalLifeInfo).Error
+				if sLocalLifeInfo == nil {
+					resEnterpriseSuppliers = append(resEnterpriseSuppliers, enterpriseSupplier)
+				}
+			}
+			enterpriseSupplierCooperates = resEnterpriseSuppliers
+		}
 	} else if param.Status == 2 { // 邀约中
 		if param.TaskType == 2 {
 			// 品牌种草
@@ -244,6 +270,7 @@ func (s CooperationService) GetSupplierInTargetTaskList(param *vo.SupplierSearch
 			sLocalLifeInfos, total, _ = dao.SLocalLifeDao{}.GetSLocalLifeByStatus(param.TaskId, 2, param.Page, param.PageSize)
 		}
 	}
+	// 针对邀约中、合作中情形
 	if enterpriseSupplierCooperates == nil {
 		if param.TaskType == 2 { // 种草
 			for _, sProjectInfo := range sProjectInfos {
@@ -288,10 +315,10 @@ func (s CooperationService) GetSupplierInTargetTaskList(param *vo.SupplierSearch
 		supplier, err := dao.SupplierDao{}.GetSupplierInfoById(enterpriseSupplierCooperate.SupplierId)
 		var supplierPreview *vo.ReSupplierPreview
 		var phoneNumber string
-		if err == nil {
+		if err == nil && supplier != nil {
 			supplierPreview = &vo.ReSupplierPreview{
 				SupplierId:   supplier.SupplierID,
-				HeadUrl:      "",
+				HeadUrl:      supplier.Avatar,
 				SupplierName: supplier.SupplierName,
 				SupplierType: supplier.SupplierType,
 				CompanyName:  supplier.CompanyName,
@@ -299,19 +326,19 @@ func (s CooperationService) GetSupplierInTargetTaskList(param *vo.SupplierSearch
 				Existence:    true,
 			}
 			phoneNumber = supplier.PhoneNumber
+			reSupplierTargetTask := &vo.ReSupplierTargetTask{
+				SupplierPreview:    supplierPreview,
+				PhoneNumber:        phoneNumber,
+				WechatId:           supplier.WechatNumber,
+				WechatUrl:          supplier.WechatQrcode,
+				CooperateNum:       enterpriseSupplierCooperate.CooperateNum,
+				UploadTalentNum:    enterpriseSupplierCooperate.UploadTalentNum,
+				CooperateTalentNum: enterpriseSupplierCooperate.CooperateTalentNum,
+				EnterpriseOperator: enterpriseOperator,
+				Status:             param.Status,
+			}
+			reSupplierTargetTasks = append(reSupplierTargetTasks, reSupplierTargetTask)
 		}
-		reSupplierTargetTask := &vo.ReSupplierTargetTask{
-			SupplierPreview:    supplierPreview,
-			PhoneNumber:        phoneNumber,
-			WechatId:           "",
-			WechatUrl:          "",
-			CooperateNum:       enterpriseSupplierCooperate.CooperateNum,
-			UploadTalentNum:    enterpriseSupplierCooperate.UploadTalentNum,
-			CooperateTalentNum: enterpriseSupplierCooperate.CooperateTalentNum,
-			EnterpriseOperator: enterpriseOperator,
-			Status:             param.Status,
-		}
-		reSupplierTargetTasks = append(reSupplierTargetTasks, reSupplierTargetTask)
 	}
 	result = vo.ResultVO{
 		Page:     param.Page,
@@ -348,8 +375,9 @@ func (t CooperationService) GetSupplierInTargetCount(param *vo.SupplierSearchInT
 
 // 服务商合作-邀约合作
 func (s CooperationService) InviteSupplierInTargetTask(param *vo.SupplierInviteInTargetTaskParam) error {
-	var sProjectInfo entity.SProjectInfo
+	var err error
 	if param.TaskType == 2 {
+		var sProjectInfo entity.SProjectInfo
 		sProjectInfo.ProjectID = param.TaskId
 		sProjectInfo.SupplierID = param.SupplierId
 		sProjectInfo.SProjectStatus = 1
@@ -379,9 +407,43 @@ func (s CooperationService) InviteSupplierInTargetTask(param *vo.SupplierInviteI
 			//sProjectInfo.ApplyNum = project.ApplyNum
 			//sProjectInfo.RecruitNum = project.RecruitNum
 		}
+		err = dao.SProjectDao{}.Insert(&sProjectInfo)
+
 	} else if param.TaskType == 3 {
 		// 本地生活
+		var sLocalLifeInfo entity.SLocalLifeInfo
+		sLocalLifeInfo.LocalID = param.TaskId
+		sLocalLifeInfo.SupplierID = param.SupplierId
+		sLocalLifeInfo.SLocalStatus = 1
+		t := time.Now()
+		sLocalLifeInfo.CreateTime = &t
+		if param.SubAccountId == 0 {
+			sLocalLifeInfo.BOperator = param.EnterpriseId
+			sLocalLifeInfo.BOperatorType = 1
+		} else {
+			sLocalLifeInfo.BOperator = strconv.Itoa(int(param.SubAccountId))
+			sLocalLifeInfo.BOperatorType = 2
+		}
+		// 查找该 localId 对应的信息
+		localLife, err1 := dao.LocalLifeDao{}.GetLocalById(param.TaskId)
+		if err1 != nil {
+			return err1
+		}
+		if localLife != nil {
+			sLocalLifeInfo.StoreID = localLife.StoreID
+			sLocalLifeInfo.TeamBuyingID = localLife.TeamBuyingId
+			sLocalLifeInfo.LocalName = localLife.LocalName
+			sLocalLifeInfo.TaskStatus = localLife.TaskStatus
+			sLocalLifeInfo.LocalType = localLife.LocalType
+			sLocalLifeInfo.LocalPlatform = localLife.LocalPlatform
+			sLocalLifeInfo.TaskForm = localLife.TaskForm
+			sLocalLifeInfo.ContentType = localLife.ContentType
+			sLocalLifeInfo.EnterpriseID = param.EnterpriseId
+			//sProjectInfo.ApplyNum = project.ApplyNum
+			//sProjectInfo.RecruitNum = project.RecruitNum
+		}
+		err = dao.SLocalLifeDao{}.Insert(&sLocalLifeInfo)
 	}
-	err := dao.SProjectDao{}.Insert(&sProjectInfo)
+
 	return err
 }