附近小店
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

137 rader
3.8 KiB

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