新增接口

This commit is contained in:
yan.y 2024-11-18 15:17:25 +08:00
parent bfcee075b6
commit 101e819b66
5 changed files with 69 additions and 27 deletions

View File

@ -63,6 +63,7 @@ var (
UserCouponsNExistOrUseError = Error{Code: 220, Msg: "用户不存在优惠券或已使用"} UserCouponsNExistOrUseError = Error{Code: 220, Msg: "用户不存在优惠券或已使用"}
PayError = Error{Code: 221, Msg: "支付失败"} PayError = Error{Code: 221, Msg: "支付失败"}
OrderNotPayError = Error{Code: 222, Msg: "订单未支付定金"} OrderNotPayError = Error{Code: 222, Msg: "订单未支付定金"}
OrderNotDispachError = Error{Code: 223, Msg: "当前订单暂未派单,无法查看护理车辆位置"}
) )
func Success(ctx *context.Context, request any, data any) { func Success(ctx *context.Context, request any, data any) {

View File

@ -45,6 +45,7 @@ func (p DefParty) RegisterList() []web_iris.Party {
p.serviceAddOrEdit(), p.serviceAddOrEdit(),
p.serviceAreaAddrList(), p.serviceAreaAddrList(),
p.serviceCarLocationUpload(), p.serviceCarLocationUpload(),
p.serviceCarLocationList(),
//车辆 //车辆
p.carServiceOrderList(), p.carServiceOrderList(),
p.carServiceProcess(), p.carServiceProcess(),

View File

@ -4,7 +4,6 @@ import (
"github.com/kataras/iris/v12" "github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/context" "github.com/kataras/iris/v12/context"
"go.uber.org/zap" "go.uber.org/zap"
"pet-house.com/business/models"
"pet-house.com/business/utils" "pet-house.com/business/utils"
"pet-house.com/core/server/database" "pet-house.com/core/server/database"
"pet-house.com/core/server/web/web_iris" "pet-house.com/core/server/web/web_iris"
@ -27,31 +26,31 @@ var frontExcludes = [...]string{
func ModuleInit() { func ModuleInit() {
utils.WechatInit() utils.WechatInit()
_err := database.Instance().AutoMigrate( _err := database.Instance().AutoMigrate(
//&models.User{}, //&models.User{},
//&models.Pet{}, //&models.Pet{},
//&models.PetBaseInfo{}, //&models.PetBaseInfo{},
//&models.ServiceAddr{}, //&models.ServiceAddr{},
//&models.UserServiceAddr{}, //&models.UserServiceAddr{},
//&models.Goods{}, //&models.Goods{},
//&models.PetGoods{}, //&models.PetGoods{},
//&models.SystemConfig{}, //&models.SystemConfig{},
//&models.OrderMain{}, //&models.OrderMain{},
//&models.OrderSub{}, //&models.OrderSub{},
//&models.OrderDetail{}, //&models.OrderDetail{},
//&models.ServiceCar{}, //&models.ServiceCar{},
//&models.CarOrder{}, //&models.CarOrder{},
//&models.ServiceCarUser{}, //&models.ServiceCarUser{},
//&models.ServiceUserMark{}, //&models.ServiceUserMark{},
//&models.ServiceUserMarkRecord{}, //&models.ServiceUserMarkRecord{},
//&models.ReserveTimeFilter{}, //&models.ReserveTimeFilter{},
//&models.OrderServiceRecord{}, //&models.OrderServiceRecord{},
//&models.AddrServiceTime{}, //&models.AddrServiceTime{},
//&models.UserAmountRecord{}, //&models.UserAmountRecord{},
//&models.Coupons{}, //&models.Coupons{},
//&models.UserCoupons{}, //&models.UserCoupons{},
//&models.RechargeInfo{}, //&models.RechargeInfo{},
//&models.PayOrder{}, //&models.PayOrder{},
&models.ServiceCarLocation{}, //&models.ServiceCarLocation{},
) )
zap_server.ZAPLOG.Info("data init ", zap.Any("err", _err)) zap_server.ZAPLOG.Info("data init ", zap.Any("err", _err))
DataInit() DataInit()

View File

@ -159,7 +159,7 @@ type ServiceCarLocationUploadRequest struct {
Latitude string //纬度 Latitude string //纬度
} }
// 服务区域列表 // 服务车辆位置上报
func (p DefParty) serviceCarLocationUpload() web_iris.Party { func (p DefParty) serviceCarLocationUpload() web_iris.Party {
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) { return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
index.Post(ServiceBase+"/serviceCarLocationUpload", func(ctx *context.Context) { index.Post(ServiceBase+"/serviceCarLocationUpload", func(ctx *context.Context) {
@ -168,14 +168,54 @@ func (p DefParty) serviceCarLocationUpload() web_iris.Party {
var serviceCarLocationUploadRequest ServiceCarLocationUploadRequest var serviceCarLocationUploadRequest ServiceCarLocationUploadRequest
json.Unmarshal(body, &serviceCarLocationUploadRequest) json.Unmarshal(body, &serviceCarLocationUploadRequest)
var serviceCarUser models.ServiceCarUser
database.Instance().Model(&models.ServiceCarUser{}).Where("uid = ?", headerBaseInfo.Uid).Find(&serviceCarUser)
if serviceCarUser.Uid == 0 {
CarNotExistError.Fail(ctx, serviceCarLocationUploadRequest)
return
}
serviceCarLocation := models.ServiceCarLocation{ serviceCarLocation := models.ServiceCarLocation{
Uid: headerBaseInfo.Uid, Uid: headerBaseInfo.Uid,
Longitude: serviceCarLocationUploadRequest.Longitude, Longitude: serviceCarLocationUploadRequest.Longitude,
Latitude: serviceCarLocationUploadRequest.Latitude, Latitude: serviceCarLocationUploadRequest.Latitude,
CarId: serviceCarUser.CarId,
Status: 1, Status: 1,
} }
database.Instance().Model(&models.ServiceCarLocation{}).Create(&serviceCarLocation) database.Instance().Model(&models.ServiceCarLocation{}).Create(&serviceCarLocation)
Success(ctx, serviceCarLocationUploadRequest, nil) Success(ctx, serviceCarLocationUploadRequest, nil)
})
}}
}
type ServiceCarLocationListRequest struct {
OrderId string //订单ID
}
type ServiceCarLocationListResponse struct {
ServiceCarLocationList []models.ServiceCarLocation `json:"serviceCarLocationList"`
}
// 服务车辆经纬度列表
func (p DefParty) serviceCarLocationList() web_iris.Party {
return web_iris.Party{Prefix: p.Prefix, PartyFunc: func(index iris.Party) {
index.Post(ServiceBase+"/serviceCarLocationList", func(ctx *context.Context) {
body, _ := io.ReadAll(ctx.Request().Body)
var serviceCarLocationListRequest ServiceCarLocationListRequest
json.Unmarshal(body, &serviceCarLocationListRequest)
var carOrder models.CarOrder
database.Instance().Model(&models.CarOrder{}).Where("order_id = ?", serviceCarLocationListRequest.OrderId).Find(&carOrder)
if carOrder.Id == 0 {
OrderNotDispachError.Fail(ctx, serviceCarLocationListRequest)
return
}
var serviceCarLocation []models.ServiceCarLocation
database.Instance().Model(&models.ServiceCarLocation{}).Where("car_id = ? and create_time >= CURDATE()", carOrder.CarId).Find(&serviceCarLocation)
Success(ctx, serviceCarLocationListRequest, ServiceCarLocationListResponse{serviceCarLocation})
}) })
}} }}

View File

@ -339,6 +339,7 @@ type PayOrder struct {
type ServiceCarLocation struct { type ServiceCarLocation struct {
Id int `gorm:"primaryKey;autoIncrement"` //id Id int `gorm:"primaryKey;autoIncrement"` //id
Uid int64 `gorm:"not null" json:"uid"` //用户ID Uid int64 `gorm:"not null" json:"uid"` //用户ID
CarId int `gorm:"not null" json:"carId"` //车辆ID
Longitude string `json:"longitude"` //经度 Longitude string `json:"longitude"` //经度
Latitude string `json:"latitude"` //纬度 Latitude string `json:"latitude"` //纬度
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"createTime"` //创建时间 CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"createTime"` //创建时间