Xingyu Xian před 2 měsíci
rodič
revize
8b6844ddaa

+ 15 - 0
db/supplier.go

@@ -30,3 +30,18 @@ func GetSupplierByUserID(ctx context.Context, userID int64) (*gorm_model.Youngee
 	}
 	return supplierInfo, nil
 }
+
+// GetSupplierById 服务商ID查找服务商信息
+func GetSupplierById(ctx context.Context, supplierId int) (*gorm_model.YoungeeSupplier, error) {
+	db := GetReadDB(ctx)
+	var supplierInfo *gorm_model.YoungeeSupplier
+	err := db.Where("supplier_id = ?", supplierId).First(&supplierInfo).Error
+	if err != nil {
+		if err == gorm.ErrRecordNotFound {
+			return nil, nil
+		} else {
+			return nil, err
+		}
+	}
+	return supplierInfo, nil
+}

+ 50 - 0
handler/supplier_withdraw_list.go

@@ -0,0 +1,50 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"youngee_b_api/model/http_model"
+	"youngee_b_api/service"
+)
+
+func WrapSupplierWithdrawListHandler(ctx *gin.Context) {
+	handler := newSupplierWithdrawListHandler(ctx)
+	baseRun(handler)
+}
+
+func newSupplierWithdrawListHandler(ctx *gin.Context) *SupplierWithdrawListHandler {
+	return &SupplierWithdrawListHandler{
+		req:  http_model.NewSupplierWithdrawListRequest(),
+		resp: http_model.NewSupplierWithdrawListResponse(),
+		ctx:  ctx,
+	}
+}
+
+type SupplierWithdrawListHandler struct {
+	req  *http_model.SupplierWithdrawListRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (h *SupplierWithdrawListHandler) getRequest() interface{} {
+	return h.req
+}
+func (h *SupplierWithdrawListHandler) getContext() *gin.Context {
+	return h.ctx
+}
+func (h *SupplierWithdrawListHandler) getResponse() interface{} {
+	return h.resp
+}
+func (h *SupplierWithdrawListHandler) run() {
+	toWithdrawList, err := service.Supplier.GetSupplierToWithdrawList(h.ctx, h.req)
+	if err != nil {
+		h.resp.Status = 40000
+		h.resp.Message = err.Error()
+		return
+	}
+	h.resp.Status = 50000
+	h.resp.Data = toWithdrawList
+}
+
+func (h *SupplierWithdrawListHandler) checkParam() error {
+	return nil
+}

+ 1 - 0
model/gorm_model/s_local_life.go

@@ -31,6 +31,7 @@ type YounggeeSLocalLifeInfo struct {
 	BOperator           int       `gorm:"column:b_operator"`             // 商家发起入库邀约人
 	BOperatorType       int       `gorm:"column:b_operator_type"`        // 商家发起入库邀约人类型:1主账号 2子账号
 	CreateTime          time.Time `gorm:"column:create_time"`            // 创建时间
+	FinishTime          time.Time `gorm:"column:finish_time"`            // 结束时间
 	CreateStrategyId    int       `gorm:"column:create_strategy_id"`     // 服务商修改服务费操作人ID
 	CreateStrategyType  int       `gorm:"column:create_strategy_type"`   // 服务商修改服务费操作人类型:1服务商主账号,2子账号
 }

+ 1 - 0
model/gorm_model/supplier.go

@@ -13,6 +13,7 @@ type YoungeeSupplier struct {
 	IdNumber        string `gorm:"column:id_number"`                              // 身份证号
 	Name            string `gorm:"column:name"`                                   // 姓名
 	UserId          int64  `gorm:"column:user_id"`                                // 用户表中的用户ID
+	SupplierType    int    `gorm:"column:supplier_type"`                          // 服务商用户类型,1为个人PR,2为机构
 }
 
 func (m *YoungeeSupplier) TableName() string {

+ 9 - 9
model/gorm_model/supplier_income.go

@@ -2,15 +2,15 @@ package gorm_model
 
 // YounggeeSupplierIncome 服务商收入信息
 type YounggeeSupplierIncome struct {
-	IncomeID             int     `gorm:"column:income_id;primary_key;AUTO_INCREMENT"` // 服务商收入表ID
-	SupplierID           int     `gorm:"column:supplier_id"`                          // 服务商ID
-	SupplierType         int     `gorm:"column:supplier_type"`                        // 服务商用户类型,1为个人PR,2为机构
-	SProjectID           int     `gorm:"column:s_project_id"`                         // 服务商加入商单后的种草任务ID
-	SLocalLifeID         int     `gorm:"column:s_local_life_id"`                      // 服务商加入商单后的本地生活ID
-	WithdrawStatus       int     `gorm:"column:withdraw_status"`                      // 提现状态,1-3分别表示可提现、提现中、已提现
-	IncomeType           int     `gorm:"column:income_type"`                          // 服务商收入类型,1种草,2带货,3本地生活
-	IncomeStatus         int     `gorm:"column:income_status"`                        // 收入状态:1可回发票,2待传发票,3平台确认中,4已回发票,5可提现,6提现中,7平台确认中,8已提现
-	SupplierChargeActual float64 `gorm:"column:supplier_charge_actual"`               // 服务费已结算
+	IncomeID            int     `gorm:"column:income_id;primary_key;AUTO_INCREMENT"` // 服务商收入表ID
+	SupplierID          int     `gorm:"column:supplier_id"`                          // 服务商ID
+	SupplierType        int     `gorm:"column:supplier_type"`                        // 服务商用户类型,1为个人PR,2为机构
+	SProjectID          int     `gorm:"column:s_project_id"`                         // 服务商加入商单后的种草任务ID
+	SLocalID            int     `gorm:"column:s_local_id"`                           // 服务商加入商单后的本地生活ID
+	IncomeType          int     `gorm:"column:income_type"`                          // 服务商收入类型,1种草,2带货,3本地生活
+	IncomeStatus        int     `gorm:"column:income_status"`                        // 收入状态:1可回发票,2待传发票,3平台确认中,4平台已确认,5可提现,6提现中,7平台确认中,8已提现
+	ServiceChargeSettle float64 `gorm:"column:service_charge_settle"`                // 服务费已结算
+	// WithdrawStatus      int     `gorm:"column:withdraw_status"`                      // 提现状态,1-4分别表示可提现、提现中、已提现、不可提现
 }
 
 func (m *YounggeeSupplierIncome) TableName() string {

+ 1 - 1
model/gorm_model/supplier_invoice.go

@@ -8,7 +8,7 @@ type YounggeeSupplierInvoice struct {
 	InvoiceId         int        `gorm:"column:invoice_id;primary_key;AUTO_INCREMENT"` // 服务商回票ID
 	SupplierId        int        `gorm:"column:supplier_id"`                           // 服务商ID
 	IncomeIds         string     `gorm:"column:income_ids"`                            // 服务商收入ID
-	InvoiceStatus     int        `gorm:"column:invoice_status"`                        // 回票状态,1待传发票,2平台确认中,3已回发票,4发票驳回
+	InvoiceStatus     int        `gorm:"column:invoice_status"`                        // 回票状态,1待传发票,2平台确认中,3平台已确认,4发票驳回
 	InvoiceUrl        string     `gorm:"column:invoice_url"`                           // 发票url
 	SOperator         int        `gorm:"column:s_operator"`                            // 服务商回票操作人
 	SOperatorType     int        `gorm:"column:s_operator_type"`                       // 服务商回票操作人类型,1主,2子

+ 4 - 4
model/gorm_model/supplier_withdraw.go

@@ -19,10 +19,10 @@ type YounggeeSupplierWithdraw struct {
 	BankNumber         string     `gorm:"column:bank_number"`                      // 提现银行卡号
 	Phone              string     `gorm:"column:phone"`                            // 手机号码
 	WithdrawStatus     int        `gorm:"column:withdraw_status"`                  // 提现状态:1待提现,2提现中,3已提现,4已驳回
-	SupplyTime         *time.Time `gorm:"column:supply_time"`
-	AgreeTime          *time.Time `gorm:"column:agree_time"`
-	RejectTime         *time.Time `gorm:"column:reject_time"`
-	FailReson          string     `gorm:"column:fail_reson"`
+	SupplyTime         *time.Time `gorm:"column:supply_time"`                      // 申请时间
+	AgreeTime          *time.Time `gorm:"column:agree_time"`                       // 同意时间
+	RejectTime         *time.Time `gorm:"column:reject_time"`                      // 驳回时间
+	FailReason         string     `gorm:"column:fail_reason"`                      // 驳回原因
 }
 
 func (m *YounggeeSupplierWithdraw) TableName() string {

+ 2 - 1
model/http_model/full_s_project_income_list.go

@@ -25,7 +25,8 @@ type FullSProjectIncomeListResponse struct {
 	ProductPhotoUid      string  `json:"product_photo_uid"`       // uid
 	ProductName          string  `json:"product_name"`            // 商品名称
 	ProductPrice         float64 `json:"product_price"`           // 商品售价
-	SupplierChargeActual float64 `json:"supplier_charge_actual"`  // 服务费已结算
+	ServiceCharge        float64 `json:"service_charge"`          // 服务费总计
+	ServiceChargeSettle  float64 `json:"service_charge_settle"`   // 服务费已结算
 	FinishTime           string  `json:"finish_time"`             // 结束时间
 	SLocalId             int     `json:"s_local_id"`              // 本地生活ID
 	LocalName            string  `json:"local_name"`              // 本地生活名称

+ 8 - 6
model/http_model/supplier_to_withdraw_list.go

@@ -16,12 +16,14 @@ type SupplierToWithdrawListData struct {
 }
 
 type SupplierToWithdrawInfo struct {
-	InvoiceId int          `json:"invoice_id"`  // 回票ID,企业服务商需要
-	IncomeId  int          `json:"income_id"`   // 收入ID,个人服务商不需要回票,所以需要这个
-	STaskInfo []*STaskInfo `json:"s_task_info"` // 任务信息
-	Amount    float64      `json:"amount"`      // 回票金额
-	AgreeTime *time.Time   `json:"agree_time"`  // 同意时间
-	Company   string       `json:"company"`     // 公司名称
+	SupplierType int          `json:"supplier_type"` // 服务商类型,1个人,2企业
+	InvoiceId    int          `json:"invoice_id"`    // 回票ID,企业服务商需要
+	IncomeId     int          `json:"income_id"`     // 收入ID,个人服务商不需要回票,所以需要这个
+	STaskInfo    []*STaskInfo `json:"s_task_info"`   // 任务信息
+	Amount       float64      `json:"amount"`        // 回票金额
+	AmountActual float64      `json:"amount_actual"` // 个人服务商应到账金额
+	AgreeTime    *time.Time   `json:"agree_time"`    // 同意时间
+	Company      string       `json:"company"`       // 公司名称
 }
 
 func NewSupplierToWithdrawListRequest() *SupplierToWithdrawListRequest {

+ 40 - 0
model/http_model/supplier_withdraw_list.go

@@ -0,0 +1,40 @@
+package http_model
+
+type SupplierWithdrawListRequest struct {
+	SupplierId int   `json:"supplier_id"` // 服务商ID
+	PageNum    int32 `json:"page_num"`
+	PageSize   int32 `json:"page_size"`
+}
+
+type SupplierWithdrawListData struct {
+	WithdrawList []*SupplierWithdrawInfo `json:"withdraw_list"` // 待提现收入列表
+	Total        int64                   `json:"total"`         // 数量
+}
+
+type SupplierWithdrawInfo struct {
+	SupplierType       int          `json:"supplier_type"`        // 服务商类型,1个人,2企业
+	SupplierWithdrawId int          `json:"supplier_withdraw_id"` // 提现流水号
+	WithdrawAmount     float64      `json:"withdraw_amount"`      // 提现金额
+	AmountPayable      float64      `json:"amount_payable"`       // 实际提现金额(扣税后)
+	STaskInfo          []*STaskInfo `json:"s_task_info"`          // 任务信息
+	Name               string       `json:"name"`                 // 姓名
+	IDNumber           string       `json:"id_number"`            // 身份证号
+	BankName           string       `json:"bank_name"`            // 开户银行名称
+	BankNumber         string       `json:"bank_number"`          // 银行卡
+	Phone              string       `json:"phone"`                // 手机号
+	Company            string       `json:"company"`              // 公司名称
+	SupplyTime         string       `json:"supply_time"`          // 申请时间
+	AgreeTime          string       `json:"agree_time"`           // 同意时间
+	RejectTime         string       `json:"reject_time"`          // 驳回时间
+	FailReason         string       `json:"fail_reason"`          // 驳回原因
+}
+
+func NewSupplierWithdrawListRequest() *SupplierWithdrawListRequest {
+	return new(SupplierWithdrawListRequest)
+}
+
+func NewSupplierWithdrawListResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(SupplierWithdrawListData)
+	return resp
+}

+ 6 - 3
route/init.go

@@ -206,18 +206,21 @@ func InitRoute(r *gin.Engine) {
 	{
 		f.Use(middleware.LoginAuthMiddleware)
 
-		// 财务管理
+		// 账单查询
 		f.POST("/fullSProject/billList", handler.WrapFullSProjectBillListHandler)         // 种草任务账单列表
 		f.POST("/fullSProject/taskBillList", handler.WrapFullSProjectTaskBillListHandler) // 种草子任务账单列表
 		f.POST("/fullSLocal/billList", handler.WrapFullSLocalBillListHandler)             // 本地生活任务账单列表
 		f.POST("/fullSLocal/taskBillList", handler.WrapFullSLocalTaskBillListHandler)     // 本地生活子任务账单列表
-		f.POST("/supplierWithdraw/toList", handler.WrapSupplierToWithdrawListHandler)     // 服务商可提现账单列表
-		f.POST("/supplierWithdraw/create", handler.WrapCreateSupplierWithdrawHandler)     // 服务商提现
 
 		// 回票
 		f.POST("/supplierInvoice/incomeList", handler.WrapFullSProjectIncomeListHandler) // 可回发票列表
 		f.POST("/supplierInvoice/create", handler.WrapCreateSupplierInvoiceHandler)      // 合并账单回票
 		f.POST("/supplierInvoice/update", handler.WrapUpdateSupplierInvoiceHandler)      // 上传发票
 		f.POST("/supplierInvoice/invoiceList", handler.WrapSupplierInvoiceListHandler)   // 发票列表
+
+		// 提现
+		f.POST("/supplierWithdraw/toList", handler.WrapSupplierToWithdrawListHandler) // 服务商可提现账单列表
+		f.POST("/supplierWithdraw/create", handler.WrapCreateSupplierWithdrawHandler) // 服务商提现
+		f.POST("/supplierWithdraw/List", handler.WrapSupplierWithdrawListHandler)     // 提现管理列表
 	}
 }

+ 274 - 61
service/supplier.go

@@ -3,6 +3,7 @@ package service
 import (
 	"context"
 	"fmt"
+	"github.com/issue9/conv"
 	log "github.com/sirupsen/logrus"
 	"strconv"
 	"strings"
@@ -67,6 +68,103 @@ func (*supplier) GetSupplierIncomeList(ctx context.Context, req *http_model.Full
 	// 2. 补充种草/本地生活任务信息
 	if supplierIncome != nil {
 		sProjectIncomeData.Total = total
+		for _, income := range supplierIncome {
+			// 2.1. 种草任务基本信息
+			if income.IncomeType == 1 {
+				var sProjectInfo *http_model.FullSProjectIncomeListResponse
+				sProjectInfo = &http_model.FullSProjectIncomeListResponse{}
+				sProjectData, sProjectErr := db.GetSProjectDetail(ctx, income.SProjectID)
+				if sProjectErr != nil {
+					log.Infof("[GetSProjectDetail] fail,err:%+v", sProjectErr)
+					return nil, sProjectErr
+				}
+				if sProjectData != nil {
+					sProjectInfo.SProjectId = sProjectData.SProjectId
+					sProjectInfo.IncomeId = income.IncomeID
+					sProjectInfo.IncomeType = income.IncomeType
+					sProjectInfo.SProjectId = sProjectData.SProjectId
+					sProjectInfo.ProjectName = sProjectData.ProjectName
+					sProjectInfo.ProjectPlatform = sProjectData.ProjectPlatform
+					sProjectInfo.ServiceCharge = sProjectData.ServiceCharge
+					sProjectInfo.ServiceChargeSettle = sProjectData.ServiceChargeSettle
+					sProjectInfo.FinishTime = conv.MustString(sProjectData.FinishTime)
+
+					// 2.2. 商品基本信息
+					productInfo, productErr := db.GetProductByID(ctx, sProjectData.ProductId)
+					if productErr != nil {
+						log.Infof("[GetProductByID] fail,err:%+v", productErr)
+						return nil, productErr
+					}
+					if productInfo != nil {
+						sProjectInfo.ProductName = productInfo.ProductName
+						sProjectInfo.ProductPrice = productInfo.ProductPrice
+					}
+					// 2.3. 商品图片信息
+					productPhotoInfo, productPhotoErr := db.GetProductPhotoByProductID(ctx, sProjectData.ProductId)
+					if productPhotoErr != nil {
+						log.Infof("[GetProductPhotoByProductID] fail,err:%+v", productPhotoErr)
+						return nil, productPhotoErr
+					}
+					if productPhotoInfo != nil {
+						for _, photo := range productPhotoInfo {
+							fmt.Println(photo)
+							if photo.Symbol == 1 {
+								sProjectInfo.ProductPhotoSymbol = 1
+								sProjectInfo.ProductPhotoUrl = photo.PhotoUrl
+								sProjectInfo.ProductPhotoUid = photo.PhotoUid
+							}
+						}
+					}
+				}
+			}
+
+			// 2.1. 本地生活任务基本信息
+			if income.IncomeType == 2 {
+				var sLocalInfo *http_model.FullSProjectIncomeListResponse
+				sLocalInfo = &http_model.FullSProjectIncomeListResponse{}
+				sLocalData, sLocalErr := db.GetSLocalLifeDetail(ctx, income.SLocalID)
+				if sLocalErr != nil {
+					log.Infof("[GetSLocalLifeDetail] fail,err:%+v", sLocalErr)
+					return nil, sLocalErr
+				}
+				if sLocalData != nil {
+					sLocalInfo.IncomeId = income.IncomeID
+					sLocalInfo.IncomeType = income.IncomeType
+					sLocalInfo.SLocalId = sLocalData.SLocalId
+					sLocalInfo.LocalName = sLocalData.LocalName
+					sLocalInfo.LocalPlatform = sLocalData.LocalPlatform
+					sLocalInfo.ServiceCharge = sLocalData.ServiceCharge
+					sLocalInfo.ServiceChargeSettle = sLocalData.ServiceChargeSettle
+					sLocalInfo.FinishTime = conv.MustString(sLocalData.FinishTime)
+
+					// 2.2. 门店基本信息
+					storeInfo, storeErr := db.FindStoreById(ctx, sLocalData.StoreId)
+					if storeErr != nil {
+						log.Infof("[GetProductByID] fail,err:%+v", storeErr)
+						return nil, storeErr
+					}
+					if storeInfo != nil {
+						sLocalInfo.StoreName = storeInfo.StoreName
+					}
+					// 2.3. 门店图片信息
+					storePhotoInfo, storePhotoErr := db.GetStorePhotoByStoreID(ctx, sLocalData.StoreId)
+					if storePhotoErr != nil {
+						log.Infof("[GetProductPhotoByProductID] fail,err:%+v", storePhotoErr)
+						return nil, storePhotoErr
+					}
+					if storePhotoInfo != nil {
+						for _, photo := range storePhotoInfo {
+							fmt.Println(photo)
+							if photo.Symbol == 1 {
+								sLocalInfo.StoreMainPhotoSymbol = 1
+								sLocalInfo.StoreMainPhotoUrl = photo.PhotoUrl
+								sLocalInfo.StoreMainPhotoUid = photo.PhotoUid
+							}
+						}
+					}
+				}
+			}
+		}
 	} else {
 		sProjectIncomeData.Total = 0
 	}
@@ -210,11 +308,11 @@ func (*supplier) GetSupplierInvoiceList(ctx context.Context, req *http_model.Sup
 			if incomeErr != nil {
 				return nil, incomeErr
 			}
-			sTaskInfo.ServiceCharge = currIncome.SupplierChargeActual
+			sTaskInfo.ServiceCharge = currIncome.ServiceChargeSettle
 			if currIncome.IncomeType == 1 {
 				sTaskInfo.Id = currIncome.SProjectID
 			} else if currIncome.IncomeType == 3 {
-				sTaskInfo.Id = currIncome.SLocalLifeID
+				sTaskInfo.Id = currIncome.SLocalID
 			}
 			supplierInvoiceInfo.STaskInfo = append(supplierInvoiceInfo.STaskInfo, sTaskInfo)
 		}
@@ -226,84 +324,194 @@ 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. 查询服务商发票信息
+
+	// 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
+	supplierInfo, supplierErr := db.GetSupplierById(ctx, req.SupplierId)
+	if supplierErr != nil {
+		return nil, supplierErr
 	}
-	if supplierInvoiceList != nil {
+	if supplierInfo != 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
+		if supplierInfo.SupplierType == 2 {
+			// 查询企业服务商发票信息
+			supplierInvoiceList, total, supplierInvoiceErr := db.GetInvoiceListBySupplierId(ctx, req.SupplierId, 3, 1, req.PageSize, req.PageNum)
+			if supplierInvoiceErr != nil {
+				return nil, supplierInvoiceErr
 			}
-			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 {
+				for _, supplierInvoice := range supplierInvoiceList {
+					// 2. 根据发票中的incomeIds去查找任务及其服务费收入
+					var supplierInvoiceInfo *http_model.SupplierToWithdrawInfo
+					supplierInvoiceInfo = &http_model.SupplierToWithdrawInfo{}
+
+					// 2.1. 基础信息填入
+					supplierInvoiceInfo.AgreeTime = supplierInvoice.AgreeTime
+					supplierInvoiceInfo.Company = supplierInvoice.Company
+					supplierInvoiceInfo.SupplierType = supplierInfo.SupplierType
+
+					// 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
+						}
+						sTaskInfo.ServiceCharge = currIncome.ServiceChargeSettle
+						supplierInvoiceInfo.Amount += currIncome.ServiceChargeSettle
+						if currIncome.IncomeType == 1 {
+							sTaskInfo.Id = currIncome.SProjectID
+						} else if currIncome.IncomeType == 3 {
+							sTaskInfo.Id = currIncome.SLocalID
+						}
+						supplierInvoiceInfo.STaskInfo = append(supplierInvoiceInfo.STaskInfo, sTaskInfo)
+					}
+					supplierInvoiceData.ToWithdrawList = append(supplierInvoiceData.ToWithdrawList, supplierInvoiceInfo)
 				}
-				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
+				supplierInvoiceData.Total = total
+			}
+
+		} else if supplierInfo.SupplierType == 1 {
+			// 个人服务商
+			// 查询个人服务商收入信息
+			supplierIncomeList, supplierIncomeTotal, supplierIncomeErr := db.GetSupplierIncomeList(ctx, req.PageSize, req.PageNum, req.SupplierId, 5)
+			if supplierIncomeErr != nil {
+				return nil, supplierIncomeErr
+			}
+			if supplierIncomeList != nil {
+				supplierInvoiceData.Total = supplierIncomeTotal
+				for _, supplierIncome := range supplierIncomeList {
+					var supplierInvoiceInfo *http_model.SupplierToWithdrawInfo
+					supplierInvoiceInfo = &http_model.SupplierToWithdrawInfo{}
+					supplierInvoiceInfo.SupplierType = supplierInfo.SupplierType
+					supplierInvoiceInfo.IncomeId = supplierIncome.IncomeID
+					supplierInvoiceInfo.Amount = supplierIncome.ServiceChargeSettle
+					supplierInvoiceInfo.AmountActual = supplierIncome.ServiceChargeSettle * 0.05
+					var sTaskInfo *http_model.STaskInfo
+					sTaskInfo = &http_model.STaskInfo{}
+					sTaskInfo.ServiceCharge = supplierIncome.ServiceChargeSettle
+					if supplierIncome.IncomeType == 1 {
+						sTaskInfo.Id = supplierIncome.SProjectID
+					} else if supplierIncome.IncomeType == 3 {
+						sTaskInfo.Id = supplierIncome.SLocalID
+					}
+					supplierInvoiceInfo.STaskInfo = append(supplierInvoiceInfo.STaskInfo, sTaskInfo)
+					supplierInvoiceData.ToWithdrawList = append(supplierInvoiceData.ToWithdrawList, supplierInvoiceInfo)
 				}
-				supplierInvoiceInfo.STaskInfo = append(supplierInvoiceInfo.STaskInfo, sTaskInfo)
 			}
-			supplierInvoiceData.ToWithdrawList = append(supplierInvoiceData.ToWithdrawList, supplierInvoiceInfo)
+
 		}
-		supplierInvoiceData.Total = total
-	} else {
-		// 个人服务商
 	}
-
 	return supplierInvoiceData, nil
 }
 
-// CreateSupplierWithdraw TODO
 // CreateSupplierWithdraw 创建服务商提现信息
 func (*supplier) CreateSupplierWithdraw(ctx context.Context, req *http_model.CreateSupplierWithdrawRequest) error {
 
-	// 1. 数据整理
 	var supplierWithdrawInfoList []*gorm_model.YounggeeSupplierWithdraw
-	for _, withdrawInfo := range req.CreateCompanySupplierWithdraw {
-		var supplierWithdrawInfo *gorm_model.YounggeeSupplierWithdraw
-		supplierWithdrawInfo = &gorm_model.YounggeeSupplierWithdraw{}
-
-		// 1.1. 接口传入信息填入
-		supplierWithdrawInfo.SupplierId = req.SupplierId
-		supplierWithdrawInfo.WithdrawStatus = 1
-		supplierWithdrawInfo.BankName = withdrawInfo.BankName
-		supplierWithdrawInfo.BankNumber = withdrawInfo.BankNumber
-
-		// 1.2. 查找服务商信息填入
-
-		// 1.3. 回票信息填入
-		supplierWithdrawInfoList = append(supplierWithdrawInfoList, supplierWithdrawInfo)
 
+	// 1. 判断服务商类型
+	supplierInfo, supplierErr := db.GetSupplierById(ctx, req.SupplierId)
+	if supplierErr != nil {
+		return supplierErr
+	}
+	if supplierInfo != nil {
+		if supplierInfo.SupplierType == 1 {
+			// 1.1. 个人服务商
+			for _, withdrawInfo := range req.CreatePersonSupplierWithdraw {
+				var supplierWithdrawInfo *gorm_model.YounggeeSupplierWithdraw
+				supplierWithdrawInfo = &gorm_model.YounggeeSupplierWithdraw{}
+
+				// 1.2.1. 接口传入信息填入
+				supplierWithdrawInfo.SupplierId = req.SupplierId
+				supplierWithdrawInfo.WithdrawStatus = 2
+				supplierWithdrawInfo.BankName = withdrawInfo.BankName
+				supplierWithdrawInfo.BankNumber = withdrawInfo.BankNumber
+				var currentTime time.Time
+				currentTime = time.Now()
+				supplierWithdrawInfo.SupplyTime = &currentTime
+				supplierWithdrawInfo.WithdrawAmount = 0.0
+
+				// 1.2.2. 查找服务商信息填入
+				supplierWithdrawInfo.Name = supplierInfo.Name
+				supplierWithdrawInfo.Phone = withdrawInfo.Phone
+
+				// 1.2.3. 收入信息填入
+				currIncome, incomeInfoErr := db.GetIncomeInfoByIncomeId(ctx, withdrawInfo.IncomeId)
+				if incomeInfoErr != nil {
+					return incomeInfoErr
+				}
+				if currIncome != nil {
+					supplierWithdrawInfo.WithdrawAmount += currIncome.ServiceChargeSettle
+				}
+				supplierWithdrawInfo.AmountPayable = supplierWithdrawInfo.WithdrawAmount
+				supplierWithdrawInfoList = append(supplierWithdrawInfoList, supplierWithdrawInfo)
+			}
+		} else if supplierInfo.SupplierType == 2 {
+			// 1.2. 机构服务商
+			for _, withdrawInfo := range req.CreateCompanySupplierWithdraw {
+				var supplierWithdrawInfo *gorm_model.YounggeeSupplierWithdraw
+				supplierWithdrawInfo = &gorm_model.YounggeeSupplierWithdraw{}
+
+				// 1.2.1. 接口传入信息填入
+				supplierWithdrawInfo.SupplierId = req.SupplierId
+				supplierWithdrawInfo.WithdrawStatus = 2
+				supplierWithdrawInfo.BankName = withdrawInfo.BankName
+				supplierWithdrawInfo.BankNumber = withdrawInfo.BankNumber
+				var currentTime time.Time
+				currentTime = time.Now()
+				supplierWithdrawInfo.SupplyTime = &currentTime
+				supplierWithdrawInfo.WithdrawAmount = 0.0
+
+				// 1.2.2. 查找服务商信息填入
+				supplierWithdrawInfo.Name = supplierInfo.Name
+				supplierWithdrawInfo.Phone = supplierInfo.PhoneNumber
+				supplierWithdrawInfo.Company = supplierInfo.CompanyName
+
+				// 1.2.3. 收入信息填入
+				incomeIds, incomeErr := db.GetIncomeIdsByInvoiceId(ctx, withdrawInfo.InvoiceId)
+				if incomeErr != nil {
+					return incomeErr
+				}
+				if 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 err
+						}
+						intSlice[i] = num
+					}
+					for _, incomeId := range intSlice {
+						currIncome, incomeInfoErr := db.GetIncomeInfoByIncomeId(ctx, incomeId)
+						if incomeInfoErr != nil {
+							return incomeInfoErr
+						}
+						if currIncome != nil {
+							supplierWithdrawInfo.WithdrawAmount += currIncome.ServiceChargeSettle
+						}
+					}
+					supplierWithdrawInfo.AmountPayable = supplierWithdrawInfo.WithdrawAmount
+				}
+				supplierWithdrawInfoList = append(supplierWithdrawInfoList, supplierWithdrawInfo)
+			}
+		}
 	}
 
 	// 2. 数据库插入
@@ -314,3 +522,8 @@ func (*supplier) CreateSupplierWithdraw(ctx context.Context, req *http_model.Cre
 
 	return nil
 }
+
+// GetSupplierWithdrawList 服务商提现列表
+func (*supplier) GetSupplierWithdrawList(ctx context.Context, req *http_model.SupplierWithdrawListRequest) (*http_model.SupplierWithdrawListData, error) {
+	
+}