aa
This commit is contained in:
@@ -4037,3 +4037,21 @@ func StoreConfirmAct(ctx *jxcontext.Context, status, msgStatusID int) (err error
|
|||||||
_, err = dao.UpdateEntity(db, msgStatus, "ConfirmStatus")
|
_, err = dao.UpdateEntity(db, msgStatus, "ConfirmStatus")
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetStoreAcctBalance(ctx *jxcontext.Context, storeID int) (storeAcct *model.StoreAcct, err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
)
|
||||||
|
totalIncome, err := dao.GetStoreAcctIncomeTotal(db, storeID, 0, utils.ZeroTimeValue, utils.ZeroTimeValue)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
totalExpend, err := dao.GetStoreAcctExpendTotal(db, storeID, 0, utils.ZeroTimeValue, utils.ZeroTimeValue)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return &model.StoreAcct{
|
||||||
|
StoreID: storeID,
|
||||||
|
AccountBalance: totalIncome - totalExpend,
|
||||||
|
}, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -978,3 +978,113 @@ func GetBrands(db *DaoDB, name string, brandID int) (brands []*model.Brand, err
|
|||||||
err = GetRows(db, &brands, sql, sqlParams)
|
err = GetRows(db, &brands, sql, sqlParams)
|
||||||
return brands, err
|
return brands, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetStoreAcctIncome(db *DaoDB, storeID, incomeType int, fromTime, toTime time.Time) (storeAcctIncomes []*model.StoreAcctIncome, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM store_acct_income
|
||||||
|
WHERE 1 = 1
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{}
|
||||||
|
if storeID != 0 {
|
||||||
|
sql += " AND store_id = ?"
|
||||||
|
sqlParams = append(sqlParams, storeID)
|
||||||
|
}
|
||||||
|
if incomeType != 0 {
|
||||||
|
sql += " AND type = ?"
|
||||||
|
sqlParams = append(sqlParams, incomeType)
|
||||||
|
}
|
||||||
|
if utils.IsTimeZero(fromTime) {
|
||||||
|
sql += " AND created_at >= ?"
|
||||||
|
sqlParams = append(sqlParams, fromTime)
|
||||||
|
}
|
||||||
|
if utils.IsTimeZero(toTime) {
|
||||||
|
sql += " AND created_at <= ?"
|
||||||
|
sqlParams = append(sqlParams, toTime)
|
||||||
|
}
|
||||||
|
err = GetRows(db, &storeAcctIncomes, sql, sqlParams)
|
||||||
|
return storeAcctIncomes, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetStoreAcctIncomeTotal(db *DaoDB, storeID, incomeType int, fromTime, toTime time.Time) (incomeTotal int, err error) {
|
||||||
|
var income *model.StoreAcctIncome
|
||||||
|
sql := `
|
||||||
|
SELECT SUM(income_price) income_price
|
||||||
|
FROM store_acct_income
|
||||||
|
WHERE 1 = 1
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{}
|
||||||
|
if storeID != 0 {
|
||||||
|
sql += " AND store_id = ?"
|
||||||
|
sqlParams = append(sqlParams, storeID)
|
||||||
|
}
|
||||||
|
if incomeType != 0 {
|
||||||
|
sql += " AND type = ?"
|
||||||
|
sqlParams = append(sqlParams, incomeType)
|
||||||
|
}
|
||||||
|
if utils.IsTimeZero(fromTime) {
|
||||||
|
sql += " AND created_at >= ?"
|
||||||
|
sqlParams = append(sqlParams, fromTime)
|
||||||
|
}
|
||||||
|
if utils.IsTimeZero(toTime) {
|
||||||
|
sql += " AND created_at <= ?"
|
||||||
|
sqlParams = append(sqlParams, toTime)
|
||||||
|
}
|
||||||
|
err = GetRow(db, &income, sql, sqlParams)
|
||||||
|
return income.IncomePrice, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetStoreAcctExpend(db *DaoDB, storeID, expendType int, fromTime, toTime time.Time) (storeAcctExpends []*model.StoreAcctExpend, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT *
|
||||||
|
FROM store_acct_expend
|
||||||
|
WHERE 1 = 1
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{}
|
||||||
|
if storeID != 0 {
|
||||||
|
sql += " AND store_id = ?"
|
||||||
|
sqlParams = append(sqlParams, storeID)
|
||||||
|
}
|
||||||
|
if expendType != 0 {
|
||||||
|
sql += " AND type = ?"
|
||||||
|
sqlParams = append(sqlParams, expendType)
|
||||||
|
}
|
||||||
|
if utils.IsTimeZero(fromTime) {
|
||||||
|
sql += " AND created_at >= ?"
|
||||||
|
sqlParams = append(sqlParams, fromTime)
|
||||||
|
}
|
||||||
|
if utils.IsTimeZero(toTime) {
|
||||||
|
sql += " AND created_at <= ?"
|
||||||
|
sqlParams = append(sqlParams, toTime)
|
||||||
|
}
|
||||||
|
err = GetRows(db, &storeAcctExpends, sql, sqlParams)
|
||||||
|
return storeAcctExpends, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetStoreAcctExpendTotal(db *DaoDB, storeID, expendType int, fromTime, toTime time.Time) (expendTotal int, err error) {
|
||||||
|
var expend *model.StoreAcctExpend
|
||||||
|
sql := `
|
||||||
|
SELECT SUM(expend_price) expend_price
|
||||||
|
FROM store_acct_expend
|
||||||
|
WHERE 1 = 1
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{}
|
||||||
|
if storeID != 0 {
|
||||||
|
sql += " AND store_id = ?"
|
||||||
|
sqlParams = append(sqlParams, storeID)
|
||||||
|
}
|
||||||
|
if expendType != 0 {
|
||||||
|
sql += " AND type = ?"
|
||||||
|
sqlParams = append(sqlParams, expendType)
|
||||||
|
}
|
||||||
|
if utils.IsTimeZero(fromTime) {
|
||||||
|
sql += " AND created_at >= ?"
|
||||||
|
sqlParams = append(sqlParams, fromTime)
|
||||||
|
}
|
||||||
|
if utils.IsTimeZero(toTime) {
|
||||||
|
sql += " AND created_at <= ?"
|
||||||
|
sqlParams = append(sqlParams, toTime)
|
||||||
|
}
|
||||||
|
err = GetRow(db, &expend, sql, sqlParams)
|
||||||
|
return expend.ExpendPrice, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -1053,3 +1053,17 @@ func (c *StoreController) StoreConfirmAct() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 查询门店账户余额
|
||||||
|
// @Description 查询门店账户余额
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param storeID formData int true "门店ID"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /GetStoreAcctBalance [get]
|
||||||
|
func (c *StoreController) GetStoreAcctBalance() {
|
||||||
|
c.callGetStoreAcctBalance(func(params *tStoreGetStoreAcctBalanceParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
retVal, err = cms.GetStoreAcctBalance(params.Ctx, params.StoreID)
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -2160,6 +2160,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "GetStoreAcctBalance",
|
||||||
|
Router: `/GetStoreAcctBalance`,
|
||||||
|
AllowHTTPMethods: []string{"get"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetStoreAlertList",
|
Method: "GetStoreAlertList",
|
||||||
|
|||||||
Reference in New Issue
Block a user