Преглед изворни кода

聚合充值+抖音团长商品

three
huangjiajun пре 1 година
родитељ
комит
0836ab850a
28 измењених фајлова са 1433 додато и 3 уклоњено
  1. +103
    -0
      app/db/db_user_fin_flow.go
  2. +498
    -0
      app/db/db_user_profile.go
  3. +36
    -0
      app/db/model/recharge_order.go
  4. +11
    -0
      app/db/model/recharge_order_msg.go
  5. +31
    -0
      app/db/model/tik_tok_team_goods.go
  6. +15
    -0
      app/db/offical/db_aggregation_user.go
  7. +23
    -0
      app/db/offical/db_lianlian_order_qrcode.go
  8. +21
    -0
      app/db/offical/db_lianlian_refund_order.go
  9. +15
    -0
      app/db/offical/db_lianlian_user.go
  10. +18
    -0
      app/db/offical/db_phone_recharge_cate.go
  11. +15
    -0
      app/db/offical/db_sys_cfg.go
  12. +16
    -0
      app/db/offical/model/aggregation_user.go
  13. +25
    -0
      app/db/offical/model/aggregation_user_recharge_ord.go
  14. +36
    -0
      app/db/offical/model/lianlian_order.go
  15. +15
    -0
      app/db/offical/model/lianlian_order_qrcode.go
  16. +22
    -0
      app/db/offical/model/lianlian_refund_order.go
  17. +16
    -0
      app/db/offical/model/lianlian_user.go
  18. +25
    -0
      app/db/offical/model/lianlian_user_recharge_ord.go
  19. +12
    -0
      app/db/offical/model/phone_recharge_cate.go
  20. +34
    -0
      app/db/offical/model/recharge_order.go
  21. +7
    -0
      app/db/offical/model/sys_cfg.go
  22. +74
    -0
      app/svc/svc_user_flow.go
  23. +4
    -0
      consume/init.go
  24. +20
    -0
      consume/md/consume_key.go
  25. +37
    -0
      consume/md/md_zhios_recharge_order_fail.go
  26. +171
    -0
      consume/zhios_recharge_order_fail.go
  27. +127
    -0
      consume/zhios_tikTok_goods_update.go
  28. +6
    -3
      go.mod

+ 103
- 0
app/db/db_user_fin_flow.go Прегледај датотеку

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

import (
"applet/app/db/model"
"applet/app/utils/logx"

"xorm.io/xorm"
)

// GetFinUserFlowByID is 用户流水记录
func GetFinUserFlowByID(Db *xorm.Engine, id interface{}) (*model.FinUserFlow, error) {
var m model.FinUserFlow
if has, err := Db.Where("id = ?", id).Get(&m); err != nil || !has {
return nil, logx.Warn(err)
}
return &m, nil
}

// GetFinUserFlowByID is 用户流水记录
func GetFinUserFlowByUIDANDOID(Db *xorm.Engine, types, uid, ordId string) (*model.FinUserFlow, error) {
var m model.FinUserFlow
if has, err := Db.Where("uid = ? and ord_id = ? and type = ?", uid, ordId, types).Get(&m); err != nil || !has {
return nil, logx.Warn(err)
}
return &m, nil
}
func GetFinUserFlowByUIDANDOIDTOORDTYPE(Db *xorm.Engine, types, uid, ordId string) (*model.FinUserFlow, error) {
var m model.FinUserFlow
if has, err := Db.Where("uid = ? and ord_id = ? and ord_type = ?", uid, ordId, types).Get(&m); err != nil || !has {
return nil, logx.Warn(err)
}
return &m, nil
}

// GetFinUserFlowByID is 用户流水记录
func GetFinUserFlowByOIDANDORDTYPE(Db *xorm.Engine, types, ordId, ordType string) (*model.FinUserFlow, error) {
var m model.FinUserFlow
if has, err := Db.Where("ord_id = ? and ord_action = ? and ord_type= ?", ordId, types, ordType).Get(&m); err != nil || !has {
return nil, logx.Warn(err)
}
return &m, nil
}

//FinUserFlowInsertOne is 插入一条流水记录
func FinUserFlowInsertOne(Db *xorm.Engine, m *model.FinUserFlow) error {
_, err := Db.InsertOne(m)
if err != nil {
return err
}
return nil
}

//FinUserFlowInsertOne is 插入一条流水记录
func FinUserFlowWithSessionInsertOne(session *xorm.Session, m *model.FinUserFlow) error {
_, err := session.InsertOne(m)
if err != nil {
return err
}
return nil
}

// FinUserFlowByUID is 用户流水
func FinUserFlowInputByUID(Db *xorm.Engine, uid interface{}, time string, limit, start int) ([]*model.FinUserFlow, error) {
var m []*model.FinUserFlow
if err := Db.Where("uid = ? AND create_at like ? and (amount> ? or ord_type=?)", uid, time+"%", "0", "fast_return").In("type", "0").Desc("create_at").Limit(limit, start).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return m, nil
}
func FinUserFlowInputByUIDWithAmount(Db *xorm.Engine, uid interface{}, types, before_amount, after_amount string) (*model.FinUserFlow, error) {
var m model.FinUserFlow
if has, err := Db.Where("uid = ? and ord_type='withdraw' and ord_action = ? and before_amount= ? and after_amount = ?", uid, types, before_amount, after_amount).Get(&m); err != nil || !has {
return nil, logx.Warn(err)
}
return &m, nil
}

// FinUserFlowByUIDByOrderAction is 用户流水 by OrderAction
func FinUserFlowInputByUIDByOrderActionByTime(Db *xorm.Engine, uid, oa interface{}, time string, limit, start int) ([]*model.FinUserFlow, error) {
var m []*model.FinUserFlow
if err := Db.Where("uid = ? AND create_at like ? and amount>0", uid, time+"%").In("ord_action", oa).Desc("create_at").Limit(limit, start).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return m, nil
}

// FinUserFlowByUIDByOrderAction is 用户流水 by OrderAction
func FinUserFlowInputByUIDByTypeByTime(Db *xorm.Engine, uid int, time string, limit, start int) ([]*model.FinUserFlow, error) {
var m []*model.FinUserFlow
if err := Db.Where("uid = ? AND type = 1 AND create_at like ? and (amount>0 or ord_type=? or ord_action=?)", uid, time+"%", "fast_return", 101).Desc("create_at").Limit(limit, start).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return m, nil
}

// 在事务中使用,插入一条流水记录
func FinUserFlowInsertOneWithSession(session *xorm.Session, m *model.FinUserFlow) error {
_, err := session.InsertOne(m)
if err != nil {
return err
}
return nil
}

+ 498
- 0
app/db/db_user_profile.go Прегледај датотеку

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

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

//UserProfileFindByArkID is get userprofile by arkid
func UserProfileFindByArkID(Db *xorm.Engine, id interface{}) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("arkid_uid = ?", id).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}
func UserProfileFindByArkToken(Db *xorm.Engine, id interface{}) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("arkid_token<>'' and arkid_token = ?", id).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}

