|
@@ -56,17 +56,21 @@ func (*supplier) CreateSupplier(ctx context.Context, phone string) (*http_model.
|
|
|
|
|
|
// GetSupplierIncomeList 查询服务商收入列表
|
|
|
func (*supplier) GetSupplierIncomeList(ctx context.Context, req *http_model.FullSProjectIncomeListRequest) (*http_model.FullSProjectIncomeData, error) {
|
|
|
+ var sProjectIncomeData *http_model.FullSProjectIncomeData
|
|
|
+ sProjectIncomeData = &http_model.FullSProjectIncomeData{}
|
|
|
+
|
|
|
// 1. 查询
|
|
|
- supplierIncome, total, err := db.GetSupplierIncomeList(ctx, req)
|
|
|
+ supplierIncome, total, err := db.GetSupplierIncomeList(ctx, req.PageSize, req.PageNum, req.SupplierId, req.IncomeStatus)
|
|
|
if err != nil {
|
|
|
return nil, nil
|
|
|
}
|
|
|
+ // 2. 补充种草/本地生活任务信息
|
|
|
+ if supplierIncome != nil {
|
|
|
+ sProjectIncomeData.Total = total
|
|
|
+ } else {
|
|
|
+ sProjectIncomeData.Total = 0
|
|
|
+ }
|
|
|
|
|
|
- // 2. 整理数据格式
|
|
|
- var sProjectIncomeData *http_model.FullSProjectIncomeData
|
|
|
- sProjectIncomeData = &http_model.FullSProjectIncomeData{}
|
|
|
- sProjectIncomeData.SProjectIncomeList = supplierIncome
|
|
|
- sProjectIncomeData.Total = total
|
|
|
return sProjectIncomeData, nil
|
|
|
}
|
|
|
|
|
@@ -223,54 +227,59 @@ func (*supplier) GetSupplierInvoiceList(ctx context.Context, req *http_model.Sup
|
|
|
// GetSupplierToWithdrawList 服务商待提现列表
|
|
|
func (*supplier) GetSupplierToWithdrawList(ctx context.Context, req *http_model.SupplierToWithdrawListRequest) (*http_model.SupplierToWithdrawListData, error) {
|
|
|
// 1. 查询服务商发票信息
|
|
|
+ var supplierInvoiceData *http_model.SupplierToWithdrawListData
|
|
|
+ supplierInvoiceData = &http_model.SupplierToWithdrawListData{}
|
|
|
+
|
|
|
supplierInvoiceList, total, err := db.GetInvoiceListBySupplierId(ctx, req.SupplierId, 3, 1, req.PageSize, req.PageNum)
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
-
|
|
|
- // 2. 根据发票中的incomeIds去查找任务及其服务费收入
|
|
|
- var supplierInvoiceData *http_model.SupplierToWithdrawListData
|
|
|
- supplierInvoiceData = &http_model.SupplierToWithdrawListData{}
|
|
|
-
|
|
|
- for _, supplierInvoice := range supplierInvoiceList {
|
|
|
- var supplierInvoiceInfo *http_model.SupplierToWithdrawInfo
|
|
|
- supplierInvoiceInfo = &http_model.SupplierToWithdrawInfo{}
|
|
|
-
|
|
|
- // 2.1. 基础信息填入
|
|
|
- supplierInvoiceInfo.AgreeTime = supplierInvoice.AgreeTime
|
|
|
- supplierInvoiceInfo.Company = supplierInvoice.Company
|
|
|
-
|
|
|
- // 2.2. 任务及其收入信息填入
|
|
|
- incomeIds := supplierInvoice.IncomeIds
|
|
|
- strSlice := strings.Split(incomeIds, ",")
|
|
|
- intSlice := make([]int, len(strSlice))
|
|
|
- for i, s := range strSlice {
|
|
|
- num, err := strconv.Atoi(s)
|
|
|
- if err != nil {
|
|
|
- fmt.Println("转换错误:", err)
|
|
|
- return nil, err
|
|
|
- }
|
|
|
- intSlice[i] = num
|
|
|
- }
|
|
|
- for _, incomeId := range intSlice {
|
|
|
- var sTaskInfo *http_model.STaskInfo
|
|
|
- sTaskInfo = &http_model.STaskInfo{}
|
|
|
- currIncome, incomeErr := db.GetIncomeInfoByIncomeId(ctx, incomeId)
|
|
|
- if incomeErr != nil {
|
|
|
- return nil, incomeErr
|
|
|
+ if supplierInvoiceList != nil {
|
|
|
+ // 企业服务商
|
|
|
+ // 2. 根据发票中的incomeIds去查找任务及其服务费收入
|
|
|
+ for _, supplierInvoice := range supplierInvoiceList {
|
|
|
+ var supplierInvoiceInfo *http_model.SupplierToWithdrawInfo
|
|
|
+ supplierInvoiceInfo = &http_model.SupplierToWithdrawInfo{}
|
|
|
+
|
|
|
+ // 2.1. 基础信息填入
|
|
|
+ supplierInvoiceInfo.AgreeTime = supplierInvoice.AgreeTime
|
|
|
+ supplierInvoiceInfo.Company = supplierInvoice.Company
|
|
|
+
|
|
|
+ // 2.2. 任务及其收入信息填入
|
|
|
+ incomeIds := supplierInvoice.IncomeIds
|
|
|
+ strSlice := strings.Split(incomeIds, ",")
|
|
|
+ intSlice := make([]int, len(strSlice))
|
|
|
+ for i, s := range strSlice {
|
|
|
+ num, err := strconv.Atoi(s)
|
|
|
+ if err != nil {
|
|
|
+ fmt.Println("转换错误:", err)
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ intSlice[i] = num
|
|
|
}
|
|
|
- sTaskInfo.ServiceCharge = currIncome.SupplierChargeActual
|
|
|
- supplierInvoiceInfo.Amount += currIncome.SupplierChargeActual
|
|
|
- if currIncome.IncomeType == 1 {
|
|
|
- sTaskInfo.Id = currIncome.SProjectID
|
|
|
- } else if currIncome.IncomeType == 3 {
|
|
|
- sTaskInfo.Id = currIncome.SLocalLifeID
|
|
|
+ for _, incomeId := range intSlice {
|
|
|
+ var sTaskInfo *http_model.STaskInfo
|
|
|
+ sTaskInfo = &http_model.STaskInfo{}
|
|
|
+ currIncome, incomeErr := db.GetIncomeInfoByIncomeId(ctx, incomeId)
|
|
|
+ if incomeErr != nil {
|
|
|
+ return nil, incomeErr
|
|
|
+ }
|
|
|
+ sTaskInfo.ServiceCharge = currIncome.SupplierChargeActual
|
|
|
+ supplierInvoiceInfo.Amount += currIncome.SupplierChargeActual
|
|
|
+ if currIncome.IncomeType == 1 {
|
|
|
+ sTaskInfo.Id = currIncome.SProjectID
|
|
|
+ } else if currIncome.IncomeType == 3 {
|
|
|
+ sTaskInfo.Id = currIncome.SLocalLifeID
|
|
|
+ }
|
|
|
+ supplierInvoiceInfo.STaskInfo = append(supplierInvoiceInfo.STaskInfo, sTaskInfo)
|
|
|
}
|
|
|
- supplierInvoiceInfo.STaskInfo = append(supplierInvoiceInfo.STaskInfo, sTaskInfo)
|
|
|
+ supplierInvoiceData.ToWithdrawList = append(supplierInvoiceData.ToWithdrawList, supplierInvoiceInfo)
|
|
|
}
|
|
|
- supplierInvoiceData.ToWithdrawList = append(supplierInvoiceData.ToWithdrawList, supplierInvoiceInfo)
|
|
|
+ supplierInvoiceData.Total = total
|
|
|
+ } else {
|
|
|
+ // 个人服务商
|
|
|
}
|
|
|
- supplierInvoiceData.Total = total
|
|
|
+
|
|
|
return supplierInvoiceData, nil
|
|
|
}
|
|
|
|
|
@@ -280,7 +289,7 @@ func (*supplier) CreateSupplierWithdraw(ctx context.Context, req *http_model.Cre
|
|
|
|
|
|
// 1. 数据整理
|
|
|
var supplierWithdrawInfoList []*gorm_model.YounggeeSupplierWithdraw
|
|
|
- for _, withdrawInfo := range req.CreateSupplierWithdrawList {
|
|
|
+ for _, withdrawInfo := range req.CreateCompanySupplierWithdraw {
|
|
|
var supplierWithdrawInfo *gorm_model.YounggeeSupplierWithdraw
|
|
|
supplierWithdrawInfo = &gorm_model.YounggeeSupplierWithdraw{}
|
|
|
|