This commit is contained in:
yan.y 2024-06-26 12:05:10 +08:00
parent e05bf0ff48
commit 8729de390f
7 changed files with 211 additions and 69 deletions

View File

@ -24,7 +24,7 @@ func (p DefParty) dispatchOrder() web_iris.Party {
var dispatchOrderRequest DispatchOrderRequest
json.Unmarshal(body, &dispatchOrderRequest)
var orderMain models.OrderMain
database.Instance().Model(&models.OrderMain{}).Where("order_id = ?", dispatchOrderRequest.OrderId).Find(&orderMain)
database.Instance().Model(&models.OrderMain{}).Where("order_id = ? and status = 1", dispatchOrderRequest.OrderId).Find(&orderMain)
if orderMain.Id == 0 {
OrderExistError.Fail(ctx, dispatchOrderRequest)
return

View File

@ -104,32 +104,79 @@ func (p DefParty) carServiceProcess() web_iris.Party {
}
var mainOrder models.OrderMain
database.Instance().Model(&models.OrderMain{}).Where("order_id = ?", subOrderInfo.MainOrderId).Find(&mainOrder)
database.Instance().Model(&models.OrderMain{}).Where("order_id = ? and status = 1", subOrderInfo.MainOrderId).Find(&mainOrder)
if mainOrder.Id == 0 {
OrderExistError.Fail(ctx, carServiceProcessRequest)
return
}
if carServiceProcessRequest.PayAmount > 0 {
mainOrder.TotalAmount = mainOrder.TotalAmount - subOrderInfo.TotalAmount + carServiceProcessRequest.PayAmount
subOrderInfo.TotalAmount = carServiceProcessRequest.PayAmount
subOrderInfo.PayAmount = carServiceProcessRequest.PayAmount
subOrderInfo.PayTime = time.Now()
subOrderInfo.PayStatus = 1
}
if carServiceProcessRequest.Type == 1 {
if subOrderInfo.OrderStatus == 3 || subOrderInfo.OrderStatus == 2 {
OrderError.Fail(ctx, carServiceProcessRequest)
return
}
subOrderInfo.OrderStatus = 2
mainOrder.OrderStatus = 2
database.Instance().Save(&mainOrder)
database.Instance().Save(&subOrderInfo)
} else if carServiceProcessRequest.Type == 2 {
if subOrderInfo.OrderStatus == 3 {
OrderError.Fail(ctx, carServiceProcessRequest)
return
}
}
var orderUserInfo *models.User
database.Instance().Model(&models.User{}).Where("id = ?", mainOrder.Uid).Find(&orderUserInfo)
if carServiceProcessRequest.PayAmount > 0 && subOrderInfo.TotalAmount != carServiceProcessRequest.PayAmount {
//原价
originAmount := subOrderInfo.PayAmount
userOriginAmount := orderUserInfo.Amount
mainOrder.TotalAmount = mainOrder.TotalAmount - subOrderInfo.TotalAmount + carServiceProcessRequest.PayAmount
if mainOrder.PayTotalAmount > 0 && subOrderInfo.TotalAmount != carServiceProcessRequest.PayAmount {
mainOrder.PayTotalAmount = mainOrder.PayTotalAmount - originAmount + carServiceProcessRequest.PayAmount*10
}
subOrderInfo.TotalAmount = carServiceProcessRequest.PayAmount
subOrderInfo.PayAmount = carServiceProcessRequest.PayAmount
if mainOrder.PayStatus == 1 {
subOrderInfo.PayAmount = carServiceProcessRequest.PayAmount * 10
recordType := 2
amount := 0
//新价格大于原价格 加回差价
if subOrderInfo.PayAmount < originAmount {
recordType = 1
amount = originAmount - subOrderInfo.PayAmount
orderUserInfo.Amount = orderUserInfo.Amount + amount
} else {
if orderUserInfo.Amount < (subOrderInfo.PayAmount - originAmount) {
OrderError.DefFail(ctx, carServiceProcessRequest, "当前余额不足")
return
}
amount = subOrderInfo.PayAmount - originAmount
orderUserInfo.Amount = orderUserInfo.Amount - amount
}
updateValues := map[string]interface{}{
"Amount": orderUserInfo.Amount,
}
database.Instance().Model(&orderUserInfo).Updates(&updateValues)
userAmountRecord := models.UserAmountRecord{
UserId: orderUserInfo.Id,
Type: recordType,
OriginAmount: userOriginAmount,
ProAmount: amount,
CurrAmount: orderUserInfo.Amount,
OrderId: mainOrder.OrderId,
ProScene: "修改订单金额",
Status: 1,
}
database.Instance().Model(&models.UserAmountRecord{}).Create(&userAmountRecord)
}
subOrderInfo.PayTime = time.Now()
subOrderInfo.PayStatus = 1
}
if carServiceProcessRequest.Type == 1 {
subOrderInfo.OrderStatus = 2
mainOrder.OrderStatus = 2
database.Instance().Save(&mainOrder)
database.Instance().Save(&subOrderInfo)
} else if carServiceProcessRequest.Type == 2 {
subOrderInfo.OrderStatus = 3
subOrderInfo.PayStatus = 1
subOrderInfo.PayTime = time.Now()
@ -150,7 +197,7 @@ func (p DefParty) carServiceProcess() web_iris.Party {
database.Instance().Save(&mainOrder)
}
pet := GetPet(subOrderInfo.PetId)
pet.PetInfo.LastServiceDate = time.Now().Format("2006-01-02 15:04:05")
pet.PetInfo.LastServiceDate = time.Now().Format("2006-01-02")
updateValues := map[string]interface{}{
"LastServiceDate": pet.PetInfo.LastServiceDate,
}

View File

@ -147,7 +147,8 @@ func DataInit() {
zap_server.ZAPLOG.Info("dataInit ServiceAddrMap : ", zap.Any("ServiceAddrMap", ServiceAddrMap))
//--------------------------------------------------宠物商品关联数据---------------------------------------------------------
var petGoodsList []models.PetGoods
database.Instance().Model(&models.PetGoods{}).Find(&petGoodsList)
database.Instance().Model(&models.PetGoods{}).Where("status = 1").Find(&petGoodsList)
zap_server.ZAPLOG.Info("111111", zap.Any("222", petGoodsList))
var PetGoodsMapC1 = make(map[string][]models.PetGoods)
for _, value := range petGoodsList {
key := strconv.Itoa(value.Assortment) + strconv.Itoa(value.PetType) + strconv.Itoa(value.Weight) + strconv.Itoa(value.Hair)
@ -161,7 +162,7 @@ func DataInit() {
zap_server.ZAPLOG.Info("dataInit petGoodsMap : ", zap.Any("petGoodsMap", PetGoodsMap))
//--------------------------------------------------商品数据---------------------------------------------------------
var goodsList []models.Goods
database.Instance().Model(&models.Goods{}).Find(&goodsList)
database.Instance().Model(&models.Goods{}).Where("status = 1").Find(&goodsList)
var GoodsMapC1 = make(map[int64]models.Goods)
for _, value := range goodsList {
GoodsMapC1[value.Id] = value

View File

@ -4,6 +4,7 @@ import (
"github.com/kataras/iris/v12"
"github.com/kataras/iris/v12/context"
"go.uber.org/zap"
"pet-house.com/business/models"
"pet-house.com/business/utils"
"pet-house.com/core/server/database"
"pet-house.com/core/server/web/web_iris"
@ -44,6 +45,7 @@ func ModuleInit() {
//&models.ReserveTimeFilter{},
//&models.OrderServiceRecord{},
//&models.AddrServiceTime{},
&models.UserAmountRecord{},
)
DataInit()
DataCacheJob()

View File

@ -93,17 +93,22 @@ func (p DefParty) orderCreate() web_iris.Party {
UserServiceAddrNotExistError.Fail(ctx, nil)
return
}
//serviceAddr := ServiceAddrMap[orderCreateRequest.ServiceAreaId]
//if serviceAddr.Id == 0 {
// NotInServiceExistError.Fail(ctx, nil)
// return
//}
/*if len(serviceAddr.ServiceArea) > 0 && serviceAddr.ServiceArea != userServiceAddr.AddrArea {
ServiceAddrNotExistError.Fail(ctx, nil)
return
}*/
var projectionServiceTime = 0
for _, value := range orderCreateRequest.PetGoodsInfos {
userPet := GetUserPet(headerBaseInfo.Uid, value.PetId)
var dog = userPet.PetBaseInfo.PetType == 2
var goodsType1 = false
for _, value := range value.GoodsIds {
goods := GoodsMap[value]
if goods.GoodsType == 1 {
goodsType1 = true
break
}
}
if dog && !goodsType1 {
OrderCreateError.DefFail(ctx, orderCreateRequest, "选择美容前提需要选择洗护商品")
return
}
for _, value := range value.GoodsIds {
goods := GoodsMap[value]
if goods.Time != "/" && len(goods.Time) > 0 {
@ -124,6 +129,7 @@ func (p DefParty) orderCreate() web_iris.Party {
return
}
}
var orderTotalAmount = 0
orderLock.Lock()
orderId := NextId.Generate().String()
@ -135,6 +141,7 @@ func (p DefParty) orderCreate() web_iris.Party {
ServiceTime: orderCreateRequest.ServiceTime,
ServiceAddrId: orderCreateRequest.ServiceAddrId,
ServiceRemark: "",
Status: 1,
}
var projectionServiceTimeAll = 0
var orderSubList []models.OrderSub
@ -142,7 +149,7 @@ func (p DefParty) orderCreate() web_iris.Party {
var mainGoods = 0
for _, value := range orderCreateRequest.PetGoodsInfos {
subOrderId := NextId.Generate().String()
var totalAmount int = 0
var totalAmount = 0
var projectionServiceTime = 0
var goodsName string
for _, value := range value.GoodsIds {
@ -171,10 +178,11 @@ func (p DefParty) orderCreate() web_iris.Party {
TotalAmount: totalAmount,
PayAmount: totalAmount,
PetInfo: petInfo,
Status: 1,
//PayTime: time.Now(),
ProjectionServiceTime: projectionServiceTime,
}
orderTotalAmount = orderTotalAmount + int(totalAmount)
orderTotalAmount = orderTotalAmount + totalAmount
orderSubList = append(orderSubList, orderSub)
}
if mainGoods == 0 {
@ -189,8 +197,10 @@ func (p DefParty) orderCreate() web_iris.Party {
if userInfo.Discount > 0 {
discount := float64(userInfo.Discount)
discountAmount = int(utils.RoundToOneDecimalPlace(float64(orderTotalAmount)*(discount/100.0)) * 10)
//discountAmount = int(math.Round(float64(orderTotalAmount)*(discount/100.0)) * 10)
} else {
discountAmount = int(utils.RoundToOneDecimalPlace(float64(orderTotalAmount) * 10))
}
orderMain.TotalAmount = orderTotalAmount
tx := database.Instance().Begin()
var db4 *gorm.DB
@ -208,6 +218,17 @@ func (p DefParty) orderCreate() web_iris.Party {
for index := range orderSubList {
orderSubList[index].PayType = 3
}
userAmountRecord := models.UserAmountRecord{
UserId: userInfo.Id,
Type: 2,
OriginAmount: currAmount,
ProAmount: discountAmount,
CurrAmount: userInfo.Amount,
OrderId: orderId,
ProScene: "下单",
Status: 1,
}
tx.Model(&models.UserAmountRecord{}).Create(&userAmountRecord)
zap_server.ZAPLOG.Info("会员金额扣除", zap.Any("用户ID", userInfo.Id), zap.Any("订单号", orderMain.OrderId), zap.Any("当前余额", currAmount), zap.Any("扣除余额", discountAmount), zap.Any("剩余余额", userInfo.Amount), zap.Any("折扣", userInfo.Discount))
discount := float64(userInfo.Discount)
for index, _ := range orderSubList {
@ -242,9 +263,12 @@ func (p DefParty) orderCreate() web_iris.Party {
func GetOrderDetail(orderId string) OrderDetail {
var orderMain models.OrderMain
database.Instance().Model(&models.OrderMain{}).Where("order_id = ?", orderId).Find(&orderMain)
database.Instance().Model(&models.OrderMain{}).Where("order_id = ? and status = 1", orderId).Find(&orderMain)
var findUserServiceAddr models.UserServiceAddr
database.Instance().Model(&models.UserServiceAddr{}).Where("id = ?", orderMain.ServiceAddrId).Find(&findUserServiceAddr)
var userInfo *models.User
database.Instance().Model(&models.User{}).Where("id = ?", orderMain.Uid).Find(&userInfo)
orderDetail := OrderDetail{
OrderId: orderMain.OrderId,
Status: orderMain.OrderStatus,
@ -258,6 +282,7 @@ func GetOrderDetail(orderId string) OrderDetail {
DiscountAmount: strconv.Itoa(orderMain.TotalAmount),
Discount: float64(orderMain.PayDiscount) / 100,
Uid: orderMain.Uid,
UserAmount: float64(userInfo.Amount) / 10.0,
}
if orderMain.PayDiscount > 0 {
orderDetail.DiscountAmount = strconv.FormatFloat(float64(orderMain.PayTotalAmount)/10.0, 'f', 1, 64)
@ -278,7 +303,7 @@ func GetOrderDetail(orderId string) OrderDetail {
Status: orderSub.OrderStatus,
UserPetInfo: GetUserPet(orderMain.Uid, orderSub.PetId),
TotalAmount: orderSub.TotalAmount,
PayAmount: strconv.Itoa(int(orderSub.PayAmount)),
PayAmount: strconv.Itoa(orderSub.PayAmount),
Discount: float64(orderSub.Discount),
Goods: goods,
}
@ -289,7 +314,7 @@ func GetOrderDetail(orderId string) OrderDetail {
orderSubR1.PayAmount = strconv.FormatFloat(x, 'f', 1, 64)
orderSubR1.DiscountAmount = orderSubR1.PayAmount
} else {
orderSubR1.DiscountAmount = strconv.Itoa(int(orderSubR1.TotalAmount))
orderSubR1.DiscountAmount = strconv.Itoa(orderSubR1.TotalAmount)
}
subOrderList = append(subOrderList, orderSubR1)
}
@ -321,7 +346,7 @@ func checkOrderServiceTime(serviceTime string, projectionServiceTime int) bool {
var orderMainTmpList []orderMainTmp
//服务时间>=预约时间 and 服务时间<=预计结束时间 时间范围内无订单才可预约
database.Instance().Model(&models.OrderMain{}).Where("service_time >= ? and service_time <= DATE_FORMAT(DATE_ADD('"+serviceTime+"', INTERVAL "+strconv.Itoa(projectionServiceTime)+" MINUTE), '%Y-%m-%d %H:%i') and order_status != 3 and order_status != 4", serviceTime).Find(&orderMainTmpList)
database.Instance().Model(&models.OrderMain{}).Where("service_time >= ? and service_time < DATE_FORMAT(DATE_ADD('"+serviceTime+"', INTERVAL "+strconv.Itoa(projectionServiceTime)+" MINUTE), '%Y-%m-%d %H:%i') and order_status != 3 and order_status != 4 and status = 1", serviceTime).Find(&orderMainTmpList)
//时间点订单数量<服务车辆*车辆单次服务数量 才可接受预约
if len(orderMainTmpList) > 0 {
return len(orderMainTmpList) >= len(CarMap)*CarServiceNum
@ -361,6 +386,7 @@ type OrderDetail struct {
TotalAmount int `json:"totalAmount"` //总金额
DiscountAmount string `json:"discountAmount"` //折扣金额
Uid int64 `json:"uid"` //用户ID
UserAmount float64 `json:"userAmount"` //用户余额
}
type OrderListResponse struct {
@ -383,9 +409,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).Offset((orderListRequest.PageNo - 1) * orderListRequest.PageSize).Limit(orderListRequest.PageSize).Order(clause.OrderByColumn{Column: clause.Column{Name: "create_time"}, Desc: true}).Find(&orderList)
database.Instance().Model(&models.OrderMain{}).Where("uid = ? and status = 1", headerBaseInfo.Uid).Offset((orderListRequest.PageNo - 1) * orderListRequest.PageSize).Limit(orderListRequest.PageSize).Order(clause.OrderByColumn{Column: clause.Column{Name: "create_time"}, Desc: true}).Find(&orderList)
} else {
database.Instance().Model(&models.OrderMain{}).Where("uid = ? and status = ?", headerBaseInfo.Uid, orderListRequest.Status).Offset((orderListRequest.PageNo - 1) * orderListRequest.PageSize).Limit(orderListRequest.PageSize).Order(clause.OrderByColumn{Column: clause.Column{Name: "create_time"}, Desc: true}).Find(&orderList)
database.Instance().Model(&models.OrderMain{}).Where("uid = ? and order_status = ? and status = 1", headerBaseInfo.Uid, orderListRequest.Status).Offset((orderListRequest.PageNo - 1) * orderListRequest.PageSize).Limit(orderListRequest.PageSize).Order(clause.OrderByColumn{Column: clause.Column{Name: "create_time"}, Desc: true}).Find(&orderList)
}
var orderDetails []OrderDetail
for _, value := range orderList {
@ -461,7 +487,7 @@ func (p DefParty) orderCancel() web_iris.Party {
var orderCancelRequest OrderCancelRequest
json.Unmarshal(body, &orderCancelRequest)
var orderMain models.OrderMain
database.Instance().Model(&models.OrderMain{}).Where("order_id = ?", orderCancelRequest.OrderId).Find(&orderMain)
database.Instance().Model(&models.OrderMain{}).Where("order_id = ? and status = 1", orderCancelRequest.OrderId).Find(&orderMain)
if orderMain.Uid != headerBaseInfo.Uid {
OrderExistError.Fail(ctx, orderCancelRequest)
return
@ -477,11 +503,23 @@ func (p DefParty) orderCancel() web_iris.Party {
if orderMain.PayStatus == 1 {
var userInfo models.User
database.Instance().Model(&models.User{}).Where("id = ?", orderMain.Uid).Find(&userInfo)
var originAmount = userInfo.Amount
userInfo.Amount = userInfo.Amount + orderMain.PayTotalAmount
updateValues := map[string]interface{}{
"Amount": userInfo.Amount,
}
database.Instance().Model(&userInfo).Updates(&updateValues)
userAmountRecord := models.UserAmountRecord{
UserId: userInfo.Id,
Type: 1,
OriginAmount: originAmount,
ProAmount: orderMain.PayTotalAmount,
CurrAmount: userInfo.Amount,
OrderId: orderMain.OrderId,
ProScene: "用户取消订单",
Status: 1,
}
database.Instance().Model(&models.UserAmountRecord{}).Create(&userAmountRecord)
orderMain.PayTotalAmount = 0
orderMain.PayStatus = 0
}
@ -492,6 +530,14 @@ func (p DefParty) orderCancel() web_iris.Party {
"PayTotalAmount": orderMain.PayTotalAmount,
}
database.Instance().Model(&orderMain).Updates(&updateValues)
var orderSubList []models.OrderSub
database.Instance().Model(&models.OrderSub{}).Where("main_order_id = ? ", orderMain.OrderId).Find(&orderSubList)
for _, orderSub := range orderSubList {
updateValuesSub := map[string]interface{}{
"OrderStatus": 4,
}
database.Instance().Model(&orderSub).Updates(&updateValuesSub)
}
Success(ctx, orderCancelRequest, OrderCancelResponse{GetOrderDetail(orderMain.OrderId)})
})
}}
@ -527,7 +573,7 @@ func (p DefParty) orderServiceTime() web_iris.Party {
ProjectionServiceTime int
}
var orderMainTmpList []orderMainTmp
database.Instance().Model(&models.OrderMain{}).Where("service_time >= DATE_SUB(NOW(), INTERVAL 7 DAY) and order_status != 3 and order_status != 4").Find(&orderMainTmpList)
database.Instance().Model(&models.OrderMain{}).Where("service_time >= DATE_SUB(NOW(), INTERVAL 7 DAY) and order_status != 3 and order_status != 4 and status = 1").Find(&orderMainTmpList)
var orderTimeMap = make(map[string]string)
var orderTimeNum = make(map[string]int)
for _, value := range orderMainTmpList {
@ -586,7 +632,7 @@ func (p DefParty) orderEdit() web_iris.Party {
var orderMain models.OrderMain
var orderSub models.OrderSub
database.Instance().Model(&models.OrderSub{}).Where("order_id = ?", orderEditRequest.OrderId).Find(&orderSub)
database.Instance().Model(&models.OrderMain{}).Where("order_id = ?", orderSub.MainOrderId).Find(&orderMain)
database.Instance().Model(&models.OrderMain{}).Where("order_id = ? and status = 1", orderSub.MainOrderId).Find(&orderMain)
if orderMain.Uid != headerBaseInfo.Uid {
OrderError.Fail(ctx, orderEditRequest)
return
@ -649,26 +695,27 @@ func (p DefParty) orderGoodsUpdate() web_iris.Party {
return
}
var orderMain models.OrderMain
database.Instance().Model(&models.OrderMain{}).Where("order_id = ?", orderSub.MainOrderId).Find(&orderMain)
database.Instance().Model(&models.OrderMain{}).Where("order_id = ? and status = 1", orderSub.MainOrderId).Find(&orderMain)
var totalAmount = 0
var projectionServiceTime = 0
for _, value := range orderGoodsUpdateRequest.GoodsIds {
goods := GoodsMap[value]
totalAmount = totalAmount + int(goods.Price)
totalAmount = totalAmount + goods.Price
if goods.Time != "/" && len(goods.Time) > 0 {
goodsTime, _ := strconv.Atoi(goods.Time)
projectionServiceTime += goodsTime
}
}
var originOrderAmount = orderSub.PayAmount
//非当前订单
var orderSubList []models.OrderSub
database.Instance().Model(&models.OrderSub{}).Where("main_order_id = ? and order_id != ", orderMain.OrderId, orderGoodsUpdateRequest.OrderId).Find(&orderSubList)
database.Instance().Model(&models.OrderSub{}).Where("main_order_id = ? and order_id != ?", orderMain.OrderId, orderGoodsUpdateRequest.OrderId).Find(&orderSubList)
//新价格
var newAmount = totalAmount
var allProjectionServiceTime = projectionServiceTime
for _, value := range orderSubList {
newAmount = newAmount + int(value.TotalAmount)
newAmount = newAmount + value.TotalAmount
allProjectionServiceTime = allProjectionServiceTime + value.ProjectionServiceTime
}
@ -689,6 +736,17 @@ func (p DefParty) orderGoodsUpdate() web_iris.Party {
OrderUpdateBalanceNotEnough.DefFail(ctx, orderGoodsUpdateRequest, "原订单金额:"+strconv.FormatFloat(float64(orderMain.PayTotalAmount)/10, 'f', 1, 64)+" 修改后订单金额:"+strconv.FormatFloat(float64(newAmount)/10, 'f', 1, 64)+";修改服务项目后余额不足,请充值后再支付")
return
}
var amountType = 2
var proAmount = 0
//原始价格小于新价格 扣,原始价格大于新价格 加
if originOrderAmount < newAmount {
proAmount = newAmount - originOrderAmount
} else {
amountType = 1
proAmount = originOrderAmount - newAmount
}
var originAmount = userInfo.Amount
var preAmount = orderMain.PayTotalAmount
userInfo.Amount = userInfo.Amount - newAmount
@ -698,6 +756,17 @@ func (p DefParty) orderGoodsUpdate() web_iris.Party {
}
database.Instance().Model(&userInfo).Updates(&updateValues)
orderMain.PayDiscount = userInfo.Discount
userAmountRecord := models.UserAmountRecord{
UserId: userInfo.Id,
Type: amountType,
OriginAmount: originAmount,
ProAmount: proAmount,
CurrAmount: userInfo.Amount,
OrderId: orderMain.OrderId,
ProScene: "修改订单服务项目",
Status: 1,
}
database.Instance().Model(&models.UserAmountRecord{}).Create(&userAmountRecord)
zap_server.ZAPLOG.Info("会员金额扣除", zap.Any("用户ID", userInfo.Id), zap.Any("订单ID", orderMain.OrderId), zap.Any("用户修改之前余额", originAmount), zap.Any("当前余额", userInfo.Amount), zap.Any("商品修改之前金额", preAmount), zap.Any("商品修改之后金额", orderMain.PayTotalAmount), zap.Any("折扣", userInfo.Discount))
}
}

View File

@ -23,8 +23,8 @@ var DogWeightMap = map[int]string{
3: "6-9kg",
4: "9-13kg",
5: "13-18kg",
//6: "18-22kg",
//7: "22-30kg",
6: "18-22kg",
7: "22-30kg",
}
type UserPetInfo struct {
@ -46,13 +46,13 @@ func GetUserPets(uId int64) []UserPetInfo {
func GetUserPet(uId int64, pId int64) UserPetInfo {
var userPet models.Pet
database.Instance().Model(&models.Pet{}).Where("uid = ? and id = ? and status = 1", uId, pId).Find(&userPet)
database.Instance().Model(&models.Pet{}).Where("uid = ? and id = ?", uId, pId).Find(&userPet)
return UserPetInfo{userPet, PetBaseInfoMap[userPet.PetId]}
}
func GetPet(pId int64) UserPetInfo {
var userPet models.Pet
database.Instance().Model(&models.Pet{}).Where("id = ? and status = 1", pId).Find(&userPet)
database.Instance().Model(&models.Pet{}).Where("id = ?", pId).Find(&userPet)
return UserPetInfo{userPet, PetBaseInfoMap[userPet.PetId]}
}
@ -138,6 +138,7 @@ func (p DefParty) petAddOrEdit() web_iris.Party {
PetId: petAddOrEditRequest.PetId,
Eunuch: petAddOrEditRequest.Eunuch,
Vaccine: petAddOrEditRequest.Vaccine,
Status: 1,
}
if petAddOrEditRequest.Id == 0 {
database.Instance().Model(&models.Pet{}).Create(&pet)
@ -224,10 +225,10 @@ func (p DefParty) delPet() web_iris.Party {
return
}
updateValues := map[string]interface{}{
"Status": 0,
"Status": 3,
}
database.Instance().Model(&userPetInfo).Updates(&updateValues)
Success(ctx, nil, nil)
Success(ctx, delPetRequest, nil)
})
}}
}

View File

@ -19,6 +19,7 @@ type User struct {
Role int `json:"role"` //用户角色 0普通用户 1护理人员
Discount int `json:"discount"` //折扣
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP;not null" json:"createTime"` //创建时间
Status int `json:"status"` //信息状态
}
// Pet 宠物信息
@ -39,7 +40,7 @@ type Pet struct {
LastServiceProj string `gorm:"default:'-'" json:"lastServiceProj"` //上次服务项目
LastServiceDate string `gorm:"default:'-'" json:"lastServiceDate"` //上次服务时间
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP;not null" json:"createTime"` //创建时间
Status int `gorm:"default:1" json:"status"` //信息状态
Status int `json:"status"` //信息状态
}
// PetBaseInfo 宠物基础信息
@ -50,6 +51,7 @@ type PetBaseInfo struct {
Size int `gorm:"not null" json:"size"` //大小 1大 2中 3小
Hair int `gorm:"not null" json:"hair"` //毛发 0未知 1长毛 2短毛
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
Status int `json:"status"` //信息状态
}
// ServiceAddr 服务地址
@ -60,6 +62,7 @@ type ServiceAddr struct {
Addr string `gorm:"not null" json:"addr"` //详细地址
DistantGapMeters int64 `gorm:"not null" json:"distantGapMeters"` //服务最远距离 单位/米
ServiceArea string `json:"serviceArea"` //服务区域
Status int `json:"status"` //信息状态
}
// UserServiceAddr 用户服务地址
@ -75,6 +78,7 @@ type UserServiceAddr struct {
Area string `gorm:"-" json:"area"` //服务区域
AddrArea string `json:"addrArea"` //地址区域
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP;not null" json:"-"` //创建时间
Status int `json:"status"` //信息状态
}
// Goods 商品信息
@ -89,6 +93,7 @@ type Goods struct {
GoodsDetail string `gorm:"not null" json:"goodsDetail"` //商品详情 图片URL
GoodsIcon string `json:"goodsIcon"` //iconUrl
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
Status int `json:"status"` //信息状态
}
// PetGoods 宠物商品
@ -102,6 +107,7 @@ type PetGoods struct {
GoodsId int64 `gorm:"not null" json:"goodsId"` //商品ID
Sort int `gorm:"not null" json:"sort"` //排序
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
Status int `json:"status"` //信息状态
}
// SystemConfig 系统配置
@ -133,7 +139,8 @@ type OrderMain struct {
PayTotalAmount int `json:"payTotalAmount"` //支付总金额
TotalAmount int `json:"totalAmount"` //总金额
PayDiscount int `gorm:"default:0" json:"payDiscount"` //支付折扣
PayType int `gorm:"default:1" json:"payType"` //支付方式 1线下 2线上 3会员余额
PayType int `json:"payType"` //支付方式 1线下 2线上 3会员余额
Status int `json:"status1"` //信息状态
}
// OrderSub 子订单
@ -154,6 +161,7 @@ type OrderSub struct {
PetInfo string `json:"petInfo"` //宠物快照信息
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:"-"` //更新时间
Status int `json:"status1"`
}
// OrderDetail 订单明细
@ -173,6 +181,20 @@ type OrderServiceRecord struct {
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"createTime"` //创建时间
}
type UserAmountRecord struct {
Id int64 `gorm:"primaryKey;autoIncrement" json:"id"` //id
UserId int64 `gorm:"index:not null" json:"userId"` //用户ID
Type int `gorm:"not null" json:"type"` //操作类型 1加 2扣
OriginAmount int `gorm:"not null" json:"originAmount"` //原始余额
ProAmount int `gorm:"not null" json:"proAmount"` //操作余额
CurrAmount int `gorm:"not null" json:"currAmount"` //剩余余额
ProScene string `gorm:"not null" json:"proScene"` //操作场景
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"createTime"` //创建时间
CreateDate time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"createDate"` //创建时间
Status int `json:"status"` //信息状态
OrderId string `json:"orderId"` //订单ID
}
// ServiceCar 服务车辆
type ServiceCar struct {
Id int `gorm:"primaryKey;autoIncrement" json:"id"` //id