@@ -11,7 +11,7 @@ import ( | |||||
) | ) | ||||
// FreeProductByID is 获取新人免单对应的商品id | // FreeProductByID is 获取新人免单对应的商品id | ||||
func FreeProductByID(sess *xorm.Session, gid, provider string) (*model.NewcomersFreeProduct, error) { | |||||
func FreeProductByID(sess *xorm.Session, gid, skuId, provider string) (*model.NewcomersFreeProduct, error) { | |||||
m := new(model.NewcomersFreeProduct) | m := new(model.NewcomersFreeProduct) | ||||
var has bool | var has bool | ||||
var err error | var err error | ||||
@@ -22,7 +22,10 @@ func FreeProductByID(sess *xorm.Session, gid, provider string) (*model.Newcomers | |||||
} | } | ||||
has, err = sess.Where("good_id LIKE ?", "%-"+gid).Get(m) | has, err = sess.Where("good_id LIKE ?", "%-"+gid).Get(m) | ||||
} else { | } else { | ||||
m.GoodId = gid | |||||
sess.Where("good_id=?", gid) | |||||
if skuId != "" { | |||||
sess.Or("good_id=?", skuId) | |||||
} | |||||
has, err = sess.Get(m) | has, err = sess.Get(m) | ||||
} | } | ||||
@@ -35,7 +38,7 @@ func FreeProductByID(sess *xorm.Session, gid, provider string) (*model.Newcomers | |||||
return m, nil | return m, nil | ||||
} | } | ||||
func MoreFreeProductByID(sess *xorm.Session, gid, provider string) (*model.MoreNewcomersFreeProduct, error) { | |||||
func MoreFreeProductByID(sess *xorm.Session, gid, skuId, provider string) (*model.MoreNewcomersFreeProduct, error) { | |||||
m := new(model.MoreNewcomersFreeProduct) | m := new(model.MoreNewcomersFreeProduct) | ||||
var has bool | var has bool | ||||
var err error | var err error | ||||
@@ -46,7 +49,10 @@ func MoreFreeProductByID(sess *xorm.Session, gid, provider string) (*model.MoreN | |||||
} | } | ||||
has, err = sess.Where("good_id LIKE ?", "%-"+gid).Get(m) | has, err = sess.Where("good_id LIKE ?", "%-"+gid).Get(m) | ||||
} else { | } else { | ||||
m.GoodId = gid | |||||
sess.Where("good_id=?", gid) | |||||
if skuId != "" { | |||||
sess.Or("good_id=?", skuId) | |||||
} | |||||
has, err = sess.Get(m) | has, err = sess.Get(m) | ||||
} | } | ||||
@@ -38,6 +38,7 @@ type ZhiosMallConsume struct { | |||||
type ZhiosOrderFree struct { | type ZhiosOrderFree struct { | ||||
ItemId string `json:"item_id"` | ItemId string `json:"item_id"` | ||||
SkuId string `json:"sku_id"` | |||||
OptPvd string `json:"opt_pvd"` | OptPvd string `json:"opt_pvd"` | ||||
OrderType string `json:"order_type"` | OrderType string `json:"order_type"` | ||||
Pid string `json:"pid"` | Pid string `json:"pid"` | ||||
@@ -343,7 +343,7 @@ func handleZhiosOrderFree(msg []byte) error { | |||||
} | } | ||||
func orderFreeCheck(eg *xorm.Engine, sess *xorm.Session, canalMsg *md.ZhiosOrderFree) *model.NewcomersFreeProduct { | func orderFreeCheck(eg *xorm.Engine, sess *xorm.Session, canalMsg *md.ZhiosOrderFree) *model.NewcomersFreeProduct { | ||||
m, err := db.FreeProductByID(sess, canalMsg.ItemId, canalMsg.OptPvd) | |||||
m, err := db.FreeProductByID(sess, canalMsg.ItemId, canalMsg.SkuId, canalMsg.OptPvd) | |||||
stock := 0 | stock := 0 | ||||
if m != nil && m.StoreId > 0 { //小于多少份就不能出售了 | if m != nil && m.StoreId > 0 { //小于多少份就不能出售了 | ||||
guideStoreStock := db.SysCfgGetWithDb(eg, canalMsg.Mid, "guide_store_stock") | guideStoreStock := db.SysCfgGetWithDb(eg, canalMsg.Mid, "guide_store_stock") | ||||
@@ -483,7 +483,7 @@ func orderFreeCheck(eg *xorm.Engine, sess *xorm.Session, canalMsg *md.ZhiosOrder | |||||
} | } | ||||
func moreOrderFreeCheck(eg *xorm.Engine, sess *xorm.Session, canalMsg *md.ZhiosOrderFree) *model.MoreNewcomersFreeProduct { | func moreOrderFreeCheck(eg *xorm.Engine, sess *xorm.Session, canalMsg *md.ZhiosOrderFree) *model.MoreNewcomersFreeProduct { | ||||
m, err := db.MoreFreeProductByID(sess, canalMsg.ItemId, canalMsg.OptPvd) | |||||
m, err := db.MoreFreeProductByID(sess, canalMsg.ItemId, canalMsg.SkuId, canalMsg.OptPvd) | |||||
stock := 0 | stock := 0 | ||||
if m != nil && m.StoreId > 0 { //小于多少份就不能出售了 | if m != nil && m.StoreId > 0 { //小于多少份就不能出售了 | ||||
guideStoreStock := db.SysCfgGetWithDb(eg, canalMsg.Mid, "guide_store_stock") | guideStoreStock := db.SysCfgGetWithDb(eg, canalMsg.Mid, "guide_store_stock") | ||||