根据平台价刷新京西价
This commit is contained in:
@@ -3699,3 +3699,107 @@ func RefreshJxPriceByVendor(ctx *jxcontext.Context, jdStoreSkus []*JdStoreSkus,
|
|||||||
}
|
}
|
||||||
return hint, err
|
return hint, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func RefreshJxPriceByVendor2(ctx *jxcontext.Context, storeIDs []int, vendorID int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
|
var (
|
||||||
|
db = dao.GetDB()
|
||||||
|
param []*StoreSkuBindInfo
|
||||||
|
)
|
||||||
|
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
|
||||||
|
switch step {
|
||||||
|
case 0:
|
||||||
|
for _, storeID := range storeIDs {
|
||||||
|
var (
|
||||||
|
pricePercentagePack []*model.PricePercentageItem
|
||||||
|
skuNameMap = make(map[int]int64)
|
||||||
|
)
|
||||||
|
storeDetail, _ := dao.GetStoreDetail(db, storeID, vendorID)
|
||||||
|
err = jxutils.Strings2Objs(storeDetail.PricePercentagePackStr, &pricePercentagePack)
|
||||||
|
if partner.IsMultiStore(vendorID) {
|
||||||
|
mulitStoreSkuHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.IPurchasePlatformStoreSkuHandler)
|
||||||
|
skuList, err := dao.GetSkusWithVendor(db, []int{vendorID}, nil, nil, nil, false)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
bareStoreSkuMap := make(map[string][]*partner.StoreSkuInfo)
|
||||||
|
for _, sku := range skuList {
|
||||||
|
bareStoreSkuMap[sku.VendorOrgCode] = append(bareStoreSkuMap[sku.VendorOrgCode], &partner.StoreSkuInfo{
|
||||||
|
SkuID: sku.ID,
|
||||||
|
VendorSkuID: sku.VendorSkuID,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
for _, orgCode := range apimanager.CurAPIManager.GetAppOrgCodeList(vendorID) {
|
||||||
|
outStoreSkuList, _ := mulitStoreSkuHandler.GetStoreSkusBareInfo(ctx, orgCode, task, storeID, storeDetail.VendorStoreID, bareStoreSkuMap[orgCode])
|
||||||
|
for _, sku := range outStoreSkuList {
|
||||||
|
price, nameID := getSkuNamePrice(db, sku.SkuID, sku.VendorPrice)
|
||||||
|
if skuNameMap[nameID] < price {
|
||||||
|
skuNameMap[nameID] = price
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for k, v := range skuNameMap {
|
||||||
|
unitPrice := jxutils.CaculateJxPriceByPricePack(pricePercentagePack, 0, int(v))
|
||||||
|
storeSkuBindInfo := &StoreSkuBindInfo{
|
||||||
|
StoreID: storeID,
|
||||||
|
NameID: k,
|
||||||
|
UnitPrice: unitPrice,
|
||||||
|
}
|
||||||
|
param = append(param, storeSkuBindInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
singleStoreHandler := partner.GetPurchasePlatformFromVendorID(vendorID).(partner.ISingleStoreStoreSkuHandler)
|
||||||
|
outSkuNameList, _ := singleStoreHandler.GetStoreSkusFullInfo(ctx, task, storeID, storeDetail.VendorStoreID, nil)
|
||||||
|
for _, skuName := range outSkuNameList {
|
||||||
|
sku := skuName.SkuList[0]
|
||||||
|
price, nameID := getSkuNamePrice(db, sku.SkuID, sku.VendorPrice)
|
||||||
|
if skuNameMap[nameID] < price {
|
||||||
|
skuNameMap[nameID] = price
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for k, v := range skuNameMap {
|
||||||
|
unitPrice := jxutils.CaculateJxPriceByPricePack(pricePercentagePack, 0, int(v))
|
||||||
|
storeSkuBindInfo := &StoreSkuBindInfo{
|
||||||
|
StoreID: storeID,
|
||||||
|
NameID: k,
|
||||||
|
UnitPrice: unitPrice,
|
||||||
|
}
|
||||||
|
param = append(param, storeSkuBindInfo)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
_, err = UpdateStoresSkusByBind(ctx, nil, param, isAsync, isContinueWhenError)
|
||||||
|
}
|
||||||
|
return result, err
|
||||||
|
}
|
||||||
|
taskSeq := tasksch.NewSeqTask2("根据平台价刷新京西平台价", ctx, isContinueWhenError, taskSeqFunc, 2)
|
||||||
|
tasksch.HandleTask(taskSeq, nil, true).Run()
|
||||||
|
if !isAsync {
|
||||||
|
_, err = taskSeq.GetResult(0)
|
||||||
|
hint = "1"
|
||||||
|
} else {
|
||||||
|
hint = taskSeq.GetID()
|
||||||
|
}
|
||||||
|
return hint, err
|
||||||
|
}
|
||||||
|
|
||||||
|
func getSkuNamePrice(db *dao.DaoDB, skuID int, orgPrice int64) (price int64, nameID int) {
|
||||||
|
var (
|
||||||
|
specQuality float64
|
||||||
|
)
|
||||||
|
skuList, _ := dao.GetSkus(db, []int{skuID}, nil, nil, nil)
|
||||||
|
for _, v := range skuList {
|
||||||
|
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 = utils.Float64TwoInt64(utils.Int2Float64(model.SpecialSpecQuality) / specQuality * utils.Int2Float64(int(orgPrice)))
|
||||||
|
} else {
|
||||||
|
price = orgPrice
|
||||||
|
}
|
||||||
|
nameID = v.NameID
|
||||||
|
}
|
||||||
|
return price, nameID
|
||||||
|
}
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ weixinMiniSecret2 = "2a57228a716ce991a52739f0ff41111d"
|
|||||||
tonglianPayAppID = "00183083"
|
tonglianPayAppID = "00183083"
|
||||||
tonglianPayKey = "18048531223"
|
tonglianPayKey = "18048531223"
|
||||||
tonglianPayCusID = "56065105499TVAH"
|
tonglianPayCusID = "56065105499TVAH"
|
||||||
tonglianPayNotifyURL = "http://callback.jxc4.com/tonglian/msg/"
|
tonglianPayNotifyURL = "http://callback.beta.jxc4.com/tonglian/msg/"
|
||||||
|
|
||||||
disableWeimob = false
|
disableWeimob = false
|
||||||
getWeixinTokenURL = "http://www.jxc4.com/v2/sys/GetWXToken"
|
getWeixinTokenURL = "http://www.jxc4.com/v2/sys/GetWXToken"
|
||||||
|
|||||||
@@ -690,3 +690,24 @@ func (c *StoreSkuController) RefreshJxPriceByVendor() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 根据平台价反算京西价2
|
||||||
|
// @Description 根据平台价反算京西价2
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param storeIDs formData string true "门店列表"
|
||||||
|
// @Param vendorID formData int true "厂商ID"
|
||||||
|
// @Param isAsync formData bool true "是否异步,缺省是同步"
|
||||||
|
// @Param isContinueWhenError formData bool true "单个同步失败是否继续,缺省false"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /RefreshJxPriceByVendor2 [put]
|
||||||
|
func (c *StoreSkuController) RefreshJxPriceByVendor2() {
|
||||||
|
var storeIDs []int
|
||||||
|
c.callRefreshJxPriceByVendor2(func(params *tStoreSkuRefreshJxPriceByVendor2Params) (retVal interface{}, errCode string, err error) {
|
||||||
|
if err = jxutils.Strings2Objs(params.StoreIDs, &storeIDs); err != nil {
|
||||||
|
return retVal, "", err
|
||||||
|
}
|
||||||
|
retVal, err = cms.RefreshJxPriceByVendor2(params.Ctx, storeIDs, params.VendorID, params.IsAsync, params.IsContinueWhenError)
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1926,6 +1926,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: 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: "RefreshJxPriceByVendor2",
|
||||||
|
Router: `/RefreshJxPriceByVendor2`,
|
||||||
|
AllowHTTPMethods: []string{"put"},
|
||||||
|
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.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "RefreshStoresSkuByVendor",
|
Method: "RefreshStoresSkuByVendor",
|
||||||
|
|||||||
Reference in New Issue
Block a user