@@ -318,3 +318,11 @@ func UserDelete(Db *xorm.Engine, uid interface{}) (int64, error) { | |||
func UserDeleteWithSess(sess *xorm.Session, uid interface{}) (int64, error) { | |||
return sess.Where("uid = ?", uid).Delete(model.User{}) | |||
} | |||
func UserProfileFindByID(Db *xorm.Engine, id interface{}) (*model.UserProfile, error) { | |||
var m model.UserProfile | |||
if has, err := Db.Where("uid = ?", id).Get(&m); err != nil || has == false { | |||
return nil, logx.Warn(err) | |||
} | |||
return &m, nil | |||
} |
@@ -0,0 +1,17 @@ | |||
package db | |||
import ( | |||
"applet/app/db/model" | |||
"applet/app/utils/logx" | |||
"xorm.io/xorm" | |||
) | |||
// UserLevlEgAll is 获取所有开启等级并且升序返回 | |||
func UserLevlEgAll(Db *xorm.Engine) ([]*model.UserLevel, error) { | |||
var m []*model.UserLevel | |||
err := Db.Where("is_use = ?", 1).Asc("level_weight").Find(&m) | |||
if err != nil { | |||
return nil, logx.Warn(err) | |||
} | |||
return m, nil | |||
} |
@@ -0,0 +1,21 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type UserLevel struct { | |||
Id int `json:"id" xorm:"not null pk autoincr comment('等级id') INT(11)"` | |||
BenefitIds string `json:"benefit_ids" xorm:"comment('该等级拥有的权益id【json】') TEXT"` | |||
LevelName string `json:"level_name" xorm:"not null default '' comment('等级名称') VARCHAR(255)"` | |||
LevelWeight int `json:"level_weight" xorm:"not null default 0 comment('等级权重') INT(11)"` | |||
LevelUpdateCondition int `json:"level_update_condition" xorm:"not null default 2 comment('2是条件升级,1是无条件升级') TINYINT(1)"` | |||
AutoAudit int `json:"auto_audit" xorm:"not null default 0 comment('(自动审核)0关闭,1开启') TINYINT(1)"` | |||
AutoUpdate int `json:"auto_update" xorm:"not null default 0 comment('(自动升级)0关闭,1开启') TINYINT(1)"` | |||
LevelDate int `json:"level_date" xorm:"default 0 comment('会员有效期(0永久有效,单位月)') INT(11)"` | |||
IsUse int `json:"is_use" xorm:"not null default 1 comment('是否开启(0否,1是)') TINYINT(1)"` | |||
ChoosableNum int `json:"choosable_num" xorm:"default 0 comment('可选任务数量(当is_must_task为0时生效)') INT(6)"` | |||
Memo string `json:"memo" xorm:"default '' comment('备注') VARCHAR(255)"` | |||
CssSet string `json:"css_set" xorm:"TEXT"` | |||
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP TIMESTAMP"` | |||
} |
@@ -0,0 +1,92 @@ | |||
package model | |||
import ( | |||
"time" | |||
) | |||
type UserProfile struct { | |||
Uid int `json:"uid" xorm:"not null pk comment('关联userID') INT(20)"` | |||
ArkidUid int `json:"arkid_uid" xorm:"not null default 0 comment('Arkid 用户ID') INT(20)"` | |||
ParentUid int `json:"parent_uid" xorm:"not null default 0 comment('上级ID') INT(20)"` | |||
ArkidToken string `json:"arkid_token" xorm:"not null default '' comment('token') VARCHAR(2000)"` | |||
AvatarUrl string `json:"avatar_url" xorm:"not null default '' comment('头像URL') VARCHAR(2000)"` | |||
CustomInviteCode string `json:"custom_invite_code" xorm:"not null default '' comment('邀请码(自定义)') VARCHAR(16)"` | |||
InviteCode string `json:"invite_code" xorm:"not null default '' comment('邀请码(系统)') VARCHAR(16)"` | |||
Gender int `json:"gender" xorm:"not null default 2 comment('性别0女,1男,2未知') TINYINT(1)"` | |||
Birthday int `json:"birthday" xorm:"not null default 0 comment('出生日期') INT(10)"` | |||
AccWxId string `json:"acc_wx_id" xorm:"not null default '' comment('账户_微信id') VARCHAR(50)"` | |||
AccWxOpenid string `json:"acc_wx_openid" xorm:"not null default '' comment('账户_微信openid') VARCHAR(80)"` | |||
AccTaobaoNickname string `json:"acc_taobao_nickname" xorm:"not null default '' comment('淘宝昵称') VARCHAR(50)"` | |||
AccTaobaoAuthTime int64 `json:"acc_taobao_auth_time" xorm:"not null default 0 comment('淘宝授权备案时间') BIGINT(11)"` | |||
AccTaobaoShareId int64 `json:"acc_taobao_share_id" xorm:"not null default 0 comment('淘宝分享relationId,') index BIGINT(12)"` | |||
AccTaobaoSelfId int64 `json:"acc_taobao_self_id" xorm:"not null default 0 comment('淘宝自购specialId') index BIGINT(12)"` | |||
AccJdSelfId string `json:"acc_jd_self_id" xorm:"not null default '' comment('京东自购ID') index VARCHAR(50)"` | |||
AccJdShareId string `json:"acc_jd_share_id" xorm:"not null default '' comment('京东分享ID') index VARCHAR(50)"` | |||
AccJdFreeId string `json:"acc_jd_free_id" xorm:"not null default '' comment('京东新人免单ID') VARCHAR(50)"` | |||
AccSuningSelfId string `json:"acc_suning_self_id" xorm:"not null default '' comment('苏宁自购ID') index VARCHAR(50)"` | |||
AccSuningShareId string `json:"acc_suning_share_id" xorm:"not null default '' comment('苏宁分享ID') index VARCHAR(50)"` | |||
AccSuningFreeId string `json:"acc_suning_free_id" xorm:"not null default '' comment('苏宁新人免单ID') VARCHAR(50)"` | |||
AccPddSelfId string `json:"acc_pdd_self_id" xorm:"not null default '' comment('拼多多自购ID') index VARCHAR(50)"` | |||
AccPddShareId string `json:"acc_pdd_share_id" xorm:"not null default '' comment('拼多多分享ID') index VARCHAR(50)"` | |||
AccPddFreeId string `json:"acc_pdd_free_id" xorm:"not null default '' comment('拼多多新人免单ID') VARCHAR(50)"` | |||
AccPddBind int `json:"acc_pdd_bind" xorm:"not null default 0 comment('拼多多是否授权绑定') TINYINT(1)"` | |||
AccVipSelfId string `json:"acc_vip_self_id" xorm:"not null default '' comment('唯品会自购ID') index VARCHAR(50)"` | |||
AccVipShareId string `json:"acc_vip_share_id" xorm:"not null default '' comment('唯品会分享ID') index VARCHAR(50)"` | |||
AccVipFreeId string `json:"acc_vip_free_id" xorm:"not null default '' comment('唯品会新人免单ID') VARCHAR(50)"` | |||
AccKaolaSelfId string `json:"acc_kaola_self_id" xorm:"not null default '' comment('考拉自购ID') index VARCHAR(50)"` | |||
AccKaolaShareId string `json:"acc_kaola_share_id" xorm:"not null default '' comment('考拉分享ID') index VARCHAR(50)"` | |||
AccKaolaFreeId string `json:"acc_kaola_free_id" xorm:"not null default '' comment('考拉新人免单ID') VARCHAR(50)"` | |||
AccDuomaiShareId int64 `json:"acc_duomai_share_id" xorm:"not null pk default 0 comment('多麦联盟分享ID') BIGINT(12)"` | |||
AccAlipay string `json:"acc_alipay" xorm:"not null default '' comment('支付宝账号') VARCHAR(50)"` | |||
AccAlipayRealName string `json:"acc_alipay_real_name" xorm:"not null default '' comment('支付宝账号真实姓名') VARCHAR(50)"` | |||
CertTime int `json:"cert_time" xorm:"not null default 0 comment('认证时间') INT(10)"` | |||
CertName string `json:"cert_name" xorm:"not null default '' comment('证件上名字,也是真实姓名') VARCHAR(50)"` | |||
CertNum string `json:"cert_num" xorm:"not null default '' comment('证件号码') VARCHAR(50)"` | |||
CertState int `json:"cert_state" xorm:"not null default 0 comment('认证状态(0为未认证,1为认证中,2为已认证,3为认证失败)') TINYINT(1)"` | |||
FinCommission string `json:"fin_commission" xorm:"not null default 0.0000 comment('累计佣金') DECIMAL(10,4)"` | |||
FinValid string `json:"fin_valid" xorm:"not null default 0.0000 comment('可用余额,fin=>finance财务') DECIMAL(10,4)"` | |||
FinInvalid string `json:"fin_invalid" xorm:"not null default 0.0000 comment('不可用余额,冻结余额') DECIMAL(10,4)"` | |||
FinSelfOrderCount int `json:"fin_self_order_count" xorm:"not null default 0 comment('自购订单数,包括未完成') INT(11)"` | |||
FinSelfOrderCountDone int `json:"fin_self_order_count_done" xorm:"not null default 0 comment('自购已完成订单') INT(11)"` | |||
FinSelfRebate float32 `json:"fin_self_rebate" xorm:"not null default 0.000000 comment('累积自购获得返利金额') FLOAT(14,6)"` | |||
FinTotal float32 `json:"fin_total" xorm:"not null default 0.000000 comment('累计总收益') FLOAT(14,6)"` | |||
Lat float32 `json:"lat" xorm:"not null default 0.000000 comment('纬度') FLOAT(15,6)"` | |||
Lng float32 `json:"lng" xorm:"not null default 0.000000 comment('经度') FLOAT(15,6)"` | |||
Memo string `json:"memo" xorm:"not null default '' comment('用户简述备注') VARCHAR(2048)"` | |||
Qq string `json:"qq" xorm:"not null default '' comment('') VARCHAR(255)"` | |||
IsNew int `json:"is_new" xorm:"not null default 1 comment('是否是新用户') TINYINT(1)"` | |||
IsVerify int `json:"is_verify" xorm:"not null default 0 comment('是否有效会员') TINYINT(1)"` | |||
IsOrdered int `json:"is_ordered" xorm:"not null default 0 comment('是否已完成首单(0否,1是)') TINYINT(1)"` | |||
FromWay string `json:"from_way" xorm:"not null default '' comment('注册来源: | |||
no_captcha_phone:免验证码手机号注册; | |||
manual_phone:手动手机验证码注册; | |||
wx:微信授权; | |||
wx_mp:小程序授权; | |||
wx_pub:公众号授权; | |||
wx_bind_phone:微信注册绑定手机号; | |||
admin:管理员添加;taobao_bind_phone:淘宝注册绑定手机号,apple_bind_phone:苹果注册绑定手机号') VARCHAR(16)"` | |||
HidOrder int `json:"hid_order" xorm:"not null default 0 comment('隐藏订单') TINYINT(3)"` | |||
HidContact int `json:"hid_contact" xorm:"not null default 0 comment('隐藏联系方式') TINYINT(4)"` | |||
NewMsgNotice int `json:"new_msg_notice" xorm:"not null default 1 comment('新消息通知') TINYINT(1)"` | |||
WxAccount string `json:"wx_account" xorm:"not null default '' comment('微信号') VARCHAR(100)"` | |||
WxQrcode string `json:"wx_qrcode" xorm:"not null default '' comment('微信二维码') VARCHAR(100)"` | |||
ThirdPartyTaobaoOid string `json:"third_party_taobao_oid" xorm:"not null default '' comment('淘宝第三方登录openID') VARCHAR(100)"` | |||
ThirdPartyTaobaoSid string `json:"third_party_taobao_sid" xorm:"not null default '' comment('淘宝第三方登录sID') VARCHAR(255)"` | |||
ThirdPartyTaobaoAcctoken string `json:"third_party_taobao_acctoken" xorm:"not null default '' comment('淘宝第三方登录topaccesstoken') VARCHAR(100)"` | |||
ThirdPartyTaobaoAuthcode string `json:"third_party_taobao_authcode" xorm:"not null default '' comment('淘宝第三方登录topAuthCode') VARCHAR(100)"` | |||
ThirdPartyAppleToken string `json:"third_party_apple_token" xorm:"not null default '' comment('苹果第三方登录token') VARCHAR(1024)"` | |||
ThirdPartyQqAccessToken string `json:"third_party_qq_access_token" xorm:"not null default '' comment('QQ第三方登录access_token') VARCHAR(255)"` | |||
ThirdPartyQqExpiresIn string `json:"third_party_qq_expires_in" xorm:"not null default '' comment('QQ第三方登录expires_in(剩余时长)') VARCHAR(255)"` | |||
ThirdPartyQqOpenid string `json:"third_party_qq_openid" xorm:"not null default '' comment('QQ第三方登陆openid(不变,用于认证)') VARCHAR(255)"` | |||
ThirdPartyQqUnionid string `json:"third_party_qq_unionid" xorm:"not null default '' comment('QQ第三方登陆unionid') VARCHAR(255)"` | |||
ThirdPartyWechatExpiresIn string `json:"third_party_wechat_expires_in" xorm:"not null default '' comment('微信第三方登录expires_in(剩余时长)') VARCHAR(255)"` | |||
ThirdPartyWechatOpenid string `json:"third_party_wechat_openid" xorm:"not null default '' comment('微信第三方登陆openid(不变,用于认证)') VARCHAR(255)"` | |||
ThirdPartyWechatUnionid string `json:"third_party_wechat_unionid" xorm:"not null default '' comment('微信第三方登陆unionid') VARCHAR(255)"` | |||
ThirdPartyWechatMiniOpenid string `json:"third_party_wechat_mini_openid" xorm:"not null default '' comment('微信小程序登录open_id') VARCHAR(255)"` | |||
ThirdPartyWechatH5Openid string `json:"third_party_wechat_h5_openid" xorm:"not null default '' comment('微信H5登录open_id') VARCHAR(255)"` | |||
FreeRemainTime int `json:"free_remain_time" xorm:"not null default 0 comment('免单剩余次数') INT(11)"` | |||
FreeCumulativeTime int `json:"free_cumulative_time" xorm:"not null default 0 comment('免单累计次数') INT(11)"` | |||
IsDelete int `json:"is_delete" xorm:"not null default 0 comment('是否已删除') TINYINT(1)"` | |||
UpdateAt time.Time `json:"update_at" xorm:"updated not null default CURRENT_TIMESTAMP comment('更新时间') TIMESTAMP"` | |||
IsSet int `json:"is_set" xorm:"not null default 0 comment('用于一个客户生成关系链匹配的') INT(1)"` | |||
} |
@@ -0,0 +1,120 @@ | |||
package consume | |||
import ( | |||
"applet/app/db" | |||
model2 "applet/app/db/model" | |||
"applet/app/utils" | |||
"applet/app/utils/logx" | |||
"applet/consume/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/db/model" | |||
zyos_go_condition_hdl "code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/hdl" | |||
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git/md" | |||
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" | |||
"encoding/json" | |||
"errors" | |||
"fmt" | |||
"github.com/jinzhu/copier" | |||
"github.com/streadway/amqp" | |||
"strings" | |||
"xorm.io/xorm" | |||
) | |||
func CanalMallOrdForYouMiShang(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(10) | |||
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 = handleCanalMallOrdForYouMiShang(res.Body) | |||
//_ = res.Reject(false) | |||
_ = res.Ack(true) | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleCanalMallOrdForYouMiShang(msg []byte) error { | |||
var canalMsg *md.CanalMallOrdForYouMiShang | |||
err := json.Unmarshal(msg, &canalMsg) | |||
if err != nil { | |||
fmt.Println("=======================", err) | |||
return err | |||
} | |||
database := strings.ReplaceAll(canalMsg.Database, "zhios_", "") | |||
if utils.InArr(database, []string{"88164961"}) == false { | |||
return nil | |||
} | |||
fmt.Println("==========================", 123333) | |||
eg := db.DBs[database] | |||
levelList, _ := db.UserLevlEgAll(eg) | |||
userId := make(map[string]string, 0) | |||
for _, v := range canalMsg.Data { | |||
if utils.StrToInt(v.Uid) == 0 || utils.InArr(v.State, []string{"1", "2", "3"}) == false { | |||
continue | |||
} | |||
userId[v.Uid] = v.Uid | |||
} | |||
fmt.Println(userId) | |||
for _, v := range userId { | |||
FindUser(eg, v, database, levelList) | |||
oneUser, _ := db.UserProfileFindByID(eg, v) | |||
if oneUser == nil || (oneUser != nil && oneUser.ParentUid == 0) { | |||
continue | |||
} | |||
FindUser(eg, utils.IntToStr(oneUser.ParentUid), database, levelList) | |||
} | |||
return nil | |||
} | |||
func FindUser(eg *xorm.Engine, uid string, dbName string, levelList []*model2.UserLevel) { | |||
oneUser, _ := db.UserFindByID(eg, uid) | |||
if oneUser == nil { | |||
return | |||
} | |||
levelWeight := 0 | |||
for _, v1 := range levelList { | |||
if v1.Id == oneUser.Level { | |||
levelWeight = v1.LevelWeight | |||
} | |||
} | |||
nextLv := "" | |||
for _, v1 := range levelList { | |||
if v1.LevelWeight <= levelWeight || v1.AutoUpdate == 0 { //小于当前等级或没开自动升级的都跳过 | |||
continue | |||
} | |||
if nextLv == "" { | |||
nextLv = utils.IntToStr(v1.Id) | |||
} | |||
} | |||
if nextLv != "" { | |||
DataDetail1 := md2.DataDetail{ | |||
AgentType: nextLv, | |||
Comment: "自动等级", | |||
MasterId: dbName, | |||
Uid: utils.IntToStr(oneUser.Uid), | |||
IsChangeTime: "1", | |||
} | |||
var info model.User | |||
copier.Copy(&info, &oneUser) | |||
fmt.Println(DataDetail1) | |||
zyos_go_condition_hdl.CommUplv("", eg, dbName, &info, oneUser.Level, DataDetail1) | |||
} | |||
} |
@@ -27,6 +27,10 @@ func initConsumes() { | |||
jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay | |||
jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess | |||
jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund | |||
jobs[consumeMd.CanalMallOrdForYouMiShangFunName] = CanalMallOrdForYouMiShang | |||
//jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore | |||
} | |||
func Run() { | |||
@@ -102,6 +102,24 @@ var RabbitMqQueueKeyList = []*MqQueue{ | |||
BindKey: "official", | |||
ConsumeFunName: "DouShenUserRegisterConsumeForOfficial", | |||
}, | |||
{ | |||
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", | |||
}, | |||
} | |||
const ( | |||
@@ -115,4 +133,6 @@ const ( | |||
ZhiosFastReturnOrderPayFunName = "ZhiosFastReturnOrderPay" | |||
ZhiosFastReturnOrderSuccessFunName = "ZhiosFastReturnOrderSuccess" | |||
ZhiosFastReturnOrderRefundFunName = "ZhiosFastReturnOrderRefund" | |||
CanalMallOrdForYouMiShangFunName = "CanalMallOrdForYouMiShang" | |||
YoumishangExchangeStoreFunName = "YoumishangExchangeStore" | |||
) |
@@ -0,0 +1,297 @@ | |||
package md | |||
type CanalMallOrdForYouMiShang struct { | |||
Data []struct { | |||
OrdId string `json:"ord_id"` | |||
MainOrdId string `json:"main_ord_id"` | |||
Uid string `json:"uid"` | |||
BuyerName string `json:"buyer_name"` | |||
BuyerPhone string `json:"buyer_phone"` | |||
CostPrice string `json:"cost_price"` | |||
State string `json:"state"` | |||
PayTime interface{} `json:"pay_time"` | |||
PayChannel string `json:"pay_channel"` | |||
ShippingTime string `json:"shipping_time"` | |||
LogisticCompany string `json:"logistic_company"` | |||
LogisticNum string `json:"logistic_num"` | |||
ReceiverPhone string `json:"receiver_phone"` | |||
ReceiverName string `json:"receiver_name"` | |||
ReceiverAddressDetail string `json:"receiver_address_detail"` | |||
ShippingType string `json:"shipping_type"` | |||
CouponDiscount string `json:"coupon_discount"` | |||
DiscountPrice string `json:"discount_price"` | |||
ReturnInsuranceFee string `json:"return_insurance_fee"` | |||
IsReceipt string `json:"is_receipt"` | |||
ShippingFee string `json:"shipping_fee"` | |||
Comment string `json:"comment"` | |||
ProvinceName string `json:"province_name"` | |||
CityName string `json:"city_name"` | |||
CountyName string `json:"county_name"` | |||
PayNum string `json:"pay_num"` | |||
ConfirmTime string `json:"confirm_time"` | |||
EstimateIntegral string `json:"estimate_integral"` | |||
EstimateCommission string `json:"estimate_commission"` | |||
CreateTime string `json:"create_time"` | |||
UpdateTime string `json:"update_time"` | |||
DeletedTime interface{} `json:"deleted_time"` | |||
FinishTime interface{} `json:"finish_time"` | |||
OrderType string `json:"order_type"` | |||
Data string `json:"data"` | |||
GroupBuyCommission string `json:"group_buy_commission"` | |||
GroupBuyCommissionTime interface{} `json:"group_buy_commission_time"` | |||
CommissionTime string `json:"commission_time"` | |||
GroupBuySettleTime interface{} `json:"group_buy_settle_time"` | |||
SettleTime interface{} `json:"settle_time"` | |||
CostVirtualCoin string `json:"cost_virtual_coin"` | |||
VirtualCoinId string `json:"virtual_coin_id"` | |||
UserCouponId string `json:"user_coupon_id"` | |||
ShareUid string `json:"share_uid"` | |||
IsConsign string `json:"is_consign"` | |||
UserLevelData string `json:"user_level_data"` | |||
GoodsId string `json:"goods_id"` | |||
IsHasUserLevel string `json:"is_has_user_level"` | |||
UserLevel string `json:"user_level"` | |||
IsGiveUserLevel string `json:"is_give_user_level"` | |||
ReturnMoneySettleAt string `json:"return_money_settle_at"` | |||
IsSetReduce string `json:"is_set_reduce"` | |||
DeductCoin string `json:"deduct_coin"` | |||
ConsumptionCoinReward string `json:"consumption_coin_reward"` | |||
DeductCoinReward string `json:"deduct_coin_reward"` | |||
IsSubsidyEnd string `json:"is_subsidy_end"` | |||
RunTime string `json:"run_time"` | |||
SupplierMerchantId string `json:"supplier_merchant_id"` | |||
SupplierOrdId string `json:"supplier_ord_id"` | |||
PayOnBehalfUid string `json:"pay_on_behalf_uid"` | |||
IsSetSubsidy string `json:"is_set_subsidy"` | |||
ProvinceId string `json:"province_id"` | |||
CityId string `json:"city_id"` | |||
CountyId string `json:"county_id"` | |||
CurrencyCode string `json:"currency_code"` | |||
TotalShippingFee string `json:"total_shipping_fee"` | |||
StoreOrdId string `json:"store_ord_id"` | |||
IsSetOutAch string `json:"is_set_out_ach"` | |||
SupplierStoreOrdId string `json:"supplier_store_ord_id"` | |||
TransactionId string `json:"transaction_id"` | |||
PayData interface{} `json:"pay_data"` | |||
SubOrderPayType interface{} `json:"sub_order_pay_type"` | |||
ConsumptionCoinRewardOut string `json:"consumption_coin_reward_out"` | |||
DeductCoinRewardOut string `json:"deduct_coin_reward_out"` | |||
IcbcIntegral string `json:"icbc_integral"` | |||
ParentUid string `json:"parent_uid"` | |||
SupplierCloudChainOrdId string `json:"supplier_cloud_chain_ord_id"` | |||
GoodsType string `json:"goods_type"` | |||
RewardCoinId string `json:"reward_coin_id"` | |||
IsVirtualGoods string `json:"is_virtual_goods"` | |||
RewardCoinAmount string `json:"reward_coin_amount"` | |||
RewardVirtualUserLv string `json:"reward_virtual_user_lv"` | |||
BaseCommission string `json:"base_commission"` | |||
PlatformCostPrice string `json:"platform_cost_price"` | |||
IsSettle string `json:"is_settle"` | |||
Pvd string `json:"pvd"` | |||
PointId string `json:"point_id"` | |||
MacaoAddress string `json:"macao_address"` | |||
AddressType string `json:"address_type"` | |||
VirtualGoodsInfo string `json:"virtual_goods_info"` | |||
PayWay string `json:"pay_way"` | |||
} `json:"data"` | |||
Database string `json:"database"` | |||
Es int64 `json:"es"` | |||
Id int `json:"id"` | |||
IsDdl bool `json:"isDdl"` | |||
MysqlType struct { | |||
OrdId string `json:"ord_id"` | |||
MainOrdId string `json:"main_ord_id"` | |||
Uid string `json:"uid"` | |||
BuyerName string `json:"buyer_name"` | |||
BuyerPhone string `json:"buyer_phone"` | |||
CostPrice string `json:"cost_price"` | |||
State string `json:"state"` | |||
PayTime string `json:"pay_time"` | |||
PayChannel string `json:"pay_channel"` | |||
ShippingTime string `json:"shipping_time"` | |||
LogisticCompany string `json:"logistic_company"` | |||
LogisticNum string `json:"logistic_num"` | |||
ReceiverPhone string `json:"receiver_phone"` | |||
ReceiverName string `json:"receiver_name"` | |||
ReceiverAddressDetail string `json:"receiver_address_detail"` | |||
ShippingType string `json:"shipping_type"` | |||
CouponDiscount string `json:"coupon_discount"` | |||
DiscountPrice string `json:"discount_price"` | |||
ReturnInsuranceFee string `json:"return_insurance_fee"` | |||
IsReceipt string `json:"is_receipt"` | |||
ShippingFee string `json:"shipping_fee"` | |||
Comment string `json:"comment"` | |||
ProvinceName string `json:"province_name"` | |||
CityName string `json:"city_name"` | |||
CountyName string `json:"county_name"` | |||
PayNum string `json:"pay_num"` | |||
ConfirmTime string `json:"confirm_time"` | |||
EstimateIntegral string `json:"estimate_integral"` | |||
EstimateCommission string `json:"estimate_commission"` | |||
CreateTime string `json:"create_time"` | |||
UpdateTime string `json:"update_time"` | |||
DeletedTime string `json:"deleted_time"` | |||
FinishTime string `json:"finish_time"` | |||
OrderType string `json:"order_type"` | |||
Data string `json:"data"` | |||
GroupBuyCommission string `json:"group_buy_commission"` | |||
GroupBuyCommissionTime string `json:"group_buy_commission_time"` | |||
CommissionTime string `json:"commission_time"` | |||
GroupBuySettleTime string `json:"group_buy_settle_time"` | |||
SettleTime string `json:"settle_time"` | |||
CostVirtualCoin string `json:"cost_virtual_coin"` | |||
VirtualCoinId string `json:"virtual_coin_id"` | |||
UserCouponId string `json:"user_coupon_id"` | |||
ShareUid string `json:"share_uid"` | |||
IsConsign string `json:"is_consign"` | |||
UserLevelData string `json:"user_level_data"` | |||
GoodsId string `json:"goods_id"` | |||
IsHasUserLevel string `json:"is_has_user_level"` | |||
UserLevel string `json:"user_level"` | |||
IsGiveUserLevel string `json:"is_give_user_level"` | |||
ReturnMoneySettleAt string `json:"return_money_settle_at"` | |||
IsSetReduce string `json:"is_set_reduce"` | |||
DeductCoin string `json:"deduct_coin"` | |||
ConsumptionCoinReward string `json:"consumption_coin_reward"` | |||
DeductCoinReward string `json:"deduct_coin_reward"` | |||
IsSubsidyEnd string `json:"is_subsidy_end"` | |||
RunTime string `json:"run_time"` | |||
SupplierMerchantId string `json:"supplier_merchant_id"` | |||
SupplierOrdId string `json:"supplier_ord_id"` | |||
PayOnBehalfUid string `json:"pay_on_behalf_uid"` | |||
IsSetSubsidy string `json:"is_set_subsidy"` | |||
ProvinceId string `json:"province_id"` | |||
CityId string `json:"city_id"` | |||
CountyId string `json:"county_id"` | |||
CurrencyCode string `json:"currency_code"` | |||
TotalShippingFee string `json:"total_shipping_fee"` | |||
StoreOrdId string `json:"store_ord_id"` | |||
IsSetOutAch string `json:"is_set_out_ach"` | |||
SupplierStoreOrdId string `json:"supplier_store_ord_id"` | |||
TransactionId string `json:"transaction_id"` | |||
PayData string `json:"pay_data"` | |||
SubOrderPayType string `json:"sub_order_pay_type"` | |||
ConsumptionCoinRewardOut string `json:"consumption_coin_reward_out"` | |||
DeductCoinRewardOut string `json:"deduct_coin_reward_out"` | |||
IcbcIntegral string `json:"icbc_integral"` | |||
ParentUid string `json:"parent_uid"` | |||
SupplierCloudChainOrdId string `json:"supplier_cloud_chain_ord_id"` | |||
GoodsType string `json:"goods_type"` | |||
RewardCoinId string `json:"reward_coin_id"` | |||
IsVirtualGoods string `json:"is_virtual_goods"` | |||
RewardCoinAmount string `json:"reward_coin_amount"` | |||
RewardVirtualUserLv string `json:"reward_virtual_user_lv"` | |||
BaseCommission string `json:"base_commission"` | |||
PlatformCostPrice string `json:"platform_cost_price"` | |||
IsSettle string `json:"is_settle"` | |||
Pvd string `json:"pvd"` | |||
PointId string `json:"point_id"` | |||
MacaoAddress string `json:"macao_address"` | |||
AddressType string `json:"address_type"` | |||
VirtualGoodsInfo string `json:"virtual_goods_info"` | |||
PayWay string `json:"pay_way"` | |||
} `json:"mysqlType"` | |||
Old []struct { | |||
State string `json:"state"` | |||
ConfirmTime interface{} `json:"confirm_time"` | |||
UpdateTime string `json:"update_time"` | |||
} `json:"old"` | |||
PkNames []string `json:"pkNames"` | |||
Sql string `json:"sql"` | |||
SqlType struct { | |||
OrdId int `json:"ord_id"` | |||
MainOrdId int `json:"main_ord_id"` | |||
Uid int `json:"uid"` | |||
BuyerName int `json:"buyer_name"` | |||
BuyerPhone int `json:"buyer_phone"` | |||
CostPrice int `json:"cost_price"` | |||
State int `json:"state"` | |||
PayTime int `json:"pay_time"` | |||
PayChannel int `json:"pay_channel"` | |||
ShippingTime int `json:"shipping_time"` | |||
LogisticCompany int `json:"logistic_company"` | |||
LogisticNum int `json:"logistic_num"` | |||
ReceiverPhone int `json:"receiver_phone"` | |||
ReceiverName int `json:"receiver_name"` | |||
ReceiverAddressDetail int `json:"receiver_address_detail"` | |||
ShippingType int `json:"shipping_type"` | |||
CouponDiscount int `json:"coupon_discount"` | |||
DiscountPrice int `json:"discount_price"` | |||
ReturnInsuranceFee int `json:"return_insurance_fee"` | |||
IsReceipt int `json:"is_receipt"` | |||
ShippingFee int `json:"shipping_fee"` | |||
Comment int `json:"comment"` | |||
ProvinceName int `json:"province_name"` | |||
CityName int `json:"city_name"` | |||
CountyName int `json:"county_name"` | |||
PayNum int `json:"pay_num"` | |||
ConfirmTime int `json:"confirm_time"` | |||
EstimateIntegral int `json:"estimate_integral"` | |||
EstimateCommission int `json:"estimate_commission"` | |||
CreateTime int `json:"create_time"` | |||
UpdateTime int `json:"update_time"` | |||
DeletedTime int `json:"deleted_time"` | |||
FinishTime int `json:"finish_time"` | |||
OrderType int `json:"order_type"` | |||
Data int `json:"data"` | |||
GroupBuyCommission int `json:"group_buy_commission"` | |||
GroupBuyCommissionTime int `json:"group_buy_commission_time"` | |||
CommissionTime int `json:"commission_time"` | |||
GroupBuySettleTime int `json:"group_buy_settle_time"` | |||
SettleTime int `json:"settle_time"` | |||
CostVirtualCoin int `json:"cost_virtual_coin"` | |||
VirtualCoinId int `json:"virtual_coin_id"` | |||
UserCouponId int `json:"user_coupon_id"` | |||
ShareUid int `json:"share_uid"` | |||
IsConsign int `json:"is_consign"` | |||
UserLevelData int `json:"user_level_data"` | |||
GoodsId int `json:"goods_id"` | |||
IsHasUserLevel int `json:"is_has_user_level"` | |||
UserLevel int `json:"user_level"` | |||
IsGiveUserLevel int `json:"is_give_user_level"` | |||
ReturnMoneySettleAt int `json:"return_money_settle_at"` | |||
IsSetReduce int `json:"is_set_reduce"` | |||
DeductCoin int `json:"deduct_coin"` | |||
ConsumptionCoinReward int `json:"consumption_coin_reward"` | |||
DeductCoinReward int `json:"deduct_coin_reward"` | |||
IsSubsidyEnd int `json:"is_subsidy_end"` | |||
RunTime int `json:"run_time"` | |||
SupplierMerchantId int `json:"supplier_merchant_id"` | |||
SupplierOrdId int `json:"supplier_ord_id"` | |||
PayOnBehalfUid int `json:"pay_on_behalf_uid"` | |||
IsSetSubsidy int `json:"is_set_subsidy"` | |||
ProvinceId int `json:"province_id"` | |||
CityId int `json:"city_id"` | |||
CountyId int `json:"county_id"` | |||
CurrencyCode int `json:"currency_code"` | |||
TotalShippingFee int `json:"total_shipping_fee"` | |||
StoreOrdId int `json:"store_ord_id"` | |||
IsSetOutAch int `json:"is_set_out_ach"` | |||
SupplierStoreOrdId int `json:"supplier_store_ord_id"` | |||
TransactionId int `json:"transaction_id"` | |||
PayData int `json:"pay_data"` | |||
SubOrderPayType int `json:"sub_order_pay_type"` | |||
ConsumptionCoinRewardOut int `json:"consumption_coin_reward_out"` | |||
DeductCoinRewardOut int `json:"deduct_coin_reward_out"` | |||
IcbcIntegral int `json:"icbc_integral"` | |||
ParentUid int `json:"parent_uid"` | |||
SupplierCloudChainOrdId int `json:"supplier_cloud_chain_ord_id"` | |||
GoodsType int `json:"goods_type"` | |||
RewardCoinId int `json:"reward_coin_id"` | |||
IsVirtualGoods int `json:"is_virtual_goods"` | |||
RewardCoinAmount int `json:"reward_coin_amount"` | |||
RewardVirtualUserLv int `json:"reward_virtual_user_lv"` | |||
BaseCommission int `json:"base_commission"` | |||
PlatformCostPrice int `json:"platform_cost_price"` | |||
IsSettle int `json:"is_settle"` | |||
Pvd int `json:"pvd"` | |||
PointId int `json:"point_id"` | |||
MacaoAddress int `json:"macao_address"` | |||
AddressType int `json:"address_type"` | |||
VirtualGoodsInfo int `json:"virtual_goods_info"` | |||
PayWay int `json:"pay_way"` | |||
} `json:"sqlType"` | |||
Table string `json:"table"` | |||
Ts int64 `json:"ts"` | |||
Type string `json:"type"` | |||
} |
@@ -7,3 +7,8 @@ type ZhiosFatReturnOrderPay struct { | |||
Name string `json:"name"` | |||
Prd string `json:"prd"` | |||
} | |||
type YouMiShangExchangeStoreStruct struct { | |||
MasterId string `json:"master_id"` | |||
Uid int64 `json:"uid"` | |||
} |
@@ -0,0 +1,75 @@ | |||
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" | |||
) | |||
func YoumishangExchangeStore(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 = handleYoumishangExchangeStore(res.Body) | |||
//_ = res.Reject(false) | |||
fmt.Println(err) | |||
if err == nil { | |||
_ = res.Ack(true) | |||
} | |||
} else { | |||
panic(errors.New("error getting message")) | |||
} | |||
} | |||
fmt.Println("get msg done") | |||
} | |||
func handleYoumishangExchangeStore(msg []byte) error { | |||
//1、解析canal采集至mq中queue的数据结构体 | |||
var canalMsg *md.YouMiShangExchangeStoreStruct | |||
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.MasterId | |||
eg := db.DBs[mid] | |||
uid := canalMsg.Uid | |||
levelList, _ := db.UserLevlEgAll(eg) | |||
FindUser(eg, utils.Int64ToStr(uid), mid, levelList) | |||
oneUser, _ := db.UserProfileFindByID(eg, uid) | |||
if oneUser == nil || (oneUser != nil && oneUser.ParentUid == 0) { | |||
return nil | |||
} | |||
FindUser(eg, utils.IntToStr(oneUser.ParentUid), mid, levelList) | |||
return nil | |||
} |
@@ -3,6 +3,7 @@ module applet | |||
go 1.18 | |||
require ( | |||
code.fnuoos.com/go_rely_warehouse/zyos_go_condition_statistics.git v1.1.2-0.20230511044138-c4ab4d961561 | |||
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_pay.git v1.6.1-0.20230412095020-14ea57f9ee82 | |||
@@ -21,6 +22,7 @@ require ( | |||
github.com/go-redis/redis v6.15.9+incompatible | |||
github.com/go-sql-driver/mysql v1.6.0 | |||
github.com/gomodule/redigo v2.0.0+incompatible | |||
github.com/jinzhu/copier v0.3.5 | |||
github.com/json-iterator/go v1.1.12 | |||
github.com/makiuchi-d/gozxing v0.0.0-20210324052758-57132e828831 | |||
github.com/robfig/cron/v3 v3.0.1 | |||
@@ -34,7 +36,7 @@ require ( | |||
google.golang.org/protobuf v1.28.0 | |||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 | |||
gopkg.in/yaml.v2 v2.4.0 | |||
xorm.io/xorm v1.3.0 | |||
xorm.io/xorm v1.3.1 | |||
) | |||
require ( | |||
@@ -80,5 +82,5 @@ require ( | |||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect | |||
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55 // indirect | |||
honnef.co/go/tools v0.0.1-2020.1.4 // indirect | |||
xorm.io/builder v0.3.10 // indirect | |||
xorm.io/builder v0.3.11-0.20220531020008-1bd24a7dc978 // indirect | |||
) |