update
This commit is contained in:
parent
22fd2b67f0
commit
d1d8c89976
|
|
@ -34,7 +34,7 @@ var defaultHeadImgUrl = "http://" + web.CONFIG.System.Addr + "/static/img/202403
|
|||
// 登录
|
||||
func (p DefParty) login() web_iris.Party {
|
||||
return web_iris.Party{
|
||||
Perfix: p.Perfix,
|
||||
Perfix: p.Prefix,
|
||||
PartyFunc: func(index iris.Party) {
|
||||
index.Post(AuthBase+"/login", func(ctx *context.Context) {
|
||||
body, _ := io.ReadAll(ctx.Request().Body)
|
||||
|
|
@ -61,7 +61,7 @@ func (p DefParty) login() web_iris.Party {
|
|||
loginRequest.HeadImgUrl = defaultHeadImgUrl
|
||||
}
|
||||
var userInfo models.User
|
||||
database.Instance().Model(&models.User{}).Where("open_id = ? or union_id = ?", "1", "2").Find(&userInfo)
|
||||
database.Instance().Model(&models.User{}).Where("open_id = ? or union_id = ?", info.Openid, info.Unionid).Find(&userInfo)
|
||||
if userInfo.Id == 0 {
|
||||
newUser := models.User{
|
||||
NickName: loginRequest.NickName,
|
||||
|
|
@ -103,7 +103,7 @@ type GetUserInfoResponse struct {
|
|||
|
||||
// 获取用户信息
|
||||
func (p DefParty) getUserInfo() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(AuthBase+"/getUserInfo", func(ctx *context.Context) {
|
||||
headerInfo := GetHeaderBaseInfo(ctx)
|
||||
var userInfo *models.User
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ type Error struct {
|
|||
}
|
||||
|
||||
type DefParty struct {
|
||||
Perfix string
|
||||
Prefix string
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
@ -51,7 +51,8 @@ var (
|
|||
|
||||
func Success(ctx *context.Context, request any, data any) {
|
||||
response := Response{200, "success", data}
|
||||
zap_server.ZAPLOG.Info(ctx.Path(), zap.Any("request", request), zap.Any("response", response))
|
||||
reqTime, _ := ctx.Values().GetTime("reqTime")
|
||||
zap_server.ZAPLOG.Info(ctx.Path(), zap.Any("request", request), zap.Any("response", response), zap.Any("costTime", time.Now().Sub(reqTime).Milliseconds()))
|
||||
write(ctx, response)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ type GoodsListResponse struct {
|
|||
|
||||
// 商品列表
|
||||
func (p DefParty) goodsList() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(GoodsBase+"/goodsList", func(ctx *context.Context) {
|
||||
headerBaseInfo := GetHeaderBaseInfo(ctx)
|
||||
body, _ := io.ReadAll(ctx.Request().Body)
|
||||
|
|
@ -90,7 +90,7 @@ func getPetGoodsList(key string) []GoodsDetail {
|
|||
|
||||
// 商品详情
|
||||
func (p DefParty) goodsDetail() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(GoodsBase+"/goodsDetail", func(ctx *context.Context) {
|
||||
//暂留
|
||||
Success(ctx, nil, nil)
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"pet-house.com/core/server/web/web_iris"
|
||||
"pet-house.com/core/server/zap_server"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var Root = "/pet-house"
|
||||
|
|
@ -45,6 +46,7 @@ func ModuleInit() {
|
|||
DataCacheJob()
|
||||
}
|
||||
func FrontAuth(ctx *context.Context) {
|
||||
ctx.Values().Set("reqTime", time.Now())
|
||||
if strings.Contains(ctx.Path(), ExcludeBase) {
|
||||
ctx.Next()
|
||||
return
|
||||
|
|
@ -82,9 +84,9 @@ func FrontAuth(ctx *context.Context) {
|
|||
}
|
||||
|
||||
func (p DefParty) index() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Get("/", func(c *context.Context) {
|
||||
c.WriteString("successful")
|
||||
_, _ = c.WriteString("successful")
|
||||
})
|
||||
}}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
"pet-house.com/core/server/database"
|
||||
"pet-house.com/core/server/web/web_iris"
|
||||
"pet-house.com/core/server/zap_server"
|
||||
"time"
|
||||
)
|
||||
|
||||
type PetGoodsInfo struct {
|
||||
|
|
@ -23,9 +24,13 @@ type OrderCreateRequest struct {
|
|||
ServiceAddrId int64 //预约服务地址
|
||||
}
|
||||
|
||||
type OrderCreateResponse struct {
|
||||
OrderDetail OrderDetail `json:"orderDetail"`
|
||||
}
|
||||
|
||||
// 创建
|
||||
func (p DefParty) orderCreate() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(OrderBase+"/orderCreate", func(ctx *context.Context) {
|
||||
headerBaseInfo := GetHeaderBaseInfo(ctx)
|
||||
body, _ := io.ReadAll(ctx.Request().Body)
|
||||
|
|
@ -84,7 +89,39 @@ func (p DefParty) orderCreate() web_iris.Party {
|
|||
return
|
||||
}
|
||||
tx.Commit()
|
||||
Success(ctx, orderCreateRequest, nil)
|
||||
|
||||
var findUserServiceAddr models.UserServiceAddr
|
||||
database.Instance().Model(&models.UserServiceAddr{}).Where("id = ? and uid = ?", orderMain.ServiceAddrId, headerBaseInfo.Uid).Find(&findUserServiceAddr)
|
||||
orderDetail := OrderDetail{
|
||||
OrderId: orderMain.OrderId,
|
||||
Status: orderMain.Status,
|
||||
ServiceTime: orderMain.ServiceTime,
|
||||
ServiceAddr: findUserServiceAddr,
|
||||
ServiceRemark: orderMain.ServiceRemark,
|
||||
CreateTime: orderMain.CreateTime.String(),
|
||||
}
|
||||
var subOrderList []SubOrder
|
||||
for _, orderSub := range orderSubList {
|
||||
var orderDetailList []models.OrderDetail
|
||||
database.Instance().Model(&models.OrderDetail{}).Where("sub_order_id = ? ", orderSub.OrderId).Find(&orderDetailList)
|
||||
var goods []models.Goods
|
||||
for _, orderDetail := range orderDetailList {
|
||||
good := GoodsMap[orderDetail.GoodsId]
|
||||
goods = append(goods, good)
|
||||
}
|
||||
orderSub := SubOrder{
|
||||
OrderId: orderSub.OrderId,
|
||||
Status: orderSub.Status,
|
||||
UserPetInfo: GetUserPet(headerBaseInfo.Uid, orderSub.PetId),
|
||||
TotalAmount: orderSub.TotalAmount,
|
||||
PayAmount: orderSub.PayAmount,
|
||||
Goods: goods,
|
||||
}
|
||||
subOrderList = append(subOrderList, orderSub)
|
||||
}
|
||||
orderDetail.CreateTime = time.DateTime
|
||||
orderDetail.SubOrderList = subOrderList
|
||||
Success(ctx, orderCreateRequest, OrderCreateResponse{orderDetail})
|
||||
})
|
||||
}}
|
||||
}
|
||||
|
|
@ -115,14 +152,14 @@ type OrderDetail struct {
|
|||
}
|
||||
|
||||
type OrderListResponse struct {
|
||||
OrderDetail []OrderDetail //订单列表
|
||||
PageNo int //页码
|
||||
PageSize int //数据数量
|
||||
OrderDetail []OrderDetail `json:"orderDetail"` //订单列表
|
||||
PageNo int `json:"pageNo"` //页码
|
||||
PageSize int `json:"pageSize"` //数据数量
|
||||
}
|
||||
|
||||
// 订单列表
|
||||
func (p DefParty) orderList() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(OrderBase+"/orderList", func(ctx *context.Context) {
|
||||
headerBaseInfo := GetHeaderBaseInfo(ctx)
|
||||
body, _ := io.ReadAll(ctx.Request().Body)
|
||||
|
|
@ -134,9 +171,9 @@ func (p DefParty) orderList() web_iris.Party {
|
|||
}
|
||||
var orderList []models.OrderMain
|
||||
if orderListRequest.Status == 0 {
|
||||
database.Instance().Model(&models.OrderMain{}).Where("uid = ?", headerBaseInfo.Uid).Limit(orderListRequest.PageSize).Offset(orderListRequest.PageNo - 1).Find(&orderList)
|
||||
database.Instance().Model(&models.OrderMain{}).Where("uid = ?", headerBaseInfo.Uid).Offset((orderListRequest.PageNo - 1) * orderListRequest.PageSize).Limit(orderListRequest.PageSize).Find(&orderList)
|
||||
} else {
|
||||
database.Instance().Model(&models.OrderMain{}).Where("uid = ? and status = ?", headerBaseInfo.Uid, orderListRequest.Status).Limit(orderListRequest.PageSize).Offset(orderListRequest.PageNo - 1).Find(&orderList)
|
||||
database.Instance().Model(&models.OrderMain{}).Where("uid = ? and status = ?", headerBaseInfo.Uid, orderListRequest.Status).Offset((orderListRequest.PageNo - 1) * orderListRequest.PageSize).Limit(orderListRequest.PageSize).Find(&orderList)
|
||||
}
|
||||
var orderDetails []OrderDetail
|
||||
for _, value := range orderList {
|
||||
|
|
@ -186,7 +223,7 @@ func (p DefParty) orderList() web_iris.Party {
|
|||
|
||||
// 获取订单可预约时间
|
||||
func (p DefParty) orderServiceTime() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(OrderBase+"/orderServiceTime", func(ctx *context.Context) {
|
||||
|
||||
})
|
||||
|
|
@ -195,7 +232,7 @@ func (p DefParty) orderServiceTime() web_iris.Party {
|
|||
|
||||
// 支付
|
||||
func (p DefParty) orderPay() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(OrderBase+"/orderPay", func(ctx *context.Context) {
|
||||
|
||||
})
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ type PetListResponse struct {
|
|||
|
||||
// 宠物列表
|
||||
func (p DefParty) petList() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(PetBase+"/petList", func(ctx *context.Context) {
|
||||
headerBaseInfo := GetHeaderBaseInfo(ctx)
|
||||
userPets := GetUserPets(headerBaseInfo.Uid)
|
||||
|
|
@ -59,7 +59,7 @@ type PetInfoResponse struct {
|
|||
}
|
||||
|
||||
func (p DefParty) petInfo() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(PetBase+"/petInfo", func(ctx *context.Context) {
|
||||
headerBaseInfo := GetHeaderBaseInfo(ctx)
|
||||
body, _ := io.ReadAll(ctx.Request().Body)
|
||||
|
|
@ -90,7 +90,7 @@ type PetAddOrEditResponse struct {
|
|||
|
||||
// 宠物添加或编辑
|
||||
func (p DefParty) petAddOrEdit() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(PetBase+"/petAddOrEdit", func(ctx *context.Context) {
|
||||
headerBaseInfo := GetHeaderBaseInfo(ctx)
|
||||
body, _ := io.ReadAll(ctx.Request().Body)
|
||||
|
|
@ -147,7 +147,7 @@ type PetTypeListResponse struct {
|
|||
|
||||
// 宠物基础信息列表
|
||||
func (p DefParty) petTypeList() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(PetBase+"/petTypeList", func(ctx *context.Context) {
|
||||
var petBaseInfoList []models.PetBaseInfo
|
||||
for _, petBaseInfo := range PetBaseInfoMap {
|
||||
|
|
@ -163,7 +163,7 @@ type DelPetRequest struct {
|
|||
}
|
||||
|
||||
func (p DefParty) delPet() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(PetBase+"/delPet", func(ctx *context.Context) {
|
||||
headerBaseInfo := GetHeaderBaseInfo(ctx)
|
||||
body, _ := io.ReadAll(ctx.Request().Body)
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ type ServiceAddrListResponse struct {
|
|||
|
||||
// 我的服务地址列表
|
||||
func (p DefParty) serviceAddrList() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(ServiceBase+"/serviceAddrList", func(ctx *context.Context) {
|
||||
headerBaseInfo := GetHeaderBaseInfo(ctx)
|
||||
var userServiceAddrList []*models.UserServiceAddr
|
||||
|
|
@ -50,7 +50,7 @@ type ServiceAddOrEditResponse struct {
|
|||
|
||||
// 服务地址添加或编辑
|
||||
func (p DefParty) serviceAddOrEdit() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(ServiceBase+"/serviceAddOrEdit", func(ctx *context.Context) {
|
||||
headerBaseInfo := GetHeaderBaseInfo(ctx)
|
||||
body, _ := io.ReadAll(ctx.Request().Body)
|
||||
|
|
@ -129,7 +129,7 @@ type ServiceAreaAddrListResponse struct {
|
|||
|
||||
// 服务区域列表
|
||||
func (p DefParty) serviceAreaAddrList() web_iris.Party {
|
||||
return web_iris.Party{Perfix: p.Perfix, PartyFunc: func(index iris.Party) {
|
||||
return web_iris.Party{Perfix: p.Prefix, PartyFunc: func(index iris.Party) {
|
||||
index.Post(ServiceBase+"/serviceAreaAddrList", func(ctx *context.Context) {
|
||||
var serviceAddrList []models.ServiceAddr
|
||||
database.Instance().Model(&models.ServiceAddr{}).Find(&serviceAddrList)
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import (
|
|||
|
||||
func main() {
|
||||
wi := web_iris.Init()
|
||||
wi.AddModule(api.DefParty{Perfix: api.Root}.RegisterList()...)
|
||||
wi.AddModule(api.DefParty{Prefix: api.Root}.RegisterList()...)
|
||||
wi.AddFrontFunc(api.FrontAuth)
|
||||
wi.AddWebStatic("./static", "/static")
|
||||
api.ModuleInit()
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ type Goods struct {
|
|||
Id int64 `gorm:"primaryKey;autoIncrement" json:"id"` //商品ID
|
||||
Name string `gorm:"not null" json:"name"` //商品名称
|
||||
GoodsType int `gorm:"not null" json:"goodsType"` //商品类型 1基础服务 2附加产品 3附加服务
|
||||
Time string `json:"time;default:'/'"` //时间
|
||||
Time string `json:"time"` //时间
|
||||
Price int32 `gorm:"not null" json:"price"` //价格
|
||||
ParentId int64 `gorm:"not null" json:"parentId"` //商品父ID
|
||||
BuyMany int `gorm:"not null" json:"buyMany"` //同类型是否可购买多个 0否 1是
|
||||
|
|
@ -109,7 +109,7 @@ type OrderMain struct {
|
|||
Id int64 `gorm:"primaryKey;autoIncrement" json:"id"` //id
|
||||
OrderId string `gorm:"index;unique;not null" json:"orderId"` //主订单号
|
||||
Uid int64 `gorm:"index;not null" json:"uid"` //用户id
|
||||
Status int `json:"status"` //主订单状态 1待服务 2服务中 3已完成
|
||||
Status int `json:"status"` //主订单状态 1待服务 2服务中 3已完成 4已派单 5已取消
|
||||
ServiceTime string `json:"serviceTime"` //服务时间
|
||||
ServiceAddrId int64 `json:"serviceAddrId"` //服务地址信息
|
||||
ServiceRemark string `json:"serviceRemark"` //服务备注
|
||||
|
|
|
|||
Loading…
Reference in New Issue