Browse Source

[20250725]达人库

lin-jim-leon 1 tuần trước cách đây
mục cha
commit
f883c5b288
3 tập tin đã thay đổi với 32 bổ sung16 xóa
  1. 30 16
      db/task.go
  2. 1 0
      model/gorm_model/s_locallife_info.go
  3. 1 0
      model/gorm_model/s_project.go

+ 30 - 16
db/task.go

@@ -404,18 +404,25 @@ func SetSpecialTaskSettleNum(ctx context.Context, TaskIDs []string) error {
 			// 在事务中更新
 			err = db.Transaction(func(tx *gorm.DB) error {
 				// 更新 ProjectInfo
-				if err := tx.Model(gorm_model.ProjectInfo{}).
+				err1 := tx.Model(gorm_model.ProjectInfo{}).
 					Where("project_id = ?", taskInfo.ProjectID).
-					Update("settle_num", gorm.Expr("settle_num + ?", 1)).
-					Error; err != nil {
-					return err
+					Updates(map[string]interface{}{
+						"settle_num":        gorm.Expr("settle_num + ?", 1),
+						"settlement_amount": gorm.Expr("settlement_amount + ?", taskInfo.RealPayment),
+					}).Error
+
+				if err1 != nil {
+					return err1
 				}
 				// 更新 YounggeeSProjectInfo
-				if err := tx.Model(gorm_model.YounggeeSProjectInfo{}).
+				err2 := tx.Model(&gorm_model.YounggeeSProjectInfo{}).
 					Where("s_project_id = ?", taskInfo.SprojectId).
-					Update("settle_num", gorm.Expr("settle_num + ?", 1)).
-					Error; err != nil {
-					return err
+					Updates(map[string]interface{}{
+						"settle_num":            gorm.Expr("settle_num + ?", 1),
+						"service_charge_settle": gorm.Expr("service_charge_settle + ?", taskInfo.RealServiceCharge),
+					}).Error
+				if err2 != nil {
+					return err2
 				}
 				return nil
 			})
@@ -431,6 +438,7 @@ func SetSpecialTaskSettleNum(ctx context.Context, TaskIDs []string) error {
 				return err
 			}
 			projectinfo.SettleNum += 1
+			projectinfo.SettlementAmount += taskInfo.RealPayment
 			err = db.Model(gorm_model.ProjectInfo{}).Where("project_id = ? ", taskInfo.ProjectID).Updates(projectinfo).Error
 			if err != nil {
 				return err
@@ -474,18 +482,24 @@ func SetSpecialLocalTaskSettleNum(ctx context.Context, TaskIDs []string) error {
 			// 在事务中更新
 			err = db.Transaction(func(tx *gorm.DB) error {
 				// 更新 YounggeeLocalLifeInfo
-				if err := tx.Model(gorm_model.YounggeeLocalLifeInfo{}).
+				err1 := tx.Model(gorm_model.YounggeeLocalLifeInfo{}).
 					Where("local_id = ?", taskInfo.LocalId).
-					Update("settle_num", gorm.Expr("settle_num + ?", 1)).
-					Error; err != nil {
-					return err
+					Updates(map[string]interface{}{
+						"settle_num":        gorm.Expr("settle_num + ?", 1),
+						"settlement_amount": gorm.Expr("settlement_amount + ?", taskInfo.RealPayment),
+					}).Error
+				if err1 != nil {
+					return err1
 				}
 				// 更新 YounggeeSLocalLifeInfo
-				if err := tx.Model(gorm_model.YounggeeSLocalLifeInfo{}).
+				err2 := tx.Model(gorm_model.YounggeeSLocalLifeInfo{}).
 					Where("s_local_life_id = ?", taskInfo.SLocalLifeId).
-					Update("settle_num", gorm.Expr("settle_num + ?", 1)).
-					Error; err != nil {
-					return err
+					Updates(map[string]interface{}{
+						"settle_num":            gorm.Expr("settle_num + ?", 1),
+						"service_charge_settle": gorm.Expr("service_charge_settle + ?", taskInfo.RealServiceCharge)}).
+					Error
+				if err2 != nil {
+					return err2
 				}
 				return nil
 			})

+ 1 - 0
model/gorm_model/s_locallife_info.go

@@ -15,6 +15,7 @@ type YounggeeSLocalLifeInfo struct {
 	SubAccountId        int       `gorm:"column:sub_account_id;type:int(11);comment:服务商子账号ID" json:"sub_account_id"`
 	ServiceCharge       string    `gorm:"column:service_charge;type:varchar(255);comment:服务商预估可赚服务费" json:"service_charge"`
 	ServiceChargeActual string    `gorm:"column:service_charge_actual;type:varchar(255);comment:服务商实际可赚服务费" json:"service_charge_actual"`
+	ServiceChargeSettle float64   `gorm:"column:service_charge_settle;type:decimal(10,2);default:0.00;comment:服务商已赚服务费" json:"service_charge_settle"`
 	OperatorType        string    `gorm:"column:operator_type;type:varchar(255);comment:添加商单操作人类型,1为服务商主账号,2为服务商子账号" json:"operator_type"`
 	SProjectStatus      string    `gorm:"column:s_project_status;type:varchar(255);comment:服务商本地生活任务状态,1待确认,2已确认,3已拒绝" json:"s_project_status"`
 	StrategyStatus      string    `gorm:"column:strategy_status;type:varchar(255);comment:定向本地生活任务是否替换招募策略" json:"strategy_status"`

+ 1 - 0
model/gorm_model/s_project.go

@@ -19,6 +19,7 @@ type YounggeeSProjectInfo struct {
 	SubAccountId        int     `gorm:"column:sub_account_id;type:int(11);default:0;comment:服务商子账号ID" json:"sub_account_id"`
 	ServiceCharge       float64 `gorm:"column:service_charge;type:decimal(10,2);default:0.00;comment:服务商预估可赚服务费" json:"service_charge"`
 	ServiceChargeActual float64 `gorm:"column:service_charge_actual;type:decimal(10,2);default:0.00;comment:服务商实际可赚服务费" json:"service_charge_actual"`
+	ServiceChargeSettle float64 `gorm:"column:service_charge_settle;type:decimal(10,2);default:0.00;comment:服务商已赚服务费" json:"service_charge_settle"`
 	OperatorType        int     `gorm:"column:operator_type;type:int(11);default:0;comment:添加商单操作人类型,1为服务商主账号,2为服务商子账号" json:"operator_type"`
 	EstimateDraftFee    float64 `gorm:"column:estimate_draft_fee;type:decimal(10,2);comment:预估稿费" json:"estimate_draft_fee"`
 	EstimateSupportFee  float64 `gorm:"column:estimate_support_fee;type:decimal(10,2);comment:预估支持费" json:"estimate_support_fee"`