附近小店
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 

95 wiersze
2.7 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 Store(c *gin.Context) {
  49. svc.Store(c)
  50. }
  51. func StoreAddLike(c *gin.Context) {
  52. svc.StoreAddLike(c)
  53. }
  54. func StoreCancelLike(c *gin.Context) {
  55. svc.StoreCancelLike(c)
  56. }
  57. func User(c *gin.Context) {
  58. user, _ := svc.GetDefaultUser(c, c.GetHeader("Authorization"))
  59. res := map[string]string{
  60. "head_img": "",
  61. "nickname": "",
  62. "coupon_str": "优惠券:",
  63. "coupon": "0",
  64. "integral_str": "积分:",
  65. "integral": "0",
  66. }
  67. if user != nil && user.Info.Uid > 0 {
  68. res["head_img"] = user.Profile.AvatarUrl
  69. res["nickname"] = user.Info.Nickname
  70. now := time.Now().Format("2006-01-02 15:04:05")
  71. count, _ := svc.MasterDb(c).Table("act_coupon_user").
  72. Where("store_type=? and uid = ? AND is_use = ? AND (valid_time_start < ? AND valid_time_end > ?)", 0,
  73. user.Info.Uid, 0, now, now).Count(&model.CommunityTeamCouponUser{})
  74. res["coupon"] = utils.Int64ToStr(count)
  75. mod, _ := db.SysModFindBySkipIdentifier(c, svc.MasterDb(c), "pub.flutter.community_team_store_index")
  76. if mod != nil {
  77. integralCoinId := gjson.Get(mod.Data, "integralCoinId").String()
  78. if utils.StrToInt(integralCoinId) > 0 {
  79. coin, _ := db.VirtualCoinGetOneById(svc.MasterDb(c), integralCoinId)
  80. if coin != nil {
  81. amount, _ := db.GetUserVirtualAmountOneEg(svc.MasterDb(c), user.Info.Uid, utils.StrToInt(integralCoinId))
  82. res["integral_str"] = coin.Name + ":"
  83. if amount != nil {
  84. res["integral"] = svc.GetCommissionPrec(c, amount.Amount, svc.SysCfgGet(c, "integral_prec"), "0")
  85. }
  86. }
  87. }
  88. }
  89. }
  90. e.OutSuc(c, res, nil)
  91. return
  92. }