huangjiajun 2 주 전
부모
커밋
a3bfa46232
10개의 변경된 파일337개의 추가작업 그리고 7개의 파일을 삭제
  1. +28
    -0
      app/db/db_activity.go
  2. +18
    -0
      app/db/db_notice.go
  3. +36
    -6
      app/db/db_store.go
  4. +12
    -0
      app/db/model/community_team_activity.go
  5. +9
    -0
      app/db/model/community_team_activity_cate.go
  6. +1
    -0
      app/db/model/community_team_store.go
  7. +22
    -0
      app/hdl/hdl_store.go
  8. +112
    -0
      app/md/mod.go
  9. +4
    -0
      app/router/router.go
  10. +95
    -1
      app/svc/svc_store.go

+ 28
- 0
app/db/db_activity.go 파일 보기

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

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

func GetActivityCate(eg *xorm.Engine, storeId string) *[]model.CommunityTeamActivityCate {
var data []model.CommunityTeamActivityCate
ids := []string{"0"}
if utils.StrToInt(storeId) > 0 {
ids = append(ids, storeId)
}
err := eg.Where("is_show=1").In("store_id", ids).OrderBy("sort desc,id desc").Find(&data)
if err != nil {
return nil
}
return &data
}
func GetActivity(eg *xorm.Engine, cid []int) *[]model.CommunityTeamActivity {
var data []model.CommunityTeamActivity
err := eg.Where("is_show=1").In("cid", cid).OrderBy("sort desc,id desc").Find(&data)
if err != nil {
return nil
}
return &data
}

+ 18
- 0
app/db/db_notice.go 파일 보기

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

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

func GetBankNotice(eg *xorm.Engine, args map[string]string) *[]model.CommunityTeamStoreNotice {
var data []model.CommunityTeamStoreNotice
size := utils.StrToInt(args["size"])
start := (utils.StrToInt(args["p"]) - 1) * size
err := eg.Where("uid=?", args["uid"]).Limit(size, start).OrderBy("id desc").Find(&data)
if err != nil {
return nil
}
return &data
}

+ 36
- 6
app/db/db_store.go 파일 보기

