From e32274a31bca1f092a902164c50ea69999c31f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Fri, 14 Aug 2020 13:56:02 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/model/order.go | 11 +++-- business/partner/purchase/jx/localjx/order.go | 47 ++++++++++++++++--- 2 files changed, 47 insertions(+), 11 deletions(-) diff --git a/business/model/order.go b/business/model/order.go index 7db123bfc..f1a579df5 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -30,6 +30,7 @@ const ( OrderTypeNormal = 0 //普通订单 OrderTypeMatter = 0 //物料订单 OrderTypeSupplyGoods = 2 //进货订单 + OrderTypeDefendPrice = 3 //守价订单 ) var ( @@ -387,11 +388,13 @@ type PriceDefendOrder struct { VendorOrderID string `orm:"column(vendor_order_id);size(48)" json:"vendorOrderID"` StoreID int `orm:"column(store_id)" json:"storeID"` SkuID int `orm:"column(sku_id)" json:"skuID"` - AddressID int `orm:"column(address_id)" json:"addressID"` + AddressID int64 `orm:"column(address_id)" json:"addressID"` Count int `json:"count"` - DefendPrice int64 `json:"defendPrice"` - ActualPayPrice int64 `json:"actualPayPrice"` // 单位为分 顾客实际支付 - IsBuyNowPrice int `json:"isBuyNowPrice"` + DefendPrice int64 `json:"defendPrice"` //守的价格 + ActualPayPrice int64 `json:"actualPayPrice"` //单位为分 顾客实际支付 + IsBuyNowPrice int `json:"isBuyNowPrice"` //库存剩x(x=当前客户购买的数量)时以当时价抢购 + Issue int `json:"issue"` //期数,每晚22:00以后的守价单是归在第二天的期数中 + IsSuccess int `json:"isSuccess"` //是否抢购成功 } func (v *PriceDefendOrder) TableIndex() [][]string { diff --git a/business/partner/purchase/jx/localjx/order.go b/business/partner/purchase/jx/localjx/order.go index 35433a1c0..77e0e748f 100644 --- a/business/partner/purchase/jx/localjx/order.go +++ b/business/partner/purchase/jx/localjx/order.go @@ -106,12 +106,13 @@ type JxOrderInfo struct { OrderPrice int64 `json:"orderPrice"` // 单位为分 订单商品价格 ActualPayPrice int64 `json:"actualPayPrice"` // 单位为分 顾客实际支付 - OrderID int64 `json:"orderID"` - StoreName string `json:"storeName"` - Weight int `json:"weight"` - FromStoreID int `json:"fromStoreID"` - EarningType int `json:"earningType"` - OrderType int `json:"orderType"` + OrderID int64 `json:"orderID"` + StoreName string `json:"storeName"` + Weight int `json:"weight"` + FromStoreID int `json:"fromStoreID"` + EarningType int `json:"earningType"` + OrderType int `json:"orderType"` + IsBuyNowPrice int `json:"isBuyNowPrice"` } type DeliveryTimeItem struct { @@ -230,7 +231,14 @@ func CreateOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64, if fromStoreID != 0 { checkMatterDeliveryAddress(deliveryAddress) } - if createType != OrderCreateTypePre { + if createType == OrderCreateTypePre { + if jxOrder.OrderType == model.OrderTypeDefendPrice { + buildDefendPriceOrder(ctx, jxOrder, addressID) + } + } else { + if jxOrder.OrderType == model.OrderTypeDefendPrice { + return + } if outJxOrder.TotalPrice != jxOrder.TotalPrice { return nil, fmt.Errorf("商品或配送信息发生改变,请重新下单") } @@ -245,6 +253,31 @@ func CreateOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64, return outJxOrder, err } +func buildDefendPriceOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64) { + var ( + issue = 0 + db = dao.GetDB() + ) + //属于下一期 + if time.Now().Hour() >= 22 { + issue = utils.Str2Int(time.Now().AddDate(0, 0, 1).Format("20060102")) + } else { + issue = utils.Str2Int(time.Now().Format("20060102")) + } + priceDefendOrder := &model.PriceDefendOrder{ + VendorOrderID: utils.Int64ToStr(GenOrderNo(ctx)), + StoreID: jxOrder.StoreID, + SkuID: jxOrder.Skus[0].SkuID, + AddressID: addressID, + Count: jxOrder.Skus[0].Count, + DefendPrice: jxOrder.Skus[0].Price, + IsBuyNowPrice: jxOrder.IsBuyNowPrice, + Issue: issue, + } + priceDefendOrder.ActualPayPrice = int64(priceDefendOrder.Count) * priceDefendOrder.DefendPrice + dao.CreateEntity(db, &priceDefendOrder) +} + // 买家取消(或申请取消)订单 func BuyerCancelOrder(ctx *jxcontext.Context, orderID int64, reason string) (canceled bool, err error) { order, err := partner.CurOrderManager.LoadOrder(utils.Int64ToStr(orderID), model.VendorIDJX)