活动
This commit is contained in:
@@ -46,8 +46,9 @@ const (
|
||||
|
||||
wxAppID = "wx4b5930c13f8b1170"
|
||||
|
||||
autoCancelOrderReason = "支付超时,系统自动取消!"
|
||||
cancelMatterOrderReason = "失败重发!"
|
||||
autoCancelOrderReason = "支付超时,系统自动取消!"
|
||||
cancelMatterOrderReason = "失败重发!"
|
||||
settleDiscountActRefundReason = "守价订单生成补退款"
|
||||
|
||||
splitMatterOrderMinWeight = 4500 //物料订单分包最少要4.5kg
|
||||
jxwxfMatterEclpID = "EMG4418113943423" //京西五香粉物料编码
|
||||
@@ -113,6 +114,7 @@ type JxOrderInfo struct {
|
||||
EarningType int `json:"earningType"`
|
||||
OrderType int `json:"orderType"`
|
||||
IsBuyNowPrice int `json:"isBuyNowPrice"`
|
||||
IsPriceDefend int `json:"isPriceDefend"`
|
||||
}
|
||||
|
||||
type DeliveryTimeItem struct {
|
||||
@@ -242,11 +244,19 @@ func CreateOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64,
|
||||
if outJxOrder.TotalPrice != jxOrder.TotalPrice {
|
||||
return nil, fmt.Errorf("商品或配送信息发生改变,请重新下单")
|
||||
}
|
||||
outJxOrder.OrderID = GenOrderNo(ctx)
|
||||
if jxOrder.IsPriceDefend == model.YES {
|
||||
outJxOrder.OrderID = jxOrder.OrderID
|
||||
} else {
|
||||
outJxOrder.OrderID = GenOrderNo(ctx)
|
||||
}
|
||||
order, err2 := jxOrder2GoodsOrder(ctx, outJxOrder, deliveryAddress, "", IsDeliverySelf)
|
||||
if err = err2; err == nil {
|
||||
order.AddressID = addressID
|
||||
order.Status = model.OrderStatusWait4Pay
|
||||
if jxOrder.IsPriceDefend == model.YES {
|
||||
order.Status = model.OrderStatusNew
|
||||
} else {
|
||||
order.Status = model.OrderStatusWait4Pay
|
||||
}
|
||||
callNewOrder(order)
|
||||
}
|
||||
}
|
||||
@@ -258,12 +268,7 @@ func buildDefendPriceOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, address
|
||||
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"))
|
||||
}
|
||||
issue = jxutils.GetDefendPriceIssue()
|
||||
priceDefendOrder := &model.PriceDefendOrder{
|
||||
VendorOrderID: utils.Int64ToStr(GenOrderNo(ctx)),
|
||||
StoreID: jxOrder.StoreID,
|
||||
@@ -406,12 +411,12 @@ func OnPayFinished(orderPay *model.OrderPay) (err error) {
|
||||
order.StatusTime = *orderPay.PayFinishedAt
|
||||
err = callNewOrder(order)
|
||||
//如果是物料的订单,直接到拣货完成,配送中的状态
|
||||
// if order.OrderType != model.OrderTypeNormal {
|
||||
if order.FromStoreID != 0 {
|
||||
if order.OrderType != model.OrderTypeNormal {
|
||||
// if order.FromStoreID != 0 {
|
||||
netprinter.PrintOrderByOrder(jxcontext.AdminCtx, order)
|
||||
PickupGoods(order, false, "jxadmin")
|
||||
// }
|
||||
}
|
||||
// }
|
||||
}
|
||||
return err
|
||||
}
|
||||
@@ -920,7 +925,9 @@ func PickupGoods(order *model.GoodsOrder, isSelfDelivery bool, userName string)
|
||||
err = changeOrderStatus(order.VendorOrderID, model.OrderStatusFinishedPickup, "")
|
||||
//如果是物料订单则直接进行京东物流的发单,并且状态直接变为配送中
|
||||
//如果是进货的订单,直接变为配送中
|
||||
err = orderSolutionForWuLiao(order)
|
||||
if order.OrderType != model.OrderTypeNormal {
|
||||
err = orderSolutionForWuLiao(order)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1854,3 +1861,52 @@ func GetSupplySupportStoreSkus(ctx *jxcontext.Context, fromDate, toDate string,
|
||||
orderSkus, err = dao.GetSupplySupportStoreSkus(db, utils.Str2Time(fromDate), utils.Str2Time(toDate), fromStoreID, storeID, utils.Str2Float64(percentage))
|
||||
return orderSkus, err
|
||||
}
|
||||
|
||||
func CreateOrderByPriceDefend(ctx *jxcontext.Context) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
priceDefends, _ := dao.GetPriceDefendOrder(db, nil, nil, []int{jxutils.GetDefendPriceIssue()}, 0, -1, 1)
|
||||
if len(priceDefends) == 0 {
|
||||
return
|
||||
}
|
||||
for _, v := range priceDefends {
|
||||
jxOrder := &JxOrderInfo{
|
||||
BuyerComment: "守价订单",
|
||||
StoreID: v.StoreID,
|
||||
Skus: []*JxSkuInfo{
|
||||
&JxSkuInfo{
|
||||
SkuID: v.SkuID,
|
||||
Count: v.Count,
|
||||
},
|
||||
},
|
||||
IsPriceDefend: model.YES,
|
||||
OrderID: utils.Str2Int64(v.VendorOrderID),
|
||||
}
|
||||
if _, err := CreateOrder(ctx, jxOrder, v.AddressID, OrderCreateTypeNormal, 0, false); err == nil {
|
||||
err = SettleDiscountActByPriceDefend(ctx, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//结算因京西折扣活动而参与守价的订单
|
||||
func SettleDiscountActByPriceDefend(ctx *jxcontext.Context, order *model.PriceDefendOrder) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
payList, err2 := dao.GetOrderPayList(db, order.VendorOrderID, jxutils.GetPossibleVendorIDFromVendorOrderID(order.VendorOrderID))
|
||||
if err = err2; err == nil {
|
||||
for _, orderPay := range payList {
|
||||
if orderPay.Status == model.PayStatusYes {
|
||||
refundID := order.VendorOrderID
|
||||
if orderPay.PayType == model.PayTypeTL {
|
||||
_, err = RefundOrderByTL(ctx, orderPay, refundID, int(order.ActualPayPrice-order.RealPrice), settleDiscountActRefundReason)
|
||||
}
|
||||
} else {
|
||||
orderPay.Status = model.PayStatusCanceled
|
||||
_, err = dao.UpdateEntity(db, orderPay)
|
||||
}
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user