Browse Source

更新

one_orenge
huangjiajun 5 months ago
parent
commit
20278b6b70
7 changed files with 123 additions and 2 deletions
  1. +16
    -0
      app/db/db_capital_pool.go
  2. +18
    -0
      app/db/model/capital_pool.go
  3. +12
    -0
      app/md/order.go
  4. +14
    -0
      app/svc/svc_comm_deal_commission.go
  5. +55
    -0
      app/svc/svc_save_capital_pool_order.go
  6. +2
    -2
      consume/md/consume_key.go
  7. +6
    -0
      consume/zhios_relate_reward_exchange.go

+ 16
- 0
app/db/db_capital_pool.go View File

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

import (
"applet/app/db/model"
"applet/app/utils/logx"
"xorm.io/xorm"
)

//UserProfileFindByArkID is get userprofile by arkid
func CapitalPoolByIsUse(Db *xorm.Engine) (*model.CapitalPool, error) {
var m model.CapitalPool
if has, err := Db.Where("is_use = 1").Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}

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

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

import (
"time"
)

type CapitalPool struct {
Id int `json:"id" xorm:"not null pk autoincr comment('主键id') INT(11)"`
IsUse int `json:"is_use" xorm:"not null comment('是否开启(否:0;是:1)') TINYINT(1)"`
IsAuto int `json:"is_auto" xorm:"not null default 0 comment('是否自动分红(否:0;是:1)') TINYINT(1)"`
BonusType string `json:"bonus_type" xorm:"not null default '0' comment('分红类型(1佣金,2积分,3区块币)多个以逗号隔开') VARCHAR(255)"`
BonusDateType int `json:"bonus_date_type" xorm:"not null default 0 comment('日期类型(1每天,2固定时间)') TINYINT(1)"`
BonusTime string `json:"bonus_time" xorm:"default '0' comment('分红日期(1,15,30)多个日期已逗号分隔开;ps 只有日期类型是2才是有数据') VARCHAR(255)"`
BonusLevelType int `json:"bonus_level_type" xorm:"not null default 0 comment('用户等级分红类型(1,指定等级,2大于或等于指定等级)') TINYINT(1)"`
UserLevelGroup string `json:"user_level_group" xorm:"not null comment('指定用户等级组json') TEXT"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"`
UpdateAt time.Time `json:"update_at" xorm:"default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"`
}

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

@@ -253,3 +253,15 @@ type VipOrder struct {

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

type InsertCapitalPoolOrdBelongData struct {
Uid string `json:"uid" remark:用户id`
Pvd string `json:"pvd" remark:订单渠道:自营,导购,o2o。。。。`
OrdId string `json:"ord_id" remark:订单id`
Commission string `json:"commission" remark:订单总佣金`
CommissionType string `json:"commission_type" remark:佣金类型(CNY,虚拟币1Id,虚拟币2Id)`
CapitalPoolRate string `json:"capital_pool_rate" remark:资金池存入比例`
DepositValue string `json:"deposit_value" remark:存入金额`
Price string `json:"price"`
PriceValue string `json:"price_value"`
}

+ 14
- 0
app/svc/svc_comm_deal_commission.go View File

@@ -3,6 +3,7 @@ package svc
import (
db2 "applet/app/db"
"applet/app/db/model"
"applet/app/md"
"applet/app/utils"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/lib/comm_plan"
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md"
@@ -200,6 +201,19 @@ func CommSettleDone(eg *xorm.Engine, pvd string, oid int64, masterId string, map
if err != nil {
return false
}
//全球分红写入
var req = &md.InsertCapitalPoolOrdBelongData{
Uid: mapData["uid"],
Pvd: mapData["pvd"],
Commission: mapData["commission"],
CommissionType: "cny",
OrdId: utils.Int64ToStr(oid),
CapitalPoolRate: mapData["global_rate"],
DepositValue: utils.Float64ToStr(utils.FloatFormat(utils.StrToFloat64(mapData["commission"])*utils.StrToFloat64(mapData["global_rate"]), 6)),
Price: mapData["price"],
PriceValue: utils.Float64ToStr(utils.FloatFormat(utils.StrToFloat64(mapData["price"])*utils.StrToFloat64(mapData["global_rate"]), 6)),
}
SaveCapitalPoolOrderByCommApi(eg, masterId, req)
return true
}
func CommCommSettleMoney(session *xorm.Session, item *model.CommOrdListRelate, appName, masterId string, mapData map[string]string) bool {


+ 55
- 0
app/svc/svc_save_capital_pool_order.go View File

@@ -0,0 +1,55 @@
package svc

import (
"applet/app/cfg"
"applet/app/db"
"applet/app/md"
"crypto/tls"
"encoding/json"
"io/ioutil"
"net/http"
"strings"
"time"
"xorm.io/xorm"
)

func SaveCapitalPoolOrderByCommApi(eg *xorm.Engine, masterId string, req *md.InsertCapitalPoolOrdBelongData) {
ms, err := db.CapitalPoolByIsUse(eg)
if ms == nil || err != nil {
return
}
host := cfg.AppComm.URL + "/api/v1/comm/CapitalPool/addBonusOrd"
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
client := &http.Client{
Timeout: 15 * time.Second,
Transport: tr,
}
byte1, _ := json.Marshal(req)
req1, _ := http.NewRequest("POST", host, strings.NewReader(string(byte1)))
req1.Header.Set("master_id", masterId)
req1.Header.Set("Content-Type", "application/json")
resp, err := (client).Do(req1)
if err != nil || resp == nil {
return
}
defer resp.Body.Close()
respByte, _ := ioutil.ReadAll(resp.Body)

if len(respByte) == 0 {
return
}
var serverResp map[string]interface{}
err = json.Unmarshal(respByte, &serverResp)
if err != nil || serverResp == nil {
return
}
if serverResp["data"] == nil {
if serverResp["msg"] != "" {
return
}
return
}
return
}

+ 2
- 2
consume/md/consume_key.go View File

@@ -463,10 +463,10 @@ var RabbitMqQueueKeyList = []*MqQueue{
},
{
ExchangeName: "zhios.relate_reward.exchange",
Name: "zhios_relate_reward",
Name: "zhios_relate_reward_dev",
Type: FanOutQueueType,
IsPersistent: false,
RoutKey: "relate_reward",
RoutKey: "relate_reward_dev",
BindKey: "",
ConsumeFunName: "ZhiosRelateRewardExchange",
},


+ 6
- 0
consume/zhios_relate_reward_exchange.go View File

@@ -72,6 +72,7 @@ func handleZhiosRelateRewardExchange(msg []byte) error {
//计算佣金
var CommissionParam md3.CommissionFirstParam
CommissionParam.CommissionParam.Commission = canalMsg.Reward
CommissionParam.CommissionParam.GoodsPrice = canalMsg.Money
CommissionParam.Uid = uid
CommissionParam.Provider = canalMsg.Provider

@@ -84,6 +85,11 @@ func handleZhiosRelateRewardExchange(msg []byte) error {
var mapData = map[string]string{
"coin_id_type": canalMsg.CoinIdType,
"mode": cfgs.Mode,
"uid": uid,
"pvd": canalMsg.Provider,
"commission": canalMsg.Reward,
"global_rate": utils.Float64ToStr(cfgs.GlobalRate),
"price": canalMsg.Money,
"title": title,
"device_model": canalMsg.DeviceModel,
"reward_type": canalMsg.RewardType,


Loading…
Cancel
Save