//UserProfileFindByInviteCode is get userprofile by InviteCode
func UserProfileFindByInviteCode(Db *xorm.Engine, code string) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("invite_code = ?", code).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}

//UserProfileFindByInviteCode is get userprofile by InviteCode
func UserProfileFindByCustomInviteCode(Db *xorm.Engine, code string) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("custom_invite_code = ?", code).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}

//UserProfileFindByInviteCodes is get userprofile by InviteCode
func UserProfileFindByInviteCodes(Db *xorm.Engine, codes ...string) (*[]model.UserProfile, error) {
var m []model.UserProfile
if err := Db.In("invite_code", codes).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}
func UserProfileFindByAll(Db *xorm.Engine) (*[]model.UserProfile, error) {
var m []model.UserProfile
if err := Db.Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}

//UserProfileFindByCustomInviteCodes is get userprofile by CustomInviteCode
func UserProfileFindByCustomInviteCodes(Db *xorm.Engine, codes ...string) (*[]model.UserProfile, error) {
var m []model.UserProfile
if err := Db.In("custom_invite_code", codes).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}

func UserProfileFindByIDSess(sess *xorm.Session, id interface{}) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := sess.Where("uid = ?", id).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}
func UserProfileFindByPID(Db *xorm.Engine, id interface{}) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("parent_uid = ?", id).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}

// UserProfileOrderByNew 找最新的记录
func UserProfileOrderByNew(Db *xorm.Engine) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("invite_code != ''").OrderBy("uid desc").Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}

// UserProfileFindByTaobaoOpenID search user_profile ByTaobaoOpenID
func UserProfileFindByTaobaoOpenID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("third_party_taobao_oid = ?", openid).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}

// UserProfileFindByQQOpenID search user_profile ByTaobaoOpenID
func UserProfileFindByQQOpenID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("third_party_qq_openid = ?", openid).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}

// UserProfileFindByAppleToken search user_profile AppleToken
func UserProfileFindByAppleToken(Db *xorm.Engine, token interface{}) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("third_party_apple_token = ?", token).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}

// UserProfileFindByWeChatOpenID search user_profile By 微信openid
func UserProfileFindByWeChatOpenID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("third_party_wechat_openid = ?", openid).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}

// UserProfileFindByWeChatMiniOpenID search user_profile By 小程序openid
func UserProfileFindByWeChatMiniOpenID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("third_party_wechat_mini_openid = ?", openid).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}

// UserProfileFindByWeChatUnionID search user_profile By 微信唯一id
func UserProfileFindByWeChatUnionID(Db *xorm.Engine, openid interface{}) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := Db.Where("third_party_wechat_unionid = ? and third_party_wechat_unionid<>''", openid).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}
func UserProfileFindByAccAlipay(Db *xorm.Engine, accAlipay string, uid int) (bool, error) {
if has, err := Db.Where("acc_alipay = ? and uid <>?", accAlipay, uid).Exist(&model.UserProfile{}); err != nil || has == false {
return false, logx.Warn(err)
}
return true, nil
}

// UserProfileisExistByTaobaoOpenID is exist by Taobao
func UserProfileisExistByTaobaoOpenID(Db *xorm.Engine, openid string) (bool, error) {
has, err := Db.Where("third_party_taobao_oid = ?", openid).Exist(&model.UserProfile{})

if err != nil {
return false, err
}
return has, nil
}
func UserProfileisThirdPartyWechatH5Openid(Db *xorm.Engine, openid string) (*model.UserProfile, error) {
var user model.UserProfile
has, err := Db.Where("third_party_wechat_h5_openid = ? and third_party_wechat_h5_openid<>''", openid).Get(&user)

if err != nil || has == false {
return nil, err
}
return &user, nil
}

// UserProfileisExistByQQOpenID is exist by QQ openid
func UserProfileisExistByQQOpenID(Db *xorm.Engine, openid string) (bool, error) {
has, err := Db.Where("third_party_qq_openid = ?", openid).Exist(&model.UserProfile{})

if err != nil {
return false, err
}
return has, nil
}

// UserProfileisExistByAppleToken is exist by apple token
func UserProfileisExistByAppleToken(Db *xorm.Engine, token string) (bool, error) {
has, err := Db.Where("third_party_apple_token = ?", token).Exist(&model.UserProfile{})

if err != nil {
return false, err
}
return has, nil
}

// UserProfileisExistByWeChatOpenID is exist by Wecaht openid
func UserProfileisExistByWeChatOpenID(Db *xorm.Engine, openid string) (bool, error) {
has, err := Db.Where("third_party_wechat_openid = ?", openid).Exist(&model.UserProfile{})

if err != nil {
return false, err
}
return has, nil
}

// UserProfileisExistByWeChatMiniOpenID is exist by Wecaht openid
func UserProfileisExistByWeChatMiniOpenID(Db *xorm.Engine, openid string) (bool, error) {
has, err := Db.Where("third_party_wechat_mini_openid = ?", openid).Exist(&model.UserProfile{})

if err != nil {
return false, err
}
return has, nil
}

// UserProfileisExistByWeChatUnionID is exist by Wecaht openid
func UserProfileisExistByWeChatUnionID(Db *xorm.Engine, openid string) (bool, error) {
has, err := Db.Where("third_party_wechat_unionid = ? and third_party_wechat_unionid<>''", openid).Exist(&model.UserProfile{})

if err != nil {
return false, err
}
return has, nil
}

// UserProfileisExistByRelationIDAndSpecialID is exist by RelationIdAndSpecialId
func UserProfileisExistByRelationIDAndSpecialID(Db *xorm.Engine, SpecialID, RelationID int64) (bool, error) {
has, err := Db.Where("acc_taobao_self_id = ? AND acc_taobao_share_id = ?", SpecialID, RelationID).Exist(&model.UserProfile{})

if err != nil {
return false, err
}
return has, nil
}

// UserProfileisExistBySpecialID is exist by SpecialId
func UserProfileisExistBySpecialID(Db *xorm.Engine, SpecialID string) (bool, error) {
has, err := Db.Where("acc_taobao_self_id = ? ", SpecialID).Exist(&model.UserProfile{})

if err != nil {
return false, err
}
return has, nil
}

// UserProfileCountByRelationID 统计relationID数量
func UserProfileCountByRelationID(Db *xorm.Engine) (total int64, err error) {
relate := new(model.UserProfile)
total, err = Db.Where("acc_taobao_share_id > 0").Count(relate)
return
}

// UserProfileCountByPUID 统计直推下级数量
func UserProfileCountByPUID(Db *xorm.Engine, puid int) (total int64, err error) {
relate := new(model.UserProfile)
total, err = Db.Where("parent_uid = ?", puid).Count(relate)
return
}

