fix:购物车下单
This commit is contained in:
@@ -5,12 +5,14 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/constants"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/utils/basic"
|
||||
"fusenapi/utils/order"
|
||||
"fusenapi/utils/shopping_cart"
|
||||
"fusenapi/utils/step_price"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"github.com/aws/aws-sdk-go/aws/session"
|
||||
"gorm.io/gorm"
|
||||
@@ -33,15 +35,22 @@ type (
|
||||
// 详情
|
||||
}
|
||||
|
||||
OrderAddress struct {
|
||||
Address string `json:"address"` // 详细地址
|
||||
Mobile string `json:"mobile"` // 手机
|
||||
Name string `json:"name"` // 姓名
|
||||
}
|
||||
|
||||
/* 下单 */
|
||||
CreateReq struct {
|
||||
ExpectedDeliveryTime string `json:"expected_delivery_time"` // 预计到货时间
|
||||
ExchangeRate int64 `json:"exchange_rate"` // 换算汇率(厘)
|
||||
CurrentCurrency string `json:"current_currency"` // 当前货币
|
||||
OriginalCurrency string `json:"original_currency"` // 原始货币
|
||||
UserId int64 `json:"user_id"`
|
||||
CartIds []int64 `json:"cart_ids"`
|
||||
DeliveryMethod string `json:"delivery_method"`
|
||||
ExpectedDeliveryTime string `json:"expected_delivery_time"` // 预计到货时间
|
||||
ExchangeRate int64 `json:"exchange_rate"` // 换算汇率(厘)
|
||||
CurrentCurrency string `json:"current_currency"` // 当前货币
|
||||
OriginalCurrency string `json:"original_currency"` // 原始货币
|
||||
UserId int64 `json:"user_id"`
|
||||
CartIds []int64 `json:"cart_ids"`
|
||||
DeliveryMethod int64 `json:"delivery_method"`
|
||||
DeliveryAddress *OrderAddress `json:"delivery_address"` // 收货地址
|
||||
}
|
||||
CreateRes struct {
|
||||
ErrorCode basic.StatusResponse
|
||||
@@ -99,7 +108,21 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
||||
// 订单总价(厘)
|
||||
var orderTotal int64
|
||||
|
||||
var payStatus int64
|
||||
var nowTime = time.Now().UTC()
|
||||
|
||||
// 收货地址
|
||||
var orderAddress *gmodel.OrderAddress
|
||||
|
||||
// 支付状态
|
||||
var payStatus = constants.ORDERPAYSTATUSUNPAIDDEPOSIT
|
||||
|
||||
// 直邮
|
||||
if in.DeliveryMethod == constants.DELIVERYMETHODDIRECTMAIL {
|
||||
orderAddress = &gmodel.OrderAddress{
|
||||
Mobile: in.DeliveryAddress.Mobile,
|
||||
Name: in.DeliveryAddress.Name,
|
||||
}
|
||||
}
|
||||
|
||||
for _, shoppingCart := range shoppingCartList {
|
||||
// 购物车快照
|
||||
@@ -248,8 +271,24 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe
|
||||
CurrentCurrency: in.CurrentCurrency,
|
||||
OriginalCurrency: in.OriginalCurrency,
|
||||
})
|
||||
fmt.Println(orderProductList, shippingFee, shippingFeeTotal, tax, taxTotal, discount, discountTotal, subtotal, orderProductTotal, total)
|
||||
// 定金
|
||||
var depositInt int64 //厘
|
||||
var deposit = gmodel.PayInfo{
|
||||
Status: gmodel.PayStatus{
|
||||
StatusCode: int64(constants.PAYSTATUSUNPAID),
|
||||
StatusTitle: constants.PayStatusMessage[constants.PAYSTATUSUNPAID],
|
||||
},
|
||||
PayAmount: gmodel.AmountInfo{},
|
||||
}
|
||||
|
||||
// 尾款
|
||||
var remainingBalanceInt int64 //厘
|
||||
var remainingBalance = gmodel.PayInfo{}
|
||||
fmt.Println(orderProductList, shippingFee, shippingFeeTotal, tax, taxTotal, discount, discountTotal, subtotal, orderProductTotal, total)
|
||||
var orderAmount = gmodel.OrderAmount{
|
||||
Deposit: deposit,
|
||||
RemainingBalance: remainingBalance,
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user