This commit is contained in:
suyl
2021-08-31 09:24:51 +08:00
parent 6e5ee2c25a
commit 03e255519f
2 changed files with 37 additions and 0 deletions

View File

@@ -1343,3 +1343,29 @@ func GetBrandUser(db *DaoDB, brandID int, userID string) (brandUsers []*model.Br
err = GetRows(db, &brandUsers, sql, sqlParams)
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
}

View File

@@ -18,6 +18,17 @@ const (
StoreIsSyncYes = 1
)
const (
BrandBillTypeIncome = 1 //收入
BrandBillTypeExpend = 2 //支出
BrandBillFeeTypeSys = 1 //系统划入
BrandBillFeeTypeCharge = 2 //人工充值
BrandBillFeeTypeSms = 3 //短信费用
BrandBillFeeTypeVoice = 4 //语音费用
BrandBillFeeTypeDelivery = 5 //三方配送费
)
const (
StoreAuditStatusCreated = 1
StoreAuditStatusOnline = 0