// UserProfileisExistByRelationID is exist by RelationID
func UserProfileisExistByRelationID(Db *xorm.Engine, RelationID string) (bool, error) {
has, err := Db.Where("acc_taobao_share_id = ? ", RelationID).Exist(&model.UserProfile{})

if err != nil {
return false, err
}
return has, nil
}

// UserProfileFindByIDs is in sql by ids
func UserProfileFindByIDs(Db *xorm.Engine, uids ...int) (*[]model.UserProfile, error) {
var m []model.UserProfile
if err := Db.In("uid", uids).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}

// UserProfileByPuid search user_profile by parent_uid
func UserProfileByPuid(Db *xorm.Engine, puid interface{}) (*[]model.UserProfile, error) {
var m []model.UserProfile
if err := Db.Where("parent_uid = ?", puid).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}
func UserProfileByPuidWithSess(sess *xorm.Session, puid interface{}) (*[]model.UserProfile, error) {
var m []model.UserProfile
if err := sess.Where("parent_uid = ?", puid).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}

//UsersProfileInByIds is profiles by ids
func UsersProfileInByIds(Db *xorm.Engine, ids []int, limit, start int) (*[]model.UserProfile, error) {
var m []model.UserProfile
if limit == 0 && start == 0 {
if err := Db.In("uid", ids).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}
if err := Db.In("uid", ids).Limit(limit, start).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}

// UsersProfileInByUIDByisVerify is In查询 以及是否是有效用户
func UsersProfileInByUIDByisVerify(Db *xorm.Engine, ids []int, isVerify interface{}) (*[]model.UserProfile, error) {
var m []model.UserProfile
if err := Db.In("uid", ids).Where("is_verify = ?", isVerify).
Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}

// UsersProfileInByIdsByDesc is 根据某列 降序
func UsersProfileInByIdsByDesc(Db *xorm.Engine, ids []int, limit, start int, c string) (*[]model.UserProfile, error) {
var m []model.UserProfile
if limit == 0 && start == 0 {
if err := Db.In("uid", ids).Desc(c).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}
if err := Db.In("uid", ids).Desc(c).Limit(limit, start).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}

// UsersProfileInByIdsByAsc is 根据某列 升序
func UsersProfileInByIdsByAsc(Db *xorm.Engine, ids []int, limit, start int, c string) (*[]model.UserProfile, error) {
var m []model.UserProfile
if limit == 0 && start == 0 {
if err := Db.In("uid", ids).Asc(c).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}
if err := Db.In("uid", ids).Asc(c).Limit(limit, start).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}

// UsersProfileByAll is 查询所有分享id大于0的数据
func UsersProfileByTaobaoShateIdNotNull(Db *xorm.Engine, limit, start int) (*[]model.UserProfile, error) {
var m []model.UserProfile
if err := Db.Where("acc_taobao_share_id > 0").Limit(limit, start).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
}

// UserProfileIsExistByUserID is mobile exist
func UserProfileIsExistByUserID(Db *xorm.Engine, id int) (bool, error) {
has, err := Db.Where("uid = ?", id).Exist(&model.UserProfile{})
if err != nil {
return false, err
}
return has, nil
}

// UserProfileIsExistByInviteCode is exist ?
func UserProfileIsExistByInviteCode(Db *xorm.Engine, code string) (bool, error) {
has, err := Db.Where("invite_code = ?", code).Exist(&model.UserProfile{})
if err != nil {
return false, err
}
return has, nil
}

// UserProfileIsExistByCustomInviteCode is exist ?
func UserProfileIsExistByCustomInviteCode(Db *xorm.Engine, code string) (bool, error) {
has, err := Db.Where("custom_invite_code = ?", code).Exist(&model.UserProfile{})
if err != nil {
return false, err
}
return has, nil
}

//UserProfileInsert is insert user
func UserProfileInsert(Db *xorm.Engine, userProfile *model.UserProfile) (int64, error) {
affected, err := Db.Insert(userProfile)
if err != nil {
return 0, err
}
return affected, nil
}

//UserProfileUpdate is update userprofile
func UserProfileUpdate(Db *xorm.Engine, uid interface{}, userProfile *model.UserProfile, forceCols ...string) (int64, error) {
var (
affected int64
err error
)
if forceCols != nil {
affected, err = Db.Where("uid=?", uid).Cols(forceCols...).Update(userProfile)
} else {
affected, err = Db.Where("uid=?", uid).AllCols().Omit("fin_valid").Update(userProfile)
}

if err != nil {
return 0, logx.Warn(err)
}
return affected, nil
}
func UserProfileUpdateWithSess(sess *xorm.Session, uid interface{}, userProfile *model.UserProfile, forceCols ...string) (int64, error) {
var (
affected int64
err error
)
if forceCols != nil {
affected, err = sess.Where("uid=?", uid).Cols(forceCols...).Update(userProfile)
} else {
affected, err = sess.Where("uid=?", uid).AllCols().Omit("fin_valid").Update(userProfile)
}

if err != nil {
return 0, logx.Warn(err)
}
return affected, nil
}

//UserProfileUpdateByArkID is update userprofile
func UserProfileUpdateByArkID(Db *xorm.Engine, arkid interface{}, userProfile *model.UserProfile, forceCols ...string) (int64, error) {
var (
affected int64
err error
)
if forceCols != nil {
affected, err = Db.Where("arkid_uid=?", arkid).Cols(forceCols...).Update(userProfile)
} else {
affected, err = Db.Where("arkid_uid=?", arkid).Update(userProfile)
}
if err != nil {
return 0, logx.Warn(err)
}
return affected, nil
}

// UserProfileDelete is delete user profile
func UserProfileDelete(Db *xorm.Engine, uid interface{}) (int64, error) {
return Db.Where("uid = ?", uid).Delete(model.UserProfile{})
}
func UserProfileDeleteWithSess(sess *xorm.Session, uid interface{}) (int64, error) {
return sess.Where("uid = ?", uid).Delete(model.UserProfile{})
}
func UserProfileFindByIdWithSession(session *xorm.Session, uid int) (*model.UserProfile, error) {
var m model.UserProfile
if has, err := session.Where("uid = ?", uid).Get(&m); err != nil || has == false {
return nil, logx.Warn(err)
}
return &m, nil
}

// 在事务中更新用户信息
func UserProfileUpdateWithSession(session *xorm.Session, uid interface{}, userProfile *model.UserProfile, forceCols ...string) (int64, error) {
var (
affected int64
err error
)
if forceCols != nil {
affected, err = session.Where("uid=?", uid).Cols(forceCols...).Update(userProfile)
} else {
affected, err = session.Where("uid=?", uid).Omit("fin_valid").Update(userProfile)
}
if err != nil {
return 0, logx.Warn(err)
}
return affected, nil
}

// UpdateUserProfileFinValid 更新用户余额
func UpdateUserProfileFinValid(Db *xorm.Engine, uid interface{}, newAmount string) error {
update, err := Db.Where("uid=?", uid).Update(&model.UserProfile{FinValid: newAmount})
if err != nil {
return err
}
if update != 1 {
return errors.New("更新失败")
}

return nil
}

