附近小店
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

162 linhas
4.7 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 BankStoreNewCate(c *gin.Context) {
  76. second := []map[string]string{
  77. {"type": "km", "value": "500", "name": "附近 500m"},
  78. {"type": "km", "value": "1000", "name": "附近 1km"},
  79. {"type": "km", "value": "2000", "name": "附近 2km"},
  80. {"type": "km", "value": "5000", "name": "附近 5km"},
  81. }
  82. var res = []map[string]interface{}{
  83. {"name": "附近网点", "type": "km", "value": "", "has_second": "1", "second": second},
  84. {"name": "营业中", "type": "work_state", "value": "0", "has_second": "0", "second": []map[string]string{}},
  85. {"name": "新网点", "type": "is_new", "value": "1", "has_second": "0", "second": []map[string]string{}},
  86. {"name": "关注网点", "type": "is_like", "value": "1", "has_second": "0", "second": []map[string]string{}},
  87. }
  88. e.OutSuc(c, res, nil)
  89. return
  90. }
  91. func BankStore(c *gin.Context) {
  92. svc.BankStore(c)
  93. }
  94. func BankActivity(c *gin.Context) {
  95. svc.BankActivity(c)
  96. }
  97. func BankNotice(c *gin.Context) {
  98. svc.BankNotice(c)
  99. }
  100. func NewStoreCate(c *gin.Context) {
  101. var res = []map[string]string{
  102. {"name": "全部店铺", "value": ""},
  103. {"name": "附近店铺", "value": "1"},
  104. {"name": "关注店铺", "value": "2"},
  105. }
  106. e.OutSuc(c, res, nil)
  107. return
  108. }
  109. func NewStore(c *gin.Context) {
  110. svc.NewStore(c)
  111. }
  112. func Store(c *gin.Context) {
  113. svc.Store(c)
  114. }
  115. func StoreLike(c *gin.Context) {
  116. svc.StoreLike(c)
  117. }
  118. func StoreAddLike(c *gin.Context) {
  119. svc.StoreAddLike(c)
  120. }
  121. func StoreCancelLike(c *gin.Context) {
  122. svc.StoreCancelLike(c)
  123. }
  124. func User(c *gin.Context) {
  125. user, _ := svc.GetDefaultUser(c, c.GetHeader("Authorization"))
  126. res := map[string]string{
  127. "head_img": "",
  128. "nickname": "",
  129. "coupon_str": "优惠券:",
  130. "coupon": "0",
  131. "integral_str": "积分:",
  132. "integral": "0",
  133. }
  134. if user != nil && user.Info.Uid > 0 {
  135. res["head_img"] = user.Profile.AvatarUrl
  136. res["nickname"] = user.Info.Nickname
  137. now := time.Now().Format("2006-01-02 15:04:05")
  138. count, _ := svc.MasterDb(c).Table("act_coupon_user").
  139. Where("store_type=? and uid = ? AND is_use = ? AND (valid_time_start < ? AND valid_time_end > ?)", 0,
  140. user.Info.Uid, 0, now, now).Count(&model.CommunityTeamCouponUser{})
  141. res["coupon"] = utils.Int64ToStr(count)
  142. mod, _ := db.SysModFindBySkipIdentifier(c, svc.MasterDb(c), "pub.flutter.community_team_store_index")
  143. if mod != nil {
  144. integralCoinId := gjson.Get(mod.Data, "integralCoinId").String()
  145. if utils.StrToInt(integralCoinId) > 0 {
  146. coin, _ := db.VirtualCoinGetOneById(svc.MasterDb(c), integralCoinId)
  147. if coin != nil {
  148. amount, _ := db.GetUserVirtualAmountOneEg(svc.MasterDb(c), user.Info.Uid, utils.StrToInt(integralCoinId))
  149. res["integral_str"] = coin.Name + ":"
  150. if amount != nil {
  151. res["integral"] = svc.GetCommissionPrec(c, amount.Amount, svc.SysCfgGet(c, "integral_prec"), "0")
  152. }
  153. }
  154. }
  155. }
  156. }
  157. e.OutSuc(c, res, nil)
  158. return
  159. }