@@ -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 | |||||
} |
@@ -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"` | |||||
} |
@@ -253,3 +253,15 @@ type VipOrder struct { | |||||
// 定制订单列表的站长 | // 定制订单列表的站长 | ||||
const CustomizedOrderListMaster = "[68823769], [22255132]" | 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"` | |||||
} |
@@ -3,6 +3,7 @@ package svc | |||||
import ( | import ( | ||||
db2 "applet/app/db" | db2 "applet/app/db" | ||||
"applet/app/db/model" | "applet/app/db/model" | ||||
"applet/app/md" | |||||
"applet/app/utils" | "applet/app/utils" | ||||
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/lib/comm_plan" | "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" | 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 { | if err != nil { | ||||
return false | 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 | return true | ||||
} | } | ||||
func CommCommSettleMoney(session *xorm.Session, item *model.CommOrdListRelate, appName, masterId string, mapData map[string]string) bool { | func CommCommSettleMoney(session *xorm.Session, item *model.CommOrdListRelate, appName, masterId string, mapData map[string]string) bool { | ||||
@@ -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 | |||||
} |
@@ -463,10 +463,10 @@ var RabbitMqQueueKeyList = []*MqQueue{ | |||||
}, | }, | ||||
{ | { | ||||
ExchangeName: "zhios.relate_reward.exchange", | ExchangeName: "zhios.relate_reward.exchange", | ||||
Name: "zhios_relate_reward", | |||||
Name: "zhios_relate_reward_dev", | |||||
Type: FanOutQueueType, | Type: FanOutQueueType, | ||||
IsPersistent: false, | IsPersistent: false, | ||||
RoutKey: "relate_reward", | |||||
RoutKey: "relate_reward_dev", | |||||
BindKey: "", | BindKey: "", | ||||
ConsumeFunName: "ZhiosRelateRewardExchange", | ConsumeFunName: "ZhiosRelateRewardExchange", | ||||
}, | }, | ||||
@@ -72,6 +72,7 @@ func handleZhiosRelateRewardExchange(msg []byte) error { | |||||
//计算佣金 | //计算佣金 | ||||
var CommissionParam md3.CommissionFirstParam | var CommissionParam md3.CommissionFirstParam | ||||
CommissionParam.CommissionParam.Commission = canalMsg.Reward | CommissionParam.CommissionParam.Commission = canalMsg.Reward | ||||
CommissionParam.CommissionParam.GoodsPrice = canalMsg.Money | |||||
CommissionParam.Uid = uid | CommissionParam.Uid = uid | ||||
CommissionParam.Provider = canalMsg.Provider | CommissionParam.Provider = canalMsg.Provider | ||||
@@ -84,6 +85,11 @@ func handleZhiosRelateRewardExchange(msg []byte) error { | |||||
var mapData = map[string]string{ | var mapData = map[string]string{ | ||||
"coin_id_type": canalMsg.CoinIdType, | "coin_id_type": canalMsg.CoinIdType, | ||||
"mode": cfgs.Mode, | "mode": cfgs.Mode, | ||||
"uid": uid, | |||||
"pvd": canalMsg.Provider, | |||||
"commission": canalMsg.Reward, | |||||
"global_rate": utils.Float64ToStr(cfgs.GlobalRate), | |||||
"price": canalMsg.Money, | |||||
"title": title, | "title": title, | ||||
"device_model": canalMsg.DeviceModel, | "device_model": canalMsg.DeviceModel, | ||||
"reward_type": canalMsg.RewardType, | "reward_type": canalMsg.RewardType, | ||||