// UpdateUserProfileFinValidWithSess 事务更新用户余额
func UpdateUserProfileFinValidWithSess(sess *xorm.Session, uid interface{}, newAmount string) error {
update, err := sess.Where("uid=?", uid).Update(&model.UserProfile{FinValid: newAmount})
if err != nil {
return err
}
if update != 1 {
return errors.New("更新失败")
}

return nil
}

+ 36
- 0
app/db/model/recharge_order.go Прегледај датотеку

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

import (
"time"
)

type RechargeOrder struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
PayMethod int `json:"pay_method" xorm:"default 0 comment('支付方式') INT(11)"`
Oid string `json:"oid" xorm:"comment('站内订单号') VARCHAR(255)"`
PlatformOid string `json:"platform_oid" xorm:"comment('平台订单号') VARCHAR(255)"`
Type string `json:"type" xorm:"comment('充值类型') VARCHAR(255)"`
Status string `json:"status" xorm:"comment('订单状态') VARCHAR(255)"`
CreateTime time.Time `json:"create_time" xorm:"DATETIME"`
PayTime time.Time `json:"pay_time" xorm:"DATETIME"`
RefundTime time.Time `json:"refund_time" xorm:"DATETIME"`
SuccessTime time.Time `json:"success_time" xorm:"DATETIME"`
Account string `json:"account" xorm:"VARCHAR(255)"`
Province string `json:"province" xorm:"VARCHAR(255)"`
Amount string `json:"amount" xorm:"default 0.00 DECIMAL(20,2)"`
GoodsId int `json:"goods_id" xorm:"default 0 INT(11)"`
Title string `json:"title" xorm:"VARCHAR(255)"`
Profit string `json:"profit" xorm:"default 0.00 DECIMAL(20,2)"`
ZyAmount string `json:"zy_amount" xorm:"default 0.00 DECIMAL(20,2)"`
City string `json:"city" xorm:"VARCHAR(255)"`
Ytype string `json:"ytype" xorm:"VARCHAR(255)"`
IdCardNo string `json:"id_card_no" xorm:"VARCHAR(255)"`
TradeNo string `json:"trade_no" xorm:"VARCHAR(255)"`
PayTradeNo string `json:"pay_trade_no" xorm:"VARCHAR(255)"`
OfficalAmount string `json:"offical_amount" xorm:"default 0.00 DECIMAL(20,2)"`
RechargeStatus string `json:"recharge_status" xorm:"VARCHAR(255)"`
UserCommission string `json:"user_commission" xorm:"default 0.0000 DECIMAL(20,4)"`
Price string `json:"price" xorm:"default 0.0000 DECIMAL(20,4)"`
SettleAt int `json:"settle_at" xorm:"default 0 INT(11)"`
}

+ 11
- 0
app/db/model/recharge_order_msg.go Прегледај датотеку

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

type RechargeOrderMsg struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Oid string `json:"oid" xorm:"VARCHAR(255)"`
Param string `json:"param" xorm:"VARCHAR(1000)"`
FirstMsg string `json:"first_msg" xorm:"VARCHAR(1000)"`
RefundMsg string `json:"refund_msg" xorm:"VARCHAR(1000)"`
SuccessMsg string `json:"success_msg" xorm:"VARCHAR(1000)"`
Err string `json:"err" xorm:"VARCHAR(1000)"`
}

+ 31
- 0
app/db/model/tik_tok_team_goods.go Прегледај датотеку

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

import (
"time"
)

type TikTokTeamGoods struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Cid int `json:"cid" xorm:"default 0 comment('分类id') INT(11)"`
Title string `json:"title" xorm:"VARCHAR(255)"`
Price string `json:"price" xorm:"default 0.00 comment('现价') DECIMAL(10,2)"`
CostPrice string `json:"cost_price" xorm:"default 0.00 comment('原价') DECIMAL(10,2)"`
Commission string `json:"commission" xorm:"default 0.00 comment('佣金比例%') DECIMAL(10,2)"`
Gid string `json:"gid" xorm:"default '' comment('商品id') VARCHAR(100)"`
Sales int `json:"sales" xorm:"default 0 comment('销量') INT(11)"`
GoodsImg string `json:"goods_img" xorm:"default '' comment('图片') VARCHAR(255)"`
DetailUrl string `json:"detail_url" xorm:"default '' comment('活动链接') VARCHAR(255)"`
ShopName string `json:"shop_name" xorm:"default '' comment('店铺名称') VARCHAR(255)"`
EndType string `json:"end_type" xorm:"default '' comment('') VARCHAR(255)"`
LmType string `json:"lm_type" xorm:"default '' comment('') VARCHAR(255)"`
ActivityStartTime time.Time `json:"activity_start_time" xorm:"comment('活动开始时间') DATETIME"`
ActivityEndTime time.Time `json:"activity_end_time" xorm:"comment('活动结束时间') DATETIME"`
OldActivityEndTime time.Time `json:"old_activity_end_time" xorm:"comment('活动结束时间') DATETIME"`
UpdateTime time.Time `json:"update_time" xorm:"comment('活动结束时间') DATETIME"`
ActivityId int `json:"activity_id" xorm:"default 0 INT(11)"`
IsDown int `json:"is_down" xorm:"default 0 INT(1)"`
Status int `json:"status" xorm:"default 0 INT(11)"`
PublicCommission string `json:"public_commission" xorm:"default 0.00 comment('佣金比例%') DECIMAL(10,2)"`
ServiceRatio string `json:"service_ratio" xorm:"default 0.00 comment('佣金比例%') DECIMAL(10,2)"`
TalentCommission string `json:"talent_commission" xorm:"default 0.00 comment('佣金比例%') DECIMAL(10,2)"`
}

+ 15
- 0
app/db/offical/db_aggregation_user.go Прегледај датотеку

@@ -0,0 +1,15 @@
package offical

import (
"applet/app/db"
officialModel "applet/app/db/offical/model"
)

func GetAggregationUserInfo(uid string) *officialModel.AggregationUser {
var user officialModel.AggregationUser
get, err := db.Db.Where("uid=?", uid).Get(&user)
if get == false || err != nil {
return nil
}
return &user
}

+ 23
- 0
app/db/offical/db_lianlian_order_qrcode.go Прегледај датотеку

@@ -0,0 +1,23 @@
package offical

import (
"applet/app/db"
"applet/app/db/offical/model"
)

func GetLianlianOrderQrcode(oid string) *[]model.LianlianOrderQrcode {
var data []model.LianlianOrderQrcode
err := db.Db.Where("oid=?", oid).Find(&data)
if err != nil {
return nil
}
return &data
}
func GetLianlianOrderQrcodeWithCode(oid, code string) *model.LianlianOrderQrcode {
var data model.LianlianOrderQrcode
get, err := db.Db.Where("oid=? and sub_oid=?", oid, code).Get(&data)
if get == false || err != nil {
return nil
}
return &data
}

