附近小店
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 

140 行
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 StorePayInfo(c *gin.Context) {
  41. svc.StorePayInfo(c)
  42. }
  43. func City(c *gin.Context) {
  44. var arg = make(map[string]string)
  45. c.ShouldBindJSON(&arg)
  46. sql := `select IF(city.name='省直辖县级行政区划' or city.name='市辖区',province.name,city.name) as newname from city
  47. LEFT JOIN province on province.id=city.province_id
  48. where %s
  49. order by CONVERT(newname USING gbk)`
  50. str := "1=1"
  51. if arg["name"] != "" {
  52. str += " and newname like '%" + arg["name"] + "%'"
  53. }
  54. sql = fmt.Sprintf(sql, str)
  55. nativeString, _ := db.QueryNativeString(svc.MasterDb(c), sql)
  56. nodeList := make([]map[string]string, 0)
  57. for _, item := range nativeString {
  58. tmp := map[string]string{
  59. "name": item["newname"],
  60. }
  61. nodeList = append(nodeList, tmp)
  62. }
  63. e.OutSuc(c, nodeList, nil)
  64. return
  65. }
  66. func BankStoreCate(c *gin.Context) {
  67. var res = []map[string]string{
  68. {"name": "全部网点", "value": ""},
  69. {"name": "附近网点", "value": "1"},
  70. {"name": "关注网点", "value": "2"},
  71. }
  72. e.OutSuc(c, res, nil)
  73. return
  74. }
  75. func BankStore(c *gin.Context) {
  76. svc.BankStore(c)
  77. }
  78. func NewStoreCate(c *gin.Context) {
  79. var res = []map[string]string{
  80. {"name": "全部店铺", "value": ""},
  81. {"name": "附近店铺", "value": "1"},
  82. {"name": "关注店铺", "value": "2"},
  83. }
  84. e.OutSuc(c, res, nil)
  85. return
  86. }
  87. func NewStore(c *gin.Context) {
  88. svc.NewStore(c)
  89. }
  90. func Store(c *gin.Context) {
  91. svc.Store(c)
  92. }
  93. func StoreLike(c *gin.Context) {
  94. svc.StoreLike(c)
  95. }
  96. func StoreAddLike(c *gin.Context) {
  97. svc.StoreAddLike(c)
  98. }
  99. func StoreCancelLike(c *gin.Context) {
  100. svc.StoreCancelLike(c)
  101. }
  102. func User(c *gin.Context) {
  103. user, _ := svc.GetDefaultUser(c, c.GetHeader("Authorization"))
  104. res := map[string]string{
  105. "head_img": "",
  106. "nickname": "",
  107. "coupon_str": "优惠券:",
  108. "coupon": "0",
  109. "integral_str": "积分:",
  110. "integral": "0",
  111. }
  112. if user != nil && user.Info.Uid > 0 {
  113. res["head_img"] = user.Profile.AvatarUrl
  114. res["nickname"] = user.Info.Nickname
  115. now := time.Now().Format("2006-01-02 15:04:05")
  116. count, _ := svc.MasterDb(c).Table("act_coupon_user").
  117. Where("store_type=? and uid = ? AND is_use = ? AND (valid_time_start < ? AND valid_time_end > ?)", 0,
  118. user.Info.Uid, 0, now, now).Count(&model.CommunityTeamCouponUser{})
  119. res["coupon"] = utils.Int64ToStr(count)
  120. mod, _ := db.SysModFindBySkipIdentifier(c, svc.MasterDb(c), "pub.flutter.community_team_store_index")
  121. if mod != nil {
  122. integralCoinId := gjson.Get(mod.Data, "integralCoinId").String()
  123. if utils.StrToInt(integralCoinId) > 0 {
  124. coin, _ := db.VirtualCoinGetOneById(svc.MasterDb(c), integralCoinId)
  125. if coin != nil {
  126. amount, _ := db.GetUserVirtualAmountOneEg(svc.MasterDb(c), user.Info.Uid, utils.StrToInt(integralCoinId))
  127. res["integral_str"] = coin.Name + ":"
  128. if amount != nil {
  129. res["integral"] = svc.GetCommissionPrec(c, amount.Amount, svc.SysCfgGet(c, "integral_prec"), "0")
  130. }
  131. }
  132. }
  133. }
  134. }
  135. e.OutSuc(c, res, nil)
  136. return
  137. }