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

180 lines
5.2 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 BankCard(c *gin.Context) {
  98. svc.BankCard(c)
  99. }
  100. func BankCardDetail(c *gin.Context) {
  101. svc.BankCardDetail(c)
  102. }
  103. func BankNotice(c *gin.Context) {
  104. svc.BankNotice(c)
  105. }
  106. func BankUserInfo(c *gin.Context) {
  107. user := svc.GetUser(c)
  108. res := map[string]string{
  109. "head_img": user.Profile.AvatarUrl,
  110. "nickname": user.Info.Nickname,
  111. "phone": user.Info.Phone,
  112. "level_name": user.Level.LevelName,
  113. "amount": svc.GetCommissionPrec(c, user.Profile.FinValid, "2", "1"),
  114. }
  115. e.OutSuc(c, res, nil)
  116. return
  117. }
  118. func NewStoreCate(c *gin.Context) {
  119. var res = []map[string]string{
  120. {"name": "全部店铺", "value": ""},
  121. {"name": "附近店铺", "value": "1"},
  122. {"name": "关注店铺", "value": "2"},
  123. }
  124. e.OutSuc(c, res, nil)
  125. return
  126. }
  127. func NewStore(c *gin.Context) {
  128. svc.NewStore(c)
  129. }
  130. func Store(c *gin.Context) {
  131. svc.Store(c)
  132. }
  133. func StoreLike(c *gin.Context) {
  134. svc.StoreLike(c)
  135. }
  136. func StoreAddLike(c *gin.Context) {
  137. svc.StoreAddLike(c)
  138. }
  139. func StoreCancelLike(c *gin.Context) {
  140. svc.StoreCancelLike(c)
  141. }
  142. func User(c *gin.Context) {
  143. user, _ := svc.GetDefaultUser(c, c.GetHeader("Authorization"))
  144. res := map[string]string{
  145. "head_img": "",
  146. "nickname": "",
  147. "coupon_str": "优惠券:",
  148. "coupon": "0",
  149. "integral_str": "积分:",
  150. "integral": "0",
  151. }
  152. if user != nil && user.Info.Uid > 0 {
  153. res["head_img"] = user.Profile.AvatarUrl
  154. res["nickname"] = user.Info.Nickname
  155. now := time.Now().Format("2006-01-02 15:04:05")
  156. count, _ := svc.MasterDb(c).Table("act_coupon_user").
  157. Where("store_type=? and uid = ? AND is_use = ? AND (valid_time_start < ? AND valid_time_end > ?)", 0,
  158. user.Info.Uid, 0, now, now).Count(&model.CommunityTeamCouponUser{})
  159. res["coupon"] = utils.Int64ToStr(count)
  160. mod, _ := db.SysModFindBySkipIdentifier(c, svc.MasterDb(c), "pub.flutter.community_team_store_index")
  161. if mod != nil {
  162. integralCoinId := gjson.Get(mod.Data, "integralCoinId").String()
  163. if utils.StrToInt(integralCoinId) > 0 {
  164. coin, _ := db.VirtualCoinGetOneById(svc.MasterDb(c), integralCoinId)
  165. if coin != nil {
  166. amount, _ := db.GetUserVirtualAmountOneEg(svc.MasterDb(c), user.Info.Uid, utils.StrToInt(integralCoinId))
  167. res["integral_str"] = coin.Name + ":"
  168. if amount != nil {
  169. res["integral"] = svc.GetCommissionPrec(c, amount.Amount, svc.SysCfgGet(c, "integral_prec"), "0")
  170. }
  171. }
  172. }
  173. }
  174. }
  175. e.OutSuc(c, res, nil)
  176. return
  177. }