From 2bd4de0f51c607a1835e5512ef0c8f2d4024afc1 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Wed, 13 Jul 2022 18:11:28 +0800 Subject: [PATCH] =?UTF-8?q?add=20reverse:for=20v1.3.5=20=E5=85=B1=E5=AF=8C?= =?UTF-8?q?=E6=94=B6=E7=9B=8A=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user_public_platoon_settlement_records.go | 21 ++++---- rule/public_platoon_settle.go | 54 +++++++++++++++++++ rule/relate_commission.go | 8 +-- 3 files changed, 70 insertions(+), 13 deletions(-) create mode 100644 rule/public_platoon_settle.go diff --git a/db/model/user_public_platoon_settlement_records.go b/db/model/user_public_platoon_settlement_records.go index 83cc239..6695cd2 100644 --- a/db/model/user_public_platoon_settlement_records.go +++ b/db/model/user_public_platoon_settlement_records.go @@ -5,13 +5,16 @@ import ( ) type UserPublicPlatoonSettlementRecords struct { - Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` - Uid int `json:"uid" xorm:"not null comment('用户id') index INT(11)"` - CoinId int `json:"coin_id" xorm:"not null default 0 comment('虚拟币id(0为金额)') INT(11)"` - Amount string `json:"amount" xorm:"not null default '' comment('结算金额') VARCHAR(50)"` - Title string `json:"title" xorm:"comment('标题') VARCHAR(255)"` - Date string `json:"date" xorm:"not null default '' comment('结算日期(0000-00)') VARCHAR(50)"` - Kind int `json:"kind" xorm:"not null default 1 comment('结算种类(1:转入用户余额 2:清零)') TINYINT(1)"` - CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` - UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` + Uid int `json:"uid" xorm:"not null comment('用户id') index INT(11)"` + CoinId int `json:"coin_id" xorm:"not null default 0 comment('虚拟币id(0为金额)') INT(11)"` + Amount string `json:"amount" xorm:"not null default '' comment('结算金额') VARCHAR(50)"` + Title string `json:"title" xorm:"comment('标题') VARCHAR(255)"` + Date string `json:"date" xorm:"not null default '' comment('结算日期(0000-00)') VARCHAR(50)"` + Kind int `json:"kind" xorm:"not null default 1 comment('结算种类(1:转入用户余额 2:清零)') TINYINT(1)"` + CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"` + Oid string `json:"oid" xorm:"comment('订单号') VARCHAR(100)"` + Type int `json:"type" xorm:"not null default 0 comment('0收入 1支出') INT(11)"` + BeforeAmount string `json:"before_amount" xorm:"comment('变更前金额') VARCHAR(100)"` } diff --git a/rule/public_platoon_settle.go b/rule/public_platoon_settle.go new file mode 100644 index 0000000..46c46f1 --- /dev/null +++ b/rule/public_platoon_settle.go @@ -0,0 +1,54 @@ +package rule + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" + zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils" + "time" + "xorm.io/xorm" +) + +func PublicPlatoonSettle(session *xorm.Session, ItemTitle, ordId string, uid, coinId int, amount float64) bool { + now := time.Now() + var data model.UserPublicPlatoonAmount + has, err := session.Where("uid=? and coin_id=?", uid, coinId).Get(&data) + if err != nil { + return false + } + beforeAmount := "0" + if has == false { + data = model.UserPublicPlatoonAmount{ + Uid: uid, + CoinId: coinId, + Amount: zhios_order_relate_utils.AnyToString(amount), + } + _, err := session.Insert(&data) + if err != nil { + return false + } + } else { + beforeAmount = data.Amount + data.Amount = zhios_order_relate_utils.Float64ToStrByPrec(zhios_order_relate_utils.StrToFloat64(data.Amount)+amount, 6) + _, err := session.Where("id=?", data.Id).Cols("amount").Update(&data) + if err != nil { + return false + } + } + finUserFlow := model.UserPublicPlatoonSettlementRecords{ + Type: 0, + Uid: uid, + Amount: zhios_order_relate_utils.AnyToString(amount), + CreateAt: now, + UpdateAt: now, + Date: now.Format("2006-01"), + Kind: 3, + CoinId: coinId, + Title: ItemTitle, + BeforeAmount: beforeAmount, + Oid: ordId, + } + _, err = session.Insert(&finUserFlow) + if err != nil { + return false + } + return true +} diff --git a/rule/relate_commission.go b/rule/relate_commission.go index bd0c0c6..f3f3111 100644 --- a/rule/relate_commission.go +++ b/rule/relate_commission.go @@ -45,7 +45,7 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi if param.GoodsId == "" { return errors.New("商品ID缺失") } - param.CommissionParam.Oid=param.GoodsId + param.CommissionParam.Oid = param.GoodsId _, _, _, _, lvUser, err := svc.GetRewardCommission(eg, ¶m.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType) if err != nil { return err @@ -96,7 +96,7 @@ func BatchGetCommissionByOrder(engine *xorm.Engine, dbName string, CommissionPar return errors.New("订单缺失") } param.CommissionParam.OldPrice = param.CommissionParam.GoodsPrice - param.CommissionParam.Oid=param.Oid + param.CommissionParam.Oid = param.Oid profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(engine, ¶m.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType) if err != nil { @@ -145,7 +145,7 @@ func SettleCommWithGoodsDetail(eg *xorm.Engine, dbName string, CommissionParam m if virCfg != nil && virCfg.Val != "" { virType = virCfg.Val } - CommissionParam.CommissionParam.Oid=CommissionParam.GoodsId + CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType) return profit, pvdFee, sysFee, subsidyFee, lvUser, err @@ -168,7 +168,7 @@ func GetRewardCommission(eg *xorm.Engine, dbName, mode string, CommissionParam m if CommissionParam.IsAllLevelReturn != 0 { isAllLevelReturn = true } - CommissionParam.CommissionParam.Oid=CommissionParam.GoodsId + CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId var lvUser = &comm_plan.LvUser{} var mapsDta = map[string]string{"show_level": CommissionParam.ShowLevel} if isAll {