Browse Source

更新

three
huangjiajun 1 year ago
parent
commit
8664c03f5e
13 changed files with 1001 additions and 58 deletions
  1. +10
    -0
      app/db/db.go
  2. +40
    -4
      app/db/db_order.go
  3. +18
    -0
      app/db/model/buckle_record.go
  4. +56
    -53
      app/db/model/ord_list.go
  5. +2
    -0
      app/db/model/ord_list_relate.go
  6. +16
    -0
      app/db/model/tik_tok_team_order_relate.go
  7. +17
    -0
      app/db/model/virtual_coin_relate.go
  8. +255
    -0
      app/md/order.go
  9. +2
    -0
      consume/init.go
  10. +19
    -0
      consume/md/consume_key.go
  11. +4
    -0
      consume/md/md_zhios_capital_pool_order_total.go
  12. +561
    -0
      consume/zhios_order_buckle.go
  13. +1
    -1
      go.mod

+ 10
- 0
app/db/db.go View File

@@ -64,6 +64,16 @@ func DbInsertBatch(Db *xorm.Engine, m ...interface{}) error {
}
return nil
}
func DbInsertBatchSess(sess *xorm.Session, m ...interface{}) error {
if len(m) == 0 {
return nil
}
id, err := sess.Insert(m...)
if id == 0 || err != nil {
return logx.Warn("cannot insert data :", err)
}
return nil
}

