刷新历史订单结算价
This commit is contained in:
@@ -613,7 +613,7 @@ func (c *OrderManager) UpdateOrderFields(order *model.GoodsOrder, fieldList []st
|
||||
return err
|
||||
}
|
||||
|
||||
func (c *OrderManager) RefreshHistoryOrdersEarningPrice(ctx *jxcontext.Context, vendorOrderId string, vendorIDs []int, storeId int, fromDate string, toDate string, isAsync, isContinueWhenError bool) (err error) {
|
||||
func (c *OrderManager) RefreshHistoryOrdersEarningPrice(ctx *jxcontext.Context, vendorOrderID string, vendorIDs []int, storeID int, fromDate string, toDate string, isAsync, isContinueWhenError bool) (err error) {
|
||||
db := dao.GetDB()
|
||||
fromDateParam := utils.Str2Time(fromDate)
|
||||
toDateParam := utils.Str2Time(toDate)
|
||||
@@ -621,9 +621,9 @@ func (c *OrderManager) RefreshHistoryOrdersEarningPrice(ctx *jxcontext.Context,
|
||||
if math.Ceil(toDateParam.Sub(fromDateParam).Hours()/24) > 10 {
|
||||
return errors.New(fmt.Sprintf("查询间隔时间不允许大于10天!时间范围:[%v] 至 [%v]", fromDate, toDate))
|
||||
}
|
||||
orderList, _ := dao.QueryOrders(db, vendorOrderId, vendorIDs, storeId, fromDateParam, toDateParam)
|
||||
orderList, _ := dao.QueryOrders(db, vendorOrderID, vendorIDs, storeID, fromDateParam, toDateParam)
|
||||
if len(orderList) <= 0 {
|
||||
return errors.New(fmt.Sprintf("未查询到订单!,vendorOrderId : %s, 时间范围:[%v] 至 [%v]", vendorOrderId, fromDate, toDate))
|
||||
return errors.New(fmt.Sprintf("未查询到订单!,vendorOrderID : %s, 时间范围:[%v] 至 [%v]", vendorOrderID, fromDate, toDate))
|
||||
}
|
||||
task := tasksch.NewParallelTask("刷新历史订单结算价", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
@@ -641,19 +641,18 @@ func (c *OrderManager) RefreshHistoryOrdersEarningPrice(ctx *jxcontext.Context,
|
||||
}
|
||||
}()
|
||||
for _, value := range order.Skus {
|
||||
if _, err := dao.UpdateEntity(db, value, "EarningPrice", "StoreSubID"); err != nil {
|
||||
if _, err = dao.UpdateEntity(db, value, "EarningPrice", "StoreSubID"); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
jxutils.RefreshOrderSkuRelated(order)
|
||||
if _, err2 := dao.UpdateEntity(db, order, "EarningPrice"); err2 != nil {
|
||||
return "", err2
|
||||
if _, err = dao.UpdateEntity(db, order, "EarningPrice"); err != nil {
|
||||
return "", err
|
||||
}
|
||||
dao.Commit(db)
|
||||
return retVal, err
|
||||
}, orderList)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
|
||||
if !isAsync {
|
||||
_, err = task.GetResult(0)
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ type OrderSkuWithActualPayPrice struct {
|
||||
PayPercentage int `json:"payPercentage"`
|
||||
}
|
||||
|
||||
func QueryOrders(db *DaoDB, vendorOrderId string, vendorIDs []int, storeID int, orderCreatedAtBegin, orderCreatedAtEnd time.Time) (orderList []*model.GoodsOrder, err error) {
|
||||
func QueryOrders(db *DaoDB, vendorOrderID string, vendorIDs []int, storeID int, orderCreatedAtBegin, orderCreatedAtEnd time.Time) (orderList []*model.GoodsOrder, err error) {
|
||||
sql := `
|
||||
SELECT t1.*
|
||||
FROM goods_order t1
|
||||
@@ -44,9 +44,9 @@ func QueryOrders(db *DaoDB, vendorOrderId string, vendorIDs []int, storeID int,
|
||||
sqlParams := []interface{}{
|
||||
orderCreatedAtBegin,
|
||||
}
|
||||
if vendorOrderId != "" {
|
||||
if vendorOrderID != "" {
|
||||
sql += " AND t1.vendor_order_id = ?"
|
||||
sqlParams = append(sqlParams, vendorOrderId)
|
||||
sqlParams = append(sqlParams, vendorOrderID)
|
||||
}
|
||||
if len(vendorIDs) > 0 {
|
||||
sql += " AND t1.vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")"
|
||||
|
||||
@@ -746,9 +746,9 @@ func (c *OrderController) AmendMissingOrders() {
|
||||
// @Param token header string true "认证token"
|
||||
// @Param fromDate formData string true "订单起始日期"
|
||||
// @Param toDate formData string true "订单结束日期"
|
||||
// @Param vendorOrderId formData string false "订单号"
|
||||
// @Param vendorIDs formData int false "平台ID列表[0,1,3]"
|
||||
// @Param storeId formData int false "门店ID"
|
||||
// @Param vendorOrderID formData string false "订单号"
|
||||
// @Param vendorIDs formData int false "平台ID列表[0,1,3]"
|
||||
// @Param storeID formData int false "门店ID"
|
||||
// @Param isAsync formData bool true "是否异步操作"
|
||||
// @Param isContinueWhenError formData bool false "单个失败是否继续,缺省true"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
@@ -758,7 +758,7 @@ func (c *OrderController) RefreshHistoryOrdersEarningPrice() {
|
||||
c.callRefreshHistoryOrdersEarningPrice(func(params *tOrderRefreshHistoryOrdersEarningPriceParams) (retVal interface{}, errCode string, err error) {
|
||||
var vendorIDList []int
|
||||
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList); err == nil {
|
||||
err = orderman.FixedOrderManager.RefreshHistoryOrdersEarningPrice(params.Ctx, params.VendorOrderId, vendorIDList, params.StoreId, params.FromDate, params.ToDate, params.IsAsync, params.IsContinueWhenError)
|
||||
err = orderman.FixedOrderManager.RefreshHistoryOrdersEarningPrice(params.Ctx, params.VendorOrderID, vendorIDList, params.StoreID, params.FromDate, params.ToDate, params.IsAsync, params.IsContinueWhenError)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user