附近小店
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 

110 satır
3.0 KiB

  1. package hdl
  2. import (
  3. "applet/app/db"
  4. "applet/app/db/model"
  5. "applet/app/e"
  6. "applet/app/svc"
  7. "applet/app/utils"
  8. "fmt"
  9. "github.com/gin-gonic/gin"
  10. "github.com/tidwall/gjson"
  11. "time"
  12. )
  13. func City(c *gin.Context) {
  14. var arg = make(map[string]string)
  15. c.ShouldBindJSON(&arg)
  16. sql := `select IF(city.name='省直辖县级行政区划' or city.name='市辖区',province.name,city.name) as newname from city
  17. LEFT JOIN province on province.id=city.province_id
  18. where %s
  19. order by CONVERT(newname USING gbk)`
  20. str := "1=1"
  21. if arg["name"] != "" {
  22. str += " and newname like '%" + arg["name"] + "%'"
  23. }
  24. sql = fmt.Sprintf(sql, str)
  25. nativeString, _ := db.QueryNativeString(svc.MasterDb(c), sql)
  26. nodeList := make([]map[string]string, 0)
  27. for _, item := range nativeString {
  28. tmp := map[string]string{
  29. "name": item["newname"],
  30. }
  31. nodeList = append(nodeList, tmp)
  32. }
  33. e.OutSuc(c, nodeList, nil)
  34. return
  35. }
  36. func BankStoreCate(c *gin.Context) {
  37. var res = []map[string]string{
  38. {"name": "全部网点", "value": ""},
  39. {"name": "附近网点", "value": "1"},
  40. {"name": "关注网点", "value": "2"},
  41. }
  42. e.OutSuc(c, res, nil)
  43. return
  44. }
  45. func BankStore(c *gin.Context) {
  46. svc.BankStore(c)
  47. }
  48. func NewStoreCate(c *gin.Context) {
  49. var res = []map[string]string{
  50. {"name": "全部店铺", "value": ""},
  51. {"name": "附近店铺", "value": "1"},
  52. {"name": "关注店铺", "value": "2"},
  53. }
  54. e.OutSuc(c, res, nil)
  55. return
  56. }
  57. func NewStore(c *gin.Context) {
  58. svc.NewStore(c)
  59. }
  60. func Store(c *gin.Context) {
  61. svc.Store(c)
  62. }
  63. func StoreLike(c *gin.Context) {
  64. svc.StoreLike(c)
  65. }
  66. func StoreAddLike(c *gin.Context) {
  67. svc.StoreAddLike(c)
  68. }
  69. func StoreCancelLike(c *gin.Context) {
  70. svc.StoreCancelLike(c)
  71. }
  72. func User(c *gin.Context) {
  73. user, _ := svc.GetDefaultUser(c, c.GetHeader("Authorization"))
  74. res := map[string]string{
  75. "head_img": "",
  76. "nickname": "",
  77. "coupon_str": "优惠券:",
  78. "coupon": "0",
  79. "integral_str": "积分:",
  80. "integral": "0",
  81. }
  82. if user != nil && user.Info.Uid > 0 {
  83. res["head_img"] = user.Profile.AvatarUrl
  84. res["nickname"] = user.Info.Nickname
  85. now := time.Now().Format("2006-01-02 15:04:05")
  86. count, _ := svc.MasterDb(c).Table("act_coupon_user").
  87. Where("store_type=? and uid = ? AND is_use = ? AND (valid_time_start < ? AND valid_time_end > ?)", 0,
  88. user.Info.Uid, 0, now, now).Count(&model.CommunityTeamCouponUser{})
  89. res["coupon"] = utils.Int64ToStr(count)
  90. mod, _ := db.SysModFindBySkipIdentifier(c, svc.MasterDb(c), "pub.flutter.community_team_store_index")
  91. if mod != nil {
  92. integralCoinId := gjson.Get(mod.Data, "integralCoinId").String()
  93. if utils.StrToInt(integralCoinId) > 0 {
  94. coin, _ := db.VirtualCoinGetOneById(svc.MasterDb(c), integralCoinId)
  95. if coin != nil {
  96. amount, _ := db.GetUserVirtualAmountOneEg(svc.MasterDb(c), user.Info.Uid, utils.StrToInt(integralCoinId))
  97. res["integral_str"] = coin.Name + ":"
  98. if amount != nil {
  99. res["integral"] = svc.GetCommissionPrec(c, amount.Amount, svc.SysCfgGet(c, "integral_prec"), "0")
  100. }
  101. }
  102. }
  103. }
  104. }
  105. e.OutSuc(c, res, nil)
  106. return
  107. }