+ 21
- 0
app/db/offical/db_lianlian_refund_order.go Прегледај датотеку

@@ -0,0 +1,21 @@
package offical

import (
"applet/app/db"
"applet/app/db/offical/model"
)

func GetLianlianRefundOrdByOrdId(ordId, code string) (*model.LianlianRefundOrder, error) {
var ord model.LianlianRefundOrder
if has, err := db.Db.Where(" oid=? and ord_ids like ?", ordId, "%"+code+"%").Get(&ord); err != nil || !has {
return nil, err
}
return &ord, nil
}
func GetLianlianRefundOrdByOrdIdAll(ordId string) (*model.LianlianRefundOrder, error) {
var ord model.LianlianRefundOrder
if has, err := db.Db.Where(" oid=? ", ordId).Get(&ord); err != nil || !has {
return nil, err
}
return &ord, nil
}

+ 15
- 0
app/db/offical/db_lianlian_user.go Прегледај датотеку

@@ -0,0 +1,15 @@
package offical

import (
"applet/app/db"
officialModel "applet/app/db/offical/model"
)

func GetLianlianUserInfo(uid string) *officialModel.LianlianUser {
var user officialModel.LianlianUser
get, err := db.Db.Where("uid=?", uid).Get(&user)
if get == false || err != nil {
return nil
}
return &user
}

+ 18
- 0
app/db/offical/db_phone_recharge_cate.go Прегледај датотеку

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

import (
"applet/app/db"
"applet/app/db/offical/model"
)

func GetPhoneRechargeCate() map[int]model.PhoneRechargeCate {
var data []model.PhoneRechargeCate
var dataMap = make(map[int]model.PhoneRechargeCate)
err := db.Db.Where("1=1").Find(&data)
if err == nil {
for _, v := range data {
dataMap[v.Cid] = v
}
}
return dataMap
}

+ 15
- 0
app/db/offical/db_sys_cfg.go Прегледај датотеку

@@ -0,0 +1,15 @@
package offical

import (
"applet/app/db"
officialModel "applet/app/db/offical/model"
)

func SysCfgByKey(key string) *officialModel.SysCfg {
var data officialModel.SysCfg
get, err := db.Db.Where("k=?", key).Get(&data)
if get == false || err != nil {
return nil
}
return &data
}

+ 16
- 0
app/db/offical/model/aggregation_user.go Прегледај датотеку

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

import (
"time"
)

type AggregationUser struct {
Id int `json:"id" xorm:"not null pk autoincr comment('自增id') INT(11)"`
Uid int `json:"uid" xorm:"not null default 0 comment('主用户id') INT(11)"`
Amount string `json:"amount" xorm:"not null default '0' comment('余额') VARCHAR(255)"`
CreditAmount string `json:"credit_amount" xorm:"not null default '100' comment('授信额度') VARCHAR(255)"`
State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(2)"`
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"default CURRENT_TIMESTAMP comment('更新时间') DATETIME"`
}

+ 25
- 0
app/db/offical/model/aggregation_user_recharge_ord.go Прегледај датотеку

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

import (
"time"
)

type AggregationUserRechargeOrd struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
OrdId string `json:"ord_id" xorm:"not null default '' comment('订单id') VARCHAR(100)"`
Uid int `json:"uid" xorm:"not null default 0 comment('主用户id') INT(11)"`
Phone int64 `json:"phone" xorm:"not null default 0 comment('主账号-手机号码') BIGINT(13)"`
Nickname string `json:"nickname" xorm:"not null default '' comment('主账号-昵称') VARCHAR(255)"`
Amount string `json:"amount" xorm:"not null default '0' comment('充值金额') VARCHAR(255)"`
CostPrice string `json:"cost_price" xorm:"not null default '0' comment('付费价格') VARCHAR(255)"`
Balance string `json:"balance" xorm:"not null default '0' comment('当前余额(充值完当前余额)') VARCHAR(255)"`
PayWay int `json:"pay_way" xorm:"not null default 1 comment('支付方式(1:支付宝 2:微信 3:余额)') TINYINT(1)"`
State int `json:"state" xorm:"not null default 0 comment('状态(0:待付款 1:已付款 2:付款失败)') TINYINT(2)"`
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"default CURRENT_TIMESTAMP comment('更新时间') DATETIME"`
TradeNo string `json:"trade_no" xorm:"not null default '' comment('支付平台(支付宝/微信)订单号') VARCHAR(100)"`
Type int `json:"type" xorm:"default 0 comment('0收入 1支出') INT(1)"`
OrdType string `json:"ord_type" xorm:"comment('订单类型') VARCHAR(255)"`
SubUid int `json:"sub_uid" xorm:"default 0 INT(11)"`
}

+ 36
- 0
app/db/offical/model/lianlian_order.go Прегледај датотеку

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

import (
"time"
)

type LianlianOrder struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Oid string `json:"oid" xorm:"default '' VARCHAR(255)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
CreateTime time.Time `json:"create_time" xorm:"DATETIME"`
PayTime time.Time `json:"pay_time" xorm:"DATETIME"`
SuccessTime time.Time `json:"success_time" xorm:"DATETIME"`
RefundTime time.Time `json:"refund_time" xorm:"DATETIME"`
Title string `json:"title" xorm:"VARCHAR(255)"`
Amount float64 `json:"amount" xorm:"default 0.0000 DOUBLE(20,4)"`
Profit float64 `json:"profit" xorm:"default 0.0000 DOUBLE(20,4)"`
Gid string `json:"gid" xorm:"VARCHAR(255)"`
ItemId string `json:"item_id" xorm:"VARCHAR(255)"`
Num int `json:"num" xorm:"default 0 INT(11)"`
Memo string `json:"memo" xorm:"VARCHAR(255)"`
LocationId string `json:"location_id" xorm:"VARCHAR(255)"`
CreateMsg string `json:"create_msg" xorm:"TEXT"`
State string `json:"state" xorm:"VARCHAR(255)"`
ValidBeginDate time.Time `json:"valid_begin_date" xorm:"DATETIME"`
ValidEndDate time.Time `json:"valid_end_date" xorm:"DATETIME"`
TradeNo string `json:"trade_no" xorm:"comment('支付平台的订单号') VARCHAR(50)"`
PayTradeNo string `json:"pay_trade_no" xorm:"comment('支付联盟支付的订单号') VARCHAR(50)"`
SysOid string `json:"sys_oid" xorm:"VARCHAR(255)"`
PayMethod int `json:"pay_method" xorm:"default 0 INT(11)"`
ItemTitle string `json:"item_title" xorm:"VARCHAR(255)"`
Img string `json:"img" xorm:"VARCHAR(255)"`
ItemPrice float64 `json:"item_price" xorm:"DOUBLE(20,4)"`
ProductCategoryId int `json:"product_category_id" xorm:"default 0 INT(11)"`
SubUid int `json:"sub_uid" xorm:"default 0 INT(11)"`
}

+ 15
- 0
app/db/offical/model/lianlian_order_qrcode.go Прегледај датотеку

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

type LianlianOrderQrcode struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Oid string `json:"oid" xorm:"default '' VARCHAR(255)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
SubOid string `json:"sub_oid" xorm:"VARCHAR(255)"`
Title string `json:"title" xorm:"VARCHAR(255)"`
COid string `json:"c_oid" xorm:"VARCHAR(255)"`
Code string `json:"code" xorm:"VARCHAR(255)"`
QrcodeImg string `json:"qrcode_img" xorm:"VARCHAR(255)"`
BookingUrl string `json:"booking_url" xorm:"VARCHAR(255)"`
Msg string `json:"msg" xorm:"TEXT"`
State string `json:"state" xorm:"VARCHAR(255)"`
}

