刷新历史订单修改
This commit is contained in:
@@ -613,7 +613,7 @@ func (c *OrderManager) UpdateOrderFields(order *model.GoodsOrder, fieldList []st
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *OrderManager) RefreshHistoryOrdersEarningPrice(ctx *jxcontext.Context, vendorOrderID string, vendorIDs []int, storeID int, fromDate string, toDate string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func (c *OrderManager) RefreshHistoryOrdersEarningPrice(ctx *jxcontext.Context, vendorOrderID string, actIDs []int, vendorIDs []int, storeID int, fromDate string, toDate string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
fromDateParam := utils.Str2Time(fromDate)
|
fromDateParam := utils.Str2Time(fromDate)
|
||||||
toDateParam := utils.Str2Time(toDate)
|
toDateParam := utils.Str2Time(toDate)
|
||||||
@@ -621,7 +621,8 @@ func (c *OrderManager) RefreshHistoryOrdersEarningPrice(ctx *jxcontext.Context,
|
|||||||
if math.Ceil(toDateParam.Sub(fromDateParam).Hours()/24) > 10 {
|
if math.Ceil(toDateParam.Sub(fromDateParam).Hours()/24) > 10 {
|
||||||
return "", errors.New(fmt.Sprintf("查询间隔时间不允许大于10天!时间范围:[%v] 至 [%v]", fromDate, toDate))
|
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)
|
||||||
|
orderList, _ := dao.QueryOrdersFilterByAct(db, vendorOrderID, actIDs, vendorIDs, storeID, fromDateParam, toDateParam)
|
||||||
if len(orderList) <= 0 {
|
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))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -593,3 +593,47 @@ func GetRiskOrderCount(db *DaoDB, dayNum int, includeToday bool) (storeOrderList
|
|||||||
|
|
||||||
return storeOrderList, GetRows(db, &storeOrderList, sql, sqlParams)
|
return storeOrderList, GetRows(db, &storeOrderList, sql, sqlParams)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func QueryOrdersFilterByAct(db *DaoDB, vendorOrderID string, actIDs, vendorIDs []int, storeID int, fromDate, toDate time.Time) (orderList []*model.GoodsOrderExt, err error) {
|
||||||
|
sql := `
|
||||||
|
SELECT a.vendor_order_id, a.vendor_id
|
||||||
|
FROM goods_order a
|
||||||
|
JOIN order_sku b ON a.vendor_order_id = b.vendor_order_id
|
||||||
|
JOIN (SELECT t1.begin_at,t1.end_at, t2.act_id,t2.store_id, t2.sku_id
|
||||||
|
FROM act t1
|
||||||
|
JOIN act_store_sku t2 ON t2.act_id = t1.id
|
||||||
|
WHERE t1.status = 1
|
||||||
|
`
|
||||||
|
sqlParams := []interface{}{}
|
||||||
|
if len(actIDs) > 0 {
|
||||||
|
sql += " AND t1.id IN (" + GenQuestionMarks(len(actIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, actIDs)
|
||||||
|
}
|
||||||
|
sql += `
|
||||||
|
)s
|
||||||
|
ON s.store_id = a.store_id
|
||||||
|
AND s.sku_id = b.sku_id
|
||||||
|
AND a.order_created_at BETWEEN s.begin_at AND s.end_at
|
||||||
|
WHERE 1=1
|
||||||
|
`
|
||||||
|
if vendorOrderID != "" {
|
||||||
|
sql += " AND a.vendor_order_id = ?"
|
||||||
|
sqlParams = append(sqlParams, vendorOrderID)
|
||||||
|
}
|
||||||
|
if len(vendorIDs) > 0 {
|
||||||
|
sql += " AND a.vendor_id IN (" + GenQuestionMarks(len(vendorIDs)) + ")"
|
||||||
|
sqlParams = append(sqlParams, vendorIDs)
|
||||||
|
}
|
||||||
|
if storeID > 0 {
|
||||||
|
sql += " AND IF(a.jx_store_id <> 0, a.jx_store_id, a.store_id) = ?"
|
||||||
|
sqlParams = append(sqlParams, storeID)
|
||||||
|
}
|
||||||
|
if !utils.IsTimeZero(fromDate) && !utils.IsTimeZero(toDate) {
|
||||||
|
sql += " AND a.order_created_at BETWEEN ? and ?"
|
||||||
|
sqlParams = append(sqlParams, fromDate, toDate)
|
||||||
|
}
|
||||||
|
sql += `
|
||||||
|
GROUP BY 1,2
|
||||||
|
`
|
||||||
|
return orderList, GetRows(db, &orderList, sql, sqlParams...)
|
||||||
|
}
|
||||||
|
|||||||
@@ -748,17 +748,18 @@ func (c *OrderController) AmendMissingOrders() {
|
|||||||
// @Param toTime formData string true "订单结束时间 (yyyy-mm-dd hh:ms:ss)"
|
// @Param toTime formData string true "订单结束时间 (yyyy-mm-dd hh:ms:ss)"
|
||||||
// @Param vendorOrderID formData string false "订单号"
|
// @Param vendorOrderID formData string false "订单号"
|
||||||
// @Param vendorIDs formData string false "平台ID列表[0,1,3]"
|
// @Param vendorIDs formData string false "平台ID列表[0,1,3]"
|
||||||
|
// @Param actIDs formData string false "活动ID列表[0,1,3]"
|
||||||
// @Param storeID formData int false "门店ID"
|
// @Param storeID formData int false "门店ID"
|
||||||
// @Param isAsync formData bool true "是否异步操作"
|
// @Param isAsync formData bool false "是否异步操作"
|
||||||
// @Param isContinueWhenError formData bool false "单个失败是否继续,缺省true"
|
// @Param isContinueWhenError formData bool false "单个失败是否继续,缺省true"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
// @Failure 200 {object} controllers.CallResult
|
// @Failure 200 {object} controllers.CallResult
|
||||||
// @router /RefreshHistoryOrdersEarningPrice [post]
|
// @router /RefreshHistoryOrdersEarningPrice [post]
|
||||||
func (c *OrderController) RefreshHistoryOrdersEarningPrice() {
|
func (c *OrderController) RefreshHistoryOrdersEarningPrice() {
|
||||||
c.callRefreshHistoryOrdersEarningPrice(func(params *tOrderRefreshHistoryOrdersEarningPriceParams) (retVal interface{}, errCode string, err error) {
|
c.callRefreshHistoryOrdersEarningPrice(func(params *tOrderRefreshHistoryOrdersEarningPriceParams) (retVal interface{}, errCode string, err error) {
|
||||||
var vendorIDList []int
|
var vendorIDList, actIDList []int
|
||||||
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList); err == nil {
|
if err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDList, params.ActIDs, &actIDList); err == nil {
|
||||||
retVal, err = orderman.FixedOrderManager.RefreshHistoryOrdersEarningPrice(params.Ctx, params.VendorOrderID, vendorIDList, params.StoreID, params.FromTime, params.ToTime, params.IsAsync, params.IsContinueWhenError)
|
retVal, err = orderman.FixedOrderManager.RefreshHistoryOrdersEarningPrice(params.Ctx, params.VendorOrderID, actIDList, vendorIDList, params.StoreID, params.FromTime, params.ToTime, params.IsAsync, params.IsContinueWhenError)
|
||||||
}
|
}
|
||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user