huangjiajun 3 months ago
parent
commit
b698791a67
2 changed files with 24 additions and 21 deletions
  1. +10
    -10
      app/agent/svc/svc_store.go
  2. +14
    -11
      app/db/db_store_withdraw.go

+ 10
- 10
app/agent/svc/svc_store.go View File

@@ -8,6 +8,7 @@ import (
"applet/app/utils"
"github.com/gin-gonic/gin"
"strings"
"time"
)

func StoreWithdrawFlow(c *gin.Context) {
@@ -68,9 +69,10 @@ func StoreWithdrawTotal(c *gin.Context) {
var allAmount float64 = 0
var waitAmount float64 = 0
var failAmount float64 = 0
allAmount, _ = svc.MasterDb(c).Where("parent_uid=?", user.Info.Uid).And("state=?", 1).Sum(&model.CommunityTeamStoreWithdrawApply{}, "amount")
waitAmount, _ = svc.MasterDb(c).Where("parent_uid=?", user.Info.Uid).And("state=?", 0).Sum(&model.CommunityTeamStoreWithdrawApply{}, "amount")
failAmount, _ = svc.MasterDb(c).Where("parent_uid=?", user.Info.Uid).And("state=?", 3).Sum(&model.CommunityTeamStoreWithdrawApply{}, "amount")
req["agent_uid"] = utils.IntToStr(user.Info.Uid)
allAmount, _ = db.CommWhere(svc.MasterDb(c), req).And("state=?", 1).Sum(&model.CommunityTeamStoreWithdrawApply{}, "amount")
waitAmount, _ = db.CommWhere(svc.MasterDb(c), req).And("state=?", 0).Sum(&model.CommunityTeamStoreWithdrawApply{}, "amount")
failAmount, _ = db.CommWhere(svc.MasterDb(c), req).And("state=?", 3).Sum(&model.CommunityTeamStoreWithdrawApply{}, "amount")
res := []map[string]string{
{"name": "累计提现金额(元):" + utils.Float64ToStr(allAmount), "tip": "统计提现成功的金额"},
{"name": "审核中金额(元):" + utils.Float64ToStr(waitAmount), "tip": "统计正在审核中的金额"},
@@ -109,7 +111,10 @@ func StoreWithdrawAudit(c *gin.Context) {
}
data.State = utils.StrToInt(req["state"])
data.Memo = req["memo"]
update, err := sess.Where("id=?", data.Id).Cols("state,memo").Update(data)
if data.State == 1 {
data.PaymentDate = time.Now().Format("2006-01-02 15:04:05")
}
update, err := sess.Where("id=?", data.Id).Cols("state,payment_date,memo").Update(data)
if update == 0 || err != nil {
sess.Rollback()
e.OutErr(c, 400, e.NewErr(400, "审核失败"))
@@ -125,12 +130,7 @@ func StoreWithdrawAuditAll(c *gin.Context) {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
count, _ := svc.MasterDb(c).In("id", strings.Split(req["ids"], ",")).And("state>0").Count(&model.CommunityTeamStoreWithdrawApply{})
if count > 0 {
e.OutErr(c, 400, e.NewErr(400, "存在已处理的记录"))
return
}
svc.MasterDb(c).In("id", strings.Split(req["ids"], ",")).Cols("state").Update(&model.CommunityTeamStoreWithdrawApply{State: 1})
svc.MasterDb(c).In("id", strings.Split(req["ids"], ",")).And("state=0").Cols("state,payment_date").Update(&model.CommunityTeamStoreWithdrawApply{State: 1, PaymentDate: time.Now().Format("2006-01-02 15:04:05")})
e.OutSuc(c, "success", nil)
return
}


+ 14
- 11
app/db/db_store_withdraw.go View File

@@ -9,6 +9,19 @@ import (

func GetStoreWithdraw(eg *xorm.Engine, arg map[string]string) (*[]model.CommunityTeamStoreWithdrawApply, int64) {
var data []model.CommunityTeamStoreWithdrawApply
sess := CommWhere(eg, arg)
limit := utils.StrToInt(arg["size"])
start := (utils.StrToInt(arg["p"]) - 1) * limit
if limit > 0 {
sess.Limit(limit, start)
}
count, err := sess.Desc("id").FindAndCount(&data)
if err != nil {
return nil, count
}
return &data, count
}
func CommWhere(eg *xorm.Engine, arg map[string]string) *xorm.Session {
sess := eg.Where("1=1")
if arg["store_uid"] != "" {
sess.And("uid=?", arg["store_uid"])
@@ -49,18 +62,8 @@ func GetStoreWithdraw(eg *xorm.Engine, arg map[string]string) (*[]model.Communit
if arg["payment_end_time"] != "" {
sess.And("payment_date<=?", arg["payment_end_time"])
}
limit := utils.StrToInt(arg["size"])
start := (utils.StrToInt(arg["p"]) - 1) * limit
if limit > 0 {
sess.Limit(limit, start)
}
count, err := sess.Desc("id").FindAndCount(&data)
if err != nil {
return nil, count
}
return &data, count
return sess
}

func GetStoreWithdrawById(sess *xorm.Session, id string) *model.CommunityTeamStoreWithdrawApply {
var data model.CommunityTeamStoreWithdrawApply
get, err := sess.Where("id=?", id).Get(&data)


Loading…
Cancel
Save