门店归属订单不漏
This commit is contained in:
@@ -6,6 +6,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/tempop"
|
||||
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/business/jxcallback/orderman"
|
||||
"git.rosy.net.cn/jx-callback/business/jxstore/act"
|
||||
@@ -160,6 +162,10 @@ func doDailyWork() {
|
||||
// 每天补全前一天与当天的订单
|
||||
curDate := utils.Time2Date(time.Now())
|
||||
orderman.FixedOrderManager.AmendMissingOrders(jxcontext.AdminCtx, nil, 0, curDate.Add(-24*time.Hour), curDate, true, true)
|
||||
//订单门店归属补漏
|
||||
//fromDate, toDate都不传默认刷新当前天5天以前的订单,只传fromDate默认刷新fromDate到当天的订单
|
||||
//只传toDate默认刷新toDate到5天以前的订单
|
||||
tempop.RefreshOrdersWithoutJxStoreID(jxcontext.AdminCtx, "", "", true, true)
|
||||
}
|
||||
|
||||
func RefreshRealMobile(ctx *jxcontext.Context, vendorID int, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
|
||||
@@ -1576,3 +1576,30 @@ func WriteToExcel(task *tasksch.SeqTask, jd []JdUserStruct) (err error) {
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func RefreshOrdersWithoutJxStoreID(ctx *jxcontext.Context, fromDate, toDate string, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
var (
|
||||
fromDateParam time.Time
|
||||
toDateParam time.Time
|
||||
)
|
||||
if fromDate != "" {
|
||||
fromDateParam = utils.Str2Time(fromDate)
|
||||
}
|
||||
if toDate != "" {
|
||||
toDateParam = utils.Str2Time(toDate)
|
||||
}
|
||||
db := dao.GetDB()
|
||||
task := tasksch.NewParallelTask("订单门店归属补漏", tasksch.NewParallelConfig().SetParallelCount(1), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
_, err = dao.UpdateOrdersWithoutJxStoreID(db, fromDateParam, toDateParam)
|
||||
return retVal, err
|
||||
}, []int{0})
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
if !isAsync {
|
||||
_, err = task.GetResult(0)
|
||||
hint = "1"
|
||||
} else {
|
||||
hint = task.GetID()
|
||||
}
|
||||
return hint, err
|
||||
}
|
||||
|
||||
@@ -918,3 +918,39 @@ func GetOrders(db *DaoDB, ids []int64, isIncludeSku, isIncludeFake bool, fromDat
|
||||
}
|
||||
return orders, totalCount, err
|
||||
}
|
||||
|
||||
func UpdateOrdersWithoutJxStoreID(db *DaoDB, fromDate, toDate time.Time) (count int64, err error) {
|
||||
sql := `
|
||||
UPDATE goods_order t1
|
||||
JOIN store_map a ON a.vendor_store_id = t1.vendor_store_id
|
||||
SET t1.jx_store_id = a.store_id
|
||||
WHERE t1.jx_store_id = 0
|
||||
AND t1.status != ?
|
||||
AND t1.vendor_store_id != ?
|
||||
AND a.status = ?
|
||||
`
|
||||
sqlParams := []interface{}{
|
||||
model.OrderStatusCanceled,
|
||||
2523687, //测试门店
|
||||
model.StoreStatusOpened,
|
||||
}
|
||||
sql += " AND t1.order_created_at >= ?"
|
||||
sql += " AND t1.order_created_at <= ?"
|
||||
if !utils.IsTimeZero(fromDate) {
|
||||
sqlParams = append(sqlParams, fromDate)
|
||||
if !utils.IsTimeZero(toDate) {
|
||||
sqlParams = append(sqlParams, toDate)
|
||||
} else {
|
||||
sqlParams = append(sqlParams, time.Now())
|
||||
}
|
||||
} else {
|
||||
if !utils.IsTimeZero(toDate) {
|
||||
sqlParams = append(sqlParams, toDate.AddDate(0, 0, -5))
|
||||
sqlParams = append(sqlParams, toDate)
|
||||
} else {
|
||||
sqlParams = append(sqlParams, time.Now().AddDate(0, 0, -5))
|
||||
sqlParams = append(sqlParams, time.Now())
|
||||
}
|
||||
}
|
||||
return ExecuteSQL(db, sql, sqlParams)
|
||||
}
|
||||
|
||||
@@ -382,3 +382,20 @@ func (c *TempOpController) GetJdUsers() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 订单门店归属补漏
|
||||
// @Description 订单门店归属补漏
|
||||
// @Param token header string true "认证token"
|
||||
// @Param fromDate formData string false "开始日期"
|
||||
// @Param toDate formData string false "结束日期(缺省不限制)"
|
||||
// @Param isAsync formData bool false "是否异步操作"
|
||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /RefreshOrdersWithoutJxStoreID [post]
|
||||
func (c *TempOpController) RefreshOrdersWithoutJxStoreID() {
|
||||
c.callRefreshOrdersWithoutJxStoreID(func(params *tTempopRefreshOrdersWithoutJxStoreIDParams) (retVal interface{}, errCode string, err error) {
|
||||
retVal, err = tempop.RefreshOrdersWithoutJxStoreID(params.Ctx, params.FromDate, params.ToDate, params.IsAsync, params.IsContinueWhenError)
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1854,6 +1854,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TempOpController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TempOpController"],
|
||||
beego.ControllerComments{
|
||||
Method: "RefreshOrdersWithoutJxStoreID",
|
||||
Router: `/RefreshOrdersWithoutJxStoreID`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TempOpController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:TempOpController"],
|
||||
beego.ControllerComments{
|
||||
Method: "RetrieveEbaiShopLicence",
|
||||
|
||||
Reference in New Issue
Block a user