附近小店
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

68 行
1.8 KiB

  1. package svc
  2. import (
  3. "applet/app/db"
  4. "applet/app/db/model"
  5. "applet/app/e"
  6. "applet/app/svc"
  7. "applet/app/utils"
  8. "github.com/gin-gonic/gin"
  9. )
  10. func StoreAmountBase(c *gin.Context) {
  11. user := svc.GetUser(c)
  12. var res = map[string]string{
  13. "is_bind": "0",
  14. "amount": "0",
  15. "wait_amount": "0",
  16. "alipay_account": user.Profile.AccAlipay,
  17. "alipay_name": user.Profile.AccAlipayRealName,
  18. }
  19. if user.Profile.AccAlipay != "" {
  20. res["is_bind"] = "1"
  21. }
  22. amount, _ := svc.MasterDb(c).Where("store_uid=? and parent_uid>0 and state=1", user.Info.Uid).Sum(&model.CommunityTeamOrder{}, "amount-agent_commission")
  23. res["wait_amount"] = utils.Float64ToStr(amount)
  24. store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  25. if store != nil {
  26. amountData := db.GetStoreAmountEg(svc.MasterDb(c), user.Info.Uid, store.ParentUid)
  27. if amountData != nil {
  28. res["amount"] = amountData.Amount
  29. }
  30. }
  31. e.OutSuc(c, res, nil)
  32. return
  33. }
  34. func StoreAmountFlow(c *gin.Context) {
  35. var req map[string]string
  36. if err := c.ShouldBindJSON(&req); err != nil {
  37. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  38. return
  39. }
  40. user := svc.GetUser(c)
  41. req["store_uid"] = utils.IntToStr(user.Info.Uid)
  42. withdraw, total := db.GetStoreAmountFlowList(svc.MasterDb(c), req)
  43. list := make([]map[string]string, 0)
  44. if withdraw != nil {
  45. var stateList = []string{"收入", "支出"}
  46. for _, v := range *withdraw {
  47. tmp := map[string]string{
  48. "amount": v.Amount,
  49. "type_str": stateList[v.Type],
  50. "type": utils.IntToStr(v.Type),
  51. "title": v.Title,
  52. "oid": utils.Int64ToStr(v.Oid),
  53. "after_amount": v.AfterAmount,
  54. "time": v.CreateAt.Format("2006-01-02 15:04:05"),
  55. }
  56. list = append(list, tmp)
  57. }
  58. }
  59. res := map[string]interface{}{
  60. "total": total,
  61. "list": list,
  62. }
  63. e.OutSuc(c, res, nil)
  64. return
  65. }