final_supplier_punish.go 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. package final
  2. import (
  3. "fmt"
  4. "zhiyuan/pkg/db"
  5. "github.com/gin-gonic/gin"
  6. )
  7. type FinalSupplierPunish struct {
  8. ID int64 `json:"id" prop:"add:false"`
  9. SupplierId int64 `json:"supplierId" label:"材料商ID" type:"int" prop:"add" search:"="`
  10. Amount float64 `json:"amount" label:"金额" type:"float" prop:"add edit" default:"0" search:"="`
  11. Explain string `json:"explain" label:"说明" type:"string" prop:"edit" search:"like"`
  12. DeletedAt int64 `json:"deleted_at" prop:"add:false select:false"`
  13. CreatedAt int64 `json:"created_at" prop:"add:false"`
  14. UpdatedAt int64 `json:"updated_at" prop:"add:false"`
  15. db.BaseModel
  16. }
  17. func (FinalSupplierPunish) TableName() string {
  18. return "zy_final_supplier_punish"
  19. }
  20. func (FinalSupplierPunish) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
  21. return true
  22. }
  23. func (FinalSupplierPunish) OnePrivilege(c *gin.Context, id int64) bool {
  24. return true
  25. }
  26. func (FinalSupplierPunish) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
  27. return nil
  28. }
  29. func (FinalSupplierPunish) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
  30. return nil
  31. }
  32. func (FinalSupplierPunish) DelPrivilege(c *gin.Context, id int64) error {
  33. return nil
  34. }
  35. func (FinalSupplierPunish) Page() bool {
  36. return false
  37. }
  38. func (FinalSupplierPunish) Count() bool {
  39. return true
  40. }
  41. func (FinalSupplierPunish) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
  42. return []db.JoinModel{}
  43. }
  44. type FinalSupplierPunishStatist struct {
  45. Punished float64 `json:"punished" label:"已罚金额" type:"float" prop:"select:ifnull(deduction.deduction_total,0)"`
  46. UnPunished float64 `json:"unpunished" label:"未罚金额" type:"float" prop:"add:false select:zy_final_supplier_punish.amount-ifnull(deduction.deduction_total,0)"`
  47. FinalSupplierPunish
  48. }
  49. type FinalSupplierPunishStatistJoinDeduction struct {
  50. db.BaseModel
  51. }
  52. func (FinalSupplierPunishStatistJoinDeduction) TableName() string {
  53. 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`)"
  54. }
  55. func (model FinalSupplierPunishStatist) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
  56. return model.FinalSupplierPunish.ListPrivilege(c, data, s)
  57. }
  58. func (model FinalSupplierPunishStatist) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
  59. return append(model.FinalSupplierPunish.LeftJoin(data, s), db.JoinModel{
  60. Model: FinalSupplierPunishStatistJoinDeduction{},
  61. As: "deduction",
  62. On: []string{
  63. fmt.Sprintf("`deduction`.`punishId` = `%s`.`id`", model.TableName()),
  64. },
  65. })
  66. }