+ 22
- 0
app/db/offical/model/lianlian_refund_order.go Прегледај датотеку

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

import (
"time"
)

type LianlianRefundOrder struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Oid string `json:"oid" xorm:"VARCHAR(255)"`
Code string `json:"code" xorm:"VARCHAR(255)"`
OrdIds string `json:"ord_ids" xorm:"VARCHAR(255)"`
CreateTime time.Time `json:"create_time" xorm:"DATETIME"`
RefundTime time.Time `json:"refund_time" xorm:"DATETIME"`
Amount float64 `json:"amount" xorm:"default 0.0000 DOUBLE(20,4)"`
RealAmount float64 `json:"real_amount" xorm:"default 0.0000 DOUBLE(20,4)"`
Num int `json:"num" xorm:"default 0 INT(11)"`
Memo string `json:"memo" xorm:"VARCHAR(255)"`
State string `json:"state" xorm:"VARCHAR(255)"`
RefundOid string `json:"refund_oid" xorm:"VARCHAR(255)"`
RefundSysOid string `json:"refund_sys_oid" xorm:"VARCHAR(255)"`
RefuseMemo string `json:"refuse_memo" xorm:"VARCHAR(255)"`
}

+ 16
- 0
app/db/offical/model/lianlian_user.go Прегледај датотеку

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

import (
"time"
)

type LianlianUser struct {
Id int `json:"id" xorm:"not null pk autoincr comment('自增id') INT(11)"`
Uid int `json:"uid" xorm:"not null default 0 comment('主用户id') INT(11)"`
Amount string `json:"amount" xorm:"not null default '0' comment('余额') VARCHAR(255)"`
CreditAmount string `json:"credit_amount" xorm:"not null default '100' comment('授信额度') VARCHAR(255)"`
State int `json:"state" xorm:"not null default 1 comment('状态(1:正常 2:冻结)') TINYINT(2)"`
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"default CURRENT_TIMESTAMP comment('更新时间') DATETIME"`
}

+ 25
- 0
app/db/offical/model/lianlian_user_recharge_ord.go Прегледај датотеку

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

import (
"time"
)

type LianlianUserRechargeOrd struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
OrdId string `json:"ord_id" xorm:"not null default '' comment('订单id') VARCHAR(100)"`
Uid int `json:"uid" xorm:"not null default 0 comment('主用户id') INT(11)"`
Phone int64 `json:"phone" xorm:"not null default 0 comment('主账号-手机号码') BIGINT(13)"`
Nickname string `json:"nickname" xorm:"not null default '' comment('主账号-昵称') VARCHAR(255)"`
Amount string `json:"amount" xorm:"not null default '0' comment('充值金额') VARCHAR(255)"`
CostPrice string `json:"cost_price" xorm:"not null default '0' comment('付费价格') VARCHAR(255)"`
Balance string `json:"balance" xorm:"not null default '0' comment('当前余额(充值完当前余额)') VARCHAR(255)"`
PayWay int `json:"pay_way" xorm:"not null default 1 comment('支付方式(1:支付宝 2:微信 3:余额)') TINYINT(1)"`
State int `json:"state" xorm:"not null default 0 comment('状态(0:待付款 1:已付款 2:付款失败)') TINYINT(2)"`
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
CreateAt time.Time `json:"create_at" xorm:"not null default CURRENT_TIMESTAMP comment('创建时间') DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"default CURRENT_TIMESTAMP comment('更新时间') DATETIME"`
TradeNo string `json:"trade_no" xorm:"not null default '' comment('支付平台(支付宝/微信)订单号') VARCHAR(100)"`
Type int `json:"type" xorm:"default 0 comment('0收入 1支出') INT(1)"`
OrdType string `json:"ord_type" xorm:"comment('订单类型') VARCHAR(255)"`
SubUid int `json:"sub_uid" xorm:"default 0 INT(11)"`
}

+ 12
- 0
app/db/offical/model/phone_recharge_cate.go Прегледај датотеку

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

type PhoneRechargeCate struct {
Id int `json:"id" xorm:"not null pk autoincr comment('自增id') INT(11)"`
Cid int `json:"cid" xorm:"not null default 0 comment('') INT(11)"`
DayNum int `json:"day_num" xorm:"not null default 0 comment('') INT(11)"`
Day int `json:"day" xorm:"not null default 0 comment('') INT(11)"`
MonthNum int `json:"month_num" xorm:"not null default 0 comment('') INT(11)"`
Area string `json:"area" xorm:"not null default '' comment('备注') VARCHAR(255)"`
PhoneZone string `json:"phone_zone" xorm:"not null default '' comment('备注') VARCHAR(255)"`
CanArea string `json:"can_area" xorm:"not null default '' comment('备注') VARCHAR(255)"`
}

+ 34
- 0
app/db/offical/model/recharge_order.go Прегледај датотеку

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

import (
"time"
)

