附近小店
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.
 
 
 

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