CaculateSkuEarningPrice中调用ConstrainPayPercentage
+RefreshOrdersPriceInfo
This commit is contained in:
@@ -751,3 +751,55 @@ func RefreshOrdersWithoutJxStoreID(ctx *jxcontext.Context, fromDate, toDate stri
|
|||||||
}
|
}
|
||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RefreshOrdersPriceInfo(ctx *jxcontext.Context, fromTime, toTime time.Time, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
|
if utils.IsTimeZero(fromTime) {
|
||||||
|
return "", fmt.Errorf("必须指定起始时间")
|
||||||
|
}
|
||||||
|
if utils.IsTimeZero(toTime) {
|
||||||
|
toTime = fromTime
|
||||||
|
}
|
||||||
|
|
||||||
|
db := dao.GetDB()
|
||||||
|
orderList, err := dao.QueryOrders(db, "", 0, nil, 0, fromTime, toTime)
|
||||||
|
if err == nil && len(orderList) > 0 {
|
||||||
|
task := tasksch.NewParallelTask("RefreshOrdersPriceInfo", tasksch.NewParallelConfig().SetParallelCount(1).SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||||
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
curOrder := batchItemList[0].(*model.GoodsOrder)
|
||||||
|
newOrder, err := FixedOrderManager.LoadOrder(curOrder.VendorOrderID, curOrder.VendorID)
|
||||||
|
if err == nil {
|
||||||
|
db := dao.GetDB()
|
||||||
|
if err = FixedOrderManager.updateOrderOtherInfo(newOrder, db); err == nil {
|
||||||
|
dao.Begin(db)
|
||||||
|
defer func() {
|
||||||
|
if r := recover(); r != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
panic(r)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
if _, err = dao.UpdateEntity(db, newOrder); err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, sku := range newOrder.Skus {
|
||||||
|
if _, err = dao.UpdateEntity(db, sku); err != nil {
|
||||||
|
dao.Rollback(db)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
dao.Commit(db)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return retVal, err
|
||||||
|
}, orderList)
|
||||||
|
tasksch.HandleTask(task, nil, true).Run()
|
||||||
|
if isAsync {
|
||||||
|
hint = task.GetID()
|
||||||
|
} else {
|
||||||
|
_, err = task.GetResult(0)
|
||||||
|
hint = "1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hint, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -487,6 +487,7 @@ func CaculateSkuEarningPrice(shopPrice, salePrice int64, storePayPercentage int)
|
|||||||
if salePrice == 0 || shopPrice > 0 && shopPrice < earningPrice {
|
if salePrice == 0 || shopPrice > 0 && shopPrice < earningPrice {
|
||||||
earningPrice = shopPrice
|
earningPrice = shopPrice
|
||||||
}
|
}
|
||||||
|
storePayPercentage = ConstrainPayPercentage(storePayPercentage)
|
||||||
if storePayPercentage <= 0 {
|
if storePayPercentage <= 0 {
|
||||||
storePayPercentage = model.DefaultEarningPricePercentage
|
storePayPercentage = model.DefaultEarningPricePercentage
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,7 +105,7 @@ func QueryOrders(db *DaoDB, vendorOrderID string, actID int, vendorIDs []int, st
|
|||||||
sqlParams = append(sqlParams, storeID)
|
sqlParams = append(sqlParams, storeID)
|
||||||
}
|
}
|
||||||
if !utils.IsTimeZero(fromDate) && !utils.IsTimeZero(toDate) {
|
if !utils.IsTimeZero(fromDate) && !utils.IsTimeZero(toDate) {
|
||||||
sql += " AND a.order_created_at BETWEEN ? and ?"
|
sql += " AND a.order_created_at BETWEEN ? AND ?"
|
||||||
sqlParams = append(sqlParams, fromDate, toDate)
|
sqlParams = append(sqlParams, fromDate, toDate)
|
||||||
}
|
}
|
||||||
err = GetRows(db, &orderNewList, sql, sqlParams...)
|
err = GetRows(db, &orderNewList, sql, sqlParams...)
|
||||||
|
|||||||
@@ -925,3 +925,23 @@ func (c *OrderController) ComplaintRider() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 重新计算订单结算信息
|
||||||
|
// @Description 重新计算订单结算信息
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param fromTime formData string true "订单起始时间"
|
||||||
|
// @Param toTime 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 /RefreshOrdersPriceInfo [post]
|
||||||
|
func (c *OrderController) RefreshOrdersPriceInfo() {
|
||||||
|
c.callRefreshOrdersPriceInfo(func(params *tOrderRefreshOrdersPriceInfoParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
timeList, err := jxutils.BatchStr2Time(params.FromTime, params.ToTime)
|
||||||
|
if err == nil {
|
||||||
|
retVal, err = orderman.RefreshOrdersPriceInfo(params.Ctx, timeList[0], timeList[1], params.IsAsync, params.IsContinueWhenError)
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1035,6 +1035,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "RefreshOrdersPriceInfo",
|
||||||
|
Router: `/RefreshOrdersPriceInfo`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:OrderController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "RefreshOrdersWithoutJxStoreID",
|
Method: "RefreshOrdersWithoutJxStoreID",
|
||||||
|
|||||||
Reference in New Issue
Block a user