From 45d816c8eb5c909720e78a984eb278a2e7ee22f5 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 15 Jul 2022 09:33:35 +0800 Subject: [PATCH 1/3] =?UTF-8?q?add=20reverse:for=20v1.4.6=20=E5=85=B1?= =?UTF-8?q?=E5=AF=8C=E6=B5=81=E6=B0=B4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user_public_platoon_income_records.go | 20 ++++++++ rule/public_platoon_settle.go | 46 ++++++++++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 db/model/user_public_platoon_income_records.go diff --git a/db/model/user_public_platoon_income_records.go b/db/model/user_public_platoon_income_records.go new file mode 100644 index 0000000..fa2a577 --- /dev/null +++ b/db/model/user_public_platoon_income_records.go @@ -0,0 +1,20 @@ +package model + +import ( + "time" +) + +type UserPublicPlatoonIncomeRecords 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"` + 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 index 011a065..e238b82 100644 --- a/rule/public_platoon_settle.go +++ b/rule/public_platoon_settle.go @@ -34,7 +34,7 @@ func PublicPlatoonSettle(session *xorm.Session, ItemTitle, ordId string, uid, co return false } } - finUserFlow := model.UserPublicPlatoonSettlementRecords{ + finUserFlow := model.UserPublicPlatoonIncomeRecords{ Type: 0, Uid: uid, Amount: zhios_order_relate_utils.AnyToString(amount), @@ -53,3 +53,47 @@ func PublicPlatoonSettle(session *xorm.Session, ItemTitle, ordId string, uid, co } return true } +func PublicPlatoonAddRecord(eg *xorm.Engine, ItemTitle, ordId string, uid, coinId, kind, types int, amount float64, beforeAmount string) bool { + now := time.Now() + + finUserFlow := model.UserPublicPlatoonIncomeRecords{ + Type: types, + Uid: uid, + Amount: zhios_order_relate_utils.AnyToString(amount), + CreateAt: now, + UpdateAt: now, + Date: now.Format("2006-01"), + Kind: kind, + CoinId: coinId, + Title: ItemTitle, + BeforeAmount: beforeAmount, + Oid: ordId, + } + _, err := eg.Insert(&finUserFlow) + if err != nil { + return false + } + return true +} +func PublicPlatoonAddRecordWithSession(session *xorm.Session, ItemTitle, ordId string, uid, coinId, kind, types int, amount float64, beforeAmount string) bool { + now := time.Now() + + finUserFlow := model.UserPublicPlatoonIncomeRecords{ + Type: types, + Uid: uid, + Amount: zhios_order_relate_utils.AnyToString(amount), + CreateAt: now, + UpdateAt: now, + Date: now.Format("2006-01"), + Kind: kind, + CoinId: coinId, + Title: ItemTitle, + BeforeAmount: beforeAmount, + Oid: ordId, + } + _, err := session.Insert(&finUserFlow) + if err != nil { + return false + } + return true +} From 475ca02fd2c2890691861a09679832bbd9856f59 Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Fri, 15 Jul 2022 14:58:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?add=20reverse:for=20v1.4.7=20=E5=88=86?= =?UTF-8?q?=E4=BD=A3=E6=96=B9=E6=A1=88=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rule/relate_commission.go | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/rule/relate_commission.go b/rule/relate_commission.go index bb723c7..dec227c 100644 --- a/rule/relate_commission.go +++ b/rule/relate_commission.go @@ -150,6 +150,32 @@ func SettleCommWithGoodsDetail(eg *xorm.Engine, dbName string, CommissionParam m 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 } +func SettleCommWithOrder(eg *xorm.Engine, dbName string, CommissionParam md.CommissionFirstParam) (float64, float64, float64, float64, *comm_plan.LvUser, error) { + var ( + isShare = false + isAllLevelReturn = false + ) + if CommissionParam.IsShare != 0 { + isShare = true + } + + if CommissionParam.IsAllLevelReturn != 0 { + isAllLevelReturn = true + } + var mapData = map[string]string{ + "old_lv": CommissionParam.OldLv, + "new_lv": CommissionParam.NewLv, + "ownbuy_return_type": zhios_order_relate_utils.IntToStr(CommissionParam.OwnbuyReturnType), + } + virCfg, _ := db.SysCfgGetOne(eg, "virtual_coin_rebate_type") + var virType = "price" + if virCfg != nil && virCfg.Val != "" { + virType = virCfg.Val + } + 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 +} //获取自购分享佣金的 func GetRewardCommission(eg *xorm.Engine, dbName, mode string, CommissionParam md.CommissionFirstParam) (float64, float64, *comm_plan.LvUser, error) { From 41722153e5ae7e0d2bfc549f70776d311adcb37d Mon Sep 17 00:00:00 2001 From: huangjiajun <582604932@qq.com> Date: Sat, 16 Jul 2022 10:40:03 +0800 Subject: [PATCH 3/3] =?UTF-8?q?add=20reverse:for=20v1.4.8=20=E5=85=B1?= =?UTF-8?q?=E5=AF=8C=E6=94=B6=E7=9B=8A=E7=BB=93=E7=AE=97=E5=8A=A0=E4=B8=AA?= =?UTF-8?q?=E6=B5=81=E6=B0=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/db_user_public_platoon_income_records.go | 15 +++++++++++ rule/public_platoon_relate_commission.go | 28 +++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 db/db_user_public_platoon_income_records.go diff --git a/db/db_user_public_platoon_income_records.go b/db/db_user_public_platoon_income_records.go new file mode 100644 index 0000000..75d500f --- /dev/null +++ b/db/db_user_public_platoon_income_records.go @@ -0,0 +1,15 @@ +package db + +import ( + "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" + "xorm.io/xorm" +) + +// BatchAddUserPublicPlatoonIncomeRecordss 批量新增数据 +func BatchAddUserPublicPlatoonIncomeRecordss(session *xorm.Session, UserPublicPlatoonIncomeRecordsData []*model.UserPublicPlatoonIncomeRecords) (int64, error) { + affected, err := session.Insert(UserPublicPlatoonIncomeRecordsData) + if err != nil { + return 0, err + } + return affected, nil +} diff --git a/rule/public_platoon_relate_commission.go b/rule/public_platoon_relate_commission.go index 83bd463..57e1e1a 100644 --- a/rule/public_platoon_relate_commission.go +++ b/rule/public_platoon_relate_commission.go @@ -258,6 +258,8 @@ func DealCommonWealthReward(engine *xorm.Engine, uid int, isCompleteReward bool) //2、完成共富奖励(插入 user_public_platoon_settlement_records 记录) && 构造返回数据 var userPublicPlatoonSettlementRecords []*model.UserPublicPlatoonSettlementRecords + var userPublicPlatoonIncomeRecords []*model.UserPublicPlatoonIncomeRecords + now := time.Now() for _, param := range *params { var userPublicPlatoonSettlementRecord = model.UserPublicPlatoonSettlementRecords{ @@ -269,17 +271,33 @@ func DealCommonWealthReward(engine *xorm.Engine, uid int, isCompleteReward bool) CreateAt: now, UpdateAt: now, } + //流水表 + var userPublicPlatoonIncomeRecord = model.UserPublicPlatoonIncomeRecords{ + Uid: param.Uid, + CoinId: param.CoinId, + Amount: param.Amount, + Date: now.AddDate(0, 0, 30).Format("2006-01-02"), + CreateAt: now, + UpdateAt: now, + } if isCompleteReward { + userPublicPlatoonIncomeRecord.Title = "共富收益转入余额" + userPublicPlatoonIncomeRecord.Kind = 1 userPublicPlatoonSettlementRecord.Kind = 1 resp = append(resp, map[string]string{ zhios_order_relate_utils.AnyToString(param.CoinId): param.Amount, }) } else { + userPublicPlatoonIncomeRecord.Title = "共富收益清零" + userPublicPlatoonIncomeRecord.Kind = 2 userPublicPlatoonSettlementRecord.Kind = 2 } if zhios_order_relate_utils.StrToFloat64(userPublicPlatoonSettlementRecord.Amount) > 0 { userPublicPlatoonSettlementRecords = append(userPublicPlatoonSettlementRecords, &userPublicPlatoonSettlementRecord) } + if zhios_order_relate_utils.StrToFloat64(userPublicPlatoonIncomeRecord.Amount) > 0 { + userPublicPlatoonIncomeRecords = append(userPublicPlatoonIncomeRecords, &userPublicPlatoonIncomeRecord) + } } affected, err := db.BatchAddUserPublicPlatoonSettlementRecordss(session, userPublicPlatoonSettlementRecords) if err != nil { @@ -291,6 +309,16 @@ func DealCommonWealthReward(engine *xorm.Engine, uid int, isCompleteReward bool) _ = session.Rollback() return } + affectedIncome, errIncome := db.BatchAddUserPublicPlatoonIncomeRecordss(session, userPublicPlatoonIncomeRecords) + if errIncome != nil { + _ = session.Rollback() + return + } + if affectedIncome == 0 { + err = errors.New("插入 user_public_platoon_settlement_records 记录失败") + _ = session.Rollback() + return + } //3、将 user_public_platoon_amount 相关记录的 amount 置 0 sql := "update user_public_platoon_amount set amount = ? where uid = ?"