You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
43 lines
1.4 KiB
43 lines
1.4 KiB
package order
|
|
|
|
import (
|
|
"base/app/common"
|
|
"base/app/model"
|
|
"git.oa00.com/go/mysql"
|
|
)
|
|
|
|
var DataLogic = &dataLogic{}
|
|
|
|
type dataLogic struct {
|
|
}
|
|
type dataCount struct {
|
|
SaleCount int64 `json:"saleCount"`
|
|
ConsignmentCount int64 `json:"consignmentCount"`
|
|
BusinessConsignmentCount int64 `json:"businessConsignmentCount"`
|
|
//DealerConsignmentCount int64 `json:"dealerConsignmentCount"`
|
|
CallCarCount int64 `json:"callCarCount"`
|
|
}
|
|
|
|
// Count @Title 订单统计
|
|
func (d *dataLogic) Count(brokerId uint) (result dataCount) {
|
|
result = dataCount{
|
|
SaleCount: SaleLogic.Count([]uint{brokerId}),
|
|
ConsignmentCount: ConsignmentLogic.Count([]uint{brokerId}),
|
|
//DealerConsignmentCount: DealerConsignmentLogic.Count(brokerIds),
|
|
CallCarCount: CallCarLogic.Count([]uint{brokerId}),
|
|
}
|
|
|
|
// 入驻商下店长或车务可发布寄售车辆
|
|
brokerStaff := model.BrokerBusinessStoreStaff{BrokerId: brokerId}
|
|
if mysql.Db.Where(&brokerStaff).First(&brokerStaff).Error == nil {
|
|
if common.InArray(brokerStaff.RoleId, model.BrokerAbilityBusinessStaffWorker) {
|
|
var businessBrokerIds []uint
|
|
mysql.Db.Model(&model.BrokerBusinessStoreStaff{}).Where("business_id = ?", brokerStaff.BusinessId).Select("broker_id").Find(&businessBrokerIds)
|
|
if len(businessBrokerIds) > 0 {
|
|
result.BusinessConsignmentCount = ConsignmentLogic.Count(businessBrokerIds)
|
|
}
|
|
}
|
|
}
|
|
return
|
|
}
|