京东物流超重验证
This commit is contained in:
@@ -2,6 +2,7 @@ package cms
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -26,6 +27,8 @@ import (
|
||||
const (
|
||||
AcceptMaxCount = 2
|
||||
CancelMaxCount = 5
|
||||
|
||||
waybillKgPrice = 200
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -634,7 +637,7 @@ func CancelJdDelivery(ctx *jxcontext.Context, vendorWaybillID, reason string) (e
|
||||
)
|
||||
err = dao.GetEntity(db, dOrder, "VendorWaybillID")
|
||||
userBill, err := dao.GetUserBill(db, ctx.GetUserID(), "")
|
||||
dOrders, err := dao.GetDeliveryOrdersNoPage(db, []string{ctx.GetUserID()}, []int{model.OrderStatusCanceled}, DayTimeBegin, DayTimeEnd)
|
||||
dOrders, err := dao.GetDeliveryOrdersNoPage(db, []string{ctx.GetUserID()}, []int{model.OrderStatusCanceled}, DayTimeBegin, DayTimeEnd, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -674,13 +677,56 @@ func CancelJdDelivery(ctx *jxcontext.Context, vendorWaybillID, reason string) (e
|
||||
}
|
||||
|
||||
func GetJdDelivery(ctx *jxcontext.Context, status int, fromTime, toTime string, pageSize, offset int) (pagedInfo *model.PagedInfo, err error) {
|
||||
return dao.GetDeliveryOrders(dao.GetDB(), []string{ctx.GetUserID()}, []int{status}, utils.Str2Time(fromTime), utils.Str2Time(toTime), pageSize, offset)
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
return dao.GetDeliveryOrders(db, []string{ctx.GetUserID()}, []int{status}, utils.Str2Time(fromTime), utils.Str2Time(toTime), pageSize, offset)
|
||||
}
|
||||
|
||||
func GetJdDeliveryDetail(ctx *jxcontext.Context, vendorWaybillID string) (queryDynamicTraceInfo []*jdeclpapi.QueryDynamicTraceInfoResult, err error) {
|
||||
return api.JdEclpAPI.QueryDynamicTraceInfo(vendorWaybillID)
|
||||
}
|
||||
|
||||
func CheckJdDeliveryWeight(ctx *jxcontext.Context) (err error) {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
)
|
||||
userBill, err := dao.GetUserBill(db, ctx.GetUserID(), "")
|
||||
if userBill.AccountBalance < 0 {
|
||||
return fmt.Errorf("您有京东物流订单实际超重,请支付欠款!")
|
||||
}
|
||||
deliveryOrders, err := dao.GetDeliveryOrdersNoPage(db, []string{ctx.GetUserID()}, nil, utils.ZeroTimeValue, utils.ZeroTimeValue, []int{0})
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
task := tasksch.NewParallelTask("CheckJdDeliveryWeight", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(true), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
deliveryOrder := batchItemList[0].(*model.DeliveryOrder)
|
||||
waybill, err := api.JdEclpAPI.WaybillQuery(deliveryOrder.VendorWaybillID)
|
||||
if err == nil {
|
||||
return retVal, err
|
||||
}
|
||||
if waybill.DeliveryID == "" {
|
||||
return retVal, err
|
||||
}
|
||||
if waybill.DeliveryID == deliveryOrder.VendorWaybillID {
|
||||
if waybill.Weight > 3 && math.Floor(deliveryOrder.Weight) < math.Floor(waybill.Weight) {
|
||||
diffPrice := (math.Floor(waybill.Weight) - math.Floor(deliveryOrder.Weight)) * waybillKgPrice
|
||||
if err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
if err = financial.AddExpendUpdateAccount(db, userBill, model.BillTypeJdWaybillOverWeight, utils.Float64TwoInt(diffPrice)); err != nil {
|
||||
return retVal, err
|
||||
}
|
||||
}
|
||||
}
|
||||
return retVal, err
|
||||
}, deliveryOrders)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
task.GetID()
|
||||
return err
|
||||
}
|
||||
|
||||
func ResetJobTimers() {
|
||||
var (
|
||||
db = dao.GetDB()
|
||||
|
||||
Reference in New Issue
Block a user