package authPayment import ( "errors" "fmt" artShow "github.com/fonchain_enterprise/fonchain-main/api/artShow" "strconv" ) type GetAuthPaymentListRequest struct { Page int64 `json:"page"` PageSize int64 `json:"pageSize"` artShow.AuthPaymentData } type GetViewAuthPaymentListRequest struct { Page int64 `json:"page"` PageSize int64 `json:"pageSize"` artShow.ViewAuthPaymentData Where string `json:"where"` ArtworkNumBegin *int32 `json:"artworkNumBegin"` ArtworkNumEnd *int32 `json:"artworkNumEnd"` PriceBegin *int32 `json:"priceBegin"` PriceEnd *int32 `json:"priceEnd"` PayTimeBegin *string `json:"payTimeBegin"` PayTimeEnd *string `json:"payTimeEnd"` SendTimeBegin *string `json:"sendTimeBegin"` SendTimeEnd *string `json:"sendTimeEnd"` RulerBegin *int32 `json:"rulerBegin"` RulerEnd *int32 `json:"rulerEnd"` } func (g *GetViewAuthPaymentListRequest) AddWhere(condition string, params ...any) { if condition == "" { return } if len(params) > 0 { condition = fmt.Sprintf(condition, params...) } if g.Where == "" { g.Where = condition } else { g.Where += " and " + condition } } func (g *GetViewAuthPaymentListRequest) QueryIsEmpty() bool { return g.ArtworkNumBegin == nil && g.ArtworkNumEnd == nil && g.PriceBegin == nil && g.PriceEnd == nil && g.PayTimeBegin == nil && g.PayTimeEnd == nil && g.SendTimeBegin == nil && g.SendTimeEnd == nil && g.RulerBegin == nil && g.RulerEnd == nil && g.ShowUid == "" && g.ShowName == "" && g.ArtistName == "" && g.Tnum == "" && g.ArtistUid == "" && g.Ruler == 0 && g.Price == 0 && g.ExhibitionType == 0 && g.IsConfirm == 0 && g.PayStatus == 0 && g.PayTime == "" && g.Per == 0 && //g.HasSend == 0 && g.ArtworkNum == 0 && g.FinalPrice == "" && g.SenderName == "" && g.SendTime == "" && g.PaySessionId == "" } type UpdateAuthPaymentHasSendReq struct { ShowUid string `json:"showUid"` ExpenseType artShow.ExpenseType `json:"expenseType"` Remark string `json:"remark"` FinalPrice string `json:"finalPrice"` finalPricceF float32 } func (u *UpdateAuthPaymentHasSendReq) Validate() error { if u.ExpenseType < 1 || u.ExpenseType > 3 { return errors.New("无效的费用类型") } finalPricceF, err := strconv.ParseFloat(u.FinalPrice, 64) if err != nil { return errors.New("最终金额不是有效的数字") } u.finalPricceF = float32(finalPricceF) // 检查是否是整数 if u.finalPricceF != float32(int(u.finalPricceF)) { return errors.New("最终金额必须是整数") } // 检查范围 if u.finalPricceF < 1 || u.finalPricceF > 999999 { return errors.New("最终金额必须在1到999999之间") } return nil } type GetViewAuthPaymentListData struct { List []*artShow.ViewAuthPaymentData `json:"list"` CurrentEditPer int `json:"currentEditPer"` } type UpdateAuthPaymentPercentReq struct { CurrentEditPer int32 `json:"currentEditPer"` } type GetAuthPaymentArtShowListRequest struct { Page int64 `json:"page"` PageSize int64 `json:"pageSize"` Where string `json:"where"` Order string `json:"order"` artShow.ViewAuthPaymentArtShow ArtworkNumBegin *int32 `json:"artworkNumBegin"` //画作数起始 ArtworkNumEnd *int32 `json:"artworkNumEnd"` //画作数结束 RulerBegin *int32 `json:"rulerBegin"` //平尺数起始 RulerEnd *int32 `json:"rulerEnd"` //平尺数结束 PriceBegin *int32 `json:"priceBegin"` //底价起始 PriceEnd *int32 `json:"priceEnd"` //底价结束 SendPayCountBegin *int32 `json:"sendPayCountBegin"` //发起支付数起始 SendPayCountEnd *int32 `json:"sendPayCountEnd"` //发起支付数结束 SendTimeBegin *string `json:"sendTimeBegin"` //发起时间起始 SendTimeEnd *string `json:"sendTimeEnd"` //发起时间结束 PayStatus int32 `json:"payStatus"` //支付状态 1=未支付(包含支付失败) 2=已支付 HasSend int32 `json:"hasSend"` //对应ViewAuthPaymentArtShow.SendPay 进行优化 } func (g *GetAuthPaymentArtShowListRequest) AddWhere(condition string, params ...any) { if condition == "" { return } if len(params) > 0 { condition = fmt.Sprintf(condition, params...) } if g.Where == "" { g.Where = condition } else { g.Where += " and " + condition } } type UpdateAuthPaymentDataReq struct { ID int64 `json:"id"` FinalPrice string `json:"finalPrice"` ExpenseType artShow.ExpenseType `json:"expenseType"` PayType artShow.PayType `json:"payType"` Remark string `json:"remark"` finalPricceF float32 } func (u *UpdateAuthPaymentDataReq) Validate() error { if u.ExpenseType < 1 || u.ExpenseType > 3 { return errors.New("无效的费用类型") } finalPricceF, err := strconv.ParseFloat(u.FinalPrice, 64) if err != nil { return errors.New("最终金额不是有效的数字") } u.finalPricceF = float32(finalPricceF) // 检查是否是整数 if u.finalPricceF != float32(int(u.finalPricceF)) { return errors.New("最终金额必须是整数") } // 检查范围 if u.finalPricceF < 1 || u.finalPricceF > 999999 { return errors.New("最终金额必须在1到999999之间") } return nil }