Bläddra i källkod

更新

guide_order
huangjiajun 5 månader sedan
förälder
incheckning
7083d727d4
5 ändrade filer med 163 tillägg och 1 borttagningar
  1. +1
    -1
      app/db/dbs_order.go
  2. +8
    -0
      app/db/model/user_day_amount.go
  3. +11
    -0
      app/db/model/user_month_amount.go
  4. +96
    -0
      app/svc/svc_order_return_money_save.go
  5. +47
    -0
      app/svc/svc_order_track_save.go

+ 1
- 1
app/db/dbs_order.go Visa fil

@@ -49,7 +49,7 @@ func DbsOrderFindById(eg *xorm.Engine, pvd string, ids string) (*model.OrdList,
}

func DbsOrderUpdate(eg *xorm.Engine, id int64, ord *model.OrdList) error {
if _, err := eg.Where("`ord_id` = ?", id).Cols("parent_ord_id,order_compare,state,paid_price,confirm_at,check_success_at,update_at,pvd_settle_at").Update(ord); err != nil {
if _, err := eg.Where("`ord_id` = ?", id).Cols("parent_ord_id,reason,order_compare,state,paid_price,confirm_at,check_success_at,update_at,pvd_settle_at").Update(ord); err != nil {
return logx.Warn(err)
}
return nil


+ 8
- 0
app/db/model/user_day_amount.go Visa fil

@@ -0,0 +1,8 @@
package model

type UserDayAmount struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
Date int `json:"date" xorm:"comment('202301') INT(11)"`
Amount string `json:"amount" xorm:"default 0.000000 DECIMAL(30,6)"`
}

+ 11
- 0
app/db/model/user_month_amount.go Visa fil

@@ -0,0 +1,11 @@
package model

type UserMonthAmount struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
Date int `json:"date" xorm:"comment('202301') INT(11)"`
Amount string `json:"amount" xorm:"default 0.000000 DECIMAL(30,6)"`
PlatformAmount string `json:"platform_amount" xorm:"default 0.000000 DECIMAL(30,6)"`
ConfirmAmount string `json:"confirm_amount" xorm:"default 0.000000 DECIMAL(30,6)"`
SettleAmount string `json:"settle_amount" xorm:"default 0.000000 DECIMAL(30,6)"`
}

+ 96
- 0
app/svc/svc_order_return_money_save.go Visa fil

@@ -17,6 +17,54 @@ func OrderReturnMoneyRelateInsert(eg *xorm.Engine, oid int64, pvd string, create
return
}
if isDelete {
if newOrd.IsTotal == 1 {
var ordRelate = make([]model.OrdListRelate, 0)
eg.Where("oid=?", newOrd.OrdId).Find(&ordRelate)
now := time.Unix(int64(newOrd.CreateAt), 0).Format("200601")
nowDay := time.Unix(int64(newOrd.CreateAt), 0).Format("20060102")
if len(ordRelate) > 0 {
isDeduct := 0
for _, v := range ordRelate {
if v.Amount == 0 && utils.StrToFloat64(v.AdditionalSubsidy) == 0 {
continue
}
var userStatistics model.UserMonthAmount
eg.Where("uid=? and date=?", v.Uid, now).Get(&userStatistics)
if userStatistics.Id != 0 {
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4)
eg.Where("id=?", userStatistics.Id).Cols("amount").Update(&userStatistics)
}
if v.CreateAt > 1711086661 {
var userStatistics1 model.UserDayAmount
eg.Where("uid=? and date=?", v.Uid, nowDay).Get(&userStatistics1)
if userStatistics1.Id != 0 {
userStatistics1 = model.UserDayAmount{
Date: utils.StrToInt(nowDay),
Uid: v.Uid,
}
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4)
eg.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1)
}
}
var userStatistics1 model.UserWaitAmount
eg.Where("uid=? ", v.Uid).Get(&userStatistics1)
if userStatistics1.Id != 0 {
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4)
eg.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1)
}
isDeduct = 1
}
if isDeduct == 1 {
if newOrd.State == 4 {
newOrd.IsTotal = 2
} else {
newOrd.IsTotal = 0
}
eg.Where("pvd_oid=?", newOrd.PvdOid).Cols("is_total").Update(newOrd)
}
}
}

