|
@@ -1,199 +1,239 @@
|
|
|
-package youngee_task_service
|
|
|
-
|
|
|
-import (
|
|
|
- "context"
|
|
|
- "encoding/json"
|
|
|
- "fmt"
|
|
|
- "math/rand"
|
|
|
- "strconv"
|
|
|
- "strings"
|
|
|
- "time"
|
|
|
- "youngmini_server/app/dao"
|
|
|
- "youngmini_server/app/model"
|
|
|
- "youngmini_server/app/model/youngee_talent_model"
|
|
|
- "youngmini_server/app/utils"
|
|
|
-
|
|
|
- "github.com/gogf/gf/database/gdb"
|
|
|
- "github.com/gogf/gf/frame/g"
|
|
|
- "github.com/gogf/gf/net/ghttp"
|
|
|
- "github.com/gogf/gf/os/gtime"
|
|
|
-)
|
|
|
-
|
|
|
-func GetWithdrawTaskInfo(r *ghttp.Request) *TalentHttpResult {
|
|
|
- tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
|
|
|
- if err != nil {
|
|
|
- return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
|
|
|
- }
|
|
|
-
|
|
|
- withdrawTaskInfoList := youngee_talent_model.WithdrawTaskInfoList{}
|
|
|
- // 获取可提现任务列表
|
|
|
- var taskList []*model.YoungeeTaskInfo
|
|
|
- err = g.Model(dao.YoungeeTaskInfo.Table).Where("talent_id = ?", tid).And("withdraw_status IN(?)", g.Slice{2, 3, 4}).Scan(&taskList)
|
|
|
- if err != nil {
|
|
|
- return &TalentHttpResult{Code: -1, Msg: "Get task list failed"}
|
|
|
- }
|
|
|
-
|
|
|
- platformMap := make(map[string]model.InfoThirdPlatform)
|
|
|
- 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]
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for _, v := range taskList {
|
|
|
- projectInfo, err := g.Model(dao.ProjectInfo.Table).Where("project_id = ?", v.ProjectId).One()
|
|
|
- if err != nil {
|
|
|
- return &TalentHttpResult{Code: -1, Msg: "Get fullproject info failed"}
|
|
|
- }
|
|
|
- // product, err := g.Model(dao.YounggeeProduct.Table).One("product_id = ?", projectInfo[dao.ProjectInfo.Columns.ProductId])
|
|
|
- // if err != nil {
|
|
|
- // return &TalentHttpResult{Code: -1, Msg: "Get product mainphoto failed"}
|
|
|
- // }
|
|
|
- // strategy := model.RecruitStrategy{}
|
|
|
- // err = g.Model(dao.RecruitStrategy.Table).Where("project_id = ? and strategy_id = ?", v.ProjectId, v.StrategyId).Scan(&strategy)
|
|
|
- // if err != nil {
|
|
|
- // return &TalentHttpResult{Code: -1, Msg: "Get RecruitStrategy failed"}
|
|
|
- // }
|
|
|
-
|
|
|
- taskInfoBrief := &youngee_talent_model.WithdrawTaskInfo{
|
|
|
- TaskId: v.TaskId,
|
|
|
- ProjectName: projectInfo[dao.ProjectInfo.Columns.ProjectName].String(),
|
|
|
- ProductPhoto: projectInfo[dao.ProjectInfo.Columns.ProductPhotoSnap].String(),
|
|
|
- PlatformIconUrl: platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformIcon,
|
|
|
- PlatformName: platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformName,
|
|
|
- TaskReward: v.TaskReward,
|
|
|
- SettleAmount: v.SettleAmount,
|
|
|
- CompleteDate: v.CompleteDate,
|
|
|
- WithdrawDate: v.WithdrawDate,
|
|
|
- Checked: false,
|
|
|
- }
|
|
|
- if v.WithdrawStatus == 2 {
|
|
|
- withdrawTaskInfoList.CanWithdrawTaskInfoList = append(withdrawTaskInfoList.CanWithdrawTaskInfoList, taskInfoBrief)
|
|
|
- } else if v.WithdrawStatus == 3 {
|
|
|
- withdrawTaskInfoList.WithdrawingTaskInfoList = append(withdrawTaskInfoList.WithdrawingTaskInfoList, taskInfoBrief)
|
|
|
- } else if v.WithdrawStatus == 4 {
|
|
|
- withdrawTaskInfoList.WithdrawedTaskInfoList = append(withdrawTaskInfoList.WithdrawedTaskInfoList, taskInfoBrief)
|
|
|
- }
|
|
|
- }
|
|
|
- return &TalentHttpResult{Code: 0, Msg: "success", Data: withdrawTaskInfoList}
|
|
|
-}
|
|
|
-
|
|
|
-func Withdraw(r *ghttp.Request) *TalentHttpResult {
|
|
|
- tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
|
|
|
- if err != nil {
|
|
|
- return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
|
|
|
- }
|
|
|
-
|
|
|
- var DataInfoReq *youngee_talent_model.WithdrawInfo
|
|
|
- err = r.ParseForm(&DataInfoReq)
|
|
|
- if err != nil {
|
|
|
- return &TalentHttpResult{Code: -2, Msg: err.Error()}
|
|
|
- }
|
|
|
- incomeIdList := strings.Split(DataInfoReq.IncomeIdList, ",")
|
|
|
- // taskIdListInt := utils.TypeTran.String2Int(taskIdListStr)
|
|
|
-
|
|
|
- // 检验是否taskIdList中所有task均处于可提现状态,且talent_id是否正确
|
|
|
- var incomeList []model.YounggeeTalentIncome
|
|
|
- err = g.Model(dao.YounggeeTalentIncome.Table).Where("talent_id = ? and withdraw_status = 1", tid).And("task_id IN (?)", incomeIdList).Scan(&incomeList)
|
|
|
- if err != nil {
|
|
|
- return &TalentHttpResult{Code: -3, Msg: "Get task list failed"}
|
|
|
- }
|
|
|
- if len(incomeIdList) != len(incomeList) {
|
|
|
- return &TalentHttpResult{Code: -4, Msg: "Task TalentID Error"}
|
|
|
- }
|
|
|
-
|
|
|
- var talentBank model.YounggeeTalentBank
|
|
|
- err = g.Model(dao.YounggeeTalentBank.Table).Where("talent_id = ?", tid).Scan(&talentBank)
|
|
|
- if err != nil {
|
|
|
- return &TalentHttpResult{Code: -5, Msg: "Get Bank Info failed"}
|
|
|
- }
|
|
|
-
|
|
|
- bankJsons, errs := json.Marshal(talentBank) //转换成JSON返回的是byte[]
|
|
|
- if errs != nil {
|
|
|
- return &TalentHttpResult{Code: -6, Msg: " Json transformed failed"}
|
|
|
- }
|
|
|
-
|
|
|
- err = g.DB().Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
|
|
|
- s1 := tid[7:]
|
|
|
- s2 := fmt.Sprintf("%d", gtime.Now().YearDay())
|
|
|
- s3 := fmt.Sprintf("%02v", rand.New(rand.NewSource(time.Now().UnixNano())).Int63n(100))
|
|
|
- s := "6" + s1 + s2 + s3
|
|
|
- // 插入提现记录
|
|
|
- _, err1 := tx.Ctx(ctx).Model(dao.YounggeeWithdrawRecord.Table).Data(model.YounggeeWithdrawRecord{
|
|
|
- WithdrawId: s,
|
|
|
- TalentId: tid,
|
|
|
- WithdrawAmount: float64(DataInfoReq.TotalAmount),
|
|
|
- AmountPayable: float64(DataInfoReq.RealAmount),
|
|
|
- IncomeIdList: DataInfoReq.IncomeIdList,
|
|
|
- ReceiveInfo: string(bankJsons),
|
|
|
- BankType: 2,
|
|
|
- Status: 1,
|
|
|
- SubmitAt: gtime.Now(),
|
|
|
- }).InsertAndGetId()
|
|
|
- if err1 != nil {
|
|
|
- fmt.Printf("[Withdraw Transaction] Error:%+v\n", err1)
|
|
|
- return err1
|
|
|
- }
|
|
|
-
|
|
|
- // 更新income表中提现状态
|
|
|
- _, err1 = tx.Ctx(ctx).Model(dao.YounggeeTalentIncome.Table).Where("task_id IN (?)", incomeIdList).Update(g.Map{"withdraw_status": 2, "withdraw_at": gtime.Now()})
|
|
|
- if err1 != nil {
|
|
|
- fmt.Printf("[Withdraw Transaction] Error:%+v\n", err1)
|
|
|
- return err1
|
|
|
- }
|
|
|
-
|
|
|
- // 更新talent表中提现金额
|
|
|
- _, err1 = tx.Ctx(ctx).Model(dao.YoungeeTalentInfo.Table).Where("id = ?", tid).Increment("withdrawing", float64(DataInfoReq.TotalAmount))
|
|
|
- if err1 != nil {
|
|
|
- fmt.Printf("[Withdraw Transaction] Error:%+v\n", err1)
|
|
|
- return err1
|
|
|
- }
|
|
|
- _, err1 = tx.Ctx(ctx).Model(dao.YoungeeTalentInfo.Table).Where("id = ?", tid).Decrement("canwithdraw", float64(DataInfoReq.TotalAmount))
|
|
|
- if err1 != nil {
|
|
|
- fmt.Printf("[Withdraw Transaction] Error:%+v\n", err1)
|
|
|
- return err1
|
|
|
- }
|
|
|
-
|
|
|
- // // 达人消息
|
|
|
- // for _, taskId := range taskIdListStr {
|
|
|
- // taskInfo := model.YoungeeTaskInfo{}
|
|
|
- // err1 = tx.Ctx(ctx).Model(dao.YoungeeTaskInfo.Table).Where("task_id = ?", taskId).Scan(&taskInfo)
|
|
|
- // if err1 != nil {
|
|
|
- // fmt.Printf("[Withdraw Transaction] Error:%+v\n", err1)
|
|
|
- // return err1
|
|
|
- // }
|
|
|
- // projectInfo := model.ProjectInfo{}
|
|
|
- // err1 = tx.Ctx(ctx).Model(model.ProjectInfo{}).Where("project_id = ?", taskInfo.ProjectId).Scan(&projectInfo)
|
|
|
- // if err1 != nil {
|
|
|
- // fmt.Printf("[Withdraw Transaction] Error:%+v\n", err1)
|
|
|
- // return err1
|
|
|
- // }
|
|
|
- // messageInfo := model.YounggeeMessageInfo{
|
|
|
- // MessageId: 12,
|
|
|
- // MessageType: 2,
|
|
|
- // CreatedAt: gtime.Now(),
|
|
|
- // TalentId: taskId,
|
|
|
- // ProjectName: projectInfo.ProjectName,
|
|
|
- // IsReaded: 0,
|
|
|
- // IsDeleted: 0,
|
|
|
- // }
|
|
|
- // _, err = tx.Ctx(ctx).Model(dao.YounggeeMessageInfo.Table).Data(&messageInfo).Insert()
|
|
|
- // if err != nil {
|
|
|
- // fmt.Printf("[Withdraw Transaction] Error:%+v\n", err)
|
|
|
- // return err
|
|
|
- // }
|
|
|
- // }
|
|
|
- return nil
|
|
|
- })
|
|
|
- if err != nil {
|
|
|
- return &TalentHttpResult{Code: -7, Msg: "Add Withdraw Record failed"}
|
|
|
- }
|
|
|
-
|
|
|
- return &TalentHttpResult{Code: 0, Msg: "success"}
|
|
|
-}
|
|
|
+package youngee_task_service
|
|
|
+
|
|
|
+import (
|
|
|
+ "context"
|
|
|
+ "encoding/json"
|
|
|
+ "fmt"
|
|
|
+ "math"
|
|
|
+ "math/rand"
|
|
|
+ "strconv"
|
|
|
+ "strings"
|
|
|
+ "time"
|
|
|
+ "youngmini_server/app/dao"
|
|
|
+ "youngmini_server/app/model"
|
|
|
+ "youngmini_server/app/model/youngee_talent_model"
|
|
|
+ "youngmini_server/app/utils"
|
|
|
+
|
|
|
+ "github.com/gogf/gf/database/gdb"
|
|
|
+ "github.com/gogf/gf/frame/g"
|
|
|
+ "github.com/gogf/gf/net/ghttp"
|
|
|
+ "github.com/gogf/gf/os/gtime"
|
|
|
+)
|
|
|
+
|
|
|
+func GetWithdrawTaskInfo(r *ghttp.Request) *TalentHttpResult {
|
|
|
+ tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ withdrawTaskInfoList := youngee_talent_model.WithdrawTaskInfoList{}
|
|
|
+ // 获取可提现任务列表
|
|
|
+ var taskList []*model.YoungeeTaskInfo
|
|
|
+ err = g.Model(dao.YoungeeTaskInfo.Table).Where("talent_id = ?", tid).And("withdraw_status IN(?)", g.Slice{2, 3, 4}).Scan(&taskList)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get task list failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ platformMap := make(map[string]model.InfoThirdPlatform)
|
|
|
+ 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]
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for _, v := range taskList {
|
|
|
+ projectInfo, err := g.Model(dao.ProjectInfo.Table).Where("project_id = ?", v.ProjectId).One()
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get fullproject info failed"}
|
|
|
+ }
|
|
|
+ // product, err := g.Model(dao.YounggeeProduct.Table).One("product_id = ?", projectInfo[dao.ProjectInfo.Columns.ProductId])
|
|
|
+ // if err != nil {
|
|
|
+ // return &TalentHttpResult{Code: -1, Msg: "Get product mainphoto failed"}
|
|
|
+ // }
|
|
|
+ // strategy := model.RecruitStrategy{}
|
|
|
+ // err = g.Model(dao.RecruitStrategy.Table).Where("project_id = ? and strategy_id = ?", v.ProjectId, v.StrategyId).Scan(&strategy)
|
|
|
+ // if err != nil {
|
|
|
+ // return &TalentHttpResult{Code: -1, Msg: "Get RecruitStrategy failed"}
|
|
|
+ // }
|
|
|
+
|
|
|
+ taskInfoBrief := &youngee_talent_model.WithdrawTaskInfo{
|
|
|
+ TaskId: v.TaskId,
|
|
|
+ ProjectName: projectInfo[dao.ProjectInfo.Columns.ProjectName].String(),
|
|
|
+ ProductPhoto: projectInfo[dao.ProjectInfo.Columns.ProductPhotoSnap].String(),
|
|
|
+ PlatformIconUrl: platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformIcon,
|
|
|
+ PlatformName: platformMap[projectInfo[dao.ProjectInfo.Columns.ProjectPlatform].String()].PlatformName,
|
|
|
+ TaskReward: v.TaskReward,
|
|
|
+ SettleAmount: v.SettleAmount,
|
|
|
+ CompleteDate: v.CompleteDate,
|
|
|
+ WithdrawDate: v.WithdrawDate,
|
|
|
+ Checked: false,
|
|
|
+ }
|
|
|
+ if v.WithdrawStatus == 2 {
|
|
|
+ withdrawTaskInfoList.CanWithdrawTaskInfoList = append(withdrawTaskInfoList.CanWithdrawTaskInfoList, taskInfoBrief)
|
|
|
+ } else if v.WithdrawStatus == 3 {
|
|
|
+ withdrawTaskInfoList.WithdrawingTaskInfoList = append(withdrawTaskInfoList.WithdrawingTaskInfoList, taskInfoBrief)
|
|
|
+ } else if v.WithdrawStatus == 4 {
|
|
|
+ withdrawTaskInfoList.WithdrawedTaskInfoList = append(withdrawTaskInfoList.WithdrawedTaskInfoList, taskInfoBrief)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return &TalentHttpResult{Code: 0, Msg: "success", Data: withdrawTaskInfoList}
|
|
|
+}
|
|
|
+
|
|
|
+func Withdraw(r *ghttp.Request) *TalentHttpResult {
|
|
|
+ tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ var DataInfoReq *youngee_talent_model.WithdrawInfo
|
|
|
+ err = r.ParseForm(&DataInfoReq)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -2, Msg: err.Error()}
|
|
|
+ }
|
|
|
+ incomeIdList := strings.Split(DataInfoReq.IncomeIdList, ",")
|
|
|
+ // taskIdListInt := utils.TypeTran.String2Int(taskIdListStr)
|
|
|
+
|
|
|
+ // 检验是否taskIdList中所有task均处于可提现状态,且talent_id是否正确
|
|
|
+ var incomeList []model.YounggeeTalentIncome
|
|
|
+ err = g.Model(dao.YounggeeTalentIncome.Table).Where("talent_id = ? and withdraw_status = 1", tid).And("task_id IN (?)", incomeIdList).Scan(&incomeList)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -3, Msg: "Get task list failed"}
|
|
|
+ }
|
|
|
+ if len(incomeIdList) != len(incomeList) {
|
|
|
+ return &TalentHttpResult{Code: -4, Msg: "Task TalentID Error"}
|
|
|
+ }
|
|
|
+
|
|
|
+ var talentBank model.YounggeeTalentBank
|
|
|
+ err = g.Model(dao.YounggeeTalentBank.Table).Where("talent_id = ?", tid).Scan(&talentBank)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -5, Msg: "Get Bank Info failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ bankJsons, errs := json.Marshal(talentBank) //转换成JSON返回的是byte[]
|
|
|
+ if errs != nil {
|
|
|
+ return &TalentHttpResult{Code: -6, Msg: " Json transformed failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ err = g.DB().Transaction(context.TODO(), func(ctx context.Context, tx *gdb.TX) error {
|
|
|
+ s1 := tid[7:]
|
|
|
+ s2 := fmt.Sprintf("%d", gtime.Now().YearDay())
|
|
|
+ s3 := fmt.Sprintf("%02v", rand.New(rand.NewSource(time.Now().UnixNano())).Int63n(100))
|
|
|
+ s := "6" + s1 + s2 + s3
|
|
|
+ RealAmount := math.Floor(float64(DataInfoReq.TotalAmount) * (1 - 0.05))
|
|
|
+ taxAmount := math.Floor(float64(DataInfoReq.TotalAmount) * 0.05)
|
|
|
+ // 插入提现记录
|
|
|
+ _, err1 := tx.Ctx(ctx).Model(dao.YounggeeWithdrawRecord.Table).Data(model.YounggeeWithdrawRecord{
|
|
|
+ WithdrawId: s,
|
|
|
+ TalentId: tid,
|
|
|
+ WithdrawAmount: float64(DataInfoReq.TotalAmount), //全部金额
|
|
|
+ AmountPayable: RealAmount, //实际到账
|
|
|
+ IncomeIdList: DataInfoReq.IncomeIdList,
|
|
|
+ ReceiveInfo: string(bankJsons),
|
|
|
+ BankType: 2,
|
|
|
+ Status: 1,
|
|
|
+ SubmitAt: gtime.Now(),
|
|
|
+ TaxAmount: taxAmount, //税
|
|
|
+ }).InsertAndGetId()
|
|
|
+ if err1 != nil {
|
|
|
+ fmt.Printf("[Withdraw Transaction] Error:%+v\n", err1)
|
|
|
+ return err1
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新income表中提现状态
|
|
|
+ _, err1 = tx.Ctx(ctx).Model(dao.YounggeeTalentIncome.Table).Where("task_id IN (?)", incomeIdList).Update(g.Map{"withdraw_status": 2, "withdraw_at": gtime.Now()})
|
|
|
+ if err1 != nil {
|
|
|
+ fmt.Printf("[Withdraw Transaction] Error:%+v\n", err1)
|
|
|
+ return err1
|
|
|
+ }
|
|
|
+
|
|
|
+ // 更新talent表中提现金额
|
|
|
+ _, err1 = tx.Ctx(ctx).Model(dao.YoungeeTalentInfo.Table).Where("id = ?", tid).Increment("withdrawing", float64(DataInfoReq.TotalAmount))
|
|
|
+ if err1 != nil {
|
|
|
+ fmt.Printf("[Withdraw Transaction] Error:%+v\n", err1)
|
|
|
+ return err1
|
|
|
+ }
|
|
|
+ _, err1 = tx.Ctx(ctx).Model(dao.YoungeeTalentInfo.Table).Where("id = ?", tid).Decrement("canwithdraw", float64(DataInfoReq.TotalAmount))
|
|
|
+ if err1 != nil {
|
|
|
+ fmt.Printf("[Withdraw Transaction] Error:%+v\n", err1)
|
|
|
+ return err1
|
|
|
+ }
|
|
|
+ //todo 达人提现插入消息
|
|
|
+ // // 达人消息
|
|
|
+ // for _, taskId := range taskIdListStr {
|
|
|
+ // taskInfo := model.YoungeeTaskInfo{}
|
|
|
+ // err1 = tx.Ctx(ctx).Model(dao.YoungeeTaskInfo.Table).Where("task_id = ?", taskId).Scan(&taskInfo)
|
|
|
+ // if err1 != nil {
|
|
|
+ // fmt.Printf("[Withdraw Transaction] Error:%+v\n", err1)
|
|
|
+ // return err1
|
|
|
+ // }
|
|
|
+ // projectInfo := model.ProjectInfo{}
|
|
|
+ // err1 = tx.Ctx(ctx).Model(model.ProjectInfo{}).Where("project_id = ?", taskInfo.ProjectId).Scan(&projectInfo)
|
|
|
+ // if err1 != nil {
|
|
|
+ // fmt.Printf("[Withdraw Transaction] Error:%+v\n", err1)
|
|
|
+ // return err1
|
|
|
+ // }
|
|
|
+ // messageInfo := model.YounggeeMessageInfo{
|
|
|
+ // MessageId: 12,
|
|
|
+ // MessageType: 2,
|
|
|
+ // CreatedAt: gtime.Now(),
|
|
|
+ // TalentId: taskId,
|
|
|
+ // ProjectName: projectInfo.ProjectName,
|
|
|
+ // IsReaded: 0,
|
|
|
+ // IsDeleted: 0,
|
|
|
+ // }
|
|
|
+ // _, err = tx.Ctx(ctx).Model(dao.YounggeeMessageInfo.Table).Data(&messageInfo).Insert()
|
|
|
+ // if err != nil {
|
|
|
+ // fmt.Printf("[Withdraw Transaction] Error:%+v\n", err)
|
|
|
+ // return err
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ return nil
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -7, Msg: "Add Withdraw Record failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ return &TalentHttpResult{Code: 0, Msg: "success"}
|
|
|
+}
|
|
|
+
|
|
|
+func GetWithdrawList(r *ghttp.Request) *TalentHttpResult {
|
|
|
+ tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
|
|
|
+ }
|
|
|
+ queryInt := r.GetQueryInt("status", -1)
|
|
|
+ var Records []*youngee_talent_model.WithdrawRecord
|
|
|
+ if queryInt == 0 {
|
|
|
+ g.DB().Model("younggee_withdraw_record").Where("talent_id = ? ", tid).Scan(&Records)
|
|
|
+ } else {
|
|
|
+ g.DB().Model("younggee_withdraw_record").Where("talent_id = ? and status = ?", tid, queryInt).Scan(&Records)
|
|
|
+ }
|
|
|
+ return &TalentHttpResult{Code: 0, Msg: "success", Data: Records}
|
|
|
+}
|
|
|
+
|
|
|
+func GetWithdrawDetail(r *ghttp.Request) *TalentHttpResult {
|
|
|
+ tid, err := utils.SessionTalentInfo.GetTalentIdFromSession(r)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
|
|
|
+ }
|
|
|
+ withdrawId := r.GetQueryString("withdraw_id", "")
|
|
|
+ var WithdrawDetail *youngee_talent_model.WithdrawDetail
|
|
|
+ err = g.DB().Model("younggee_withdraw_record").Where("talent_id = ? and withdraw_id = ?", tid, withdrawId).Scan(&WithdrawDetail)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
|
|
|
+ }
|
|
|
+ // 将 IncomeIdList 分割成 ID 列表
|
|
|
+ incomeIDs := strings.Split(WithdrawDetail.IncomeIdList, ",")
|
|
|
+ err = g.DB().Model("younggee_talent_income").Where("id IN ?", incomeIDs).Scan(WithdrawDetail.TalentIncomeInfo)
|
|
|
+ if err != nil {
|
|
|
+ return &TalentHttpResult{Code: -1, Msg: "Get talent info failed"}
|
|
|
+ }
|
|
|
+
|
|
|
+ return &TalentHttpResult{Code: 0, Msg: "success", Data: WithdrawDetail}
|
|
|
+}
|