update
This commit is contained in:
parent
19f2cac258
commit
2f90ee9e17
|
|
@ -159,7 +159,7 @@ type GetUserInfoResponse struct {
|
||||||
Uid int64 `json:"uid"`
|
Uid int64 `json:"uid"`
|
||||||
NickName string `json:"nickName"`
|
NickName string `json:"nickName"`
|
||||||
HeadImgUrl string `json:"headImgUrl"`
|
HeadImgUrl string `json:"headImgUrl"`
|
||||||
Discount float32 `json:"discount"`
|
Discount float64 `json:"discount"`
|
||||||
Amount int `json:"amount"`
|
Amount int `json:"amount"`
|
||||||
Role int `json:"role"`
|
Role int `json:"role"`
|
||||||
UserPets []UserPetInfo `json:"userPets"`
|
UserPets []UserPetInfo `json:"userPets"`
|
||||||
|
|
@ -182,7 +182,7 @@ func (p DefParty) getUserInfo() web_iris.Party {
|
||||||
NickName: userInfo.NickName,
|
NickName: userInfo.NickName,
|
||||||
HeadImgUrl: userInfo.HeadImgUrl,
|
HeadImgUrl: userInfo.HeadImgUrl,
|
||||||
Amount: userInfo.Amount,
|
Amount: userInfo.Amount,
|
||||||
Discount: float32(userInfo.Discount) / 100,
|
Discount: float64(userInfo.Discount) / 100,
|
||||||
Role: userInfo.Role,
|
Role: userInfo.Role,
|
||||||
UserPets: GetUserPets(userInfo.Id),
|
UserPets: GetUserPets(userInfo.Id),
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,8 @@ var (
|
||||||
OrderError = Error{Code: 212, Msg: "当前订单无法修改"}
|
OrderError = Error{Code: 212, Msg: "当前订单无法修改"}
|
||||||
CarNotExistError = Error{Code: 213, Msg: "当前用户未关联车辆"}
|
CarNotExistError = Error{Code: 213, Msg: "当前用户未关联车辆"}
|
||||||
OrderExistError = Error{Code: 214, Msg: "订单不存在"}
|
OrderExistError = Error{Code: 214, Msg: "订单不存在"}
|
||||||
|
PetInfoNotDelError = Error{Code: 215, Msg: "当前宠物存在待服务订单,无法删除"}
|
||||||
|
PetInfoNotUpdateError = Error{Code: 216, Msg: "当前宠物存在待服务订单,无法修改"}
|
||||||
)
|
)
|
||||||
|
|
||||||
func Success(ctx *context.Context, request any, data any) {
|
func Success(ctx *context.Context, request any, data any) {
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,7 @@ func (p DefParty) RegisterList() []web_iris.Party {
|
||||||
p.orderDetail(),
|
p.orderDetail(),
|
||||||
p.orderGoodsUpdate(),
|
p.orderGoodsUpdate(),
|
||||||
p.orderPay(),
|
p.orderPay(),
|
||||||
|
p.orderCancel(),
|
||||||
//宠物
|
//宠物
|
||||||
p.petList(),
|
p.petList(),
|
||||||
p.petInfo(),
|
p.petInfo(),
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,8 @@ import (
|
||||||
"github.com/kataras/iris/v12/context"
|
"github.com/kataras/iris/v12/context"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"io"
|
"io"
|
||||||
|
"pet-house.com/business/models"
|
||||||
|
"pet-house.com/core/server/database"
|
||||||
"pet-house.com/core/server/web/web_iris"
|
"pet-house.com/core/server/web/web_iris"
|
||||||
"pet-house.com/core/server/zap_server"
|
"pet-house.com/core/server/zap_server"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
@ -41,7 +43,9 @@ func (p DefParty) goodsList() web_iris.Party {
|
||||||
var goodsListRequest GoodsListRequest
|
var goodsListRequest GoodsListRequest
|
||||||
json.Unmarshal(body, &goodsListRequest)
|
json.Unmarshal(body, &goodsListRequest)
|
||||||
userPetInfo := GetUserPet(headerBaseInfo.Uid, goodsListRequest.Pid)
|
userPetInfo := GetUserPet(headerBaseInfo.Uid, goodsListRequest.Pid)
|
||||||
if userPetInfo.PetInfo.Id == 0 {
|
var userInfo *models.User
|
||||||
|
database.Instance().Model(&models.User{}).Where("id = ?", headerBaseInfo.Uid).Find(&userInfo)
|
||||||
|
if userPetInfo.PetInfo.Id == 0 && userInfo.Role == 0 {
|
||||||
PetNotExistError.Fail(ctx, goodsListRequest)
|
PetNotExistError.Fail(ctx, goodsListRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ import (
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"gorm.io/gorm/clause"
|
"gorm.io/gorm/clause"
|
||||||
"io"
|
"io"
|
||||||
|
"math"
|
||||||
"pet-house.com/business/models"
|
"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"
|
||||||
|
|
@ -71,7 +72,7 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||||
}
|
}
|
||||||
haveReserve := checkOrderServiceTime(orderCreateRequest.ServiceTime, projectionServiceTime)
|
haveReserve := checkOrderServiceTime(orderCreateRequest.ServiceTime, projectionServiceTime)
|
||||||
if haveReserve {
|
if haveReserve {
|
||||||
OrderCreateError.DefFail(ctx, orderCreateRequest, "当前时间点不可预约")
|
OrderCreateError.DefFail(ctx, orderCreateRequest, "当前订单预估服务时长预计:"+strconv.Itoa(projectionServiceTime)+"分钟,服务时间过长,请更换时间段预约")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for _, value := range orderCreateRequest.PetGoodsInfos {
|
for _, value := range orderCreateRequest.PetGoodsInfos {
|
||||||
|
|
@ -100,6 +101,7 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||||
subOrderId := NextId.Generate().String()
|
subOrderId := NextId.Generate().String()
|
||||||
var totalAmount int32 = 0
|
var totalAmount int32 = 0
|
||||||
var projectionServiceTime = 0
|
var projectionServiceTime = 0
|
||||||
|
var goodsName string
|
||||||
for _, value := range value.GoodsIds {
|
for _, value := range value.GoodsIds {
|
||||||
goods := GoodsMap[value]
|
goods := GoodsMap[value]
|
||||||
totalAmount = totalAmount + goods.Price
|
totalAmount = totalAmount + goods.Price
|
||||||
|
|
@ -111,18 +113,22 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||||
if goods.GoodsType == 1 || goods.GoodsType == 2 {
|
if goods.GoodsType == 1 || goods.GoodsType == 2 {
|
||||||
mainGoods++
|
mainGoods++
|
||||||
}
|
}
|
||||||
|
goodsName = goods.Name + "、" + goodsName
|
||||||
}
|
}
|
||||||
|
userPetInfo := GetUserPet(headerBaseInfo.Uid, value.PetId)
|
||||||
|
var petInfo = "宠物名称:" + userPetInfo.PetInfo.NickName + "</br>品种:" + userPetInfo.PetBaseInfo.Assortment + "</br>服务项目:" + goodsName
|
||||||
projectionServiceTimeAll += projectionServiceTime
|
projectionServiceTimeAll += projectionServiceTime
|
||||||
orderSub := models.OrderSub{
|
orderSub := models.OrderSub{
|
||||||
OrderId: subOrderId,
|
OrderId: subOrderId,
|
||||||
MainOrderId: orderMain.OrderId,
|
MainOrderId: orderMain.OrderId,
|
||||||
OrderStatus: 1,
|
OrderStatus: 1,
|
||||||
PetId: value.PetId,
|
PetId: value.PetId,
|
||||||
PayType: 1,
|
PayType: 1,
|
||||||
Discount: 100,
|
Discount: 100,
|
||||||
TotalAmount: totalAmount,
|
TotalAmount: totalAmount,
|
||||||
PayAmount: totalAmount,
|
PayAmount: totalAmount,
|
||||||
PayTime: time.Now(),
|
PetInfo: petInfo,
|
||||||
|
//PayTime: time.Now(),
|
||||||
ProjectionServiceTime: projectionServiceTime,
|
ProjectionServiceTime: projectionServiceTime,
|
||||||
}
|
}
|
||||||
orderTotalAmount = orderTotalAmount + int(totalAmount)
|
orderTotalAmount = orderTotalAmount + int(totalAmount)
|
||||||
|
|
@ -136,11 +142,13 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||||
var userInfo *models.User
|
var userInfo *models.User
|
||||||
database.Instance().Model(&models.User{}).Where("id = ?", headerBaseInfo.Uid).Find(&userInfo)
|
database.Instance().Model(&models.User{}).Where("id = ?", headerBaseInfo.Uid).Find(&userInfo)
|
||||||
if userInfo.Discount > 0 {
|
if userInfo.Discount > 0 {
|
||||||
orderTotalAmount = orderTotalAmount * (userInfo.Discount / 100)
|
discount := float64(userInfo.Discount)
|
||||||
|
orderTotalAmount = int(math.Round(float64(orderTotalAmount) * (discount / 100.0)))
|
||||||
}
|
}
|
||||||
tx := database.Instance().Begin()
|
tx := database.Instance().Begin()
|
||||||
var db4 *gorm.DB
|
var db4 *gorm.DB
|
||||||
if userInfo.Amount >= orderTotalAmount {
|
if userInfo.Amount >= orderTotalAmount {
|
||||||
|
var currAmount = userInfo.Amount
|
||||||
orderMain.PayStatus = 1
|
orderMain.PayStatus = 1
|
||||||
orderMain.PayTotalAmount = orderTotalAmount
|
orderMain.PayTotalAmount = orderTotalAmount
|
||||||
userInfo.Amount = userInfo.Amount - orderTotalAmount
|
userInfo.Amount = userInfo.Amount - orderTotalAmount
|
||||||
|
|
@ -148,14 +156,16 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||||
"Amount": userInfo.Amount,
|
"Amount": userInfo.Amount,
|
||||||
}
|
}
|
||||||
db4 = tx.Model(&userInfo).Updates(&updateValues)
|
db4 = tx.Model(&userInfo).Updates(&updateValues)
|
||||||
|
orderMain.PayDiscount = userInfo.Discount
|
||||||
|
zap_server.ZAPLOG.Info("会员金额扣除", zap.Any("用户ID", userInfo.Id), zap.Any("当前余额", currAmount), zap.Any("扣除余额", orderTotalAmount), zap.Any("剩余余额", userInfo.Amount), zap.Any("折扣", userInfo.Discount))
|
||||||
}
|
}
|
||||||
db := tx.Model(&models.OrderDetail{}).CreateInBatches(&orderSubDetailList, len(orderSubDetailList))
|
db := tx.Model(&models.OrderDetail{}).CreateInBatches(&orderSubDetailList, len(orderSubDetailList))
|
||||||
db1 := tx.Model(&models.OrderSub{}).CreateInBatches(&orderSubList, len(orderSubList))
|
db1 := tx.Model(&models.OrderSub{}).CreateInBatches(&orderSubList, len(orderSubList))
|
||||||
db2 := tx.Model(&models.OrderMain{}).Create(&orderMain)
|
db2 := tx.Model(&models.OrderMain{}).Create(&orderMain)
|
||||||
if db4.Error != nil || db.Error != nil || db1.Error != nil || db2.Error != nil {
|
if (db4 != nil && db4.Error != nil) || db.Error != nil || db1.Error != nil || db2.Error != nil {
|
||||||
tx.Callback()
|
tx.Callback()
|
||||||
orderLock.Unlock()
|
orderLock.Unlock()
|
||||||
zap_server.ZAPLOG.Error("订单插入失败", zap.Any("db", db.Error), zap.Any("db1", db1.Error), zap.Any("db2", db2.Error))
|
zap_server.ZAPLOG.Error("订单插入失败", zap.Any("db", db.Error), zap.Any("db1", db1.Error), zap.Any("db2", db2.Error), zap.Any("db4", db4.Error))
|
||||||
OrderCreateError.Fail(ctx, orderCreateRequest)
|
OrderCreateError.Fail(ctx, orderCreateRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
@ -362,13 +372,14 @@ func (p DefParty) orderCancel() web_iris.Party {
|
||||||
orderMain.PayTotalAmount = 0
|
orderMain.PayTotalAmount = 0
|
||||||
orderMain.PayStatus = 0
|
orderMain.PayStatus = 0
|
||||||
}
|
}
|
||||||
orderMain.OrderStatus = 5
|
orderMain.OrderStatus = 4
|
||||||
updateValues := map[string]interface{}{
|
updateValues := map[string]interface{}{
|
||||||
"OrderStatus": orderMain.OrderStatus,
|
"OrderStatus": orderMain.OrderStatus,
|
||||||
"PayStatus": orderMain.PayStatus,
|
"PayStatus": orderMain.PayStatus,
|
||||||
"PayTotalAmount": orderMain.PayTotalAmount,
|
"PayTotalAmount": orderMain.PayTotalAmount,
|
||||||
}
|
}
|
||||||
database.Instance().Model(&orderMain).Updates(&updateValues)
|
database.Instance().Model(&orderMain).Updates(&updateValues)
|
||||||
|
Success(ctx, orderCancelRequest, OrderCancelResponse{GetOrderDetail(orderMain.OrderId)})
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@ type UserPetInfo struct {
|
||||||
|
|
||||||
func GetUserPets(uId int64) []UserPetInfo {
|
func GetUserPets(uId int64) []UserPetInfo {
|
||||||
var userPetList []models.Pet
|
var userPetList []models.Pet
|
||||||
database.Instance().Model(&models.Pet{}).Where("uid = ?", uId).Find(&userPetList)
|
database.Instance().Model(&models.Pet{}).Where("uid = ? and status = 1", uId).Find(&userPetList)
|
||||||
var userPets []UserPetInfo
|
var userPets []UserPetInfo
|
||||||
if len(userPetList) > 0 {
|
if len(userPetList) > 0 {
|
||||||
for _, pet := range userPetList {
|
for _, pet := range userPetList {
|
||||||
|
|
@ -46,7 +46,7 @@ func GetUserPets(uId int64) []UserPetInfo {
|
||||||
|
|
||||||
func GetUserPet(uId int64, pId int64) UserPetInfo {
|
func GetUserPet(uId int64, pId int64) UserPetInfo {
|
||||||
var userPet models.Pet
|
var userPet models.Pet
|
||||||
database.Instance().Model(&models.Pet{}).Where("uid = ? and id = ?", uId, pId).Find(&userPet)
|
database.Instance().Model(&models.Pet{}).Where("uid = ? and id = ? and status = 1", uId, pId).Find(&userPet)
|
||||||
return UserPetInfo{userPet, PetBaseInfoMap[userPet.PetId]}
|
return UserPetInfo{userPet, PetBaseInfoMap[userPet.PetId]}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -139,10 +139,20 @@ func (p DefParty) petAddOrEdit() web_iris.Party {
|
||||||
pet.Id = petAddOrEditRequest.Id
|
pet.Id = petAddOrEditRequest.Id
|
||||||
var userPetInfo models.Pet
|
var userPetInfo models.Pet
|
||||||
database.Instance().Model(&models.Pet{}).Where("id = ? and uid = ?", pet.Id, headerBaseInfo.Uid).Find(&userPetInfo)
|
database.Instance().Model(&models.Pet{}).Where("id = ? and uid = ?", pet.Id, headerBaseInfo.Uid).Find(&userPetInfo)
|
||||||
if userPetInfo.Id == 0 {
|
var userInfo *models.User
|
||||||
|
database.Instance().Model(&models.User{}).Where("id = ?", headerBaseInfo.Uid).Find(&userInfo)
|
||||||
|
if userPetInfo.Id == 0 && userInfo.Role == 0 {
|
||||||
PetNotExistError.Fail(ctx, petAddOrEditRequest)
|
PetNotExistError.Fail(ctx, petAddOrEditRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if userInfo.Role == 0 {
|
||||||
|
var count int64
|
||||||
|
database.Instance().Model(&models.OrderSub{}).Where("pet_id = ? and (order_status = 1 or order_status = 2)", userPetInfo.Id).Count(&count)
|
||||||
|
if count > 0 {
|
||||||
|
PetInfoNotUpdateError.Fail(ctx, petAddOrEditRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
updateValues := map[string]interface{}{
|
updateValues := map[string]interface{}{
|
||||||
"NickName": pet.NickName,
|
"NickName": pet.NickName,
|
||||||
"HeadImgType": pet.HeadImgType,
|
"HeadImgType": pet.HeadImgType,
|
||||||
|
|
@ -201,7 +211,16 @@ func (p DefParty) delPet() web_iris.Party {
|
||||||
PetNotExistError.Fail(ctx, delPetRequest)
|
PetNotExistError.Fail(ctx, delPetRequest)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
database.Instance().Where("id = ?", userPetInfo.PetId).Delete(&models.Pet{})
|
var count int64
|
||||||
|
database.Instance().Model(&models.OrderSub{}).Where("pet_id = ? and (order_status = 1 or order_status = 2)", userPetInfo.Id).Count(&count)
|
||||||
|
if count > 0 {
|
||||||
|
PetInfoNotDelError.Fail(ctx, delPetRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
updateValues := map[string]interface{}{
|
||||||
|
"Status": 0,
|
||||||
|
}
|
||||||
|
database.Instance().Model(&userPetInfo).Updates(&updateValues)
|
||||||
Success(ctx, nil, nil)
|
Success(ctx, nil, nil)
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,7 @@ func (p DefParty) serviceAddOrEdit() web_iris.Party {
|
||||||
}
|
}
|
||||||
}*/
|
}*/
|
||||||
//userServiceAddr.AddrArea = recogResponse.County
|
//userServiceAddr.AddrArea = recogResponse.County
|
||||||
|
|
||||||
if serviceAddOrEditRequest.Id == 0 {
|
if serviceAddOrEditRequest.Id == 0 {
|
||||||
database.Instance().Model(&models.UserServiceAddr{}).Create(&userServiceAddr)
|
database.Instance().Model(&models.UserServiceAddr{}).Create(&userServiceAddr)
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -121,6 +122,12 @@ func (p DefParty) serviceAddOrEdit() web_iris.Party {
|
||||||
}
|
}
|
||||||
database.Instance().Model(&userServiceAddr).Updates(&updateValues)
|
database.Instance().Model(&userServiceAddr).Updates(&updateValues)
|
||||||
}
|
}
|
||||||
|
var userInfo *models.User
|
||||||
|
database.Instance().Model(&models.User{}).Where("id = ?", headerBaseInfo.Uid).Find(&userInfo)
|
||||||
|
updateValues := map[string]interface{}{
|
||||||
|
"Mobile": userInfo.Mobile,
|
||||||
|
}
|
||||||
|
database.Instance().Model(&userInfo).Updates(&updateValues)
|
||||||
var userServiceAddrList []*models.UserServiceAddr
|
var userServiceAddrList []*models.UserServiceAddr
|
||||||
database.Instance().Model(&models.UserServiceAddr{}).Where("uid = ?", headerBaseInfo.Uid).Find(&userServiceAddrList)
|
database.Instance().Model(&models.UserServiceAddr{}).Where("uid = ?", headerBaseInfo.Uid).Find(&userServiceAddrList)
|
||||||
for _, value := range userServiceAddrList {
|
for _, value := range userServiceAddrList {
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@ type Pet struct {
|
||||||
LastServiceProj string `gorm:"default:'-'" json:"lastServiceProj"` //上次服务项目
|
LastServiceProj string `gorm:"default:'-'" json:"lastServiceProj"` //上次服务项目
|
||||||
LastServiceDate string `gorm:"default:'-'" json:"lastServiceDate"` //上次服务时间
|
LastServiceDate string `gorm:"default:'-'" json:"lastServiceDate"` //上次服务时间
|
||||||
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP;not null" json:"createTime"` //创建时间
|
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP;not null" json:"createTime"` //创建时间
|
||||||
|
Status int `gorm:"default:1" json:"status"` //信息状态
|
||||||
}
|
}
|
||||||
|
|
||||||
// PetBaseInfo 宠物基础信息
|
// PetBaseInfo 宠物基础信息
|
||||||
|
|
@ -53,12 +54,12 @@ type PetBaseInfo struct {
|
||||||
|
|
||||||
// ServiceAddr 服务地址
|
// ServiceAddr 服务地址
|
||||||
type ServiceAddr struct {
|
type ServiceAddr struct {
|
||||||
Id int64 `gorm:"primaryKey;autoIncrement" json:"id"` //ID
|
Id int64 `gorm:"primaryKey;autoIncrement" json:"id"` //ID
|
||||||
Longitude string `json:"longitude"` //经度
|
Longitude string `json:"longitude"` //经度
|
||||||
Latitude string `json:"latitude"` //纬度
|
Latitude string `json:"latitude"` //纬度
|
||||||
Addr string `gorm:"not null" json:"addr"` //详细地址
|
Addr string `gorm:"not null" json:"addr"` //详细地址
|
||||||
DistantGapMeters float64 `gorm:"not null" json:"distantGapMeters"` //服务最远距离 单位/米
|
DistantGapMeters int64 `gorm:"not null" json:"distantGapMeters"` //服务最远距离 单位/米
|
||||||
ServiceArea string `json:"serviceArea"` //服务区域
|
ServiceArea string `json:"serviceArea"` //服务区域
|
||||||
}
|
}
|
||||||
|
|
||||||
// UserServiceAddr 用户服务地址
|
// UserServiceAddr 用户服务地址
|
||||||
|
|
@ -130,6 +131,7 @@ type OrderMain struct {
|
||||||
PayStatus int `gorm:"default:0" json:"payStatus"` //支付状态 0未支付 1已支付
|
PayStatus int `gorm:"default:0" json:"payStatus"` //支付状态 0未支付 1已支付
|
||||||
DispatchStatus int `gorm:"default:0" json:"dispatchStatus"` //派单状态 0未派单 1已派单
|
DispatchStatus int `gorm:"default:0" json:"dispatchStatus"` //派单状态 0未派单 1已派单
|
||||||
PayTotalAmount int `json:"payTotalAmount"` //支付总金额
|
PayTotalAmount int `json:"payTotalAmount"` //支付总金额
|
||||||
|
PayDiscount int `gorm:"default:0" json:"payDiscount"` //支付折扣
|
||||||
}
|
}
|
||||||
|
|
||||||
// OrderSub 子订单
|
// OrderSub 子订单
|
||||||
|
|
@ -147,6 +149,7 @@ type OrderSub struct {
|
||||||
PayAmount int32 `json:"payAmount"` //实际支付金额
|
PayAmount int32 `json:"payAmount"` //实际支付金额
|
||||||
PayTime time.Time `gorm:"type:timestamp;" json:"payTime"` //支付时间
|
PayTime time.Time `gorm:"type:timestamp;" json:"payTime"` //支付时间
|
||||||
PayRemark string `json:"payRemark"` //支付备注
|
PayRemark string `json:"payRemark"` //支付备注
|
||||||
|
PetInfo string `json:"petInfo"` //宠物快照信息
|
||||||
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"createTime"` //创建时间
|
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"createTime"` //创建时间
|
||||||
UpdateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP" json:"-"` //更新时间
|
UpdateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP" json:"-"` //更新时间
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ type TimeObject struct {
|
||||||
|
|
||||||
func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFilter, orderTimeMap map[string]string, carNum int, orderNumMap map[string]int, carServiceNum int, times []string) map[string][]TimeObject {
|
func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFilter, orderTimeMap map[string]string, carNum int, orderNumMap map[string]int, carServiceNum int, times []string) map[string][]TimeObject {
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
currentTime := time.Now().AddDate(0, 0, 1)
|
currentTime := time.Now()
|
||||||
// 计算半小时后的时间
|
// 计算半小时后的时间
|
||||||
halfHourLater := currentTime.Add(time.Duration(minute) * time.Minute)
|
halfHourLater := currentTime.Add(time.Duration(minute) * time.Minute)
|
||||||
|
|
||||||
|
|
@ -56,7 +56,8 @@ func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFil
|
||||||
orderNum, existOrderNum := orderNumMap[nextHour.Format("2006-01-02 15:04")]
|
orderNum, existOrderNum := orderNumMap[nextHour.Format("2006-01-02 15:04")]
|
||||||
if (nextHour.Hour() >= workStart && nextHour.Hour() < workEnd) && (!existsDay && !existsHour) && !existOrderTime {
|
if (nextHour.Hour() >= workStart && nextHour.Hour() < workEnd) && (!existsDay && !existsHour) && !existOrderTime {
|
||||||
key := nextHour.Format("2006-01-02")
|
key := nextHour.Format("2006-01-02")
|
||||||
if _, ok := serviceDaysMap[key]; len(serviceDaysMap) > 0 && !ok {
|
key1 := nextHour.Format("2006-01-02 15:04")
|
||||||
|
if _, ok := serviceDaysMap[key1]; len(serviceDaysMap) > 0 && !ok {
|
||||||
//不存在服务配置中返回false
|
//不存在服务配置中返回false
|
||||||
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
||||||
Time: nextHour.Format("15:04"),
|
Time: nextHour.Format("15:04"),
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"math"
|
||||||
"pet-house.com/business/models"
|
"pet-house.com/business/models"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
@ -17,6 +18,15 @@ func TestGetStrDays(t *testing.T) {
|
||||||
Type: 2,
|
Type: 2,
|
||||||
Content: "12",
|
Content: "12",
|
||||||
}
|
}
|
||||||
days := GetStrDays(7, 30, ReserveMap, nil, 1, nil, 2)
|
//days := GetStrDays(7, 30, ReserveMap, nil, 1, nil, 2)
|
||||||
fmt.Println(days)
|
//fmt.Println(days)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestCalc(t *testing.T) {
|
||||||
|
i := math.Round(386 * (float64(85) / 100))
|
||||||
|
fmt.Println(i)
|
||||||
|
}
|
||||||
|
func TestCalc1(t *testing.T) {
|
||||||
|
i := float64(85) / 100
|
||||||
|
fmt.Println(i)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue