接口更新
This commit is contained in:
parent
6da775c9bd
commit
ce1a74983a
|
|
@ -2,12 +2,14 @@ package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"github.com/kataras/iris/v12"
|
"github.com/kataras/iris/v12"
|
||||||
"github.com/kataras/iris/v12/context"
|
"github.com/kataras/iris/v12/context"
|
||||||
"gorm.io/gorm/clause"
|
"gorm.io/gorm/clause"
|
||||||
"io"
|
"io"
|
||||||
"pet-house.com/business/models"
|
"pet-house.com/business/models"
|
||||||
"pet-house.com/core/server/database"
|
"pet-house.com/core/server/database"
|
||||||
|
"pet-house.com/core/server/web"
|
||||||
"pet-house.com/core/server/web/web_iris"
|
"pet-house.com/core/server/web/web_iris"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
@ -69,7 +71,9 @@ type CarServiceProcessRequest struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type CarServiceProcessResponse struct {
|
type CarServiceProcessResponse struct {
|
||||||
OrderDetail OrderDetail `json:"orderDetail"`
|
OrderDetail OrderDetail `json:"orderDetail"` //订单详情
|
||||||
|
Desc string `json:"desc"` //支付描述
|
||||||
|
PayImgUrl string `json:"payImgUrl"` //支付二维码
|
||||||
}
|
}
|
||||||
|
|
||||||
// 服务处理
|
// 服务处理
|
||||||
|
|
@ -121,6 +125,8 @@ func (p DefParty) carServiceProcess() web_iris.Party {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
desc := ""
|
||||||
|
payImgUrl := ""
|
||||||
|
|
||||||
var orderUserInfo *models.User
|
var orderUserInfo *models.User
|
||||||
database.Instance().Model(&models.User{}).Where("id = ?", mainOrder.Uid).Find(&orderUserInfo)
|
database.Instance().Model(&models.User{}).Where("id = ?", mainOrder.Uid).Find(&orderUserInfo)
|
||||||
|
|
@ -236,8 +242,16 @@ func (p DefParty) carServiceProcess() web_iris.Party {
|
||||||
FilePath: carServiceProcessRequest.FileName,
|
FilePath: carServiceProcessRequest.FileName,
|
||||||
Type: carServiceProcessRequest.Type,
|
Type: carServiceProcessRequest.Type,
|
||||||
})
|
})
|
||||||
|
var payOrder *models.PayOrder
|
||||||
|
database.Instance().Model(&models.PayOrder{}).Where("order_id = ?", mainOrder.PayOrderId).Find(&payOrder)
|
||||||
|
//已支付成功且主订单未支付
|
||||||
|
if payOrder.Id == 0 || payOrder.OrderStatus == 0 {
|
||||||
|
payPrice := subOrderInfo.PayAmount
|
||||||
|
desc = "您还需支付" + fmt.Sprintf("%.1f", float64(payPrice)/10.0)
|
||||||
|
payImgUrl = web.CONFIG.System.Domain + "/static/img/pay.png"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Success(ctx, carServiceProcessRequest, CarServiceProcessResponse{GetOrderDetail(mainOrder.OrderId)})
|
Success(ctx, carServiceProcessRequest, CarServiceProcessResponse{GetOrderDetail(mainOrder.OrderId), desc, payImgUrl})
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"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"
|
||||||
|
|
@ -39,7 +40,7 @@ type OrderCreateResponse struct {
|
||||||
type OrderCreatePreCheckResponse struct {
|
type OrderCreatePreCheckResponse struct {
|
||||||
HasAlert bool `json:"hasAlert"` //是否弹窗提示 返回false直接下单,返回ture弹出确认框,确认框点击是之后调用下单接口
|
HasAlert bool `json:"hasAlert"` //是否弹窗提示 返回false直接下单,返回ture弹出确认框,确认框点击是之后调用下单接口
|
||||||
AlertMsg string `json:"alertMsg"` //弹窗消息
|
AlertMsg string `json:"alertMsg"` //弹窗消息
|
||||||
PayType int `json:"payType"` //扣款消息
|
PayType int `json:"payType"` //扣款类型
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p DefParty) orderCreatePreCheck() web_iris.Party {
|
func (p DefParty) orderCreatePreCheck() web_iris.Party {
|
||||||
|
|
@ -87,6 +88,7 @@ func (p DefParty) orderCreatePreCheck() web_iris.Party {
|
||||||
}
|
}
|
||||||
orderCreatePreCheckResponse := OrderCreatePreCheckResponse{
|
orderCreatePreCheckResponse := OrderCreatePreCheckResponse{
|
||||||
HasAlert: false,
|
HasAlert: false,
|
||||||
|
PayType: 0,
|
||||||
}
|
}
|
||||||
if userInfo.Discount > 0 {
|
if userInfo.Discount > 0 {
|
||||||
discount := float64(userInfo.Discount)
|
discount := float64(userInfo.Discount)
|
||||||
|
|
@ -96,12 +98,10 @@ func (p DefParty) orderCreatePreCheck() web_iris.Party {
|
||||||
orderCreatePreCheckResponse.HasAlert = true
|
orderCreatePreCheckResponse.HasAlert = true
|
||||||
orderCreatePreCheckResponse.AlertMsg = "您的会员余额不够,需要进行线下支付,当前订单将不享受会员折扣优惠价格"
|
orderCreatePreCheckResponse.AlertMsg = "您的会员余额不够,需要进行线下支付,当前订单将不享受会员折扣优惠价格"
|
||||||
orderCreatePreCheckResponse.PayType = 0
|
orderCreatePreCheckResponse.PayType = 0
|
||||||
|
} else {
|
||||||
|
orderCreatePreCheckResponse.PayType = 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//订金使用余额支付
|
|
||||||
if userInfo.Amount > 300 {
|
|
||||||
orderCreatePreCheckResponse.PayType = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
Success(ctx, orderCreateRequest, orderCreatePreCheckResponse)
|
Success(ctx, orderCreateRequest, orderCreatePreCheckResponse)
|
||||||
})
|
})
|
||||||
|
|
@ -340,20 +340,31 @@ func (p DefParty) orderCreate() web_iris.Party {
|
||||||
ProScene: "下单",
|
ProScene: "下单",
|
||||||
Status: 1,
|
Status: 1,
|
||||||
}
|
}
|
||||||
|
price := 0.0
|
||||||
for index_, orderSub := range orderSubList {
|
for index_, orderSub := range orderSubList {
|
||||||
if userInfo.Discount > 0 {
|
if userInfo.Discount > 0 {
|
||||||
discount := float64(userInfo.Discount)
|
discount := float64(userInfo.Discount)
|
||||||
discountAmount1 := int(utils.RoundToOneDecimalPlace(float64(orderSub.GoodsOriginAmount)*(discount/100.0)) * 10)
|
discountAmount1 := int(utils.RoundToOneDecimalPlace(float64(orderSub.GoodsOriginAmount)*(discount/100.0)) * 10)
|
||||||
orderSubList[index_].PayAmount = discountAmount1 + orderSub.GoodsDiscountAmount
|
orderSubList[index_].PayAmount = discountAmount1 + orderSub.GoodsDiscountAmount
|
||||||
}
|
}
|
||||||
|
price = price + float64(orderSub.PayAmount)
|
||||||
}
|
}
|
||||||
tx.Model(&models.UserAmountRecord{}).Create(&userAmountRecord)
|
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+orderGoodsDiscountAmount), zap.Any("剩余余额", userInfo.Amount), zap.Any("折扣", userInfo.Discount), zap.Any("优惠券折扣信息", coupons))
|
zap_server.ZAPLOG.Info("会员金额扣除", zap.Any("用户ID", userInfo.Id), zap.Any("订单号", orderMain.OrderId), zap.Any("当前余额", currAmount), zap.Any("扣除余额", discountAmount+orderGoodsDiscountAmount), zap.Any("剩余余额", userInfo.Amount), zap.Any("折扣", userInfo.Discount), zap.Any("优惠券折扣信息", coupons))
|
||||||
for index_, _ := range orderSubList {
|
for index_, _ := range orderSubList {
|
||||||
orderSubList[index_].Discount = userInfo.Discount
|
orderSubList[index_].Discount = userInfo.Discount
|
||||||
//orderSubList[index].PayAmount = int32(math.Round(float64(orderSubList[index].TotalAmount) * (discount / 100.0)))
|
|
||||||
//orderSubList[index].PayAmount = discountAmount + orderGoodsDiscountAmount
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
payOrder := models.PayOrder{
|
||||||
|
OrderId: orderId,
|
||||||
|
OrderName: "宠物洗护付款(会员余额)-" + orderMain.OrderId,
|
||||||
|
OrderPrice: fmt.Sprintf("%.1f", price),
|
||||||
|
RechargeId: 0,
|
||||||
|
PayId: "",
|
||||||
|
Uid: headerBaseInfo.Uid,
|
||||||
|
OrderStatus: 3,
|
||||||
|
}
|
||||||
|
database.Instance().Model(&models.PayOrder{}).Create(&payOrder)
|
||||||
} else {
|
} else {
|
||||||
userAmountRecord := models.UserAmountRecord{
|
userAmountRecord := models.UserAmountRecord{
|
||||||
UserId: userInfo.Id,
|
UserId: userInfo.Id,
|
||||||
|
|
@ -793,8 +804,33 @@ func (p DefParty) orderServiceTime() web_iris.Party {
|
||||||
}
|
}
|
||||||
var orderMainTmpList []orderMainTmp
|
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 and status = 1").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 orderMainTmp1 []struct {
|
||||||
|
ServiceTime string
|
||||||
|
Count int
|
||||||
|
}
|
||||||
|
err := database.Instance().Raw(`
|
||||||
|
SELECT service_time, COUNT(1) AS count
|
||||||
|
FROM order_mains
|
||||||
|
WHERE service_time >= DATE_SUB(NOW(), INTERVAL 7 DAY)
|
||||||
|
AND order_status != 3
|
||||||
|
AND order_status != 4
|
||||||
|
AND status = 1
|
||||||
|
GROUP BY service_time
|
||||||
|
HAVING count > 0
|
||||||
|
`).Scan(&orderMainTmp1).Error
|
||||||
|
if err != nil {
|
||||||
|
ServerError.Fail(ctx, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
var orderTimeMap = make(map[string]string)
|
var orderTimeMap = make(map[string]string)
|
||||||
var orderTimeNum = make(map[string]int)
|
var orderTimeNum = make(map[string]int)
|
||||||
|
var orderTimeCount = make(map[string]int)
|
||||||
|
for _, val := range orderMainTmp1 {
|
||||||
|
orderTimeCount[val.ServiceTime] = val.Count
|
||||||
|
}
|
||||||
|
|
||||||
for _, value := range orderMainTmpList {
|
for _, value := range orderMainTmpList {
|
||||||
orderTimeMap[value.ServiceTime] = value.ServiceTime
|
orderTimeMap[value.ServiceTime] = value.ServiceTime
|
||||||
orderTimeNum[value.ServiceTime] = orderTimeNum[value.ServiceTime] + 1
|
orderTimeNum[value.ServiceTime] = orderTimeNum[value.ServiceTime] + 1
|
||||||
|
|
@ -812,7 +848,7 @@ func (p DefParty) orderServiceTime() web_iris.Party {
|
||||||
serviceTime := AddrServiceMap[orderServiceTimeRequest.ServiceAddrId]
|
serviceTime := AddrServiceMap[orderServiceTimeRequest.ServiceAddrId]
|
||||||
times := strings.Split(serviceTime.Times, ",")
|
times := strings.Split(serviceTime.Times, ",")
|
||||||
carNum := len(CarMap)
|
carNum := len(CarMap)
|
||||||
daysMap := utils.GetStrDays(7, 60, ReserveMap, orderTimeMap, carNum, orderTimeNum, CarServiceNum, times)
|
daysMap := utils.GetStrDays(7, 60, ReserveMap, orderTimeMap, carNum, orderTimeNum, CarServiceNum, times, orderTimeCount)
|
||||||
var dayHoursMap = make(map[string][]TimeObject)
|
var dayHoursMap = make(map[string][]TimeObject)
|
||||||
for day, values := range daysMap {
|
for day, values := range daysMap {
|
||||||
key := day
|
key := day
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package api
|
||||||
import (
|
import (
|
||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"github.com/kataras/iris/v12"
|
"github.com/kataras/iris/v12"
|
||||||
"github.com/kataras/iris/v12/context"
|
"github.com/kataras/iris/v12/context"
|
||||||
"github.com/wechatpay-apiv3/wechatpay-go/core"
|
"github.com/wechatpay-apiv3/wechatpay-go/core"
|
||||||
|
|
@ -34,7 +35,8 @@ func (p DefParty) rechargeInfoList() web_iris.Party {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ToPayRequest struct {
|
type ToPayRequest struct {
|
||||||
PayId int //支付ID
|
PayId int //支付ID
|
||||||
|
OrderId string //订单号
|
||||||
}
|
}
|
||||||
|
|
||||||
type ToPayResponse struct {
|
type ToPayResponse struct {
|
||||||
|
|
@ -54,21 +56,59 @@ func (p DefParty) toPay() web_iris.Party {
|
||||||
json.Unmarshal(body, &toPayRequest)
|
json.Unmarshal(body, &toPayRequest)
|
||||||
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)
|
||||||
var rechargeInfo *models.RechargeInfo
|
price := 0.0
|
||||||
database.Instance().Model(&models.RechargeInfo{}).Where("id = ?", toPayRequest.PayId).Find(&rechargeInfo)
|
desc := "充值"
|
||||||
|
id := 0
|
||||||
|
if len(toPayRequest.OrderId) == 0 {
|
||||||
|
var rechargeInfo *models.RechargeInfo
|
||||||
|
database.Instance().Model(&models.RechargeInfo{}).Where("id = ?", toPayRequest.PayId).Find(&rechargeInfo)
|
||||||
|
price1, _ := strconv.ParseFloat(rechargeInfo.Price, 64)
|
||||||
|
price = price1
|
||||||
|
desc = rechargeInfo.Name
|
||||||
|
id = rechargeInfo.Id
|
||||||
|
}
|
||||||
svc := jsapi.JsapiApiService{Client: utils.GetWxPayService()}
|
svc := jsapi.JsapiApiService{Client: utils.GetWxPayService()}
|
||||||
price, _ := strconv.ParseFloat(rechargeInfo.Price, 64)
|
var payPrice = core.Int64(int64(price * 100.0))
|
||||||
orderId := NextId.Generate().String()
|
orderId := NextId.Generate().String()
|
||||||
|
//支付订单
|
||||||
|
if len(toPayRequest.OrderId) > 0 {
|
||||||
|
var orderSubList []models.OrderSub
|
||||||
|
database.Instance().Model(&models.OrderSub{}).Where("main_order_id = ? ", toPayRequest.OrderId).Find(&orderSubList)
|
||||||
|
if len(orderSubList) == 0 {
|
||||||
|
OrderExistError.Fail(ctx, toPayRequest)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//取出折扣价
|
||||||
|
price1 := 0.0
|
||||||
|
for _, orderSub := range orderSubList {
|
||||||
|
price1 = price1 + float64(orderSub.PayAmount)
|
||||||
|
}
|
||||||
|
var orderMain models.OrderMain
|
||||||
|
database.Instance().Model(&models.OrderMain{}).Where("order_id = ? and status = 1", toPayRequest.OrderId).Find(&orderMain)
|
||||||
|
if len(orderMain.PayOrderId) > 0 {
|
||||||
|
var payOrder *models.PayOrder
|
||||||
|
database.Instance().Model(&models.PayOrder{}).Where("order_id = ?", orderMain.PayOrderId).Find(&payOrder)
|
||||||
|
if payOrder.OrderStatus == 1 {
|
||||||
|
//去除定金扣除金额
|
||||||
|
price1 = price1 - (30.0 * 10)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
payPrice = core.Int64(int64(price1 * 10.0))
|
||||||
|
desc = "宠物洗护付款-" + toPayRequest.OrderId
|
||||||
|
orderId = toPayRequest.OrderId
|
||||||
|
price = price1 / 10.0
|
||||||
|
}
|
||||||
// 得到prepay_id,以及调起支付所需的参数和签名
|
// 得到prepay_id,以及调起支付所需的参数和签名
|
||||||
resp, _, err := svc.PrepayWithRequestPayment(ctx,
|
resp, _, err := svc.PrepayWithRequestPayment(ctx,
|
||||||
jsapi.PrepayRequest{
|
jsapi.PrepayRequest{
|
||||||
Appid: core.String(utils.CONFIG.AppId),
|
Appid: core.String(utils.CONFIG.AppId),
|
||||||
Mchid: core.String(utils.CONFIG.MchId),
|
Mchid: core.String(utils.CONFIG.MchId),
|
||||||
Description: core.String(rechargeInfo.Name),
|
Description: core.String(desc),
|
||||||
OutTradeNo: core.String(orderId),
|
OutTradeNo: core.String(orderId),
|
||||||
NotifyUrl: core.String(web.CONFIG.System.Domain + "/pet-house/pay/payNotify"),
|
NotifyUrl: core.String(web.CONFIG.System.Domain + "/pet-house/pay/payNotify"),
|
||||||
Amount: &jsapi.Amount{
|
Amount: &jsapi.Amount{
|
||||||
Total: core.Int64(int64(price * 100.0)),
|
Total: payPrice,
|
||||||
},
|
},
|
||||||
Payer: &jsapi.Payer{
|
Payer: &jsapi.Payer{
|
||||||
Openid: core.String(userInfo.OpenId),
|
Openid: core.String(userInfo.OpenId),
|
||||||
|
|
@ -81,9 +121,9 @@ func (p DefParty) toPay() web_iris.Party {
|
||||||
}
|
}
|
||||||
payOrder := models.PayOrder{
|
payOrder := models.PayOrder{
|
||||||
OrderId: orderId,
|
OrderId: orderId,
|
||||||
OrderName: rechargeInfo.Name,
|
OrderName: desc,
|
||||||
OrderPrice: rechargeInfo.Price,
|
OrderPrice: fmt.Sprintf("%.1f", price),
|
||||||
RechargeId: rechargeInfo.Id,
|
RechargeId: id,
|
||||||
PayId: "",
|
PayId: "",
|
||||||
Uid: headerBaseInfo.Uid,
|
Uid: headerBaseInfo.Uid,
|
||||||
}
|
}
|
||||||
|
|
@ -132,10 +172,20 @@ JIhayMjkemIO27X1j1ZdtA314xZpPrO4uqrVFiLahoZ9y6az0RhNpPadYcT6D24G
|
||||||
transaction := new(payments.Transaction)
|
transaction := new(payments.Transaction)
|
||||||
notifyReq, err := handler.ParseNotifyRequest(ctx, ctx.Request(), transaction)
|
notifyReq, err := handler.ParseNotifyRequest(ctx, ctx.Request(), transaction)
|
||||||
zap_server.ZAPLOG.Info("payNotify", zap.Any("notifyReq", notifyReq), zap.Any("transaction", transaction), zap.Any("err", err))
|
zap_server.ZAPLOG.Info("payNotify", zap.Any("notifyReq", notifyReq), zap.Any("transaction", transaction), zap.Any("err", err))
|
||||||
|
state := *transaction.TradeState
|
||||||
|
OrderStatus := 0
|
||||||
|
if "SUCCESS" == state {
|
||||||
|
OrderStatus = 1
|
||||||
|
} else if "REFUND" == state {
|
||||||
|
OrderStatus = 2
|
||||||
|
} else {
|
||||||
|
zap_server.ZAPLOG.Info("payNotify", zap.Any("notifyReq", notifyReq), zap.Any("transaction", transaction), zap.Any("state", state))
|
||||||
|
return
|
||||||
|
}
|
||||||
var payOrder *models.PayOrder
|
var payOrder *models.PayOrder
|
||||||
database.Instance().Model(&models.PayOrder{}).Where("order_id = ?", transaction.OutTradeNo).Find(&payOrder)
|
database.Instance().Model(&models.PayOrder{}).Where("order_id = ?", transaction.OutTradeNo).Find(&payOrder)
|
||||||
payOrderD := map[string]interface{}{
|
payOrderD := map[string]interface{}{
|
||||||
"OrderStatus": 1,
|
"OrderStatus": OrderStatus,
|
||||||
"PayId": *transaction.TransactionId,
|
"PayId": *transaction.TransactionId,
|
||||||
}
|
}
|
||||||
database.Instance().Model(&payOrder).Updates(&payOrderD)
|
database.Instance().Model(&payOrder).Updates(&payOrderD)
|
||||||
|
|
@ -163,6 +213,12 @@ JIhayMjkemIO27X1j1ZdtA314xZpPrO4uqrVFiLahoZ9y6az0RhNpPadYcT6D24G
|
||||||
"Amount": userInfo.Amount,
|
"Amount": userInfo.Amount,
|
||||||
}
|
}
|
||||||
database.Instance().Model(&userInfo).Updates(&updateValues)
|
database.Instance().Model(&userInfo).Updates(&updateValues)
|
||||||
|
} else {
|
||||||
|
var orderMain models.OrderMain
|
||||||
|
database.Instance().Model(&models.OrderMain{}).Where("order_id = ? and status = 1", payOrder.OrderId).Find(&orderMain)
|
||||||
|
//设置订单状态
|
||||||
|
orderMain.PayStatus = 1
|
||||||
|
database.Instance().Save(&orderMain)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
|
|
|
||||||
|
|
@ -311,25 +311,28 @@ type UserCoupons struct {
|
||||||
|
|
||||||
// RechargeInfo 充值挡位信息
|
// RechargeInfo 充值挡位信息
|
||||||
type RechargeInfo struct {
|
type RechargeInfo struct {
|
||||||
Id int `gorm:"primaryKey;autoIncrement" json:"id"` //id
|
Id int `gorm:"primaryKey;autoIncrement" json:"id"` //id
|
||||||
Name string `gorm:"not null" json:"name"` //挡位名称
|
Name string `gorm:"not null" json:"name"` //挡位名称
|
||||||
Desc string `json:"desc"` //挡位描述
|
Desc string `json:"desc"` //挡位描述
|
||||||
Price string `gorm:"not null" json:"price"` //价格
|
Price string `gorm:"not null" json:"price"` //价格
|
||||||
Give string `gorm:"default:无" json:"give"` //赠送
|
RechargePrice string `gorm:"not null;default:0" json:"rechargePrice"` //实际充值
|
||||||
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
|
Give string `gorm:"default:无" json:"give"` //赠送
|
||||||
UpdateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP" json:"-"` //更新时间
|
CreateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP" json:"-"` //创建时间
|
||||||
Status int `gorm:"default:1" json:"-" json:"-"` //状态
|
UpdateTime time.Time `gorm:"type:timestamp;default:CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP" json:"-"` //更新时间
|
||||||
Type int `gorm:"default:1" json:"type" json:"type"` //类型 1充值挡位 2押金
|
Status int `gorm:"default:1" json:"-" json:"-"` //状态
|
||||||
|
Type int `gorm:"default:1" json:"type" json:"type"` //类型 1充值挡位 2押金
|
||||||
}
|
}
|
||||||
|
|
||||||
// PayOrder 支付订单
|
// PayOrder 支付订单
|
||||||
type PayOrder struct {
|
type PayOrder struct {
|
||||||
Id int `gorm:"primaryKey;autoIncrement"` //id
|
Id int `gorm:"primaryKey;autoIncrement"` //id
|
||||||
OrderId string `gorm:"not null"` //订单ID
|
Uid int64 `gorm:"not null;default:0" json:"uid"` //uid
|
||||||
OrderName string `gorm:"not null"` //订单名称
|
OrderId string `gorm:"not null"` //订单ID
|
||||||
OrderPrice string `gorm:"not null"` //订单金额
|
OrderName string `gorm:"not null"` //订单名称
|
||||||
OrderStatus int `gorm:"not null;default:0"` //订单状态 0:未支付 1:已支付 2:已退款
|
OrderPrice string `gorm:"not null"` //订单金额
|
||||||
|
OrderStatus int `gorm:"not null;default:0"` //订单状态 0:未支付 1:已支付 2:已退款 3:会员余额支付
|
||||||
PayId string //三方交易号
|
PayId string //三方交易号
|
||||||
|
RechargeId int `gorm:"not null;default:0"` //充值ID
|
||||||
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:"-"` //更新时间
|
||||||
Status int `gorm:"default:1" json:"-"` //状态
|
Status int `gorm:"default:1" json:"-"` //状态
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ type TimeObject struct {
|
||||||
Y bool `json:"y"`
|
Y bool `json:"y"`
|
||||||
}
|
}
|
||||||
|
|
||||||
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, orderTimeCount map[string]int) map[string][]TimeObject {
|
||||||
// 获取当前时间
|
// 获取当前时间
|
||||||
currentTime := time.Now()
|
currentTime := time.Now()
|
||||||
// 计算半小时后的时间
|
// 计算半小时后的时间
|
||||||
|
|
@ -81,7 +81,8 @@ func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFil
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
key := nextHour.Format("2006-01-02")
|
key := nextHour.Format("2006-01-02")
|
||||||
//当前订单数小于车辆数 可接单
|
key1 := nextHour.Format("2006-01-02 15:04")
|
||||||
|
//当前订单数小于车辆数 可接单 时间范围可能会超出到11点
|
||||||
if existOrderNum && orderNum < carNum*carServiceNum {
|
if existOrderNum && orderNum < carNum*carServiceNum {
|
||||||
if _, ok := dayHoursMap[key]; ok {
|
if _, ok := dayHoursMap[key]; ok {
|
||||||
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
||||||
|
|
@ -95,17 +96,28 @@ func GetStrDays(day int, minute int, reserveMap map[string]models.ReserveTimeFil
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
} else if nextHour.Hour() >= workStart && nextHour.Hour() < workEnd {
|
} else if nextHour.Hour() >= workStart && nextHour.Hour() < workEnd {
|
||||||
if _, ok := dayHoursMap[key]; ok {
|
//查看当前时间对应的订单数量
|
||||||
|
orderCount := orderTimeCount[key1]
|
||||||
|
//预约时间对应的订单数<车辆数量 当前时间可以预约
|
||||||
|
if orderCount < carNum*carServiceNum {
|
||||||
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
||||||
Time: nextHour.Format("15:04"),
|
Time: nextHour.Format("15:04"),
|
||||||
Y: false,
|
Y: true,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
dayHoursMap[key] = []TimeObject{{
|
if _, ok := dayHoursMap[key]; ok {
|
||||||
Time: nextHour.Format("15:04"),
|
dayHoursMap[key] = append(dayHoursMap[key], TimeObject{
|
||||||
Y: false,
|
Time: nextHour.Format("15:04"),
|
||||||
}}
|
Y: false,
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
dayHoursMap[key] = []TimeObject{{
|
||||||
|
Time: nextHour.Format("15:04"),
|
||||||
|
Y: false,
|
||||||
|
}}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -103,3 +103,6 @@ func TestMap(t *testing.T) {
|
||||||
}
|
}
|
||||||
print("12345", c1[2].Id)
|
print("12345", c1[2].Id)
|
||||||
}
|
}
|
||||||
|
func Test22(t *testing.T) {
|
||||||
|
fmt.Println("您还需支付" + fmt.Sprintf("%.1f", float64(1298)/10.0))
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue