diff --git a/business/api/car.go b/business/api/car.go index f43837b..7456e07 100644 --- a/business/api/car.go +++ b/business/api/car.go @@ -63,7 +63,7 @@ func (p DefParty) carServiceOrderList() web_iris.Party { type CarServiceProcessRequest struct { Type int //操作类型 1开始 2结束 SubOrderId string //子订单ID - PayAmount int32 //实际支付金额 + PayAmount int //实际支付金额 PayRemark string //支付备注 FileName string //拍照文件 } @@ -109,16 +109,18 @@ func (p DefParty) carServiceProcess() web_iris.Party { 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 } - if carServiceProcessRequest.PayAmount > 0 { - subOrderInfo.TotalAmount = carServiceProcessRequest.PayAmount - subOrderInfo.PayTime = time.Now() - subOrderInfo.PayStatus = 1 - } subOrderInfo.OrderStatus = 2 mainOrder.OrderStatus = 2 database.Instance().Save(&mainOrder) @@ -131,9 +133,6 @@ func (p DefParty) carServiceProcess() web_iris.Party { subOrderInfo.OrderStatus = 3 subOrderInfo.PayStatus = 1 subOrderInfo.PayTime = time.Now() - if carServiceProcessRequest.PayAmount > 0 { - subOrderInfo.TotalAmount = carServiceProcessRequest.PayAmount - } subOrderInfo.PayRemark = carServiceProcessRequest.PayRemark database.Instance().Save(&subOrderInfo) var count int64 @@ -155,7 +154,7 @@ func (p DefParty) carServiceProcess() web_iris.Party { updateValues := map[string]interface{}{ "LastServiceDate": pet.PetInfo.LastServiceDate, } - database.Instance().Model(&models.Pet{}).Updates(&updateValues) + database.Instance().Model(&pet.PetInfo).Updates(&updateValues) } else if carServiceProcessRequest.Type == 3 { subOrderInfo.PayRemark = carServiceProcessRequest.PayRemark database.Instance().Save(&subOrderInfo) diff --git a/business/api/goods.go b/business/api/goods.go index b1a3bdd..a64e4b6 100644 --- a/business/api/goods.go +++ b/business/api/goods.go @@ -22,7 +22,7 @@ type GoodsDetail struct { Name string `json:"name"` //商品名称 GoodsType int `json:"goodsType"` //商品类型 1基础服务 2附加产品 3附加服务 Time string `json:"time"` //时间 - Price int32 `json:"price"` //价格 + Price int `json:"price"` //价格 ParentId int64 `json:"parentId"` //商品父ID BuyMany int `json:"buyMany"` //同类型是否可购买多个 0否 1是 GoodsDetail string `json:"goodsDetail"` //商品详情 图片URL diff --git a/business/api/order.go b/business/api/order.go index 5855a74..d2eb4ce 100644 --- a/business/api/order.go +++ b/business/api/order.go @@ -114,7 +114,7 @@ func (p DefParty) orderCreate() web_iris.Party { } haveReserve := checkOrderServiceTime(orderCreateRequest.ServiceTime, projectionServiceTime) if haveReserve { - OrderCreateError.DefFail(ctx, orderCreateRequest, "当前订单预估服务时长预计:"+strconv.Itoa(projectionServiceTime)+"分钟,服务时间过长,请更换时间段预约") + OrderCreateError.DefFail(ctx, orderCreateRequest, "当前订单预估服务时长预计:"+strconv.Itoa(projectionServiceTime)+"分钟,服务时间过长,请更换时间段预约或联系客服协助预约") return } for _, value := range orderCreateRequest.PetGoodsInfos { @@ -142,7 +142,7 @@ func (p DefParty) orderCreate() web_iris.Party { var mainGoods = 0 for _, value := range orderCreateRequest.PetGoodsInfos { subOrderId := NextId.Generate().String() - var totalAmount int32 = 0 + var totalAmount int = 0 var projectionServiceTime = 0 var goodsName string for _, value := range value.GoodsIds { @@ -179,6 +179,7 @@ func (p DefParty) orderCreate() web_iris.Party { } if mainGoods == 0 { OrderCreateError.DefFail(ctx, orderCreateRequest, "订单未选择主商品,创建失败") + orderLock.Unlock() return } orderMain.ProjectionServiceTime = projectionServiceTimeAll @@ -212,7 +213,7 @@ func (p DefParty) orderCreate() web_iris.Party { for index, _ := range orderSubList { orderSubList[index].Discount = userInfo.Discount //orderSubList[index].PayAmount = int32(math.Round(float64(orderSubList[index].TotalAmount) * (discount / 100.0))) - orderSubList[index].PayAmount = int32(utils.RoundToOneDecimalPlace(float64(orderSubList[index].TotalAmount)*(discount/100.0)) * 10) + orderSubList[index].PayAmount = int(utils.RoundToOneDecimalPlace(float64(orderSubList[index].TotalAmount)*(discount/100.0)) * 10) } } var findUserServiceAddr models.UserServiceAddr @@ -256,6 +257,7 @@ func GetOrderDetail(orderId string) OrderDetail { TotalAmount: orderMain.TotalAmount, DiscountAmount: strconv.Itoa(orderMain.TotalAmount), Discount: float64(orderMain.PayDiscount) / 100, + Uid: orderMain.Uid, } if orderMain.PayDiscount > 0 { orderDetail.DiscountAmount = strconv.FormatFloat(float64(orderMain.PayTotalAmount)/10.0, 'f', 1, 64) @@ -308,6 +310,14 @@ func checkOrderServiceTime(serviceTime string, projectionServiceTime int) bool { ServiceTime string ProjectionServiceTime int } + serviceTimeD, _ := time.Parse("2006-01-02 15:04", serviceTime) + hour := serviceTimeD.Hour() + if hour == 20 && projectionServiceTime > 2*60 { + return true + } + if hour == 21 && projectionServiceTime > 1*60 { + return true + } var orderMainTmpList []orderMainTmp //服务时间>=预约时间 and 服务时间<=预计结束时间 时间范围内无订单才可预约 @@ -329,7 +339,7 @@ type SubOrder struct { OrderId string `json:"orderId"` //子订单ID Status int `json:"status"` //子订单状态 0待派单 1待服务 2服务中 3已完成 4已取消 UserPetInfo UserPetInfo `json:"userPetInfo"` //用户宠物信息 - TotalAmount int32 `json:"totalAmount"` //总金额 + TotalAmount int `json:"totalAmount"` //总金额 PayAmount string `json:"payAmount"` //实际支付金额 DiscountAmount string `json:"discountAmount"` //折扣金额 Discount float64 `json:"discount"` //用户折扣 @@ -350,6 +360,7 @@ type OrderDetail struct { Discount float64 `json:"discount"` //用户折扣 TotalAmount int `json:"totalAmount"` //总金额 DiscountAmount string `json:"discountAmount"` //折扣金额 + Uid int64 `json:"uid"` //用户ID } type OrderListResponse struct { @@ -702,8 +713,8 @@ func (p DefParty) orderGoodsUpdate() web_iris.Party { database.Instance().Model(&models.OrderDetail{}).Create(&orderDetail) } - orderSub.TotalAmount = int32(totalAmount) - orderSub.PayAmount = int32(newAmount) + orderSub.TotalAmount = totalAmount + orderSub.PayAmount = newAmount orderSub.ProjectionServiceTime = projectionServiceTime updateValues := map[string]interface{}{ "TotalAmount": orderSub.TotalAmount, diff --git a/business/doc/sql_bak.sql b/business/doc/sql_bak.sql new file mode 100644 index 0000000..4bf7bc3 --- /dev/null +++ b/business/doc/sql_bak.sql @@ -0,0 +1,38 @@ +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (54, '指甲修剪', '30', 4, 10, 0, 1, '指甲修剪', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/局部修剪.png', 1, '2024-04-30 17:03:34', '2024-04-30 17:03:37'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (55, '耳道修剪', '30', 4, 10, 0, 1, '耳道修剪', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/局部修剪.png', 1, '2024-04-30 17:03:34', '2024-04-30 17:03:37'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (56, '刷牙', '30', 4, 15, 0, 1, '刷牙', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/局部修剪.png', 1, '2024-04-30 17:03:34', '2024-04-30 17:03:37'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (59, 'B级半手剪', '60', 2, 80, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (60, 'B级半手剪', '60', 2, 100, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (61, 'B级半手剪', '60', 2, 120, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (62, 'B级半手剪', '60', 2, 150, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (63, 'B级半手剪', '60', 2, 180, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (64, 'B级半手剪', '60', 2, 220, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (65, 'B级半手剪', '60', 2, 280, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (66, 'B级纯手剪', '90', 2, 100, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (67, 'B级纯手剪', '90', 2, 120, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (68, 'B级纯手剪', '90', 2, 150, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (69, 'B级纯手剪', '90', 2, 180, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (70, 'B级纯手剪', '90', 2, 220, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (71, 'B级纯手剪', '90', 2, 280, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (72, 'B级纯手剪', '90', 2, 360, 0, 0, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/造型修剪.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (117, '指甲修剪', '30', 4, 10, 0, 1, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/臻享洗护.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (118, '耳道修剪', '30', 4, 10, 0, 1, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/臻享洗护.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); +INSERT INTO pet_house.goods (id, name, time, goods_type, price, parent_id, buy_many, goods_detail, create_time, goods_icon, status, create_date, update_date) VALUES (119, '刷牙', '30', 4, 15, 0, 1, '无', '2024-04-30 17:04:15', 'https://test-pet-house.ifish7.com/static/img/臻享洗护.png', 1, '2024-04-30 17:04:15', '2024-04-30 17:04:15'); + + +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (55, 0, 1, 0, 54, '2024-05-04 20:09:53', 0, 0, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (56, 0, 1, 0, 55, '2024-05-04 20:09:53', 0, 0, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (57, 0, 1, 0, 56, '2024-05-04 20:09:53', 0, 0, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (60, 0, 2, 0, 59, '2024-05-04 20:13:05', 0, 1, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (61, 0, 2, 0, 60, '2024-05-04 20:13:05', 0, 2, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (62, 0, 2, 0, 61, '2024-05-04 20:13:05', 0, 3, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (63, 0, 2, 0, 62, '2024-05-04 20:13:05', 0, 4, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (64, 0, 2, 0, 63, '2024-05-04 20:13:05', 0, 5, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (65, 0, 2, 0, 66, '2024-05-04 20:15:01', 0, 1, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (66, 0, 2, 0, 67, '2024-05-04 20:15:01', 0, 2, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (67, 0, 2, 0, 68, '2024-05-04 20:15:01', 0, 3, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (68, 0, 2, 0, 69, '2024-05-04 20:15:01', 0, 4, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (69, 0, 2, 0, 70, '2024-05-04 20:15:01', 0, 5, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (111, 0, 2, 0, 117, '2024-05-04 21:02:19', 0, 0, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (112, 0, 2, 0, 118, '2024-05-04 21:02:20', 0, 0, 1, 0); +INSERT INTO pet_house.pet_goods (id, assortment, pet_type, size, goods_id, create_time, sort, weight, status, hair) VALUES (113, 0, 2, 0, 119, '2024-05-04 21:02:20', 0, 0, 1, 0); diff --git a/business/models/dataModel.go b/business/models/dataModel.go index 1a743c1..cd34454 100644 --- a/business/models/dataModel.go +++ b/business/models/dataModel.go @@ -83,7 +83,7 @@ type Goods struct { Name string `gorm:"not null" json:"name"` //商品名称 GoodsType int `gorm:"not null" json:"goodsType"` //商品类型 1基础服务 2附加产品 3附加服务 Time string `json:"time"` //时间 - Price int32 `gorm:"not null" json:"price"` //价格 + Price int `gorm:"not null" json:"price"` //价格 ParentId int64 `gorm:"not null" json:"parentId"` //商品父ID BuyMany int `gorm:"not null" json:"buyMany"` //同类型是否可购买多个 0否 1是 GoodsDetail string `gorm:"not null" json:"goodsDetail"` //商品详情 图片URL @@ -145,10 +145,10 @@ type OrderSub struct { PetId int64 `gorm:"index" json:"petId"` //宠物ID PayType int `gorm:"not null" json:"payType"` //支付方式 1线下 2线上 3会员余额 Discount int `json:"discount"` //折扣 - TotalAmount int32 `gorm:"not null" json:"totalAmount"` //总金额 + TotalAmount int `gorm:"not null" json:"totalAmount"` //总金额 ProjectionServiceTime int `json:"projectionServiceTime"` //服务预估时长 PayStatus int `gorm:"default:0" json:"payStatus"` //支付状态 0未支付 1已支付 - PayAmount int32 `json:"payAmount"` //实际支付金额 + PayAmount int `json:"payAmount"` //实际支付金额 PayTime time.Time `gorm:"type:timestamp;" json:"payTime"` //支付时间 PayRemark string `json:"payRemark"` //支付备注 PetInfo string `json:"petInfo"` //宠物快照信息 @@ -161,7 +161,7 @@ type OrderDetail struct { Id int64 `gorm:"primaryKey;autoIncrement" json:"id"` //id SubOrderId string `gorm:"index;not null" json:"subOrderId"` //子订单ID GoodsId int64 `gorm:"index;not null" json:"goodsId"` //商品ID - Amount int32 `gorm:"not null" json:"amount"` //价格 + Amount int `gorm:"not null" json:"amount"` //价格 } // OrderServiceRecord 订单服务记录