Browse Source

更新

guide_order
huangjiajun 2 months ago
parent
commit
c16dbc4387
3 changed files with 62 additions and 1 deletions
  1. +2
    -0
      app/svc/svc_pddorder_refund_track.go
  2. +59
    -0
      app/svc/svc_tborder_refund_track.go
  3. +1
    -1
      go.mod

+ 2
- 0
app/svc/svc_pddorder_refund_track.go View File

@@ -548,6 +548,8 @@ func RefundDoing(eg *xorm.Engine, returnMoneyType string, order *model.OrdList,
}
commAreaRefund(session, order.Uid, utils.Int64ToStr(order.OrdId), md.PVD_GUIDE, order.ItemId, title)
commStoreRefund(eg, session, utils.Int64ToStr(order.OrdId), order.Pvd)
refundServiceVirtualAmount(eg, session, order.OrdId)

// 更新订单状态
tt := utils.StrToInt(utils.AnyToString(now.Unix()))
order.State = 4


+ 59
- 0
app/svc/svc_tborder_refund_track.go View File

@@ -10,6 +10,7 @@ import (
"applet/app/utils/cache"
"applet/app/utils/logx"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/lib/comm_plan"
"code.fnuoos.com/go_rely_warehouse/zyos_model.git/src/models"
"fmt"
"github.com/tidwall/gjson"
"strings"
@@ -144,6 +145,8 @@ func DeductMoney(eg *xorm.Engine, existOrd model.OrdList, ords map[string]md.Ord
commRefund(eg, session, &existOrd, existOrd.Uid, existOrd.Pvd, existOrd.ItemId, rebateList, str, dbName)
commAreaRefund(session, existOrd.Uid, utils.Int64ToStr(existOrd.OrdId), md.PVD_GUIDE, existOrd.ItemId, str)
commStoreRefund(eg, session, utils.Int64ToStr(existOrd.OrdId), existOrd.Pvd)
refundServiceVirtualAmount(eg, session, existOrd.OrdId)

existOrd.IsRefund = 1
}
_, _ = db.OrdUpdateOneAll(eg, &existOrd)
@@ -162,6 +165,60 @@ func DeductMoney(eg *xorm.Engine, existOrd model.OrdList, ords map[string]md.Ord
}
return
}
func refundServiceVirtualAmount(eg *xorm.Engine, sess *xorm.Session, oid int64) (bool, error) {
var list = make([]models.ServiceAwardReturnFlow, 0)
sess.Where("oid=? and is_end=?", oid, 0).Find(&list)
for _, v := range list {
// 退虚拟币
var userVirtualAmount model.UserVirtualAmount
var beforeCoinAmount = ""
has, err := sess.Where("uid = ? AND coin_id = ?", v.Uid, v.CoinId).Get(&userVirtualAmount)
if err != nil {
return false, err
}
var virtualAmount = 0.0
if !has {
continue
} else if utils.StrToFloat64(userVirtualAmount.Amount) > 0 {
beforeCoinAmount = userVirtualAmount.Amount
virtualAmount = utils.StrToFloat64(v.HasReturnMoney)
if utils.StrToFloat64(beforeCoinAmount)-utils.StrToFloat64(v.HasReturnMoney) < 0 {
virtualAmount = utils.StrToFloat64(beforeCoinAmount)
}
userVirtualAmount.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(userVirtualAmount.Amount)-virtualAmount, 6)
_, err := sess.Where("id = ?", userVirtualAmount.Id).AllCols().Update(&userVirtualAmount)
if err != nil {
logx.Warn(err)
return false, err
}
// 虚拟币流水
coinFlow := model.UserVirtualCoinFlow{
Uid: v.Uid,
CoinId: v.CoinId,
Direction: 2,
Title: "退款扣除分红",
OrdId: utils.AnyToString(oid),
Amout: utils.Float64ToStrByPrec(virtualAmount, 6),
BeforeAmout: beforeCoinAmount,
AfterAmout: userVirtualAmount.Amount,
SysFee: "0.00",
CreateTime: time.Now(),
TransferType: 99,
}
_, err = sess.Insert(&coinFlow)
if err != nil {
return false, err
}
}
v.IsEnd = 1
update, err := sess.Where("id=?", v.Id).Cols("is_end").Update(&v)
if update == 0 || err != nil {
return false, err
}
}
return true, nil
}

func deductMoneySecond(eg *xorm.Engine, existOrd model.OrdList, dbName, str string) {
if existOrd.Uid == 0 {
return
@@ -190,6 +247,8 @@ func deductMoneySecond(eg *xorm.Engine, existOrd model.OrdList, dbName, str stri
commRefund(eg, session, &existOrd, existOrd.Uid, existOrd.Pvd, existOrd.ItemId, rebateList, str, dbName)
commAreaRefund(session, existOrd.Uid, utils.Int64ToStr(existOrd.OrdId), md.PVD_GUIDE, existOrd.ItemId, str)
commStoreRefund(eg, session, utils.Int64ToStr(existOrd.OrdId), existOrd.Pvd)
refundServiceVirtualAmount(eg, session, existOrd.OrdId)

existOrd.IsRefund = 1
}
_, _ = db.OrdUpdateOneAll(eg, &existOrd)


+ 1
- 1
go.mod View File

@@ -11,7 +11,7 @@ require (
code.fnuoos.com/go_rely_warehouse/zyos_go_o2o_business.git v1.0.9
code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20241022105427-5652e016f74f
code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20240706080117-2babe132fe43
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20241017011352-f7f92494c0f4
code.fnuoos.com/go_rely_warehouse/zyos_model.git v0.0.4-0.20241025091058-686549ebf89d
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751
github.com/boombuler/barcode v1.0.1


Loading…
Cancel
Save