a
This commit is contained in:
@@ -1343,3 +1343,29 @@ func GetBrandUser(db *DaoDB, brandID int, userID string) (brandUsers []*model.Br
|
|||||||
err = GetRows(db, &brandUsers, sql, sqlParams)
|
err = GetRows(db, &brandUsers, sql, sqlParams)
|
||||||
return brandUsers, err
|
return brandUsers, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetBrandBalance(db *DaoDB, brandID int) (result int, err error) {
|
||||||
|
var (
|
||||||
|
balance = &struct {
|
||||||
|
Balance int
|
||||||
|
}{}
|
||||||
|
)
|
||||||
|
sql := `
|
||||||
|
SELECT a.balance - b.balance balance
|
||||||
|
FROM (
|
||||||
|
SELECT SUM(price) balance
|
||||||
|
FROM brand_bill
|
||||||
|
WHERE brand_id = ?
|
||||||
|
AND bill_type = ?
|
||||||
|
) a,
|
||||||
|
(
|
||||||
|
SELECT IFNULL(SUM(price), 0) balance
|
||||||
|
FROM brand_bill
|
||||||
|
WHERE brand_id = ?
|
||||||
|
AND bill_type = ?
|
||||||
|
) b
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{brandID, model.BrandBillTypeIncome, brandID, model.BrandBillTypeExpend}
|
||||||
|
err = GetRow(db, &balance, sql, sqlParams)
|
||||||
|
return balance.Balance, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,6 +18,17 @@ const (
|
|||||||
StoreIsSyncYes = 1
|
StoreIsSyncYes = 1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
BrandBillTypeIncome = 1 //收入
|
||||||
|
BrandBillTypeExpend = 2 //支出
|
||||||
|
|
||||||
|
BrandBillFeeTypeSys = 1 //系统划入
|
||||||
|
BrandBillFeeTypeCharge = 2 //人工充值
|
||||||
|
BrandBillFeeTypeSms = 3 //短信费用
|
||||||
|
BrandBillFeeTypeVoice = 4 //语音费用
|
||||||
|
BrandBillFeeTypeDelivery = 5 //三方配送费
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
StoreAuditStatusCreated = 1
|
StoreAuditStatusCreated = 1
|
||||||
StoreAuditStatusOnline = 0
|
StoreAuditStatusOnline = 0
|
||||||
|
|||||||
Reference in New Issue
Block a user