123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132 |
- package final
- import (
- "fmt"
- "zhiyuan/pkg/db"
- "github.com/gin-gonic/gin"
- )
- type FinalSupplier struct {
- ID int64 `json:"id" prop:"add:false"`
- Name string `json:"name" label:"名称" type:"string" prop:"add edit" search:"like"`
- AdminId int64 `json:"adminId" label:"人员ID" type:"int" prop:"add edit" search:"="`
- ReceiptHour int64 `json:"receipt_hour" label:"配送小时" type:"int" prop:"edit" default:"0" search:"="`
- StockHour int64 `json:"stock_hour" label:"备货小时" type:"int" prop:"edit" default:"0" search:"="`
- CustomStockHour int64 `json:"custom_stock_hour" label:"定制品备货小时" type:"int" prop:"edit" default:"0" search:"="`
- InstallHour int64 `json:"install_hour" label:"安装小时" type:"int" prop:"edit" default:"0" search:"="`
- Prepayment int64 `json:"prepayment" label:"预付款" type:"int" prop:"edit" default:"0" search:"="`
- WarningAmount float64 `json:"warning_amount" label:"预付款预警金额" type:"float" prop:"edit" default:"0" search:"="`
- NoticeIds string `json:"notice_ids" label:"预付款通知人" type:"string" prop:"edit"`
- Install int64 `json:"install" label:"安装" type:"int" prop:"edit" default:"0" search:"="`
- Reduce int64 `json:"reduce" label:"精简流程" type:"int" prop:"edit" default:"0" search:"="`
- State int64 `json:"state" label:"状态" type:"int" prop:"edit" default:"0" search:"="`
- OrderAt int64 `json:"order_at" prop:"add:false select:false"`
- 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 (FinalSupplier) TableName() string {
- return "zy_final_supplier"
- }
- func (FinalSupplier) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
- return true
- }
- func (FinalSupplier) OnePrivilege(c *gin.Context, id int64) bool {
- return true
- }
- func (FinalSupplier) AddPrivilege(c *gin.Context, data map[string]interface{}, post map[string]interface{}) error {
- return nil
- }
- func (FinalSupplier) EditPrivilege(c *gin.Context, id int64, data map[string]interface{}, post map[string]interface{}) error {
- return nil
- }
- func (FinalSupplier) DelPrivilege(c *gin.Context, id int64) error {
- return nil
- }
- func (FinalSupplier) Page() bool {
- return false
- }
- func (FinalSupplier) Count() bool {
- return true
- }
- func (model FinalSupplier) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
- return []db.JoinModel{}
- }
- type FinalSupplierPrepaymentStatist struct {
- OrderTotal float64 `json:"order_total" type:"float" prop:"select:ifnull(order.total,0)"`
- PrepaymentTotal float64 `json:"prepayment_total" type:"float" prop:"select:ifnull(prepayment.total,0)"`
- Total float64 `json:"total" type:"float" prop:"select:ifnull(prepayment.total,0)-ifnull(order.total,0)"`
- FinalSupplier
- }
- type FinalSupplierJoinOrder struct {
- db.BaseModel
- }
- func (FinalSupplierJoinOrder) TableName() string {
- return "(select `supplier_id`,ifnull(sum(total),0) as `total` from `zy_final_material_order` where `state` >= 0 and `deleted_at` = 0 group by `supplier_id`)"
- }
- type FinalSupplierJoinPrepayment struct {
- db.BaseModel
- }
- func (FinalSupplierJoinPrepayment) TableName() string {
- return "(select `supplierId`,ifnull(sum(amount),0) as `total` from `zy_final_supplier_prepayment` where `deleted_at` = 0 group by `supplierId`)"
- }
- func (model FinalSupplierPrepaymentStatist) ListPrivilege(c *gin.Context, data map[string]interface{}, s *db.Select) bool {
- s.Where = append(s.Where, fmt.Sprintf("`%s`.`prepayment` = %s", model.TableName(), s.Param(1)))
- return model.FinalSupplier.ListPrivilege(c, data, s)
- }
- func (model FinalSupplierPrepaymentStatist) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
- return append(model.FinalSupplier.LeftJoin(data, s), db.JoinModel{
- Model: FinalSupplierJoinOrder{},
- As: "order",
- On: []string{
- fmt.Sprintf("`order`.`supplier_id` = `%s`.`id`", model.TableName()),
- },
- }, db.JoinModel{
- Model: FinalSupplierJoinPrepayment{},
- As: "prepayment",
- On: []string{
- fmt.Sprintf("`prepayment`.`supplierId` = `%s`.`id`", model.TableName()),
- },
- })
- }
- type FinalSupplierTimeoutStatist struct {
- MeasureTimeout float64 `json:"measure_timeout" type:"float" prop:"select:if(isnull(order.id),0,count(if(order.measure_time-order.notice_measure_time>7*24*60*60,1,0)))"`
- StockTimeout float64 `json:"stock_timeout" type:"float" prop:"select:if(isnull(order.id),0,count(if(order.take_time+if(order.is_custom=1,zy_final_supplier.custom_stock_hour,zy_final_supplier.stock_hour)*3600<order.stock_time,1,0)))"`
- ReceiptTimeout float64 `json:"receipt_timeout" type:"float" prop:"select:if(isnull(order.id),0,count(if(order.deliver_time>order.receipt_date,1,0)))"`
- InstallTimeout float64 `json:"install_timeout" type:"float" prop:"select:if(isnull(order.id),0,count(if(order.install_time>order.install_date,1,0)))"`
- TimeoutTotal float64 `json:"timeout_total" type:"float" prop:"select:if(isnull(order.id),0,count(if(order.measure_time-order.notice_measure_time>7*24*60*60,1,0)+if(order.take_time+if(order.is_custom=1,zy_final_supplier.custom_stock_hour,zy_final_supplier.stock_hour)*3600<order.stock_time,1,0)+if(order.deliver_time>order.receipt_date,1,0)+if(order.install_time>order.install_date,1,0)))"`
- FinalSupplier
- }
- func (model FinalSupplierTimeoutStatist) GroupBy() string {
- return fmt.Sprintf("`%s`.`id`", model.TableName())
- }
- func (model FinalSupplierTimeoutStatist) LeftJoin(data map[string]interface{}, s *db.Select) []db.JoinModel {
- return append(model.FinalSupplier.LeftJoin(data, s), db.JoinModel{
- Model: FinalMaterialOrder{},
- As: "order",
- On: []string{
- fmt.Sprintf("`order`.`supplier_id` = `%s`.`id`", model.TableName()),
- },
- })
- }
|