fmt.Println("=====================写入明细2", newOrd.PvdOid)
if newOrd.ReturnMoneySettleAt > 0 {
db.OrderRelateDeleteByOidbylevel(eg, oid, pvd)
@@ -101,6 +149,54 @@ func PlayLetOrderReturnMoneyRelateInsert(eg *xorm.Engine, oid int64, pvd string,
return
}
if isDelete {
if newOrd.IsTotal == 1 {
var ordRelate = make([]model.OrdListRelate, 0)
eg.Where("oid=?", newOrd.OrdId).Find(&ordRelate)
now := time.Unix(int64(newOrd.CreateAt), 0).Format("200601")
nowDay := time.Unix(int64(newOrd.CreateAt), 0).Format("20060102")
if len(ordRelate) > 0 {
isDeduct := 0
for _, v := range ordRelate {
if v.Amount == 0 && utils.StrToFloat64(v.AdditionalSubsidy) == 0 {
continue
}
var userStatistics model.UserMonthAmount
eg.Where("uid=? and date=?", v.Uid, now).Get(&userStatistics)
if userStatistics.Id != 0 {
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4)
eg.Where("id=?", userStatistics.Id).Cols("amount").Update(&userStatistics)
}
if v.CreateAt > 1711086661 {
var userStatistics1 model.UserDayAmount
eg.Where("uid=? and date=?", v.Uid, nowDay).Get(&userStatistics1)
if userStatistics1.Id != 0 {
userStatistics1 = model.UserDayAmount{
Date: utils.StrToInt(nowDay),
Uid: v.Uid,
}
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4)
eg.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1)
}
}
var userStatistics1 model.UserWaitAmount
eg.Where("uid=? ", v.Uid).Get(&userStatistics1)
if userStatistics1.Id != 0 {
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4)
eg.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1)
}
isDeduct = 1
}
if isDeduct == 1 {
if newOrd.State == 4 {
newOrd.IsTotal = 2
} else {
newOrd.IsTotal = 0
}
eg.Where("pvd_oid=?", newOrd.PvdOid).Cols("is_total").Update(newOrd)
}
}
}

fmt.Println("=====================写入明细2", newOrd.PvdOid)
if newOrd.ReturnMoneySettleAt > 0 {
db.OrderRelateDeleteByOidbylevel(eg, oid, pvd)


+ 47
- 0
app/svc/svc_order_track_save.go Visa fil

@@ -439,6 +439,53 @@ func OrderRelateInsert(eg *xorm.Engine, oid int64, pvd string, createTime int, l
fmt.Println(isDelete)
//先删掉
if isDelete {
if newOrd.IsTotal == 1 {
var ordRelate = make([]model.OrdListRelate, 0)
eg.Where("oid=?", newOrd.OrdId).Find(&ordRelate)
now := time.Unix(int64(newOrd.CreateAt), 0).Format("200601")
nowDay := time.Unix(int64(newOrd.CreateAt), 0).Format("20060102")
if len(ordRelate) > 0 {
isDeduct := 0
for _, v := range ordRelate {
if v.Amount == 0 && utils.StrToFloat64(v.AdditionalSubsidy) == 0 {
continue
}
var userStatistics model.UserMonthAmount
eg.Where("uid=? and date=?", v.Uid, now).Get(&userStatistics)
if userStatistics.Id != 0 {
userStatistics.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4)
eg.Where("id=?", userStatistics.Id).Cols("amount").Update(&userStatistics)
}
if v.CreateAt > 1711086661 {
var userStatistics1 model.UserDayAmount
eg.Where("uid=? and date=?", v.Uid, nowDay).Get(&userStatistics1)
if userStatistics1.Id != 0 {
userStatistics1 = model.UserDayAmount{
Date: utils.StrToInt(nowDay),
Uid: v.Uid,
}
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4)
eg.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1)
}
}
var userStatistics1 model.UserWaitAmount
eg.Where("uid=? ", v.Uid).Get(&userStatistics1)
if userStatistics1.Id != 0 {
userStatistics1.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userStatistics1.Amount)-v.Amount-utils.StrToFloat64(v.AdditionalSubsidy), 4)
eg.Where("id=?", userStatistics1.Id).Cols("amount").Update(&userStatistics1)
}
isDeduct = 1
}
if isDeduct == 1 {
if newOrd.State == 4 {
newOrd.IsTotal = 2
} else {
newOrd.IsTotal = 0
}
eg.Where("pvd_oid=?", newOrd.PvdOid).Cols("is_total").Update(newOrd)
}
}
}
fmt.Println("=====================写入明细2", newOrd.PvdOid)
if pvd == md.PVD_JDOwn {
db.OrderRelateDeleteByOid(eg, oid, md.PVD_JD)


Laddar…
Avbryt
Spara