diff --git a/app/db/db_newcomers_free_product.go b/app/db/db_newcomers_free_product.go index 8102014..633c889 100644 --- a/app/db/db_newcomers_free_product.go +++ b/app/db/db_newcomers_free_product.go @@ -11,7 +11,7 @@ import ( ) // 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) var has bool 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) } else { - m.GoodId = gid + sess.Where("good_id=?", gid) + if skuId != "" { + sess.Or("good_id=?", skuId) + } has, err = sess.Get(m) } @@ -35,7 +38,7 @@ func FreeProductByID(sess *xorm.Session, gid, provider string) (*model.Newcomers 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) var has bool 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) } else { - m.GoodId = gid + sess.Where("good_id=?", gid) + if skuId != "" { + sess.Or("good_id=?", skuId) + } has, err = sess.Get(m) } diff --git a/consume/md/md_zhios_capital_pool_order_total.go b/consume/md/md_zhios_capital_pool_order_total.go index f6053e4..d671d90 100644 --- a/consume/md/md_zhios_capital_pool_order_total.go +++ b/consume/md/md_zhios_capital_pool_order_total.go @@ -38,6 +38,7 @@ type ZhiosMallConsume struct { type ZhiosOrderFree struct { ItemId string `json:"item_id"` + SkuId string `json:"sku_id"` OptPvd string `json:"opt_pvd"` OrderType string `json:"order_type"` Pid string `json:"pid"` diff --git a/consume/zhios_order_free.go b/consume/zhios_order_free.go index 77ab2ee..15c21a6 100644 --- a/consume/zhios_order_free.go +++ b/consume/zhios_order_free.go @@ -343,7 +343,7 @@ func handleZhiosOrderFree(msg []byte) error { } 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 if m != nil && m.StoreId > 0 { //小于多少份就不能出售了 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 { - m, err := db.MoreFreeProductByID(sess, canalMsg.ItemId, canalMsg.OptPvd) + m, err := db.MoreFreeProductByID(sess, canalMsg.ItemId, canalMsg.SkuId, canalMsg.OptPvd) stock := 0 if m != nil && m.StoreId > 0 { //小于多少份就不能出售了 guideStoreStock := db.SysCfgGetWithDb(eg, canalMsg.Mid, "guide_store_stock")