huangjiajun 1 month ago
parent
commit
bc3081629f
5 changed files with 120 additions and 0 deletions
  1. +28
    -0
      app/db/db_card.go
  2. +12
    -0
      app/db/model/community_team_card.go
  3. +18
    -0
      app/hdl/hdl_store.go
  4. +3
    -0
      app/router/router.go
  5. +59
    -0
      app/svc/svc_store.go

+ 28
- 0
app/db/db_card.go View File

@@ -0,0 +1,28 @@
package db

import (
"applet/app/db/model"
"applet/app/utils"
"xorm.io/xorm"
)

func GetCard(eg *xorm.Engine, arg map[string]string) *[]model.CommunityTeamCard {
var data []model.CommunityTeamCard
sess := eg.Where("1=1")
limit := utils.StrToInt(arg["size"])
start := (utils.StrToInt(arg["p"]) - 1) * limit
err := sess.OrderBy("sort desc,id desc").Limit(limit, start).Find(&data)
if err != nil {
return nil
}
return &data
}
func GetCardDetail(eg *xorm.Engine, arg map[string]string) *model.CommunityTeamCard {
var data model.CommunityTeamCard
sess := eg.Where("id=?", arg["id"])
get, err := sess.Get(&data)
if err != nil || get == false {
return nil
}
return &data
}

+ 12
- 0
app/db/model/community_team_card.go View File

@@ -0,0 +1,12 @@
package model

type CommunityTeamCard struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Title string `json:"title" xorm:"VARCHAR(255)"`
Sort int `json:"sort" xorm:"INT(11)"`
IsUse int `json:"is_use" xorm:"default 1 INT(1)"`
Img string `json:"img" xorm:"VARCHAR(255)"`
Content string `json:"content" xorm:"TEXT"`
FirstTip string `json:"first_tip" xorm:"VARCHAR(255)"`
SecondTip string `json:"second_tip" xorm:"VARCHAR(255)"`
}

+ 18
- 0
app/hdl/hdl_store.go View File

@@ -96,9 +96,27 @@ func BankStore(c *gin.Context) {
func BankActivity(c *gin.Context) {
svc.BankActivity(c)
}
func BankCard(c *gin.Context) {
svc.BankCard(c)
}
func BankCardDetail(c *gin.Context) {
svc.BankCardDetail(c)
}
func BankNotice(c *gin.Context) {
svc.BankNotice(c)
}
func BankUserInfo(c *gin.Context) {
user := svc.GetUser(c)
res := map[string]string{
"head_img": user.Profile.AvatarUrl,
"nickname": user.Info.Nickname,
"phone": user.Info.Phone,
"level_name": user.Level.LevelName,
"amount": svc.GetCommissionPrec(c, user.Profile.FinValid, "2", "1"),
}
e.OutSuc(c, res, nil)
return
}
func NewStoreCate(c *gin.Context) {
var res = []map[string]string{
{"name": "全部店铺", "value": ""},


+ 3
- 0
app/router/router.go View File

@@ -150,6 +150,8 @@ func routeCommunityTeam(r *gin.RouterGroup) {
r.POST("/bank/store/list", hdl.BankStore)
r.POST("/bank/store/activity", hdl.BankActivity)
r.POST("/bank/store/notice", hdl.BankNotice)
r.POST("/bank/card", hdl.BankCard)
r.POST("/bank/card/detail", hdl.BankCardDetail)

r.GET("/new/store/cate", hdl.NewStoreCate)
r.POST("/new/store/list", hdl.NewStore)
@@ -162,6 +164,7 @@ func routeCommunityTeam(r *gin.RouterGroup) {
r.GET("/user", hdl.User)
// 用户授权后调用的接口
r.Use(mw.AuthJWT)
r.GET("/bank/user/info", hdl.BankUserInfo)
r.POST("/coupon/receive", hdl.CouponReceive)
r.POST("/store/addLike", hdl.StoreAddLike)
r.POST("/store/cancelLike", hdl.StoreCancelLike)


+ 59
- 0
app/svc/svc_store.go View File

@@ -267,6 +267,65 @@ func BankActivity(c *gin.Context) {
e.OutSuc(c, list, nil)
return
}
func BankCardDetail(c *gin.Context) {
var arg map[string]string
if err := c.ShouldBindJSON(&arg); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
detail := db.GetCardDetail(MasterDb(c), arg)
if detail == nil {
e.OutErr(c, 400, e.NewErr(400, "记录不存在"))
return
}
tmp := map[string]string{
"id": utils.IntToStr(detail.Id),
"title": detail.Title,
"first_tip": detail.FirstTip,
"second_tip": detail.SecondTip,
"time_str": "",
"content": detail.Content,
"type": "0",
}
if tmp["time_str"] != "" {
tmp["type"] = "1"
}
if detail.IsUse == 0 {
tmp["type"] = "2"
}
e.OutSuc(c, tmp, nil)
return
}
func BankCard(c *gin.Context) {
var arg map[string]string
if err := c.ShouldBindJSON(&arg); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
list := make([]map[string]string, 0)
data := db.GetCard(MasterDb(c), arg)
if data != nil {
for _, v := range *data {
tmp := map[string]string{
"id": utils.IntToStr(v.Id),
"title": v.Title,
"first_tip": v.FirstTip,
"second_tip": v.SecondTip,
"time_str": "",
"type": "0",
}
if tmp["time_str"] != "" {
tmp["type"] = "1"
}
if v.IsUse == 0 {
tmp["type"] = "2"
}
list = append(list, tmp)
}
}
e.OutSuc(c, list, nil)
return
}
func NewStore(c *gin.Context) {
var arg map[string]string
if err := c.ShouldBindJSON(&arg); err != nil {


Loading…
Cancel
Save