package final import ( "fmt" "zhiyuan/pkg/db" "github.com/gin-gonic/gin" ) type FinalSupplierPunish struct { ID int64 `json:"id" prop:"add:false"` SupplierId int64 `json:"supplierId" label:"材料商ID" type:"int" prop:"add" search:"="` Amount float64 `json:"amount" label:"金额" type:"float" prop:"add edit" default:"0" search:"="` Explain string `json:"explain" label:"说明" type:"string" prop:"edit" search:"like"` DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"` CreatedAt int64 `json:"created_at" prop:"add:false"` UpdatedAt int64 `json:"updated_at" prop:"add:false"` db.BaseModel } func (FinalSupplierPunish) TableName() string { return "zy_final_supplier_punish" } func (FinalSupplierPunish) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool { return true } func (FinalSupplierPunish) OnePrivilege(c *gin.Context, id int64) bool { return true } func (FinalSupplierPunish) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error { return nil } func (FinalSupplierPunish) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error { return nil } func (FinalSupplierPunish) DelPrivilege(c *gin.Context, id int64) error { return nil } func (FinalSupplierPunish) Page() bool { return false } func (FinalSupplierPunish) Count() bool { return true } func (FinalSupplierPunish) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel { return []db.JoinModel{} } type FinalSupplierPunishStatist struct { Punished float64 `json:"punished" label:"已罚金额" type:"float" prop:"select:ifnull(deduction.deduction_total,0)"` UnPunished float64 `json:"unpunished" label:"未罚金额" type:"float" prop:"add:false select:zy_final_supplier_punish.amount-ifnull(deduction.deduction_total,0)"` FinalSupplierPunish } type FinalSupplierPunishStatistJoinDeduction struct { db.BaseModel } func (FinalSupplierPunishStatistJoinDeduction) TableName() string { return "(select `deduction`.`supplierId`, `deduction`.`punishId`, ifnull(sum(`deduction`.`amount`),0) as `deduction_total` from `zy_final_supplier_punish_deduction` as `deduction` left join `zy_final_material_settle` as `settle` on `settle`.`id` = `deduction`.`settleId` where `deduction`.`deleted_at` = 0 and `settle`.`state` != -1 group by `deduction`.`punishId`)" } func (model FinalSupplierPunishStatist) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool { return model.FinalSupplierPunish.ListPrivilege(c, data, s) } func (model FinalSupplierPunishStatist) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel { return append(model.FinalSupplierPunish.LeftJoin(data, s), db.JoinModel{ Model: FinalSupplierPunishStatistJoinDeduction{}, As: "deduction", On: []string{ fmt.Sprintf("`deduction`.`punishId` = `%s`.`id`", model.TableName()), }, }) }