This commit is contained in:
yan.y
2024-06-02 22:35:40 +08:00
parent b8fb0c8ee8
commit e05bf0ff48
5 changed files with 69 additions and 21 deletions
+9 -10
View File
@@ -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)
+1 -1
View File
@@ -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
+17 -6
View File
@@ -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,