Accept Merge Request #110: (yonghui -> mark)
Merge Request: 订单预警 Created By: @苏尹岚 Accepted By: @苏尹岚 URL: https://rosydev.coding.net/p/jx-callback/d/jx-callback/git/merge/110
This commit is contained in:
@@ -224,6 +224,9 @@ func init() {
|
||||
},
|
||||
TimeoutAction: func(savedOrderInfo *WatchOrderInfo, bill *model.Waybill) (err error) {
|
||||
order := savedOrderInfo.order
|
||||
if order != nil && order.TotalShopMoney == 0 {
|
||||
globals.SugarLogger.Debugf("init() TotalShopMoney=0 orderID:%s", order.VendorOrderID)
|
||||
}
|
||||
mobile := order.ConsigneeMobile
|
||||
if order.ConsigneeMobile2 != "" {
|
||||
mobile = order.ConsigneeMobile2
|
||||
@@ -353,6 +356,9 @@ func Init() {
|
||||
// 以下是订单
|
||||
func (s *DefScheduler) OnOrderNew(order *model.GoodsOrder, isPending bool) (err error) {
|
||||
globals.SugarLogger.Debugf("OnOrderNew orderID:%s", order.VendorOrderID)
|
||||
if order != nil && order.TotalShopMoney == 0 {
|
||||
globals.SugarLogger.Debugf("OnOrderNew TotalShopMoney=0 orderID:%s", order.VendorOrderID)
|
||||
}
|
||||
savedOrderInfo := s.loadSavedOrderFromMap(model.Order2Status(order), false)
|
||||
savedOrderInfo.SetOrder(order)
|
||||
if order.Status >= model.OrderStatusNew {
|
||||
|
||||
@@ -2835,3 +2835,45 @@ func GetCellForFocusStoreSkus(db *dao.DaoDB, rowNum int, row []string, sheetPara
|
||||
}
|
||||
skuMap[skuID] = price
|
||||
}
|
||||
|
||||
func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||
var (
|
||||
skuBindInfos []*StoreSkuBindInfo
|
||||
skuNameMap = make(map[int][]*StoreSkuBindSkuInfo)
|
||||
storeIDs []int
|
||||
)
|
||||
db := dao.GetDB()
|
||||
skuList, err := dao.GetSkus(db, skuIDs, nil, nil, nil)
|
||||
storeList, err := dao.GetStoreList(db, nil, nil, "")
|
||||
for _, v := range storeList {
|
||||
storeIDs = append(storeIDs, v.ID)
|
||||
}
|
||||
for _, v := range skuList {
|
||||
skuNameMap[v.NameID] = append(skuNameMap[v.NameID], &StoreSkuBindSkuInfo{
|
||||
SkuID: v.ID,
|
||||
IsSale: 1,
|
||||
})
|
||||
}
|
||||
task := tasksch.NewParallelTask("根据skuID部分关注商品", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||
store := batchItemList[0].(*model.Store)
|
||||
for k, v := range skuNameMap {
|
||||
midPrice, _ := dao.GetMidPriceByNameID(db, store.CityCode, k, utils.Time2Date(time.Now().AddDate(0, 0, -1)))
|
||||
skuBindInfo := &StoreSkuBindInfo{
|
||||
NameID: k,
|
||||
UnitPrice: midPrice,
|
||||
IsFocus: 1,
|
||||
Skus: v,
|
||||
}
|
||||
retVal = []*StoreSkuBindInfo{skuBindInfo}
|
||||
}
|
||||
return retVal, err
|
||||
}, storeList)
|
||||
tasksch.HandleTask(task, nil, true).Run()
|
||||
result, err := task.GetResult(0)
|
||||
for _, v := range result {
|
||||
skuBindInfos = append(skuBindInfos, v.(*StoreSkuBindInfo))
|
||||
}
|
||||
hint, err = UpdateStoresSkus(ctx, storeIDs, skuBindInfos, false, isAsync, isContinueWhenError)
|
||||
return hint, err
|
||||
}
|
||||
|
||||
@@ -1347,12 +1347,11 @@ func GetDeletedStoreSkuBind(db *DaoDB, storeID, skuID int) (storeSkuBind *model.
|
||||
|
||||
func GetMidPriceByNameID(db *DaoDB, cityCode, skuNameID int, snapDate time.Time) (midPrice int, err error) {
|
||||
var (
|
||||
storeSkuExt []*StoreSkuExt
|
||||
price int
|
||||
skuMap = make(map[int]int)
|
||||
sku []*model.SkuAndName
|
||||
skuMap = make(map[int]int)
|
||||
)
|
||||
sql := `
|
||||
SELECT a.mid_price bind_price,a.sku_id,b.spec_quality sku_spec_quality
|
||||
SELECT a.mid_price price, a.sku_id id, b.spec_quality, c.unit, b.spec_unit
|
||||
FROM price_refer_snapshot a
|
||||
JOIN sku b ON a.sku_id = b.id
|
||||
JOIN sku_name c ON c.id = b.name_id
|
||||
@@ -1365,13 +1364,26 @@ func GetMidPriceByNameID(db *DaoDB, cityCode, skuNameID int, snapDate time.Time)
|
||||
snapDate,
|
||||
cityCode,
|
||||
}
|
||||
err = GetRows(db, &storeSkuExt, sql, sqlParams...)
|
||||
err = GetRows(db, &sku, sql, sqlParams...)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
if len(storeSkuExt) > 0 {
|
||||
for _, v := range storeSkuExt {
|
||||
price = model.SpecialSpecQuality / int(utils.Float64TwoInt64(float64(v.SkuSpecQuality))) * v.BindPrice
|
||||
if len(sku) > 0 {
|
||||
for _, v := range sku {
|
||||
var (
|
||||
price int
|
||||
specQuality float64
|
||||
)
|
||||
if v.Unit == model.SpecialUnit {
|
||||
if v.SpecUnit == model.SpecUnitNames[1] || v.SpecUnit == model.SpecUnitNames[2] {
|
||||
specQuality = float64(v.SpecQuality) * 1000
|
||||
} else {
|
||||
specQuality = float64(v.SpecQuality)
|
||||
}
|
||||
price = int(utils.Float64TwoInt64(utils.Int2Float64(model.SpecialSpecQuality) / specQuality * utils.Int2Float64(v.Price)))
|
||||
} else {
|
||||
price = v.Price
|
||||
}
|
||||
if skuMap[skuNameID] < price {
|
||||
skuMap[skuNameID] = price
|
||||
}
|
||||
|
||||
@@ -243,6 +243,7 @@ type SkuAndName struct {
|
||||
ExPrefix string
|
||||
ExPrefixBegin *time.Time
|
||||
ExPrefixEnd *time.Time
|
||||
Price int
|
||||
}
|
||||
|
||||
func (*Sku) TableUnique() [][]string {
|
||||
|
||||
@@ -554,7 +554,7 @@ func (c *StoreSkuController) FocusStoreSkusByExcel() {
|
||||
|
||||
// @Title 得到门店的分类列表
|
||||
// @Description 得到门店的分类列表(按商品销量)
|
||||
// @Param token header string false "认证token"
|
||||
// @Param token header string true "认证token"
|
||||
// @Param storeID query int true "门店ID"
|
||||
// @Param parentID query int false "父分类id"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
@@ -572,7 +572,7 @@ func (c *StoreSkuController) GetStoreCategories() {
|
||||
|
||||
// @Title 获取各平台所有门店某商品的价格
|
||||
// @Description 获取各平台所有门店某商品的价格
|
||||
// @Param token header string false "认证token"
|
||||
// @Param token header string true "认证token"
|
||||
// @Param skuID formData int true "商品ID"
|
||||
// @Param vendorIDs formData string true "厂商ID列表"
|
||||
// @Param isAsync formData bool true "是否异步,缺省是同步"
|
||||
@@ -589,3 +589,22 @@ func (c *StoreSkuController) GetVendorStoreSkuPrice() {
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
// @Title 根据skuID关注商品,价格为中位价,部分可售
|
||||
// @Description 根据skuID关注商品,价格为中位价,部分可售
|
||||
// @Param token header string true "认证token"
|
||||
// @Param skuIDs formData string true "商品ID列表"
|
||||
// @Param isAsync formData bool true "是否异步,缺省是同步"
|
||||
// @Param isContinueWhenError formData bool true "单个同步失败是否继续,缺省false"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
// @router /FocusStoreSkusBySku [post]
|
||||
func (c *StoreSkuController) FocusStoreSkusBySku() {
|
||||
var skuIDList []int
|
||||
c.callFocusStoreSkusBySku(func(params *tStoreSkuFocusStoreSkusBySkuParams) (retVal interface{}, errCode string, err error) {
|
||||
if jxutils.Strings2Objs(params.SkuIDs, &skuIDList); err == nil {
|
||||
retVal, err = cms.FocusStoreSkusBySku(params.Ctx, skuIDList, params.IsAsync, params.IsContinueWhenError)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1620,6 +1620,15 @@ func init() {
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "FocusStoreSkusBySku",
|
||||
Router: `/FocusStoreSkusBySku`,
|
||||
AllowHTTPMethods: []string{"post"},
|
||||
MethodParams: param.Make(),
|
||||
Filters: nil,
|
||||
Params: nil})
|
||||
|
||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
||||
beego.ControllerComments{
|
||||
Method: "GetMissingStoreSkuFromOrder",
|
||||
|
||||
Reference in New Issue
Block a user