huangjiajun 1 개월 전
부모
커밋
d9e84c52df
12개의 변경된 파일380개의 추가작업 그리고 1개의 파일을 삭제
  1. +41
    -0
      app/db/db_store_pay_qrcode.go
  2. +27
    -0
      app/db/db_store_qrcode.go
  3. +9
    -0
      app/db/model/community_team_store_pay_qrcode.go
  4. +10
    -0
      app/db/model/community_team_store_qrcode.go
  5. +27
    -0
      app/hdl/hdl_store.go
  6. +13
    -0
      app/md/md_store.go
  7. +6
    -0
      app/mw/mw_db.go
  8. +8
    -0
      app/router/router.go
  9. +22
    -0
      app/store/hdl/hdl_qrcode.go
  10. +1
    -1
      app/store/hdl/hdl_user.go
  11. +120
    -0
      app/store/svc/svc_qrcode.go
  12. +96
    -0
      app/svc/svc_store.go

+ 41
- 0
app/db/db_store_pay_qrcode.go 파일 보기

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

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

func GetStorePayQrcode(eg *xorm.Engine, args map[string]string) (*[]model.CommunityTeamStorePayQrcode, int64) {
var data []model.CommunityTeamStorePayQrcode
sess := eg.Where("uid=?", args["uid"])
size := utils.StrToInt(args["size"])
start := (utils.StrToInt(args["p"]) - 1) * size
total, err := sess.Limit(size, start).Desc("id").FindAndCount(&data)
if err != nil {
return nil, total
}
return &data, total
}
func GetStorePayQrcodeById(eg *xorm.Engine, id string) *model.CommunityTeamStorePayQrcode {
var data model.CommunityTeamStorePayQrcode
get, err := eg.Where("id=?", id).Get(&data)
if get == false || err != nil {
return nil
}
return &data
}
func GetStorePayQrcodeByUId(eg *xorm.Engine, uid int) {
var data model.CommunityTeamStorePayQrcode
get, _ := eg.Where("uid=? ", uid).Get(&data)
if get == false {
data = model.CommunityTeamStorePayQrcode{
Id: 0,
Uid: uid,
Type: 0,
IsUse: 1,
Name: "默认",
}
}
return
}

+ 27
- 0
app/db/db_store_qrcode.go 파일 보기

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

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

func GetStoreQrcode(eg *xorm.Engine, args map[string]string) (*[]model.CommunityTeamStoreQrcode, int64) {
var data []model.CommunityTeamStoreQrcode
sess := eg.Where("uid=?", args["uid"])
size := utils.StrToInt(args["size"])
start := (utils.StrToInt(args["p"]) - 1) * size
total, err := sess.Limit(size, start).Desc("id").FindAndCount(&data)
if err != nil {
return nil, total
}
return &data, total
}
func GetStoreQrcodeById(eg *xorm.Engine, id string) *model.CommunityTeamStoreQrcode {
var data model.CommunityTeamStoreQrcode
get, err := eg.Where("id=?", id).Get(&data)
if get == false || err != nil {
return nil
}
return &data
}

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

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

type CommunityTeamStorePayQrcode struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
Type int `json:"type" xorm:"default 0 INT(11)"`
IsUse int `json:"is_use" xorm:"default 0 INT(11)"`
Name string `json:"name" xorm:"VARCHAR(255)"`
}

+ 10
- 0
app/db/model/community_team_store_qrcode.go 파일 보기

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

type CommunityTeamStoreQrcode struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
TableNum int `json:"table_num" xorm:"default 0 INT(11)"`
Type int `json:"type" xorm:"default 0 INT(11)"`
IsUse int `json:"is_use" xorm:"default 0 INT(11)"`
Name string `json:"name" xorm:"VARCHAR(255)"`
}

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

