|
- package svc
-
- import (
- "applet/app/db"
- "applet/app/db/model"
- "applet/app/e"
- "applet/app/svc"
- "applet/app/utils"
- "github.com/gin-gonic/gin"
- )
-
- func StoreAmountBase(c *gin.Context) {
- user := svc.GetUser(c)
- var res = map[string]string{
- "is_bind": "0",
- "amount": "0",
- "wait_amount": "0",
- "alipay_account": user.Profile.AccAlipay,
- "alipay_name": user.Profile.AccAlipayRealName,
- }
- if user.Profile.AccAlipay != "" {
- res["is_bind"] = "1"
- }
- amount, _ := svc.MasterDb(c).Where("store_uid=? and parent_uid>0 and state=1", user.Info.Uid).Sum(&model.CommunityTeamOrder{}, "amount-agent_commission")
- res["wait_amount"] = utils.Float64ToStr(amount)
- store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
- if store != nil {
- amountData := db.GetStoreAmountEg(svc.MasterDb(c), user.Info.Uid, store.ParentUid)
- if amountData != nil {
- res["amount"] = amountData.Amount
- }
- }
- e.OutSuc(c, res, nil)
- return
- }
- func StoreAmountFlow(c *gin.Context) {
- var req map[string]string
- if err := c.ShouldBindJSON(&req); err != nil {
- e.OutErr(c, e.ERR_INVALID_ARGS, err)
- return
- }
- user := svc.GetUser(c)
- req["store_uid"] = utils.IntToStr(user.Info.Uid)
- withdraw, total := db.GetStoreAmountFlowList(svc.MasterDb(c), req)
- list := make([]map[string]string, 0)
- if withdraw != nil {
- var stateList = []string{"收入", "支出"}
- for _, v := range *withdraw {
- tmp := map[string]string{
- "amount": v.Amount,
- "type_str": stateList[v.Type],
- "type": utils.IntToStr(v.Type),
- "title": v.Title,
- "oid": utils.Int64ToStr(v.Oid),
- "after_amount": v.AfterAmount,
- "time": v.CreateAt.Format("2006-01-02 15:04:05"),
- }
- list = append(list, tmp)
- }
- }
- res := map[string]interface{}{
- "total": total,
- "list": list,
- }
- e.OutSuc(c, res, nil)
- return
- }
|