type RechargeOrder struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"default 0 INT(11)"`
PayMethod int `json:"pay_method" xorm:"comment('支付方式') 0 INT(11)"`
Oid string `json:"oid" xorm:"comment('站内订单号') VARCHAR(255)"`
PlatformOid string `json:"platform_oid" xorm:"comment('平台订单号') VARCHAR(255)"`
Type string `json:"type" xorm:"comment('充值类型') VARCHAR(255)"`
Status string `json:"status" xorm:"comment('订单状态') VARCHAR(255)"`
CreateTime time.Time `json:"create_time" xorm:"DATETIME"`
PayTime time.Time `json:"pay_time" xorm:"DATETIME"`
RefundTime time.Time `json:"refund_time" xorm:"DATETIME"`
SuccessTime time.Time `json:"success_time" xorm:"DATETIME"`
Account string `json:"account" xorm:"VARCHAR(255)"`
Province string `json:"province" xorm:"VARCHAR(255)"`
Amount string `json:"amount" xorm:"default 0.00 DECIMAL(20,2)"`
GoodsId int `json:"goods_id" xorm:"default 0 INT(11)"`
Title string `json:"title" xorm:"VARCHAR(255)"`
Profit string `json:"profit" xorm:"default 0.00 DECIMAL(20,2)"`
ZyAmount string `json:"zy_amount" xorm:"default 0.00 DECIMAL(20,2)"`
OfficalAmount string `json:"offical_amount" xorm:"default 0.00 DECIMAL(20,2)"`
City string `json:"city" xorm:"VARCHAR(255)"`
Ytype string `json:"ytype" xorm:"VARCHAR(255)"`
IdCardNo string `json:"id_card_no" xorm:"VARCHAR(255)"`
TradeNo string `json:"trade_no" xorm:"VARCHAR(255)"`
PayTradeNo string `json:"pay_trade_no" xorm:"VARCHAR(255)"`
SubUid int `json:"sub_uid" xorm:"default 0 INT(11)"`
RechargeStatus string `json:"recharge_status" xorm:"VARCHAR(255)"`
}

+ 7
- 0
app/db/offical/model/sys_cfg.go Прегледај датотеку

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

type SysCfg struct {
K string `json:"k" xorm:"not null pk comment('键') VARCHAR(127)"`
V string `json:"v" xorm:"comment('值') TEXT"`
Memo string `json:"memo" xorm:"not null default '' comment('备注') VARCHAR(255)"`
}

+ 74
- 0
app/svc/svc_user_flow.go Прегледај датотеку

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

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

func UpdateUserFinValidAndInterFlow(engine *xorm.Engine, money, Title, ordType string, types, orderAction, uid, id int, ordId, otherId int64) error {
session := engine.NewSession()
defer session.Close()
session.Begin()
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 {
_ = session.Rollback()
if err == nil {
err = errors.New("更新用户余额信息失败")
}
return err
}
err = flowInsertSess(session, uid, money, orderAction, ordId, otherId, id, Title, ordType, types, beforeAmount, afterAmount)
if err != nil {
_ = session.Rollback()
return err
}
return session.Commit()
}

func flowInsertSess(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
}

+ 4
- 0
consume/init.go Прегледај датотеку

@@ -33,7 +33,11 @@ func initConsumes() {
jobs[consumeMd.CanalMallOrdForYouMiShangFunName] = CanalMallOrdForYouMiShang
jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore

jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail

jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate

}

func Run() {


+ 20
- 0
consume/md/consume_key.go Прегледај датотеку

@@ -138,6 +138,24 @@ var RabbitMqQueueKeyList = []*MqQueue{
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",
},
}

const (
@@ -154,5 +172,7 @@ const (
ZhiosFastReturnOrderRefundFunName = "ZhiosFastReturnOrderRefund"
CanalMallOrdForYouMiShangFunName = "CanalMallOrdForYouMiShang"
YoumishangExchangeStoreFunName = "YoumishangExchangeStore"
ZhiosRechargeOrderFailFunName = "ZhiosRechargeOrderFail"
ZhiosTikTokUpdateFunName = "ZhiosTikTokUpdate"
CloudIssuanceAsyncMLoginFunName = "CloudIssuanceAsyncMLoginConsume"
)

+ 37
- 0
consume/md/md_zhios_recharge_order_fail.go Прегледај датотеку

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

type ZhiosRechargeOrderPay struct {
Uid string `json:"uid"`
Mid string `json:"mid"`
Oid string `json:"oid"`
}
type TikTokExChangeRoutKeyForUpdateParam struct {
Cid string `json:"cid"`
Status string `json:"status"`
Str string `json:"str"`
IsOk bool `json:"is_ok"`
Mid string `json:"mid"`
Data string `json:"data"`
}
type TikTokData struct {
Commission string `json:"commission"`
PublicCommission string `json:"public_commission"`
ServiceRatio string `json:"service_ratio"`
CostPrice string `json:"cost_price"`
GoodsID string `json:"goods_id"`
GoodsImg string `json:"goods_img"`
GoodsSales string `json:"goods_sales"`
GoodsTitle string `json:"goods_title"`
InStock string `json:"in_stock"`
Price string `json:"price"`
Sharable string `json:"sharable"`
ShopID string `json:"shop_id"`
ShopName string `json:"shop_name"`
DetailURL string `json:"detail_url"`
YhqPrice string `json:"yhq_price"`
Cid string `json:"cid"`
ActivityStartTime string `json:"activity_start_time"`
ActivityEndTime string `json:"activity_end_time"`
Imgs []string `json:"imgs"`
UpdateTime string `json:"update_time"`
}

+ 171
- 0
consume/zhios_recharge_order_fail.go Прегледај датотеку

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

import (
"applet/app/db"
"applet/app/db/model"
"applet/app/db/offical"
model2 "applet/app/db/offical/model"
"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"
"code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git/recharge"
"encoding/json"
"errors"
"fmt"
"github.com/streadway/amqp"
"github.com/tidwall/gjson"
"strings"
"time"
"xorm.io/xorm"
)

func ZhiosRechargeOrderFail(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 = handleZhiosRechargeOrderFail(res.Body)
//_ = res.Reject(false)
if err == nil {
_ = res.Ack(true)
}
} else {
panic(errors.New("error getting message"))
}
}
fmt.Println("get msg done")
}

func handleZhiosRechargeOrderFail(msg []byte) error {
//1、解析canal采集至mq中queue的数据结构体
var canalMsg *md.ZhiosRechargeOrderPay
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]
uid := utils.StrToInt(canalMsg.Uid)
oid := canalMsg.Oid
var orderData model.RechargeOrder
b, err2 := eg.Where("oid=? and uid=?", oid, uid).Get(&orderData)
if err2 != nil {
return errors.New("err")
}
if b == false {
return nil
}
if orderData.Status != "已付款" {
return nil
}
//查询官方接口看看有没有订单
param, aggregationRechargeApiKey := CommAggregation(eg, mid)
param["out_trade_nums"] = oid
order, err := recharge.GetOrder(aggregationRechargeApiKey, param)
if err != nil {
return errors.New("err")
}
if gjson.Get(order, "errno").Int() == 0 && strings.Contains(order, oid) == false {
// 更改为已支付
orderData.Status = "已退款"
orderData.RefundTime = time.Now()
// 保存ord
row, err := eg.ID(orderData.Id).Cols("status,pay_method,refund_time").Update(&orderData)
if row > 0 && err == nil {
svc.UpdateUserFinValidAndInterFlow(eg,
orderData.Amount, "聚合充值"+orderData.Title+"退款", "aggregation_recharge", 0, 24, orderData.Uid, orderData.Id, int64(orderData.Id), utils.StrToInt64(orderData.Oid))
} else {
return errors.New("err")
}
rechargeNotPayMoney := db.SysCfgGetWithDb(eg, mid, "recharge_not_pay_money")
if rechargeNotPayMoney != "1" {
ZyRechargeMoneyDeal(mid, orderData.Oid, orderData.Uid, utils.StrToFloat64(orderData.ZyAmount), 0, orderData.Title+"退款", "refund")
}
}
return nil
}
func ZyRechargeMoneyDeal(mid string, orderId string, uid int, officalAmount float64, types int, title, orderType string) error {
info := offical.GetAggregationUserInfo(mid)
if info == nil {
fmt.Println("获取价格失败")
return e.NewErr(400, "获取价格失败")
}
if types == 1 {
if utils.StrToFloat64(info.Amount)+utils.StrToFloat64(info.CreditAmount)-officalAmount < 0 {
fmt.Println("预存款不足")
return e.NewErr(400, "预存款不足")
}
info.Amount = utils.Float64ToStr(utils.StrToFloat64(info.Amount) - officalAmount)
} else {
info.Amount = utils.Float64ToStr(utils.StrToFloat64(info.Amount) + officalAmount)
}
update, err := db.Db.Where("id=?", info.Id).Cols("amount").Update(info)
if update == 0 || err != nil {
return e.NewErr(400, "预存款不足")
}
var flow = model2.AggregationUserRechargeOrd{
OrdId: orderId,
Uid: utils.StrToInt(mid),
Amount: utils.Float64ToStr(officalAmount),
CostPrice: utils.Float64ToStr(officalAmount),
Balance: info.Amount,
PayWay: 0,
State: 1,
Memo: title,
CreateAt: time.Now(),
Type: types,
OrdType: orderType,
SubUid: uid,
}
//TODO 要不要判断失败呢
db.Db.Insert(&flow)
return nil
}

func CommAggregation(eg *xorm.Engine, mid string) (map[string]string, string) {
aggregationRechargeApiKey := db.SysCfgGetWithDb(eg, mid, "aggregation_recharge_api_key")
aggregationRechargeUserId := db.SysCfgGetWithDb(eg, mid, "aggregation_recharge_user_id")
if aggregationRechargeApiKey == "" {
aggregationRechargeApiKeyMap := offical.SysCfgByKey("aggregation_recharge_api_key")
if aggregationRechargeApiKeyMap != nil {
aggregationRechargeApiKey = aggregationRechargeApiKeyMap.V
}
}
if aggregationRechargeUserId == "" {
aggregationRechargeUserIdMap := offical.SysCfgByKey("aggregation_recharge_user_id")
if aggregationRechargeUserIdMap != nil {
aggregationRechargeUserId = aggregationRechargeUserIdMap.V
}
}
param := map[string]string{
"userid": aggregationRechargeUserId,
}
return param, aggregationRechargeApiKey
}

+ 127
- 0
consume/zhios_tikTok_goods_update.go Прегледај датотеку

@@ -0,0 +1,127 @@
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"
"time"
)

func ZhiosTikTokUpdate(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 = handleZhiosTikTokGoodsUpdate(res.Body)
//_ = res.Reject(false)
if err == nil {
_ = res.Ack(true)
}
} else {
panic(errors.New("error getting message"))
}
}
fmt.Println("get msg done")
}

func handleZhiosTikTokGoodsUpdate(msg []byte) error {
//1、解析canal采集至mq中queue的数据结构体
var canalMsg *md.TikTokExChangeRoutKeyForUpdateParam
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]
var v md.TikTokData
json.Unmarshal([]byte(canalMsg.Data), &v)
var tmp model.TikTokTeamGoods
get, _ := eg.Where("gid=? and activity_id=?", v.GoodsID, canalMsg.Cid).Get(&tmp)
if get {
//if tmp.IsDown == 1 {
// continue
//}
tmp.IsDown = 0
tmp.ServiceRatio = v.ServiceRatio
tmp.Price = v.Price
tmp.TalentCommission = v.PublicCommission
tmp.PublicCommission = v.PublicCommission
tmp.Title = v.GoodsTitle
tmp.CostPrice = v.CostPrice
tmp.Commission = v.Commission
tmp.GoodsImg = v.GoodsImg
tmp.DetailUrl = v.DetailURL
tmp.EndType = "已采集"
tmp.LmType = ""
tmp.Sales = utils.StrToInt(v.GoodsSales)
tmp.ActivityId = utils.StrToInt(canalMsg.Cid)
tmp.ActivityStartTime = utils.TimeParseStd(v.ActivityStartTime + " 00:00:00")
tmp.ActivityEndTime = utils.TimeParseStd(v.ActivityEndTime + " 23:59:59")
tmp.OldActivityEndTime = utils.TimeParseStd(v.ActivityEndTime + " 23:59:59")
tmp.UpdateTime = time.Now()
tmp.Status = utils.StrToInt(canalMsg.Status)
if tmp.Status == 3 || tmp.Status == 6 {
tmp.ActivityEndTime = time.Now()
}
eg.Where("id=?", tmp.Id).AllCols().Update(&tmp)
} else {
if utils.InArr(canalMsg.Status, []string{"3", "6"}) {
return nil
}
tmp = model.TikTokTeamGoods{
Cid: utils.StrToInt(v.Cid),
ServiceRatio: v.ServiceRatio,
Title: v.GoodsTitle,
Price: v.Price,
CostPrice: v.CostPrice,
Commission: v.Commission,
TalentCommission: v.PublicCommission,
PublicCommission: v.PublicCommission,
Gid: v.GoodsID,
Sales: utils.StrToInt(v.GoodsSales),
GoodsImg: v.GoodsImg,
DetailUrl: v.DetailURL,
ShopName: v.ShopName,
ActivityStartTime: utils.TimeParseStd(v.ActivityStartTime + " 00:00:00"),
ActivityEndTime: utils.TimeParseStd(v.ActivityEndTime + " 23:59:59"),
OldActivityEndTime: utils.TimeParseStd(v.ActivityEndTime + " 23:59:59"),
ActivityId: utils.StrToInt(canalMsg.Cid),
UpdateTime: time.Now(),
EndType: "已采集",
IsDown: 0,
}
eg.InsertOne(&tmp)
}
return nil
}

+ 6
- 3
go.mod Прегледај датотеку

@@ -7,6 +7,7 @@ require (
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
code.fnuoos.com/go_rely_warehouse/zyos_go_third_party_api.git v1.1.21-0.20230602010249-27d29647d800
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
@@ -30,7 +31,7 @@ require (
github.com/streadway/amqp v1.0.0
github.com/swaggo/swag v1.7.0
github.com/syyongx/php2go v0.9.7
github.com/tidwall/gjson v1.7.4
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
@@ -43,6 +44,7 @@ require (
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/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
@@ -61,6 +63,7 @@ require (
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/nilorg/sdk v0.0.0-20221104025912-4b6ccb7004d8 // indirect
github.com/olivere/elastic/v7 v7.0.32 // indirect
github.com/onsi/ginkgo v1.15.0 // indirect
github.com/onsi/gomega v1.10.5 // indirect
@@ -68,8 +71,8 @@ require (
github.com/pkg/errors v0.9.1 // indirect
github.com/rakyll/statik v0.1.7 // indirect
github.com/syndtr/goleveldb v1.0.0 // indirect
github.com/tidwall/match v1.0.3 // indirect
github.com/tidwall/pretty v1.1.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
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect


Loading…
Откажи
Сачувај