From bcddaa3fc83c0012f6b53e76ee2c8c6ce9e86b22 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Tue, 9 Jul 2024 16:24:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/db/db_newcomers_free_product.go | 18 +++++++++++------ app/db/db_second_newcomers_free.go | 9 ++++++--- app/db/model/ord_item_info.go | 1 + app/db/model/ord_list.go | 1 + app/md/order.go | 1 + app/svc/svc_order_track_save_create.go | 15 +++++++------- app/svc/svc_order_track_save_create_update.go | 20 ++++++++++--------- app/svc/svc_order_track_save_update.go | 8 ++++---- 8 files changed, 44 insertions(+), 29 deletions(-) diff --git a/app/db/db_newcomers_free_product.go b/app/db/db_newcomers_free_product.go index ef0177b..6b34fc7 100644 --- a/app/db/db_newcomers_free_product.go +++ b/app/db/db_newcomers_free_product.go @@ -12,7 +12,7 @@ import ( ) // FreeProductByID is 获取新人免单对应的商品id -func FreeProductByID(Db *xorm.Engine, gid, provider string) (*model.NewcomersFreeProduct, error) { +func FreeProductByID(Db *xorm.Engine, gid, skuId, provider string) (*model.NewcomersFreeProduct, error) { m := new(model.NewcomersFreeProduct) var has bool var err error @@ -23,8 +23,11 @@ func FreeProductByID(Db *xorm.Engine, gid, provider string) (*model.NewcomersFre } has, err = Db.Where("good_id LIKE ?", "%-"+gid).Get(m) } else { - m.GoodId = gid - has, err = Db.Get(m) + sess := Db.Where("good_id=?", gid) + if skuId != "" { + sess.Or("good_id=?", skuId) + } + has, err = sess.Get(m) } if err != nil { @@ -36,7 +39,7 @@ func FreeProductByID(Db *xorm.Engine, gid, provider string) (*model.NewcomersFre return m, nil } -func MoreFreeProductByID(Db *xorm.Engine, gid, provider string) (*model.MoreNewcomersFreeProduct, error) { +func MoreFreeProductByID(Db *xorm.Engine, gid, skuId, provider string) (*model.MoreNewcomersFreeProduct, error) { m := new(model.MoreNewcomersFreeProduct) var has bool var err error @@ -47,8 +50,11 @@ func MoreFreeProductByID(Db *xorm.Engine, gid, provider string) (*model.MoreNewc } has, err = Db.Where("good_id LIKE ?", "%-"+gid).Get(m) } else { - m.GoodId = gid - has, err = Db.Get(m) + sess := Db.Where("good_id=?", gid) + if skuId != "" { + sess.Or("good_id=?", skuId) + } + has, err = sess.Get(m) } if err != nil { diff --git a/app/db/db_second_newcomers_free.go b/app/db/db_second_newcomers_free.go index 6135d27..5f393ee 100644 --- a/app/db/db_second_newcomers_free.go +++ b/app/db/db_second_newcomers_free.go @@ -73,7 +73,7 @@ func SecondGetPriceTypeById(Db *xorm.Engine, id int) *model.SecondNewcomersFreeP } return &price } -func SecondFreeProductByID(Db *xorm.Engine, gid, provider string) (*model.SecondNewcomersFreeProduct, error) { +func SecondFreeProductByID(Db *xorm.Engine, gid, skuId, provider string) (*model.SecondNewcomersFreeProduct, error) { m := new(model.SecondNewcomersFreeProduct) var has bool var err error @@ -84,8 +84,11 @@ func SecondFreeProductByID(Db *xorm.Engine, gid, provider string) (*model.Second } has, err = Db.Where("good_id LIKE ?", "%-"+gid).Get(m) } else { - m.GoodId = gid - has, err = Db.Get(m) + sess := Db.Where("good_id=?", gid) + if skuId != "" { + sess.Or("good_id=?", skuId) + } + has, err = sess.Get(m) } if err != nil { diff --git a/app/db/model/ord_item_info.go b/app/db/model/ord_item_info.go index 45144bb..4bbfa97 100644 --- a/app/db/model/ord_item_info.go +++ b/app/db/model/ord_item_info.go @@ -7,4 +7,5 @@ type OrdItemInfo struct { Thumbnail string `json:"thumbnail" xorm:"not null default '' comment('缩略图URL') VARCHAR(2000)"` ItemTitle string `json:"item_title" xorm:"not null default '' comment('标题') VARCHAR(256)"` ItemLink string `json:"item_link" xorm:"not null default '' comment('商品链接') VARCHAR(2000)"` + NumItemId string `json:"num_item_id" xorm:"not null default '' comment('商品链接') VARCHAR(2000)"` } diff --git a/app/db/model/ord_list.go b/app/db/model/ord_list.go index ac2e0b4..27a22e8 100644 --- a/app/db/model/ord_list.go +++ b/app/db/model/ord_list.go @@ -60,4 +60,5 @@ type OrdList struct { OrderFormType int `xorm:"not null default 0 INT(1)" json:"order_form_type"` IsTotal int `xorm:"not null default 0 INT(1)" json:"is_total"` TaskType string `xorm:"not null default '' VARCHAR(100)" json:"task_type"` + NumItemId string `xorm:"not null default '' VARCHAR(100)" json:"num_item_id"` } diff --git a/app/md/order.go b/app/md/order.go index a6cef18..c303d7f 100644 --- a/app/md/order.go +++ b/app/md/order.go @@ -148,6 +148,7 @@ type OrderInfo struct { ParentOrdId int64 Pvd string ItemId string + SkuId string ItemNum int ItemPrice float64 ItemTitle string diff --git a/app/svc/svc_order_track_save_create.go b/app/svc/svc_order_track_save_create.go index d2eb3ae..fa17143 100644 --- a/app/svc/svc_order_track_save_create.go +++ b/app/svc/svc_order_track_save_create.go @@ -566,6 +566,7 @@ func OrderSaveCreate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, opts ParentOrdId: v.ParentOrdId, Pvd: newPvd, ItemId: v.ItemId, + NumItemId: v.SkuId, ItemNum: v.ItemNum, ItemPrice: v.ItemPrice, PaidPrice: v.PaidPrice, @@ -619,13 +620,13 @@ func OrderSaveCreate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, opts if len(v.Thumbnail) > 3 && v.Thumbnail[0:2] == "//" { thumbnail = "http:" + v.Thumbnail } - db.DbsOrderItemInfoInsert(eg, &model.OrdItemInfo{ - ItemId: v.ItemId, - Pvd: newPvd, - Thumbnail: thumbnail, - ItemTitle: v.ItemTitle, - ItemLink: v.ItemLink, + ItemId: v.ItemId, + Pvd: newPvd, + Thumbnail: thumbnail, + NumGoodsId: v.SkuId, + ItemTitle: v.ItemTitle, + ItemLink: v.ItemLink, }) mode := "" if opt != nil { @@ -756,7 +757,7 @@ func CheckValid(eg *xorm.Engine, dbName string, uid, isOrder int, ch *rabbit.Cha } func orderSecondFreeCheck(eg *xorm.Engine, v *md.OrderInfo, oid int64, uid int, isNeedReduct int) *model.SecondNewcomersFreeProduct { - m, err := db.SecondFreeProductByID(eg, v.ItemId, v.Pvd) + m, err := db.SecondFreeProductByID(eg, v.ItemId, v.SkuId, v.Pvd) if err != nil || m == nil { logx.Warn(err) diff --git a/app/svc/svc_order_track_save_create_update.go b/app/svc/svc_order_track_save_create_update.go index e3e7614..df68ec8 100644 --- a/app/svc/svc_order_track_save_create_update.go +++ b/app/svc/svc_order_track_save_create_update.go @@ -229,7 +229,7 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, NotSettleDeduct(eg, &v, dbName) } if v.State != 4 && v.PriceType > 0 { - m, _ := db.FreeProductByID(eg, v.ItemId, v.Pvd) + m, _ := db.FreeProductByID(eg, v.ItemId, v.NumItemId, v.Pvd) //直接退回账号了 定制 storeOrder := db.GuideStoreOrder(eg, v.OrdId) if m != nil { @@ -258,7 +258,7 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, } } if v.State != 4 && v.SecondPriceType > 0 { - m, _ := db.SecondFreeProductByID(eg, v.ItemId, v.Pvd) + m, _ := db.SecondFreeProductByID(eg, v.ItemId, v.NumItemId, v.Pvd) if m != nil { m.Stock++ m.Sale-- @@ -269,7 +269,7 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, } } if v.State == 4 && v.PriceType > 0 { - m, _ := db.FreeProductByID(eg, v.ItemId, v.Pvd) + m, _ := db.FreeProductByID(eg, v.ItemId, v.NumItemId, v.Pvd) //直接退回账号了 定制 storeOrder := db.GuideStoreOrder(eg, v.OrdId) if m != nil { @@ -292,7 +292,7 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, } if v.State == 4 && v.ThirdPriceType > 0 { - m, _ := db.MoreFreeProductByID(eg, v.ItemId, v.Pvd) + m, _ := db.MoreFreeProductByID(eg, v.ItemId, v.NumItemId, v.Pvd) //直接退回账号了 定制 storeOrder := db.GuideStoreOrder(eg, v.OrdId) if m != nil { @@ -878,6 +878,7 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, } // 插入新订单 newOrd := &model.OrdList{ + NumItemId: v.SkuId, TaskType: v.TaskType, OrderFormType: orderFormType, OrdId: oid, @@ -941,11 +942,12 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, } db.DbsOrderItemInfoInsert(eg, &model.OrdItemInfo{ - ItemId: v.ItemId, - Pvd: newPvd, - Thumbnail: thumbnail, - ItemTitle: v.ItemTitle, - ItemLink: v.ItemLink, + ItemId: v.ItemId, + Pvd: newPvd, + Thumbnail: thumbnail, + ItemTitle: v.ItemTitle, + ItemLink: v.ItemLink, + NumGoodsId: v.SkuId, }) mode := "" if opt != nil { diff --git a/app/svc/svc_order_track_save_update.go b/app/svc/svc_order_track_save_update.go index f0df1a1..bea67fd 100644 --- a/app/svc/svc_order_track_save_update.go +++ b/app/svc/svc_order_track_save_update.go @@ -220,7 +220,7 @@ func OrderSaveUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, opts NotSettleDeduct(eg, &v, dbName) } if v.State != 4 && v.PriceType > 0 { - m, _ := db.FreeProductByID(eg, v.ItemId, v.Pvd) + m, _ := db.FreeProductByID(eg, v.ItemId, v.NumItemId, v.Pvd) //直接退回账号了 定制 storeOrder := db.GuideStoreOrder(eg, v.OrdId) if m != nil { @@ -249,7 +249,7 @@ func OrderSaveUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, opts } } if v.State != 4 && v.SecondPriceType > 0 { - m, _ := db.SecondFreeProductByID(eg, v.ItemId, v.Pvd) + m, _ := db.SecondFreeProductByID(eg, v.ItemId, v.NumItemId, v.Pvd) if m != nil { m.Stock++ m.Sale-- @@ -260,7 +260,7 @@ func OrderSaveUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, opts } } if v.State == 4 && v.PriceType > 0 { - m, _ := db.FreeProductByID(eg, v.ItemId, v.Pvd) + m, _ := db.FreeProductByID(eg, v.ItemId, v.NumItemId, v.Pvd) //直接退回账号了 定制 storeOrder := db.GuideStoreOrder(eg, v.OrdId) if m != nil { @@ -283,7 +283,7 @@ func OrderSaveUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, opts } if v.State == 4 && v.ThirdPriceType > 0 { - m, _ := db.MoreFreeProductByID(eg, v.ItemId, v.Pvd) + m, _ := db.MoreFreeProductByID(eg, v.ItemId, v.NumItemId, v.Pvd) //直接退回账号了 定制 storeOrder := db.GuideStoreOrder(eg, v.OrdId) if m != nil {