Author | SHA1 | Message | Date |
---|---|---|---|
huangjiajun | 69c8955f64 | 更新 | 3 days ago |
huangjiajun | d295c7e646 | 更新 | 3 days ago |
huangjiajun | c06fe5b032 | 更新 | 3 days ago |
huangjiajun | 1c29cbbc36 | 更新 | 1 week ago |
huangjiajun | 6170a3e8ce | 更新 | 1 week ago |
huangjiajun | 67365d0098 | 更新 | 1 week ago |
huangjiajun | 9990476c4b | 更新 | 1 week ago |
huangjiajun | d65627eec1 | 更新 | 1 week ago |
dengbiao | a2b2d7b376 | update | 2 months ago |
huangjiajun | a1df1ab915 | 更新 | 3 months ago |
huangjiajun | 36c4a9e2a7 | 更新 | 3 months ago |
huangjiajun | 4a1bb56fdc | 更新 | 3 months ago |
huangjiajun | 37ef619809 | 更新 | 3 months ago |
huangjiajun | b610286ed7 | 更新 | 3 months ago |
huangjiajun | b70a7fb95b | 更新 | 3 months ago |
huangjiajun | 892b07468b | 更新 | 3 months ago |
huangjiajun | efba0c4c59 | 更新 | 3 months ago |
huangjiajun | ca8218a5e7 | 更新 | 4 months ago |
huangjiajun | 0abf7c311f | 更新 | 4 months ago |
huangjiajun | 61a311caea | 更新 | 4 months ago |
huangjiajun | 415fbcb1c7 | 更新 | 4 months ago |
huangjiajun | c04645942f | 更新 | 4 months ago |
huangjiajun | 2584616767 | 更新 | 4 months ago |
huangjiajun | 20278b6b70 | 更新 | 4 months ago |
huangjiajun | f2576800fb | 更新 | 5 months ago |
huangjiajun | ad5fc6d65e | 更新 | 5 months ago |
huangjiajun | 503794f1bc | 更新 | 6 months ago |
huangjiajun | 87efca7f68 | 更新 | 6 months ago |
huangjiajun | 00e6685320 | 更新 | 6 months ago |
huangjiajun | 5ec4a582b9 | 更新 | 6 months ago |
huangjiajun | 2d7adcb029 | 更新 | 6 months ago |
huangjiajun | 494fe3f746 | 更新 | 6 months ago |
huangjiajun | 1943da0d83 | 更新 | 6 months ago |
huangjiajun | bb622382ff | 更新 | 7 months ago |
huangjiajun | 84e5e7612f | 更新 | 7 months ago |
huangjiajun | 0f4e6cd6d5 | 更新 | 7 months ago |
huangjiajun | ab4444a6f3 | 更新 | 7 months ago |
huangjiajun | 759ad2d2d8 | 更新 | 7 months ago |
huangjiajun | b06d5bf195 | 更新 | 7 months ago |
huangjiajun | 995ba77216 | 更新 | 7 months ago |
huangjiajun | 62a0c7da36 | 一个橘子 | 7 months ago |
huangjiajun | 8a136a42e0 | 一个橘子 | 7 months ago |
huangjiajun | 1f3048adec | 一个橘子 | 7 months ago |
huangjiajun | d4a164c1fa | 一个橘子 | 7 months ago |
huangjiajun | 6ca12be6f7 | 一个橘子 | 7 months ago |
huangjiajun | 0a064d4c14 | 一个橘子 | 7 months ago |
huangjiajun | 2a4b4a7f75 | 一个橘子 | 7 months ago |
huangjiajun | db6b066e20 | 一个橘子 | 7 months ago |
huangjiajun | 8043d63974 | 一个橘子 | 7 months ago |
huangjiajun | b9285d612e | 一个橘子 | 7 months ago |
huangjiajun | 5069ee0d9f | test | 7 months ago |
@@ -24,6 +24,9 @@ COPY static/html static/html | |||
RUN rm -f /etc/localtime \ | |||
&& ln -sv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ | |||
&& echo "Asia/Shanghai" > /etc/timezone | |||
# 更新 CA 证书库 | |||
RUN apt-get update && apt-get install -y ca-certificates | |||
# 在build阶段复制可执行的go二进制文件app | |||
COPY --from=build /go/release/zyos ./zyos | |||
@@ -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,43 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils" | |||
"xorm.io/xorm" | |||
) | |||
func GetCoinAmountDate(sess *xorm.Session, coinId, date string) *model.CoinAmountDateTotal { | |||
var data model.CoinAmountDateTotal | |||
get, _ := sess.Where("coin_id=? and date=?", coinId, date).Get(&data) | |||
if get == false { | |||
data = model.CoinAmountDateTotal{ | |||
Date: utils.StrToInt(date), | |||
Amount: "0", | |||
CoinId: utils.StrToInt(coinId), | |||
} | |||
one, err := sess.InsertOne(&data) | |||
if one == 0 || err != nil { | |||
return nil | |||
} | |||
} | |||
return &data | |||
} | |||
func GetCoinAmountDateForUse(sess *xorm.Session, coinId, date, uid string) *model.CoinAmountUserTotal { | |||
var data model.CoinAmountUserTotal | |||
get, _ := sess.Where("coin_id=? and date=? and uid=?", coinId, date, uid).Get(&data) | |||
if get == false { | |||
data = model.CoinAmountUserTotal{ | |||
Date: utils.StrToInt(date), | |||
Uid: utils.StrToInt(uid), | |||
Amount: "0", | |||
CoinId: utils.StrToInt(coinId), | |||
} | |||
one, err := sess.InsertOne(&data) | |||
if one == 0 || err != nil { | |||
return nil | |||
} | |||
} | |||
return &data | |||
} |
@@ -0,0 +1,23 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"xorm.io/xorm" | |||
) | |||
func CommOrderRelateListByOid(Db *xorm.Engine, oid int64, pvd string) ([]*model.CommOrdListRelate, error) { | |||
var ol []*model.CommOrdListRelate | |||
err := Db.Where("oid=? and pvd=?", oid, pvd).Find(&ol) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return ol, nil | |||
} | |||
func CommOrderRelateListByOidSess(sess *xorm.Session, oid int64, pvd string) ([]*model.CommOrdListRelate, error) { | |||
var ol []*model.CommOrdListRelate | |||
err := sess.Where("oid=? and pvd=?", oid, pvd).Find(&ol) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return ol, nil | |||
} |
@@ -0,0 +1,29 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils" | |||
"time" | |||
"xorm.io/xorm" | |||
) | |||
// | |||
func GetMoneyReward(eg *xorm.Engine, uid, date, month string) *model.MoneyReward { | |||
var data model.MoneyReward | |||
get, err := eg.Where("uid=? and date=?", uid, date).Get(&data) | |||
if err != nil { | |||
return nil | |||
} | |||
if get == false { | |||
data = model.MoneyReward{ | |||
Uid: utils.StrToInt(uid), | |||
Date: utils.StrToInt(date), | |||
Time: time.Now(), | |||
Month: utils.StrToInt(month), | |||
Amount: "", | |||
} | |||
eg.Insert(&data) | |||
} | |||
return &data | |||
} |
@@ -0,0 +1,16 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"xorm.io/xorm" | |||
) | |||
// | |||
func TaskCenterBase(Db *xorm.Engine) (*model.OneOrengeTaskBase, error) { | |||
var PineappleTaskBase model.OneOrengeTaskBase | |||
has, err := Db.Get(&PineappleTaskBase) | |||
if has == false || err != nil { | |||
return nil, err | |||
} | |||
return &PineappleTaskBase, nil | |||
} |
@@ -0,0 +1,23 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"xorm.io/xorm" | |||
) | |||
func TaskOrderRelateListByOid(Db *xorm.Engine, oid int64, pvd string) ([]*model.TaskOrdListRelate, error) { | |||
var ol []*model.TaskOrdListRelate | |||
err := Db.Where("oid=? and pvd=?", oid, pvd).Find(&ol) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return ol, nil | |||
} | |||
func TaskOrderRelateListByOidSess(sess *xorm.Session, oid int64, pvd string) ([]*model.TaskOrdListRelate, error) { | |||
var ol []*model.TaskOrdListRelate | |||
err := sess.Where("oid=? and pvd=?", oid, pvd).Find(&ol) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return ol, nil | |||
} |
@@ -25,7 +25,19 @@ func GetUserVirtualAmountFlow(eg *xorm.Engine, args map[string]string) *[]model. | |||
} | |||
return &data | |||
} | |||
func GetUserVirtualAmountOne(session *xorm.Session, uid int, coinId int) (*model.UserVirtualAmount, error) { | |||
var m model.UserVirtualAmount | |||
isExist, err := session.Table("user_virtual_amount").Where("uid = ? AND coin_id = ?", uid, coinId).Get(&m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
if !isExist { | |||
return nil, nil | |||
} | |||
return &m, nil | |||
} | |||
func UserVirtualAmountFindByIdWithSession(session *xorm.Session, uid, coinId int) (*model.UserVirtualAmount, error) { | |||
var m model.UserVirtualAmount | |||
has, err := session.Where("uid = ? AND coin_id = ?", uid, coinId).Get(&m) | |||
@@ -119,6 +119,15 @@ func VirtualCoinListInUse(Db *xorm.Engine, masterId, isFreeze string) ([]*model. | |||
return m, nil | |||
} | |||
func VirtualCoinListInUseSess(sess *xorm.Session, masterId, isFreeze string) ([]*model.VirtualCoin, error) { | |||
var m []*model.VirtualCoin | |||
err := sess.Where("is_use=1").Asc("id").Find(&m) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return m, nil | |||
} | |||
func VirtualCoinMapInUse(Db *xorm.Engine, masterId, isFreeze string) (map[string]model.VirtualCoin, error) { | |||
virtualCoinMap := make(map[string]model.VirtualCoin) | |||
@@ -131,6 +140,17 @@ func VirtualCoinMapInUse(Db *xorm.Engine, masterId, isFreeze string) (map[string | |||
} | |||
return virtualCoinMap, nil | |||
} | |||
func VirtualCoinMapInUseSess(sess *xorm.Session, masterId, isFreeze string) (map[string]model.VirtualCoin, error) { | |||
virtualCoinMap := make(map[string]model.VirtualCoin) | |||
listInUse, err := VirtualCoinListInUseSess(sess, masterId, isFreeze) | |||
if err != nil { | |||
return nil, err | |||
} | |||
for _, coin := range listInUse { | |||
virtualCoinMap[utils.AnyToString(coin.Id)] = *coin | |||
} | |||
return virtualCoinMap, nil | |||
} | |||
func VirtualCoinByIds(eg *xorm.Engine, ids []string) map[string]model.VirtualCoin { | |||
var data []model.VirtualCoin | |||
@@ -0,0 +1,24 @@ | |||
package db | |||
import ( | |||
model2 "applet/app/db/model" | |||
"xorm.io/xorm" | |||
) | |||
// 根据订单id查出相关的数据 | |||
func GetVirtualCoinRelateListWithOrdId(engine *xorm.Engine, ordId int64, pvd string) ([]*model2.VirtualCoinRelate, error) { | |||
var list []*model2.VirtualCoinRelate | |||
err := engine.Table("virtual_coin_relate").Where("oid = ? and pvd=?", ordId, pvd).Find(&list) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return list, nil | |||
} | |||
func GetVirtualCoinRelateListWithOrdIdSess(sess *xorm.Session, ordId int64, pvd string) ([]*model2.VirtualCoinRelate, error) { | |||
var list []*model2.VirtualCoinRelate | |||
err := sess.Table("virtual_coin_relate").Where("oid = ? and pvd=?", ordId, pvd).Find(&list) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return list, nil | |||
} |
@@ -110,7 +110,8 @@ func GetAllDatabaseDev() *[]model.DbMapping { | |||
fmt.Println("cfg.Local is: ", cfg.Local) | |||
if cfg.Local { // 本地调试 加快速度 | |||
fmt.Println("notice:LOCAL TEST, only masterId:** 99813608 ** available!") | |||
err = Db.Where("deleted_at != ? AND db_master_id=?", 1, 31585332).Find(&m) | |||
err = Db.Where("deleted_at != ? AND is_dev = '1' AND db_master_id=?", 1, 123456).Find(&m) | |||
} else { | |||
err = Db.Where("deleted_at != ? AND is_dev = '1' ", 1).Find(&m) | |||
} | |||
@@ -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"` | |||
} |
@@ -0,0 +1,8 @@ | |||
package model | |||
type CoinAmountDateTotal struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Date int `json:"date" xorm:"default 0 INT(11)"` | |||
Amount string `json:"amount" xorm:"default 0.000000 DECIMAL(20,6)"` | |||
CoinId int `json:"coin_id" xorm:"default 0 INT(11)"` | |||
} |
@@ -0,0 +1,9 @@ | |||
package model | |||
type CoinAmountUserTotal struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Date int `json:"date" xorm:"default 0 INT(11)"` | |||
Amount string `json:"amount" xorm:"default 0.000000 DECIMAL(20,6)"` | |||
CoinId int `json:"coin_id" xorm:"default 0 INT(11)"` | |||
Uid int `json:"uid" xorm:"default 0 INT(11)"` | |||
} |
@@ -0,0 +1,15 @@ | |||
package model | |||
type CommOrdListRelate 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)"` | |||
Amount float64 `json:"amount" xorm:"not null default 0.00 comment('金额') FLOAT(10,2)"` | |||
Pvd string `json:"pvd" xorm:"not null default '' comment('供应商taobao,jd,pdd,vip,suning,kaola') index VARCHAR(8)"` | |||
Info string `json:"info" xorm:"not null comment('备注') TEXT"` | |||
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)"` | |||
ExtendType int `json:"extend_type" xorm:"default 0 unique(IDX_ORD) comment('0普通 1超级推荐人 2团长 3团长上级超级推荐人 4团长担保用户') INT(11)"` | |||
} |
@@ -0,0 +1,21 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type FbPaySet struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
IsUse int `json:"is_use" xorm:"not null default 0 comment('1开启') TINYINT(1)"` | |||
VendorSn string `json:"vendor_sn" xorm:"not null comment('服务商开放平台id(服务商后台生成') VARCHAR(255)"` | |||
StoreId string `json:"store_id" xorm:"not null comment('商户门店号') VARCHAR(255)"` | |||
AppSecret string `json:"app_secret" xorm:"not null default '' comment('appSecret') VARCHAR(255)"` | |||
MerchantId string `json:"merchant_id" xorm:"not null comment('呗商户号,以服务商级接入时必传,以商户级接入时不传') VARCHAR(255)"` | |||
PayImg string `json:"pay_img" xorm:"not null comment('支付图标') VARCHAR(255)"` | |||
UpdateTime time.Time `json:"update_time" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` | |||
AliPayUse int `json:"ali_pay_use" xorm:"not null default 1 comment('1开启') TINYINT(1)"` | |||
WechatPayUse int `json:"wechat_pay_use" xorm:"not null default 1 comment('1开启') TINYINT(1)"` | |||
FastPayUse int `json:"fast_pay_use" xorm:"default 0 comment('1开启') TINYINT(1)"` | |||
AppId string `json:"app_id" xorm:"not null comment('付呗应用id') VARCHAR(255)"` | |||
OriginalId string `json:"original_id" xorm:"comment('original_id') VARCHAR(255)"` | |||
} |
@@ -0,0 +1,83 @@ | |||
package model | |||
import ( | |||
"applet/app/utils/cache" | |||
"fmt" | |||
jsoniter "github.com/json-iterator/go" | |||
"xorm.io/xorm" | |||
) | |||
var Json = jsoniter.ConfigCompatibleWithStandardLibrary | |||
func (set *FbPaySet) init(engine *xorm.Engine) error { | |||
_, err := engine.Insert(set) | |||
return err | |||
} | |||
func (set *FbPaySet) Get(engine *xorm.Engine) error { | |||
exist, err := engine.IsTableExist(set) | |||
if err != nil { | |||
return err | |||
} | |||
if !exist { | |||
if err := engine.CreateTables(set); err != nil { | |||
return err | |||
} | |||
} | |||
if err != nil { | |||
return err | |||
} | |||
get, err := engine.Get(set) | |||
if err != nil { | |||
return err | |||
} | |||
if !get { | |||
err := set.init(engine) | |||
if err != nil { | |||
return err | |||
} | |||
} | |||
return nil | |||
} | |||
func (set *FbPaySet) Update(engine *xorm.Engine, cols []string) error { | |||
if len(cols) == 0 { | |||
_, err := engine.ID(set.Id).AllCols().Update(set) | |||
if err != nil { | |||
return err | |||
} | |||
return nil | |||
} else { | |||
_, err := engine.ID(set.Id).Cols(cols...).Update(set) | |||
if err != nil { | |||
return err | |||
} | |||
return nil | |||
} | |||
} | |||
func (set *FbPaySet) ToRedis(mid string) error { | |||
marshalToString, err := Json.MarshalToString(set) | |||
if err != nil { | |||
return err | |||
} | |||
key := fmt.Sprintf("%s:fb_pay_setting", mid) | |||
_, err = cache.SetEx(key, marshalToString, 39528000) // 半年 | |||
if err != nil { | |||
return err | |||
} | |||
return nil | |||
} | |||
func (set *FbPaySet) GetByRedis(mid string) bool { | |||
key := fmt.Sprintf("%s:fb_pay_setting", mid) | |||
marshalString, _ := cache.GetString(key) | |||
if marshalString == "" || len(marshalString) < 10 { | |||
return false | |||
} | |||
err := Json.UnmarshalFromString(marshalString, set) | |||
if err != nil { | |||
return false | |||
} | |||
return true | |||
} |
@@ -101,4 +101,9 @@ type MallOrd struct { | |||
Platform string `json:"platform" xorm:" default '' comment('') VARCHAR(255)"` | |||
PayDiscountMoney string `json:"pay_discount_money" xorm:"default '0.00' comment('供应链同一商家总运费') DECIMAL(12,2)"` | |||
IsDeductDiscount int `json:"is_deduct_discount" xorm:"comment('') INT(11)"` | |||
IsShareMoney int `json:"is_share_money" xorm:"default 0 comment('') INT(11)"` | |||
PayTradeNo string `json:"pay_trade_no" xorm:"comment('支付联盟支付的订单号') VARCHAR(50)"` | |||
PayOid string `json:"pay_oid" xorm:" default '' comment('') VARCHAR(255)"` | |||
ShareMoneyOid string `json:"share_money_oid" xorm:" default '' comment('') VARCHAR(255)"` | |||
MerchantNo string `json:"merchant_no" xorm:" default '' comment('') VARCHAR(255)"` | |||
} |
@@ -0,0 +1,42 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type MerchantIncomeInfo struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
ZyosMerchantId int `json:"zyos_merchant_id" xorm:"not null comment('智莺商家id') INT(11)"` | |||
FbMerchantCode string `json:"fb_merchant_code" xorm:"not null comment('付呗商户账号') VARCHAR(255)"` | |||
SalesMan int `json:"sales_man" xorm:"comment('授理商编号') INT(11)"` | |||
BaseInfo string `json:"base_info" xorm:"not null comment('付呗商户基本信息') TEXT"` | |||
LegalPerson string `json:"legal_person" xorm:"not null comment('付呗法人信息,个人类型填联系人信息') TEXT"` | |||
AddressInfo string `json:"address_info" xorm:"not null comment('付呗店铺地址信息') TEXT"` | |||
LicenseInfo string `json:"license_info" xorm:"comment('付呗(营业资质信息)注:小微进件不要传此对象') TEXT"` | |||
AccountInfo string `json:"account_info" xorm:"comment('付呗结算信息') TEXT"` | |||
ShopInfo string `json:"shop_info" xorm:"comment('付呗门店信息') TEXT"` | |||
RateInfo string `json:"rate_info" xorm:"comment('付呗费率') TEXT"` | |||
OtherInfo string `json:"other_info" xorm:"comment('付呗其它信息') TEXT"` | |||
CreateTime time.Time `json:"create_time" xorm:"created not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"` | |||
UpdateTime time.Time `json:"update_time" xorm:"updated not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"` | |||
DeletedTime time.Time `json:"deleted_time" xorm:"deleted comment('删除时间') DATETIME"` | |||
FbMerchantId int `json:"fb_merchant_id" xorm:"comment('付呗商户号') INT(11)"` | |||
FbStoreId int `json:"fb_store_id" xorm:"comment('付呗门店ID') INT(11)"` | |||
IncomeSuccessInfo string `json:"income_success_info" xorm:"comment('付呗入驻成功后返回的信息') TEXT"` | |||
LegalIdCardFrontPhoto string `json:"legal_id_card_front_photo" xorm:"comment('法人身份证正面二进制数据源') TEXT"` | |||
LegalIdCardBackPhoto string `json:"legal_id_card_back_photo" xorm:"comment('法人身份证反面二进制数据源') TEXT"` | |||
HandHoldIdCardPhoto string `json:"hand_hold_id_card_photo" xorm:"comment('手持身份证照二进制数据源') TEXT"` | |||
LicensePhoto string `json:"license_photo" xorm:"comment('营业执照照片二进制数据源') TEXT"` | |||
StoreEnvPhoto string `json:"store_env_photo" xorm:"comment('经营场所内设照片二进制数据源') TEXT"` | |||
StoreFrontPhoto string `json:"store_front_photo" xorm:"comment('门头照二进制数据源') TEXT"` | |||
StoreCashPhoto string `json:"store_cash_photo" xorm:"comment('收银台照片二进制数据源') TEXT"` | |||
OperatingLicensePhoto string `json:"operating_license_photo" xorm:"comment('经营许可证图片二进制数据源') TEXT"` | |||
BankCardPhoto string `json:"bank_card_photo" xorm:"comment('银行卡正面二进制数据源') TEXT"` | |||
IdCardFrontPhoto string `json:"id_card_front_photo" xorm:"comment('结算人身份证正面二进制数据源') TEXT"` | |||
IdCardBackPhoto string `json:"id_card_back_photo" xorm:"comment('结算人身份证反面二进制数据源') TEXT"` | |||
GroupCreateState int `json:"group_create_state" xorm:"comment('创建分账组是否成功') INT(11)"` | |||
GroupCreateResp string `json:"group_create_resp" xorm:"comment('创建分账组返回结果') TEXT"` | |||
GroupId string `json:"group_id" xorm:"not null comment('分账组id') VARCHAR(255)"` | |||
AgreementImg string `json:"agreement_img" xorm:"not null comment('') VARCHAR(600)"` | |||
AppSupplementInfo string `json:"app_supplement_info" xorm:"comment('app补充信息') TEXT"` | |||
} |
@@ -0,0 +1,16 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
// | |||
type MoneyReward struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"INT(11)"` | |||
Date int `json:"date" xorm:"default 0 INT(11)"` | |||
Time time.Time `json:"time" xorm:"DATETIME"` | |||
Month int `json:"month" xorm:"default 0 INT(11)"` | |||
Amount string `json:"amount" xorm:"default 0.00 DECIMAL(20,2)"` | |||
} |
@@ -0,0 +1,15 @@ | |||
package model | |||
type OneOrengeTaskBase struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
CoinId int `json:"coin_id" xorm:"default 0 INT(11)"` | |||
SignCondition int `json:"sign_condition" xorm:"default 0 comment('0无条件 1看完视频') INT(1)"` | |||
SignWayType int `json:"sign_way_type" xorm:"default 0 comment('签到玩法 0连续签到 1累计签到') INT(1)"` | |||
SignWay string `json:"sign_way" xorm:"default '' comment('签到玩法') VARCHAR(255)"` | |||
MustSign int `json:"must_sign" xorm:"default 0 comment('强制签到') INT(1)"` | |||
WithdrawClearDay int `json:"withdraw_clear_day" xorm:"default 0 comment('收益清空 未进入app天数') INT(11)"` | |||
BaseSignReward string `json:"base_sign_reward" xorm:"default 0.00 comment('签到基础奖励') DECIMAL(20,2)"` | |||
AdvId int `json:"adv_id" xorm:"default 0 INT(11)"` | |||
VideoTotal int `json:"video_total" xorm:"default 0 INT(11)"` | |||
VideoReward string `json:"video_reward" xorm:"default 0.00 comment('签到基础奖励') DECIMAL(20,2)"` | |||
} |
@@ -0,0 +1,42 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type OnlineMerchantIncomeInfo struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
ZyosMerchantId int `json:"zyos_merchant_id" xorm:"not null comment('智莺商家id') INT(11)"` | |||
FbMerchantCode string `json:"fb_merchant_code" xorm:"not null comment('乐刷商户账号') VARCHAR(255)"` | |||
SalesMan int `json:"sales_man" xorm:"comment('授理商编号') INT(11)"` | |||
BaseInfo string `json:"base_info" xorm:"not null comment('乐刷商户基本信息') TEXT"` | |||
LegalPerson string `json:"legal_person" xorm:"not null comment('乐刷法人信息,个人类型填联系人信息') TEXT"` | |||
AddressInfo string `json:"address_info" xorm:"not null comment('乐刷店铺地址信息') TEXT"` | |||
LicenseInfo string `json:"license_info" xorm:"comment('乐刷(营业资质信息)注:小微进件不要传此对象') TEXT"` | |||
AccountInfo string `json:"account_info" xorm:"comment('乐刷结算信息') TEXT"` | |||
ShopInfo string `json:"shop_info" xorm:"comment('乐刷门店信息') TEXT"` | |||
RateInfo string `json:"rate_info" xorm:"comment('乐刷费率') TEXT"` | |||
OtherInfo string `json:"other_info" xorm:"comment('乐刷其它信息') TEXT"` | |||
CreateTime time.Time `json:"create_time" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"` | |||
UpdateTime time.Time `json:"update_time" xorm:"not null default CURRENT_TIMESTAMP comment('更新时间') DATETIME"` | |||
DeletedTime time.Time `json:"deleted_time" xorm:"comment('删除时间') DATETIME"` | |||
FbMerchantId int `json:"fb_merchant_id" xorm:"comment('乐刷商户号') INT(11)"` | |||
FbStoreId int `json:"fb_store_id" xorm:"comment('乐刷门店ID') INT(11)"` | |||
IncomeSuccessInfo string `json:"income_success_info" xorm:"comment('乐刷入驻成功后返回的信息') TEXT"` | |||
LegalIdCardFrontPhoto string `json:"legal_id_card_front_photo" xorm:"comment('法人身份证正面二进制数据源') TEXT"` | |||
LegalIdCardBackPhoto string `json:"legal_id_card_back_photo" xorm:"comment('法人身份证反面二进制数据源') TEXT"` | |||
HandHoldIdCardPhoto string `json:"hand_hold_id_card_photo" xorm:"comment('手持身份证照二进制数据源') TEXT"` | |||
LicensePhoto string `json:"license_photo" xorm:"comment('营业执照照片二进制数据源') TEXT"` | |||
StoreEnvPhoto string `json:"store_env_photo" xorm:"comment('经营场所内设照片二进制数据源') TEXT"` | |||
StoreFrontPhoto string `json:"store_front_photo" xorm:"comment('门头照二进制数据源') TEXT"` | |||
StoreCashPhoto string `json:"store_cash_photo" xorm:"comment('收银台照片二进制数据源') TEXT"` | |||
OperatingLicensePhoto string `json:"operating_license_photo" xorm:"comment('经营许可证图片二进制数据源') TEXT"` | |||
BankCardPhoto string `json:"bank_card_photo" xorm:"comment('银行卡正面二进制数据源') TEXT"` | |||
IdCardFrontPhoto string `json:"id_card_front_photo" xorm:"comment('结算人身份证正面二进制数据源') TEXT"` | |||
IdCardBackPhoto string `json:"id_card_back_photo" xorm:"comment('结算人身份证反面二进制数据源') TEXT"` | |||
GroupCreateState int `json:"group_create_state" xorm:"comment('创建分账组是否成功') INT(11)"` | |||
GroupCreateResp string `json:"group_create_resp" xorm:"comment('创建分账组返回结果') TEXT"` | |||
GroupId string `json:"group_id" xorm:"comment('分账组id') VARCHAR(255)"` | |||
AppSupplementInfo string `json:"app_supplement_info" xorm:"comment('app补充信息') TEXT"` | |||
AgreementImg string `json:"agreement_img" xorm:"not null comment('') VARCHAR(600)"` | |||
} |
@@ -0,0 +1,23 @@ | |||
package model | |||
type StationLedgerInfo struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
MerchantOrderSn string `json:"merchant_order_sn" xorm:"comment('系统订单号') VARCHAR(255)"` | |||
Info string `json:"info" xorm:"comment('申请信息') TEXT"` | |||
AccountId string `json:"account_id" xorm:"comment('分账id') VARCHAR(100)"` | |||
Type string `json:"type" xorm:"comment('第三方类型 付呗--fubei') VARCHAR(50)"` | |||
State int `json:"state" xorm:"default 0 comment('1审核中 2审核成功 3审核失败') INT(1)"` | |||
ReturnData string `json:"return_data" xorm:"comment('第三方返回信息') TEXT"` | |||
FailMessage string `json:"fail_message" xorm:"comment('失败原因') VARCHAR(255)"` | |||
MerchantId string `json:"merchant_id" xorm:"comment('商户id') VARCHAR(100)"` | |||
LegalPersonIdCardFrontPhoto string `json:"legal_person_id_card_front_photo" xorm:"comment('法人证件正面照片') TEXT"` | |||
LegalPersonIdCardBackPhoto string `json:"legal_person_id_card_back_photo" xorm:"comment('法人证件反面照片') TEXT"` | |||
SettlementPersonIdCardFrontPhoto string `json:"settlement_person_id_card_front_photo" xorm:"comment('结算人证件正面照片') TEXT"` | |||
SettlementPersonIdCardBackPhoto string `json:"settlement_person_id_card_back_photo" xorm:"comment('结算人证件反面照片') TEXT"` | |||
BankCardPhoto string `json:"bank_card_photo" xorm:"comment('结算银行卡照片') TEXT"` | |||
LicensePhoto string `json:"license_photo" xorm:"comment('营业执照照片地址') TEXT"` | |||
AuthorizationPic string `json:"authorization_pic" xorm:"comment('非法人结算授权函 ') TEXT"` | |||
StoreEnvPhoto string `json:"store_env_photo" xorm:"comment('店内环境照') TEXT"` | |||
StoreFrontImgUrl string `json:"store_front_img_url" xorm:"comment('门头照') TEXT"` | |||
StoreCashPhoto string `json:"store_cash_photo" xorm:"comment('收银台照片') TEXT"` | |||
} |
@@ -0,0 +1,15 @@ | |||
package model | |||
type TaskOrdListRelate 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)"` | |||
Amount float64 `json:"amount" xorm:"not null default 0.00 comment('金额') FLOAT(10,2)"` | |||
Pvd string `json:"pvd" xorm:"not null default '' comment('供应商taobao,jd,pdd,vip,suning,kaola') index VARCHAR(8)"` | |||
Info string `json:"info" xorm:"not null comment('备注') TEXT"` | |||
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)"` | |||
ExtendType int `json:"extend_type" xorm:"default 0 unique(IDX_ORD) comment('0普通 1超级推荐人 2团长 3团长上级超级推荐人 4团长担保用户') INT(11)"` | |||
} |
@@ -0,0 +1,12 @@ | |||
package model | |||
// | |||
type UserExtendTotal struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Uid int `json:"uid" xorm:"default 0 INT(11)"` | |||
Date int `json:"date" xorm:"default 0 INT(11)"` | |||
Month int `json:"month" xorm:"default 0 INT(11)"` | |||
Count int `json:"count" xorm:"default 0 comment('直推的') INT(11)"` | |||
TeamCount int `json:"team_count" xorm:"default 0 comment('团队的') INT(11)"` | |||
} |
@@ -0,0 +1,8 @@ | |||
package model | |||
type UserPublicPlatoonAmount struct { | |||
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"` | |||
Uid int `json:"uid" xorm:"unique(idx_uid_coin_id) INT(11)"` | |||
CoinId int `json:"coin_id" xorm:"unique(idx_uid_coin_id) INT(11)"` | |||
Amount string `json:"amount" xorm:"DECIMAL(16,6)"` | |||
} |
@@ -0,0 +1,20 @@ | |||
package model | |||
type YibaoShareMoney struct { | |||
Id int `json:"id" xorm:"not null pk autoincr INT(11)"` | |||
Oid string `json:"oid" xorm:"VARCHAR(255)"` | |||
PayOid string `json:"pay_oid" xorm:"VARCHAR(255)"` | |||
Msg string `json:"msg" xorm:"TEXT"` | |||
StoreMoney string `json:"store_money" xorm:"default 0.00 DECIMAL(20,2)"` | |||
ZhiyingMoney string `json:"zhiying_money" xorm:"default 0.00 DECIMAL(20,2)"` | |||
PlatformMoney string `json:"platform_money" xorm:"default 0.00 DECIMAL(20,2)"` | |||
Platform string `json:"platform" xorm:"VARCHAR(255)"` | |||
PayMethod string `json:"pay_method" xorm:"VARCHAR(255)"` | |||
Status string `json:"status" xorm:"VARCHAR(255)"` | |||
EndOid string `json:"end_oid" xorm:"VARCHAR(255)"` | |||
EndMsg string `json:"end_msg" xorm:"TEXT"` | |||
EndStatus string `json:"end_status" xorm:"VARCHAR(255)"` | |||
Param string `json:"param" xorm:"TEXT"` | |||
EndParam string `json:"end_param" xorm:"TEXT"` | |||
Type string `json:"type" xorm:"VARCHAR(255)"` | |||
} |
@@ -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"` | |||
} |
@@ -0,0 +1,101 @@ | |||
package svc | |||
import ( | |||
"applet/app/utils" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model" | |||
"time" | |||
"xorm.io/xorm" | |||
) | |||
//共富收益 | |||
func PublicPlatoonSettle(session *xorm.Session, ItemTitle, source, 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: utils.AnyToString(amount), | |||
} | |||
_, err := session.Insert(&data) | |||
if err != nil { | |||
return false | |||
} | |||
} else { | |||
beforeAmount = data.Amount | |||
data.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(data.Amount)+amount, 6) | |||
_, err := session.Where("id=?", data.Id).Cols("amount").Update(&data) | |||
if err != nil { | |||
return false | |||
} | |||
} | |||
finUserFlow := model.UserPublicPlatoonIncomeRecords{ | |||
Type: 0, | |||
Uid: uid, | |||
Amount: utils.AnyToString(amount), | |||
CreateAt: now, | |||
UpdateAt: now, | |||
Date: now.Format("2006-01"), | |||
Kind: 3, | |||
CoinId: coinId, | |||
Title: ItemTitle, | |||
BeforeAmount: beforeAmount, | |||
Oid: ordId, | |||
Source: source, | |||
} | |||
_, err = session.Insert(&finUserFlow) | |||
if err != nil { | |||
return false | |||
} | |||
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: 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, source string) bool { | |||
now := time.Now() | |||
finUserFlow := model.UserPublicPlatoonIncomeRecords{ | |||
Type: types, | |||
Uid: uid, | |||
Amount: utils.AnyToString(amount), | |||
CreateAt: now, | |||
UpdateAt: now, | |||
Date: now.Format("2006-01"), | |||
Kind: kind, | |||
CoinId: coinId, | |||
Title: ItemTitle, | |||
BeforeAmount: beforeAmount, | |||
Oid: ordId, | |||
Source: source, | |||
} | |||
_, err := session.Insert(&finUserFlow) | |||
if err != nil { | |||
return false | |||
} | |||
return true | |||
} |
@@ -0,0 +1,303 @@ | |||
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" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule" | |||
svc2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/svc" | |||
"fmt" | |||
"github.com/jinzhu/copier" | |||
"time" | |||
"xorm.io/xorm" | |||
) | |||
func CommGetLvUser(engine *xorm.Engine, CommissionParam md2.CommissionFirstParam, oid int64, masterId string, mapData map[string]string) { | |||
commArr := rule.GetComm(engine) | |||
plan, commission, virtualCoinMoneyRate := svc2.GetAllPlan(engine, masterId) | |||
var CommissionParam1 md2.CommissionParam | |||
comm := CommissionParam.CommissionParam | |||
err2 := copier.Copy(&CommissionParam1, &comm) | |||
fmt.Println(err2) | |||
_, _, _, _, lvUser, err := svc2.GetRewardCommission(engine, &CommissionParam1, false, CommissionParam.Uid, CommissionParam.Provider, masterId, true, mapData, commArr, plan, commission, virtualCoinMoneyRate) | |||
if err != nil { | |||
return | |||
} | |||
if lvUser == nil { | |||
return | |||
} | |||
CommCommOrderRelateInsert(engine, oid, CommissionParam.Provider, int(time.Now().Unix()), lvUser, mapData) | |||
//sql := `SELECT id from user_virtual_coin_flow where ord_id='%d'` | |||
//sql = fmt.Sprintf(sql, oid) | |||
//nativeString, _ := db2.QueryNativeString(engine, sql) | |||
//has := false | |||
//if len(nativeString) > 0 && utils.StrToInt(nativeString[0]["id"]) > 0 { | |||
// has = true | |||
//} | |||
//sql1 := `SELECT id from fin_user_flow where ord_id='%d'` | |||
//sql1 = fmt.Sprintf(sql1, oid) | |||
//nativeString1, _ := db2.QueryNativeString(engine, sql1) | |||
//has1 := false | |||
//if len(nativeString1) > 0 && utils.StrToInt(nativeString1[0]["id"]) > 0 { | |||
// has1 = true | |||
//} | |||
//fmt.Println("===========任务4=============", masterId, CommissionParam.Uid, oid, has, has1) | |||
//if has == false && has1 == false { | |||
CommSettleDone(engine, CommissionParam.Provider, oid, masterId, mapData) | |||
//} | |||
} | |||
// 分佣表插入获取到的数据 | |||
func CommCommOrderRelateInsert(eg *xorm.Engine, oid int64, pvd string, createTime int, lvUser *comm_plan.LvUser, mapData map[string]string) { | |||
level := 0 | |||
oldLevel := 0 | |||
fmt.Println(lvUser) | |||
profit := utils.FloatFormat(lvUser.Profit+lvUser.SubsidyFee, 6) | |||
oldLvUser := lvUser | |||
data := []*model.CommOrdListRelate{ | |||
{ | |||
Oid: oid, | |||
Uid: lvUser.Uid, | |||
Amount: profit, | |||
Pvd: pvd, | |||
CreateAt: createTime, | |||
Level: level, | |||
}, | |||
} | |||
if mapData["reward_type"] == "2" { | |||
data = make([]*model.CommOrdListRelate, 0) | |||
} | |||
mode := mapData["mode"] | |||
for lvUser.ParentUser != nil { | |||
lvUser = lvUser.ParentUser | |||
if lvUser.Uid == 0 { | |||
continue | |||
} | |||
fmt.Println(lvUser) | |||
level = level + 1 | |||
profit = utils.FloatFormat(lvUser.Profit+lvUser.SubsidyFee, 6) | |||
var additionalSubsidy float64 = 0 | |||
if utils.InArr(mode, []string{"lv_winery", "public_platoon"}) { | |||
profit = utils.FloatFormat(lvUser.Profit, 6) | |||
additionalSubsidy = lvUser.SubsidyFee | |||
} | |||
data = append(data, &model.CommOrdListRelate{ | |||
Oid: oid, | |||
Uid: lvUser.Uid, | |||
Amount: profit, | |||
Pvd: pvd, | |||
CreateAt: createTime, | |||
Level: level, | |||
Mode: mode, | |||
AdditionalSubsidy: utils.Float64ToStrByPrec(additionalSubsidy, 9), | |||
ExtendType: lvUser.ExtendType, | |||
}) | |||
} | |||
for _, v := range data { | |||
if utils.StrToInt(mapData["coin_id_type"]) > 0 { | |||
v.Amount = 0 | |||
v.AdditionalSubsidy = "0" | |||
v.Info = "任务没佣金设置,不返佣金" | |||
} | |||
} | |||
err1 := db2.DbInsertBatch(eg, data) | |||
if err1 != nil { | |||
return | |||
} else { | |||
// 插入虚拟币数据 | |||
vcrData := CommCombineVirtualCoinRelateData(oldLvUser, oid, pvd, oldLevel, mapData) | |||
err2 := db2.DbInsertBatch(eg, vcrData) | |||
for _, item := range vcrData { | |||
fmt.Println(item) | |||
} | |||
if err2 != nil { | |||
return | |||
} | |||
} | |||
} | |||
func CommSettleDone(eg *xorm.Engine, pvd string, oid int64, masterId string, mapData map[string]string) bool { | |||
fmt.Println("=======================任务=============", masterId, oid, pvd) | |||
ol, err := db2.CommOrderRelateListByOid(eg, oid, pvd) | |||
if err != nil { | |||
return false | |||
} | |||
// 查询虚拟币 virtual_coin_relate 表 | |||
vcrList, err := db2.GetVirtualCoinRelateListWithOrdId(eg, oid, pvd) | |||
if err != nil { | |||
return false | |||
} | |||
session := eg.NewSession() | |||
defer session.Close() | |||
if err := session.Begin(); err != nil { | |||
return false | |||
} | |||
set, _ := db2.SysCfgGetOne(eg, "app_name_cn") | |||
var appName = "" | |||
if set != nil { | |||
appName = set.Val | |||
} | |||
pvdOid := oid | |||
if mapData["pvd_oid"] != "" { | |||
pvdOid = utils.StrToInt64(mapData["pvd_oid"]) | |||
} | |||
for _, item := range ol { | |||
if mapData["reward_type"] == "2" && item.Level == 0 { | |||
continue | |||
} | |||
//佣金不为空 | |||
if item.Amount > 0 { | |||
//公排 | |||
if utils.InArr(item.Mode, []string{"lv_commission_public_platoon", "lv_price_public_platoon"}) && item.ExtendType == 5 { | |||
fmt.Println("======================555") | |||
bools := PublicPlatoonSettle(session, "共富奖励", mapData["title"], utils.Int64ToStr(pvdOid), item.Uid, 0, item.Amount) | |||
fmt.Println("======================666", bools) | |||
if bools == false { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
continue | |||
} | |||
item.Oid = pvdOid | |||
_ = CommCommSettleMoney(session, item, appName, masterId, mapData) | |||
} | |||
if utils.StrToFloat64(item.AdditionalSubsidy) > 0 { | |||
if item.Mode == "public_platoon" { //公排 | |||
bools := PublicPlatoonSettle(session, "共富奖励", mapData["title"], utils.Int64ToStr(pvdOid), item.Uid, 0, utils.StrToFloat64(item.AdditionalSubsidy)) | |||
if bools == false { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
} | |||
} | |||
} | |||
// 虚拟币相关操作 | |||
for _, item := range vcrList { | |||
if mapData["reward_type"] == "2" && item.Level == 0 { | |||
continue | |||
} | |||
if utils.StrToFloat64(item.Amount) > 0 { | |||
if utils.InArr(item.Mode, []string{"lv_commission_public_platoon", "lv_price_public_platoon"}) && item.ExtendType == 5 { | |||
fmt.Println("======================555") | |||
bools := PublicPlatoonSettle(session, "共富奖励", mapData["title"], utils.Int64ToStr(pvdOid), item.Uid, item.CoinId, utils.StrToFloat64(item.Amount)) | |||
fmt.Println("======================666", bools) | |||
if bools == false { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
continue | |||
} | |||
item.Oid = pvdOid | |||
_ = CommSettleVirtualCoin(session, item, mapData) | |||
} | |||
//公排 | |||
if item.Mode == "public_platoon" && utils.StrToFloat64(item.AdditionalSubsidy) > 0 { | |||
bools := PublicPlatoonSettle(session, "共富奖励", mapData["title"], utils.Int64ToStr(pvdOid), item.Uid, item.CoinId, utils.StrToFloat64(item.AdditionalSubsidy)) | |||
if bools == false { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
} | |||
} | |||
// 提交事务 | |||
err = session.Commit() | |||
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 { | |||
now := time.Now() | |||
beforeAmount := "0" | |||
afterAmount := "0" | |||
var affected int64 = 0 | |||
userProfile, err := db2.UserProfileFindByIdWithSession(session, item.Uid) | |||
if userProfile == nil { | |||
} | |||
if err != nil || userProfile == nil { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
// 获取余额更新锁 | |||
cb, err := HandleBalanceDistributedLock(masterId, utils.IntToStr(item.Uid), "mall_settle_order") | |||
if err != nil { | |||
fmt.Println(err.Error()) | |||
_ = session.Rollback() | |||
return false | |||
} | |||
// 释放锁 | |||
if cb != nil { | |||
defer cb() | |||
} | |||
// 开始写入流水 | |||
var orderAction int | |||
if item.Level == 0 { | |||
orderAction = 10 // 自购 | |||
} else { | |||
orderAction = 11 // 推广 | |||
} | |||
var ItemTitle = mapData["title"] + "奖励" | |||
if item.Level > 0 { | |||
ItemTitle = mapData["title"] + "团队奖励" | |||
} | |||
finUserFlow := model.FinUserFlow{ | |||
Type: 0, | |||
Uid: item.Uid, | |||
Amount: utils.Float64ToStrByPrec(item.Amount, 8), | |||
BeforeAmount: beforeAmount, | |||
AfterAmount: afterAmount, | |||
OrdType: item.Pvd, | |||
OrdId: utils.AnyToString(item.Oid), | |||
OrdAction: orderAction, | |||
OrdDetail: "", | |||
State: 2, | |||
OtherId: item.Id, | |||
OrdTitle: ItemTitle, | |||
OrdTime: int(now.Unix()), | |||
CreateAt: now, | |||
UpdateAt: now, | |||
} | |||
// 更新用户余额 | |||
finUserFlow.BeforeAmount = userProfile.FinValid | |||
userProfile.FinValid = utils.Float64ToStrByPrec(utils.AnyToFloat64(userProfile.FinValid)+utils.AnyToFloat64(item.Amount), 8) | |||
userProfile.FinTotal = userProfile.FinTotal + utils.StrToFloat32(utils.Float64ToStrByPrec(item.Amount, 8)) | |||
affected, err = db2.UserProfileUpdateWithSession(session, item.Uid, userProfile, "fin_valid", "fin_total") | |||
finUserFlow.AfterAmount = userProfile.FinValid | |||
has, errs := db2.InsertCommWithSession( | |||
session, &finUserFlow) | |||
if affected == 0 || err != nil || errs != nil || has == 0 { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
if utils.InArr(item.Mode, []string{"public_platoon", "lv_commission_public_platoon", "lv_price_public_platoon"}) { //公排的加一条流水 | |||
kind := 4 | |||
title := "自购奖" | |||
if item.Level == 1 { | |||
kind = 5 | |||
title = "直推奖" | |||
} | |||
bools := PublicPlatoonAddRecordWithSession(session, title, utils.Int64ToStr(item.Oid), item.Uid, 0, kind, 0, item.Amount, beforeAmount, mapData["title"]+"奖励") | |||
if bools == false { | |||
return false | |||
} | |||
} | |||
return true | |||
} |
@@ -0,0 +1,457 @@ | |||
package svc | |||
import ( | |||
db2 "applet/app/db" | |||
"applet/app/db/model" | |||
"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" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule" | |||
svc2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/svc" | |||
"fmt" | |||
"github.com/jinzhu/copier" | |||
"time" | |||
"xorm.io/xorm" | |||
) | |||
func GetLvUser(engine *xorm.Engine, CommissionParam md2.CommissionFirstParam, oid int64, masterId string, mapData map[string]string) { | |||
commArr := rule.GetComm(engine) | |||
plan, commission, virtualCoinMoneyRate := svc2.GetAllPlan(engine, masterId) | |||
var CommissionParam1 md2.CommissionParam | |||
comm := CommissionParam.CommissionParam | |||
err2 := copier.Copy(&CommissionParam1, &comm) | |||
fmt.Println(err2) | |||
_, _, _, _, lvUser, err := svc2.GetRewardCommission(engine, &CommissionParam1, false, CommissionParam.Uid, CommissionParam.Provider, masterId, true, mapData, commArr, plan, commission, virtualCoinMoneyRate) | |||
if err != nil { | |||
return | |||
} | |||
if lvUser == nil { | |||
return | |||
} | |||
CommOrderRelateInsert(engine, oid, CommissionParam.Provider, int(time.Now().Unix()), lvUser, mapData) | |||
//sql := `SELECT id from user_virtual_coin_flow where ord_id='%d'` | |||
//sql = fmt.Sprintf(sql, oid) | |||
//nativeString, _ := db2.QueryNativeString(engine, sql) | |||
//has := false | |||
//if len(nativeString) > 0 && utils.StrToInt(nativeString[0]["id"]) > 0 { | |||
// has = true | |||
//} | |||
//sql1 := `SELECT id from fin_user_flow where ord_id='%d'` | |||
//sql1 = fmt.Sprintf(sql1, oid) | |||
//nativeString1, _ := db2.QueryNativeString(engine, sql1) | |||
//has1 := false | |||
//if len(nativeString1) > 0 && utils.StrToInt(nativeString1[0]["id"]) > 0 { | |||
// has1 = true | |||
//} | |||
//fmt.Println("===========任务4=============", masterId, CommissionParam.Uid, oid, has, has1) | |||
//if has == false && has1 == false { | |||
SettleDone(engine, CommissionParam.Provider, oid, masterId, mapData) | |||
//} | |||
} | |||
// 分佣表插入获取到的数据 | |||
func CommOrderRelateInsert(eg *xorm.Engine, oid int64, pvd string, createTime int, lvUser *comm_plan.LvUser, mapData map[string]string) { | |||
level := 0 | |||
oldLevel := 0 | |||
fmt.Println(lvUser) | |||
profit := utils.FloatFormat(lvUser.Profit+lvUser.SubsidyFee, 6) | |||
oldLvUser := lvUser | |||
data := []*model.TaskOrdListRelate{ | |||
{ | |||
Oid: oid, | |||
Uid: lvUser.Uid, | |||
Amount: profit, | |||
Pvd: pvd, | |||
CreateAt: createTime, | |||
Level: level, | |||
}, | |||
} | |||
if mapData["reward_type"] == "2" { | |||
data = make([]*model.TaskOrdListRelate, 0) | |||
} | |||
mode := mapData["mode"] | |||
for lvUser.ParentUser != nil { | |||
lvUser = lvUser.ParentUser | |||
if lvUser.Uid == 0 { | |||
continue | |||
} | |||
fmt.Println(lvUser) | |||
level = level + 1 | |||
profit = utils.FloatFormat(lvUser.Profit+lvUser.SubsidyFee, 6) | |||
var additionalSubsidy float64 = 0 | |||
if utils.InArr(mode, []string{"lv_winery", "public_platoon"}) { | |||
profit = utils.FloatFormat(lvUser.Profit, 6) | |||
additionalSubsidy = lvUser.SubsidyFee | |||
} | |||
data = append(data, &model.TaskOrdListRelate{ | |||
Oid: oid, | |||
Uid: lvUser.Uid, | |||
Amount: profit, | |||
Pvd: pvd, | |||
CreateAt: createTime, | |||
Level: level, | |||
Mode: mode, | |||
AdditionalSubsidy: utils.Float64ToStrByPrec(additionalSubsidy, 9), | |||
ExtendType: lvUser.ExtendType, | |||
}) | |||
} | |||
for _, v := range data { | |||
if utils.StrToInt(mapData["coin_id_type"]) > 0 { | |||
v.Amount = 0 | |||
v.AdditionalSubsidy = "0" | |||
v.Info = "任务没佣金设置,不返佣金" | |||
} | |||
} | |||
err1 := db2.DbInsertBatch(eg, data) | |||
if err1 != nil { | |||
return | |||
} else { | |||
// 插入虚拟币数据 | |||
vcrData := CommCombineVirtualCoinRelateData(oldLvUser, oid, pvd, oldLevel, mapData) | |||
err2 := db2.DbInsertBatch(eg, vcrData) | |||
for _, item := range vcrData { | |||
fmt.Println(item) | |||
} | |||
if err2 != nil { | |||
return | |||
} | |||
} | |||
} | |||
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 CommCombineVirtualCoinRelateData(lvUser *comm_plan.LvUser, oid int64, pvd string, level int, mapData map[string]string) []*model.VirtualCoinRelate { | |||
mode := mapData["mode"] | |||
var data = make([]*model.VirtualCoinRelate, 0) | |||
if mapData["reward_type"] != "2" && level == 0 || level > 0 { | |||
//可能没有极差返利 只有补贴 | |||
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 lvUser.Uid == 0 { | |||
continue | |||
} | |||
if item.Cid != "0" && item.Cid != "commission" { | |||
//加上补贴 | |||
subsidyFee := subsidyFeeList[item.Cid] | |||
var additionalSubsidy float64 = 0 | |||
profit := utils.Float64ToStrByPrec(item.Val+subsidyFee, 9) | |||
if utils.InArr(mode, []string{"lv_winery", "public_platoon"}) { | |||
profit = utils.Float64ToStrByPrec(item.Val, 9) | |||
additionalSubsidy = subsidyFee | |||
} | |||
if mode == "public_platoon" && level > 1 { | |||
profit = "0" | |||
} | |||
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, CommCombineVirtualCoinRelateData(lvUser.ParentUser, oid, pvd, level, mapData)...) | |||
} | |||
return data | |||
} | |||
func SettleDone(eg *xorm.Engine, pvd string, oid int64, masterId string, mapData map[string]string) bool { | |||
fmt.Println("=======================任务=============", masterId, oid, pvd) | |||
ol, err := db2.TaskOrderRelateListByOid(eg, oid, pvd) | |||
if err != nil { | |||
return false | |||
} | |||
// 查询虚拟币 virtual_coin_relate 表 | |||
vcrList, err := db2.GetVirtualCoinRelateListWithOrdId(eg, oid, pvd) | |||
if err != nil { | |||
return false | |||
} | |||
session := eg.NewSession() | |||
defer session.Close() | |||
if err := session.Begin(); err != nil { | |||
return false | |||
} | |||
set, _ := db2.SysCfgGetOne(eg, "app_name_cn") | |||
var appName = "" | |||
if set != nil { | |||
appName = set.Val | |||
} | |||
for _, item := range ol { | |||
if mapData["reward_type"] == "2" && item.Level == 0 { | |||
continue | |||
} | |||
//佣金不为空 | |||
if item.Amount > 0 { | |||
//公排 | |||
if utils.InArr(item.Mode, []string{"lv_commission_public_platoon", "lv_price_public_platoon"}) && item.ExtendType == 5 { | |||
fmt.Println("======================555") | |||
bools := PublicPlatoonSettle(session, "共富奖励", mapData["title"], utils.Int64ToStr(oid), item.Uid, 0, item.Amount) | |||
fmt.Println("======================666", bools) | |||
if bools == false { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
continue | |||
} | |||
_ = CommSettleMoney(session, item, appName, masterId) | |||
} | |||
if utils.StrToFloat64(item.AdditionalSubsidy) > 0 { | |||
if item.Mode == "public_platoon" { //公排 | |||
bools := PublicPlatoonSettle(session, "共富奖励", mapData["title"], utils.Int64ToStr(oid), item.Uid, 0, utils.StrToFloat64(item.AdditionalSubsidy)) | |||
if bools == false { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
} | |||
} | |||
} | |||
// 虚拟币相关操作 | |||
for _, item := range vcrList { | |||
if mapData["reward_type"] == "2" && item.Level == 0 { | |||
continue | |||
} | |||
if utils.StrToFloat64(item.Amount) > 0 { | |||
if utils.InArr(item.Mode, []string{"lv_commission_public_platoon", "lv_price_public_platoon"}) && item.ExtendType == 5 { | |||
fmt.Println("======================555") | |||
bools := PublicPlatoonSettle(session, "共富奖励", mapData["title"], utils.Int64ToStr(oid), item.Uid, item.CoinId, utils.StrToFloat64(item.Amount)) | |||
fmt.Println("======================666", bools) | |||
if bools == false { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
continue | |||
} | |||
_ = CommSettleVirtualCoin(session, item, map[string]string{}) | |||
} | |||
//公排 | |||
if item.Mode == "public_platoon" && utils.StrToFloat64(item.AdditionalSubsidy) > 0 { | |||
bools := PublicPlatoonSettle(session, "共富奖励", mapData["title"], utils.Int64ToStr(oid), item.Uid, item.CoinId, utils.StrToFloat64(item.AdditionalSubsidy)) | |||
if bools == false { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
} | |||
} | |||
// 提交事务 | |||
err = session.Commit() | |||
if err != nil { | |||
return false | |||
} | |||
return true | |||
} | |||
func CommSettleMoney(session *xorm.Session, item *model.TaskOrdListRelate, appName, masterId string) bool { | |||
now := time.Now() | |||
beforeAmount := "0" | |||
afterAmount := "0" | |||
var affected int64 = 0 | |||
userProfile, err := db2.UserProfileFindByIdWithSession(session, item.Uid) | |||
if userProfile == nil { | |||
} | |||
if err != nil || userProfile == nil { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
// 获取余额更新锁 | |||
cb, err := HandleBalanceDistributedLock(masterId, utils.IntToStr(item.Uid), "mall_settle_order") | |||
if err != nil { | |||
fmt.Println(err.Error()) | |||
_ = session.Rollback() | |||
return false | |||
} | |||
// 释放锁 | |||
if cb != nil { | |||
defer cb() | |||
} | |||
// 开始写入流水 | |||
var orderAction int | |||
if item.Level == 0 { | |||
orderAction = 10 // 自购 | |||
} else { | |||
orderAction = 11 // 推广 | |||
} | |||
var ItemTitle = "任务分佣结算" | |||
if item.Pvd == "adset_video" { | |||
ItemTitle = "看视频奖励" | |||
} | |||
titles := ItemTitle | |||
if item.Level > 0 { | |||
ItemTitle = "团队任务奖励" | |||
if item.Pvd == "adset_video" { | |||
ItemTitle = "团队看视频奖励" | |||
} | |||
} | |||
finUserFlow := model.FinUserFlow{ | |||
Type: 0, | |||
Uid: item.Uid, | |||
Amount: utils.Float64ToStrByPrec(item.Amount, 8), | |||
BeforeAmount: beforeAmount, | |||
AfterAmount: afterAmount, | |||
OrdType: item.Pvd, | |||
OrdId: utils.AnyToString(item.Oid), | |||
OrdAction: orderAction, | |||
OrdDetail: "", | |||
State: 2, | |||
OtherId: item.Id, | |||
OrdTitle: ItemTitle, | |||
OrdTime: int(now.Unix()), | |||
CreateAt: now, | |||
UpdateAt: now, | |||
} | |||
// 更新用户余额 | |||
finUserFlow.BeforeAmount = userProfile.FinValid | |||
userProfile.FinValid = utils.Float64ToStrByPrec(utils.AnyToFloat64(userProfile.FinValid)+utils.AnyToFloat64(item.Amount), 8) | |||
userProfile.FinTotal = userProfile.FinTotal + utils.StrToFloat32(utils.Float64ToStrByPrec(item.Amount, 8)) | |||
affected, err = db2.UserProfileUpdateWithSession(session, item.Uid, userProfile, "fin_valid", "fin_total") | |||
finUserFlow.AfterAmount = userProfile.FinValid | |||
has, errs := db2.InsertCommWithSession( | |||
session, &finUserFlow) | |||
if affected == 0 || err != nil || errs != nil || has == 0 { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
if utils.InArr(item.Mode, []string{"public_platoon", "lv_commission_public_platoon", "lv_price_public_platoon"}) { //公排的加一条流水 | |||
kind := 4 | |||
title := "自购奖" | |||
if item.Level == 1 { | |||
kind = 5 | |||
title = "直推奖" | |||
} | |||
bools := PublicPlatoonAddRecordWithSession(session, title, utils.Int64ToStr(item.Oid), item.Uid, 0, kind, 0, item.Amount, beforeAmount, titles) | |||
if bools == false { | |||
return false | |||
} | |||
} | |||
return true | |||
} | |||
func CommSettleVirtualCoin(session *xorm.Session, virtualCoinRelateItem *model.VirtualCoinRelate, mapData map[string]string) bool { | |||
var ( | |||
beforeAmount = "0" | |||
afterAmount = "0" | |||
) | |||
// 查询用户虚拟币余额表记录,有则更新,无则新增一条记录 | |||
userVirtualAmount, err := db2.GetUserVirtualAmountOne(session, virtualCoinRelateItem.Uid, virtualCoinRelateItem.CoinId) | |||
if err != nil { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
if userVirtualAmount == nil { // 没有记录则新增一条 | |||
userVirtualAmount = &model.UserVirtualAmount{ | |||
Uid: virtualCoinRelateItem.Uid, | |||
CoinId: virtualCoinRelateItem.CoinId, | |||
Amount: virtualCoinRelateItem.Amount, | |||
} | |||
afterAmount = virtualCoinRelateItem.Amount | |||
has, errs := db2.InsertCommWithSession( | |||
session, userVirtualAmount) | |||
if errs != nil || has == 0 { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
} else { // 更新 | |||
beforeAmount = userVirtualAmount.Amount | |||
amount := utils.StrToFloat64(userVirtualAmount.Amount) + utils.StrToFloat64(virtualCoinRelateItem.Amount) | |||
userVirtualAmount.Amount = utils.Float64ToStrByPrec(amount, 6) | |||
afterAmount = userVirtualAmount.Amount | |||
affected, err := session.Where("id = ?", userVirtualAmount.Id).Update(userVirtualAmount) | |||
if err != nil { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
if affected == 0 { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
} | |||
var title = "任务分佣结算" | |||
if virtualCoinRelateItem.Pvd == "adset_video" { | |||
title = "看视频奖励" | |||
} | |||
if mapData["title"] != "" { | |||
title = mapData["title"] + "奖励" | |||
} | |||
titles := title | |||
if virtualCoinRelateItem.Level > 0 { | |||
title = "团队任务奖励" | |||
if virtualCoinRelateItem.Pvd == "adset_video" { | |||
title = "团队看视频奖励" | |||
} | |||
if mapData["title"] != "" { | |||
title = mapData["title"] + "团队奖励" | |||
} | |||
} | |||
// 用户虚拟币流水表新增记录 | |||
var userVirtualCoinFlow = model.UserVirtualCoinFlow{ | |||
Uid: virtualCoinRelateItem.Uid, | |||
CoinId: virtualCoinRelateItem.CoinId, | |||
Direction: 1, | |||
Title: title, | |||
OrdId: utils.Int64ToStr(virtualCoinRelateItem.Oid), | |||
Amout: virtualCoinRelateItem.Amount, | |||
BeforeAmout: beforeAmount, | |||
AfterAmout: afterAmount, | |||
SysFee: "0", | |||
CreateTime: time.Now(), | |||
} | |||
has, errs := db2.InsertCommWithSession( | |||
session, &userVirtualCoinFlow) | |||
if errs != nil || has == 0 { | |||
_ = session.Rollback() | |||
return false | |||
} | |||
if utils.InArr(virtualCoinRelateItem.Mode, []string{"public_platoon", "lv_commission_public_platoon", "lv_price_public_platoon"}) { //公排的加一条流水 | |||
kind := 4 | |||
title := "自购奖" | |||
if virtualCoinRelateItem.Level == 1 { | |||
kind = 5 | |||
title = "直推奖" | |||
} | |||
bools := PublicPlatoonAddRecordWithSession(session, title, utils.Int64ToStr(virtualCoinRelateItem.Oid), virtualCoinRelateItem.Uid, virtualCoinRelateItem.CoinId, kind, 0, utils.StrToFloat64(virtualCoinRelateItem.Amount), beforeAmount, titles) | |||
if bools == false { | |||
return false | |||
} | |||
} | |||
return true | |||
} |
@@ -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 | |||
} |
@@ -74,3 +74,69 @@ func virtualCoinFlowInsert(session *xorm.Session, uid, coinId, coinIdTo int, mon | |||
} | |||
return data.Id, nil | |||
} | |||
func UpdateUserFinValidAndInterFlowWithSession(session *xorm.Session, money, Title, ordType string, types, orderAction, uid, id int, ordId, otherId int64) error { | |||
if utils.StrToFloat64(money) <= 0 { | |||
return nil | |||
} | |||
userProfile, err := db.UserProfileFindByIdWithSession(session, uid) | |||
if err != nil || userProfile == nil { | |||
_ = session.Rollback() | |||
if err == nil { | |||
err = errors.New("获取用户余额信息失败") | |||
} | |||
return err | |||
} | |||
beforeAmount := userProfile.FinValid | |||
if types == 0 { | |||
userProfile.FinValid = utils.AnyToString(utils.AnyToFloat64(userProfile.FinValid) + utils.StrToFloat64(money)) | |||
} else if types == 1 { | |||
userProfile.FinValid = utils.AnyToString(utils.AnyToFloat64(userProfile.FinValid) - utils.StrToFloat64(money)) | |||
} | |||
afterAmount := userProfile.FinValid | |||
userProfile.FinTotal = userProfile.FinTotal + utils.StrToFloat32(money) | |||
affected, err := db.UserProfileUpdateWithSession(session, uid, userProfile, "fin_valid,fin_total") | |||
if err != nil || affected == 0 { | |||
if err == nil { | |||
err = errors.New("更新用户余额信息失败") | |||
} | |||
return err | |||
} | |||
err = flowInsert(session, uid, money, orderAction, ordId, otherId, id, Title, ordType, types, beforeAmount, afterAmount) | |||
if err != nil { | |||
return err | |||
} | |||
return nil | |||
} | |||
// 开始写入流水 | |||
//uid:用户id,paidPrice金额,ordId订单id,id其他关联订单,具体根据订单类型判断,goodsId(OrdDetail记录商品ID或提现账号),ItemTitle订单标题 | |||
//type:0收入,1支出,beforeAmount变更前金额,afterAmount变更后 | |||
//orderAction:10自购,11推广,12团队,13免单,20提现,21消费,22退款,23拼团返佣,24资金池分红 | |||
//ordType:订单类型taobao,jd,pdd,vip,suning,kaola,own自营,withdraw提现,vip_refund会员升级退款,vip_order会员升级余额支付流水,group_buy拼团 | |||
func flowInsert(session *xorm.Session, uid int, paidPrice string, orderAction int, ordId int64, id int64, goodsId int, ItemTitle string, ordType string, types int, beforeAmount string, afterAmount string) error { | |||
now := time.Now() | |||
if err := db.FinUserFlowInsertOneWithSession( | |||
session, | |||
&model.FinUserFlow{ | |||
Type: types, | |||
Uid: uid, | |||
Amount: paidPrice, | |||
BeforeAmount: beforeAmount, | |||
AfterAmount: afterAmount, | |||
OrdType: ordType, | |||
OrdId: utils.Int64ToStr(ordId), | |||
OrdAction: orderAction, | |||
OrdDetail: utils.IntToStr(goodsId), | |||
State: 2, | |||
OtherId: id, | |||
OrdTitle: ItemTitle, | |||
OrdTime: int(now.Unix()), | |||
CreateAt: now, | |||
UpdateAt: now, | |||
}); err != nil { | |||
_ = logx.Warn(err) | |||
return err | |||
} | |||
return nil | |||
} |
@@ -2,13 +2,10 @@ package svc | |||
import ( | |||
"applet/app/cfg" | |||
db2 "applet/app/db" | |||
"applet/app/svc" | |||
"applet/app/utils" | |||
"applet/cloud_issuance/db" | |||
"applet/cloud_issuance/enum" | |||
"applet/cloud_issuance/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/chain_transfer" | |||
cache2 "code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/utils/cache" | |||
"fmt" | |||
"github.com/gin-gonic/gin" | |||
@@ -63,11 +60,6 @@ func (dealCloudIssuanceCallBackService *DealCloudIssuanceCallBackService) DealCa | |||
utils.FilePutContents("cloud", utils.SerializeStr(args)) | |||
randInt := utils.RandIntRand(10, 100) | |||
time.Sleep(time.Millisecond * time.Duration(randInt)) // 等待10 ~ 100毫秒 | |||
chain := chain_transfer.TurnChain(svc.MasterDb(c), db2.Db, args) | |||
utils.FilePutContents("cloud_resp", utils.SerializeStr(chain)) | |||
if chain.Count != "" { | |||
req.Data.Content = chain.Count | |||
} | |||
} | |||
utils.FilePutContents("cloud", req.Data.Content) | |||
err = cloudIssuanceService.RobotMacSendText(md.RobotMacSendTextRequest{ | |||
@@ -0,0 +1,130 @@ | |||
package consume | |||
import ( | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/shopspring/decimal" | |||
"github.com/streadway/amqp" | |||
"strings" | |||
"time" | |||
) | |||
func CanalUserVirtualCoinFlowConsume(queue md.MqQueue) { | |||
fmt.Println(">>>>>>>>>>>>CanalUserVirtualCoinFlowConsume>>>>>>>>>>>>") | |||
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(">>>>>>>>>>>>>>>>CanalUserVirtualCoinFlowConsume<<<<<<<<<<<<<<<<<<<<<<<<<") | |||
err = handleCanalUserVirtualCoinFlow(res.Body) | |||
if err != nil { | |||
fmt.Println("handleCanalUserVirtualCoinFlow_ERR:::::", err.Error()) | |||
} | |||
//_ = res.Reject(false) | |||
err = res.Ack(true) | |||
fmt.Println("err ::: ", err) | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleCanalUserVirtualCoinFlow(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.CanalUserVirtualCoinFlowOrderMessage[md.CanalUserVirtualCoinFlowOrder] | |||
err := json.Unmarshal(msg, &canalMsg) | |||
if err != nil { | |||
return err | |||
} | |||
masterId := strings.Split(canalMsg.Database, "_")[1] | |||
if masterId != "32053480" { | |||
return nil | |||
} | |||
engine := db.DBs[masterId] | |||
now := time.Now() | |||
//2、查找 one_circles_green_energy_basic_setting 基础设置 | |||
userPublicPlatoonDoubleNetworkSetting, err := db.UserPublicPlatoonDoubleNetworkSettingGetOneByParams(engine, map[string]interface{}{ | |||
"key": "is_open", | |||
"value": 1, | |||
}) | |||
if err != nil { | |||
return err | |||
} | |||
if userPublicPlatoonDoubleNetworkSetting == nil { | |||
return errors.New("公排双网未开启") | |||
} | |||
if canalMsg.Type == md.CanalMsgInsertSqlType { | |||
if canalMsg.Data[0].CoinId == utils.IntToStr(userPublicPlatoonDoubleNetworkSetting.CoinId) { | |||
//3、查找 user_public_platoon_double_network_user_coin_record | |||
userPublicPlatoonDoubleNetworkUserCoinRecord, err1 := db.UserPublicPlatoonDoubleNetworkUserCoinRecordGetOneByParams(engine, map[string]interface{}{ | |||
"key": "uid", | |||
"value": canalMsg.Data[0].Uid, | |||
}) | |||
if err1 != nil { | |||
return err1 | |||
} | |||
if userPublicPlatoonDoubleNetworkUserCoinRecord == nil { | |||
userProfile, err2 := db.UserProfileFindByIDSess(engine.NewSession(), canalMsg.Data[0].Uid) | |||
if userProfile == nil { | |||
return errors.New("用户不存在") | |||
} | |||
if err2 != nil { | |||
return err2 | |||
} | |||
//新增记录 | |||
_, err3 := db.UserPublicPlatoonDoubleNetworkUserCoinRecordInsert(engine, &model.UserPublicPlatoonDoubleNetworkUserCoinRecord{ | |||
Uid: utils.StrToInt(canalMsg.Data[0].Uid), | |||
LastAmount: canalMsg.Data[0].AfterAmout, | |||
Amount: canalMsg.Data[0].AfterAmout, | |||
RecommendUid: userProfile.ParentUid, | |||
CoinId: utils.StrToInt(canalMsg.Data[0].CoinId), | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err3 != nil { | |||
return err3 | |||
} | |||
} else { | |||
//更新记录 | |||
afterAmount, _ := decimal.NewFromString(canalMsg.Data[0].AfterAmout) | |||
amount, _ := decimal.NewFromString(userPublicPlatoonDoubleNetworkUserCoinRecord.Amount) | |||
lastAmount, _ := decimal.NewFromString(userPublicPlatoonDoubleNetworkUserCoinRecord.LastAmount) | |||
if canalMsg.Data[0].Direction == "1" || canalMsg.Data[0].Direction == "2" { | |||
//收入 && 支出 | |||
userPublicPlatoonDoubleNetworkUserCoinRecord.Amount = amount.Add(afterAmount.Sub(lastAmount)).String() | |||
} | |||
userPublicPlatoonDoubleNetworkUserCoinRecord.LastAmount = canalMsg.Data[0].AfterAmout | |||
_, err2 := db.UserPublicPlatoonDoubleNetworkUserCoinRecordUpdate(engine, userPublicPlatoonDoubleNetworkUserCoinRecord.Id, userPublicPlatoonDoubleNetworkUserCoinRecord, "amount", "last_amount") | |||
if err2 != nil { | |||
return err2 | |||
} | |||
} | |||
} | |||
} | |||
return nil | |||
} |
@@ -0,0 +1,78 @@ | |||
package consume | |||
import ( | |||
"applet/app/db" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/streadway/amqp" | |||
"strings" | |||
) | |||
func CancalUserMoneyConsume(queue md.MqQueue) { | |||
fmt.Println(">>>>>>>>>>>>handleCancalUserMoneyConsume>>>>>>>>>>>>") | |||
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(">>>>>>>>>>>>>>>>handleCancalUserMoneyConsume<<<<<<<<<<<<<<<<<<<<<<<<<") | |||
err = handleCancalUserMoneyConsume(res.Body) | |||
if err != nil { | |||
fmt.Println("handleCancalUserMoneyConsume_ERR:::::", err.Error()) | |||
} | |||
//_ = res.Reject(false) | |||
err = res.Ack(true) | |||
fmt.Println("err ::: ", err) | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleCancalUserMoneyConsume(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.CanalUserMoneyMessage[md.CanalUserMoney] | |||
err := json.Unmarshal(msg, &canalMsg) | |||
if err != nil { | |||
return err | |||
} | |||
masterId := strings.Split(canalMsg.Database, "_")[1] | |||
if masterId != "15763466" { | |||
return nil | |||
} | |||
engine := db.DBs[masterId] | |||
// | |||
if canalMsg.Type == md.CanalMsgInsertSqlType { | |||
if utils.StrToFloat64(canalMsg.Data[0].Amount) > 0 && canalMsg.Data[0].Type == "0" { | |||
ex := strings.Split(canalMsg.Data[0].CreateAt, " ") | |||
date := strings.ReplaceAll(ex[0], "-", "") | |||
monthEx := strings.Split(ex[0], "-") | |||
reward := db.GetMoneyReward(engine, canalMsg.Data[0].Uid, date, monthEx[0]+monthEx[1]) | |||
reward.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(reward.Amount)+utils.StrToFloat64(canalMsg.Data[0].Amount), 6) | |||
engine.Where("id=?", reward.Id).Update(reward) | |||
} | |||
} | |||
return nil | |||
} |
@@ -0,0 +1,92 @@ | |||
package consume | |||
import ( | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/streadway/amqp" | |||
"strings" | |||
"time" | |||
) | |||
func CancalUserRelateConsume(queue md.MqQueue) { | |||
fmt.Println(">>>>>>>>>>>>CancalUserRelateConsume>>>>>>>>>>>>") | |||
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(">>>>>>>>>>>>>>>>CancalUserRelateConsume<<<<<<<<<<<<<<<<<<<<<<<<<") | |||
err = handleCancalUserRelateConsume(res.Body) | |||
if err != nil { | |||
fmt.Println("CancalUserRelateConsume_ERR:::::", err.Error()) | |||
} | |||
//_ = res.Reject(false) | |||
err = res.Ack(true) | |||
fmt.Println("err ::: ", err) | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleCancalUserRelateConsume(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.CanalUserRelateMessage[md.CanalUserRelate] | |||
err := json.Unmarshal(msg, &canalMsg) | |||
if err != nil { | |||
return err | |||
} | |||
masterId := strings.Split(canalMsg.Database, "_")[1] | |||
if masterId != "15763466" { | |||
return nil | |||
} | |||
engine := db.DBs[masterId] | |||
// | |||
if canalMsg.Type == md.CanalMsgInsertSqlType { | |||
var data1 model.UserExtendTotal | |||
date := time.Unix(utils.TimeStdParseUnix(canalMsg.Data[0].InviteTime), 0).Format("20060102") | |||
month := time.Unix(utils.TimeStdParseUnix(canalMsg.Data[0].InviteTime), 0).Format("200601") | |||
engine.Where("uid=? and date=?", canalMsg.Data[0].ParentUid, date).Get(&data1) | |||
if data1.Id == 0 { | |||
data1 = model.UserExtendTotal{ | |||
Uid: utils.StrToInt(canalMsg.Data[0].ParentUid), | |||
Date: utils.StrToInt(date), | |||
Month: utils.StrToInt(month), | |||
Count: 0, | |||
TeamCount: 0, | |||
} | |||
engine.Insert(&data1) | |||
} | |||
if utils.StrToInt(canalMsg.Data[0].Level) == 1 { | |||
data1.Count++ | |||
} else { | |||
data1.TeamCount++ | |||
} | |||
engine.Where("id=?", data1.Id).AllCols().Update(&data1) | |||
} | |||
return nil | |||
} |
@@ -2,7 +2,6 @@ package consume | |||
import ( | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
@@ -10,14 +9,11 @@ import ( | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/shopspring/decimal" | |||
"github.com/streadway/amqp" | |||
"strings" | |||
"time" | |||
) | |||
func CanalUserVirtualCoinFlowConsume(queue md.MqQueue) { | |||
fmt.Println(">>>>>>>>>>>>CanalUserVirtualCoinFlowConsume>>>>>>>>>>>>") | |||
func CanalOneOrengeUserVirtualCoinFlowConsume(queue md.MqQueue) { | |||
ch, err := rabbit.Cfg.Pool.GetChannel() | |||
if err != nil { | |||
logx.Error(err) | |||
@@ -27,7 +23,7 @@ func CanalUserVirtualCoinFlowConsume(queue md.MqQueue) { | |||
//1、将自己绑定到交换机上 | |||
ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey) | |||
//2、取出数据进行消费 | |||
ch.Qos(1) | |||
ch.Qos(1000) | |||
delivery := ch.Consume(queue.Name, false) | |||
var res amqp.Delivery | |||
@@ -36,10 +32,10 @@ func CanalUserVirtualCoinFlowConsume(queue md.MqQueue) { | |||
res, ok = <-delivery | |||
if ok == true { | |||
//fmt.Println(string(res.Body)) | |||
fmt.Println(">>>>>>>>>>>>>>>>CanalUserVirtualCoinFlowConsume<<<<<<<<<<<<<<<<<<<<<<<<<") | |||
err = handleCanalUserVirtualCoinFlow(res.Body) | |||
fmt.Println(">>>>>>>>>>>>>>>>CanalOneOrengeUserVirtualCoinFlowConsume<<<<<<<<<<<<<<<<<<<<<<<<<") | |||
err = handleCanalOneOrengeUserVirtualCoinFlow(res.Body) | |||
if err != nil { | |||
fmt.Println("handleCanalUserVirtualCoinFlow_ERR:::::", err.Error()) | |||
fmt.Println("CanalOneOrengeUserVirtualCoinFlowConsume_ERR:::::", err.Error()) | |||
} | |||
//_ = res.Reject(false) | |||
err = res.Ack(true) | |||
@@ -51,7 +47,7 @@ func CanalUserVirtualCoinFlowConsume(queue md.MqQueue) { | |||
fmt.Println("get msg done") | |||
} | |||
func handleCanalUserVirtualCoinFlow(msg []byte) error { | |||
func handleCanalOneOrengeUserVirtualCoinFlow(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.CanalUserVirtualCoinFlowOrderMessage[md.CanalUserVirtualCoinFlowOrder] | |||
err := json.Unmarshal(msg, &canalMsg) | |||
@@ -60,70 +56,43 @@ func handleCanalUserVirtualCoinFlow(msg []byte) error { | |||
} | |||
masterId := strings.Split(canalMsg.Database, "_")[1] | |||
if masterId != "32053480" { | |||
if masterId != "15763466" { | |||
return nil | |||
} | |||
engine := db.DBs[masterId] | |||
now := time.Now() | |||
//2、查找 one_circles_green_energy_basic_setting 基础设置 | |||
userPublicPlatoonDoubleNetworkSetting, err := db.UserPublicPlatoonDoubleNetworkSettingGetOneByParams(engine, map[string]interface{}{ | |||
"key": "is_open", | |||
"value": 1, | |||
}) | |||
if err != nil { | |||
return err | |||
} | |||
if userPublicPlatoonDoubleNetworkSetting == nil { | |||
return errors.New("公排双网未开启") | |||
} | |||
if canalMsg.Type == md.CanalMsgInsertSqlType { | |||
if canalMsg.Data[0].CoinId == utils.IntToStr(userPublicPlatoonDoubleNetworkSetting.CoinId) { | |||
//3、查找 user_public_platoon_double_network_user_coin_record | |||
userPublicPlatoonDoubleNetworkUserCoinRecord, err1 := db.UserPublicPlatoonDoubleNetworkUserCoinRecordGetOneByParams(engine, map[string]interface{}{ | |||
"key": "uid", | |||
"value": canalMsg.Data[0].Uid, | |||
}) | |||
if err1 != nil { | |||
return err1 | |||
} | |||
if userPublicPlatoonDoubleNetworkUserCoinRecord == nil { | |||
userProfile, err2 := db.UserProfileFindByIDSess(engine.NewSession(), canalMsg.Data[0].Uid) | |||
if userProfile == nil { | |||
return errors.New("用户不存在") | |||
} | |||
if err2 != nil { | |||
return err2 | |||
} | |||
//新增记录 | |||
_, err3 := db.UserPublicPlatoonDoubleNetworkUserCoinRecordInsert(engine, &model.UserPublicPlatoonDoubleNetworkUserCoinRecord{ | |||
Uid: utils.StrToInt(canalMsg.Data[0].Uid), | |||
LastAmount: canalMsg.Data[0].AfterAmout, | |||
Amount: canalMsg.Data[0].AfterAmout, | |||
RecommendUid: userProfile.ParentUid, | |||
CoinId: utils.StrToInt(canalMsg.Data[0].CoinId), | |||
CreateAt: now.Format("2006-01-02 15:04:05"), | |||
UpdateAt: now.Format("2006-01-02 15:04:05"), | |||
}) | |||
if err3 != nil { | |||
return err3 | |||
} | |||
} else { | |||
//更新记录 | |||
afterAmount, _ := decimal.NewFromString(canalMsg.Data[0].AfterAmout) | |||
amount, _ := decimal.NewFromString(userPublicPlatoonDoubleNetworkUserCoinRecord.Amount) | |||
lastAmount, _ := decimal.NewFromString(userPublicPlatoonDoubleNetworkUserCoinRecord.LastAmount) | |||
if canalMsg.Data[0].Direction == "1" || canalMsg.Data[0].Direction == "2" { | |||
//收入 && 支出 | |||
userPublicPlatoonDoubleNetworkUserCoinRecord.Amount = amount.Add(afterAmount.Sub(lastAmount)).String() | |||
} | |||
userPublicPlatoonDoubleNetworkUserCoinRecord.LastAmount = canalMsg.Data[0].AfterAmout | |||
_, err2 := db.UserPublicPlatoonDoubleNetworkUserCoinRecordUpdate(engine, userPublicPlatoonDoubleNetworkUserCoinRecord.Id, userPublicPlatoonDoubleNetworkUserCoinRecord, "amount", "last_amount") | |||
if err2 != nil { | |||
return err2 | |||
} | |||
} | |||
if canalMsg.Data[0].TransferType == "9" || canalMsg.Data[0].Direction != "1" || utils.StrToFloat64(canalMsg.Data[0].Amout) <= 0 { | |||
//转赠不记录 | |||
return nil | |||
} | |||
sess := engine.NewSession() | |||
defer sess.Close() | |||
sess.Begin() | |||
date := utils.TimeParseStd(canalMsg.Data[0].CreateTime).Format("20060102") | |||
amountDate := db.GetCoinAmountDate(sess, canalMsg.Data[0].CoinId, date) | |||
if amountDate == nil { | |||
sess.Rollback() | |||
return errors.New("失败") | |||
} | |||
amountDate.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(canalMsg.Data[0].Amout)+utils.StrToFloat64(amountDate.Amount), 8) | |||
update, err := sess.Where("id=?", amountDate.Id).Cols("amount").Update(amountDate) | |||
if update == 0 || err != nil { | |||
sess.Rollback() | |||
return errors.New("失败") | |||
} | |||
amountUser := db.GetCoinAmountDateForUse(sess, canalMsg.Data[0].CoinId, date, canalMsg.Data[0].Uid) | |||
if amountUser == nil { | |||
sess.Rollback() | |||
return errors.New("失败") | |||
} | |||
amountUser.Amount = utils.Float64ToStrByPrec(utils.StrToFloat64(canalMsg.Data[0].Amout)+utils.StrToFloat64(amountUser.Amount), 8) | |||
update, err = sess.Where("id=?", amountUser.Id).Cols("amount").Update(amountUser) | |||
if update == 0 || err != nil { | |||
sess.Rollback() | |||
return errors.New("失败") | |||
} | |||
sess.Commit() | |||
} | |||
return nil | |||
@@ -17,75 +17,9 @@ func Init() { | |||
// 增加消费任务队列 | |||
func initConsumes() { | |||
// | |||
jobs[consumeMd.ZhiosIntegralProxyRechargeFunName] = ZhiosIntegralProxyRecharge | |||
jobs[consumeMd.ZhiosUserUpLvFunName] = ZhiosUserUpLv | |||
jobs[consumeMd.CanalGuideOrderByUserUpLvConsume] = CanalGuideOrderByUserUpLvConsume | |||
jobs[consumeMd.ZhiosOrderFreeFunName] = ZhiosOrderFree | |||
jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal | |||
jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond | |||
// | |||
jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal | |||
jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy | |||
jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle | |||
// | |||
jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder | |||
jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder | |||
jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation | |||
jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser | |||
jobs[consumeMd.ZhiosYibao0rderShareMoneyMallExchange] = ZhiosYibao0rderShareMoneyMallExchange //自营订单 | |||
jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition | |||
jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial | |||
jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter | |||
jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender | |||
jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans | |||
jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv | |||
jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay | |||
jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess | |||
jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund | |||
jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond | |||
jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore | |||
jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail | |||
jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume | |||
jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate | |||
jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate | |||
jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal | |||
jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail | |||
jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward | |||
// | |||
////////////////////////////////////// V1 ///////////////////////////////////////////////////// | |||
//jobs[consumeMd.CloudIssuanceMsgCallBackFunName] = CloudIssuanceMsgCallBackConsume | |||
//////////////////////////////////////// V2 ///////////////////////////////////////////////////// | |||
//jobs[consumeMd.SupplyCloudChainFenxiaoNewChangeFunName] = SupplyCloudChainFenxiaoNewChangeConsume | |||
//////////////////////////////////////// V3 ///////////////////////////////////////////////////// | |||
//jobs[consumeMd.MallAddSupplyGoodsFunName] = MallAddSupplyGoodsConsume | |||
//////////////////////////////////////// bigData ///////////////////////////////////////////////////// | |||
//jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume | |||
//jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume | |||
//jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume | |||
//jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume | |||
//////////////////////////////////////// oneCircles ///////////////////////////////////////////////////// | |||
//jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume | |||
//jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume | |||
//jobs[consumeMd.OneCirclesSignInCopyGreenEnergyFunName] = OneCirclesSignInCopyGreenEnergyConsume | |||
//////////////////////////////////////// withdraw ///////////////////////////////////////////////////// | |||
//jobs[consumeMd.WithdrawConsumeFunName] = WithdrawConsume | |||
//jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume //绿色双链积分 | |||
} | |||
func Run() { | |||
@@ -12,477 +12,16 @@ type MqQueue struct { | |||
var RabbitMqQueueKeyList = []*MqQueue{ | |||
{ | |||
ExchangeName: "", | |||
Name: "cloud_issuance_async_mlogin", | |||
Type: SimpleQueueType, | |||
IsPersistent: false, | |||
RoutKey: "", | |||
BindKey: "", | |||
ConsumeFunName: "CloudIssuanceAsyncMLoginConsume", | |||
}, | |||
{ | |||
ExchangeName: "zhios.cloud.issuance.msg.callback.exchange", | |||
Name: "cloud_issuance_msg_call_back", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "", | |||
BindKey: "", | |||
ConsumeFunName: "CloudIssuanceMsgCallBackConsume", | |||
}, | |||
{ | |||
ExchangeName: "zhios.cloud_chain.fenxiao.newChange.exchange", | |||
Name: "cloud_chain_fenxiao_newChange", | |||
Type: FanOutQueueType, | |||
IsPersistent: false, | |||
RoutKey: "", | |||
BindKey: "", | |||
ConsumeFunName: "SupplyCloudChainFenxiaoNewChangeConsume", | |||
}, | |||
{ | |||
ExchangeName: "zhios.addSupplyGoods.exchange", | |||
Name: "mall_add_supply_goods", | |||
Type: FanOutQueueType, | |||
IsPersistent: false, | |||
RoutKey: "", | |||
BindKey: "", | |||
ConsumeFunName: "MallAddSupplyGoodsConsume", | |||
}, | |||
{ | |||
ExchangeName: "canal.topic", | |||
Name: "canal_order", | |||
Type: TopicQueueType, | |||
IsPersistent: false, | |||
RoutKey: "canal_mall_order", | |||
BindKey: "", | |||
ConsumeFunName: "CanalOrderConsume", | |||
}, | |||
{ | |||
ExchangeName: "canal.topic", | |||
Name: "canal_guide_order", | |||
Type: TopicQueueType, | |||
IsPersistent: false, | |||
RoutKey: "canal_order_list", | |||
BindKey: "", | |||
ConsumeFunName: "CanalGuideOrderConsume", | |||
}, | |||
{ | |||
ExchangeName: "canal.topic", | |||
Name: "canal_guide_order_by_user_up_lv", | |||
Type: TopicQueueType, | |||
IsPersistent: false, | |||
RoutKey: "canal_order_list", | |||
BindKey: "", | |||
ConsumeFunName: "CanalGuideOrderByUserUpLvConsume", | |||
}, | |||
{ | |||
ExchangeName: "zhios.app.user.visit.ip.address.exchange", | |||
Name: "zhios_user_visit_ip_address_queue", | |||
Type: FanOutQueueType, | |||
IsPersistent: false, | |||
RoutKey: "queue_one", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiOsUserVisitIpAddressConsume", | |||
}, | |||
{ | |||
ExchangeName: "zhios.order.fast.return.exchange", | |||
Name: "zhios_fast_return_order_pay", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_pay", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosFastReturnOrderPay", | |||
}, | |||
{ | |||
ExchangeName: "zhios.order.fast.return.exchange", | |||
Name: "zhios_fast_return_order_success", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_success", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosFastReturnOrderSuccess", | |||
}, | |||
{ | |||
ExchangeName: "zhios.order.fast.return.exchange", | |||
Name: "zhios_fast_return_order_refund", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_refund", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosFastReturnOrderRefund", | |||
}, | |||
{ | |||
ExchangeName: "zhios.order.fast.return.exchange", | |||
Name: "zhios_fast_return_order_refund_second", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_refund_second", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosFastReturnOrderRefundSecond", | |||
}, | |||
{ | |||
ExchangeName: "zhios.doushen.user.register.exchange", | |||
Name: "zhios_doushen_user_register_my_fans", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "my_fans", | |||
BindKey: "my_fans", | |||
ConsumeFunName: "DouShenUserRegisterConsumeForMyFans", | |||
}, | |||
{ | |||
ExchangeName: "zhios.doushen.user.register.exchange", | |||
Name: "zhios_doushen_user_register_operation_center", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "operation_center", | |||
BindKey: "operation_center", | |||
ConsumeFunName: "DouShenUserRegisterConsumeForOperationCenter", | |||
}, | |||
{ | |||
ExchangeName: "zhios.doushen.user.register.exchange", | |||
Name: "zhios_doushen_user_register_my_recommender", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "my_recommender", | |||
BindKey: "my_recommender", | |||
ConsumeFunName: "DouShenUserRegisterConsumeForMyRecommender", | |||
}, | |||
{ | |||
ExchangeName: "zhios.doushen.user.register.exchange", | |||
Name: "zhios_doushen_user_register_official", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "official", | |||
BindKey: "official", | |||
ConsumeFunName: "DouShenUserRegisterConsumeForOfficial", | |||
}, | |||
{ | |||
ExchangeName: "zhios.doushen.user.register.exchange", | |||
Name: "zhios_doushen_user_register_user_comm_up_lv", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "user_register_comm_up_lv", | |||
BindKey: "user_register_comm_up_lv", | |||
ConsumeFunName: "DouShenUserRegisterConsumeForUserRegisterUpLv", | |||
}, | |||
{ | |||
ExchangeName: "canal.topic", | |||
Name: "canal_mall_ord_for_you_mi_shang", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "canal_mall_order", | |||
BindKey: "", | |||
ConsumeFunName: "CanalMallOrdForYouMiShang", | |||
}, | |||
{ | |||
ExchangeName: "zhios.youmishang.exchange", | |||
Name: "zhios_youmishang_exchange_store", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "store", | |||
BindKey: "store", | |||
ConsumeFunName: "YoumishangExchangeStore", | |||
}, | |||
{ | |||
ExchangeName: "zhios.recharge.order.exchange", | |||
Name: "zhios_recharge_order_fail", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_fail", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosRechargeOrderFail", | |||
}, | |||
{ | |||
ExchangeName: "zhios.tikTok.exchange", | |||
Name: "zhios_tikTok_update", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "update", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosTikTokUpdate", | |||
}, | |||
{ | |||
ExchangeName: "zhios.tikTok.exchange", | |||
Name: "zhios_tikTok_all_update", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "all_update", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosTikTokAllUpdate", | |||
}, | |||
{ | |||
ExchangeName: "zhios.capital_pool.order_total.exchange", | |||
Name: "zhios_capital_pool_order_total", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_total", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosCapitalPoolOrderTotal", | |||
}, | |||
{ | |||
ExchangeName: "zhios.acquisition.exchange", | |||
Name: "zhios_acquisition_condition", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "condition", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosAcquisitionCondition", | |||
}, | |||
{ | |||
ExchangeName: "zhios.acquisition.exchange", | |||
Name: "zhios_acquisition_condition_dev", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "acq_dev", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosAcquisitionConditionDev", | |||
}, | |||
{ | |||
ExchangeName: "zhios.recharge.order.exchange", | |||
Name: "zhios_recharge_order_fail_dev", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_fail_dev", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosRechargeOrderFailDev", | |||
}, | |||
{ | |||
ExchangeName: "zhios.express.order.exchange", | |||
Name: "zhios_express_order_fail", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_fail", | |||
BindKey: "", | |||
ConsumeFunName: "zhiosExpressOrderFail", | |||
}, | |||
{ | |||
ExchangeName: "zhios.withdraw.reward.exchange", | |||
Name: "zhios_withdraw_reward", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "withdraw_reward", | |||
BindKey: "", | |||
ConsumeFunName: "zhiosWithdrawReward", | |||
}, | |||
{ | |||
ExchangeName: "zhios.user_valid.exchange", | |||
Name: "zhios_user_valid", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "user_valid", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosValidUser", | |||
}, | |||
{ | |||
ExchangeName: "zhios.appreciation.exchange", | |||
Name: "zhios_appreciation", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "appreciation", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosAppreciation", | |||
}, | |||
{ | |||
ExchangeName: "zhios.appreciation.exchange", | |||
Name: "zhios_appreciation_dev", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "appreciation_dev", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosAppreciationDev", | |||
}, | |||
{ | |||
ExchangeName: "zhios.guide_store.exchange", | |||
Name: "zhios_guide_store_order", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "guide_store_order", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosGuideStoreOrder", | |||
}, | |||
{ | |||
ExchangeName: "zhios.supplier_after_order.exchange", | |||
Name: "zhios_supplier_after_order", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "refund", | |||
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_hjy.exchange", | |||
Name: "zhios_order_hjy", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_hjy", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosOrderHjy", | |||
}, | |||
{ | |||
ExchangeName: "zhios.order_settle_total.exchange", | |||
Name: "zhios_order_settle_total", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_settle_total", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosOrderSettleTotal", | |||
}, | |||
{ | |||
ExchangeName: "zhios.order_total.exchange", | |||
Name: "zhios_order_total", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_total", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosOrderTotal", | |||
}, | |||
{ | |||
ExchangeName: "zhios.order_total.exchange", | |||
Name: "zhios_order_total_second", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_total_second", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosOrderTotalSecond", | |||
}, | |||
{ | |||
ExchangeName: "zhios.order_free.exchange", | |||
Name: "zhios_order_free", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "order_free", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosOrderFree", | |||
}, | |||
{ | |||
ExchangeName: "zhios.user_up_lv.exchange", | |||
Name: "zhios_user_up_lv", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "user_up_lv", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosUserUpLv", | |||
}, | |||
{ | |||
ExchangeName: "zhios.integral_proxy_recharge.exchange", | |||
Name: "zhios_integral_proxy_recharge", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "integral_proxy_recharge", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosIntegralProxyRecharge", | |||
}, | |||
{ | |||
ExchangeName: "zhios.mall_green_coin_consume.exchange", | |||
Name: "zhios_mall_green_coin_consume", | |||
Type: DirectQueueType, | |||
IsPersistent: false, | |||
RoutKey: "mall_green_coin_consume", | |||
BindKey: "", | |||
ConsumeFunName: "ZhiosMallGreenCoinConsume", | |||
}, | |||
{ | |||
ExchangeName: "canal.topic", | |||
Name: "canal_user_virtual_coin_flow", | |||
Type: TopicQueueType, | |||
IsPersistent: false, | |||
RoutKey: "canal_user_virtual_coin_flow", | |||
BindKey: "", | |||
ConsumeFunName: "CanalUserVirtualCoinFlowConsume", | |||
}, | |||
{ | |||
ExchangeName: "one.circles", | |||
Name: "one_circles_sign_in_green_energy", | |||
Type: TopicQueueType, | |||
IsPersistent: false, | |||
RoutKey: "sign_in", | |||
BindKey: "", | |||
ConsumeFunName: "OneCirclesSignInGreenEnergyConsume", | |||
}, | |||
{ | |||
ExchangeName: "one.circles", | |||
Name: "one_circles_start_level_dividend", | |||
Type: TopicQueueType, | |||
IsPersistent: false, | |||
RoutKey: "star_level_dividend", | |||
BindKey: "", | |||
ConsumeFunName: "OneCirclesStartLevelDividendConsume", | |||
}, | |||
{ | |||
ExchangeName: "one.circles", | |||
Name: "one_circles_sign_in_green_energy_copy", | |||
Type: TopicQueueType, | |||
IsPersistent: false, | |||
RoutKey: "sign_in_copy", | |||
BindKey: "", | |||
ConsumeFunName: "OneCirclesSignInCopyGreenEnergyConsume", | |||
}, | |||
{ | |||
ExchangeName: "zhios.app.user.withdraw.apply.exchange", | |||
Name: "zhios_app_user_withdraw_apply_queue", | |||
ExchangeName: "zhios.yibao_order_share_money.exchange", | |||
Name: "zhios_yibao_order_share_money_mall", | |||
Type: FanOutQueueType, | |||
IsPersistent: false, | |||
RoutKey: "queues_one", | |||
RoutKey: "mall", | |||
BindKey: "", | |||
ConsumeFunName: "WithdrawConsume", | |||
ConsumeFunName: "ZhiosYibao0rderShareMoneyMallExchange", | |||
}, | |||
} | |||
const ( | |||
ZhiosUserRelateFunName = "ZhiosUserRelate" | |||
ZhiosIntegralProxyRechargeFunName = "ZhiosIntegralProxyRecharge" | |||
ZhiosMallGreenCoinConsumeFunName = "ZhiosMallGreenCoinConsume" | |||
ZhiosUserUpLvFunName = "ZhiosUserUpLv" | |||
CanalGuideOrderByUserUpLvConsume = "CanalGuideOrderByUserUpLvConsume" | |||
ZhiosOrderFreeFunName = "ZhiosOrderFree" | |||
ZhiosOrderSettleTotalFunName = "ZhiosOrderSettleTotal" | |||
ZhiosOrderTotalFunName = "ZhiosOrderTotal" | |||
ZhiosOrderTotalSecondFunName = "ZhiosOrderTotalSecond" | |||
ZhiosOrderHjyFunName = "ZhiosOrderHjy" | |||
ZhiosOrderBuckleFunName = "ZhiosOrderBuckle" | |||
ZhiosSupplierAfterOrderFunName = "ZhiosSupplierAfterOrder" | |||
CanalOrderConsumeFunName = "CanalOrderConsume" | |||
CanalGuideOrderConsumeFunName = "CanalGuideOrderConsume" | |||
ZhiOsUserVisitIpAddressConsumeFunName = "ZhiOsUserVisitIpAddressConsume" | |||
DouShenUserRegisterConsumeForOfficialFunName = "DouShenUserRegisterConsumeForOfficial" | |||
DouShenUserRegisterConsumeForOperationCenterFunName = "DouShenUserRegisterConsumeForOperationCenter" | |||
DouShenUserRegisterConsumeForMyRecommenderFunName = "DouShenUserRegisterConsumeForMyRecommender" | |||
DouShenUserRegisterConsumeForMyFansFunName = "DouShenUserRegisterConsumeForMyFans" | |||
DouShenUserRegisterConsumeForUserRegisterUpLvFunName = "DouShenUserRegisterConsumeForUserRegisterUpLv" | |||
ZhiosFastReturnOrderPayFunName = "ZhiosFastReturnOrderPay" | |||
ZhiosFastReturnOrderSuccessFunName = "ZhiosFastReturnOrderSuccess" | |||
ZhiosFastReturnOrderRefundFunName = "ZhiosFastReturnOrderRefund" | |||
ZhiosFastReturnOrderRefundSecondFunName = "ZhiosFastReturnOrderRefundSecond" | |||
CanalMallOrdForYouMiShangFunName = "CanalMallOrdForYouMiShang" | |||
YoumishangExchangeStoreFunName = "YoumishangExchangeStore" | |||
ZhiosRechargeOrderFailFunName = "ZhiosRechargeOrderFail" | |||
ZhiosRechargeOrderFailDevFunName = "ZhiosRechargeOrderFailDev" | |||
ZhiosCapitalPoolOrderTotalFunName = "ZhiosCapitalPoolOrderTotal" | |||
ZhiosExpressOrderFail = "zhiosExpressOrderFail" | |||
ZhiosWithdrawReward = "zhiosWithdrawReward" | |||
ZhiosTikTokUpdateFunName = "ZhiosTikTokUpdate" | |||
ZhiosTikTokAllUpdateFunName = "ZhiosTikTokAllUpdate" | |||
CloudIssuanceAsyncMLoginFunName = "CloudIssuanceAsyncMLoginConsume" | |||
CloudIssuanceMsgCallBackFunName = "CloudIssuanceMsgCallBackConsume" | |||
ZhiosAcquisitionConditionFunName = "ZhiosAcquisitionCondition" | |||
ZhiosValidUserFunName = "ZhiosValidUser" | |||
ZhiosAppreciationFunName = "ZhiosAppreciation" | |||
ZhiosAppreciationDevFunName = "ZhiosAppreciationDev" | |||
ZhiosGuideStoreOrderFunName = "ZhiosGuideStoreOrder" | |||
ZhiosAcquisitionConditionDevFunName = "ZhiosAcquisitionConditionDev" | |||
SupplyCloudChainFenxiaoNewChangeFunName = "SupplyCloudChainFenxiaoNewChangeConsume" | |||
MallAddSupplyGoodsFunName = "MallAddSupplyGoodsConsume" | |||
CanalUserVirtualCcoinFlowFunName = "CanalUserVirtualCoinFlowConsume" | |||
OneCirclesSignInGreenEnergyFunName = "OneCirclesSignInGreenEnergyConsume" | |||
OneCirclesStartLevelDividendFunName = "OneCirclesStartLevelDividendConsume" | |||
OneCirclesSignInCopyGreenEnergyFunName = "OneCirclesSignInCopyGreenEnergyConsume" | |||
WithdrawConsumeFunName = "WithdrawConsume" | |||
ZhiosYibao0rderShareMoneyMallExchange = "ZhiosYibao0rderShareMoneyMallExchange" | |||
) |
@@ -7,7 +7,28 @@ type ZhiosAcquisition struct { | |||
Mid string `json:"mid"` | |||
Id string `json:"id"` | |||
} | |||
type ZhiosOrderShareMoney struct { | |||
OrdId string `json:"ord_id"` | |||
Mid string `json:"mid"` | |||
PayWay string `json:"pay_way"` | |||
} | |||
type ZhiosTaskReward struct { | |||
CoinId string `json:"coin_id"` | |||
Money string `json:"money"` | |||
Uid string `json:"uid"` | |||
Mid string `json:"mid"` | |||
Reward string `json:"reward"` | |||
CoinIdType string `json:"coin_id_type"` | |||
Mode string `json:"mode"` | |||
Title string `json:"title"` | |||
DeviceModel string `json:"device_model"` | |||
Oid string `json:"oid"` | |||
RewardType string `json:"reward_type"` | |||
PlanType string `json:"plan_type"` | |||
Provider string `json:"provider"` | |||
PvdOid string `json:"pvd_oid"` | |||
IsTeam string `json:"is_team"` | |||
} | |||
type AcquisitionCfg struct { | |||
Id string `json:"id"` | |||
Status string `json:"status"` | |||
@@ -0,0 +1,39 @@ | |||
package md | |||
type CanalUserMoney struct { | |||
Id string `json:"id" xorm:"pk autoincr comment('流水编号') BIGINT(20)"` | |||
Uid string `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"` | |||
Type string `json:"type" xorm:"not null default 0 comment('0收入,1支出') TINYINT(1)"` | |||
Amount string `json:"amount" xorm:"not null default 0.0000 comment('变动金额') DECIMAL(11,4)"` | |||
BeforeAmount string `json:"before_amount" xorm:"not null default 0.0000 comment('变动前金额') DECIMAL(11,4)"` | |||
AfterAmount string `json:"after_amount" xorm:"not null default 0.0000 comment('变动后金额') DECIMAL(11,4)"` | |||
SysFee string `json:"sys_fee" xorm:"not null default 0.0000 comment('手续费') DECIMAL(11,4)"` | |||
PaymentType string `json:"payment_type" xorm:"not null default 1 comment('1支付宝,2微信.3手动转账') TINYINT(1)"` | |||
OrdType string `json:"ord_type" xorm:"not null default '' comment('订单类型taobao,jd,pdd,vip,suning,kaola,own自营,withdraw提现') VARCHAR(20)"` | |||
OrdId string `json:"ord_id" xorm:"not null default '' comment('对应订单编号') VARCHAR(50)"` | |||
OrdTitle string `json:"ord_title" xorm:"not null default '' comment('订单标题') VARCHAR(50)"` | |||
OrdAction string `json:"ord_action" xorm:"not null default 0 comment('10自购,11推广,12团队,20提现,21消费') TINYINT(2)"` | |||
OrdTime string `json:"ord_time" xorm:"not null default 0 comment('下单时间or提现时间') INT(11)"` | |||
OrdDetail string `json:"ord_detail" xorm:"not null default '' comment('记录商品ID或提现账号') VARCHAR(50)"` | |||
ExpectedTime string `json:"expected_time" xorm:"not null default '0' comment('预期到账时间,字符串用于直接显示,结算后清除内容') VARCHAR(30)"` | |||
State string `json:"state" xorm:"not null default 1 comment('1未到账,2已到账') TINYINT(1)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(2000)"` | |||
OtherId string `json:"other_id" xorm:"not null default 0 comment('其他关联订单,具体根据订单类型判断') BIGINT(20)"` | |||
AliOrdId string `json:"ali_ord_id" xorm:"default '' comment('支付宝订单号') VARCHAR(128)"` | |||
CreateAt string `json:"create_at" xorm:"created not null default CURRENT_TIMESTAMP comment('创建时间') TIMESTAMP"` | |||
UpdateAt string `json:"update_at" xorm:"updated not null default CURRENT_TIMESTAMP comment('更新时间') TIMESTAMP"` | |||
} | |||
// | |||
type CanalUserMoneyMessage[T any] struct { | |||
Data []T `json:"data"` | |||
Database string `json:"database"` | |||
ES int64 `json:"es"` | |||
ID int64 `json:"id"` | |||
IsDdl bool `json:"isDdl"` | |||
Old []T `json:"old"` | |||
PkNames []string `json:"pkNames"` | |||
Table string `json:"table"` | |||
TS int64 `json:"ts"` | |||
Type string `json:"type"` | |||
} |
@@ -0,0 +1,23 @@ | |||
package md | |||
type CanalUserRelate struct { | |||
Id string `json:"id" xorm:"pk autoincr comment('主键') BIGINT(10)"` | |||
ParentUid string `json:"parent_uid" xorm:"not null default 0 comment('上级会员ID') unique(idx_union_u_p_id) INT(20)"` | |||
Uid string `json:"uid" xorm:"not null default 0 comment('关联UserID') unique(idx_union_u_p_id) INT(20)"` | |||
Level string `json:"level" xorm:"not null default 1 comment('推广等级(1直属,大于1非直属)') INT(10)"` | |||
InviteTime string `json:"invite_time" xorm:"not null default CURRENT_TIMESTAMP comment('邀请时间') TIMESTAMP"` | |||
} | |||
// | |||
type CanalUserRelateMessage[T any] struct { | |||
Data []T `json:"data"` | |||
Database string `json:"database"` | |||
ES int64 `json:"es"` | |||
ID int64 `json:"id"` | |||
IsDdl bool `json:"isDdl"` | |||
Old []T `json:"old"` | |||
PkNames []string `json:"pkNames"` | |||
Table string `json:"table"` | |||
TS int64 `json:"ts"` | |||
Type string `json:"type"` | |||
} |
@@ -2,7 +2,6 @@ package consume | |||
import ( | |||
"applet/app/cfg" | |||
"applet/app/db" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
@@ -56,8 +55,8 @@ func handleOneCirclesSignInGreenEnergy(msgData []byte) error { | |||
return err | |||
} | |||
engine := db.DBs[msg.MasterId] | |||
err = one_circles.HandleSettlementSignInGreenEnergy(engine, msg.MasterId, msg.Id, msg.Uid) | |||
//engine := db.DBs[msg.MasterId] | |||
//err = one_circles.HandleSettlementSignInGreenEnergy(engine, msg.MasterId, msg.Id, msg.Uid) | |||
fmt.Println("err::::", err) | |||
if err != nil { | |||
return err | |||
@@ -2,7 +2,6 @@ package consume | |||
import ( | |||
"applet/app/cfg" | |||
"applet/app/db" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
@@ -56,8 +55,8 @@ func handleOneCirclesSignInCopyGreenEnergy(msgData []byte) error { | |||
return err | |||
} | |||
engine := db.DBs[msg.MasterId] | |||
err = one_circles.HandleSettlementSignInGreenEnergy(engine, msg.MasterId, msg.Id, msg.Uid) | |||
//engine := db.DBs[msg.MasterId] | |||
//err = one_circles.HandleSettlementSignInGreenEnergy(engine, msg.MasterId, msg.Id, msg.Uid) | |||
fmt.Println("err::::", err) | |||
if err != nil { | |||
return err | |||
@@ -0,0 +1,333 @@ | |||
package consume | |||
import ( | |||
"applet/app/cfg" | |||
"applet/app/db" | |||
"applet/app/db/model" | |||
"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_pay.git/lib/fb_pay" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/db/offical" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/yibao_pay" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/streadway/amqp" | |||
"github.com/tidwall/gjson" | |||
"time" | |||
"xorm.io/xorm" | |||
) | |||
func ZhiosYibao0rderShareMoneyMallExchange(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(">>>>>>>>>>>>>>>>ZhiosYibao0rderShareMoneyMallExchange<<<<<<<<<<<<<<<<<<<<<<<<<") | |||
err = handleZhiosYibao0rderShareMoneyMallExchange(res.Body) | |||
_ = res.Ack(true) | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleZhiosYibao0rderShareMoneyMallExchange(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.ZhiosOrderShareMoney | |||
fmt.Println(string(msg)) | |||
var tmpString string | |||
err := json.Unmarshal(msg, &tmpString) | |||
if err != nil { | |||
fmt.Println(err.Error()) | |||
return err | |||
} | |||
fmt.Println(tmpString) | |||
err = json.Unmarshal([]byte(tmpString), &canalMsg) | |||
if err != nil { | |||
return err | |||
} | |||
mid := canalMsg.Mid | |||
eg := db.DBs[mid] | |||
if eg == nil { | |||
return nil | |||
} | |||
var ord = make([]model.MallOrd, 0) | |||
eg.In("state", []string{"1", "2", "3"}).And("pay_oid=?", canalMsg.OrdId).Find(&ord) | |||
if len(ord) == 0 { | |||
return nil | |||
} | |||
payMethod := 0 | |||
var total float64 = 0 | |||
var fee float64 = 0 | |||
uniqueOrderNo := "" | |||
payOid := "" | |||
uid := 0 | |||
MerchantNo := "" | |||
for _, v := range ord { | |||
if v.State != 3 { | |||
return nil | |||
} | |||
uid = v.Uid | |||
uniqueOrderNo = v.TransactionId | |||
payOid = v.PayTradeNo | |||
payMethod = v.PayChannel | |||
MerchantNo = v.MerchantNo | |||
fee = utils.StrToFloat64(v.TotalShippingFee) | |||
total += utils.StrToFloat64(v.CostPrice) | |||
} | |||
total += fee | |||
if utils.InArr(utils.IntToStr(payMethod), []string{"21", "22"}) { | |||
yibaoShare(eg, payMethod, total, payOid, uniqueOrderNo, MerchantNo, uid) | |||
} else if utils.InArr(utils.IntToStr(payMethod), []string{"19"}) { | |||
fbShare(eg, canalMsg.Mid, payMethod, total, payOid, uniqueOrderNo, MerchantNo, uid) | |||
} | |||
return nil | |||
} | |||
func fbShare(eg *xorm.Engine, dbName string, payMethod int, total float64, payOid, uniqueOrderNo, MerchantNo string, uid int) { | |||
key := yibao_pay.CommKey(db.Db, true) | |||
zhiyingOnlineBili := utils.StrToFloat64(key["zhiyingOnlineBili"]) - 0.63 | |||
zhiyingUnlineBili := utils.StrToFloat64(key["zhiyingUnlineBili"]) - 0.63 | |||
bili := zhiyingUnlineBili / 100 | |||
if payMethod == 19 { | |||
bili = zhiyingOnlineBili / 100 | |||
} | |||
fee := total * bili | |||
if fee < 0.01 { | |||
fee = 0 | |||
} | |||
fee = float64(int64(fee*100)) / 100 | |||
req3 := map[string]string{} | |||
req3["key"] = utils.SerializeStr(key) | |||
req3["bili"] = utils.Float64ToStr(bili) | |||
total = float64(int64((total-fee)*100)) / 100 | |||
var tmp = model.YibaoShareMoney{ | |||
Oid: utils.OrderUUID(uid), | |||
PayOid: payOid, | |||
StoreMoney: utils.Float64ToStr(total), | |||
ZhiyingMoney: utils.Float64ToStr(fee), | |||
Platform: "mall", | |||
PayMethod: utils.IntToStr(payMethod), | |||
Param: utils.SerializeStr(req3), | |||
Type: "fb", | |||
} | |||
eg.Insert(&tmp) | |||
//4、调用分账接口 | |||
fbPaySet, err := GetFbMdSetting(eg, dbName) | |||
if err != nil { | |||
utils.FilePutContents("GetFbMdSettingErr", "err:"+err.Error()) | |||
logx.Warn(err) | |||
return | |||
} | |||
if fbPaySet.VendorSn == "" { | |||
err = errors.New("没有设置相关付呗支付信息") | |||
utils.FilePutContents("GetFbMdSettingErr", "err:"+err.Error()) | |||
logx.Warn(err) | |||
return | |||
} | |||
var ( | |||
merchantIncomeInfo model.OnlineMerchantIncomeInfo | |||
) | |||
_, err = eg.Where("zyos_merchant_id = ? AND group_create_state = ?", 0, 1).Get(&merchantIncomeInfo) | |||
if merchantIncomeInfo.FbStoreId == 0 || merchantIncomeInfo.FbMerchantId == 0 { | |||
err = errors.New("付呗支付暂未开通") | |||
utils.FilePutContents("GetMerchantIncomeInfoErr", "err:"+err.Error()) | |||
logx.Warn(err) | |||
return | |||
} | |||
parameters := fb_pay.GetRequestParametersByVendorSn(fbPaySet.VendorSn) | |||
parameters.Method = "openapi.agent.account.order.share" | |||
param := make(map[string]interface{}) | |||
param["merchant_id"] = merchantIncomeInfo.FbMerchantId | |||
param["pay_order_sn"] = payOid | |||
param["merchant_order_sn"] = tmp.Oid | |||
param["notify_level"] = "agent" | |||
host := "http://csapi.fnuo123.com.cn" | |||
if cfg.Prd { | |||
host = "http://yadht.zehaochi.com.cn" | |||
} | |||
param["notify_url"] = fmt.Sprintf("%s/api/v1/o2oc/customer/pay/fb/order/share/callback", host) | |||
shareDetail := []map[string]interface{}{ | |||
{ | |||
"account_id": "", | |||
"account_type": "2", | |||
"share_amount": total, | |||
"remark": "商户分账", | |||
}, | |||
} | |||
if fee > 0 { //TODO | |||
var tmp1 = map[string]interface{}{ | |||
"account_id": offical.SysCfgByKey(db.Db, "zhiying_fb_account"), | |||
"account_type": "1", | |||
"share_amount": fee, | |||
"remark": "服务费", | |||
} | |||
shareDetail = append(shareDetail, tmp1) | |||
} | |||
param["share_detail"] = shareDetail | |||
utils.FilePutContents("split_account_param:::", utils.SerializeStr(param)) | |||
fmt.Println(param) | |||
parameters.Nonce = utils.AnyToString(time.Now().Unix()) | |||
parameters.SetBizContent(param) | |||
parameters.SetSign(fbPaySet.AppSecret) | |||
send, err := parameters.Send(cfg.Prd) | |||
if err != nil { | |||
utils.FilePutContents("openapiagentaccountordershare", "err:"+err.Error()) | |||
logx.Warn(err) | |||
return | |||
} | |||
resp := struct { | |||
MerchantId int64 `json:"merchant_id"` | |||
PayOrderSn interface{} `json:"pay_order_sn"` | |||
MerchantPayOrderSn interface{} `json:"merchant_pay_order_sn"` | |||
MerchantOrderSn string `json:"merchant_order_sn"` | |||
OrderNo interface{} `json:"order_no"` | |||
ShareDetail interface{} `json:"share_detail"` | |||
}{} | |||
utils.Unserialize([]byte(send), &resp) | |||
tmp.Msg = send | |||
if orderNoStr, ok := resp.OrderNo.(string); ok { | |||
tmp.Oid = orderNoStr | |||
} else if orderNoStrArry, ok := resp.OrderNo.([]string); ok && len(orderNoStrArry) > 0 { | |||
tmp.Oid = orderNoStrArry[0] | |||
} | |||
tmp.Status = "SUCCESS" | |||
eg.Where("id=?", tmp.Id).Cols("msg,status").Update(&tmp) | |||
return | |||
} | |||
func yibaoShare(eg *xorm.Engine, payMethod int, total float64, payOid, uniqueOrderNo, MerchantNo string, uid int) { | |||
key := yibao_pay.CommKey(db.Db, true) | |||
zhiyingOnlineBili := utils.StrToFloat64(key["zhiyingOnlineBili"]) - utils.StrToFloat64(key["yibaoOnlineBili"]) | |||
zhiyingUnlineBili := utils.StrToFloat64(key["zhiyingUnlineBili"]) - utils.StrToFloat64(key["yibaoUnlineBili"]) | |||
allBili := utils.StrToFloat64(key["zhiyingUnlineBili"]) / 100 | |||
bili := zhiyingUnlineBili / 100 | |||
if payMethod == 22 { | |||
allBili = utils.StrToFloat64(key["zhiyingOnlineBili"]) / 100 | |||
bili = zhiyingOnlineBili / 100 | |||
} | |||
fee := total * bili | |||
if fee < 0.01 { | |||
fee = 0 | |||
} | |||
param := yibao_pay.CommKey(db.Db, true) | |||
divideDetail := []map[string]string{ | |||
{"amount": utils.Float64ToStr(fee), "ledgerNo": key["zhiyingMerchantNo"]}, | |||
} | |||
req1 := map[string]string{ | |||
"merchantNo": MerchantNo, | |||
"orderId": payOid, | |||
"uniqueOrderNo": uniqueOrderNo, | |||
"divideRequestId": utils.OrderUUID(uid), | |||
"divideDetail": utils.SerializeStr(divideDetail), | |||
} | |||
req3 := req1 | |||
req3["key"] = utils.SerializeStr(key) | |||
req3["bili"] = utils.Float64ToStr(bili) | |||
req3["ledgerNo"] = key["zhiyingMerchantNo"] | |||
var tmp = model.YibaoShareMoney{ | |||
Oid: req1["divideRequestId"], | |||
PayOid: payOid, | |||
StoreMoney: utils.Float64ToStr(total - total*allBili), | |||
ZhiyingMoney: utils.Float64ToStr(total * bili), | |||
Platform: "mall", | |||
PayMethod: utils.IntToStr(payMethod), | |||
Param: utils.SerializeStr(req3), | |||
Type: "yibao", | |||
} | |||
eg.Insert(&tmp) | |||
if fee > 0 { | |||
method := "/rest/v1.0/divide/apply" | |||
send, err := yibao_pay.PostFormSend(method, param["appId"], param["isvPriKey"], req1) | |||
if err != nil || send == nil { | |||
if err != nil { | |||
tmp.Msg = err.Error() | |||
} else { | |||
tmp.Msg = "接口错误" | |||
} | |||
eg.Where("id=?", tmp.Id).Cols("msg").Update(&tmp) | |||
fmt.Println(err) | |||
return | |||
} | |||
res := utils.SerializeStr(send.Result) | |||
fmt.Println(res) | |||
if gjson.Get(res, "code").String() != "OPR00000" { | |||
tmp.Msg = res | |||
eg.Where("id=?", tmp.Id).Cols("msg").Update(&tmp) | |||
return | |||
} | |||
if gjson.Get(res, "status").String() != "SUCCESS" { | |||
tmp.Msg = res | |||
tmp.Status = gjson.Get(res, "status").String() | |||
eg.Where("id=?", tmp.Id).Cols("msg,status").Update(&tmp) | |||
return | |||
} | |||
tmp.Msg = res | |||
tmp.Status = gjson.Get(res, "status").String() | |||
eg.Where("id=?", tmp.Id).Cols("msg,status").Update(&tmp) | |||
} | |||
req2 := map[string]string{ | |||
"merchantNo": MerchantNo, | |||
"orderId": payOid, | |||
"uniqueOrderNo": uniqueOrderNo, | |||
"divideRequestId": req1["divideRequestId"] + "1", | |||
} | |||
tmp.EndOid = req2["divideRequestId"] | |||
tmp.EndParam = utils.SerializeStr(req2) | |||
eg.Where("id=?", tmp.Id).Cols("end_param").Update(&tmp) | |||
method2 := "/rest/v1.0/divide/complete" | |||
send2, err2 := yibao_pay.PostFormSend(method2, param["appId"], param["isvPriKey"], req2) | |||
if err2 != nil || send2 == nil { | |||
if err2 != nil { | |||
tmp.EndMsg = err2.Error() | |||
} else { | |||
tmp.EndMsg = "接口错误" | |||
} | |||
eg.Where("id=?", tmp.Id).Cols("end_msg").Update(&tmp) | |||
return | |||
} | |||
res2 := utils.SerializeStr(send2.Result) | |||
fmt.Println(res2) | |||
if gjson.Get(res2, "code").String() != "OPR00000" { | |||
tmp.EndMsg = res2 | |||
eg.Where("id=?", tmp.Id).Cols("end_msg").Update(&tmp) | |||
return | |||
} | |||
tmp.EndMsg = res2 | |||
tmp.EndStatus = gjson.Get(res2, "divideStatus").String() | |||
eg.Where("id=?", tmp.Id).Cols("end_msg,end_status").Update(&tmp) | |||
return | |||
} | |||
func GetFbMdSetting(engine *xorm.Engine, mid string) (*model.FbPaySet, error) { | |||
var ( | |||
setting model.FbPaySet | |||
) | |||
get := setting.GetByRedis(mid) | |||
if get { | |||
return &setting, nil | |||
} else { | |||
err := setting.Get(engine) | |||
if err != nil { | |||
return nil, err | |||
} | |||
return &setting, nil | |||
} | |||
} |
@@ -0,0 +1,113 @@ | |||
package consume | |||
import ( | |||
"applet/app/db" | |||
"applet/app/svc" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
md3 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/streadway/amqp" | |||
) | |||
// | |||
func ZhiosNewVideoRewardExchange(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(20) | |||
delivery := ch.Consume(queue.Name, false) | |||
var res amqp.Delivery | |||
var ok bool | |||
for { | |||
res, ok = <-delivery | |||
if ok == true { | |||
fmt.Println(">>>>>>>>>>>>>>>>ZhiosNewVideoRewardExchange<<<<<<<<<<<<<<<<<<<<<<<<<") | |||
err = handleZhiosNewVideoRewardExchange(res.Body) | |||
if err != nil { | |||
fmt.Println(err) | |||
fmt.Println("ZhiosOwnNewVideoRewardExchange_ERR:::::", err.Error()) | |||
_ = res.Reject(false) | |||
//TODO::重新推回队列末尾,避免造成队列堵塞 | |||
var msg *md.ZhiosTaskReward | |||
json.Unmarshal(res.Body, &msg) | |||
ch.Publish(queue.ExchangeName, msg, queue.RoutKey) | |||
//TODO::推一份到异常备份队列 | |||
ch.Publish(queue.ExchangeName, msg, "new_video_reward_abnormal") | |||
} else { | |||
_ = res.Ack(true) | |||
} | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleZhiosNewVideoRewardExchange(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.ZhiosTaskReward | |||
fmt.Println(string(msg)) | |||
var tmpString string | |||
err := json.Unmarshal(msg, &tmpString) | |||
if err != nil { | |||
fmt.Println(err.Error()) | |||
return err | |||
} | |||
fmt.Println(tmpString) | |||
err = json.Unmarshal([]byte(tmpString), &canalMsg) | |||
if err != nil { | |||
return err | |||
} | |||
mid := canalMsg.Mid | |||
eg := db.DBs[mid] | |||
if eg == nil { | |||
return nil | |||
} | |||
amount := canalMsg.Money | |||
//奖励 | |||
oid := canalMsg.Oid | |||
uid := canalMsg.Uid | |||
if canalMsg.IsTeam != "1" { | |||
sess := eg.NewSession() | |||
defer sess.Close() | |||
sess.Begin() | |||
_, err = svc.ExchangeUserVirFinValidAndInterFlowWithSession(sess, | |||
utils.StrToFloat64(amount), "看视频奖励", "0", 1, 170, utils.StrToInt(uid), utils.StrToInt(canalMsg.CoinId), 0, utils.StrToInt64(oid), "", 0, 0) | |||
if err != nil { | |||
sess.Rollback() | |||
return err | |||
} | |||
sess.Commit() | |||
} | |||
if canalMsg.Mode != "" { | |||
//计算佣金 | |||
var CommissionParam md3.CommissionFirstParam | |||
CommissionParam.CommissionParam.Commission = canalMsg.Reward | |||
CommissionParam.Uid = uid | |||
CommissionParam.Provider = canalMsg.PlanType | |||
title := canalMsg.Title | |||
var mapData = map[string]string{ | |||
"coin_id_type": canalMsg.CoinIdType, | |||
"mode": canalMsg.Mode, | |||
"title": title, | |||
"device_model": canalMsg.DeviceModel, | |||
"reward_type": canalMsg.RewardType, | |||
} | |||
svc.GetLvUser(eg, CommissionParam, utils.StrToInt64(canalMsg.Oid), mid, mapData) | |||
} | |||
return nil | |||
} |
@@ -0,0 +1,95 @@ | |||
package consume | |||
import ( | |||
"applet/app/db" | |||
"applet/app/svc" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/streadway/amqp" | |||
) | |||
// | |||
func ZhiosOwnNewVideoRewardExchange(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(">>>>>>>>>>>>>>>>ZhiosOwnNewVideoRewardExchange<<<<<<<<<<<<<<<<<<<<<<<<<") | |||
err = handleZhiosOwnNewVideoRewardExchange(res.Body) | |||
if err != nil { | |||
fmt.Println(err) | |||
fmt.Println("ZhiosOwnNewVideoRewardExchange_ERR:::::", err.Error()) | |||
_ = res.Reject(false) | |||
//TODO::重新推回队列末尾,避免造成队列堵塞 | |||
var msg *md.ZhiosTaskReward | |||
json.Unmarshal(res.Body, &msg) | |||
ch.Publish(queue.ExchangeName, msg, queue.RoutKey) | |||
//TODO::推一份到异常备份队列 | |||
ch.Publish(queue.ExchangeName, msg, "own_new_video_reward_abnormal") | |||
} else { | |||
_ = res.Ack(true) | |||
} | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleZhiosOwnNewVideoRewardExchange(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.ZhiosTaskReward | |||
fmt.Println(string(msg)) | |||
var tmpString string | |||
err := json.Unmarshal(msg, &tmpString) | |||
if err != nil { | |||
fmt.Println(err.Error()) | |||
return err | |||
} | |||
fmt.Println(tmpString) | |||
err = json.Unmarshal([]byte(tmpString), &canalMsg) | |||
if err != nil { | |||
return err | |||
} | |||
mid := canalMsg.Mid | |||
eg := db.DBs[mid] | |||
if eg == nil { | |||
return nil | |||
} | |||
amount := canalMsg.Money | |||
//奖励 | |||
oid := canalMsg.Oid | |||
uid := canalMsg.Uid | |||
sess := eg.NewSession() | |||
defer sess.Close() | |||
sess.Begin() | |||
_, err = svc.ExchangeUserVirFinValidAndInterFlowWithSession(sess, | |||
utils.StrToFloat64(amount), "看视频奖励", "0", 1, 170, utils.StrToInt(uid), utils.StrToInt(canalMsg.CoinId), 0, utils.StrToInt64(oid), "", 0, 0) | |||
if err != nil { | |||
sess.Rollback() | |||
return err | |||
} | |||
sess.Commit() | |||
return nil | |||
} |
@@ -0,0 +1,100 @@ | |||
package consume | |||
import ( | |||
"applet/app/db" | |||
"applet/app/svc" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
md3 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" | |||
svc2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/svc" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/streadway/amqp" | |||
) | |||
// | |||
func ZhiosRelateRewardExchange(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 = handleZhiosRelateRewardExchange(res.Body) | |||
//_ = res.Reject(false) | |||
fmt.Println(err) | |||
_ = res.Ack(true) | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleZhiosRelateRewardExchange(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.ZhiosTaskReward | |||
fmt.Println(string(msg)) | |||
var tmpString string | |||
err := json.Unmarshal(msg, &tmpString) | |||
if err != nil { | |||
fmt.Println(err.Error()) | |||
return err | |||
} | |||
fmt.Println(tmpString) | |||
err = json.Unmarshal([]byte(tmpString), &canalMsg) | |||
if err != nil { | |||
return err | |||
} | |||
mid := canalMsg.Mid | |||
eg := db.DBs[mid] | |||
if eg == nil { | |||
return nil | |||
} | |||
uid := canalMsg.Uid | |||
//计算佣金 | |||
var CommissionParam md3.CommissionFirstParam | |||
CommissionParam.CommissionParam.Commission = canalMsg.Reward | |||
CommissionParam.CommissionParam.GoodsPrice = canalMsg.Money | |||
CommissionParam.Uid = uid | |||
CommissionParam.Provider = canalMsg.Provider | |||
plans, commission, virtualCoinMoneyRate := svc2.GetAllPlan(eg, mid) | |||
cfgs, err := svc2.GetPlanCfg(eg, canalMsg.Provider, mid, plans, commission, virtualCoinMoneyRate, &CommissionParam.CommissionParam) | |||
if err != nil || cfgs == nil { | |||
return nil | |||
} | |||
title := canalMsg.Title | |||
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, | |||
"pvd_oid": canalMsg.PvdOid, | |||
} | |||
svc.CommGetLvUser(eg, CommissionParam, utils.StrToInt64(canalMsg.Oid), mid, mapData) | |||
return nil | |||
} |
@@ -0,0 +1,89 @@ | |||
package consume | |||
import ( | |||
"applet/app/db" | |||
"applet/app/svc" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
md3 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/streadway/amqp" | |||
) | |||
// | |||
func ZhiosTaskRewardExchange(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 = handleZhiosTaskRewardExchange(res.Body) | |||
//_ = res.Reject(false) | |||
fmt.Println(err) | |||
_ = res.Ack(true) | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleZhiosTaskRewardExchange(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.ZhiosTaskReward | |||
fmt.Println(string(msg)) | |||
var tmpString string | |||
err := json.Unmarshal(msg, &tmpString) | |||
if err != nil { | |||
fmt.Println(err.Error()) | |||
return err | |||
} | |||
fmt.Println(tmpString) | |||
err = json.Unmarshal([]byte(tmpString), &canalMsg) | |||
if err != nil { | |||
return err | |||
} | |||
mid := canalMsg.Mid | |||
eg := db.DBs[mid] | |||
if eg == nil { | |||
return nil | |||
} | |||
uid := canalMsg.Uid | |||
//计算佣金 | |||
var CommissionParam md3.CommissionFirstParam | |||
CommissionParam.CommissionParam.Commission = canalMsg.Reward | |||
CommissionParam.Uid = uid | |||
CommissionParam.Provider = "task_center" | |||
if canalMsg.RewardType == "2" { | |||
CommissionParam.Provider = "task_reward_new" | |||
} | |||
title := canalMsg.Title | |||
var mapData = map[string]string{ | |||
"coin_id_type": canalMsg.CoinIdType, | |||
"mode": canalMsg.Mode, | |||
"title": title, | |||
"device_model": canalMsg.DeviceModel, | |||
"reward_type": canalMsg.RewardType, | |||
} | |||
svc.GetLvUser(eg, CommissionParam, utils.StrToInt64(canalMsg.Oid), mid, mapData) | |||
return nil | |||
} |
@@ -0,0 +1,86 @@ | |||
package consume | |||
import ( | |||
"applet/app/db" | |||
"applet/app/svc" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
md3 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/streadway/amqp" | |||
) | |||
// | |||
func ZhiosTaskVideoRewardExchange(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 = handleZhiosVideoTaskVideoRewardExchange(res.Body) | |||
//_ = res.Reject(false) | |||
fmt.Println(err) | |||
_ = res.Ack(true) | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleZhiosVideoTaskVideoRewardExchange(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.ZhiosTaskReward | |||
fmt.Println(string(msg)) | |||
var tmpString string | |||
err := json.Unmarshal(msg, &tmpString) | |||
if err != nil { | |||
fmt.Println(err.Error()) | |||
return err | |||
} | |||
fmt.Println(tmpString) | |||
err = json.Unmarshal([]byte(tmpString), &canalMsg) | |||
if err != nil { | |||
return err | |||
} | |||
mid := canalMsg.Mid | |||
eg := db.DBs[mid] | |||
if eg == nil { | |||
return nil | |||
} | |||
uid := canalMsg.Uid | |||
//计算佣金 | |||
var CommissionParam md3.CommissionFirstParam | |||
CommissionParam.CommissionParam.Commission = canalMsg.Reward | |||
CommissionParam.Uid = uid | |||
CommissionParam.Provider = canalMsg.PlanType | |||
title := canalMsg.Title | |||
var mapData = map[string]string{ | |||
"coin_id_type": canalMsg.CoinIdType, | |||
"mode": canalMsg.Mode, | |||
"title": title, | |||
"device_model": canalMsg.DeviceModel, | |||
"reward_type": canalMsg.RewardType, | |||
} | |||
svc.GetLvUser(eg, CommissionParam, utils.StrToInt64(canalMsg.Oid), mid, mapData) | |||
return nil | |||
} |
@@ -0,0 +1,142 @@ | |||
package consume | |||
import ( | |||
"applet/app/db" | |||
"applet/app/e" | |||
"applet/app/svc" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
db2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/streadway/amqp" | |||
"xorm.io/xorm" | |||
) | |||
// | |||
func CancalUserIntegralExchange(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 = handleCancalUserIntegralExchange(res.Body) | |||
//_ = res.Reject(false) | |||
fmt.Println(err) | |||
_ = res.Ack(true) | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleCancalUserIntegralExchange(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.ZhiosAcquisition | |||
fmt.Println(string(msg)) | |||
var tmpString string | |||
err := json.Unmarshal(msg, &tmpString) | |||
if err != nil { | |||
fmt.Println(err.Error()) | |||
return err | |||
} | |||
fmt.Println(tmpString) | |||
err = json.Unmarshal([]byte(tmpString), &canalMsg) | |||
if err != nil { | |||
return err | |||
} | |||
mid := canalMsg.Mid | |||
eg := db.DBs[mid] | |||
if eg == nil { | |||
return nil | |||
} | |||
uid := canalMsg.Uid | |||
base, _ := db.TaskCenterBase(eg) | |||
if base == nil { | |||
return nil | |||
} | |||
sess := eg.NewSession() | |||
defer sess.Close() | |||
sess.Begin() | |||
amount, _ := db.UserVirtualAmountFindById(sess, utils.StrToInt(uid), base.CoinId) | |||
if amount != nil && utils.StrToFloat64(amount.Amount) > 0 { | |||
err := CoinExchange(eg, sess, utils.StrToInt(uid), utils.IntToStr(base.CoinId), "cny", amount.Amount, mid) | |||
if err != nil { | |||
sess.Rollback() | |||
return nil | |||
} | |||
} | |||
sess.Commit() | |||
return nil | |||
} | |||
func CoinExchange(eg *xorm.Engine, sess *xorm.Session, uid int, coinId, coinIdTo, amount, masterId string) error { | |||
//虚拟币转换 | |||
//获取目前可以兑换的虚拟币 | |||
coinMapInUse, err := db.VirtualCoinMapInUseSess(sess, masterId, "") | |||
if err != nil { | |||
return nil | |||
} | |||
fromCoin, ok := coinMapInUse[coinId] | |||
toCoin, ok2 := coinMapInUse[coinIdTo] | |||
//判断兑换的虚拟币是否可以兑换 | |||
if !ok || (!ok2 && coinIdTo != "cny") { | |||
return nil | |||
} | |||
//被兑换虚拟币金额比例,兑换虚拟币金额比例,手续费比例 | |||
var ( | |||
fromRate, toRate float64 | |||
) | |||
//获取用户两个虚拟币的余额数据 | |||
fromWallet, err := db2.GetUserVirtualWalletWithSession(sess, uid, utils.StrToInt(coinId)) | |||
if err != nil { | |||
return nil | |||
} | |||
amount = fromWallet.Amount | |||
fromRate = utils.AnyToFloat64(fromCoin.ExchangeRatio) | |||
toRate = utils.AnyToFloat64(toCoin.ExchangeRatio) | |||
if coinIdTo == "cny" { | |||
toRate = 1 | |||
} | |||
//兑换比例 | |||
rate := fromRate / toRate | |||
//计算兑换的总值 | |||
toValue := utils.AnyToFloat64(amount) / rate | |||
toAmount := toValue | |||
//先扣 | |||
title := coinMapInUse[coinId].Name + "兑换" + coinMapInUse[coinIdTo].Name | |||
_, err = svc.ExchangeUserVirFinValidAndInterFlowWithSession(sess, | |||
utils.StrToFloat64(amount), title, "0", 2, 5, uid, utils.StrToInt(coinId), utils.StrToInt(coinIdTo), -1, "", 0, 0) | |||
if err != nil { | |||
return e.NewErrCode(e.ERR_BAD_REQUEST) | |||
} | |||
//再给 | |||
err = svc.UpdateUserFinValidAndInterFlowWithSession(sess, | |||
utils.Float64ToStr(toAmount), title, "money_exchange", 0, 35, uid, 0, utils.StrToInt64(coinId), 0) | |||
if err != nil { | |||
return err | |||
} | |||
return nil | |||
} |
@@ -5,10 +5,10 @@ go 1.18 | |||
require ( | |||
code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git v1.1.2-0.20240222023917-c31b53f7e8cb | |||
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.20240315113731-a22c0fb96812 | |||
code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5 | |||
code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git v1.9.10-0.20240722064401-49d2884770db | |||
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.20240126015516-38ca248db2fd | |||
code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20241108004357-6b70a3b89bf2 | |||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 | |||
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 | |||
github.com/boombuler/barcode v1.0.1 | |||
@@ -17,15 +17,15 @@ require ( | |||
github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5 | |||
github.com/forgoer/openssl v1.2.1 | |||
github.com/gin-contrib/sessions v0.0.3 | |||
github.com/gin-gonic/gin v1.8.0 | |||
github.com/go-playground/locales v0.14.0 | |||
github.com/go-playground/universal-translator v0.18.0 | |||
github.com/go-playground/validator/v10 v10.10.0 | |||
github.com/gin-gonic/gin v1.9.1 | |||
github.com/go-playground/locales v0.14.1 | |||
github.com/go-playground/universal-translator v0.18.1 | |||
github.com/go-playground/validator/v10 v10.14.0 | |||
github.com/go-redis/redis v6.15.9+incompatible | |||
github.com/go-sql-driver/mysql v1.6.0 | |||
github.com/go-sql-driver/mysql v1.8.1 | |||
github.com/gomodule/redigo v2.0.0+incompatible | |||
github.com/iGoogle-ink/gopay v1.5.36 | |||
github.com/jinzhu/copier v0.3.5 | |||
github.com/jinzhu/copier v0.4.0 | |||
github.com/json-iterator/go v1.1.12 | |||
github.com/makiuchi-d/gozxing v0.1.1 | |||
github.com/mingrammer/commonregex v1.0.1 | |||
@@ -34,59 +34,70 @@ require ( | |||
github.com/sony/sonyflake v1.0.0 | |||
github.com/streadway/amqp v1.0.0 | |||
github.com/swaggo/swag v1.7.0 | |||
github.com/syyongx/php2go v0.9.7 | |||
github.com/syyongx/php2go v0.9.8 | |||
github.com/tidwall/gjson v1.14.1 | |||
go.uber.org/zap v1.16.0 | |||
google.golang.org/grpc v1.32.0 | |||
google.golang.org/protobuf v1.28.0 | |||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 | |||
google.golang.org/protobuf v1.30.0 | |||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 | |||
gopkg.in/yaml.v2 v2.4.0 | |||
xorm.io/xorm v1.3.2 | |||
) | |||
require ( | |||
filippo.io/edwards25519 v1.1.0 // indirect | |||
github.com/KyleBanks/depth v1.2.1 // indirect | |||
github.com/PuerkitoBio/purell v1.1.1 // indirect | |||
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect | |||
github.com/bitly/go-simplejson v0.5.0 // indirect | |||
github.com/bytedance/sonic v1.9.1 // indirect | |||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect | |||
github.com/gabriel-vasile/mimetype v1.4.2 // indirect | |||
github.com/gin-contrib/sse v0.1.0 // indirect | |||
github.com/go-openapi/jsonpointer v0.19.5 // indirect | |||
github.com/go-openapi/jsonreference v0.19.5 // indirect | |||
github.com/go-openapi/spec v0.20.3 // indirect | |||
github.com/go-openapi/swag v0.19.15 // indirect | |||
github.com/goccy/go-json v0.9.7 // indirect | |||
github.com/goccy/go-json v0.10.2 // indirect | |||
github.com/golang/protobuf v1.5.3 // indirect | |||
github.com/golang/snappy v0.0.4 // indirect | |||
github.com/gorilla/context v1.1.1 // indirect | |||
github.com/gorilla/securecookie v1.1.1 // indirect | |||
github.com/gorilla/sessions v1.2.1 // indirect | |||
github.com/josharian/intern v1.0.0 // indirect | |||
github.com/leodido/go-urn v1.2.1 // indirect | |||
github.com/klauspost/cpuid/v2 v2.2.4 // indirect | |||
github.com/leodido/go-urn v1.2.4 // indirect | |||
github.com/mailru/easyjson v0.7.7 // indirect | |||
github.com/mattn/go-isatty v0.0.14 // indirect | |||
github.com/mattn/go-isatty v0.0.19 // indirect | |||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect | |||
github.com/modern-go/reflect2 v1.0.2 // indirect | |||
github.com/mvdan/xurls v1.1.0 // indirect | |||
github.com/nilorg/sdk v0.0.0-20221104025912-4b6ccb7004d8 // indirect | |||
github.com/olivere/elastic/v7 v7.0.32 // indirect | |||
github.com/pelletier/go-toml/v2 v2.0.1 // indirect | |||
github.com/pelletier/go-toml/v2 v2.0.8 // indirect | |||
github.com/pkg/errors v0.9.1 // indirect | |||
github.com/rakyll/statik v0.1.7 // indirect | |||
github.com/satori/go.uuid v1.2.0 // indirect | |||
github.com/sirupsen/logrus v1.9.3 // indirect | |||
github.com/syndtr/goleveldb v1.0.0 // indirect | |||
github.com/tidwall/match v1.1.1 // indirect | |||
github.com/tidwall/pretty v1.2.0 // indirect | |||
github.com/ugorji/go/codec v1.2.7 // indirect | |||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect | |||
github.com/ugorji/go/codec v1.2.11 // indirect | |||
github.com/yop-platform/yop-go-sdk v0.0.0-20241029152043-ff36040e534a // indirect | |||
go.uber.org/atomic v1.7.0 // indirect | |||
go.uber.org/multierr v1.6.0 // indirect | |||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97 // indirect | |||
golang.org/x/arch v0.3.0 // indirect | |||
golang.org/x/crypto v0.9.0 // indirect | |||
golang.org/x/lint v0.0.0-20200302205851-738671d3881b // indirect | |||
golang.org/x/net v0.0.0-20221004154528-8021a29435af // indirect | |||
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect | |||
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10 // indirect | |||
golang.org/x/text v0.3.7 // indirect | |||
golang.org/x/tools v0.1.0 // indirect | |||
golang.org/x/net v0.10.0 // indirect | |||
golang.org/x/sync v0.1.0 // indirect | |||
golang.org/x/sys v0.8.0 // indirect | |||
golang.org/x/text v0.9.0 // indirect | |||
golang.org/x/tools v0.6.0 // indirect | |||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect | |||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 // indirect | |||
gopkg.in/yaml.v3 v3.0.1 // indirect | |||
honnef.co/go/tools v0.0.1-2020.1.4 // indirect | |||
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 // indirect | |||
) |