附近小店
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

svc_store_amount.go 2.2 KiB

3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
2 months ago
3 months ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  23. if store != nil {
  24. str := "commission"
  25. if store.ParentUid > 0 {
  26. str = "amount-agent_commission"
  27. }
  28. if store.StoreType == 1 {
  29. str = "amount-platform_commission"
  30. }
  31. amount, _ := svc.MasterDb(c).Where("store_uid=? and parent_uid=? and store_type=? and state=1", user.Info.Uid, store.ParentUid, store.StoreType).Sum(&model.CommunityTeamOrder{}, str)
  32. res["wait_amount"] = utils.Float64ToStr(amount)
  33. amountData := db.GetStoreAmountEg(svc.MasterDb(c), user.Info.Uid, store.ParentUid, store.StoreType)
  34. if amountData != nil {
  35. res["amount"] = amountData.Amount
  36. }
  37. }
  38. e.OutSuc(c, res, nil)
  39. return
  40. }
  41. func StoreAmountFlow(c *gin.Context) {
  42. var req map[string]string
  43. if err := c.ShouldBindJSON(&req); err != nil {
  44. e.OutErr(c, e.ERR_INVALID_ARGS, err)
  45. return
  46. }
  47. user := svc.GetUser(c)
  48. req["store_uid"] = utils.IntToStr(user.Info.Uid)
  49. store := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
  50. if store != nil {
  51. req["parent_uid"] = utils.IntToStr(store.ParentUid)
  52. req["store_type"] = utils.IntToStr(store.StoreType)
  53. }
  54. withdraw, total := db.GetStoreAmountFlowList(svc.MasterDb(c), req)
  55. list := make([]map[string]string, 0)
  56. if withdraw != nil {
  57. var stateList = []string{"收入", "支出"}
  58. for _, v := range *withdraw {
  59. tmp := map[string]string{
  60. "amount": v.Amount,
  61. "type_str": stateList[v.Type],
  62. "type": utils.IntToStr(v.Type),
  63. "title": v.Title,
  64. "oid": utils.Int64ToStr(v.Oid),
  65. "after_amount": v.AfterAmount,
  66. "time": v.CreateAt.Format("2006-01-02 15:04:05"),
  67. }
  68. list = append(list, tmp)
  69. }
  70. }
  71. res := map[string]interface{}{
  72. "total": total,
  73. "list": list,
  74. }
  75. e.OutSuc(c, res, nil)
  76. return
  77. }