@@ -19,8 +19,10 @@ func GetUserStore(eg *xorm.Engine, id int) *model.CommunityTeamStore {
func GetStore(eg *xorm.Engine, arg map[string]string) []map[string]string {
lng := utils.StrToFloat64(arg["lng"])
lat := utils.StrToFloat64(arg["lat"])
sel := ` *,sqrt( ( (( %f - lng)*PI()*12656*cos((( %f +lat)/2)*PI()/180)/180) * (( %f - lng)*PI()*12656*cos (((%f+lat)/2)*PI()/180)/180) ) + ( ((%f-lat)*PI()*12656/180) * ((%f-lat)*PI()*12656/180) ) ) AS km`
sel = fmt.Sprintf(sel, lng, lat, lng, lat, lat, lat)
str := "sqrt( ( (( %f - lng)*PI()*12656*cos((( %f +lat)/2)*PI()/180)/180) * (( %f - lng)*PI()*12656*cos (((%f+lat)/2)*PI()/180)/180) ) + ( ((%f-lat)*PI()*12656/180) * ((%f-lat)*PI()*12656/180) ) )"
str = fmt.Sprintf(str, lng, lat, lng, lat, lat, lat)
sel := ` *,%s AS km`
sel = fmt.Sprintf(sel, str)
sql := `select %s from community_team_store where %s %s`
where := "state=1"
if arg["parent_uid"] != "" {
@@ -37,6 +39,20 @@ func GetStore(eg *xorm.Engine, arg map[string]string) []map[string]string {
if arg["store_id"] != "" {
where += " and uid = '" + arg["store_id"] + "'"
}
if arg["work_state"] != "" {
where += " and work_state = '" + arg["work_state"] + "'"
}
if arg["is_new"] != "" {
where += " and is_new = '" + arg["is_new"] + "'"
}

if utils.StrToFloat64(arg["km"]) > 0 {
where += " and " + str + "<=" + utils.Float64ToStr(utils.StrToFloat64(arg["km"])/1000)
} else {
if arg["city_id"] == "" || utils.StrToFloat64(arg["lat"]) == 0 {
where += " and " + str + "<=1000"
}
}
//if arg["city"] != "" {
// where += " and city like '%" + arg["city"] + "%'"
//}
@@ -67,8 +83,10 @@ func GetStore(eg *xorm.Engine, arg map[string]string) []map[string]string {
func GetStoreLike(eg *xorm.Engine, arg map[string]string) []map[string]string {
lng := utils.StrToFloat64(arg["lng"])
lat := utils.StrToFloat64(arg["lat"])
sel := ` cts.*,sqrt( ( (( %f - cts.lng)*PI()*12656*cos((( %f +cts.lat)/2)*PI()/180)/180) * (( %f - cts.lng)*PI()*12656*cos (((%f+cts.lat)/2)*PI()/180)/180) ) + ( ((%f-cts.lat)*PI()*12656/180) * ((%f-cts.lat)*PI()*12656/180) ) ) AS km`
sel = fmt.Sprintf(sel, lng, lat, lng, lat, lat, lat)
str := "sqrt( ( (( %f - lng)*PI()*12656*cos((( %f +lat)/2)*PI()/180)/180) * (( %f - lng)*PI()*12656*cos (((%f+lat)/2)*PI()/180)/180) ) + ( ((%f-lat)*PI()*12656/180) * ((%f-lat)*PI()*12656/180) ) )"
str = fmt.Sprintf(str, lng, lat, lng, lat, lat, lat)
sel := ` cts.*,%s AS km`
sel = fmt.Sprintf(sel, str)
sql := `select %s from community_team_store_like ctsl
left join community_team_store cts on ctsl.store_id=cts.id
where %s %s`
@@ -84,11 +102,23 @@ where %s %s`
where += " and cts.store_type=" + arg["store_type"]
}
}
if utils.StrToFloat64(arg["km"]) > 0 {
where += " and " + str + "<=" + utils.Float64ToStr(utils.StrToFloat64(arg["km"])/1000)
}
if arg["store_id"] != "" {
where += " and cts.uid = '" + arg["store_id"] + "'"
}
if arg["city"] != "" {
where += " and cts.city='" + arg["city"] + "'"
//if arg["city"] != "" {
// where += " and cts.city='" + arg["city"] + "'"
//}
if arg["province_id"] != "" {
where += " and cts.province_id = '" + arg["province_id"] + "'"
}
if arg["city_id"] != "" {
where += " and cts.city_id = '" + arg["city_id"] + "'"
}
if arg["district_id"] != "" {
where += " and cts.district_id = '" + arg["district_id"] + "'"
}
if arg["name"] != "" {
where += " and cts.name like '%" + arg["name"] + "'"


+ 12
- 0
app/db/model/community_team_activity.go 파일 보기

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

type CommunityTeamActivity struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Name string `json:"name" xorm:"Varchar(255)"`
StoreId int `json:"store_id" xorm:"INT(11)"`
Sort int `json:"sort" xorm:"INT(11)"`
Cid int `json:"cid" xorm:"INT(11)"`
IsShow int `json:"is_show" xorm:"default 1 INT(1)"`
Img string `json:"img" xorm:"VARCHAR(255)"`
Skip string `json:"skip" xorm:"TEXT"`
}

+ 9
- 0
app/db/model/community_team_activity_cate.go 파일 보기

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

type CommunityTeamActivityCate struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Name string `json:"name" xorm:"varchar(11)"`
StoreId int `json:"store_id" xorm:"INT(11)"`
Sort int `json:"sort" xorm:"INT(11)"`
IsShow int `json:"is_show" xorm:"default 1 INT(1)"`
}

+ 1
- 0
app/db/model/community_team_store.go 파일 보기

@@ -19,6 +19,7 @@ type CommunityTeamStore struct {
UpdateAt time.Time `json:"update_at" xorm:"DATETIME"`
State int `json:"state" xorm:"default 0 comment('0非店长 1店长') INT(1)"`
WorkState int `json:"work_state" xorm:"default 0 comment('0营业中 1休息中') INT(1)"`
Fan int `json:"fan" xorm:"default 0 comment('') INT(1)"`
Name string `json:"name" xorm:"VARCHAR(255)"`
Province string `json:"province" xorm:"comment('省级的名称') VARCHAR(255)"`
City string `json:"city" xorm:"comment('市级的名称') VARCHAR(255)"`


+ 22
- 0
app/hdl/hdl_store.go 파일 보기

@@ -74,9 +74,31 @@ func BankStoreCate(c *gin.Context) {
e.OutSuc(c, res, nil)
return
}
func BankStoreNewCate(c *gin.Context) {
second := []map[string]string{
{"type": "km", "value": "500", "name": "附近 500m"},
{"type": "km", "value": "1000", "name": "附近 1km"},
{"type": "km", "value": "2000", "name": "附近 2km"},
{"type": "km", "value": "5000", "name": "附近 5km"},
}
var res = []map[string]interface{}{
{"name": "附近网点", "type": "km", "value": "", "has_second": "1", "second": second},
{"name": "营业中", "type": "work_state", "value": "0", "has_second": "0", "second": []map[string]string{}},
{"name": "新网点", "type": "is_new", "value": "1", "has_second": "0", "second": []map[string]string{}},
{"name": "关注网点", "type": "is_like", "value": "1", "has_second": "0", "second": []map[string]string{}},
}
e.OutSuc(c, res, nil)
return
}
func BankStore(c *gin.Context) {
svc.BankStore(c)
}
func BankActivity(c *gin.Context) {
svc.BankActivity(c)
}
func BankNotice(c *gin.Context) {
svc.BankNotice(c)
}
func NewStoreCate(c *gin.Context) {
var res = []map[string]string{
{"name": "全部店铺", "value": ""},


+ 112
- 0
app/md/mod.go 파일 보기

@@ -0,0 +1,112 @@
package md

type Skip struct {
CateTag string `json:"cate_tag"`
Data CommModData `json:"data"`
IsEnd string `json:"is_end"`
IsJump string `json:"is_jump"`
Name string `json:"name"`
RequiredLogin string `json:"required_login"`
RequiredTaobaoAuth string `json:"required_taobao_auth"`
SkipIdentifier string `json:"skip_identifier"`
SkipName string `json:"skip_name"`
URL string `json:"url"`
}
type CommModData struct {
AppKey string `json:"app_key"`
LinkName string `json:"link_name"`
AdvInfo string `json:"adv_info"`
StoreId string `json:"store_id"`
Url string `json:"url"`
AppId string `json:"app_id"`
AlipayUrl string `json:"alipay_url"`
AlipayAppid string `json:"alipay_appid"`
ActivityId string `json:"activity_id"`
Id string `json:"id"`
AdName string `json:"ad_name"`
AndroidAdID string `json:"android_ad_id"`
AndroidMediaID string `json:"android_media_id"`
AutoClickAd string `json:"auto_click_ad"`
Autoplay string `json:"autoplay"`
BrandID string `json:"brand_id"`
Conditions string `json:"conditions"`
CreateAt string `json:"create_at"`
EndTime string `json:"end_time"`
Img string `json:"img"`
IosAdID string `json:"ios_ad_id"`
IosMediaID string `json:"ios_media_id"`
IsRecommend interface{} `json:"is_recommend"`
LevelLimitID string `json:"level_limit_id"`
LevelLimitName string `json:"level_limit_name"`
LevelWeight string `json:"level_weight"`
NeedLocation int64 `json:"need_location"`
SdkType string `json:"sdk_type"`
AdvType string `json:"adv_type"`
Type string `json:"type"`
SourceType string `json:"source_type"`
StartTime string `json:"start_time"`
UpdateAt string `json:"update_at"`
VisitCount string `json:"visit_count"`
IsCanBuy string `json:"is_can_buy"`
IsShowCouponList string `json:"is_show_coupon_list"`
UserCouponAmount string `json:"user_coupon_amount"`
Coupon string `json:"coupon"`
CountingDown string `json:"counting_down" `
FunctionSkipType string `json:"function_skip_type"`
OpenType string `json:"open_type" ` //app 应用内打开 browser 系统浏览器打开
GoodsId string `json:"goods_id"`
GoodsType string `json:"goods_type"`
FromCoinId string `json:"from_coin_id"`
ToCoinId string `json:"to_coin_id"`
LevelType string `json:"level_type"`
TransferType string `json:"transfer_type"`
CoinId string `json:"coin_id"`
ChannelId string `json:"channel_id"`
SecretKey string `json:"secret_key"`
OrderType string `json:"order_type"`
Platform string `json:"platform"`
SecondAdvList AdvCommModData `json:"second_adv_list"`
ThirdAdvList AdvCommModData `json:"third_adv_list"`
HwData map[string]string `json:"hw_data"`
//IsShowConditionPop string `json:"is_show_condition_pop"`
//ShowConditionStr string `json:"show_condition_str"`
//ShowConditionSkip SkipData `json:"show_condition_skip"`
CustomPosterPop CustomPosterPop `json:"custom_poster_pop"`
CustomContentPop CustomContentPop `json:"custom_content_pop"`
}
type CustomContentPop struct {
CloseImg string `json:"close_img"`
CloseImgUrl string `json:"close_img_url"`
TopImg string `json:"top_img"`
TopImgUrl string `json:"top_img_url"`
BgImg string `json:"bg_img"`
BgImgUrl string `json:"bg_img_url"`
TipContentColor string `json:"tip_content_color"`
CopyContent string `json:"copy_content"`
TipContent string `json:"tip_content"`
BtnBgColor string `json:"btn_bg_color"`
BtnContentColor string `json:"btn_content_color"`
BtnContent string `json:"btn_content"`
IsJumpWechat string `json:"is_jump_wechat"`
}

type AdvCommModData struct {
Id string `json:"id"`
AdName string `json:"ad_name"`
AndroidAdID string `json:"android_ad_id"`
AndroidMediaID string `json:"android_media_id"`
AutoClickAd string `json:"auto_click_ad"`
Autoplay string `json:"autoplay"`
IosAdID string `json:"ios_ad_id"`
IosMediaID string `json:"ios_media_id"`
SdkType string `json:"sdk_type"`
AdvType string `json:"adv_type"`
}
type CustomPosterPop struct {
Img string `json:"img"`
ImgUrl string `json:"img_url"`
ShareBtnImg string `json:"share_btn_img"`
ShareBtnImgUrl string `json:"share_btn_img_url"`
SaveBtnImg string `json:"save_btn_img"`
SaveBtnImgUrl string `json:"save_btn_img_url"`
}

+ 4
- 0
app/router/router.go 파일 보기

@@ -146,7 +146,11 @@ func routeCommunityTeam(r *gin.RouterGroup) {
r.POST("/store/pay/info", hdl.StorePayInfo)
r.POST("/city", hdl.City)
r.GET("/bank/store/cate", hdl.BankStoreCate)
r.GET("/bank/store/new/cate", hdl.BankStoreNewCate)
r.POST("/bank/store/list", hdl.BankStore)
r.POST("/bank/store/activity", hdl.BankActivity)
r.POST("/bank/store/notice", hdl.BankNotice)

r.GET("/new/store/cate", hdl.NewStoreCate)
r.POST("/new/store/list", hdl.NewStore)
r.POST("/store", hdl.Store)


+ 95
- 1
app/svc/svc_store.go 파일 보기

@@ -4,7 +4,9 @@ import (
"applet/app/db"
"applet/app/db/model"
"applet/app/e"
"applet/app/md"
"applet/app/utils"
"encoding/json"
"github.com/gin-gonic/gin"
"time"
)
@@ -140,7 +142,7 @@ func BankStore(c *gin.Context) {
arg["store_type"] = "0"
user, _ := GetDefaultUser(c, c.GetHeader("Authorization"))
var store = make([]map[string]string, 0)
if arg["cid"] == "2" {
if arg["cid"] == "2" || arg["is_like"] == "1" {
store = db.GetStoreLike(MasterDb(c), arg)
} else {
store = db.GetStore(MasterDb(c), arg)
@@ -157,6 +159,14 @@ func BankStore(c *gin.Context) {
if utils.StrToFloat64(km) <= 0 || utils.StrToFloat64(v["lat"]) == 0 || utils.StrToFloat64(v["lng"]) == 0 {
v["km"] = "-"
}
label := make([]string, 0)
if v["is_new"] == "1" {
label = append(label, "新门店")
}
isWork := "1"
if v["work_state"] == "1" {
isWork = "0"
}
tmp := map[string]interface{}{
"lat": v["lat"],
"lng": v["lng"],
@@ -168,8 +178,13 @@ func BankStore(c *gin.Context) {
"uid": v["uid"],
"phone": v["phone"],
"logo": v["logo"],
"is_work": isWork,
"is_like": "0",
"fan": "",
"label": label,
}
if utils.StrToInt(v["fan"]) > 0 {
tmp["fan"] = v["fan"]
}
if user != nil {
count, _ := MasterDb(c).Where("uid=? and store_id=?", user.Info.Uid, v["id"]).Count(&model.CommunityTeamStoreLike{})
@@ -182,6 +197,76 @@ func BankStore(c *gin.Context) {
e.OutSuc(c, storeList, nil)
return
}
func BankNotice(c *gin.Context) {
var arg map[string]string
if err := c.ShouldBindJSON(&arg); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
data := db.GetBankNotice(MasterDb(c), arg)
list := make([]map[string]string, 0)
if data != nil {
for _, v := range *data {
tmp := map[string]string{
"id": utils.IntToStr(v.Id),
"title": v.Title,
"content": v.Content,
"create_time": v.CreateTime.Format("2006-01-02 15:04"),
}
list = append(list, tmp)
}
}
e.OutSuc(c, list, nil)
return
}
func BankActivity(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]interface{}, 0)
cate := db.GetActivityCate(MasterDb(c), arg["uid"])
if cate != nil {
ids := make([]int, 0)
for _, v := range *cate {
ids = append(ids, v.Id)
}
activityMap := make(map[int][]map[string]interface{})
if len(ids) > 0 {
activity := db.GetActivity(MasterDb(c), ids)
if activity != nil {
scheme, host := ImageBucket(c)
for _, v := range *activity {
_, ok := activityMap[v.Cid]
if ok == false {
activityMap[v.Cid] = make([]map[string]interface{}, 0)
}
var skip md.Skip
json.Unmarshal(utils.MarshalJSONCamelCase2JsonSnakeCase(v.Skip), &skip)
tmp := map[string]interface{}{
"name": v.Name, "img": ImageFormatWithBucket(scheme, host, v.Img), "skip": skip,
}
activityMap[v.Cid] = append(activityMap[v.Cid], tmp)
}
}
}
for _, v := range *cate {
tmpList := make([]map[string]interface{}, 0)
_, ok := activityMap[v.Id]
if ok {
tmpList = activityMap[v.Id]
}
tmp := map[string]interface{}{
"name": v.Name,
"list": tmpList,
}
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 {
@@ -367,6 +452,9 @@ func StoreAddLike(c *gin.Context) {
Time: time.Now(),
}
MasterDb(c).Insert(&data)
store := db.GetStoreIdEg(MasterDb(c), arg["id"])
store.Fan++
MasterDb(c).Where("id=?", store.Id).Cols("fan").Update(store)
e.OutSuc(c, "success", nil)
return
}
@@ -379,6 +467,12 @@ func StoreCancelLike(c *gin.Context) {
}
user := GetUser(c)
MasterDb(c).Where("uid=? and store_id=?", user.Info.Uid, arg["id"]).Delete(&model.CommunityTeamStoreLike{})
store := db.GetStoreIdEg(MasterDb(c), arg["id"])
store.Fan--
if store.Fan < 0 {
store.Fan = 0
}
MasterDb(c).Where("id=?", store.Id).Cols("fan").Update(store)
e.OutSuc(c, "success", nil)
return
}

불러오는 중...
취소
저장