yankun 8 miesięcy temu
rodzic
commit
7c9f1c007f
34 zmienionych plików z 1515 dodań i 978 usunięć
  1. 55 31
      app/api/youngee_talent_api/talent_auth_get_api.go
  2. 25 15
      app/api/youngee_talent_api/talent_auth_post_api.go
  3. 154 80
      app/model/youngee_talent_model/project_detail.go
  4. 3 1
      app/model/youngee_talent_model/project_info.go
  5. 3 2
      app/model/youngee_talent_model/selection.go
  6. 4 2
      app/model/youngee_talent_model/selection_task.go
  7. 103 40
      app/model/youngee_talent_model/task_info.go
  8. 89 84
      app/service/youngee_sectask_service/seletion_square.go
  9. 4 3
      app/service/youngee_talent_service/LoginFromSms.go
  10. 3 3
      app/service/youngee_talent_service/SendSmsCode.go
  11. 2 0
      app/service/youngee_talent_service/talent_info.go
  12. 125 55
      app/service/youngee_talent_service/talent_ks_auth.go
  13. 7 6
      app/service/youngee_talent_service/wxlogin.go
  14. 102 7
      app/service/youngee_task_service/project_info.go
  15. 4 1
      app/service/youngee_task_service/task_data.go
  16. 463 286
      app/service/youngee_task_service/task_info.go
  17. 162 160
      app/service/youngee_task_service/task_link.go
  18. 193 192
      app/service/youngee_task_service/task_sketch.go
  19. 9 5
      app/system/sectask/sectask_service.go
  20. BIN
      bin/main
  21. BIN
      bin/v3.5.2/linux_amd64/youngmini_server
  22. BIN
      bin/v3.5.2/windows_amd64/youngmini_server.exe
  23. BIN
      bin/v3.6.0/linux_amd64/youngmini_server
  24. BIN
      bin/v3.6.0/windows_amd64/youngmini_server.exe
  25. BIN
      bin/v3.6.1/linux_amd64/.DS_Store
  26. BIN
      bin/v3.6.1/windows_amd64/youngmini_server.exe
  27. BIN
      bin/v3.7.0/linux_amd64/youngmini_server
  28. BIN
      bin/v3.7.0/windows_amd64/youngmini_server.exe
  29. BIN
      bin/v3.7.1/linux_amd64/youngmini_server
  30. BIN
      bin/v3.7.1/windows_amd64/youngmini_server.exe
  31. 1 1
      config/config.toml
  32. 1 0
      main.go
  33. 1 2
      middleware/middleware_wx_auth.go
  34. 2 2
      router/router.go

+ 55 - 31
app/api/youngee_talent_api/talent_auth_get_api.go

@@ -67,7 +67,6 @@ func (*talentAuthGetApi) GetSingleAddress(r *ghttp.Request) {
 	}
 }
 
-// GetTalentAddress 获取达人社媒账号
 // youngee_platform_account_info
 func (*talentAuthGetApi) GetTalentAccount(r *ghttp.Request) {
 	res := youngee_talent_service.GetTalentAccount(r)
@@ -86,7 +85,7 @@ func (*talentAuthGetApi) GetTalentAccountKuaishou(r *ghttp.Request) {
 	}
 }
 
