物料订单库存判断

This commit is contained in:
苏尹岚
2020-03-18 14:58:25 +08:00
parent 480d5b8268
commit 239a44afdc
3 changed files with 9 additions and 11 deletions

View File

@@ -523,7 +523,7 @@ func GetStoresSkusNew(ctx *jxcontext.Context, storeIDs, skuIDs []int, isFocus, i
t3.id store_id, t3.name store_name, t3.pay_percentage,
t1.*,
t2.name_id, t2.id sku_id, t2.spec_quality sku_spec_quality, t2.spec_unit sku_spec_unit, t2.weight, t2m.vendor_thing_id sku_jd_id,
t2.comment, t2.category_id sku_category_id, t2.status sku_status,
t2.comment, t2.category_id sku_category_id, t2.status sku_status, t2.eclp_id,
t4.created_at bind_created_at, t4.updated_at bind_updated_at, t4.last_operator bind_last_operator, t4.deleted_at bind_deleted_at,
t4.sub_store_id, t4.price bind_price, IF(t4.unit_price IS NOT NULL, t4.unit_price, t1.price) unit_price, t4.status store_sku_status, t4.auto_sale_at,
t4.ebai_id, t4.mtwm_id,

View File

@@ -233,6 +233,8 @@ type StoreSkuExt struct {
EarningPrice int `json:"earningPrice"`
EarningActID int `orm:"column(earning_act_id)" json:"earningActID"`
EclpID string `orm:"column(eclp_id)" json:"eclpID"`
}
type SkuNameAndPlace struct {

View File

@@ -489,16 +489,6 @@ func generateOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64
if fromStoreID != 0 {
if v.EclpID == "" {
return nil, nil, fmt.Errorf("此商品物料编码为空请联系管理员skuID:[%v]", v.ID)
} else {
result, err := api.JdEclpAPI.QueryStock(v.EclpID)
if err != nil {
return nil, nil, err
}
if len(result) > 0 {
if result[0].UsableNum == 0 {
return nil, nil, fmt.Errorf("此商品库存不足无法购买请联系管理员skuID:[%v]", v.ID)
}
}
}
}
skuMap[v.ID] = v
@@ -514,6 +504,12 @@ func generateOrder(ctx *jxcontext.Context, jxOrder *JxOrderInfo, addressID int64
}
for _, v := range skus {
if storeSkuBind := storeSkuMap[v.SkuID]; storeSkuBind != nil {
result2, _ := api.JdEclpAPI.QueryStock(storeSkuBind.EclpID)
if len(result2) > 0 {
if result2[0].UsableNum < v.Count {
return nil, nil, fmt.Errorf("此商品库存不足无法购买请联系管理员skuID:[%v]", v.SkuID)
}
}
if sku := skuMap[v.SkuID]; sku != nil {
jxSku := &JxSkuInfo{
SkuID: v.SkuID,