Browse Source

更新

guide_order
huangjiajun 6 months ago
parent
commit
bcddaa3fc8
8 changed files with 44 additions and 29 deletions
  1. +12
    -6
      app/db/db_newcomers_free_product.go
  2. +6
    -3
      app/db/db_second_newcomers_free.go
  3. +1
    -0
      app/db/model/ord_item_info.go
  4. +1
    -0
      app/db/model/ord_list.go
  5. +1
    -0
      app/md/order.go
  6. +8
    -7
      app/svc/svc_order_track_save_create.go
  7. +11
    -9
      app/svc/svc_order_track_save_create_update.go
  8. +4
    -4
      app/svc/svc_order_track_save_update.go

+ 12
- 6
app/db/db_newcomers_free_product.go View File

@@ -12,7 +12,7 @@ import (
) )


// FreeProductByID is 获取新人免单对应的商品id // 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) m := new(model.NewcomersFreeProduct)
var has bool var has bool
var err error 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) has, err = Db.Where("good_id LIKE ?", "%-"+gid).Get(m)
} else { } 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 { if err != nil {
@@ -36,7 +39,7 @@ func FreeProductByID(Db *xorm.Engine, gid, provider string) (*model.NewcomersFre


return m, nil 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) m := new(model.MoreNewcomersFreeProduct)
var has bool var has bool
var err error 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) has, err = Db.Where("good_id LIKE ?", "%-"+gid).Get(m)
} else { } 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 { if err != nil {


+ 6
- 3
app/db/db_second_newcomers_free.go View File

@@ -73,7 +73,7 @@ func SecondGetPriceTypeById(Db *xorm.Engine, id int) *model.SecondNewcomersFreeP
} }
return &price 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) m := new(model.SecondNewcomersFreeProduct)
var has bool var has bool
var err error 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) has, err = Db.Where("good_id LIKE ?", "%-"+gid).Get(m)
} else { } 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 { if err != nil {


+ 1
- 0
app/db/model/ord_item_info.go View File

@@ -7,4 +7,5 @@ type OrdItemInfo struct {
Thumbnail string `json:"thumbnail" xorm:"not null default '' comment('缩略图URL') VARCHAR(2000)"` Thumbnail string `json:"thumbnail" xorm:"not null default '' comment('缩略图URL') VARCHAR(2000)"`
ItemTitle string `json:"item_title" xorm:"not null default '' comment('标题') VARCHAR(256)"` ItemTitle string `json:"item_title" xorm:"not null default '' comment('标题') VARCHAR(256)"`
ItemLink string `json:"item_link" xorm:"not null default '' comment('商品链接') VARCHAR(2000)"` 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)"`
} }

+ 1
- 0
app/db/model/ord_list.go View File

@@ -60,4 +60,5 @@ type OrdList struct {
OrderFormType int `xorm:"not null default 0 INT(1)" json:"order_form_type"` 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"` IsTotal int `xorm:"not null default 0 INT(1)" json:"is_total"`
TaskType string `xorm:"not null default '' VARCHAR(100)" json:"task_type"` TaskType string `xorm:"not null default '' VARCHAR(100)" json:"task_type"`
NumItemId string `xorm:"not null default '' VARCHAR(100)" json:"num_item_id"`
} }

+ 1
- 0
app/md/order.go View File

@@ -148,6 +148,7 @@ type OrderInfo struct {
ParentOrdId int64 ParentOrdId int64
Pvd string Pvd string
ItemId string ItemId string
SkuId string
ItemNum int ItemNum int
ItemPrice float64 ItemPrice float64
ItemTitle string ItemTitle string


+ 8
- 7
app/svc/svc_order_track_save_create.go View File

@@ -566,6 +566,7 @@ func OrderSaveCreate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, opts
ParentOrdId: v.ParentOrdId, ParentOrdId: v.ParentOrdId,
Pvd: newPvd, Pvd: newPvd,
ItemId: v.ItemId, ItemId: v.ItemId,
NumItemId: v.SkuId,
ItemNum: v.ItemNum, ItemNum: v.ItemNum,
ItemPrice: v.ItemPrice, ItemPrice: v.ItemPrice,
PaidPrice: v.PaidPrice, 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] == "//" { if len(v.Thumbnail) > 3 && v.Thumbnail[0:2] == "//" {
thumbnail = "http:" + v.Thumbnail thumbnail = "http:" + v.Thumbnail
} }

db.DbsOrderItemInfoInsert(eg, &model.OrdItemInfo{ 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 := "" mode := ""
if opt != nil { 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 { 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 { if err != nil || m == nil {


logx.Warn(err) logx.Warn(err)


+ 11
- 9
app/svc/svc_order_track_save_create_update.go View File

@@ -229,7 +229,7 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo,
NotSettleDeduct(eg, &v, dbName) NotSettleDeduct(eg, &v, dbName)
} }
if v.State != 4 && v.PriceType > 0 { 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) storeOrder := db.GuideStoreOrder(eg, v.OrdId)
if m != nil { if m != nil {
@@ -258,7 +258,7 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo,
} }
} }
if v.State != 4 && v.SecondPriceType > 0 { 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 { if m != nil {
m.Stock++ m.Stock++
m.Sale-- m.Sale--
@@ -269,7 +269,7 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo,
} }
} }
if v.State == 4 && v.PriceType > 0 { 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) storeOrder := db.GuideStoreOrder(eg, v.OrdId)
if m != nil { if m != nil {
@@ -292,7 +292,7 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo,


} }
if v.State == 4 && v.ThirdPriceType > 0 { 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) storeOrder := db.GuideStoreOrder(eg, v.OrdId)
if m != nil { if m != nil {
@@ -878,6 +878,7 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo,
} }
// 插入新订单 // 插入新订单
newOrd := &model.OrdList{ newOrd := &model.OrdList{
NumItemId: v.SkuId,
TaskType: v.TaskType, TaskType: v.TaskType,
OrderFormType: orderFormType, OrderFormType: orderFormType,
OrdId: oid, OrdId: oid,
@@ -941,11 +942,12 @@ func OrderSaveCreateUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo,
} }


db.DbsOrderItemInfoInsert(eg, &model.OrdItemInfo{ 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 := "" mode := ""
if opt != nil { if opt != nil {


+ 4
- 4
app/svc/svc_order_track_save_update.go View File

@@ -220,7 +220,7 @@ func OrderSaveUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, opts
NotSettleDeduct(eg, &v, dbName) NotSettleDeduct(eg, &v, dbName)
} }
if v.State != 4 && v.PriceType > 0 { 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) storeOrder := db.GuideStoreOrder(eg, v.OrdId)
if m != nil { 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 { 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 { if m != nil {
m.Stock++ m.Stock++
m.Sale-- m.Sale--
@@ -260,7 +260,7 @@ func OrderSaveUpdate(eg *xorm.Engine, pvd string, ordData *[]md.OrderInfo, opts
} }
} }
if v.State == 4 && v.PriceType > 0 { 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) storeOrder := db.GuideStoreOrder(eg, v.OrdId)
if m != nil { 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 { 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) storeOrder := db.GuideStoreOrder(eg, v.OrdId)
if m != nil { if m != nil {


Loading…
Cancel
Save