@@ -4,6 +4,7 @@ import (
"applet/app/db"
"applet/app/db/model"
"applet/app/e"
"applet/app/md"
"applet/app/svc"
"applet/app/utils"
"fmt"
@@ -12,6 +13,32 @@ import (
"time"
)

func StyleStoreScan(c *gin.Context) {
Db := svc.MasterDb(c)
skipIdentifier := "pub.flutter.community_team_store_scan_ord"
moduleCfg, err := db.SysModFindBySkipIdentifier(c, Db, skipIdentifier)
if err != nil {
e.OutErr(c, e.ERR_FILE_SAVE, nil)
return
}
var O2OScanOrdModule md.ModuleByO2oCByScanOrdData
if moduleCfg != nil {
bytes := utils.MarshalJSONCamelCase2JsonSnakeCase(moduleCfg.Data)
utils.Unserialize(bytes, &O2OScanOrdModule)
e.OutSuc(c, &O2OScanOrdModule, nil)
return
}
setting := md.InitO2OScanOrdModule
utils.Unserialize([]byte(setting), &O2OScanOrdModule)
e.OutSuc(c, &O2OScanOrdModule, nil)
return
}
func StoreScan(c *gin.Context) {
svc.StoreScan(c)
}
func StorePayScan(c *gin.Context) {
svc.StorePayScan(c)
}
func City(c *gin.Context) {
var arg = make(map[string]string)
c.ShouldBindJSON(&arg)


+ 13
- 0
app/md/md_store.go 파일 보기

@@ -4,6 +4,10 @@ import (
"applet/app/db/model"
)

const (
InitO2OScanOrdModule = "{\"bg_img\":\"http://ossn.izhim.net/%E4%B8%AA%E6%80%A7%E5%8C%96%2F%E4%B8%AD%E9%97%B4%E9%A1%B5%E8%83%8C%E6%99%AF%E5%9B%BE-484448.png\",\"bg_img_url\":\"http://ossn.izhim.net/个性化/中间页背景图-484448.png\",\"logo\":\"\",\"logo_url\":\"\",\"down_btn_bg_color\":\"#FFFFF\",\"down_btn_font_color\":\"#333333\",\"down_btn_font\":\"进入小程序点餐/付款\"}"
)

type Store struct {
P string `json:"p"`
Size string `json:"size"`
@@ -64,3 +68,12 @@ type CommunityTeamStore struct {
CityId string `json:"city_id" xorm:"comment('市级的名称') INT(11)"`
DistrictId string `json:"district_id" xorm:"comment('县,区名称') INT(11)"`
}
type ModuleByO2oCByScanOrdData struct {
BgImg string `json:"bg_img"`
BgImgUrl string `json:"bg_img_url"`
Logo string `json:"logo"`
LogoUrl string `json:"logo_url"`
DownBtnBgColor string `json:"down_btn_bg_color"`
DownBtnFontColor string `json:"down_btn_font_color"`
DownBtnFont string `json:"down_btn_font"`
}

+ 6
- 0
app/mw/mw_db.go 파일 보기

@@ -18,6 +18,12 @@ import (
func DB(c *gin.Context) {
fmt.Println(c.Request.Header)
masterID := mw.GetMasterId(db.Db, c)
if masterID == "" {
masterID = svc.GetWebSiteDomainMasterId("userStoreAgent", c.Request.Host)
}
if masterID == "" {
masterID = svc.GetWebSiteDomainMasterId("userStoreStore", c.Request.Host)
}
_, ok := db.DBs[masterID]
if !ok {
e.OutErr(c, e.ERR_MASTER_ID, errors.New("not found master_id in DBs"))


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

@@ -118,6 +118,11 @@ func routeCommunityTeamOwnStore(r *gin.RouterGroup) {
r.POST("/goods/save", storeHdl.GoodsSave)
r.POST("/goods/detail", storeHdl.GoodsDetail)
r.POST("/goods/del", storeHdl.GoodsDel)
r.GET("/qrcode/base", storeHdl.QrcodeBase)
r.GET("/qrcode/pay/style", storeHdl.QrcodePayStyle)
r.POST("/qrcode/list", storeHdl.Qrcode)
r.POST("/qrcode/save", storeHdl.QrcodeSave)
r.POST("/qrcode/del", storeHdl.QrcodeDel)
r.POST("/goods/cate/list", storeHdl.GoodsCate)
r.POST("/goods/cate/save", storeHdl.GoodsCateSave)
r.POST("/goods/cate/show", storeHdl.GoodsCateShow)
@@ -131,6 +136,9 @@ func routeCommunityTeam(r *gin.RouterGroup) {
r.Use(mw.CheckBody) //body参数转换
r.Use(mw.CheckSign) //签名校验
r.Use(mw.Checker)
r.GET("/style/store/scan", hdl.StyleStoreScan)
r.POST("/store/scan", hdl.StoreScan)
r.POST("/store/pay/scan", hdl.StorePayScan)
r.POST("/city", hdl.City)
r.GET("/bank/store/cate", hdl.BankStoreCate)
r.POST("/bank/store/list", hdl.BankStore)


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

@@ -0,0 +1,22 @@
package hdl

import (
"applet/app/store/svc"
"github.com/gin-gonic/gin"
)

func QrcodePayStyle(c *gin.Context) {
svc.QrcodePayStyle(c)
}
func QrcodeBase(c *gin.Context) {
svc.QrcodeBase(c)
}
func Qrcode(c *gin.Context) {
svc.Qrcode(c)
}
func QrcodeSave(c *gin.Context) {
svc.QrcodeSave(c)
}
func QrcodeDel(c *gin.Context) {
svc.QrcodeDel(c)
}

+ 1
- 1
app/store/hdl/hdl_user.go 파일 보기

@@ -40,7 +40,6 @@ func User(c *gin.Context) {
res["info"] = storeCheck.Info
}
}

userParty := db.GetStoreIdEg(svc.MasterDb(c), utils.IntToStr(user.Info.Uid))
if userParty != nil {
if userParty.State == 1 {
@@ -50,6 +49,7 @@ func User(c *gin.Context) {
}
res["store_type"] = utils.IntToStr(userParty.StoreType)
}
db.GetStorePayQrcodeByUId(svc.MasterDb(c), user.Info.Uid)
e.OutSuc(c, res, nil)
return
}


+ 120
- 0
app/store/svc/svc_qrcode.go 파일 보기

@@ -0,0 +1,120 @@
package svc

import (
"applet/app/db"
"applet/app/db/model"
"applet/app/e"
"applet/app/svc"
"applet/app/utils"
"applet/app/utils/qrcode"
"encoding/json"
"fmt"
"github.com/gin-gonic/gin"
"strings"
)

func QrcodePayStyle(c *gin.Context) {
eg := svc.MasterDb(c)
user := svc.GetUser(c)
m, _ := SysModDataBySkipIdentifier(c, "pub.flutter.o2o_store_qrcode_style")
bytes := utils.MarshalJSONCamelCase2JsonSnakeCase(m.Data)
m.Data = string(bytes)
fmt.Println(m.Data)
store := db.GetStoreIdEg(eg, utils.IntToStr(user.Info.Uid))
if store != nil {
m.Data = strings.ReplaceAll(m.Data, "{店铺名}", store.Name)
m.Data = strings.ReplaceAll(m.Data, "{店铺编号}", utils.IntToStr(store.Uid))
}
var res = make(map[string]interface{})
json.Unmarshal([]byte(m.Data), &res)
e.OutSuc(c, res, nil)
return
}

// 获取mod data by SkipIdentifier
func SysModDataBySkipIdentifier(c *gin.Context, name string) (*model.SysModule, error) {
mod, err := db.SysModFindBySkipIdentifier(c, db.DBs[c.GetString("mid")], name)
if err != nil {
return nil, err
}
return mod, nil
}
func QrcodeBase(c *gin.Context) {
h5Domain := svc.GetWebSiteDomainInfo(c, "wap")
content := h5Domain + "/#/zy-landing-page/pages/o2o-scan/o2o-scan?qrcode_id=1"
res := map[string]string{
"pay_url": content,
"pay_qrcode": strings.ReplaceAll(qrcode.GetPNGBase64(content), "\u0000", ""),
}
e.OutSuc(c, res, nil)
return
}
func Qrcode(c *gin.Context) {
var arg map[string]string
if err := c.ShouldBindJSON(&arg); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
user := svc.GetUser(c)
arg["uid"] = utils.IntToStr(user.Info.Uid)
arg["store_type"] = "1"
cate, total := db.GetStoreQrcode(svc.MasterDb(c), arg)
list := make([]map[string]string, 0)
if cate != nil {
h5Domain := svc.GetWebSiteDomainInfo(c, "wap")
for _, v := range *cate {
tmp := map[string]string{
"id": utils.IntToStr(v.Id),
"table_num": utils.IntToStr(v.TableNum),
"name": v.Name,
"is_use": utils.IntToStr(v.IsUse),
"qrcode": "",
"url": "",
}
content := h5Domain + "/#/zy-landing-page/pages/o2o-scan/o2o-scan?qrcode_id=" + utils.AnyToString(v.Id)
tmp["qrcode"] = strings.ReplaceAll(qrcode.GetPNGBase64(content), "\u0000", "")
tmp["url"] = content
list = append(list, tmp)
}
}
res := map[string]interface{}{
"list": list, "total": total,
}
e.OutSuc(c, res, nil)
return
}
func QrcodeSave(c *gin.Context) {
var arg map[string]string
if err := c.ShouldBindJSON(&arg); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
user := svc.GetUser(c)
if arg["id"] != "" {
data := db.GetStoreQrcodeById(svc.MasterDb(c), arg["id"])
data.TableNum = utils.StrToInt(arg["table_num"])
data.Name = arg["name"]
data.IsUse = utils.StrToInt(arg["is_use"])
svc.MasterDb(c).Where("id=?", data.Id).Update(data)
} else {
data := &model.CommunityTeamStoreQrcode{
Uid: user.Info.Uid,
TableNum: utils.StrToInt(arg["table_num"]),
IsUse: utils.StrToInt(arg["is_use"]),
Name: arg["name"],
}
svc.MasterDb(c).Insert(data)
}
e.OutSuc(c, "success", nil)
return
}
func QrcodeDel(c *gin.Context) {
var arg map[string]string
if err := c.ShouldBindJSON(&arg); err != nil {
e.OutErr(c, e.ERR_INVALID_ARGS, err)
return
}
svc.MasterDb(c).In("id", strings.Split(arg["ids"], ",")).Delete(&model.CommunityTeamStoreQrcode{})
e.OutSuc(c, "success", nil)
return
}

+ 96
- 0
app/svc/svc_store.go 파일 보기

@@ -9,6 +9,102 @@ import (
"time"
)

func StorePayScan(c *gin.Context) {
kind := c.DefaultQuery("type", "alipay") //1:支付宝 2:微信
id, _ := c.GetQuery("id")
if id == "" {
e.OutErr(c, e.ERR_INVALID_ARGS, nil)
return
}
engine := MasterDb(c)
data := db.GetStorePayQrcodeById(engine, id)
if data == nil {
e.OutErr(c, 400, e.NewErr(400, "桌码不存在"))
return
}
if data.IsUse != 1 {
e.OutErr(c, 400, e.NewErr(400, "桌码不可用"))
return
}
type RefundReq struct {
StoreId string `json:"store_id" `
StoreType string `json:"store_type" `
AppId string `json:"app_id" `
InviteCode string `json:"invite_code"`
}
store := db.GetStoreIdEg(engine, utils.IntToStr(data.Uid))
if store == nil {
e.OutErr(c, 400, e.NewErr(400, "门店不存在"))
return
}
user, _ := db.UserProfileFindByID(engine, store.Uid)
var appId = ""
var inviteCode = user.InviteCode
if kind != "alipay" {
communityTeamStoreWxAppletId := db.SysCfgGet(c, "community_team_store_wx_applet_id")
var wxApplet model.WxAppletList
MasterDb(c).Where("id=?", communityTeamStoreWxAppletId).Get(&wxApplet)
appId = wxApplet.OriginalAppId
}

var result = RefundReq{
StoreId: utils.IntToStr(data.Uid),
AppId: appId,
StoreType: utils.IntToStr(store.StoreType),
InviteCode: inviteCode,
}
e.OutSuc(c, result, nil)
return
}
func StoreScan(c *gin.Context) {
kind := c.DefaultQuery("type", "alipay") //1:支付宝 2:微信
id, _ := c.GetQuery("id")
if id == "" {
e.OutErr(c, e.ERR_INVALID_ARGS, nil)
return
}
engine := MasterDb(c)
data := db.GetStoreQrcodeById(engine, id)
if data == nil {
e.OutErr(c, 400, e.NewErr(400, "桌码不存在"))
return
}
if data.IsUse != 1 {
e.OutErr(c, 400, e.NewErr(400, "桌码不可用"))
return
}
type RefundReq struct {
StoreId string `json:"store_id" `
StoreType string `json:"store_type" `
TableNumber string `json:"table_number" `
AppId string `json:"app_id" `
InviteCode string `json:"invite_code"`
}
store := db.GetStoreIdEg(engine, utils.IntToStr(data.Uid))
if store == nil {
e.OutErr(c, 400, e.NewErr(400, "门店不存在"))
return
}
user, _ := db.UserProfileFindByID(engine, store.Uid)
var appId = ""
var inviteCode = user.InviteCode
if kind != "alipay" {
communityTeamStoreWxAppletId := db.SysCfgGet(c, "community_team_store_wx_applet_id")
var wxApplet model.WxAppletList
MasterDb(c).Where("id=?", communityTeamStoreWxAppletId).Get(&wxApplet)
appId = wxApplet.OriginalAppId
}

var result = RefundReq{
StoreId: utils.IntToStr(data.Uid),
TableNumber: utils.IntToStr(data.TableNum),
AppId: appId,
StoreType: utils.IntToStr(store.StoreType),
InviteCode: inviteCode,
}
e.OutSuc(c, result, nil)
return
}
func BankStore(c *gin.Context) {
var arg map[string]string
if err := c.ShouldBindJSON(&arg); err != nil {


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