-// 达人授权二维码展示(包括抖音,快手),需携带platform_id
+// 达人授权二维码获取和展示(包括抖音,快手),需携带platform_id
 func (*talentAuthGetApi) DisplayQrcode(r *ghttp.Request) {
 	res := youngee_talent_service.GetQrcode(r)
 	err := r.Response.WriteJson(res)
@@ -96,6 +95,15 @@ func (*talentAuthGetApi) DisplayQrcode(r *ghttp.Request) {
 
 }
 
+// 达人授权快手电商
+func (*talentAuthGetApi) GetKsEcomQrcode(r *ghttp.Request) {
+	res := youngee_talent_service.GetKsEcomQrcode(r)
+	err := r.Response.WriteJson(res)
+	if err != nil {
+		panic("write response error")
+	}
+}
+
 // 检查表中有无数据
 func (*talentAuthGetApi) CheckAccount(r *ghttp.Request) {
 	res := youngee_talent_service.CheckAccount(r)
@@ -150,25 +158,25 @@ func (*talentAuthGetApi) QuerySalesFor90Days(r *ghttp.Request) {
 	}
 }
 
-// 查询快手总作品数
-func (*talentAuthGetApi) VideoCount(r *ghttp.Request) {
-	res := youngee_talent_service.VideoCount(r)
-	err := r.Response.WriteJson(res)
-	if err != nil {
-		panic("write response error")
-	}
-}
-
-// 查询快手总点赞数
-func (*talentAuthGetApi) LikeCount(r *ghttp.Request) {
-	res := youngee_talent_service.LikeCount(r)
-	err := r.Response.WriteJson(res)
-	if err != nil {
-		panic("write response error")
-	}
-}
+//// 查询快手总作品数
+//func (*talentAuthGetApi) VideoCount(r *ghttp.Request) {
+//	res := youngee_talent_service.VideoCount(r)
+//	err := r.Response.WriteJson(res)
+//	if err != nil {
+//		panic("write response error")
+//	}
+//}
+//
+//// 查询快手总点赞数
+//func (*talentAuthGetApi) LikeCount(r *ghttp.Request) {
+//	res := youngee_talent_service.LikeCount(r)
+//	err := r.Response.WriteJson(res)
+//	if err != nil {
+//		panic("write response error")
+//	}
+//}
 
-// 获取用户快手平台账号列表
+// 账号绑定页面h--获取用户快手平台账号列表
 func (*talentAuthGetApi) GetKuaishouList(r *ghttp.Request) {
 	res := youngee_talent_service.GetKuaishouList(r)
 	err := r.Response.WriteJson(res)
@@ -187,7 +195,6 @@ func (*talentAuthGetApi) GetDouyinList(r *ghttp.Request) {
 }
 
 // 带货---点击添加橱窗---展示可选择的快手信息
-// 带货---免费领样---展示可选择的快手信息
 func (*talentAuthGetApi) AddWindowKuaishouList(r *ghttp.Request) {
 	res := youngee_talent_service.AddWindowKuaishouList(r)
 	err := r.Response.WriteJson(res)
@@ -205,6 +212,15 @@ func (*talentAuthGetApi) SignUpSecKuaishouList(r *ghttp.Request) {
 	}
 }
 
+// 种草---报名页面---展示可选择的快手信息(含是否报名的判断)
+func (*talentAuthGetApi) SignUpProjKuaishouList(r *ghttp.Request) {
+	res := youngee_task_service.SignUpProjKuaishouList(r)
+	err := r.Response.WriteJson(res)
+	if err != nil {
+		panic("write response error")
+	}
+}
+
 // 带货加入橱窗---选中账号---点击提交(选品不存在/未开通)--需要提供productid和openid和粉丝数和销量(他们来自list中)
 func (*talentAuthGetApi) AddWindowWithKsAccount(r *ghttp.Request) {
 	res := youngee_talent_service.AddWindowWithKsAccount(r)
@@ -235,7 +251,6 @@ func (*talentAuthGetApi) IsLogin(r *ghttp.Request) {
 	r.Response.Writeln("islogin接口检查")
 	//此res就是前端中的res
 	res := youngee_talent_service.IsLogin(r)
-
 	err := r.Response.WriteJson(res)
 	if err != nil {
 		panic("write response error")
@@ -251,7 +266,7 @@ func (*talentAuthGetApi) IsSignUpTask(r *ghttp.Request) {
 	}
 }
 
-// 返回所有任务的任务列表
+// 返回所有任务的任务列表--点每个tab都访问这个接口
 func (*talentAuthGetApi) GetTaskBriefList(r *ghttp.Request) {
 	res := youngee_task_service.GetTaskBriefList(r)
 	err := r.Response.WriteJson(res)
@@ -261,13 +276,13 @@ func (*talentAuthGetApi) GetTaskBriefList(r *ghttp.Request) {
 }
 
 // 返回指定任务阶段的任务列表
-func (*talentAuthGetApi) GetTaskExeList(r *ghttp.Request) {
-	res := youngee_task_service.GetExeTaskBriefList(r)
-	err := r.Response.WriteJson(res)
-	if err != nil {
-		panic("write response error")
-	}
-}
+//func (*talentAuthGetApi) GetTaskExeList(r *ghttp.Request) {
+//	res := youngee_task_service.GetExeTaskBriefList(r)
+//	err := r.Response.WriteJson(res)
+//	if err != nil {
+//		panic("write response error")
+//	}
+//}
 
 // 获取任务数量
 func (*talentAuthGetApi) GetTaskExeNum(r *ghttp.Request) {
@@ -355,7 +370,7 @@ func (*talentAuthGetApi) SubmitTaskSketch(r *ghttp.Request) {
 }
 
 // GetUnSubmitTaskSketch 获取未提交的任务初稿
-// younggee_sketch_info
+// younggee_sketch_info  //is_review = 0
 func (*talentAuthGetApi) GetUnsubmitTaskSketch(r *ghttp.Request) {
 	res := youngee_task_service.GetUnSubmitTaskSketch(r)
 	err := r.Response.WriteJson(res)
@@ -638,3 +653,12 @@ func (*talentAuthGetApi) GetSelectionBrowseHistory(r *ghttp.Request) {
 		panic("write response error")
 	}
 }
+
+// // 匹配种草策略,含是否可选属性
+func (*talentAuthGetApi) GetProjRecruitList(r *ghttp.Request) {
+	res := youngee_task_service.GetProjRecruitList(r)
+	err := r.Response.WriteJson(res)
+	if err != nil {
+		panic("write response error")
+	}
+}

+ 25 - 15
app/api/youngee_talent_api/talent_auth_post_api.go

@@ -91,14 +91,6 @@ func (*talentAuthPostApi) UpdateTalentAccount(r *ghttp.Request) {
 	}
 }
 
-func (*talentAuthPostApi) SignUpTask(r *ghttp.Request) {
-	res := youngee_task_service.SignUpTask(r)
-	err := r.Response.WriteJson(res)
-	if err != nil {
-		panic("write response error")
-	}
-}
-
 // OnAddTalentBank 添加银行卡绑定信息
 // younggee_talent_bank
 func (*talentAuthPostApi) AddTalentBank(r *ghttp.Request) {
@@ -109,7 +101,7 @@ func (*talentAuthPostApi) AddTalentBank(r *ghttp.Request) {
 	}
 }
 
-// AddTaskScript 添加脚本
+// AddTaskScript 添加脚本
 // younggee_script_info
 func (*talentAuthPostApi) AddTaskScript(r *ghttp.Request) {
 	res := youngee_task_service.AddTaskScript(r)
@@ -119,7 +111,7 @@ func (*talentAuthPostApi) AddTaskScript(r *ghttp.Request) {
 	}
 }
 
-// AddTaskSketch 添加初稿
+// AddTaskSketch 添加初稿 ,报名后的第一步
 // younggee_sketch_info
 func (*talentAuthPostApi) AddTaskSketch(r *ghttp.Request) {
 	res := youngee_task_service.AddTaskSketch(r)
@@ -210,17 +202,35 @@ func (*talentAuthPostApi) AddYoungTeam(r *ghttp.Request) {
 	}
 }
 
-func (*talentAuthPostApi) SignUpSecTaskFromWindow(r *ghttp.Request) {
-	res := youngee_sectask_service.SignUpSecTaskFromWindow(r)
+//func (*talentAuthPostApi) SignUpSecTaskFromWindow(r *ghttp.Request) {
+//	res := youngee_sectask_service.SignUpSecTaskFromWindow(r)
+//	err := r.Response.WriteJson(res)
+//	if err != nil {
+//		panic("write response error")
+//	}
+//}
+
+// 带货---已选中账号--点击立即报名并加入橱窗
+func (*talentAuthPostApi) SignUpSecTaskWithKsAccount(r *ghttp.Request) {
+	res := youngee_sectask_service.SignUpSecTaskWithKsAccount(r)
 	err := r.Response.WriteJson(res)
 	if err != nil {
 		panic("write response error")
 	}
 }
 
-// 已选中账号--点击立即报名并加入橱窗
-func (*talentAuthPostApi) SignUpSecTaskWithKsAccount(r *ghttp.Request) {
-	res := youngee_sectask_service.SignUpSecTaskWithKsAccount(r)
+// 报名种草 Old Version
+//func (*talentAuthPostApi) SignUpTask(r *ghttp.Request) {
+//	res := youngee_task_service.SignUpTask(r)
+//	err := r.Response.WriteJson(res)
+//	if err != nil {
+//		panic("write response error")
+//	}
+//}
+
+// 种草---已选中账号--点击立即报名并加入橱窗
+func (*talentAuthPostApi) SignUpTaskWithKsAccount(r *ghttp.Request) {
+	res := youngee_task_service.SignUpTaskWithKsAccount(r)
 	err := r.Response.WriteJson(res)
 	if err != nil {
 		panic("write response error")

+ 154 - 80
app/model/youngee_talent_model/project_detail.go

@@ -1,80 +1,154 @@
-package youngee_talent_model
-
-import (
-	"github.com/gogf/gf/util/gmeta"
-
-	"github.com/gogf/gf/os/gtime"
-)
-
-type PlatformInfo struct {
-	gmeta.Meta   `orm:"table:info_third_platform"`
-	PlatformId   int    `json:"platform_id"`
-	PlatformIcon string `json:"platform_icon"`
-	PlatformName string `json:"platform_name"`
-}
-
-type ProductInfo struct {
-	gmeta.Meta    `orm:"table:younggee_product"`
-	ProductId     int             `json:"product_id"`     // 商品id
-	ProductName   string          `json:"product_name"`   // 商品名称
-	ProductType   int             `json:"product_type"`   // 商品类型
-	ShopAddress   string          `json:"shop_address"`   // 店铺地址,商品类型为线下品牌时需填写
-	ProductPrice  int64           `json:"product_price"`  // 商品价值
-	ProductDetail string          `json:"product_detail"` // 商品详情
-	ProductUrl    string          `json:"product_url"`    // 商品链接,可为电商网址、公司官网、大众点评的店铺地址等可以说明商品信息或者品牌信息的线上地址;
-	BrandName     string          `json:"brand_name"`     // 品牌名称
-	ProductPhoto  []*ProductPhoto `orm:"with:product_id=product_id"`
-}
-
-type ProductPhoto struct {
-	gmeta.Meta     `orm:"table:younggee_product_photo"`
-	ProductPhotoId int    `json:"product_photo_id"` // 商品图片id
-	PhotoUrl       string `json:"photo_url"`        // 图片或视频url
-	Symbol         int    `json:"symbol"`           // 图片为主图或详情图标志位,1为主图,2为详情图,3为视频
-	ProductId      int    `json:"product_id"`       // 所属商品id
-}
-
-type RecruitStrategy struct {
-	gmeta.Meta        `orm:"table:recruit_strategy"`
-	RecruitStrategyId int    `json:"recruit_strategy_id"` // 招募策略id
-	FeeForm           int    `json:"fee_form"`            // 稿费形式,1-3分别代表产品置换、固定稿费、自报价
-	StrategyId        int    `json:"strategy_id"`         // 策略id
-	FollowersLow      int    `json:"followers_low"`       // 达人粉丝数下限
-	FollowersUp       int    `json:"followers_up"`        // 达人粉丝数上限
-	RecruitNumber     int    `json:"recruit_number"`      // 招募数量
-	Offer             int    `json:"offer"`               // 报价
-	TOffer            int    `json:"t_offer"`             // 达人报价报价
-	ProjectId         string `json:"project_id"`          // 所属项目id
-	ServiceCharge     int    `json:"service_charge"`      // 平台服务费,稿费形式为产品置换时必填
-}
-
-type ProjectPhoto struct {
-	gmeta.Meta     `orm:"table:project_photo"`
-	ProjectPhotoId int    `json:"project_photo_id"` // 项目图片id
-	PhotoUrl       string `json:"photo_url"`        // 图片url
-	PhotoUid       string `json:"photo_uid"`        //
-	ProjectId      string `json:"project_id"`       // 所属项目id
-	FileName       string `json:"file_name"`        // 文件名称
-}
-
-type ProjectDetail struct {
-	gmeta.Meta       `orm:"table:project_info"`
-	ProjectId        string             `json:"project_id"`                // 项目id
-	ProjectName      string             `json:"project_name"`              // 项目名称
-	ProjectType      int                `json:"project_type"`              // 项目类型,1代表全流程项目,2代表专项项目
-	ProjectStatus    int                `json:"project_status"`            // 项目状态,1-10分别代表创建中、待审核、审核通过、招募中、招募完毕、待支付、已支付、失效、执行中、已结案
-	ProjectPlatform  int                `json:"project_platform"`          // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
-	ProjectForm      int                `json:"project_form"`              // 项目形式,1-4分别代表实体商品寄拍、虚拟产品测评、线下探店打卡、素材微原创
-	TalentType       string             `json:"talent_type"`               // 达人类型
-	RecruitDdl       *gtime.Time        `json:"recruit_ddl"`               // 招募截止时间
-	ContentType      int                `json:"content_type"`              // 内容形式,1代表图文,2代表视频
-	ProjectDetail    string             `json:"project_detail"`            // 项目详情
-	ApplyNum         int                `json:"apply_num"`                 // 报名人数
-	ProductId        int                `json:"product_id"`                // 关联商品id
-	EnterpriseId     string             `json:"enterprise_id"`             // 所属企业id
-	ProjectPhoto     []*ProjectPhoto    `orm:"with:project_id=project_id"` // 项目详情图
-	RecruitStrategy  []*RecruitStrategy `orm:"with:project_id=project_id"` // 招募策略
-	PlatformInfo     *PlatformInfo      `orm:"with:platform_id=project_platform"`
-	ProductSnap      string             `orm:"product_snap"         json:"product_snap"`       // 商品信息快照
-	ProductPhotoSnap string             `orm:"product_photo_snap"   json:"product_photo_snap"` // 商品图片快照
-}
+package youngee_talent_model
+
+import (
+	"github.com/gogf/gf/os/gtime"
+	"github.com/gogf/gf/util/gmeta"
+)
+
+type PlatformInfo struct {
+	gmeta.Meta   `orm:"table:info_third_platform"`
+	PlatformId   int    `json:"platform_id"`
+	PlatformIcon string `json:"platform_icon"`
+	PlatformName string `json:"platform_name"`
+}
+
+type ProductInfo struct {
+	gmeta.Meta    `orm:"table:younggee_product"`
+	ProductId     int             `json:"product_id"`     // 商品id
+	ProductName   string          `json:"product_name"`   // 商品名称
+	ProductType   int             `json:"product_type"`   // 商品类型
+	ShopAddress   string          `json:"shop_address"`   // 店铺地址,商品类型为线下品牌时需填写
+	ProductPrice  int64           `json:"product_price"`  // 商品价值
+	ProductDetail string          `json:"product_detail"` // 商品详情
+	ProductUrl    string          `json:"product_url"`    // 商品链接,可为电商网址、公司官网、大众点评的店铺地址等可以说明商品信息或者品牌信息的线上地址;
+	BrandName     string          `json:"brand_name"`     // 品牌名称
+	ProductPhoto  []*ProductPhoto `orm:"with:product_id=product_id"`
+}
+
+type ProductPhoto struct {
+	gmeta.Meta     `orm:"table:younggee_product_photo"`
+	ProductPhotoId int    `json:"product_photo_id"` // 商品图片id
+	PhotoUrl       string `json:"photo_url"`        // 图片或视频url
+	Symbol         int    `json:"symbol"`           // 图片为主图或详情图标志位,1为主图,2为详情图,3为视频
+	ProductId      int    `json:"product_id"`       // 所属商品id
+}
+
+type RecruitStrategy struct {
+	gmeta.Meta        `orm:"table:recruit_strategy"`
+	RecruitStrategyId int    `json:"recruit_strategy_id"` // 招募策略id
+	FeeForm           int    `json:"fee_form"`            // 稿费形式,1-3分别代表产品置换、固定稿费、自报价
+	StrategyId        int    `json:"strategy_id"`         // 策略id
+	FollowersLow      int    `json:"followers_low"`       // 达人粉丝数下限
+	FollowersUp       int    `json:"followers_up"`        // 达人粉丝数上限
+	RecruitNumber     int    `json:"recruit_number"`      // 招募数量
+	Offer             int    `json:"offer"`               // 报价
+	TOffer            int    `json:"t_offer"`             // 达人报价报价
+	ProjectId         string `json:"project_id"`          // 所属项目id
+	ServiceCharge     int    `json:"service_charge"`      // 平台服务费,稿费形式为产品置换时必填
+	IsFit             int    `json:"is_fit"`              //此策略是否匹配成功
+}
+
+// 种草brief
+type ProjectBrief struct {
+	gmeta.Meta     `orm:"table:project_brief"`
+	ProjectBriefId int    `json:"project_brief_id"` // 项目图片id
+	PhotoUrl       string `json:"photo_url"`        // 图片url
+	PhotoUid       string `json:"photo_uid"`        //
+	ProjectId      string `json:"project_id"`       // 所属项目id
+	FileName       string `json:"file_name"`        // 文件名称
+}
+
+// 种草素材
+type ProjectMaterial struct {
+	gmeta.Meta `orm:"table:project_material"`
+	Material   int    `json:"material_id"` // 项目图片id
+	PhotoUrl   string `json:"photo_url"`   // 图片url
+	PhotoUid   string `json:"photo_uid"`   //
+	ProjectId  string `json:"project_id"`  // 所属项目id
+	FileName   string `json:"file_name"`   // 文件名称
+}
+
+// 商家表
+type Enterprise struct {
+	gmeta.Meta       `orm:"table:enterprise"`
+	EnterpriseId     int         `orm:"enterprise_id" json:"enterprise_id"`             // 企业id,用户ID的生成规则为:1(企业用户代码)+分秒数字+四位随机数字
+	Industry         int         `orm:"industry"              json:"industry"`          // 行业,1-14分别代表能源、化工、材料、机械设备/军工、企业服务/造纸印刷、运输设备、旅游酒店、媒体/信息通信服务、批发/零售、消费品、卫生保健/医疗、金融、建材/建筑/房地产、公共事业
+	BusinessName     string      `orm:"business_name"         json:"business_name"`     // 公司或组织名称
+	UserId           int         `orm:"user_id,unique"        json:"user_id"`           // 对应用户id
+	Balance          float64     `orm:"balance"               json:"balance"`           // 账户余额
+	FrozenBalance    float64     `orm:"frozen_balance"        json:"frozen_balance"`    // 冻结余额
+	AvailableBalance float64     `orm:"available_balance"     json:"available_balance"` // 可用余额
+	BillableAmount   float64     `orm:"billable_amount"       json:"billable_amount"`   // 可开票金额
+	Invoicing        float64     `orm:"invoicing"             json:"invoicing"`         // 开票中金额
+	Recharging       float64     `orm:"recharging"            json:"recharging"`        // 充值中金额
+	CreatedAt        *gtime.Time `orm:"created_at"            json:"created_at"`        // 创建时间
+	UpdatedAt        *gtime.Time `orm:"updated_at"            json:"updated_at"`        // 更新时间
+	AuthStatus       int         `orm:"auth_status"            json:"auth_status"`      // 商家认证状态,0未认证,1已认证
+}
+
+type YounggeeSupplier struct {
+	gmeta.Meta      `orm:"table:younggee_supplier"`
+	SupplierId      int    `orm:"supplier_id" json:"supplier_id"`                    // 服务商ID
+	SupplierName    string `orm:"supplier_name"             json:"supplier_name"`    // 服务商名称
+	PhoneNumber     string `orm:"phone_number"              json:"phone_number"`     // 手机号
+	BusinessLicense string `orm:"business_license"          json:"business_license"` // 营业执照url
+	USCI            string `orm:"usci"                      json:"usci"`             // 统一社会信用代码
+	CompanyName     string `orm:"company_name"              json:"company_name"`     // 公司名称
+	IdFront         string `orm:"id_front"                  json:"id_front"`         // 身份证人像面url
+	IdBack          string `orm:"id_back"                   json:"id_back"`          // 身份证国徽面url
+	IdNumber        string `orm:"id_number"                 json:"id_number"`        // 身份证号
+	Name            string `orm:"name"                      json:"name"`             // 姓名
+	UserId          int    `orm:"user_id"                   json:"user_id"`          // 用户表中的用户ID
+	SupplierType    int    `orm:"supplier_type"             json:"supplier_type"`    // 服务商用户类型,1为个人PR,2为机构
+}
+
+// 服务商接手的项目信息
+type ProjectInfoSupplier struct {
+	gmeta.Meta          `orm:"table:younggee_s_project_info"`
+	SProjectID          int     `orm:"s_project_id" json:"s_project_id"`                   // 服务商种草任务ID
+	ProjectID           string  `orm:"project_id" json:"project_id"`                       // 被服务商加入商单的原种草任务ID
+	ProjectStatus       int8    `orm:"project_status" json:"project_status"`               // 项目状态
+	ProjectType         int8    `orm:"project_type" json:"project_type"`                   // 种草任务类型
+	ProjectName         string  `orm:"project_name" json:"project_name"`                   // 种草任务名称
+	ProjectPlatform     int8    `orm:"project_platform" json:"project_platform"`           // 种草任务平台
+	ProjectForm         int8    `orm:"project_form" json:"project_form"`                   // 任务形式
+	ContentType         int8    `orm:"content_type" json:"content_type"`                   // 内容形式
+	ShareCode           string  `orm:"share_code" json:"share_code"`                       // 分享码URL
+	SupplierID          int     `orm:"supplier_id" json:"supplier_id"`                     // 服务商ID
+	EnterpriseID        string  `orm:"enterprise_id" json:"enterprise_id"`                 // 所属企业ID
+	ApplyNum            int     `orm:"apply_num" json:"apply_num"`                         // 报名人数
+	RecruitNum          int     `orm:"recruit_num" json:"recruit_num"`                     // 已招募人数
+	SettleNum           int     `orm:"settle_num" json:"settle_num"`                       // 已结算人数
+	SubAccountID        int     `orm:"sub_account_id" json:"sub_account_id"`               // 服务商子账号ID
+	ServiceCharge       float64 `orm:"service_charge" json:"service_charge"`               // 服务商预估可赚服务费
+	ServiceChargeActual float64 `orm:"service_charge_actual" json:"service_charge_actual"` // 服务商实际可赚服务费
+	OperatorType        int     `orm:"operator_type" json:"operator_type"`
+}
+
+type ProjectDetail struct {
+	gmeta.Meta          `orm:"table:project_info"`
+	ProjectId           string               `json:"project_id"`                                    // 项目id
+	ProjectName         string               `json:"project_name"`                                  // 项目名称
+	ProjectType         int                  `json:"project_type"`                                  // 项目类型,1代表全流程项目,2代表专项项目
+	ProjectStatus       int                  `json:"project_status"`                                // 项目状态,1-10分别代表创建中、待审核、审核通过、招募中、招募完毕、待支付、已支付、失效、执行中、已结案
+	ProjectPlatform     int                  `json:"project_platform"`                              // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	ProjectForm         int                  `json:"project_form"`                                  // 项目形式,1-4分别代表实体商品寄拍、虚拟产品测评、线下探店打卡、素材微原创
+	TalentType          string               `json:"talent_type"`                                   // 达人类型
+	RecruitDdl          *gtime.Time          `json:"recruit_ddl"`                                   // 招募截止时间
+	ContentType         int                  `json:"content_type"`                                  // 内容形式,1代表图文,2代表视频
+	ProjectDetail       string               `json:"project_detail"`                                // 项目详情
+	ApplyNum            int                  `json:"apply_num"`                                     // 报名人数
+	ProductId           int                  `json:"product_id"`                                    // 关联商品id
+	EnterpriseId        string               `json:"enterprise_id"`                                 // 所属企业id
+	SupplierId          string               `json:"supplier_id"`                                   //所属服务商id
+	WatchedNum          int                  `json:"watched_num"`                                   // 浏览量
+	ProjectBrief        []*ProjectBrief      `orm:"with:project_id=project_id"`                     // 项目brief图
+	ProjectMaterial     []*ProjectMaterial   `orm:"with:project_id=project_id"`                     // 项目brief图
+	RecruitStrategy     []*RecruitStrategy   `orm:"with:project_id=project_id"`                     // 招募策略
+	Enterprise          *Enterprise          `orm:"with:enterprise_id=enterprise_id"`               // 商家信息
+	ProjectInfoSupplier *ProjectInfoSupplier `orm:"with:project_id=project_id"`                     //服务商项目特有信息
+	YounggeeSupplier    *YounggeeSupplier    `orm:"with:supplier_id=supplier_id"`                   // 服务商信息
+	PlatformInfo        *PlatformInfo        `orm:"with:platform_id=project_platform"`              //平台信息,目前为快手
+	ProductSnap         string               `orm:"product_snap"         json:"product_snap"`       // 商品信息快照
+	ProductPhotoSnap    string               `orm:"product_photo_snap"   json:"product_photo_snap"` // 商品图片快照
+}

+ 3 - 1
app/model/youngee_talent_model/project_info.go

@@ -26,10 +26,11 @@ type ProjectInfo struct {
 	ProjectDetail    string             `json:"project_detail"`   // 项目详情
 	RecruitNum       int                `json:"recruit_num"`      //
 	ApplyNum         int                `json:"apply_num"`        //
-	EnterpriseId     int                `json:"enterprise_id"`    // 所属企业id
+	EnterpriseId     string             `json:"enterprise_id"`    // 所属企业id
 	ProductId        int                `json:"product_id"`       // 关联商品id
 	WatchedNum       int                `json:"watched_num"`      // 浏览量
 	RecruitStrategys []*RecruitStrategy `orm:"with:project_id=project_id"`
+	Enterprise       *Enterprise        `orm:"with:enterprise_id=enterprise_id"`
 	ProductSnap      string             `orm:"product_snap"         json:"product_snap"`       // 商品信息快照
 	ProductPhotoSnap string             `orm:"product_photo_snap"   json:"product_photo_snap"` // 商品图片快照
 }
@@ -53,4 +54,5 @@ type ProjectCollectionInfoList struct {
 type ProjectInfoList struct {
 	MaxPage      int `json:"max_page"`
 	ProjectInfos []*ProjectInfo
+	//ProjectDetail []*ProjectDetail
 }

+ 3 - 2
app/model/youngee_talent_model/selection.go

@@ -86,8 +86,8 @@ type SelectionBrief struct {
 }
 
 type SelectionExample struct {
-	gmeta.Meta  `orm:"table:younggee_sec_example"`
-	ExampleId   int         `json:"example_id"`   // 选品示例图id
+	gmeta.Meta  `orm:"table:younggee_sec_material"`
+	MaterialId  int         `json:"material_id"`  // 选品示例图id
 	FileUrl     string      `json:"file_url"`     // 文件url
 	FileUid     string      `json:"file_uid"`     // 文件uid
 	SelectionId string      `json:"selection_id"` // 所属选品id
@@ -133,6 +133,7 @@ type SelectionDetail struct {
 	YounggeeProduct      []*YounggeeProduct      `orm:"with:product_id=product_id"`     // 商品基本表
 	YounggeeProductPhoto []*YounggeeProductPhoto `orm:"with:product_id=product_id"`     // 商品图片表
 	PlatformInfo         *PlatformInfo           `orm:"with:platform_id=platform"`      //一个selection只有一个平台,直接指针对象object
+	EnterpriseInfo       *Enterprise             `orm:"with:enterprise_id=enterprise_id"`
 }
 
 // 种草收藏列表

+ 4 - 2
app/model/youngee_talent_model/selection_task.go

@@ -15,6 +15,7 @@ type SignSecTaskReq struct {
 	SaleNum     int    `json:"saleNum"`
 	FansNum     int    `json:"fans"`
 	OpenId      string `json:"open_id"`
+	IsOk        int    `json:"is_ok"` //此快手是否满足领样条件 0不满足,1满足
 }
 
 type SignSecTaskResp struct {
@@ -26,7 +27,7 @@ type SecTaskInfoDetail struct {
 	Id                     int                          `orm:"id,primary"                json:"id"`           // 递增id
 	TaskId                 string                       `orm:"task_id"                   json:"task_id"`      // 选品任务id
 	SelectionId            string                       `orm:"selection_id"              json:"selection_id"` // 选品id
-	OpenId                 string                       `orm:"open_id"                  json:"open_id"`       //快手唯一标识
+	OpenId                 string                       `orm:"open_id"                   json:"open_id"`      //快手唯一标识
 	ProductId              string                       `orm:"product_id"                json:"product_id"`
 	TalentId               string                       `orm:"talent_id"                 json:"talent_id"`                 // 达人id
 	AccountId              int                          `orm:"account_id"                json:"account_id"`                // 账号id
@@ -66,7 +67,8 @@ type SecTaskInfoDetail struct {
 	SelectionInfo          *model.YounggeeSelectionInfo `orm:"with:selection_id=selection_id"`                  //选品表
 	YounggeeProduct        *YounggeeProduct             `orm:"with:product_id=product_id"`                      // 商品基本表
 	YounggeeProductPhoto   []*YounggeeProductPhoto      `orm:"with:product_id=product_id"`                      // 商品图片表
-	PlatformInfo           *PlatformInfo                `orm:"with:platform_id=platform_id"`
+	PlatformInfo           *PlatformInfo                `orm:"with:platform_id=platform_id"`                    //platform_id=8的是快手平台信息,含有粉丝数和作品数
+	KsUserInfo             []*KuaishouUserInfo          `orm:"with:open_id=open_id"`
 	TaskDdl                *gtime.Time                  `json:"task_ddl"`
 }
 

+ 103 - 40
app/model/youngee_talent_model/task_info.go

@@ -1,63 +1,126 @@
 package youngee_talent_model
 
 import (
-	"youngmini_server/app/model"
-
 	"github.com/gogf/gf/util/gmeta"
+	"youngmini_server/app/model"
 
 	"github.com/gogf/gf/os/gtime"
 )
 
+//	type YoungeeTaskInfo struct {
+//		gmeta.Meta             `orm:"table:youngee_task_info"`
+//		TaskId                 string      `json:"task_id"`                   // 任务id
+//		ProjectId              string      `json:"project_id"`                // 项目id
+//		TalentId               string      `json:"talent_id"`                 // 达人id
+//		OpenId                 string      `json:"open_id"`                   //快手唯一标识
+//		TalentPlatformInfoSnap string      `json:"talent_platform_info_snap"` // 达人平台信息快照
+//		TalentPersonalInfoSnap string      `json:"talent_personal_info_snap"` // 达人个人信息快照
+//		TalentPostAddrSnap     string      `json:"talent_post_addr_snap"`     // 收货地址快照
+//		StrategyId             int         `json:"strategy_id"`               // 报名选择的招募策略id
+//		TaskReward             float64     `json:"task_reward"`               // 达人报酬
+//		SettleAmount           float64     `json:"settle_amount"`             // 达人实际所得(扣除违约扣款)
+//		AllPayment             float64     `json:"all_payment"`               // 企业支付
+//		RealPayment            float64     `json:"real_payment"`              // 企业实际支付(扣除违约扣款)
+//		Penalty                int         `json:"penalty"`                   // 违约扣款比例,百分之
+//		FeeForm                int         `json:"fee_form"`                  // 稿费形式,1,2,3分别代表产品置换、固定稿费、自报价
+//		ServiceCharge          float64     `json:"service_charge"`            // 服务费
+//		ServiceRate            int         `json:"service_rate"`              // 服务费率,千分之
+//		TaskStatus             int         `json:"task_status"`               // 任务状态 1待选 2已选 3落选
+//		TaskStage              int         `json:"task_stage"`                // 任务阶段
+//		CreateDate             *gtime.Time `json:"create_date"`               // 创建时间
+//		SelectDate             *gtime.Time `json:"select_date"`               // 反选时间
+//		CompleteStatus         int         `json:"complete_status"`           // 结束方式 1未结束 2正常结束 3反选失败 4被解约
+//		CompleteDate           *gtime.Time `json:"complete_date"`             // 结束时间
+//	}
 type YoungeeTaskInfo struct {
 	gmeta.Meta             `orm:"table:youngee_task_info"`
-	TaskId                 string      `json:"task_id"`                   // 任务id
-	ProjectId              string      `json:"project_id"`                // 项目id
-	TalentId               string      `json:"talent_id"`                 // 达人id
-	AccountId              int         `json:"account_id"`                // 账号id
-	TalentPlatformInfoSnap string      `json:"talent_platform_info_snap"` // 达人平台信息快照
-	TalentPersonalInfoSnap string      `json:"talent_personal_info_snap"` // 达人个人信息快照
-	TalentPostAddrSnap     string      `json:"talent_post_addr_snap"`     // 收货地址快照
-	StrategyId             int         `json:"strategy_id"`               // 报名选择的招募策略id
-	TaskReward             float64     `json:"task_reward"`               // 达人报酬
-	SettleAmount           float64     `json:"settle_amount"`             // 达人实际所得(扣除违约扣款)
-	AllPayment             float64     `json:"all_payment"`               // 企业支付
-	RealPayment            float64     `json:"real_payment"`              // 企业实际支付(扣除违约扣款)
-	Penalty                int         `json:"penalty"`                   // 违约扣款比例,百分之
-	FeeForm                int         `json:"fee_form"`                  // 稿费形式,1,2,3分别代表产品置换、固定稿费、自报价
-	ServiceCharge          float64     `json:"service_charge"`            // 服务费
-	ServiceRate            int         `json:"service_rate"`              // 服务费率,千分之
-	TaskStatus             int         `json:"task_status"`               // 任务状态 1待选 2已选 3落选
-	TaskStage              int         `json:"task_stage"`                // 任务阶段
-	CreateDate             *gtime.Time `json:"create_date"`               // 创建时间
-	SelectDate             *gtime.Time `json:"select_date"`               // 反选时间
-	CompleteStatus         int         `json:"complete_status"`           // 结束方式 1未结束 2正常结束 3反选失败 4被解约
-	CompleteDate           *gtime.Time `json:"complete_date"`             // 结束时间
+	TaskId                 string         `json:"task_id"`                   // 任务ID
+	ProjectId              string         `json:"project_id"`                // 项目ID
+	TalentId               string         `json:"talent_id"`                 // 达人ID
+	AccountId              int            `json:"account_id"`                // 账号ID
+	OpenId                 string         `json:"open_id"`                   // 快手唯一标识
+	StrategyId             int            `json:"strategy_id"`               // 报名选择的招募策略ID
+	TalentPlatformInfoSnap string         `json:"talent_platform_info_snap"` // 达人平台信息快照
+	TalentPersonalInfoSnap string         `json:"talent_personal_info_snap"` // 达人个人信息快照
+	TalentPostAddrSnap     string         `json:"talent_post_addr_snap"`     // 收货地址快照
+	TaskReward             float64        `json:"task_reward"`               // 达人报酬
+	SettleAmount           int            `json:"settle_amount"`             // 达人实际所得(扣除违约扣款)
+	AllPayment             float64        `json:"all_payment"`               // 企业支付总额
+	RealPayment            float64        `json:"real_payment"`              // 企业实际支付(扣除违约扣款)
+	ServiceRate            int            `json:"service_rate"`              // 服务费率(千分比)
+	ServiceCharge          float64        `json:"service_charge"`            // 服务费
+	FeeForm                int            `json:"fee_form"`                  // 稿费形式 1: 产品置换 2: 固定稿费 3: 自报价
+	ErrBreakRate           int            `json:"err_break_rate"`            // 未上传类型违约扣款比例(百分比)
+	ScriptBreakRate        int            `json:"script_break_rate"`         // 脚本超时违约扣款比例(百分比)
+	SketchBreakRate        int            `json:"sketch_break_rate"`         // 初稿超时违约扣款比例(百分比)
+	LinkBreakRate          int            `json:"link_break_rate"`           // 链接超时违约扣款比例(百分比)
+	DataBreakRate          int            `json:"data_break_rate"`           // 数据超时违约扣款比例(百分比)
+	TaskStage              int            `json:"task_stage"`                // 任务阶段
+	TaskStatus             int            `json:"task_status"`               // 商家任务状态 1: 待选 2: 已选 3: 落选
+	LogisticsStatus        int            `json:"logistics_status"`          // 发货状态 1: 待发货 2: 已发货 3: 已签收
+	ScriptStatus           int            `json:"script_status"`             // 脚本上传状态 1-5 表示各阶段
+	SketchStatus           int            `json:"sketch_status"`             // 初稿上传状态 1-5 表示各阶段
+	LinkStatus             int            `json:"link_status"`               // 链接上传状态 1-5 表示各阶段
+	DataStatus             int            `json:"data_status"`               // 数据上传状态 1-5 表示各阶段
+	CompleteStatus         int            `json:"complete_status"`           // 结束方式 1: 未结束 2: 正常结束 3: 反选失败 4: 被解约
+	UpdateAt               *gtime.Time    `json:"update_at"`                 // 更新时间
+	CreateDate             *gtime.Time    `json:"create_date"`               // 创建时间
+	SelectDate             *gtime.Time    `json:"select_date"`               // 反选时间
+	DeliveryDate           *gtime.Time    `json:"delivery_date"`             // 发货时间
+	CompleteDate           *gtime.Time    `json:"complete_date"`             // 结束时间
+	WithdrawDate           *gtime.Time    `json:"withdraw_date"`             // 提现时间
+	CurDefaultType         int            `json:"cur_default_type"`          // 当前处于的违约类型
+	WithdrawStatus         int            `json:"withdraw_status"`           // 提现状态 1-4 表示不同状态
+	LeadTeamId             string         `json:"lead_team_id"`              // 团长young之团ID
+	TeamId                 string         `json:"team_id"`                   // 团员young之团ID
+	SettleStatus           int            `json:"settle_status"`             // 结算状态 1: 待结算 2: 已结算
+	TeamIncome             float64        `json:"team_income"`               // 团长现金收益
+	TeamPoint              int            `json:"team_point"`                // 团长积分收益
+	CurBreakAt             *gtime.Time    `json:"cur_break_at"`              // 当前阶段截止时间
+	SupplierId             int            `json:"supplier_id"`               // 服务商ID
+	SupplierStatus         int            `json:"supplier_status"`           // 服务商任务状态
+	DraftFee               int            `json:"draft_fee"`                 // 达人稿费
+	SignedTime             *gtime.Time    `json:"signed_time"`               // 签收时间
+	FansNum                int            `json:"fans_num"`                  // 粉丝数
+	VoteAvg                int            `json:"vote_avg"`                  // 平均点赞数
+	CommitAvg              int            `json:"commit_avg"`                // 平均评论数
+	BOperator              string         `json:"b_operator"`                // 商家确定达人操作人ID
+	BOperatorType          int            `json:"b_operator_type"`           // 商家操作人类型
+	SOperator              int            `json:"s_operator"`                // 服务商提报达人操作人ID
+	SOperatorType          int            `json:"s_operator_type"`           // 服务商操作人类型
+	SProjectId             int            `json:"s_project_id"`              // 服务商种草任务ID
+	ProjectDetail          *ProjectDetail `json:"project_detail"`            //项目详情
 }
 
 type SignTaskInfo struct {
 	ProjectId  string `json:"project_id"`
+	OpenID     string `json:"open_id"` //选中快手账号唯一标识
 	AddressId  uint64 `json:"address_id"`
 	StrategyId int    `json:"strategy_id"`
 	Offer      int    `json:"offer"`
 }
 
 type TaskInfoBrief struct {
-	TaskId           string      `json:"task_id"`
-	PlatformIconUrl  string      `json:"platform_icon_url"`
-	PlatformName     string      `json:"platform_name"`
-	PlatformNickName string      `json:"platform_nick_name"`
-	ProjectName      string      `json:"project_name"`
-	ProductPhotoSnap string      `json:"product_photo_snap"`
-	TaskStatus       int         `json:"task_status"`
-	TaskStage        int         `json:"task_stage"`
-	ScriptStatus     uint        `json:"script_status"` // 脚本上传状态 1-5分别代表待添加、已添加、待修改、已修改、已通过
-	SketchStatus     uint        `json:"sketch_status"` // 初稿上传状态 1-5分别代表待添加、已添加、待修改、已修改、已通过
-	LinkStatus       uint        `json:"link_status"`   // 链接上传状态 1-5分别代表待添加、已添加、待修改、已修改、已通过
-	DataStatus       uint        `json:"data_status"`   // 数据上传状态 1-5分别代表待添加、已添加、待修改、已修改、已通过
-	TaskReward       float64     `json:"task_reward"`   // 达人报酬
-	BreakRate        int         `json:"break_rate"`    // 违约扣款比例,百分之
-	CurBreakAt       *gtime.Time `json:"cur_break_at"`  // 当前阶段截止时间
-	FeeForm          int         `json:"fee_form"`      // 稿费形式,1,2,3分别代表产品置换、固定稿费、自报价
+	TaskId           string            `json:"task_id"`
+	PlatformIconUrl  string            `json:"platform_icon_url"`
+	PlatformName     string            `json:"platform_name"`
+	PlatformNickName string            `json:"platform_nick_name"`
+	ProjectName      string            `json:"project_name"`
+	ProductPhotoSnap string            `json:"product_photo_snap"`
+	TaskStatus       int               `json:"task_status"`
+	TaskStage        int               `json:"task_stage"`
+	ScriptStatus     int               `json:"script_status"` // 脚本上传状态 1-5分别代表待添加、已添加、待修改、已修改、已通过
+	SketchStatus     int               `json:"sketch_status"` // 初稿上传状态 1-5分别代表待添加、已添加、待修改、已修改、已通过
+	LinkStatus       int               `json:"link_status"`   // 链接上传状态 1-5分别代表待添加、已添加、待修改、已修改、已通过
+	DataStatus       int               `json:"data_status"`   // 数据上传状态 1-5分别代表待添加、已添加、待修改、已修改、已通过
+	TaskReward       float64           `json:"task_reward"`   // 达人报酬
+	BreakRate        int               `json:"break_rate"`    // 违约扣款比例,百分之
+	CurBreakAt       *gtime.Time       `json:"cur_break_at"`  // 当前阶段截止时间
+	FeeForm          int               `json:"fee_form"`      // 稿费形式,1,2,3分别代表产品置换、固定稿费、自报价
+	ProjectDetail    *ProjectDetail    `json:"project_detail"`
+	AccountInfo      *KuaishouUserInfo `json:"account_info"` //报名平台账号信息
+	TaskInfo         *YoungeeTaskInfo  `json:"task_info"`
+	SignUpTime       *gtime.Time       `json:"sign_up_time"` //报名时间
 }
 
 type TaskInfoBriefList struct {

+ 89 - 84
app/service/youngee_sectask_service/seletion_square.go

@@ -6,7 +6,6 @@ import (
 	"fmt"
 	"github.com/gogf/gf/database/gdb"
 	"github.com/lin-jim-leon/kuaishou/open/merchant"
-	"reflect"
 	"youngmini_server/app/dao"
 	"youngmini_server/app/model"
 	"youngmini_server/app/model/youngee_talent_model"
@@ -47,46 +46,46 @@ func GetSelectionList(r *ghttp.Request) *TalentHttpResult {
 	pageIndex := r.GetQueryInt("idx", -1)
 	cntPerPage := r.GetQueryInt("cnt", -1)
 	//platform := r.Get("platform")
-	secForm := r.Get("secform")
-	taskForm := r.Get("taskform")
-	categoryForm := r.Get("categoryform")
-	searchValue := r.Get("searchvalue")
-	if pageIndex == -1 || cntPerPage == -1 || cntPerPage == 0 {
-		return &TalentHttpResult{Code: -1, Msg: "参数错误"}
-	}
-
-	// 如果有领样形式的过滤条件,则将过滤条件保存于secFormList
-	var secFormList []interface{}
-	if secForm != nil {
-		if reflect.TypeOf(secForm).Kind() != reflect.Slice {
-			return &TalentHttpResult{Code: -2, Msg: "搜索条件领样形式错误"}
-		}
-
-		secFormList = make([]interface{}, 0)
-		secFormList = secForm.([]interface{})
-	}
-
-	// 如果有任务形式的过滤条件,则将过滤条件保存于taskFormList
-	var taskFormList []interface{}
-	if taskForm != nil {
-		if reflect.TypeOf(taskForm).Kind() != reflect.Slice {
-			return &TalentHttpResult{Code: -2, Msg: "搜索条件任务形式错误"}
-		}
-
-		taskFormList = make([]interface{}, 0)
-		taskFormList = taskForm.([]interface{})
-	}
-
-	// 如果有商品类目的过滤条件,则将过滤条件保存于categoryFormList
-	var categoryFormList []interface{}
-	if categoryForm != nil {
-		if reflect.TypeOf(categoryForm).Kind() != reflect.Slice {
-			return &TalentHttpResult{Code: -2, Msg: "搜索条件任务形式错误"}
-		}
-
-		categoryFormList = make([]interface{}, 0)
-		categoryFormList = categoryForm.([]interface{})
-	}
+	//secForm := r.Get("secform")
+	//taskForm := r.Get("taskform")
+	//categoryForm := r.Get("categoryform")
+	//searchValue := r.Get("searchvalue")
+	//if pageIndex == -1 || cntPerPage == -1 || cntPerPage == 0 {
+	//	return &TalentHttpResult{Code: -1, Msg: "参数错误"}
+	//}
+	//
+	//// 如果有领样形式的过滤条件,则将过滤条件保存于secFormList
+	//var secFormList []interface{}
+	//if secForm != nil {
+	//	if reflect.TypeOf(secForm).Kind() != reflect.Slice {
+	//		return &TalentHttpResult{Code: -2, Msg: "搜索条件领样形式错误"}
+	//	}
+	//
+	//	secFormList = make([]interface{}, 0)
+	//	secFormList = secForm.([]interface{})
+	//}
+	//
+	//// 如果有任务形式的过滤条件,则将过滤条件保存于taskFormList
+	//var taskFormList []interface{}
+	//if taskForm != nil {
+	//	if reflect.TypeOf(taskForm).Kind() != reflect.Slice {
+	//		return &TalentHttpResult{Code: -2, Msg: "搜索条件任务形式错误"}
+	//	}
+	//
+	//	taskFormList = make([]interface{}, 0)
+	//	taskFormList = taskForm.([]interface{})
+	//}
+	//
+	//// 如果有商品类目的过滤条件,则将过滤条件保存于categoryFormList
+	//var categoryFormList []interface{}
+	//if categoryForm != nil {
+	//	if reflect.TypeOf(categoryForm).Kind() != reflect.Slice {
+	//		return &TalentHttpResult{Code: -2, Msg: "搜索条件任务形式错误"}
+	//	}
+	//
+	//	categoryFormList = make([]interface{}, 0)
+	//	categoryFormList = categoryForm.([]interface{})
+	//}
 
 	// 如果有平台的过滤条件,则将平台列表保存于platformList  弃用
 	/*	var platformList []interface{}
@@ -112,39 +111,39 @@ func GetSelectionList(r *ghttp.Request) *TalentHttpResult {
 		whereStr += ")"
 	}*/
 
-	if taskFormList != nil {
-		whereStr += " and task_mode in ("
-		for _, v := range taskFormList {
-			whereStr += v.(string) + ", "
-		}
-
-		whereStr = whereStr[0 : len(whereStr)-2]
-		whereStr += ")"
-	}
-	if secFormList != nil {
-		whereStr += " and sample_mode in ("
-		for _, v := range secFormList {
-			whereStr += v.(string) + ", "
-		}
-
-		whereStr = whereStr[0 : len(whereStr)-2]
-		whereStr += ")"
-	}
-
-	if categoryFormList != nil {
-		whereStr += " and product_category in ("
-		for _, v := range categoryFormList {
-			whereStr += v.(string) + ", "
-		}
-
-		whereStr = whereStr[0 : len(whereStr)-2]
-		whereStr += ")"
-	}
-
-	//搜索栏
-	if searchValue != nil {
-		whereStr += " and selection_name like '%" + searchValue.(string) + "%'"
-	}
+	//if taskFormList != nil {
+	//	whereStr += " and task_mode in ("
+	//	for _, v := range taskFormList {
+	//		whereStr += v.(string) + ", "
+	//	}
+	//
+	//	whereStr = whereStr[0 : len(whereStr)-2]
+	//	whereStr += ")"
+	//}
+	//if secFormList != nil {
+	//	whereStr += " and sample_mode in ("
+	//	for _, v := range secFormList {
+	//		whereStr += v.(string) + ", "
+	//	}
+	//
+	//	whereStr = whereStr[0 : len(whereStr)-2]
+	//	whereStr += ")"
+	//}
+	//
+	//if categoryFormList != nil {
+	//	whereStr += " and product_category in ("
+	//	for _, v := range categoryFormList {
+	//		whereStr += v.(string) + ", "
+	//	}
+	//
+	//	whereStr = whereStr[0 : len(whereStr)-2]
+	//	whereStr += ")"
+	//}
+
+	////搜索栏
+	//if searchValue != nil {
+	//	whereStr += " and selection_name like '%" + searchValue.(string) + "%'"
+	//}
 
 	// 查询所有selection
 	//YounggeeSelectionInfo含有表中的所有属性
@@ -155,9 +154,9 @@ func GetSelectionList(r *ghttp.Request) *TalentHttpResult {
 	if err != nil {
 		return &TalentHttpResult{Code: -3, Msg: "查询数据库失败"}
 	}
-	fmt.Println("****searchValue:", searchValue)
-	fmt.Println("****secFormList:", secFormList)
-	fmt.Println("****taskFormList:", taskFormList)
+	//fmt.Println("****searchValue:", searchValue)
+	//fmt.Println("****secFormList:", secFormList)
+	//fmt.Println("****taskFormList:", taskFormList)
 
 	fmt.Println("****whereStr: ", whereStr)
 
@@ -205,7 +204,7 @@ func GetSelectionCollectionList(r *ghttp.Request) *TalentHttpResult {
 		SelectionID string `json:"selection_id"`
 	}
 	var selectionInfos []SelectionInfo
-	err = g.DB().Model("younggee_selection_collect_info").Where("talent_id = ? AND delete = ?", tId, 0).Fields("selection_id").Scan(&selectionInfos)
+	err = g.DB().Model("younggee_selection_collect_info").Where("talent_id = ? AND deleted = ?", tId, 0).Fields("selection_id").Scan(&selectionInfos)
 	fmt.Println("-----", selectionInfos)
 	if err != nil {
 		fmt.Println("查询 selection_id 失败---", err.Error())
@@ -283,6 +282,7 @@ func GetSelectionDetail(r *ghttp.Request) *TalentHttpResult {
 	}
 	sid := r.GetQueryString("selectionid", 0)
 	pid := r.GetQueryString("productid", 0)
+
 	if sid == "" {
 		return &TalentHttpResult{Code: -2, Msg: "data query failed"}
 	}
@@ -423,13 +423,17 @@ func SignUpSecTaskWithKsAccount(r *ghttp.Request) *TalentHttpResult {
 	if err != nil {
 		return &TalentHttpResult{Code: -2, Msg: "parse param error"}
 	}
-
+	if signSecTaskReq.IsOk == 0 {
+		return &TalentHttpResult{Code: -10, Msg: "此账号领样条件不满足"}
+	}
 	// 查得的selectionDetail包含product、photo、策略表等综合数据
 	var selectionDetail *youngee_talent_model.SelectionDetail
 	err = g.DB().Model(youngee_talent_model.SelectionDetail{}).WithAll().Where("selection_id", signSecTaskReq.SelectionId).Scan(&selectionDetail)
 	if err != nil {
 		return &TalentHttpResult{Code: -3, Msg: err.Error()}
 	}
+	//根据freeStrage判断当前的粉丝数是否满足条件
+	//前端传递根据粉丝数目和悬赏策略对比。传递满足条件是否满足。
 
 	//获取选品表中的ddl
 	var selectionInfo *model.YounggeeSelectionInfo
@@ -510,11 +514,11 @@ func SignUpSecTaskWithKsAccount(r *ghttp.Request) *TalentHttpResult {
 		AssignmentStatus:       1,
 		UpdateAt:               gtime.Now(),
 		WithdrawStatus:         1,
-		LeadTeamId:             signSecTaskReq.LeadTeamId,
-		TeamId:                 signSecTaskReq.TeamId,
-		TeamIncome:             0,
-		TeamPoint:              0,
-		TaskDdl:                selectionInfo.TaskDdl,
+		//LeadTeamId:             signSecTaskReq.LeadTeamId,
+		//TeamId:                 signSecTaskReq.TeamId,
+		TeamIncome: 0,
+		TeamPoint:  0,
+		TaskDdl:    selectionInfo.TaskDdl,
 	}
 
 	//加入橱窗逻辑,
@@ -572,6 +576,7 @@ func SignUpSecTaskWithKsAccount(r *ghttp.Request) *TalentHttpResult {
 	//return &TalentHttpResult{Code: 0, Msg: "success", Data: selectionDetail}
 }
 
+// 加入橱窗--没有报名信息则创建报名信息
 func SignUpSecTaskFromWindow(r *ghttp.Request) *TalentHttpResult {
 	tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
 	if err != nil {

+ 4 - 3
app/service/youngee_talent_service/LoginFromSms.go

@@ -26,7 +26,7 @@ func LoginFromSms(r *ghttp.Request) *TalentHttpResult {
 	l := LoginReq{}
 	err := r.ParseForm(&l)
 	if err != nil {
-		fmt.Printf("前端数据解析错误")
+		r.Response.WriteJson("前端数据解析错误")
 	}
 	//通过手机号和验证码构造出key。
 	VcodeKey := fmt.Sprintf("%s%s", "c_user:", l.Phone)
@@ -91,9 +91,9 @@ func LoginFromSms(r *ghttp.Request) *TalentHttpResult {
 				LastLoginDate:     gtime.Now(),
 				CreateDate:        gtime.Now(),
 			}
-
 			res.Avatar = defaultAvatar
 			res.Nickname = "样叽用户" + newTalentId
+			res.Phone = l.Phone
 
 			_, err = g.DB().Model(dao.YoungeeTalentInfo.Table).Data(talentInfo).Insert()
 			if err != nil {
@@ -103,6 +103,7 @@ func LoginFromSms(r *ghttp.Request) *TalentHttpResult {
 			newTalentId = rec["id"].String()
 			res.Avatar = rec["avatar"].String()
 			res.Nickname = rec["talent_wx_nickname"].String()
+			res.Phone = rec["talent_phone_number"].String()
 			// 更新达人最近登录时间
 			_, err = g.DB().Model(dao.YoungeeTalentInfo.Table).Data(
 				g.Map{
@@ -120,7 +121,7 @@ func LoginFromSms(r *ghttp.Request) *TalentHttpResult {
 		}
 		res.Token = token
 
-		// 以token为键保存session 存储在服务器中
+		//以token为键保存session 存储在服务器中
 		//自动生成一个 session ID 并通过 Cookie 将其发送给客户端,以便在后续请求中识别该客户端的会话
 		//自动生成一个 session ID,并通过 `Set-Cookie` 头将其发送给客户端,前端可以通过r.header['Set-Cookie']获取cookie
 		err = r.Session.Set(token, g.Map{

+ 3 - 3
app/service/youngee_talent_service/SendSmsCode.go

@@ -34,7 +34,7 @@ func SendSmsCode(r *ghttp.Request) *TalentHttpResult {
 	l := SendcodeReq{}
 	err := r.ParseForm(&l)
 	if err != nil {
-		fmt.Printf("前端数据解析错误")
+		return &TalentHttpResult{Code: -1, Msg: "请求体解析失败"}
 	}
 	vcode := GetCode()
 	fmt.Println("验证码为=====>", vcode)
@@ -47,11 +47,11 @@ func SendSmsCode(r *ghttp.Request) *TalentHttpResult {
 	//验证码存redis
 	_ = SetRedis(l.Phone, vcode)
 
-	return &TalentHttpResult{Code: 1, Msg: "sendSmsCodeSuccess"}
+	return &TalentHttpResult{Code: 0, Msg: "sendSmsCodeSuccess"}
 }
 
 func SetRedis(phone string, vcode string) error {
-	err, _ := g.Redis().Do("SETEX", getRedisKey(phone), vcode, 120) //第三个参数以秒为单位
+	err, _ := g.Redis().Do("SETEX", getRedisKey(phone), 120, vcode) //第三个参数以秒为单位
 	if err != nil {
 		fmt.Println("redis存储错误")
 	}

+ 2 - 0
app/service/youngee_talent_service/talent_info.go

@@ -1,6 +1,7 @@
 package youngee_talent_service
 
 import (
+	"fmt"
 	"youngmini_server/app/dao"
 	"youngmini_server/app/model/youngee_talent_model"
 	"youngmini_server/app/utils"
@@ -35,6 +36,7 @@ func OnUpdateTalentInfo(r *ghttp.Request) *TalentHttpResult {
 	}
 	var infos *youngee_talent_model.TalentSelfInputInfo
 	err = r.ParseForm(&infos)
+	fmt.Println("头像地址---->:", infos.Avatar)
 	if err != nil {
 		return &TalentHttpResult{Code: -2, Msg: err.Error()}
 	}

+ 125 - 55
app/service/youngee_talent_service/talent_ks_auth.go

@@ -12,6 +12,7 @@ import (
 	"github.com/lin-jim-leon/kuaishou/open/merchant"
 	"github.com/lin-jim-leon/kuaishou/open/user"
 	"log"
+	"sync"
 	"time"
 	"youngmini_server/app/model/youngee_talent_model"
 	"youngmini_server/app/service/youngee_sectask_service"
@@ -33,16 +34,41 @@ const (
 	//SignSecret1   = "bf6393dce0a2b669ee348bebb837b0da"
 )
 
+// 定义全局变量保存上下文
+var ctx context.Context
+var cancel context.CancelFunc
+var once sync.Once // 确保上下文只被初始化一次
+
+// 初始化 chromedp 上下文的函数
+func initChromedpContext() {
+	once.Do(func() {
+		// 初始化 chromedp 上下文
+		ctx, cancel = chromedp.NewContext(context.Background())
+		fmt.Println("Chromedp 上下文已初始化")
+	})
+}
+
+// 清理上下文的函数,用于关闭浏览器和取消上下文
+func CleanupChromedpContext() {
+	if cancel != nil {
+		cancel()
+		fmt.Println("Chromedp 上下文已关闭")
+	}
+}
+
 func GetQrcode(r *ghttp.Request) *TalentHttpResult {
 	//达人id获取
 	tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
+	fmt.Println("tid:", tid, "err:", err)
 	if err != nil {
 		return &TalentHttpResult{Code: -1, Msg: "Get talent id failed"}
 	}
 	// 记录开始时间
 	startTime := time.Now()
 	// 创建一个新的上下文
-	ctx, cancel := chromedp.NewContext(context.Background())
+	// 确保 chromedp 上下文已初始化
+	initChromedpContext()
+	//ctx, cancel := chromedp.NewContext(context.Background())
 	// 构建包含 tid 的 urlstr
 	var urlstr string
 	typePlatform := r.GetInt("platform_id")
@@ -84,14 +110,57 @@ func GetQrcode(r *ghttp.Request) *TalentHttpResult {
 	println("ok----->", ok)
 	println("url----->", urlstr)
 	fmt.Println("代码运行时间:", time.Since(startTime))
-	//r.Response.WriteJson(text)
+	return &TalentHttpResult{Code: 0, Msg: "success", Data: text}
+}
 
-	// 在300秒后取消上下文
-	time.AfterFunc(300*time.Second, func() {
-		cancel()
+func GetKsEcomQrcode(r *ghttp.Request) *TalentHttpResult {
+	fmt.Println("GetKsEcomQrcode-----")
+	//达人id获取
+	tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
+	fmt.Println("tid:", tid, "err:", err)
+	if err != nil {
+		return &TalentHttpResult{Code: -1, Msg: "Get talent id failed"}
+	}
+	// 记录开始时间
+	startTime := time.Now()
+	// 确保上下文只初始化一次
+	once.Do(func() {
+		ctx, _ = chromedp.NewContext(context.Background())
+		fmt.Println("Chromedp 上下文已初始化")
 	})
+	// 创建一个新的上下文
+	//ctx, _ := chromedp.NewContext(context.Background())
+	//需要访问的网址,无state,扫码后跳转到订购页面
+	urlstr := fmt.Sprintf("https://login.kwaixiaodian.com/?biz=fuwu&redirect_url=https://fuwu.kwaixiaodian.com/new/detail?id=22328015871939")
+	// 执行任务
+	var text string
+	var ok bool
+	var tasks chromedp.Tasks
+	//快手
+	tasks = chromedp.Tasks{
+		chromedp.Navigate(urlstr),
+		//点击出现二维码
+		chromedp.Click(`#root > div > div.UqM2VqEDB3qdOFvSOHAB > div > div > div > div.container__content > div:nth-child(1) > div`),
+		// 获取二维码
+		chromedp.AttributeValue(`#root > div > div.UqM2VqEDB3qdOFvSOHAB > div > div > div > div.Kmu1OHb3un0JBPZDkGa8 > div.JAc4fjotOx_h8lOtGzuB > div.dIaAe1BsCdQL6GtURkNI > img`, "src", &text, &ok),
+	}
 
-	return &TalentHttpResult{Code: 0, Msg: "success", Data: text}
+	//浏览器启动!
+	err = chromedp.Run(ctx, tasks)
+	if err != nil {
+		fmt.Println("errInfo---", err.Error())
+	}
+	println("text----->", text)
+	println("ok----->", ok)
+	println("url----->", urlstr)
+	fmt.Println("代码运行时间:", time.Since(startTime))
+
+	// 在300秒后取消上下文
+	//time.AfterFunc(300*time.Second, func() {
+	//	cancel()
+	//})
+	// 返回二维码的操作已经完成,后续操作(go fun)在后台继续进行
+	return &TalentHttpResult{Code: 0, Msg: "二维码已生成", Data: text}
 }
 
 // 检查数据库表中是否有达人对应的数据 且 token未过期
@@ -175,7 +244,7 @@ func CheckKsNewAccount(r *ghttp.Request) *TalentHttpResult {
 	//check到了更新时间在两秒内的插入的数据。则说明已绑定。弹窗消失。
 	tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
 	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: "Get talent id failed"}
+		return &TalentHttpResult{Code: -2, Msg: "Get talent id failed"}
 	}
 	redisKsBindStatusKey := fmt.Sprintf("KsBind:%s", tid)
 	bindStatus, err := g.Redis().DoVar("GET", redisKsBindStatusKey)
@@ -183,7 +252,7 @@ func CheckKsNewAccount(r *ghttp.Request) *TalentHttpResult {
 		return &TalentHttpResult{Code: -1, Msg: "此快手账号已被其他达人绑定", Data: nil}
 	}
 	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: "Get talent id failed"}
+		return &TalentHttpResult{Code: -3, Msg: "Get talent id failed"}
 	}
 
 	// 获取当前时间
@@ -197,9 +266,9 @@ func CheckKsNewAccount(r *ghttp.Request) *TalentHttpResult {
 		return &TalentHttpResult{Code: -4, Msg: "Database query failed"}
 	}
 
+	//当前达人没有绑定过账号
 	if len(userInfos) == 0 {
 		// 如果没有符合条件的数据,返回失败
-		return &TalentHttpResult{Code: -5, Msg: "No valid data found"}
 	}
 
 	// 找到 CreateTime 最新的记录
@@ -213,7 +282,7 @@ func CheckKsNewAccount(r *ghttp.Request) *TalentHttpResult {
 	// 计算创建时间与当前时间的差值
 	timeDiff := currentTime.Sub(latestUserInfo.CreateTime)
 	if timeDiff <= 3*time.Second {
-		return &TalentHttpResult{Code: 0, Msg: "success"}
+		return &TalentHttpResult{Code: 0, Msg: "授权完成,数据已入库"}
 	}
 
 	// 超过时间差,返回失败
@@ -357,7 +426,7 @@ func AddWindowKuaishouList(r *ghttp.Request) *TalentHttpResult {
 		// 将过期检查结果赋值给 expired 属性 ,过期则不能被选中用于加入橱窗
 		record.Expired = expired
 	}
-	return &TalentHttpResult{Code: 0, Msg: "加入橱窗成功", Data: resInfo}
+	return &TalentHttpResult{Code: 0, Msg: "快手列表展示成功", Data: resInfo}
 }
 
 func SignUpSecKuaishouList(r *ghttp.Request) *TalentHttpResult {
@@ -572,12 +641,13 @@ func QuerySalesFor30Days(r *ghttp.Request) *TalentHttpResult {
 
 func QueryOkSaleNum(r *ghttp.Request) *TalentHttpResult {
 	tid, _ := utils.SessionTalentInfo.GetTalentIdFromSession(r)
+	openID := r.GetString("open_id")
 	// 创建一个 KuaishouUserInfo 结构体的实例
 	userInfo := &youngee_talent_model.KuaishouUserInfo{}
 
 	// 查询数据库中的 access_token 字段
 	// 使用 g.DB() 获取数据库连接,并执行查询
-	key, err := g.DB().Model(userInfo).Fields("access_token").Where("talent_id = ?", tid).Value()
+	key, err := g.DB().Model(userInfo).Fields("access_token").Where("talent_id = ? AND open_id= ? AND platform_id = ?", tid, openID, 4).Value()
 	AccessToken := key.String()
 	if err != nil {
 		// 处理错误
@@ -617,51 +687,51 @@ func QueryOkSaleNum(r *ghttp.Request) *TalentHttpResult {
 	endTime = currentTime
 	saleNum += GetSaleNumByDayInterval_Ok(ClientKey, SignSecret, AccessToken, beginTime, endTime)
 	// 查询成功,返回成功结果和数据
-	return &TalentHttpResult{Code: 0, Msg: "获取30天销售量成功", Data: saleNum}
+	return &TalentHttpResult{Code: 0, Msg: "获取90天销售量成功", Data: saleNum}
 }
 
-func VideoCount(r *ghttp.Request) *TalentHttpResult {
-	tid, _ := utils.SessionTalentInfo.GetTalentIdFromSession(r)
-	// 创建一个 KuaishouUserInfo 结构体的实例
-	userInfo := &youngee_talent_model.KuaishouUserInfo{}
-
-	// 查询数据库中的 access_token 字段
-	// 使用 g.DB() 获取数据库连接,并执行查询
-	key, err := g.DB().Model(userInfo).Fields("access_token").Where("talent_id = ? AND platform_id = ?", tid, 8).Value()
-	AccessToken := key.String()
-	if err != nil {
-		// 处理错误
-		fmt.Println("Error querying access_token:", err)
-	}
-	if key == nil {
-		// 处理错误
-		fmt.Println("can not find talentId's bindinfo :", err)
-	}
-
-	count, err := GetVideoCount(ClientKey1, AccessToken)
-	return &TalentHttpResult{Code: 0, Msg: "获取总作品数成功", Data: count}
-}
-
-func LikeCount(r *ghttp.Request) *TalentHttpResult {
-	tid, _ := utils.SessionTalentInfo.GetTalentIdFromSession(r)
-	// 创建一个 KuaishouUserInfo 结构体的实例
-	userInfo := &youngee_talent_model.KuaishouUserInfo{}
-
-	// 查询数据库中的 access_token 字段
-	// 使用 g.DB() 获取数据库连接,并执行查询
-	key, err := g.DB().Model(userInfo).Fields("access_token").Where("talent_id = ? AND platform_id = ?", tid, 8).Value()
-	AccessToken := key.String()
-	if err != nil {
-		// 处理错误
-		fmt.Println("Error querying access_token:", err)
-	}
-	if key == nil {
-		// 处理错误
-		fmt.Println("can not find talentId's bindinfo :", err)
-	}
-	count, err := GetLikeCount(ClientKey1, AccessToken)
-	return &TalentHttpResult{Code: 0, Msg: "获取总点赞数成功", Data: count}
-}
+//func VideoCount(r *ghttp.Request) *TalentHttpResult {
+//	tid, _ := utils.SessionTalentInfo.GetTalentIdFromSession(r)
+//	// 创建一个 KuaishouUserInfo 结构体的实例
+//	userInfo := &youngee_talent_model.KuaishouUserInfo{}
+//
+//	// 查询数据库中的 access_token 字段
+//	// 使用 g.DB() 获取数据库连接,并执行查询
+//	key, err := g.DB().Model(userInfo).Fields("access_token").Where("talent_id = ? AND platform_id = ?", tid, 8).Value()
+//	AccessToken := key.String()
+//	if err != nil {
+//		// 处理错误
+//		fmt.Println("Error querying access_token:", err)
+//	}
+//	if key == nil {
+//		// 处理错误
+//		fmt.Println("can not find talentId's bindinfo :", err)
+//	}
+//
+//	count, err := GetVideoCount(ClientKey1, AccessToken)
+//	return &TalentHttpResult{Code: 0, Msg: "获取总作品数成功", Data: count}
+//}
+//
+//func LikeCount(r *ghttp.Request) *TalentHttpResult {
+//	tid, _ := utils.SessionTalentInfo.GetTalentIdFromSession(r)
+//	// 创建一个 KuaishouUserInfo 结构体的实例
+//	userInfo := &youngee_talent_model.KuaishouUserInfo{}
+//
+//	// 查询数据库中的 access_token 字段
+//	// 使用 g.DB() 获取数据库连接,并执行查询
+//	key, err := g.DB().Model(userInfo).Fields("access_token").Where("talent_id = ? AND platform_id = ?", tid, 8).Value()
+//	AccessToken := key.String()
+//	if err != nil {
+//		// 处理错误
+//		fmt.Println("Error querying access_token:", err)
+//	}
+//	if key == nil {
+//		// 处理错误
+//		fmt.Println("can not find talentId's bindinfo :", err)
+//	}
+//	count, err := GetLikeCount(ClientKey1, AccessToken)
+//	return &TalentHttpResult{Code: 0, Msg: "获取总点赞数成功", Data: count}
+//}
 
 // 获取用户快手平台账号列表
 func GetKuaishouList(r *ghttp.Request) *TalentHttpResult {

+ 7 - 6
app/service/youngee_talent_service/wxlogin.go

@@ -56,7 +56,6 @@ type GetPhoneRequestBody struct {
 }
 
 func WxLogin(r *ghttp.Request) *TalentHttpResult {
-
 	l := youngee_talent_model.WxLoginInfo{}
 	err := r.ParseForm(&l)
 	if err != nil {
@@ -89,11 +88,13 @@ func WxLogin(r *ghttp.Request) *TalentHttpResult {
 
 	//为了获得手机号
 	phoneNum := getPhoneNum(l.GetPhoneCode)
+	fmt.Println("phoneNum:---->", phoneNum)
 
 	// 根据openid查询达人信息
-	rec, err := g.DB().Model("youngee_talent_info").One("talent_phone_number", phoneNum)
+	//rec, err := g.DB().Model("youngee_talent_info").One("talent_phone_number", phoneNum)
+	rec, err := g.DB().Model("youngee_talent_info").Where("talent_phone_number = ?", phoneNum).One()
 	if err != nil {
-		return &TalentHttpResult{Code: -5, Msg: "get talent info failed"}
+		return &TalentHttpResult{Code: -5, Msg: err.Error()}
 	}
 
 	// 如果达人被拉黑,则返回
@@ -124,7 +125,7 @@ func WxLogin(r *ghttp.Request) *TalentHttpResult {
 		res.Avatar = l.Avatar
 		res.Nickname = l.Nickname
 		res.Phone = phoneNum //接口返回手机号
-		_, err = g.DB().Model(dao.YoungeeTalentInfo.Table).Data(talentInfo).Insert()
+		_, err = g.DB().Model("youngee_talent_info").Data(talentInfo).Insert()
 		if err != nil {
 			return &TalentHttpResult{Code: -7, Msg: "get talentId failed"}
 		}
@@ -135,12 +136,12 @@ func WxLogin(r *ghttp.Request) *TalentHttpResult {
 		res.Nickname = rec["talent_wx_nickname"].String()
 		res.Phone = rec["talent_phone_number"].String()
 		// 更新达人最近登录时间
-		_, err = g.DB().Model(dao.YoungeeTalentInfo.Table).Data(
+		_, err = g.DB().Model("youngee_talent_info").Data(
 			g.Map{
 				"last_login_date": gtime.Now(),
 			}).Where("id", newTalentId).Update()
 		if err != nil {
-			return &TalentHttpResult{Code: -8, Msg: "update talent last login date failed"}
+			return &TalentHttpResult{Code: -8, Msg: err.Error()}
 		}
 	}
 

+ 102 - 7
app/service/youngee_task_service/project_info.go

@@ -11,6 +11,7 @@ import (
 	"youngmini_server/app/dao"
 	"youngmini_server/app/model"
 	"youngmini_server/app/model/youngee_talent_model"
+	"youngmini_server/app/service/youngee_talent_service"
 	"youngmini_server/app/utils"
 
 	"github.com/gogf/gf/frame/g"
@@ -115,7 +116,6 @@ func GetProjectInfoList(r *ghttp.Request) *TalentHttpResult {
 	}
 	fmt.Println("searchValue:", searchValue)
 	fmt.Println("feeFormList:", feeFormList)
-	fmt.Println("projectList:", projectList)
 	// 筛选出满足稿费形式条件的项目id列表
 	for _, v := range projectList {
 		string_slice := strings.Split(v.FeeForm, ",")
@@ -166,14 +166,16 @@ func GetProjectInfoList(r *ghttp.Request) *TalentHttpResult {
 
 	var projectInfoList = youngee_talent_model.ProjectInfoList{}
 	err = g.DB().Model("project_info").WithAll().Where(whereStr).
-		Order("project_status ASC,recruit_ddl ASC, project_id").Limit(startId, cntPerPage).Scan(&projectInfoList.ProjectInfos)
+		Order("project_status ASC,recruit_ddl DESC").Limit(startId, cntPerPage).Scan(&projectInfoList.ProjectInfos)
 
 	if err != nil {
 		return &TalentHttpResult{Code: -6, Msg: "查询数据库失败"}
 	}
 
-	// 查询每个商品的浏览量
+	// 遍历projectList
 	for i, project := range projectInfoList.ProjectInfos {
+		fmt.Println("project.EnterpriseId---", project.EnterpriseId)
+		//处理浏览量
 		projectViewKey := "project:view:" + gconv.String(project.ProjectId)
 		//redis中取浏览量 返回的是gvar.Var类型。 不存咋则为nil。经过viewCount.Int变成0
 		viewCount, err := g.Redis().DoVar("GET", projectViewKey)
@@ -182,8 +184,22 @@ func GetProjectInfoList(r *ghttp.Request) *TalentHttpResult {
 			return &TalentHttpResult{Code: 0, Msg: "Redis error"}
 		}
 		projectInfoList.ProjectInfos[i].WatchedNum = viewCount.Int()
-	}
+		// 如果 enterprise_id 有值,查询 Enterprise 信息并关联,服务商的任务不会出现在首页
+		//if project.EnterpriseId != "" {
+		//	var enterprise *youngee_talent_model.Enterprise
+		//	err := g.DB().Model("enterprise").Where("enterprise_id", project.EnterpriseId).Scan(&enterprise)
+		//	if err != nil {
+		//		fmt.Println("查询失败")
+		//		continue // 如果查询失败,跳过当前 project 继续处理下一个
+		//	}
+		//
+		//	fmt.Println("查询结果---", enterprise)
+		//
+		//	// 将查询到的 Enterprise 赋值给 projectInfo 的 Enterprise 字段
+		//	projectInfoList.ProjectInfos[i].Enterprise = enterprise
+		//}
 
+	}
 	projectInfoList.MaxPage = maxPage
 
 	return &TalentHttpResult{Code: 0, Msg: "success", Data: projectInfoList}
@@ -192,7 +208,13 @@ func GetProjectInfoList(r *ghttp.Request) *TalentHttpResult {
 // 获取单个项目详情service
 func GetProjectDetail(r *ghttp.Request) *TalentHttpResult {
 	tid, _ := utils.SessionTalentInfo.GetTalentIdFromSession(r)
-	pid := r.GetQueryInt("projectid", 0)
+	pid := r.GetQueryInt("project_id", 0)
+	//通过首页进入的详情页,获取服务商id,younggee_supplier表
+	enterprise_id := r.GetQueryString("enterprise_id", "")
+	//通过扫服务商码进入的详情页,获取服务商id,younggee_supplier表
+	supplier_id := r.GetQueryString("supplier_id", "")
+	fmt.Println("enterprise_id----:", enterprise_id)
+	fmt.Println("supplier_id----:", supplier_id)
 	// Redis key
 	projectViewKey := "project:view:" + strconv.Itoa(pid)
 	userViewedKey := "user:viewed:" + tid + ":" + strconv.Itoa(pid)
@@ -240,10 +262,83 @@ func GetProjectDetail(r *ghttp.Request) *TalentHttpResult {
 	}
 
 	var ProjectDetail *youngee_talent_model.ProjectDetail
-	err = g.DB().Model(youngee_talent_model.ProjectDetail{}).WithAll().Where("project_id", pid).Scan(&ProjectDetail)
+	err = g.DB().Model("project_info").WithAll().Where("project_id", pid).Scan(&ProjectDetail)
 	if err != nil {
-		return &TalentHttpResult{Code: -3, Msg: "data query failed"}
+		return &TalentHttpResult{Code: -3, Msg: err.Error()}
+	}
+
+	if enterprise_id != "" { //project来自商家
+		var enterprise *youngee_talent_model.Enterprise
+		err = g.DB().Model("enterprise").WithAll().Where("enterprise_id", enterprise_id).Scan(&enterprise)
+		if err != nil {
+			return &TalentHttpResult{Code: -3, Msg: err.Error()}
+		}
+		ProjectDetail.Enterprise = enterprise
+	}
+	if supplier_id != "" {
+		// 来自服务商
+		var younggeeSupplier *youngee_talent_model.YounggeeSupplier
+		err = g.DB().Model("younggee_supplier").WithAll().Where("supplier_id", supplier_id).Scan(&younggeeSupplier)
+		if err != nil {
+			return &TalentHttpResult{Code: -3, Msg: err.Error()}
+		}
+		ProjectDetail.YounggeeSupplier = younggeeSupplier
 	}
 
 	return &TalentHttpResult{Code: 0, Msg: "success", Data: ProjectDetail}
 }
+
+func SignUpProjKuaishouList(r *ghttp.Request) *TalentHttpResult {
+	tid, _ := utils.SessionTalentInfo.GetTalentIdFromSession(r)
+	pid := r.GetQueryString("project_id", 0)
+	// 定义用于存储查询结果的结构体切片
+	var results []*youngee_talent_model.KuaishouUserInfo
+	// 查询此达人下,platform_id 为 8 或 4 的所有数据,并将结果扫描到结构体切片中
+	err := g.DB().Model(&youngee_talent_model.KuaishouUserInfo{}).
+		Where("talent_id = ?", tid).
+		Where("platform_id IN (?, ?)", 4, 8).
+		Order("open_id ASC, platform_id DESC"). // 按 open_id 排序,确保每组的数据连续,并且 platform_id=4 的数据排在前面
+		Scan(&results)
+	if err != nil {
+		return &TalentHttpResult{Code: 1, Msg: "查询失败", Data: nil}
+	}
+
+	// 创建一个 map,用于记录每个 open_id 对应的记录
+	//key是openid,value是数组,从而实现一对多
+	openIdMap := make(map[string][]*youngee_talent_model.KuaishouUserInfo)
+
+	// 将查询结果按 open_id 分组
+	for _, record := range results {
+		openIdMap[record.OpenId] = append(openIdMap[record.OpenId], record)
+	}
+
+	// 筛选出 open_id 对应两条数据且 platform_id = 4 的记录
+	var resInfo []*youngee_talent_model.KuaishouUserInfo
+	for _, records := range openIdMap {
+		if len(records) == 2 { // 确保有两条数据,排除只有一个 platform_id 的情况
+			for _, record := range records {
+				if record.PlatformId == 4 { // 选取 platform_id = 4(电商) 的记录,含有粉丝数就好,因为需要加入橱窗
+					resInfo = append(resInfo, record)
+					break
+				}
+			}
+		}
+	}
+	// 遍历 resInfo 检查过期和是否报名
+	for _, record := range resInfo {
+		// 调用 CheckKuaishouTokenExp 函数,检查 openId 是否过期
+		expired := youngee_talent_service.CheckKuaishouTokenExp(record.OpenId)
+		// 将过期检查结果赋值给 expired 属性 ,过期则不能被选中用于加入橱窗
+		record.Expired = expired
+		//是否报名
+		isSignResult, err := g.DB().Model("younggee_task_info").Where("project_id=? AND open_id=? talent_id=?", pid, record.OpenId, tid).One()
+		// 根据查询结果设置 IsSign 属性
+		if err != nil || isSignResult.IsEmpty() {
+			record.IsSign = 0 // 没有查到数据,设置为 0
+		} else {
+			record.IsSign = 1 // 查到数据,设置为 1
+		}
+
+	}
+	return &TalentHttpResult{Code: 0, Msg: "success", Data: resInfo}
+}

+ 4 - 1
app/service/youngee_task_service/task_data.go

@@ -47,6 +47,9 @@ func AddTaskData(r *ghttp.Request) *TalentHttpResult {
 		IsOk:          0,
 	}
 
+	//todo:  修改taskstage为  14:数据待审
+	//todo 留痕而不是updata
+
 	_, err = g.DB().Model(model.YounggeeDataInfo{}).Data(DataInfo).Insert()
 	if err != nil {
 		return &TalentHttpResult{Code: -3, Msg: "YounggeeDataInfo insert failed"}
@@ -233,7 +236,7 @@ func SelectionCollection(r *ghttp.Request) *TalentHttpResult {
 				"create_time": gtime.Now(),
 			}).Update()
 		if err != nil {
-			return &TalentHttpResult{Code: -2, Msg: err.Error()}
+			return &TalentHttpResult{Code: -1, Msg: err.Error()}
 		}
 	}
 	return &TalentHttpResult{Code: 0, Msg: "collection success"}

+ 463 - 286
app/service/youngee_task_service/task_info.go

@@ -7,6 +7,7 @@ import (
 	"youngmini_server/app/dao"
 	"youngmini_server/app/model"
 	"youngmini_server/app/model/youngee_talent_model"
+	"youngmini_server/app/service/youngee_talent_service"
 	"youngmini_server/app/utils"
 
 	"github.com/gogf/gf/database/gdb"
@@ -17,204 +18,204 @@ import (
 )
 
 // 新建任务service
-func SignUpTask(r *ghttp.Request) *TalentHttpResult {
-	tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
-	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
-	}
-
-	var signTaskInfo *youngee_talent_model.SignTaskInfo
-	err = r.ParseForm(&signTaskInfo)
-	if err != nil {
-		return &TalentHttpResult{Code: -2, Msg: "data query failed"}
-	}
-	var projectDetail *youngee_talent_model.ProjectDetail
-	err = g.DB().Model(youngee_talent_model.ProjectDetail{}).WithAll().Where("project_id", signTaskInfo.ProjectId).Scan(&projectDetail)
-	if err != nil {
-		return &TalentHttpResult{Code: -3, Msg: err.Error()}
-	}
-
-	var talentInfo *youngee_talent_model.TalentInfo
-	err = g.DB().Model("youngee_talent_info").WithAll().Where("id", tid).Scan(&talentInfo)
-	if err != nil {
-		return &TalentHttpResult{Code: -4, Msg: "Get talent info failed"}
-	}
-
-	var accountInfo *youngee_talent_model.PlatformAccountInfo
-	err = g.DB().Model("youngee_platform_account_info").WithAll().Where("talent_id = ? and platform_id = ?", tid, projectDetail.ProjectPlatform).Scan(&accountInfo)
-	if err != nil {
-		return &TalentHttpResult{Code: -5, Msg: err.Error()}
-	}
-
-	address, err := g.DB().Model(dao.YoungeeTalentDeliveryAddress.Table).One("talent_id = ? and address_id = ?", tid, signTaskInfo.AddressId)
-	if err != nil {
-		return &TalentHttpResult{Code: -6, Msg: err.Error()}
-	}
-
-	var newTaskId string
-	// 首先生成任务id
-	newTaskId = utils.GetUuid.GetTaskId(projectDetail.ProjectId, projectDetail.EnterpriseId, tid)
-
-	// 生成达人平台账号信息快照
-	accountSnap, err := gjson.Encode(accountInfo)
-	if err != nil {
-		return &TalentHttpResult{Code: -7, Msg: "encode platform snap failed"}
-	}
-
-	// 生成达人信息快照
-	talentSnap, err := gjson.Encode(talentInfo)
-	if err != nil {
-		return &TalentHttpResult{Code: -8, Msg: "encode talent info snap failed"}
-	}
-
-	// 生成收货地址快照
-	addrSnap, err := gjson.Encode(address)
-	if err != nil {
-		return &TalentHttpResult{Code: -9, Msg: "encode delivery address snap failed"}
-	}
-	taskInfo := model.YoungeeTaskInfo{}
-	if projectDetail.ProjectType == 1 {
-		// 全流程任务
-
-		// 计算平台服务费
-		// 1. 先获取稿费形式
-		var strategy *youngee_talent_model.RecruitStrategy
-		err = g.DB().Model("recruit_strategy").WithAll().Where("strategy_id = ? and project_id= ?", signTaskInfo.StrategyId, signTaskInfo.ProjectId).Scan(&strategy)
-		if err != nil {
-			return &TalentHttpResult{Code: -10, Msg: err.Error()}
-		}
-
-		// 2. 根据稿费形式、平台、粉丝数获取服务费最高的定价策略
-		// 2.1 查询所有对应定价策略
-		whereStr1 := fmt.Sprintf("fee_form = %d and platform = %d and fans_low <= %d and fans_up > %d", strategy.FeeForm, projectDetail.ProjectPlatform, strategy.FollowersLow, strategy.FollowersLow)
-		orStr1 := fmt.Sprintf("fee_form = %d and platform = %d and fans_low < %d and fans_up >= %d", strategy.FeeForm, projectDetail.ProjectPlatform, strategy.FollowersUp, strategy.FollowersUp)
-		orStr2 := fmt.Sprintf("fee_form = %d and platform = %d and fans_low >= %d and fans_up <= %d", strategy.FeeForm, projectDetail.ProjectPlatform, strategy.FollowersLow, strategy.FollowersUp)
-		orStr3 := fmt.Sprintf("fee_form = %d and platform = %d and fans_low <= %d and fans_up >= %d", strategy.FeeForm, projectDetail.ProjectPlatform, strategy.FollowersLow, strategy.FollowersUp)
-		var pricings []*model.InfoPricingStrategy
-		err = g.DB().Model("info_pricing_strategy").WithAll().Where(whereStr1).Or(orStr1).Or(orStr2).Or(orStr3).Scan(&pricings)
-		if err != nil {
-			return &TalentHttpResult{Code: -11, Msg: err.Error()}
-		} else if pricings == nil {
-			return &TalentHttpResult{Code: -12, Msg: "无相关定价策略"}
-		}
-		var pricing *model.InfoPricingStrategy
-		// 2.2 从对应定价策略中选取服务费率最高
-		if strategy.FeeForm == 1 {
-			var maxCharge float64 = 0
-			for _, v := range pricings {
-				if v.ServiceCharge >= maxCharge {
-					maxCharge = v.ServiceCharge
-					pricing = v
-				}
-			}
-		} else {
-			var maxRate int = 0
-			for _, v := range pricings {
-				if v.ServiceRate >= maxRate {
-					maxRate = v.ServiceRate
-					pricing = v
-				}
-			}
-		}
-		var serviceCharge = 0.0
-		var serviceRate = 0
-		var allReward = 0.0
-		var allPayment = 0.0
-		switch strategy.FeeForm {
-		case 1: // 产品置换,服务费固定,在项目生成时确定
-			serviceCharge = float64(strategy.ServiceCharge)
-			allPayment = serviceCharge
-			break
-		case 2: // 固定稿费,m2  =  y2 * r2
-			allPayment = float64(strategy.Offer)
-			serviceRate = pricing.ServiceRate
-			serviceCharge = allPayment * float64(serviceRate) / 1000
-			allReward = allPayment - serviceCharge
-			break
-		case 3: // 自报价,m3 = x3 * r3
-			allReward = float64(signTaskInfo.Offer)
-			serviceRate = pricing.ServiceRate
-			var tmpRate = float64(1000-serviceRate) / 1000
-			allPayment = allReward / tmpRate
-			serviceCharge = allPayment - allReward
-			break
-		default:
-			break
-		}
-		taskInfo = model.YoungeeTaskInfo{
-			TaskId:                 newTaskId,
-			ProjectId:              signTaskInfo.ProjectId,
-			TalentId:               tid,
-			AccountId:              accountInfo.AccountId,
-			TalentPlatformInfoSnap: string(accountSnap),
-			TalentPersonalInfoSnap: string(talentSnap),
-			TalentPostAddrSnap:     string(addrSnap),
-			StrategyId:             signTaskInfo.StrategyId,
-			TaskReward:             allReward,
-			SettleAmount:           allReward,
-			AllPayment:             allPayment,
-			TaskStage:              1,
-			RealPayment:            allPayment,
-			FeeForm:                strategy.FeeForm,
-			ServiceCharge:          serviceCharge,
-			ServiceRate:            serviceRate,
-			CreateDate:             gtime.Now(),
-			TaskStatus:             1,
-			LogisticsStatus:        1,
-			LinkStatus:             1,
-			DataStatus:             1,
-			ScriptStatus:           1,
-			SketchStatus:           1,
-			CompleteStatus:         1,
-			CurDefaultType:         0,
-			WithdrawStatus:         1,
-			SettleStatus:           1,
-		}
-	} else {
-		// 专项任务
-		taskInfo = model.YoungeeTaskInfo{
-			TaskId:                 newTaskId,
-			ProjectId:              signTaskInfo.ProjectId,
-			TalentId:               tid,
-			AccountId:              accountInfo.AccountId,
-			TalentPlatformInfoSnap: string(accountSnap),
-			TalentPersonalInfoSnap: string(talentSnap),
-			TalentPostAddrSnap:     string(addrSnap),
-			TaskStage:              1,
-			CreateDate:             gtime.Now(),
-			TaskStatus:             1,
-			LogisticsStatus:        1,
-			LinkStatus:             1,
-			DataStatus:             1,
-			ScriptStatus:           1,
-			SketchStatus:           1,
-			CompleteStatus:         1,
-			CurDefaultType:         0,
-			WithdrawStatus:         1,
-		}
-	}
-	err = g.DB().Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
-		// 在task_info表中插入任务
-		_, err = tx.Ctx(ctx).Model(dao.YoungeeTaskInfo.Table).Data(&taskInfo).Insert()
-		if err != nil {
-			return err
-		}
-
-		// 对应项目的报名人数自增
-		_, err = tx.Ctx(ctx).Model(dao.ProjectInfo.Table).Where(dao.ProjectInfo.Columns.ProjectId, projectDetail.ProjectId).Increment(dao.ProjectInfo.Columns.ApplyNum, 1)
-		if err != nil {
-			return err
-		}
-		return nil
-	})
-	if err != nil {
-		return &TalentHttpResult{Code: -18, Msg: "add Task data failed"}
-	}
-
-	return &TalentHttpResult{Code: 0, Msg: "success", Data: newTaskId}
-}
-
-// 判断是否已报名任务
+//func SignUpTask(r *ghttp.Request) *TalentHttpResult {
+//	tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
+//	if err != nil {
+//		return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
+//	}
+//
+//	var signTaskInfo *youngee_talent_model.SignTaskInfo
+//	err = r.ParseForm(&signTaskInfo)
+//	if err != nil {
+//		return &TalentHttpResult{Code: -2, Msg: "data query failed"}
+//	}
+//	var projectDetail *youngee_talent_model.ProjectDetail
+//	err = g.DB().Model(youngee_talent_model.ProjectDetail{}).WithAll().Where("project_id", signTaskInfo.ProjectId).Scan(&projectDetail)
+//	if err != nil {
+//		return &TalentHttpResult{Code: -3, Msg: err.Error()}
+//	}
+//
+//	var talentInfo *youngee_talent_model.TalentInfo
+//	err = g.DB().Model("youngee_talent_info").WithAll().Where("id", tid).Scan(&talentInfo)
+//	if err != nil {
+//		return &TalentHttpResult{Code: -4, Msg: "Get talent info failed"}
+//	}
+//
+//	var accountInfo *youngee_talent_model.PlatformAccountInfo
+//	err = g.DB().Model("youngee_platform_account_info").WithAll().Where("talent_id = ? and platform_id = ?", tid, projectDetail.ProjectPlatform).Scan(&accountInfo)
+//	if err != nil {
+//		return &TalentHttpResult{Code: -5, Msg: err.Error()}
+//	}
+//
+//	address, err := g.DB().Model(dao.YoungeeTalentDeliveryAddress.Table).One("talent_id = ? and address_id = ?", tid, signTaskInfo.AddressId)
+//	if err != nil {
+//		return &TalentHttpResult{Code: -6, Msg: err.Error()}
+//	}
+//
+//	var newTaskId string
+//	// 首先生成任务id
+//	newTaskId = utils.GetUuid.GetTaskId(projectDetail.ProjectId, projectDetail.EnterpriseId, tid)
+//
+//	//// 生成达人平台账号信息快照
+//	accountSnap, err := gjson.Encode(accountInfo)
+//	//if err != nil {
+//	//	return &TalentHttpResult{Code: -7, Msg: "encode platform snap failed"}
+//	//}
+//
+//	// 生成达人信息快照
+//	talentSnap, err := gjson.Encode(talentInfo)
+//	if err != nil {
+//		return &TalentHttpResult{Code: -8, Msg: "encode talent info snap failed"}
+//	}
+//
+//	// 生成收货地址快照
+//	addrSnap, err := gjson.Encode(address)
+//	if err != nil {
+//		return &TalentHttpResult{Code: -9, Msg: "encode delivery address snap failed"}
+//	}
+//	taskInfo := model.YoungeeTaskInfo{}
+//	if projectDetail.ProjectType == 1 {
+//		// 全流程任务
+//
+//		// 计算平台服务费
+//		// 1. 先获取稿费形式
+//		var strategy *youngee_talent_model.RecruitStrategy
+//		err = g.DB().Model("recruit_strategy").WithAll().Where("strategy_id = ? and project_id= ?", signTaskInfo.StrategyId, signTaskInfo.ProjectId).Scan(&strategy)
+//		if err != nil {
+//			return &TalentHttpResult{Code: -10, Msg: err.Error()}
+//		}
+//
+//		// 2. 根据稿费形式、平台、粉丝数获取服务费最高的定价策略
+//		// 2.1 查询所有对应定价策略
+//		whereStr1 := fmt.Sprintf("fee_form = %d and platform = %d and fans_low <= %d and fans_up > %d", strategy.FeeForm, projectDetail.ProjectPlatform, strategy.FollowersLow, strategy.FollowersLow)
+//		orStr1 := fmt.Sprintf("fee_form = %d and platform = %d and fans_low < %d and fans_up >= %d", strategy.FeeForm, projectDetail.ProjectPlatform, strategy.FollowersUp, strategy.FollowersUp)
+//		orStr2 := fmt.Sprintf("fee_form = %d and platform = %d and fans_low >= %d and fans_up <= %d", strategy.FeeForm, projectDetail.ProjectPlatform, strategy.FollowersLow, strategy.FollowersUp)
+//		orStr3 := fmt.Sprintf("fee_form = %d and platform = %d and fans_low <= %d and fans_up >= %d", strategy.FeeForm, projectDetail.ProjectPlatform, strategy.FollowersLow, strategy.FollowersUp)
+//		var pricings []*model.InfoPricingStrategy
+//		err = g.DB().Model("recruit_strategy").WithAll().Where(whereStr1).Or(orStr1).Or(orStr2).Or(orStr3).Scan(&pricings)
+//		if err != nil {
+//			return &TalentHttpResult{Code: -11, Msg: err.Error()}
+//		} else if pricings == nil {
+//			return &TalentHttpResult{Code: -12, Msg: "无相关定价策略"}
+//		}
+//		var pricing *model.InfoPricingStrategy
+//		// 2.2 从对应定价策略中选取服务费率最高
+//		if strategy.FeeForm == 1 {
+//			var maxCharge float64 = 0
+//			for _, v := range pricings {
+//				if v.ServiceCharge >= maxCharge {
+//					maxCharge = v.ServiceCharge
+//					pricing = v
+//				}
+//			}
+//		} else {
+//			var maxRate int = 0
+//			for _, v := range pricings {
+//				if v.ServiceRate >= maxRate {
+//					maxRate = v.ServiceRate
+//					pricing = v
+//				}
+//			}
+//		}
+//		var serviceCharge = 0.0
+//		var serviceRate = 0
+//		var allReward = 0.0
+//		var allPayment = 0.0
+//		switch strategy.FeeForm {
+//		case 1: // 产品置换,服务费固定,在项目生成时确定
+//			serviceCharge = float64(strategy.ServiceCharge)
+//			allPayment = serviceCharge
+//			break
+//		case 2: // 固定稿费,m2  =  y2 * r2
+//			allPayment = float64(strategy.Offer)
+//			serviceRate = pricing.ServiceRate
+//			serviceCharge = allPayment * float64(serviceRate) / 1000
+//			allReward = allPayment - serviceCharge
+//			break
+//		case 3: // 自报价,m3 = x3 * r3
+//			allReward = float64(signTaskInfo.Offer)
+//			serviceRate = pricing.ServiceRate
+//			var tmpRate = float64(1000-serviceRate) / 1000
+//			allPayment = allReward / tmpRate
+//			serviceCharge = allPayment - allReward
+//			break
+//		default:
+//			break
+//		}
+//		taskInfo = model.YoungeeTaskInfo{
+//			TaskId:                 newTaskId,
+//			ProjectId:              signTaskInfo.ProjectId,
+//			TalentId:               tid,
+//			AccountId:              accountInfo.AccountId,
+//			TalentPlatformInfoSnap: string(accountSnap),
+//			TalentPersonalInfoSnap: string(talentSnap),
+//			TalentPostAddrSnap:     string(addrSnap),
+//			StrategyId:             signTaskInfo.StrategyId,
+//			TaskReward:             allReward,
+//			SettleAmount:           allReward,
+//			AllPayment:             allPayment,
+//			TaskStage:              1,
+//			RealPayment:            allPayment,
+//			FeeForm:                strategy.FeeForm,
+//			ServiceCharge:          serviceCharge,
+//			ServiceRate:            serviceRate,
+//			CreateDate:             gtime.Now(),
+//			TaskStatus:             1,
+//			LogisticsStatus:        1,
+//			LinkStatus:             1,
+//			DataStatus:             1,
+//			ScriptStatus:           1,
+//			SketchStatus:           1,
+//			CompleteStatus:         1,
+//			CurDefaultType:         0,
+//			WithdrawStatus:         1,
+//			SettleStatus:           1,
+//		}
+//	} else {
+//		// 专项任务
+//		taskInfo = model.YoungeeTaskInfo{
+//			TaskId:    newTaskId,
+//			ProjectId: signTaskInfo.ProjectId,
+//			TalentId:  tid,
+//			AccountId: accountInfo.AccountId,
+//			//TalentPlatformInfoSnap: string(accountSnap),
+//			TalentPersonalInfoSnap: string(talentSnap),
+//			TalentPostAddrSnap:     string(addrSnap),
+//			TaskStage:              1,
+//			CreateDate:             gtime.Now(),
+//			TaskStatus:             1,
+//			LogisticsStatus:        1,
+//			LinkStatus:             1,
+//			DataStatus:             1,
+//			ScriptStatus:           1,
+//			SketchStatus:           1,
+//			CompleteStatus:         1,
+//			CurDefaultType:         0,
+//			WithdrawStatus:         1,
+//		}
+//	}
+//	err = g.DB().Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
+//		// 在task_info表中插入任务
+//		_, err = tx.Ctx(ctx).Model(dao.YoungeeTaskInfo.Table).Data(&taskInfo).Insert()
+//		if err != nil {
+//			return err
+//		}
+//
+//		// 对应项目的报名人数自增
+//		_, err = tx.Ctx(ctx).Model(dao.ProjectInfo.Table).Where(dao.ProjectInfo.Columns.ProjectId, projectDetail.ProjectId).Increment(dao.ProjectInfo.Columns.ApplyNum, 1)
+//		if err != nil {
+//			return err
+//		}
+//		return nil
+//	})
+//	if err != nil {
+//		return &TalentHttpResult{Code: -18, Msg: "add Task data failed"}
+//	}
+//
+//	return &TalentHttpResult{Code: 0, Msg: "success", Data: newTaskId}
+//}
+
+// 判断是否已报名任务,快手平台账号选择时,已经判断过
 func IsSignUpTask(r *ghttp.Request) *TalentHttpResult {
 	tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
 	if err != nil {
@@ -251,12 +252,14 @@ func GetTaskBriefList(r *ghttp.Request) *TalentHttpResult {
 
 	fmt.Print(whereStr)
 	// 获取任务列表
-	var taskList []*model.YoungeeTaskInfo
+	var taskList []*youngee_talent_model.YoungeeTaskInfo
+	//此达人下,所有快手账号的任务都展示
 	err = g.Model(dao.YoungeeTaskInfo.Table).Where(whereStr).Scan(&taskList)
 	if err != nil {
 		return &TalentHttpResult{Code: -1, Msg: "Get task list failed"}
 	}
 
+	//便后续根据 PlatformId 快速查找平台信息。platformMap的key是PlatformId,value是平台具体描述
 	platformMap := make(map[string]model.InfoThirdPlatform)
 	platformInfo := []*model.InfoThirdPlatform{}
 	if len(taskList) != 0 {
@@ -271,23 +274,34 @@ func GetTaskBriefList(r *ghttp.Request) *TalentHttpResult {
 	}
 
 	// 为每个任务根据项目id查询项目名称和主图
+	//taskBriefList存了各个阶段的tasklist
 	taskBriefList := youngee_talent_model.TaskInfoBriefList{}
-	for _, v := range taskList {
-		projectInfo, err := g.Model(dao.ProjectInfo.Table).Where("project_id = ?", v.ProjectId).One()
+	for _, v := range taskList { //taskList含所有任务
+		//获取具体的招募策略,taskInfo中
+		var projectDetail *youngee_talent_model.ProjectDetail
+		err := g.Model("project_info").WithAll().Where("project_id = ?", v.ProjectId).Scan(&projectDetail)
+		fmt.Println("projectDetail-----", projectDetail)
 		if err != nil {
 			return &TalentHttpResult{Code: -1, Msg: "Get fullproject info failed"}
 		}
-		account, err := g.Model(dao.YoungeePlatformAccountInfo.Table).One("platform_id = ? and talent_id = ?", projectInfo[dao.ProjectInfo.Columns.ProjectPlatform], v.TalentId)
+		var account *youngee_talent_model.KuaishouUserInfo
+		err = g.Model("platform_kuaishou_user_info").Where("platform_id = ? and talent_id = ? and open_id = ?", 8, tid, v.OpenId).Scan(&account)
+		//拿快手平台验证是否过期
+		expired := youngee_talent_service.CheckKuaishouTokenExp(account.OpenId)
+		account.Expired = expired
+
 		if err != nil {
 			return &TalentHttpResult{Code: -1, Msg: "Get account info failed"}
 		}
+		//taskInfoBrief含需要展示在页面的内容,被加入各阶段List
 		taskInfoBrief := &youngee_talent_model.TaskInfoBrief{
-			TaskId:           v.TaskId,
-			PlatformIconUrl:  platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformIcon,
-			PlatformName:     platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformName,
-			PlatformNickName: account[dao.YoungeePlatformAccountInfo.Columns.PlatformNickname].String(),
-			ProjectName:      projectInfo[dao.ProjectInfo.Columns.ProjectName].String(),
-			ProductPhotoSnap: projectInfo[dao.ProjectInfo.Columns.ProductPhotoSnap].String(),
+			TaskId:          v.TaskId,
+			PlatformIconUrl: platformMap[strconv.Itoa(projectDetail.PlatformInfo.PlatformId)].PlatformIcon,
+			//PlatformName:     platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformName,
+			//PlatformNickName: account[dao.YoungeePlatformAccountInfo.Columns.PlatformNickname].String(),
+
+			ProjectName:      projectDetail.ProjectName,
+			ProductPhotoSnap: projectDetail.ProductPhotoSnap,
 			TaskStatus:       v.TaskStatus,
 			TaskStage:        v.TaskStage,
 			LinkStatus:       v.LinkStatus,
@@ -298,6 +312,10 @@ func GetTaskBriefList(r *ghttp.Request) *TalentHttpResult {
 			BreakRate:        v.ScriptBreakRate + v.SketchBreakRate + v.LinkBreakRate + v.DataBreakRate,
 			CurBreakAt:       v.CurBreakAt,
 			FeeForm:          v.FeeForm,
+			ProjectDetail:    projectDetail,
+			TaskInfo:         v,
+			AccountInfo:      account, //含是否过期,粉丝数,作品数目
+
 		}
 		taskBriefList.AllTaskInfoList = append(taskBriefList.AllTaskInfoList, taskInfoBrief)
 
@@ -314,84 +332,84 @@ func GetTaskBriefList(r *ghttp.Request) *TalentHttpResult {
 }
 
 // 查询执行中所有任务
-func GetExeTaskBriefList(r *ghttp.Request) *TalentHttpResult {
-	tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
-	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
-	}
-	var taskStageList = [5]int{0, 7, 9, 11, 13}
-	taskStageKey := r.GetQueryInt("taskStage", 0)
-	if taskStageKey == 0 {
-		return &TalentHttpResult{Code: -2, Msg: "parse param error"}
-	}
-	taskStage := taskStageList[taskStageKey+1]
-
-	// 获取任务列表
-	//这是一个切片,其中的每个元素都是指向 model.YoungeeTaskInfo 结构体的指针。通常用于存储多个任务信息的列表。
-	var taskList []*model.YoungeeTaskInfo
-	whereCondition := g.Map{
-		dao.YoungeeTaskInfo.Columns.TalentId:  tid,
-		dao.YoungeeTaskInfo.Columns.TaskStage: taskStage,
-	}
-	err = g.Model(dao.YoungeeTaskInfo.Table).Where(whereCondition).Scan(&taskList)
-	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: "Get task list failed"}
-	}
-
-	platformMap := make(map[string]model.InfoThirdPlatform)
-	var platformInfo []*model.InfoThirdPlatform
-	if len(taskList) != 0 {
-		err := g.Model(dao.InfoThirdPlatform.Table).Scan(&platformInfo)
-		if err != nil {
-			return &TalentHttpResult{Code: -1, Msg: "Get platform failed"}
-		}
-
-		for i, _ := range platformInfo {
-			platformMap[strconv.Itoa(platformInfo[i].PlatformId)] = *platformInfo[i]
-		}
-	}
-
-	// 为每个任务根据项目id查询项目名称和主图
-	var taskBriefList []*youngee_talent_model.TaskInfoBrief
-	for _, v := range taskList {
-		whereCondition = g.Map{
-			dao.ProjectInfo.Columns.ProjectId: v.ProjectId,
-		}
-		projectInfo, err := g.Model(dao.ProjectInfo.Table).Where(whereCondition).One()
-		if err != nil {
-			return &TalentHttpResult{Code: -1, Msg: "Get fullproject info failed"}
-		}
-		whereCondition = g.Map{
-			dao.YoungeePlatformAccountInfo.Columns.PlatformId: projectInfo[dao.ProjectInfo.Columns.ProjectPlatform],
-			dao.YoungeePlatformAccountInfo.Columns.TalentId:   v.TalentId,
-		}
-		account, err := g.Model(dao.YoungeePlatformAccountInfo.Table).Where(whereCondition).One()
-		if err != nil {
-			return &TalentHttpResult{Code: -1, Msg: "Get account info failed"}
-		}
-		taskInfoBrief := &youngee_talent_model.TaskInfoBrief{
-			TaskId:           v.TaskId,
-			PlatformIconUrl:  platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformIcon,
-			PlatformName:     platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformName,
-			PlatformNickName: account[dao.YoungeePlatformAccountInfo.Columns.PlatformNickname].String(),
-			ProjectName:      projectInfo[dao.ProjectInfo.Columns.ProjectName].String(),
-			ProductPhotoSnap: projectInfo[dao.ProjectInfo.Columns.ProductPhotoSnap].String(),
-			TaskStatus:       v.TaskStatus,
-			TaskStage:        v.TaskStage,
-			LinkStatus:       v.LinkStatus,
-			DataStatus:       v.DataStatus,
-			ScriptStatus:     v.ScriptStatus,
-			SketchStatus:     v.SketchStatus,
-			TaskReward:       v.TaskReward,
-			BreakRate:        v.ScriptBreakRate + v.SketchBreakRate + v.LinkBreakRate + v.DataBreakRate,
-			CurBreakAt:       v.CurBreakAt,
-			FeeForm:          v.FeeForm,
-		}
-		taskBriefList = append(taskBriefList, taskInfoBrief)
-	}
-
-	return &TalentHttpResult{Code: 0, Msg: "success", Data: taskBriefList}
-}
+//func GetExeTaskBriefList(r *ghttp.Request) *TalentHttpResult {
+//	tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
+//	if err != nil {
+//		return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
+//	}
+//	var taskStageList = [5]int{0, 7, 9, 11, 13}
+//	taskStageKey := r.GetQueryInt("taskStage", 0)
+//	if taskStageKey == 0 {
+//		return &TalentHttpResult{Code: -2, Msg: "parse param error"}
+//	}
+//	taskStage := taskStageList[taskStageKey+1]
+//
+//	// 获取任务列表
+//	//这是一个切片,其中的每个元素都是指向 model.YoungeeTaskInfo 结构体的指针。通常用于存储多个任务信息的列表。
+//	var taskList []*model.YoungeeTaskInfo
+//	whereCondition := g.Map{
+//		dao.YoungeeTaskInfo.Columns.TalentId:  tid,
+//		dao.YoungeeTaskInfo.Columns.TaskStage: taskStage,
+//	}
+//	err = g.Model(dao.YoungeeTaskInfo.Table).Where(whereCondition).Scan(&taskList)
+//	if err != nil {
+//		return &TalentHttpResult{Code: -1, Msg: "Get task list failed"}
+//	}
+//
+//	platformMap := make(map[string]model.InfoThirdPlatform)
+//	var platformInfo []*model.InfoThirdPlatform
+//	if len(taskList) != 0 {
+//		err := g.Model(dao.InfoThirdPlatform.Table).Scan(&platformInfo)
+//		if err != nil {
+//			return &TalentHttpResult{Code: -1, Msg: "Get platform failed"}
+//		}
+//
+//		for i, _ := range platformInfo {
+//			platformMap[strconv.Itoa(platformInfo[i].PlatformId)] = *platformInfo[i]
+//		}
+//	}
+//
+//	// 为每个任务根据项目id查询项目名称和主图
+//	var taskBriefList []*youngee_talent_model.TaskInfoBrief
+//	for _, v := range taskList {
+//		whereCondition = g.Map{
+//			dao.ProjectInfo.Columns.ProjectId: v.ProjectId,
+//		}
+//		projectInfo, err := g.Model(dao.ProjectInfo.Table).Where(whereCondition).One()
+//		if err != nil {
+//			return &TalentHttpResult{Code: -1, Msg: "Get fullproject info failed"}
+//		}
+//		whereCondition = g.Map{
+//			dao.YoungeePlatformAccountInfo.Columns.PlatformId: projectInfo[dao.ProjectInfo.Columns.ProjectPlatform],
+//			dao.YoungeePlatformAccountInfo.Columns.TalentId:   v.TalentId,
+//		}
+//		account, err := g.Model(dao.YoungeePlatformAccountInfo.Table).Where(whereCondition).One()
+//		if err != nil {
+//			return &TalentHttpResult{Code: -1, Msg: "Get account info failed"}
+//		}
+//		taskInfoBrief := &youngee_talent_model.TaskInfoBrief{
+//			TaskId:           v.TaskId,
+//			PlatformIconUrl:  platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformIcon,
+//			PlatformName:     platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformName,
+//			PlatformNickName: account[dao.YoungeePlatformAccountInfo.Columns.PlatformNickname].String(),
+//			ProjectName:      projectInfo[dao.ProjectInfo.Columns.ProjectName].String(),
+//			ProductPhotoSnap: projectInfo[dao.ProjectInfo.Columns.ProductPhotoSnap].String(),
+//			TaskStatus:       v.TaskStatus,
+//			TaskStage:        v.TaskStage,
+//			LinkStatus:       v.LinkStatus,
+//			DataStatus:       v.DataStatus,
+//			ScriptStatus:     v.ScriptStatus,
+//			SketchStatus:     v.SketchStatus,
+//			TaskReward:       v.TaskReward,
+//			BreakRate:        v.ScriptBreakRate + v.SketchBreakRate + v.LinkBreakRate + v.DataBreakRate,
+//			CurBreakAt:       v.CurBreakAt,
+//			FeeForm:          v.FeeForm,
+//		}
+//		taskBriefList = append(taskBriefList, taskInfoBrief)
+//	}
+//
+//	return &TalentHttpResult{Code: 0, Msg: "success", Data: taskBriefList}
+//}
 
 // 查询执行中所有任务
 func GetExeTaskNum(r *ghttp.Request) *TalentHttpResult {
@@ -505,3 +523,162 @@ func GetTaskDetail(r *ghttp.Request) *TalentHttpResult {
 
 	return &TalentHttpResult{Code: 0, Msg: "success", Data: taskDetail}
 }
+
+// 匹配种草策略,含是否可选属性
+func GetProjRecruitList(r *ghttp.Request) *TalentHttpResult {
+	fanNum := r.GetQueryInt("fan_num", -1)
+	projectId := r.GetQueryString("project_id", -1)
+	var recruitStrategies []*youngee_talent_model.RecruitStrategy
+	err := g.DB().Model("recruit_strategy").Where("project_id = ?", projectId).Scan(&recruitStrategies)
+	if err != nil {
+		fmt.Println(err.Error())
+	}
+	for _, strategy := range recruitStrategies {
+		// 判断粉丝数是否满足当前策略的要求
+		if fanNum >= strategy.FollowersLow {
+			// 如果粉丝数满足策略的范围,设置 is_fit 为 1
+			strategy.IsFit = 1
+		} else {
+			// 否则设置 is_fit 为 0
+			strategy.IsFit = 0
+		}
+	}
+	//根据projectId获取招募策略表多条策略,
+	return &TalentHttpResult{Code: 0, Msg: "success", Data: recruitStrategies}
+}
+
+// 报名种草任务
+func SignUpTaskWithKsAccount(r *ghttp.Request) *TalentHttpResult {
+	tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
+	if err != nil {
+		return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
+	}
+
+	//POST请求体信息
+	var signTaskInfo *youngee_talent_model.SignTaskInfo
+	err = r.ParseForm(&signTaskInfo)
+	if err != nil {
+		return &TalentHttpResult{Code: -2, Msg: "data query failed"}
+	}
+
+	//种草详情信息
+	var projectDetail *youngee_talent_model.ProjectDetail
+	err = g.DB().Model(youngee_talent_model.ProjectDetail{}).WithAll().Where("project_id", signTaskInfo.ProjectId).Scan(&projectDetail)
+	if err != nil {
+		return &TalentHttpResult{Code: -3, Msg: err.Error()}
+	}
+
+	//达人用户信息
+	var talentInfo *youngee_talent_model.TalentInfo
+	err = g.DB().Model("youngee_talent_info").WithAll().Where("id", tid).Scan(&talentInfo)
+	if err != nil {
+		return &TalentHttpResult{Code: -4, Msg: "Get talent info failed"}
+	}
+
+	//达人快手信息
+	var accountInfo *youngee_talent_model.KuaishouUserInfo
+	err = g.DB().Model("platform_kuaishou_user_info").WithAll().Where("talent_id = ? AND open_id = ? AND platform_id = ? ", tid, signTaskInfo.OpenID, 8).Scan(&accountInfo)
+	if err != nil {
+		return &TalentHttpResult{Code: -5, Msg: err.Error()}
+	}
+
+	//var accountInfo *youngee_talent_model.PlatformAccountInfo
+	//err = g.DB().Model("youngee_platform_account_info").WithAll().Where("talent_id = ? and platform_id = ?", tid, projectDetail.ProjectPlatform).Scan(&accountInfo)
+	//if err != nil {
+	//	return &TalentHttpResult{Code: -5, Msg: err.Error()}
+	//}
+
+	//project_form=1寄拍需要填写地址
+	var address *model.YoungeeTalentDeliveryAddress
+	if projectDetail.ProjectForm == 1 {
+		err := g.DB().Model(dao.YoungeeTalentDeliveryAddress.Table).Where("talent_id = ? and address_id = ?", tid, signTaskInfo.AddressId).Scan(&address)
+		if err != nil {
+			return &TalentHttpResult{Code: -6, Msg: err.Error()}
+		}
+	} else {
+		address = new(model.YoungeeTalentDeliveryAddress) //赋空值
+	}
+	var newTaskId string
+	// 首先生成任务id
+	newTaskId = utils.GetUuid.GetTaskId(projectDetail.ProjectId, projectDetail.EnterpriseId, tid)
+	//// 生成达人平台账号信息快照
+	accountSnap, err := gjson.Encode(accountInfo)
+	//if err != nil {
+	//	return &TalentHttpResult{Code: -7, Msg: "encode platform snap failed"}
+	//}
+
+	// 生成达人信息快照
+	talentSnap, err := gjson.Encode(talentInfo)
+	if err != nil {
+		return &TalentHttpResult{Code: -8, Msg: "encode talent info snap failed"}
+	}
+
+	// 生成收货地址快照
+	addrSnap, err := gjson.Encode(address)
+	if err != nil {
+		return &TalentHttpResult{Code: -9, Msg: "encode delivery address snap failed"}
+	}
+	taskInfo := youngee_talent_model.YoungeeTaskInfo{}
+	if projectDetail.ProjectType == 1 {
+		// 全流程任务/公开任务
+		var strategy *youngee_talent_model.RecruitStrategy
+		err = g.DB().Model("recruit_strategy").WithAll().Where("strategy_id = ? and project_id= ?", signTaskInfo.StrategyId, signTaskInfo.ProjectId).Scan(&strategy)
+		if err != nil {
+			return &TalentHttpResult{Code: -10, Msg: err.Error()}
+		}
+		taskInfo = youngee_talent_model.YoungeeTaskInfo{
+			TaskId:                 newTaskId,
+			ProjectId:              signTaskInfo.ProjectId,
+			TalentId:               tid,
+			OpenId:                 accountInfo.OpenId,
+			TalentPlatformInfoSnap: string(accountSnap),
+			TalentPersonalInfoSnap: string(talentSnap),
+			TalentPostAddrSnap:     string(addrSnap),
+			StrategyId:             signTaskInfo.StrategyId,
+			TaskStage:              1,
+			FeeForm:                strategy.FeeForm,
+			//ServiceCharge:          serviceCharge,
+			//ServiceRate:            serviceRate,
+			CreateDate:      gtime.Now(),
+			TaskStatus:      1,
+			LogisticsStatus: 1,
+			LinkStatus:      1,
+			DataStatus:      1,
+			ScriptStatus:    1,
+			SketchStatus:    1,
+			CompleteStatus:  1,
+			CurDefaultType:  0,
+			WithdrawStatus:  1,
+			SettleStatus:    1,
+			DraftFee:        signTaskInfo.Offer, //商家或者服务商可以看到的稿费价格,无非置换为空,一口价为策略表中的t_offer,自报价是达人添加的,
+			SettleAmount:    signTaskInfo.Offer,
+		}
+	}
+	err = g.DB().Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
+		// 在task_info表中插入任务
+		_, err = tx.Ctx(ctx).Model(dao.YoungeeTaskInfo.Table).Data(&taskInfo).Insert()
+		if err != nil {
+			return err
+		}
+
+		// 对应项目的报名人数自增
+		_, err = tx.Ctx(ctx).Model(dao.ProjectInfo.Table).Where(dao.ProjectInfo.Columns.ProjectId, projectDetail.ProjectId).Increment(dao.ProjectInfo.Columns.ApplyNum, 1)
+		if err != nil {
+			return err
+		}
+		//如果经过服务商,服务younggee_s_project_info中报名人数加一
+		if projectDetail.ProjectInfoSupplier != nil {
+			_, err = tx.Ctx(ctx).Model("younggee_s_project_info").Where("project_id = ? ", projectDetail.ProjectId).Increment("apply_num", 1)
+			if err != nil {
+				return err
+			}
+		}
+
+		return nil
+	})
+	if err != nil {
+		return &TalentHttpResult{Code: -18, Msg: "add Task data failed"}
+	}
+
+	return &TalentHttpResult{Code: 0, Msg: "success", Data: newTaskId}
+}

+ 162 - 160
app/service/youngee_task_service/task_link.go

@@ -1,160 +1,162 @@
-package youngee_task_service
-
-import (
-	"youngmini_server/app/dao"
-	"youngmini_server/app/model"
-	"youngmini_server/app/model/youngee_talent_model"
-
-	"github.com/gogf/gf/frame/g"
-	"github.com/gogf/gf/net/ghttp"
-	"github.com/gogf/gf/os/gtime"
-)
-
-// 添加链接service
-func AddTaskLink(r *ghttp.Request) *TalentHttpResult {
-	var LinkInfoReq *youngee_talent_model.AddTaskLinkRequest
-	err := r.ParseForm(&LinkInfoReq)
-	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: err.Error()}
-	}
-	// 查询该任务id是否有未提交链接
-	// 查询该任务是否有未提交脚本,无则插入,有则更新
-	unSubmitLink, err := g.DB().Model(model.YounggeeLinkInfo{}).Where("task_id = ? and is_submit = 0", LinkInfoReq.TaskId).One()
-	if err != nil {
-		return &TalentHttpResult{Code: -2, Msg: "YounggeeLinkInfo find failed"}
-	}
-	if unSubmitLink != nil {
-		_, err = g.DB().Model(model.YounggeeLinkInfo{}).Where("link_id = ?", unSubmitLink[dao.YounggeeLinkInfo.Columns.LinkId]).Delete()
-		if err != nil {
-			return &TalentHttpResult{Code: -3, Msg: "YounggeeLinkInfo delete failed"}
-		}
-	}
-
-	// 如果无未提交链接,则直接插入
-	LinkInfo := model.YounggeeLinkInfo{
-		TaskId:   LinkInfoReq.TaskId,
-		LinkUrl:  LinkInfoReq.LinkUrl,
-		PhotoUrl: LinkInfoReq.PhotoUrl,
-		CreateAt: gtime.Now(),
-		IsReview: 0,
-		IsSubmit: 0,
-		IsOk:     0,
-	}
-
-	_, err = g.DB().Model(model.YounggeeLinkInfo{}).Data(LinkInfo).Insert()
-	if err != nil {
-		return &TalentHttpResult{Code: -3, Msg: "YounggeeLinkInfo insert failed"}
-	}
-
-	LinkStatus, err := g.DB().Model(model.YoungeeTaskInfo{}).Fields("link_status").Where("task_id = ?", LinkInfoReq.TaskId).Value()
-	if err != nil {
-		return &TalentHttpResult{Code: -5, Msg: "Get task info failed"}
-	}
-	if LinkStatus.Int64() == 1 {
-		_, err = g.Model(dao.YoungeeTaskInfo.Table).Where("task_id = ?", LinkInfoReq.TaskId).Update(g.Map{"link_status": 2})
-		if err != nil {
-			return &TalentHttpResult{Code: -6, Msg: "YoungeeTaskInfo update failed"}
-		}
-	} else if LinkStatus.Int64() == 3 {
-		_, err = g.Model(dao.YoungeeTaskInfo.Table).Where("task_id = ?", LinkInfoReq.TaskId).Update(g.Map{"link_status": 4})
-		if err != nil {
-			return &TalentHttpResult{Code: -6, Msg: "YoungeeTaskInfo update failed"}
-		}
-	}
-
-	return &TalentHttpResult{Code: 0, Msg: "success"}
-}
-
-// 提交链接service
-func SubmitTaskLink(r *ghttp.Request) *TalentHttpResult {
-	taskId, _ := r.Get("task_id").(string)
-	taskInfo := model.YoungeeTaskInfo{}
-	// 查询是否处于违约状态
-	err1 := g.DB().Model(model.YoungeeTaskInfo{}).Where("task_id = ?", taskId).Scan(&taskInfo)
-	if err1 != nil {
-		return &TalentHttpResult{Code: -1, Msg: "YoungeeTaskInfo find failed"}
-	}
-	if taskInfo.CurDefaultType == 5 || taskInfo.CurDefaultType == 9 {
-		// 若处于违约状态则解除并更新企业应支付金额
-		_, err1 = g.DB().Model(model.YoungeeTaskInfo{}).Data(g.Map{"cur_default_type": "0", "real_payment": taskInfo.AllPayment, "err_break_rate": 0}).Where("task_id = ?", taskId).Update()
-		if err1 != nil {
-			return &TalentHttpResult{Code: -2, Msg: "YoungeeTaskInfo update failed"}
-		}
-
-		// 更新违约记录表
-		_, err1 = g.DB().Model(model.YoungeeContractInfo{}).Data(g.Map{"default_status": 2}).Where("task_id = ? and default_status in (?)", taskId, g.Slice{1, 3, 4}).Update()
-		if err1 != nil {
-			return &TalentHttpResult{Code: -2, Msg: "YoungeeContractInfo update failed"}
-		}
-	}
-
-	// 查询该任务是否有已添加或已修改链接
-	res, err := g.DB().Model(model.YounggeeLinkInfo{}).Where("task_id = ? and is_submit = 0", taskId).Count()
-	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: "YounggeeLinkInfo find failed"}
-	}
-	if res == 1 && (taskInfo.LinkStatus == 2 || taskInfo.LinkStatus == 4) {
-		_, err = g.DB().Model(model.YounggeeLinkInfo{}).Data(g.Map{"is_submit": "1", "submit_at": gtime.Now()}).Where("task_id = ? and is_submit = 0", taskId).Update()
-		if err != nil {
-			return &TalentHttpResult{Code: -3, Msg: "YounggeeLinkInfo update failed"}
-		}
-		_, err = g.DB().Model(model.YoungeeTaskInfo{}).Data(g.Map{"task_stage": "12"}).Where("task_id = ?", taskId).Update()
-		if err != nil {
-			return &TalentHttpResult{Code: -4, Msg: "YoungeeTaskInfo update failed"}
-		}
-		// 记录任务日志-上传链接
-		taskLog := model.YounggeeTaskLog{
-			TaskId:  taskId,
-			Content: "上传链接",
-			LogAt:   gtime.Now(),
-		}
-		_, err = g.DB().Model(dao.YounggeeTaskLog.Table).Data(&taskLog).Insert()
-		if err != nil {
-			return &TalentHttpResult{Code: -5, Msg: "YounggeeTaskLog insert failed"}
-		}
-		projectInfo := model.ProjectInfo{}
-		err1 = g.DB().Model(model.ProjectInfo{}).Where("project_id = ?", taskInfo.ProjectId).Scan(&projectInfo)
-		if err1 != nil {
-			return &TalentHttpResult{Code: -8, Msg: "ProjectInfo find failed"}
-		}
-		messageInfo := model.YounggeeMessageInfo{
-			MessageId:   12,
-			MessageType: 2,
-			CreatedAt:   gtime.Now(),
-			TalentId:    taskInfo.TalentId,
-			ProjectName: projectInfo.ProjectName,
-			IsReaded:    0,
-			IsDeleted:   0,
-		}
-		_, err = g.DB().Model(dao.YounggeeMessageInfo.Table).Data(&messageInfo).Insert()
-		if err != nil {
-			return &TalentHttpResult{Code: -9, Msg: "YounggeeMessageInfo insert failed"}
-		}
-	}
-
-	return &TalentHttpResult{Code: 0, Msg: "success"}
-}
-
-// 查询链接提交审阅记录service
-func GetTaskLink(r *ghttp.Request) *TalentHttpResult {
-	taskId := r.Get("task_id")
-
-	res, err := g.DB().Model(dao.YounggeeLinkInfo.Table).Where("is_submit = 1 and is_review = 1 and task_id = ?", taskId).OrderAsc("submit_at").All()
-	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: err.Error()}
-	}
-
-	return &TalentHttpResult{Code: 0, Msg: "success", Data: res}
-}
-
-// 查询未提交链接service
-func GetUnSubmitTaskLink(r *ghttp.Request) *TalentHttpResult {
-	taskId := r.Get("task_id")
-
-	res, err := g.DB().Model(dao.YounggeeLinkInfo.Table).Where("is_review = 0 and task_id = ?", taskId).One()
-	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: err.Error()}
-	}
-
-	return &TalentHttpResult{Code: 0, Msg: "success", Data: res}
-}
+package youngee_task_service
+
+import (
+	"youngmini_server/app/dao"
+	"youngmini_server/app/model"
+	"youngmini_server/app/model/youngee_talent_model"
+
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/net/ghttp"
+	"github.com/gogf/gf/os/gtime"
+)
+
+// 添加链接service
+func AddTaskLink(r *ghttp.Request) *TalentHttpResult {
+	var LinkInfoReq *youngee_talent_model.AddTaskLinkRequest
+	err := r.ParseForm(&LinkInfoReq)
+	if err != nil {
+		return &TalentHttpResult{Code: -1, Msg: err.Error()}
+	}
+	// 查询该任务id是否有未提交链接
+	// 查询该任务是否有未提交脚本,无则插入,有则更新
+	unSubmitLink, err := g.DB().Model(model.YounggeeLinkInfo{}).Where("task_id = ? and is_submit = 0", LinkInfoReq.TaskId).One()
+	if err != nil {
+		return &TalentHttpResult{Code: -2, Msg: "YounggeeLinkInfo find failed"}
+	}
+	if unSubmitLink != nil {
+		_, err = g.DB().Model(model.YounggeeLinkInfo{}).Where("link_id = ?", unSubmitLink[dao.YounggeeLinkInfo.Columns.LinkId]).Delete()
+		if err != nil {
+			return &TalentHttpResult{Code: -3, Msg: "YounggeeLinkInfo delete failed"}
+		}
+	}
+
+	// 如果无未提交链接,则直接插入
+	LinkInfo := model.YounggeeLinkInfo{
+		TaskId:   LinkInfoReq.TaskId,
+		LinkUrl:  LinkInfoReq.LinkUrl,
+		PhotoUrl: LinkInfoReq.PhotoUrl,
+		CreateAt: gtime.Now(),
+		IsReview: 0,
+		IsSubmit: 0,
+		IsOk:     0,
+	}
+
+	//todo : task表中task stage 12:链接待审
+
+	_, err = g.DB().Model(model.YounggeeLinkInfo{}).Data(LinkInfo).Insert()
+	if err != nil {
+		return &TalentHttpResult{Code: -3, Msg: "YounggeeLinkInfo insert failed"}
+	}
+
+	LinkStatus, err := g.DB().Model(model.YoungeeTaskInfo{}).Fields("link_status").Where("task_id = ?", LinkInfoReq.TaskId).Value()
+	if err != nil {
+		return &TalentHttpResult{Code: -5, Msg: "Get task info failed"}
+	}
+	if LinkStatus.Int64() == 1 {
+		_, err = g.Model(dao.YoungeeTaskInfo.Table).Where("task_id = ?", LinkInfoReq.TaskId).Update(g.Map{"link_status": 2})
+		if err != nil {
+			return &TalentHttpResult{Code: -6, Msg: "YoungeeTaskInfo update failed"}
+		}
+	} else if LinkStatus.Int64() == 3 {
+		_, err = g.Model(dao.YoungeeTaskInfo.Table).Where("task_id = ?", LinkInfoReq.TaskId).Update(g.Map{"link_status": 4})
+		if err != nil {
+			return &TalentHttpResult{Code: -6, Msg: "YoungeeTaskInfo update failed"}
+		}
+	}
+
+	return &TalentHttpResult{Code: 0, Msg: "success"}
+}
+
+// 提交链接service
+func SubmitTaskLink(r *ghttp.Request) *TalentHttpResult {
+	taskId, _ := r.Get("task_id").(string)
+	taskInfo := model.YoungeeTaskInfo{}
+	// 查询是否处于违约状态
+	err1 := g.DB().Model(model.YoungeeTaskInfo{}).Where("task_id = ?", taskId).Scan(&taskInfo)
+	if err1 != nil {
+		return &TalentHttpResult{Code: -1, Msg: "YoungeeTaskInfo find failed"}
+	}
+	if taskInfo.CurDefaultType == 5 || taskInfo.CurDefaultType == 9 {
+		// 若处于违约状态则解除并更新企业应支付金额
+		_, err1 = g.DB().Model(model.YoungeeTaskInfo{}).Data(g.Map{"cur_default_type": "0", "real_payment": taskInfo.AllPayment, "err_break_rate": 0}).Where("task_id = ?", taskId).Update()
+		if err1 != nil {
+			return &TalentHttpResult{Code: -2, Msg: "YoungeeTaskInfo update failed"}
+		}
+
+		// 更新违约记录表
+		_, err1 = g.DB().Model(model.YoungeeContractInfo{}).Data(g.Map{"default_status": 2}).Where("task_id = ? and default_status in (?)", taskId, g.Slice{1, 3, 4}).Update()
+		if err1 != nil {
+			return &TalentHttpResult{Code: -2, Msg: "YoungeeContractInfo update failed"}
+		}
+	}
+
+	// 查询该任务是否有已添加或已修改链接
+	res, err := g.DB().Model(model.YounggeeLinkInfo{}).Where("task_id = ? and is_submit = 0", taskId).Count()
+	if err != nil {
+		return &TalentHttpResult{Code: -1, Msg: "YounggeeLinkInfo find failed"}
+	}
+	if res == 1 && (taskInfo.LinkStatus == 2 || taskInfo.LinkStatus == 4) {
+		_, err = g.DB().Model(model.YounggeeLinkInfo{}).Data(g.Map{"is_submit": "1", "submit_at": gtime.Now()}).Where("task_id = ? and is_submit = 0", taskId).Update()
+		if err != nil {
+			return &TalentHttpResult{Code: -3, Msg: "YounggeeLinkInfo update failed"}
+		}
+		_, err = g.DB().Model(model.YoungeeTaskInfo{}).Data(g.Map{"task_stage": "12"}).Where("task_id = ?", taskId).Update()
+		if err != nil {
+			return &TalentHttpResult{Code: -4, Msg: "YoungeeTaskInfo update failed"}
+		}
+		// 记录任务日志-上传链接
+		taskLog := model.YounggeeTaskLog{
+			TaskId:  taskId,
+			Content: "上传链接",
+			LogAt:   gtime.Now(),
+		}
+		_, err = g.DB().Model(dao.YounggeeTaskLog.Table).Data(&taskLog).Insert()
+		if err != nil {
+			return &TalentHttpResult{Code: -5, Msg: "YounggeeTaskLog insert failed"}
+		}
+		projectInfo := model.ProjectInfo{}
+		err1 = g.DB().Model(model.ProjectInfo{}).Where("project_id = ?", taskInfo.ProjectId).Scan(&projectInfo)
+		if err1 != nil {
+			return &TalentHttpResult{Code: -8, Msg: "ProjectInfo find failed"}
+		}
+		messageInfo := model.YounggeeMessageInfo{
+			MessageId:   12,
+			MessageType: 2,
+			CreatedAt:   gtime.Now(),
+			TalentId:    taskInfo.TalentId,
+			ProjectName: projectInfo.ProjectName,
+			IsReaded:    0,
+			IsDeleted:   0,
+		}
+		_, err = g.DB().Model(dao.YounggeeMessageInfo.Table).Data(&messageInfo).Insert()
+		if err != nil {
+			return &TalentHttpResult{Code: -9, Msg: "YounggeeMessageInfo insert failed"}
+		}
+	}
+
+	return &TalentHttpResult{Code: 0, Msg: "success"}
+}
+
+// 查询链接提交审阅记录service
+func GetTaskLink(r *ghttp.Request) *TalentHttpResult {
+	taskId := r.Get("task_id")
+
+	res, err := g.DB().Model(dao.YounggeeLinkInfo.Table).Where("is_submit = 1 and is_review = 1 and task_id = ?", taskId).OrderAsc("submit_at").All()
+	if err != nil {
+		return &TalentHttpResult{Code: -1, Msg: err.Error()}
+	}
+
+	return &TalentHttpResult{Code: 0, Msg: "success", Data: res}
+}
+
+// 查询未提交链接service
+func GetUnSubmitTaskLink(r *ghttp.Request) *TalentHttpResult {
+	taskId := r.Get("task_id")
+
+	res, err := g.DB().Model(dao.YounggeeLinkInfo.Table).Where("is_review = 0 and task_id = ?", taskId).One()
+	if err != nil {
+		return &TalentHttpResult{Code: -1, Msg: err.Error()}
+	}
+
+	return &TalentHttpResult{Code: 0, Msg: "success", Data: res}
+}

+ 193 - 192
app/service/youngee_task_service/task_sketch.go

@@ -1,192 +1,193 @@
-package youngee_task_service
-
-import (
-	"strings"
-	"youngmini_server/app/dao"
-	"youngmini_server/app/model"
-	"youngmini_server/app/model/youngee_talent_model"
-
-	"github.com/gogf/gf/frame/g"
-	"github.com/gogf/gf/net/ghttp"
-	"github.com/gogf/gf/os/gtime"
-)
-
-// 添加初稿service
-func AddTaskSketch(r *ghttp.Request) *TalentHttpResult {
-	var sketchInfoReq *youngee_talent_model.AddTaskSketchRequest
-	err := r.ParseForm(&sketchInfoReq)
-	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: err.Error()}
-	}
-	photoUrl := strings.Split(sketchInfoReq.PhotoUrl, ",")
-	// 查询该任务id是否有未提交初稿
-	// 查询该任务是否有未提交脚本,无则插入,有则更新
-	unSubmitSketch, err := g.DB().Model(model.YounggeeSketchInfo{}).Where("task_id = ? and is_submit = 0", sketchInfoReq.TaskId).One()
-	if err != nil {
-		return &TalentHttpResult{Code: -2, Msg: "YounggeeSketchInfo find failed"}
-	}
-	if unSubmitSketch != nil {
-		// 如果有未提交初稿,则删除并重新添加
-		_, err := g.DB().Model(model.YounggeeSketchPhoto{}).Where("sketch_id = ?", unSubmitSketch[dao.YounggeeSketchInfo.Columns.SketchId]).Delete()
-		if err != nil {
-			return &TalentHttpResult{Code: -3, Msg: "YounggeeSketchPhoto delete failed"}
-		}
-
-		_, err = g.DB().Model(model.YounggeeSketchInfo{}).Where("sketch_id = ?", unSubmitSketch[dao.YounggeeSketchInfo.Columns.SketchId]).Delete()
-		if err != nil {
-			return &TalentHttpResult{Code: -3, Msg: "YounggeeSketchInfo delete failed"}
-		}
-	}
-
-	// 如果无未提交初稿,则直接插入
-	sketchInfo := model.YounggeeSketchInfo{
-		TaskId:   sketchInfoReq.TaskId,
-		Title:    sketchInfoReq.Title,
-		Type:     sketchInfoReq.Type,
-		Content:  sketchInfoReq.Content,
-		CreateAt: gtime.Now(),
-		IsReview: 0,
-		IsSubmit: 0,
-		IsOk:     0,
-	}
-
-	sketchId, err := g.DB().Model(model.YounggeeSketchInfo{}).Data(sketchInfo).InsertAndGetId()
-	if err != nil {
-		return &TalentHttpResult{Code: -3, Msg: "YounggeeSketchInfo insert failed"}
-	}
-	for _, v := range photoUrl {
-		_, err := g.DB().Model(model.YounggeeSketchPhoto{}).Data(g.Map{"sketch_id": sketchId, "photo_url": v, "symbol": sketchInfoReq.Type, "create_at": gtime.Now()}).Insert()
-		if err != nil {
-			return &TalentHttpResult{Code: -3, Msg: "YounggeeSketchPhoto insert failed"}
-		}
-	}
-
-	sketchStatus, err := g.DB().Model(model.YoungeeTaskInfo{}).Fields("sketch_status").Where("task_id = ?", sketchInfoReq.TaskId).Value()
-	if err != nil {
-		return &TalentHttpResult{Code: -5, Msg: "Get task info failed"}
-	}
-	if sketchStatus.Int64() == 1 {
-		_, err = g.Model(dao.YoungeeTaskInfo.Table).Where("task_id = ?", sketchInfoReq.TaskId).Update(g.Map{"sketch_status": 2})
-		if err != nil {
-			return &TalentHttpResult{Code: -6, Msg: "YoungeeTaskInfo update failed"}
-		}
-	} else if sketchStatus.Int64() == 3 {
-		_, err = g.Model(dao.YoungeeTaskInfo.Table).Where("task_id = ?", sketchInfoReq.TaskId).Update(g.Map{"sketch_status": 4})
-		if err != nil {
-			return &TalentHttpResult{Code: -6, Msg: "YoungeeTaskInfo update failed"}
-		}
-	}
-
-	return &TalentHttpResult{Code: 0, Msg: "success"}
-}
-
-// 提交初稿service
-func SubmitTaskSketch(r *ghttp.Request) *TalentHttpResult {
-	taskId, _ := r.Get("task_id").(string) // 查询是否处于违约状态
-	taskInfo := model.YoungeeTaskInfo{}
-	// 查询是否处于违约状态
-	err1 := g.DB().Model(model.YoungeeTaskInfo{}).Where("task_id = ?", taskId).Scan(&taskInfo)
-	if err1 != nil {
-		return &TalentHttpResult{Code: -1, Msg: "YoungeeTaskInfo find failed"}
-	}
-	if taskInfo.CurDefaultType == 3 || taskInfo.CurDefaultType == 9 {
-		// 若处于违约状态则解除并更新企业应支付金额
-		_, err1 = g.DB().Model(model.YoungeeTaskInfo{}).Data(g.Map{"cur_default_type": "0", "real_payment": taskInfo.AllPayment, "err_break_rate": 0}).Where("task_id = ?", taskId).Update()
-		if err1 != nil {
-			return &TalentHttpResult{Code: -2, Msg: "YoungeeTaskInfo update failed"}
-		}
-
-		// 更新违约记录表
-		_, err1 = g.DB().Model(model.YoungeeContractInfo{}).Data(g.Map{"default_status": 2}).Where("task_id = ? and default_status in (?)", taskId, g.Slice{1, 3, 4}).Update()
-		if err1 != nil {
-			return &TalentHttpResult{Code: -2, Msg: "YoungeeContractInfo update failed"}
-		}
-	}
-
-	// 查询该任务是否有已添加或已修改初稿
-	res, err := g.DB().Model(model.YounggeeSketchInfo{}).Where("task_id = ? and is_submit = 0", taskId).Count()
-	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: "YounggeeSketchInfo find failed"}
-	}
-	if res == 1 && (taskInfo.SketchStatus == 2 || taskInfo.SketchStatus == 4) {
-		_, err = g.DB().Model(model.YounggeeSketchInfo{}).Data(g.Map{"is_submit": "1", "submit_at": gtime.Now()}).Where("task_id = ? and is_submit = 0", taskId).Update()
-		if err != nil {
-			return &TalentHttpResult{Code: -3, Msg: "YounggeeSketchInfo update failed"}
-		}
-		_, err = g.DB().Model(model.YoungeeTaskInfo{}).Data(g.Map{"task_stage": "10"}).Where("task_id = ?", taskId).Update()
-		if err != nil {
-			return &TalentHttpResult{Code: -4, Msg: "YoungeeTaskInfo update failed"}
-		}
-		// 记录任务日志-上传初稿
-		taskLog := model.YounggeeTaskLog{
-			TaskId:  taskId,
-			Content: "上传初稿",
-			LogAt:   gtime.Now(),
-		}
-		_, err = g.DB().Model(dao.YounggeeTaskLog.Table).Data(&taskLog).Insert()
-		if err != nil {
-			return &TalentHttpResult{Code: -5, Msg: "YounggeeTaskLog insert failed"}
-		}
-		projectInfo := model.ProjectInfo{}
-		err1 := g.DB().Model(model.ProjectInfo{}).Where("project_id = ?", taskInfo.ProjectId).Scan(&projectInfo)
-		if err1 != nil {
-			return &TalentHttpResult{Code: -8, Msg: "ProjectInfo find failed"}
-		}
-		messageInfo := model.YounggeeMessageInfo{
-			MessageId:   11,
-			MessageType: 2,
-			CreatedAt:   gtime.Now(),
-			TalentId:    taskInfo.TalentId,
-			ProjectName: projectInfo.ProjectName,
-			IsReaded:    0,
-			IsDeleted:   0,
-		}
-		_, err = g.DB().Model(dao.YounggeeMessageInfo.Table).Data(&messageInfo).Insert()
-		if err != nil {
-			return &TalentHttpResult{Code: -9, Msg: "YounggeeMessageInfo insert failed"}
-		}
-	}
-
-	return &TalentHttpResult{Code: 0, Msg: "success"}
-}
-
-// 查询脚本提交审阅记录service
-func GetTaskSketch(r *ghttp.Request) *TalentHttpResult {
-	taskId := r.Get("task_id")
-
-	var sketchInfoList []*youngee_talent_model.TaskSketchInfo
-	err := g.DB().Model(dao.YounggeeSketchInfo.Table).Where("is_submit = 1 and is_review = 1 and task_id = ?", taskId).OrderAsc("submit_at").Scan(&sketchInfoList)
-	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: err.Error()}
-	}
-	for _, v := range sketchInfoList {
-		var sketchPhotoList []*youngee_talent_model.YounggeeSketchPhoto
-		err = g.DB().Model(dao.YounggeeSketchPhoto.Table).Where("sketch_id = ?", v.SketchId).Scan(&sketchPhotoList)
-		if err != nil {
-			return &TalentHttpResult{Code: -2, Msg: err.Error()}
-		}
-		v.Photo = sketchPhotoList
-	}
-
-	return &TalentHttpResult{Code: 0, Msg: "success", Data: sketchInfoList}
-}
-
-// 查询未提交初稿service
-func GetUnSubmitTaskSketch(r *ghttp.Request) *TalentHttpResult {
-	taskId := r.Get("task_id")
-
-	var unSubmitSketch *youngee_talent_model.TaskSketchInfo
-	err := g.DB().Model(dao.YounggeeSketchInfo.Table).Where("is_review = 0 and task_id = ?", taskId).OrderAsc("submit_at").Scan(&unSubmitSketch)
-	if err != nil {
-		return &TalentHttpResult{Code: -1, Msg: err.Error()}
-	}
-
-	var sketchPhotoList []*youngee_talent_model.YounggeeSketchPhoto
-	err = g.DB().Model(dao.YounggeeSketchPhoto.Table).Where("sketch_id = ?", unSubmitSketch.SketchId).Scan(&sketchPhotoList)
-	if err != nil {
-		return &TalentHttpResult{Code: -2, Msg: err.Error()}
-	}
-	unSubmitSketch.Photo = sketchPhotoList
-
-	return &TalentHttpResult{Code: 0, Msg: "success", Data: unSubmitSketch}
-}
+package youngee_task_service
+
+import (
+	"strings"
+	"youngmini_server/app/dao"
+	"youngmini_server/app/model"
+	"youngmini_server/app/model/youngee_talent_model"
+
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/net/ghttp"
+	"github.com/gogf/gf/os/gtime"
+)
+
+// 添加初稿service
+func AddTaskSketch(r *ghttp.Request) *TalentHttpResult {
+	var sketchInfoReq *youngee_talent_model.AddTaskSketchRequest
+	err := r.ParseForm(&sketchInfoReq)
+	if err != nil {
+		return &TalentHttpResult{Code: -1, Msg: err.Error()}
+	}
+	photoUrl := strings.Split(sketchInfoReq.PhotoUrl, ",")
+	// 查询该任务id是否有未提交初稿
+	// 查询该任务是否有未提交脚本,无则插入,有则更新
+	unSubmitSketch, err := g.DB().Model(model.YounggeeSketchInfo{}).Where("task_id = ? and is_submit = 0", sketchInfoReq.TaskId).One()
+	if err != nil {
+		return &TalentHttpResult{Code: -2, Msg: "YounggeeSketchInfo find failed"}
+	}
+	if unSubmitSketch != nil {
+		// 如果有未提交初稿,则删除并重新添加
+		_, err := g.DB().Model(model.YounggeeSketchPhoto{}).Where("sketch_id = ?", unSubmitSketch[dao.YounggeeSketchInfo.Columns.SketchId]).Delete()
+		if err != nil {
+			return &TalentHttpResult{Code: -3, Msg: "YounggeeSketchPhoto delete failed"}
+		}
+
+		_, err = g.DB().Model(model.YounggeeSketchInfo{}).Where("sketch_id = ?", unSubmitSketch[dao.YounggeeSketchInfo.Columns.SketchId]).Delete()
+		if err != nil {
+			return &TalentHttpResult{Code: -3, Msg: "YounggeeSketchInfo delete failed"}
+		}
+	}
+	// 如果无未提交初稿,则直接插入
+	sketchInfo := model.YounggeeSketchInfo{
+		TaskId:   sketchInfoReq.TaskId,
+		Title:    sketchInfoReq.Title,
+		Type:     sketchInfoReq.Type,
+		Content:  sketchInfoReq.Content,
+		CreateAt: gtime.Now(),
+		IsReview: 0,
+		IsSubmit: 0,
+		IsOk:     0,
+	}
+
+	sketchId, err := g.DB().Model(model.YounggeeSketchInfo{}).Data(sketchInfo).InsertAndGetId()
+	if err != nil {
+		return &TalentHttpResult{Code: -3, Msg: "YounggeeSketchInfo insert failed"}
+	}
+	for _, v := range photoUrl {
+		_, err := g.DB().Model(model.YounggeeSketchPhoto{}).Data(g.Map{"sketch_id": sketchId, "photo_url": v, "symbol": sketchInfoReq.Type, "create_at": gtime.Now()}).Insert()
+		if err != nil {
+			return &TalentHttpResult{Code: -3, Msg: "YounggeeSketchPhoto insert failed"}
+		}
+	}
+	//todo :task_stage改成10 初稿待审
+	//todo: 再次提交,之前的也要保留,不能仅仅updata
+
+	sketchStatus, err := g.DB().Model(model.YoungeeTaskInfo{}).Fields("sketch_status").Where("task_id = ?", sketchInfoReq.TaskId).Value()
+	if err != nil {
+		return &TalentHttpResult{Code: -5, Msg: "Get task info failed"}
+	}
+	if sketchStatus.Int64() == 1 {
+		_, err = g.Model(dao.YoungeeTaskInfo.Table).Where("task_id = ?", sketchInfoReq.TaskId).Update(g.Map{"sketch_status": 2})
+		if err != nil {
+			return &TalentHttpResult{Code: -6, Msg: "YoungeeTaskInfo update failed"}
+		}
+	} else if sketchStatus.Int64() == 3 {
+		_, err = g.Model(dao.YoungeeTaskInfo.Table).Where("task_id = ?", sketchInfoReq.TaskId).Update(g.Map{"sketch_status": 4})
+		if err != nil {
+			return &TalentHttpResult{Code: -6, Msg: "YoungeeTaskInfo update failed"}
+		}
+	}
+
+	return &TalentHttpResult{Code: 0, Msg: "success"}
+}
+
+// 提交初稿service
+func SubmitTaskSketch(r *ghttp.Request) *TalentHttpResult {
+	taskId, _ := r.Get("task_id").(string) // 查询是否处于违约状态
+	taskInfo := model.YoungeeTaskInfo{}
+	// 查询是否处于违约状态
+	err1 := g.DB().Model(model.YoungeeTaskInfo{}).Where("task_id = ?", taskId).Scan(&taskInfo)
+	if err1 != nil {
+		return &TalentHttpResult{Code: -1, Msg: "YoungeeTaskInfo find failed"}
+	}
+	if taskInfo.CurDefaultType == 3 || taskInfo.CurDefaultType == 9 {
+		// 若处于违约状态则解除并更新企业应支付金额
+		_, err1 = g.DB().Model(model.YoungeeTaskInfo{}).Data(g.Map{"cur_default_type": "0", "real_payment": taskInfo.AllPayment, "err_break_rate": 0}).Where("task_id = ?", taskId).Update()
+		if err1 != nil {
+			return &TalentHttpResult{Code: -2, Msg: "YoungeeTaskInfo update failed"}
+		}
+
+		// 更新违约记录表
+		_, err1 = g.DB().Model(model.YoungeeContractInfo{}).Data(g.Map{"default_status": 2}).Where("task_id = ? and default_status in (?)", taskId, g.Slice{1, 3, 4}).Update()
+		if err1 != nil {
+			return &TalentHttpResult{Code: -2, Msg: "YoungeeContractInfo update failed"}
+		}
+	}
+
+	// 查询该任务是否有已添加或已修改初稿
+	res, err := g.DB().Model(model.YounggeeSketchInfo{}).Where("task_id = ? and is_submit = 0", taskId).Count()
+	if err != nil {
+		return &TalentHttpResult{Code: -1, Msg: "YounggeeSketchInfo find failed"}
+	}
+	if res == 1 && (taskInfo.SketchStatus == 2 || taskInfo.SketchStatus == 4) {
+		_, err = g.DB().Model(model.YounggeeSketchInfo{}).Data(g.Map{"is_submit": "1", "submit_at": gtime.Now()}).Where("task_id = ? and is_submit = 0", taskId).Update()
+		if err != nil {
+			return &TalentHttpResult{Code: -3, Msg: "YounggeeSketchInfo update failed"}
+		}
+		_, err = g.DB().Model(model.YoungeeTaskInfo{}).Data(g.Map{"task_stage": "10"}).Where("task_id = ?", taskId).Update()
+		if err != nil {
+			return &TalentHttpResult{Code: -4, Msg: "YoungeeTaskInfo update failed"}
+		}
+		// 记录任务日志-上传初稿
+		taskLog := model.YounggeeTaskLog{
+			TaskId:  taskId,
+			Content: "上传初稿",
+			LogAt:   gtime.Now(),
+		}
+		_, err = g.DB().Model(dao.YounggeeTaskLog.Table).Data(&taskLog).Insert()
+		if err != nil {
+			return &TalentHttpResult{Code: -5, Msg: "YounggeeTaskLog insert failed"}
+		}
+		projectInfo := model.ProjectInfo{}
+		err1 := g.DB().Model(model.ProjectInfo{}).Where("project_id = ?", taskInfo.ProjectId).Scan(&projectInfo)
+		if err1 != nil {
+			return &TalentHttpResult{Code: -8, Msg: "ProjectInfo find failed"}
+		}
+		messageInfo := model.YounggeeMessageInfo{
+			MessageId:   11,
+			MessageType: 2,
+			CreatedAt:   gtime.Now(),
+			TalentId:    taskInfo.TalentId,
+			ProjectName: projectInfo.ProjectName,
+			IsReaded:    0,
+			IsDeleted:   0,
+		}
+		_, err = g.DB().Model(dao.YounggeeMessageInfo.Table).Data(&messageInfo).Insert()
+		if err != nil {
+			return &TalentHttpResult{Code: -9, Msg: "YounggeeMessageInfo insert failed"}
+		}
+	}
+
+	return &TalentHttpResult{Code: 0, Msg: "success"}
+}
+
+// 查询脚本提交审阅记录service
+func GetTaskSketch(r *ghttp.Request) *TalentHttpResult {
+	taskId := r.Get("task_id")
+
+	var sketchInfoList []*youngee_talent_model.TaskSketchInfo
+	err := g.DB().Model(dao.YounggeeSketchInfo.Table).Where("is_submit = 1 and is_review = 1 and task_id = ?", taskId).OrderAsc("submit_at").Scan(&sketchInfoList)
+	if err != nil {
+		return &TalentHttpResult{Code: -1, Msg: err.Error()}
+	}
+	for _, v := range sketchInfoList {
+		var sketchPhotoList []*youngee_talent_model.YounggeeSketchPhoto
+		err = g.DB().Model(dao.YounggeeSketchPhoto.Table).Where("sketch_id = ?", v.SketchId).Scan(&sketchPhotoList)
+		if err != nil {
+			return &TalentHttpResult{Code: -2, Msg: err.Error()}
+		}
+		v.Photo = sketchPhotoList
+	}
+
+	return &TalentHttpResult{Code: 0, Msg: "success", Data: sketchInfoList}
+}
+
+// 查询未提交初稿service
+func GetUnSubmitTaskSketch(r *ghttp.Request) *TalentHttpResult {
+	taskId := r.Get("task_id")
+
+	var unSubmitSketch *youngee_talent_model.TaskSketchInfo
+	err := g.DB().Model(dao.YounggeeSketchInfo.Table).Where("is_review = 0 and task_id = ?", taskId).OrderAsc("submit_at").Scan(&unSubmitSketch)
+	if err != nil {
+		return &TalentHttpResult{Code: -1, Msg: err.Error()}
+	}
+
+	var sketchPhotoList []*youngee_talent_model.YounggeeSketchPhoto
+	err = g.DB().Model(dao.YounggeeSketchPhoto.Table).Where("sketch_id = ?", unSubmitSketch.SketchId).Scan(&sketchPhotoList)
+	if err != nil {
+		return &TalentHttpResult{Code: -2, Msg: err.Error()}
+	}
+	unSubmitSketch.Photo = sketchPhotoList
+
+	return &TalentHttpResult{Code: 0, Msg: "success", Data: unSubmitSketch}
+}

+ 9 - 5
app/system/sectask/sectask_service.go

@@ -127,16 +127,20 @@ func (s *secTaskService) ListTab(listSecTaskTabReq *ListSecTaskTabReq, tid strin
 	var whereStr string
 	//前端点击了那个tab  TabStage
 	switch listSecTaskTabReq.TabStage {
+	//全部
 	case 1:
 		// 返回指定talentId的所有数据
 		whereStr = fmt.Sprintf("talent_id='%s'", tid)
+	//case 2:
+	//	// 返回指定talentId且free_stage为3, 4, 5的数据
+	//	whereStr = fmt.Sprintf("talent_id='%s' AND free_stage IN (3, 4, 5)", tid)
+
+	//已出单
 	case 2:
-		// 返回指定talentId且free_stage为3, 4, 5的数据
-		whereStr = fmt.Sprintf("talent_id='%s' AND free_stage IN (3, 4, 5)", tid)
-	case 3:
 		// 返回指定talentId且sale_num_all大于0的数据
 		whereStr = fmt.Sprintf("talent_id='%s' AND sale_num_all > 0", tid)
-	case 4:
+	//已过期
+	case 3:
 		// 返回指定talentId且已过DDL的数据
 		whereStr = fmt.Sprintf("talent_id='%s' AND task_ddl < NOW()", tid)
 	}
@@ -144,7 +148,7 @@ func (s *secTaskService) ListTab(listSecTaskTabReq *ListSecTaskTabReq, tid strin
 	var secTaskInfoList []youngee_talent_model.SecTaskInfoDetail
 	err := g.DB().Model(youngee_talent_model.SecTaskInfoDetail{}).WithAll().
 		Where(whereStr).
-		Order("task_ddl DESC").
+		Order("task_ddl DESC ").
 		Scan(&secTaskInfoList)
 	if err != nil {
 		return &ListSecTaskTabRes{Count: -1, Msg: err.Error(), SecTaskTable: nil}

BIN
bin/main


BIN
bin/v3.5.2/linux_amd64/youngmini_server


BIN
bin/v3.5.2/windows_amd64/youngmini_server.exe


BIN
bin/v3.6.0/linux_amd64/youngmini_server


BIN
bin/v3.6.0/windows_amd64/youngmini_server.exe


BIN
bin/v3.6.1/linux_amd64/.DS_Store


BIN
bin/v3.6.1/windows_amd64/youngmini_server.exe


BIN
bin/v3.7.0/linux_amd64/youngmini_server


BIN
bin/v3.7.0/windows_amd64/youngmini_server.exe


BIN
bin/v3.7.1/linux_amd64/youngmini_server


BIN
bin/v3.7.1/windows_amd64/youngmini_server.exe


+ 1 - 1
config/config.toml

@@ -19,7 +19,7 @@ name = "youngmini_server"
 output = "./bin"
 pack = ""
 system = "linux,windows"
-version = "v3.5.2"
+version = "v3.7.1"
 [gfcli.gen.dao]
 jsonCase = "Snake"
 link = "mysql:talent:talentDB_123@tcp(139.9.53.143:3306)/youngmini"

+ 1 - 0
main.go

@@ -11,6 +11,7 @@ import (
 )
 
 func main() {
+
 	// 设置session存储于redis
 	g.Server().SetConfigWithMap(g.Map{
 		"SessionStorage": gsession.NewStorageRedis(g.Redis()),

+ 1 - 2
middleware/middleware_wx_auth.go

@@ -12,10 +12,9 @@ func WxAuth(r *ghttp.Request) {
 	if !r.Session.Contains(token) {
 		r.Response.WriteJson(g.Map{
 			"code": 403,
-			"msg":  "请重新登录",
+			"msg":  "您还没有登陆达人账号,请检查请求头",
 		})
 		return
 	}
-
 	r.Middleware.Next()
 }

+ 2 - 2
router/router.go

@@ -90,7 +90,7 @@ func init() {
 		s.BindHandler("/apitest", func(r *ghttp.Request) {
 			r.Response.WriteJson("成功访问服务端")
 		})
-		//用于快手电商:nignx转发含code的请求到此处
+		//扫码之后---用于快手电商:nignx转发含code的请求到此处
 		s.BindHandler("/kuaishouauth", func(r *ghttp.Request) {
 			fmt.Println("****进入rounter中的/kuaishouauth*******")
 			ClientKey := "ks651333097154138217"
@@ -134,6 +134,7 @@ func init() {
 			}
 			//来自达人授权,获取accesstoken
 			res_auth, _ := oauth.GetAccessToken(ClientKey, ClientSecret, code)
+			r.Response.WriteJson(res_auth)
 
 			//防止一个快手账号重复绑定
 			userInfo := youngee_talent_model.KuaishouUserInfo{}
@@ -165,7 +166,6 @@ func init() {
 			//获取基本信息
 			res_info, _ := user.GetUserinfo(ClientKey, AccessToken)
 			//30天销量不在扫码时获取。
-
 			err_auth := r.Response.WriteJson(res_auth)
 			err_info := r.Response.WriteJson(res_info)
 			if err_auth != nil {