// QueryNativeString 查询原生sql
func QueryNativeString(Db *xorm.Engine, sql string, args ...interface{}) ([]map[string]string, error) {


+ 40
- 4
app/db/db_order.go View File

@@ -29,9 +29,9 @@ func OrderListByOids(Db *xorm.Engine, oids []int64) (*[]model.OrdList, error) {
}
return &o, nil
}
func OrderListByOid(Db *xorm.Engine, oids string) (*model.OrdList, error) {
func OrderListByOid(sess *xorm.Session, oids string) (*model.OrdList, error) {
var o model.OrdList
get, err := Db.Where("pvd_oid=?", oids).Get(&o)
get, err := sess.Where("ord_id=?", oids).Get(&o)
if err != nil || get == false {
return nil, errors.New("没订单")
}
@@ -170,8 +170,15 @@ func OrderListByPvdOidAndUid(Db *xorm.Engine, oid string) (*model.OrdList, error
}
return &o, nil
}
func OrderListByUpdateOrd(Db *xorm.Engine, ord *model.OrdList) (bool, error) {
if row, err := Db.Where("pvd_oid = ? ", ord.PvdOid).AllCols().Update(ord); row == 0 || err != nil {
func OrderListByPvdOid(sess *xorm.Session, oid string) (*model.OrdList, error) {
var o model.OrdList
if has, err := sess.Where("ord_id=?", oid).Get(&o); err != nil || !has {
return nil, logx.Error(err)
}
return &o, nil
}
func OrderListByUpdateOrd(sess *xorm.Session, ord *model.OrdList) (bool, error) {
if row, err := sess.Where("pvd_oid = ? ", ord.PvdOid).AllCols().Update(ord); row == 0 || err != nil {
return false, logx.Warn(err)
}
return true, nil
@@ -468,3 +475,32 @@ func OrdUpdateOneAll(Db *xorm.Engine, order *model.OrdList) (int64, error) {
}
return affect, nil
}
func OrderRelateDeleteByOid(sess *xorm.Session, oid int64, pvd string) (int64, error) {
_, err := sess.Where("oid=? and pvd=?", oid, pvd).Delete(model.OrdListRelate{})
if err != nil {
return 0, err
}
return 1, nil
}
func OrderRelateFindByOid(sess *xorm.Session, oid int64, pvd string) (*[]model.OrdListRelate, error) {
var data []model.OrdListRelate
err := sess.Where("oid=? and pvd=?", oid, pvd).Find(&data)
if err != nil {
return nil, err
}
return &data, nil
}
func VirtualCoinOrderRelateDeleteByOid(sess *xorm.Session, oid int64, pvd string) (int64, error) {
_, err := sess.Where("oid=? and pvd=?", oid, pvd).Delete(model.VirtualCoinRelate{})
if err != nil {
return 0, err
}
return 1, nil
}
func TikTokTeamOrderRelateDeleteByOid(sess *xorm.Session, oid int64, pvd string) (int64, error) {
_, err := Db.Where("oid=? and pvd=?", oid, pvd).Delete(model.TikTokTeamOrderRelate{})
if err != nil {
return 0, err
}
return 1, nil
}

+ 18
- 0
app/db/model/buckle_record.go View File

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

import (
"time"
)

type BuckleRecord struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Date string `json:"date" xorm:"comment('2023-12') index VARCHAR(255)"`
Time time.Time `json:"time" xorm:"DATETIME"`
Uid int `json:"uid" xorm:"default 0 index INT(11)"`
Level int `json:"level" xorm:"default 0 index INT(11)"`
OrdId string `json:"ord_id" xorm:"VARCHAR(255)"`
PvdOrdId string `json:"pvd_ord_id" xorm:"VARCHAR(255)"`
Amount string `json:"amount" xorm:"DECIMAL(20,6)"`
BeforeAmount string `json:"before_amount" xorm:"DECIMAL(20,6)"`
AfterAmount string `json:"after_amount" xorm:"DECIMAL(20,6)"`
}

+ 56
- 53
app/db/model/ord_list.go View File

@@ -1,57 +1,60 @@
package model

type OrdList struct {
OrdId int64 `xorm:"pk autoincr BIGINT(20)" json:"ord_id"`
Uid int `xorm:"not null index INT(10)" json:"uid"`
PvdOid string `xorm:"not null index(IDX_PVD) VARCHAR(50)" json:"pvd_oid"`
ParentOrdId int64 `xorm:" BIGINT(20)" json:"parent_ord_id"`
Pvd string `xorm:"not null default '' index(IDX_PVD) index(IDX_PVD_ITEM) VARCHAR(8)" json:"pvd"`
ItemId string `xorm:"not null default '' index(IDX_PVD_ITEM) VARCHAR(50)" json:"item_id"`
ItemNum int `xorm:"not null default 1 TINYINT(3)" json:"item_num"`
ItemPrice float64 `xorm:"not null default 0.00 DOUBLE(10,2)" json:"item_price"`
ItemCommissionRate float64 `xorm:"not null default 0.00 DOUBLE(6,4)" json:"item_commission_rate"`
PaidPrice float64 `xorm:"not null default 0.00 DOUBLE(10,2)" json:"paid_price"`
OrderType int `xorm:"not null default 0 TINYINT(1)" json:"order_type"`
PriceType int `xorm:"not null default 0 INT(1)" json:"price_type"`
OrderCompare int `xorm:"not null default 0 TINYINT(1)" json:"order_compare"`
SubsidyFee float64 `xorm:"not null default 0.00 DOUBLE(8,2)" json:"subsidy_fee"`
SubsidyRate float64 `xorm:"not null default 0.0000 DOUBLE(10,4)" json:"subsidy_rate"`
UserCommission float64 `xorm:"not null default 0.000 DOUBLE(8,3)" json:"user_commission"`
UserReturnMoney float64 `xorm:"not null default 0.000 DOUBLE(8,3)" json:"user_return_money"`
UserCommissionRate float64 `xorm:"not null default 0.0000 DOUBLE(6,4)" json:"user_commission_rate"`
PvdCommission float64 `xorm:"not null default 0.0000 DOUBLE(8,4)" json:"pvd_commission"`
PvdCommissionRate float64 `xorm:"not null default 0.0000 DOUBLE(6,4)" json:"pvd_commission_rate"`
SysCommission float64 `xorm:"not null default 0.0000 DOUBLE(8,4)" json:"sys_commission"`
SysCommissionRate float64 `xorm:"not null default 0.0000 DOUBLE(6,4)" json:"sys_commission_rate"`
PlanCommissionId int `xorm:"not null default 0 INT(10)" json:"plan_commission_id"`
PlanCommissionState int `xorm:"not null default 0 TINYINT(1)" json:"plan_commission_state"`
Reason string `xorm:"not null default '' VARCHAR(32)" json:"reason"`
State int `xorm:"not null default 0 TINYINT(1)" json:"state"`
LockState int `xorm:"not null default 0 TINYINT(1)" json:"lock_state"`
CreateAt int `xorm:"not null default 0 INT(10)" json:"create_at"`
UpdateAt int `xorm:"not null default 0 INT(11)" json:"update_at"`
ConfirmAt int `xorm:"not null default 0 INT(10)" json:"confirm_at"`
CheckSuccessAt int `xorm:"not null default 0 INT(10)" json:"check_success_at"`
PvdSettleAt int `xorm:"not null default 0 INT(10)" json:"pvd_settle_at"`
SettleAt int `xorm:"not null default 0 INT(10)" json:"settle_at"`
ReturnMoneySettleAt int `xorm:"not null default 0 INT(10)" json:"return_money_settle_at"`
SubsidyAt int `xorm:"not null default 0 INT(10)" json:"subsidy_at"`
BenefitList string `xorm:"not null default '' index VARCHAR(200)" json:"benefit_list"`
BenefitAll float64 `xorm:"not null default 0.00 DOUBLE(10,3)" json:"benefit_all"`
Data string `xorm:"not null default '' VARCHAR(2000)" json:"data"`
UpdateFrom int `xorm:"not null default 0 TINYINT(1)" json:"update_from"`
CreateFrom int `xorm:"not null default 0 TINYINT(1)" json:"create_from"`
IsRefund int `xorm:"not null default 0 INT(1)" json:"is_refund"`
IsSendMsg int `xorm:"not null default 0 INT(1)" json:"is_send_msg"`
PvdPid string `xorm:"not null default '' VARCHAR(100)" json:"pvd_pid"`
CostPrice float64 `xorm:"not null default 0.00 FLOAT(10,2)" json:"cost_price"`
PlatformData string `xorm:"TEXT" json:"platform_data"`
IsTikTokTeamOrder int `xorm:"not null default 0 INT(1)" json:"is_tik_tok_team_order"`
TikTokTeamCommission string `json:"tik_tok_team_commission" xorm:"not null default 0.00 comment('') DECIMAL(20,8)"`
IsFastSign int `xorm:"not null default 0 INT(1)" json:"is_fast_sign"`
IsWaitReduce int `xorm:"not null default 0 INT(1)" json:"is_wait_reduce"`
FastSignId string `xorm:"not null default '' VARCHAR(100)" json:"fast_sign_id"`
TransferSignId string `xorm:"not null default '' VARCHAR(100)" json:"transfer_sign_id"`
IsTransfer int `xorm:"not null default 0 INT(1)" json:"is_transfer"`
FastSuccess int `xorm:"not null default 0 INT(1)" json:"fast_success"`
OrdId int64 `xorm:"pk autoincr BIGINT(20)" json:"ord_id"`
Uid int `xorm:"not null index INT(10)" json:"uid"`
PvdOid string `xorm:"not null index(IDX_PVD) VARCHAR(50)" json:"pvd_oid"`
ParentOrdId int64 `xorm:" BIGINT(20)" json:"parent_ord_id"`
Pvd string `xorm:"not null default '' index(IDX_PVD) index(IDX_PVD_ITEM) VARCHAR(8)" json:"pvd"`
ItemId string `xorm:"not null default '' index(IDX_PVD_ITEM) VARCHAR(50)" json:"item_id"`
ItemNum int `xorm:"not null default 1 TINYINT(3)" json:"item_num"`
ItemPrice float64 `xorm:"not null default 0.00 DOUBLE(10,2)" json:"item_price"`
ItemCommissionRate float64 `xorm:"not null default 0.00 DOUBLE(6,4)" json:"item_commission_rate"`
PaidPrice float64 `xorm:"not null default 0.00 DOUBLE(10,2)" json:"paid_price"`
OrderType int `xorm:"not null default 0 TINYINT(1)" json:"order_type"`
PriceType int `xorm:"not null default 0 INT(1)" json:"price_type"`
OrderCompare int `xorm:"not null default 0 TINYINT(1)" json:"order_compare"`
SubsidyFee float64 `xorm:"not null default 0.00 DOUBLE(8,2)" json:"subsidy_fee"`
SubsidyRate float64 `xorm:"not null default 0.0000 DOUBLE(10,4)" json:"subsidy_rate"`
UserCommission float64 `xorm:"not null default 0.000 DOUBLE(8,3)" json:"user_commission"`
UserReturnMoney float64 `xorm:"not null default 0.000 DOUBLE(8,3)" json:"user_return_money"`
UserCommissionRate float64 `xorm:"not null default 0.0000 DOUBLE(6,4)" json:"user_commission_rate"`
PvdCommission float64 `xorm:"not null default 0.0000 DOUBLE(8,4)" json:"pvd_commission"`
PvdCommissionRate float64 `xorm:"not null default 0.0000 DOUBLE(6,4)" json:"pvd_commission_rate"`
SysCommission float64 `xorm:"not null default 0.0000 DOUBLE(8,4)" json:"sys_commission"`
SysCommissionRate float64 `xorm:"not null default 0.0000 DOUBLE(6,4)" json:"sys_commission_rate"`
PlanCommissionId int `xorm:"not null default 0 INT(10)" json:"plan_commission_id"`
PlanCommissionState int `xorm:"not null default 0 TINYINT(1)" json:"plan_commission_state"`
Reason string `xorm:"not null default '' VARCHAR(32)" json:"reason"`
State int `xorm:"not null default 0 TINYINT(1)" json:"state"`
LockState int `xorm:"not null default 0 TINYINT(1)" json:"lock_state"`
CreateAt int `xorm:"not null default 0 INT(10)" json:"create_at"`
UpdateAt int `xorm:"not null default 0 INT(11)" json:"update_at"`
ConfirmAt int `xorm:"not null default 0 INT(10)" json:"confirm_at"`
CheckSuccessAt int `xorm:"not null default 0 INT(10)" json:"check_success_at"`
PvdSettleAt int `xorm:"not null default 0 INT(10)" json:"pvd_settle_at"`
SettleAt int `xorm:"not null default 0 INT(10)" json:"settle_at"`
ReturnMoneySettleAt int `xorm:"not null default 0 INT(10)" json:"return_money_settle_at"`
SubsidyAt int `xorm:"not null default 0 INT(10)" json:"subsidy_at"`
BenefitList string `xorm:"not null default '' index VARCHAR(200)" json:"benefit_list"`
BenefitAll float64 `xorm:"not null default 0.00 DOUBLE(10,3)" json:"benefit_all"`
Data string `xorm:"not null default '' VARCHAR(2000)" json:"data"`
UpdateFrom int `xorm:"not null default 0 TINYINT(1)" json:"update_from"`
CreateFrom int `xorm:"not null default 0 TINYINT(1)" json:"create_from"`
IsRefund int `xorm:"not null default 0 INT(1)" json:"is_refund"`
IsSendMsg int `xorm:"not null default 0 INT(1)" json:"is_send_msg"`
PvdPid string `xorm:"not null default '' VARCHAR(100)" json:"pvd_pid"`
CostPrice float64 `xorm:"not null default 0.00 FLOAT(10,2)" json:"cost_price"`
PlatformData string `xorm:"TEXT" json:"platform_data"`
IsTikTokTeamOrder int `xorm:"not null default 0 INT(1)" json:"is_tik_tok_team_order"`
TikTokTeamCommission string `json:"tik_tok_team_commission" xorm:"not null default 0.00 comment('') DECIMAL(20,8)"`
IsFastSign int `xorm:"not null default 0 INT(1)" json:"is_fast_sign"`
IsWaitReduce int `xorm:"not null default 0 INT(1)" json:"is_wait_reduce"`
FastSignId string `xorm:"not null default '' VARCHAR(100)" json:"fast_sign_id"`
TransferSignId string `xorm:"not null default '' VARCHAR(100)" json:"transfer_sign_id"`
IsTransfer int `xorm:"not null default 0 INT(1)" json:"is_transfer"`
FastSuccess int `xorm:"not null default 0 INT(1)" json:"fast_success"`
BuckleCommission string `json:"buckle_commission" xorm:"DECIMAL(20,2)"`
OrderFormType int `xorm:"not null default 0 INT(1)" json:"order_form_type"`
TikTokTeamRealCommission string `json:"tik_tok_team_real_commission" xorm:"not null default 0.00 comment('') DECIMAL(20,8)"`
}

+ 2
- 0
app/db/model/ord_list_relate.go View File

@@ -5,6 +5,7 @@ type OrdListRelate struct {
Oid int64 `json:"oid" xorm:"not null default 0 comment('订单号') index unique(IDX_ORD) BIGINT(20)"`
Uid int `json:"uid" xorm:"not null default 0 comment('用户ID') unique(IDX_ORD) index INT(10)"`
Amount float64 `json:"amount" xorm:"not null default 0.00 comment('金额') DOUBLE(12,4)"`
OldAmount float64 `json:"old_amount" xorm:"not null default 0.00 comment('金额') DOUBLE(12,4)"`
ReturnMoney float64 `json:"return_money" xorm:"not null default 0.00 comment('返现金额') DOUBLE(10,2)"`
Pvd string `json:"pvd" xorm:"not null default '' comment('供应商taobao,jd,pdd,vip,suning,kaola') index VARCHAR(255)"`
CreateAt int `json:"create_at" xorm:"not null default 0 comment('订单创建时间') index INT(10)"`
@@ -13,4 +14,5 @@ type OrdListRelate struct {
BlockIcons string `json:"block_icons" xorm:"default 0.0000 comment('区块币') DECIMAL(12,4)"`
Mode string `json:"mode" xorm:"not null default '' comment('分佣方案类型') VARCHAR(255)"`
AdditionalSubsidy string `json:"additional_subsidy" xorm:"not null default 0.00 comment('额外补贴 酒庄模式才有效') DECIMAL(16,6)"`
ExtendType int `json:"extend_type" xorm:"default 0 comment('0普通 1超级推荐人 2团长 3团长上级超级推荐人 4团长担保用户') INT(11)"`
}

+ 16
- 0
app/db/model/tik_tok_team_order_relate.go View File

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

import (
"time"
)

type TikTokTeamOrderRelate struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
CoinId int `json:"coin_id" xorm:"default 0 unique(coin_id) INT(11)"`
Uid int `json:"uid" xorm:"default 0 unique(coin_id) INT(11)"`
Amount string `json:"amount" xorm:"default 0.00000000 DECIMAL(20,8)"`
Oid string `json:"oid" xorm:"default '' unique(coin_id) VARCHAR(255)"`
Time time.Time `json:"time" xorm:"DATETIME"`
Commission string `json:"commission" xorm:"default 0.00000000 DECIMAL(20,8)"`
Pvd string `json:"pvd" xorm:"VARCHAR(255)"`
}

+ 17
- 0
app/db/model/virtual_coin_relate.go View File

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

type VirtualCoinRelate struct {
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"`
Oid int64 `json:"oid" xorm:"not null default 0 comment('订单号') index unique(IDX_ORD) BIGINT(20)"`
Uid int `json:"uid" xorm:"not null default 0 comment('用户ID') unique(IDX_ORD) index INT(10)"`
CoinId int `json:"coin_id" xorm:"comment('虚拟币id') unique(IDX_ORD) INT(11)"`
Amount string `json:"amount" xorm:"not null default 0.000000 comment('数量') DECIMAL(16,6)"`
Pvd string `json:"pvd" xorm:"not null default '' comment('供应商taobao,jd,pdd,vip,suning,kaola,mall_goods,group_buy') index VARCHAR(255)"`
CreateAt int `json:"create_at" xorm:"not null default 0 comment('订单创建时间') index INT(10)"`
Level int `json:"level" xorm:"not null default 0 comment('0自购 1直推 大于1:间推') INT(10)"`
Mode string `json:"mode" xorm:"default '' comment('分佣方案类型') VARCHAR(255)"`
AdditionalSubsidy string `json:"additional_subsidy" xorm:"default 0.000000 comment('额外补贴 酒庄模式才有效') DECIMAL(16,6)"`
AdditionalSubsidyBili string `json:"additional_subsidy_bili" xorm:"default 0.000000 comment('额外补贴比例 酒庄模式才有效') DECIMAL(16,6)"`
TeamFreeze int `json:"team_freeze" xorm:"comment('定制') INT(1)"`
ExtendType int `json:"extend_type" xorm:"default 0 comment('0普通 1超级推荐人 2团长 3团长上级超级推荐人 4团长担保用户') unique(IDX_ORD) INT(11)"`
}

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

@@ -0,0 +1,255 @@
package md

// 0已付款,1已收货,2成功,3供应商已结算,4已失效,5平台已结算
const (
OrderStatePaid = iota
OrderStateRecv
OrderStateSucc
OrderStatePvdSettle
OrderStateFail
OrderStateSysSettle
)

const (
OrderTypeSelf = iota // 自购订单
OrderTypeShare // 分享订单
OrderTypeFree // 免单订单
OrderTypeActSelf //活动自购订单
OrderTypeWechatActSelf //小程序活动自购订单
OrderTypeWechatActShare //小程序活动分享订单
OrderTypeTljFree //淘礼金免单订单
OrderTypeTljRelationFree //淘礼金渠道免单订单
OrderTypeWechatActSelfNew = iota + 1 //小程序活动自购订单

)

var OrderState = map[int]struct{}{
OrderStatePaid: {},
OrderStateRecv: {},
OrderStateSucc: {},
OrderStatePvdSettle: {},
OrderStateFail: {},
OrderStateSysSettle: {},
}

type OrderDetail struct {
GoodsInfo OrderList `json:"goods_info"`
OrderInfoList []InfoDetail `json:"order_info_list"`
}
type InfoDetail struct {
Title string `json:"title"`
Content string `json:"content"`
Type string `json:"type"`
}
type OrderStates struct {
Name string `json:"name"`
Type string `json:"type"`
}
type OrderStatusNew struct {
Name string `json:"name"`
Type string `json:"type"`
Tips string `json:"tips"`
TipsReplaceKey string `json:"tips_replace_key"`
TipsReplaceColor string `json:"tips_replace_color"`
AmountText string `json:"amount_text"`
IncomeText string `json:"income_text"`
}
type OrderList struct {
Uid int `json:"uid"`
Nickname string `json:"nickname"`
HidOrder bool `json:"hid_order"`
OrdId string `json:"ord_id"`
ProviderOid string `json:"provider_oid"`
ItemId string `json:"item_id"`
ItemNum int `json:"item_num"`
ItemTitle string `json:"item_title"`
ItemPrice string `json:"item_price"`
Provider string `json:"provider"`
PaidPrice string `json:"paid_price"`
OrderType int `json:"order_type"`
PriceType int `json:"price_type"`
PriceName string `json:"price_name"`
UserCommissionStr string `json:"user_commission_str"`
UserCommission string `json:"user_commission"`
OldUserCommission string `json:"old_user_commission"`
FreeCommission string `json:"free_commission"`
UnionCommission string `json:"union_commission"`
UserCommissionRate string `json:"user_commission_rate"`
Reason string `json:"reason"`
State int `json:"state"`
OldState int `json:"old_state"`
IsFastSign int `json:"is_fast_sign"`
OrderTypes string `json:"order_types"`
UserAlipayName string `json:"user_alipay_name"`
UserAlipayLogo string `json:"user_alipay_logo"`
CreateAt string `json:"create_at"`
UpdateAt string `json:"update_at"`
ConfirmAt string `json:"confirm_at"`
SettleAt string `json:"settle_at"`
PvdSettleAt string `json:"pvd_settle_at"`
Thumbnail string `json:"thumbnail"`
Info string `json:"info"`
UpgradeInfo string `json:"upgrade_info"`
UpgradeReq string `json:"upgrade_req"`
UpgradeValue string `json:"upgrade_value"`
SettleInfo string `json:"settle_info"`
OrderCompare string `json:"order_compare"`
StationOrdId string `json:"station_ord_id"`
CoinList []CoinList `json:"coin_list"`
ReturnMoney string `json:"return_money"`
OrderDetailViewType string `json:"order_detail_view_type"`
OrderInfoList []InfoDetail `json:"order_info_list"`
StateStr string `json:"state_str"`
AmountText string `json:"amount_text"`
OrdModeType string `json:"ord_mode_type"`
AvatarUrl string `json:"avatar_url"`
UserLevel string `json:"user_level"`
UserLevelName string `json:"user_level_name"`
}
type CoinList struct {
CoinId string `json:"coin_id"`
CoinName string `json:"coin_name"`
CoinValue string `json:"coin_value"`
CoinBili string `json:"coin_bili"`
}
type OrderInfoList struct {
Title string `json:"title"`
Type string `json:"type"`
}
type CommissionFirstParam struct {
CommissionParam CommissionParam `json:"commission_param"`
Uid string `json:"uid"`
IsShare int `json:"is_share"`
OldLv string `json:"old_lv"` //升级礼包读取的是升级前的等级
NewLv string `json:"new_lv"` //升级礼包读取的是升级后的等级
Provider string `json:"provider"`
IsAllLevelReturn int `json:"is_all_level_return"` // 是否返回所有层级
GoodsId string `json:"goods_id,omitempty"` // 用于标记是哪个商品的
OwnbuyReturnType int `json:"ownbuy_return_type"` //自购是否返利 0返利 1不返利
Oid string `json:"oid"`
ShowLevel string `json:"show_level"`
IsShowExtend string `json:"is_show_extend"`
}
type CommissionParam struct {
GoodsPrice string `json:"goods_price"`
OldPrice string `json:"old_price"`
PaidPrice string `json:"paid_price"`
Commission string `json:"commission"`
CommissionRate string `json:"commission_rate"`
CouponPrice string `json:"coupon_price"`
WlGoodsPrice string `json:"wl_goods_price"` //卷后价
LowerPrice string `json:"lower_price"`
LowestCouponPrice string `json:"lowestCouponPrice"`
MinGroupPrice string `json:"min_group_price"`
TikTokTeamCommission string `json:"tik_tok_team_commission"`
IsTikTokTeamOrder string `json:"is_tik_tok_team_order"`
DouyinBili string `json:"douyin_bili"`
}
type PrivacyCfg struct {
IsOn string `json:"is_on"`
Nickname string `json:"nickname"`
Phone string `json:"phone"`
GoodsTitle string `json:"goods_title"`
GoodsImage string `json:"goods_image"`
OrderNum string `json:"order_num"`
SelfCommission string `json:"self_commission"`
SonCommission string `json:"son_commission"`
}
type OrderItemList struct {
ItemId string `json:"item_id"`
ItemNum int `json:"item_num"`
Price string `json:"price"`
Commission string `json:"commission"`
CommissionRate string `json:"commission_rate"`
}
type UserPid struct {
Pid string
Uid int
OrderType int
Lv int
NewLv int
OwnbuyReturnType int //0有返利 1没有返利
}

type OrderInfo struct {
Oid int64
PvdOid string
ParentOrdId int64
Pvd string
ItemId string
ItemNum int
ItemPrice float64
ItemTitle string
ItemLink string // 用户ID
Thumbnail string // 缩略图
PaidPrice float64 // 付款总价
OrderType int // 0自购,1分享订单,2新人免单
Pid string // 推广位ID
IsCompare int // 是否比价订单, 只有拼多多和淘宝有
Commission float64 // 总佣金
CommissionRate float64 // 佣金比例
Reason string // 撤单原因
PayTime int64 // 支付时间
StartTime int64 // 下单时间
EndTime int64 // 结束时间
State int // 订单状态, 0已付款,1已收货,2成功,3已结算,4已失效
ConfirmAt int64 //确认收货时间
CheckSuccessAt int64 //审核通过时间
CostPrice float64
Source string //
IsTikTokTeamOrder int
TikTokTeamCommission string
TikTokTeamRealCommission string
OptPvd string
}

type OrderFindRequest struct {
Oid string `json:"oid"`
Uid string `json:"uid"`
}
type CardOrderInfo struct {
ID string `json:"id"`
OrderID string `json:"orderId"`
CreateTime string `json:"create_time"`
UID string `json:"uid"`
Zuid string `json:"zuid"`
Statut string `json:"statut"`
Account string `json:"account"`
BuyNum string `json:"buy_num"`
GID string `json:"g_id"`
SpecID string `json:"spec_id"`
Type string `json:"type"`
Payment string `json:"payment"`
Msg string `json:"msg"`
PayTime string `json:"pay_time"`
LID string `json:"l_id"`
SysOrderID string `json:"sys_orderId"`
Status string `json:"status"`
RechargeStatus string `json:"recharge_status"`
IsToreturn string `json:"is_toreturn"`
CardMsg string `json:"card_msg"`
IsFh string `json:"is_fh"`
Oid string `json:"oid"`
}
type VipOrder struct {
ID string `json:"id"`
ShareAppExtendID string `json:"share_app_extend_id"`
Oid string `json:"oid"`
Gid string `json:"gid"`
Info string `json:"info"`
Commission string `json:"commission"`
CommissionRate string `json:"commission_rate"`
UID string `json:"uid"`
Payment string `json:"payment"`
Status string `json:"status"`
ChannelTag string `json:"channelTag"`
NewCustomer string `json:"newCustomer"`
CreateTime string `json:"create_time"`
SignTime string `json:"sign_time"`
JsTime string `json:"js_time"`
ZmUpdateTime string `json:"zm_update_time"`
StationPid string `json:"station_pid"`
}

// 定制订单列表的站长
const CustomizedOrderListMaster = "[68823769], [22255132]"

+ 2
- 0
consume/init.go View File

@@ -17,6 +17,8 @@ func Init() {

// 增加消费任务队列
func initConsumes() {
jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
//
jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder
jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder



+ 19
- 0
consume/md/consume_key.go View File

@@ -272,9 +272,28 @@ var RabbitMqQueueKeyList = []*MqQueue{
BindKey: "",
ConsumeFunName: "ZhiosSupplierAfterOrder",
},
{
ExchangeName: "zhios.order_buckle.exchange",
Name: "zhios_order_buckle",
Type: DirectQueueType,
IsPersistent: false,
RoutKey: "order_buckle",
BindKey: "",
ConsumeFunName: "ZhiosOrderBuckle",
},
//{
// ExchangeName: "zhios.order_buckle.exchange",
// Name: "zhios_order_buckle_dev",
// Type: DirectQueueType,
// IsPersistent: false,
// RoutKey: "order_buckle_dev",
// BindKey: "",
// ConsumeFunName: "ZhiosOrderBuckle",
//},
}

const (
ZhiosOrderBuckleFunName = "ZhiosOrderBuckle"
ZhiosSupplierAfterOrderFunName = "ZhiosSupplierAfterOrder"
CanalOrderConsumeFunName = "CanalOrderConsume"
CanalGuideOrderConsumeFunName = "CanalGuideOrderConsume"


+ 4
- 0
consume/md/md_zhios_capital_pool_order_total.go View File

@@ -18,6 +18,10 @@ type ZhiosWithdraw struct {
Id string `json:"id"`
Mid string `json:"mid"`
}
type ZhiosOrderBuckle struct {
Oid string `json:"oid"`
Mid string `json:"mid"`
}

type ZhiosAppreciation struct {
Uid string `json:"uid"`


+ 561
- 0
consume/zhios_order_buckle.go View File

@@ -0,0 +1,561 @@
package consume

import (
"applet/app/db"
"applet/app/db/model"
md2 "applet/app/md"
"applet/app/utils"
"applet/app/utils/logx"
"applet/consume/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/lib/comm_plan"
md3 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/svc"
"encoding/json"
"errors"
"fmt"
"github.com/jinzhu/copier"
"github.com/streadway/amqp"
"github.com/tidwall/gjson"
"time"
"xorm.io/xorm"
)

func ZhiosOrderBuckle(queue md.MqQueue) {
fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>")
ch, err := rabbit.Cfg.Pool.GetChannel()
if err != nil {
logx.Error(err)
return
}
defer ch.Release()
//1、将自己绑定到交换机上
ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey)
//2、取出数据进行消费
ch.Qos(1)
delivery := ch.Consume(queue.Name, false)

var res amqp.Delivery
var ok bool
for {
res, ok = <-delivery
if ok == true {
//fmt.Println(string(res.Body))
fmt.Println(">>>>>>>>>>>>>>>>CanalOrderConsume<<<<<<<<<<<<<<<<<<<<<<<<<")
err = handleZhiosOrderBuckle(res.Body)
//_ = res.Reject(false)
if err != nil {
_ = res.Reject(false)
//TODO::重新推回队列末尾,避免造成队列堵塞
var msg *md.ZhiosOrderBuckle
var tmpString string
err := json.Unmarshal(res.Body, &tmpString)
if err != nil {
return
}
fmt.Println(tmpString)
err = json.Unmarshal([]byte(tmpString), &msg)
if err != nil {
return
}
ch.Publish(queue.ExchangeName, utils.SerializeStr(msg), queue.RoutKey)
} else {
_ = res.Ack(true)
}
} else {
panic(errors.New("error getting message"))
}
}
fmt.Println("get msg done")
}

func handleZhiosOrderBuckle(msg []byte) error {
//1、解析canal采集至mq中queue的数据结构体
var canalMsg *md.ZhiosOrderBuckle
fmt.Println(string(msg))
var tmpString string
err := json.Unmarshal(msg, &tmpString)
if err != nil {
fmt.Println("===with", err.Error())
return err
}
fmt.Println(tmpString)
err = json.Unmarshal([]byte(tmpString), &canalMsg)
if err != nil {
fmt.Println("===with", err.Error())
return err
}
mid := canalMsg.Mid
eg := db.DBs[mid]
if eg == nil {
return nil
}
sess := eg.NewSession()
defer sess.Close()
sess.Begin()

ordData, err := db.OrderListByPvdOid(sess, canalMsg.Oid)
if err != nil || ordData == nil {
return nil
}
if ordData.OrderFormType < 0 || ordData.State > 3 {
sess.Commit()

return nil
}
user, _ := db.UserFindByID(eg, ordData.Uid)
if user == nil {
sess.Commit()

return nil
}
//判断是否符合条件 TODO
bools := checkUser(eg, canalMsg.Mid, user, utils.FloatFormat(ordData.BenefitAll, 3))
if bools == false {
sess.Commit()

return nil
}

fmt.Println(ordData)
//加入分佣关系链
opts, commissionOpts, _ := svc.GetAllPlan(eg, canalMsg.Mid)
if opts == nil {
sess.Commit()

return nil
}
BenefitAll := ordData.BenefitAll
pvd := ordData.Pvd
if ordData.OrderFormType == 1 { //京东自营
pvd = md3.PVD_JDOwn
}
var rmd = md3.CommissionParam{IsTikTokTeamOrder: utils.IntToStr(ordData.IsTikTokTeamOrder)}
opt, err := svc.GetPlanCfg(eg, pvd, canalMsg.Mid, opts, commissionOpts, map[int]string{}, &rmd)
if err != nil {
sess.Commit()
return nil
}

if opt.BuckleRate == 0 {
sess.Commit()

return nil
}
//计算出暗扣的比例 TODO
if opt.BuckleRate > 0 {
BenefitAll = utils.FloatFormat(ordData.BenefitAll*(1-opt.BuckleRate), 2)
}
var ord = md2.OrderInfo{
PvdOid: ordData.PvdOid,
Pvd: pvd,
ItemId: ordData.ItemId,
ItemNum: ordData.ItemNum,
ItemPrice: ordData.ItemPrice,
PaidPrice: ordData.PaidPrice,
OrderType: ordData.OrderType,
Commission: BenefitAll,
State: ordData.State,
}
//调用公共的分佣
isShare := 0
if ord.OrderType == 1 {
isShare = 1
}
//计算每个用户的分佣
req := md2.CommissionFirstParam{
CommissionParam: md2.CommissionParam{
Commission: utils.Float64ToStr(ord.Commission),
PaidPrice: utils.Float64ToStr(ord.PaidPrice),
OldPrice: utils.Float64ToStr(ord.PaidPrice),
IsTikTokTeamOrder: utils.IntToStr(ordData.IsTikTokTeamOrder),
},
Uid: utils.IntToStr(ordData.Uid),
IsShare: isShare,
Provider: ord.Pvd,
IsAllLevelReturn: 1,
}
if utils.InArr(ord.Pvd, []string{md3.PVD_TB, md3.PVD_TM, md3.PVD_PDD, md3.PVD_SN, md3.PVD_KL, md3.PVD_JD, md3.PVD_JDOwn, md3.PVD_VIP}) == false {
req.CommissionParam.GoodsPrice = utils.Float64ToStr(ord.PaidPrice)
}
commissionList, err := GetCommissionByCommApi(eg, canalMsg.Mid, req)
if err != nil || commissionList.LvUser == nil {
sess.Commit()
return nil
}
pvdFee := commissionList.PvdFee
sysFee := commissionList.SysFee
subsidyFee := commissionList.SubsidyFee
lvUser := commissionList.LvUser
profit := commissionList.Profit
ordData.SubsidyFee = subsidyFee
ordData.PvdCommission = pvdFee
ordData.SysCommission = sysFee
ordData.BuckleCommission = utils.Float64ToStr(BenefitAll)
if ordData.OrderFormType == 2 {
ordData.OrderFormType = -2
} else {
ordData.OrderFormType = -1

}
var selfRate float64 = 0
var subsidyRate float64 = 0
//处理记录佣金
if opt != nil {
profit = lvUser.Profit
//判断下这个等级有么有设置
ordData.UserCommission = profit
ordData.SubsidyRate = subsidyRate
ordData.UserCommissionRate = selfRate
ordData.PlanCommissionId = opt.PlanCommissionId
ordData.BenefitList = SerializeLvUser(NewCalcLvUserFee(lvUser))
}
has, _ := db.OrderListByUpdateOrd(sess, ordData)
if has == false {
sess.Rollback()
return nil
}

//批量写入
if lvUser != nil {
err := OrderRelateInsert(eg, sess, ordData.OrdId, ordData.Pvd, ordData.CreateAt, lvUser, ordData, canalMsg.Mid, true, opt.Mode, "1")
if err != nil {
sess.Rollback()
return err
}
}
sess.Commit()
return nil
}

func checkUser(eg *xorm.Engine, dbName string, user *model.User, commission float64) bool {
buckleData := db.SysCfgGetWithDb(eg, dbName, "buckle_data")
//注册时间
lastMonthEstimateCommission := gjson.Get(buckleData, "last_month_estimate_commission").String() //用户上个月预估佣金金额大于
monthOrderCount := gjson.Get(buckleData, "month_order_count").String() //用户每月订单笔数
orderCommissionEnd := gjson.Get(buckleData, "order_commission_end").String() //用户订单佣金金额:结束区间
orderCommissionStart := gjson.Get(buckleData, "order_commission_start").String() //用户订单佣金金额:开始区间
userRegDay := gjson.Get(buckleData, "user_reg_day").String() //用户注册时间
if (time.Now().Unix()-user.CreateAt.Unix())/86400 < utils.StrToInt64(userRegDay) && utils.StrToInt64(userRegDay) > 0 {
fmt.Println("时间=============", (time.Now().Unix()-user.CreateAt.Unix())/86400)
return false
}
if utils.StrToFloat64(lastMonthEstimateCommission) > 0 {
lastMonthRange := utils.GetTimeRange("last_month")
// 统计上月预估 (预估包含结算部分且是有效订单)
sqlTpl2 := `SELECT cast(SUM(IF(ol.state<>4 or pco.state=1 or dol.id>0 or ro.status<>'已退款' or pso.status<>'订单退款', LEFT(olr.amount,LENGTH(olr.amount)-2), 0)) as decimal(50,4)) AS amount
FROM ord_list_relate olr
LEFT JOIN ord_list ol ON olr.oid = ol.ord_id
LEFT JOIN privilege_card_ord pco ON olr.oid =pco.ord_id
LEFT JOIN duoyou_ord_list dol ON olr.oid =dol.oid
LEFT JOIN recharge_order ro ON olr.oid =ro.oid
LEFT JOIN playlet_sale_order pso ON olr.oid =pso.custom_oid
WHERE olr.uid = ?
AND olr.create_at >= ?
AND olr.create_at < ?
`
lastMonthResult, _ := db.QueryNativeString(eg, sqlTpl2, user.Uid, lastMonthRange["start"], lastMonthRange["end"])
if len(lastMonthRange) == 0 {
return false
}
fmt.Println("上月预估佣金=============", lastMonthResult[0]["amount"])

if utils.StrToFloat64(lastMonthResult[0]["amount"]) < utils.StrToFloat64(lastMonthEstimateCommission) {
return false
}
}
if utils.StrToFloat64(monthOrderCount) > 0 {
currentMonth := utils.GetTimeRange("current_month")
count, _ := eg.Where("uid=? and create_at>=?", user.Uid, currentMonth["start"]).In("state", []string{"0", "1", "2", "3", "5"}).Count(&model.OrdList{})
fmt.Println("本月订单数=============", count)

if count < utils.StrToInt64(monthOrderCount) {
return false
}
}
if utils.StrToFloat64(orderCommissionEnd) > 0 && utils.StrToFloat64(orderCommissionStart) > 0 {
fmt.Println("订单佣金=============", commission)
if commission < utils.StrToFloat64(orderCommissionStart) {
return false
}
if commission > utils.StrToFloat64(orderCommissionEnd) {
return false
}
}
return true
}

func OrderRelateInsert(eg *xorm.Engine, sess *xorm.Session, oid int64, pvd string, createTime int, lvUser *comm_plan.LvUser, newOrd *model.OrdList, masterId string, isDelete bool, mode string, isNew string) error {
if lvUser == nil {
return nil
}
uid := lvUser.Uid
if uid == 0 {
return nil
}
oldLvUser := lvUser
oldLevel := 0
byOid, _ := db.OrderListByOid(sess, utils.Int64ToStr(oid))
data := OrderRelateInsertComm(eg, oid, pvd, createTime, lvUser, newOrd, masterId, mode)
fmt.Println(data)

if data == nil || len(data) == 0 {
return nil
}
list, _ := db.OrderRelateFindByOid(sess, oid, pvd)
listMap := make(map[int]model.OrdListRelate)
if list != nil {
for _, v := range *list {
listMap[v.Uid] = v
}
}
for k, v := range data {
tmp, ok := listMap[v.Uid]
if ok {
data[k].OldAmount = tmp.Amount
leave := utils.FloatFormat(tmp.Amount-v.Amount, 6)
if leave >= 0 {
var tmps = model.BuckleRecord{
Date: time.Now().Format("2006-01"),
Time: time.Now(),
Uid: v.Uid,
OrdId: utils.Int64ToStr(v.Oid),
PvdOrdId: byOid.PvdOid,
Amount: utils.Float64ToStrByPrec(leave, 6),
BeforeAmount: utils.Float64ToStrByPrec(tmp.Amount, 6),
AfterAmount: utils.Float64ToStrByPrec(v.Amount, 6),
Level: v.Level,
}
_, err := sess.Insert(&tmps)
if err != nil {
return err
}
}
}

}

fmt.Println(isDelete)
_, err2 := db.OrderRelateDeleteByOid(sess, oid, pvd)
if err2 != nil {
return err2
}
_, err2 = db.VirtualCoinOrderRelateDeleteByOid(sess, oid, pvd)
if err2 != nil {
return err2
}
//后写入
err := db.DbInsertBatchSess(sess, data)
if err != nil {
return err

} else if lvUser.ProfitList != nil {
// 插入虚拟币数据
vcrData := CombineVirtualCoinRelateData(oldLvUser, oid, pvd, oldLevel, mode)
if len(vcrData) == 0 {
return nil
}
err := db.DbInsertBatchSess(sess, vcrData)
if err != nil {
return err

}
}
if lvUser.TikTokOwnSubsidyFeeList != nil {
_, err2 := db.TikTokTeamOrderRelateDeleteByOid(sess, oid, pvd)
if err != nil {
return err2
}
var teamData []model.TikTokTeamOrderRelate
TikTokTeamCommission := newOrd.TikTokTeamCommission
if utils.StrToFloat64(newOrd.TikTokTeamRealCommission) > 0 {
TikTokTeamCommission = newOrd.TikTokTeamRealCommission
}
for k, v := range lvUser.TikTokOwnSubsidyFeeList {
tmp := model.TikTokTeamOrderRelate{
CoinId: utils.StrToInt(k),
Uid: uid,
Amount: utils.Float64ToStrByPrec(v, 8),
Oid: utils.Int64ToStr(oid),
Time: time.Now(),
Commission: TikTokTeamCommission,
Pvd: pvd,
}
teamData = append(teamData, tmp)
}
if len(teamData) == 0 {
return nil
}
err := db.DbInsertBatchSess(sess, &teamData)
if err != nil {
return err

}
}
return nil
}
func CombineVirtualCoinRelateData(lvUser *comm_plan.LvUser, oid int64, pvd string, level int, mode string) []*model.VirtualCoinRelate {
var data []*model.VirtualCoinRelate
//可能没有极差返利 只有补贴
profitList := lvUser.ProfitList
if len(profitList) == 0 {
profitList = lvUser.SubsidyFeeList
}
if profitList != nil {
var subsidyFeeList map[string]float64
if lvUser.SubsidyFeeList != nil && len(lvUser.ProfitList) > 0 {
subsidyFeeList = convertList2Map(lvUser.SubsidyFeeList)
}
var coinList = make([]string, 0)
for _, v := range profitList {
coinList = append(coinList, v.Cid)
}
if utils.InArr(mode, []string{"lv_winery", "public_platoon"}) && lvUser.SubsidyFeeList != nil { //补贴类型 没有的要补上
subsidyFeeList = convertList2Map(lvUser.SubsidyFeeList)
for _, v := range lvUser.SubsidyFeeList {
if utils.InArr(v.Cid, coinList) == false && v.Val > 0 {
v.Val = 0
profitList = append(profitList, v)
}
}
}
for _, item := range profitList {
if item.Cid != "0" && item.Cid != "commission" {
//加上补贴
subsidyFee := subsidyFeeList[item.Cid]
var ownSubsidyFee float64 = 0
ownSubsidyFee1, ok := lvUser.OwnSubsidyFeeList[item.Cid]
if ok {
ownSubsidyFee = ownSubsidyFee1
}
var additionalSubsidy float64 = 0
profit := utils.Float64ToStrByPrec(item.Val+subsidyFee+ownSubsidyFee, 9)
if utils.InArr(mode, []string{"lv_winery", "public_platoon"}) {
profit = utils.Float64ToStrByPrec(item.Val+ownSubsidyFee, 9)
additionalSubsidy = subsidyFee

}
if mode == "public_platoon" && level > 1 {
profit = "0"
}
if lvUser.Uid == 0 {
continue
}
var virtualCoinRelate = &model.VirtualCoinRelate{
Oid: oid,
Uid: lvUser.Uid,
CoinId: utils.StrToInt(item.Cid),
Amount: profit,
Pvd: pvd,
CreateAt: int(time.Now().Unix()),
Level: level,
Mode: mode,
AdditionalSubsidy: utils.Float64ToStrByPrec(additionalSubsidy, 6),
ExtendType: lvUser.ExtendType,
}
data = append(data, virtualCoinRelate)
}
}
}
if lvUser.ParentUser != nil {
level += 1
data = append(data, CombineVirtualCoinRelateData(lvUser.ParentUser, oid, pvd, level, mode)...)
}
return data
}
func convertList2Map(a []*comm_plan.VirtualCoinCommission) (b map[string]float64) {
b = make(map[string]float64)
for _, i := range a {
b[i.Cid] = i.Val
}
return b
}

func OrderRelateInsertComm(eg *xorm.Engine, oid int64, pvd string, createTime int, lvUser *comm_plan.LvUser, newOrd *model.OrdList, masterId string, mode string) []*model.OrdListRelate {
var datas []*model.OrdListRelate
if lvUser == nil {
return datas
}
level := 0
fmt.Println("关系链---"+utils.Int64ToStr(oid)+"---"+pvd+"---", utils.SerializeStr(lvUser))
var ownSubsidyFee float64 = 0
ownSubsidyFee1, ok := lvUser.OwnSubsidyFeeList["0"]
if ok {
ownSubsidyFee = ownSubsidyFee1
}
profit := utils.FloatFormat(lvUser.Profit+lvUser.SubsidyFee+ownSubsidyFee, 9)
data := []*model.OrdListRelate{{Oid: oid, Uid: lvUser.Uid, Amount: profit, AdditionalSubsidy: utils.Float64ToStrByPrec(lvUser.AdditionalSubsidy, 9), Pvd: pvd, CreateAt: createTime, Level: level, Mode: mode, ExtendType: lvUser.ExtendType}}
for lvUser.ParentUser != nil {
lvUser = lvUser.ParentUser
fmt.Println(lvUser)
level = level + 1
profit = utils.FloatFormat(lvUser.Profit+lvUser.SubsidyFee, 9)
var additionalSubsidy float64 = 0
if utils.InArr(mode, []string{"lv_winery", "public_platoon"}) {
profit = utils.FloatFormat(lvUser.Profit, 6)
additionalSubsidy = lvUser.SubsidyFee
}
if lvUser.Uid == 0 {
continue
}
data = append(data, &model.OrdListRelate{
Oid: oid,
Uid: lvUser.Uid,
Amount: profit,
Pvd: pvd,
CreateAt: createTime,
Level: level,
Mode: mode,
AdditionalSubsidy: utils.Float64ToStrByPrec(additionalSubsidy, 9),
ExtendType: lvUser.ExtendType,
})
}
return data
}

func SerializeLvUser(lvUser map[int]float64) string {
s := ""
for k, v := range lvUser {
s += "|" + utils.IntToStr(k) + ":" + utils.Float64ToStr(v)
}
return s
}

func NewCalcLvUserFee(lvUser *comm_plan.LvUser) map[int]float64 {
fee := map[int]float64{}
if lvUser == nil {
return fee
}
if lvUser.ParentUser == nil {
fee[lvUser.Uid] = lvUser.Profit
}
for lvUser.ParentUser != nil {
fee[lvUser.Uid] = lvUser.Profit
lvUser = lvUser.ParentUser
}
return fee
}

func SettleComm(eg *xorm.Engine, masterId string, CommissionParam md2.CommissionFirstParam) (float64, float64, float64, float64, *comm_plan.LvUser, error) {
var CommissionParam1 = md3.CommissionFirstParam{}
copier.Copy(&CommissionParam1, CommissionParam)
profit, pvdFee, sysFee, subsidyFee, lvUser, err := rule.SettleCommWithOrder(eg, masterId, CommissionParam1)
return profit, pvdFee, sysFee, subsidyFee, lvUser, err
}

// GetCommissionByCommApi 调用公共接口获取佣金
func GetCommissionByCommApi(eg *xorm.Engine, masterId string, req md2.CommissionFirstParam) (*comm_plan.SettleCommissionToGuide, error) {
profit, pvdFee, sysFee, subsidyFee, lvUser, err := SettleComm(eg, masterId, req)
if err != nil {
return nil, err
}
result := &comm_plan.SettleCommissionToGuide{
Profit: profit,
PvdFee: pvdFee,
SysFee: sysFee,
SubsidyFee: subsidyFee,
LvUser: lvUser,
}
return result, nil
}

+ 1
- 1
go.mod View File

@@ -6,7 +6,7 @@ require (
code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git v1.1.2-0.20231117125527-cb06c9e24f3f
code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.0
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.4
code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20231130020109-71fc70fb5505
code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20231213085413-6f5ba418f36c
code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git v1.6.2-0.20231116085701-9ba6e19f877b
code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20230911014653-22cc8e626d17
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5


Loading…
Cancel
Save