Sfoglia il codice sorgente

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	consume/init.go
#	consume/md/consume_key.go
order_statistics
huangjiajun 6 mesi fa
parent
commit
2e74dede4b
38 ha cambiato i file con 2226 aggiunte e 117 eliminazioni
  1. +3
    -3
      app/db/db_user.go
  2. +121
    -0
      app/db/db_user_virtual_coin_flow_aggregation.go
  3. +1
    -1
      app/db/db_user_withdrawapply.go
  4. +1
    -1
      app/db/dbs_map.go
  5. +1
    -0
      app/db/model/fin_withdraw_apply.go
  6. +13
    -0
      app/db/model/user_virtual_coin_flow_aggregation.go
  7. +40
    -0
      app/flexible_employment/db/db_flexible_employment_basic.go
  8. +44
    -0
      app/flexible_employment/db/db_flexible_employment_ord.go
  9. +40
    -0
      app/flexible_employment/db/db_flexible_employment_pupiao_basic.go
  10. +44
    -0
      app/flexible_employment/db/db_flexible_employment_pupiao_ord.go
  11. +13
    -0
      app/flexible_employment/db/model/flexible_employment_basic.go
  12. +18
    -0
      app/flexible_employment/db/model/flexible_employment_ord.go
  13. +14
    -0
      app/flexible_employment/db/model/flexible_employment_pupiao_basic.go
  14. +21
    -0
      app/flexible_employment/db/model/flexible_employment_pupiao_ord.go
  15. +13
    -0
      app/flexible_employment/db/model/flexible_employment_pupiao_user_info.go
  16. +17
    -0
      app/flexible_employment/db/model/flexible_employment_user_info.go
  17. +35
    -0
      app/flexible_employment/enum/enum_api.go
  18. +22
    -0
      app/flexible_employment/enum/enum_pupiao_api.go
  19. +9
    -0
      app/flexible_employment/md/md_api.go
  20. +58
    -0
      app/flexible_employment/md/md_call_back.go
  21. +77
    -0
      app/flexible_employment/md/mq.go
  22. +105
    -0
      app/flexible_employment/svc/svc_fin_withdraw_apply.go
  23. +99
    -0
      app/flexible_employment/utils/aes/utils.go
  24. +26
    -0
      app/flexible_employment/utils/algorithm.go
  25. +60
    -0
      app/flexible_employment/utils/rpc_client.go
  26. +10
    -0
      app/flexible_employment/utils/string.go
  27. +155
    -0
      app/lib/flexible_employment/gongmao.go
  28. +117
    -0
      app/lib/flexible_employment/pupiao.go
  29. +3
    -0
      app/utils/convert.go
  30. +48
    -42
      consume/init.go
  31. +109
    -49
      consume/md/consume_key.go
  32. +150
    -0
      consume/one_circles_activity_coin_auto_exchange_green_energy_consume.go
  33. +150
    -0
      consume/one_circles_activity_coin_auto_exchange_green_energy_for_team_consume.go
  34. +99
    -0
      consume/one_circles_settlement_public_activity_coin_consume.go
  35. +165
    -0
      consume/withdraw_consume_gongmao.go
  36. +176
    -0
      consume/withdraw_consume_pupiao.go
  37. +120
    -0
      consume/zhios_one_circles_coin_consume.go
  38. +29
    -21
      go.mod

+ 3
- 3
app/db/db_user.go Vedi File

@@ -193,8 +193,8 @@ func UserFindByID(Db *xorm.Engine, id interface{}) (*model.User, error) {
}
return &m, nil
}
func UserFindByIDWithSession(sess *xorm.Session, id interface{}) (*model.User, error) {
var m model.User
func UserFindByIDWithSession(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)
@@ -290,7 +290,7 @@ func UserUpdate(Db *xorm.Engine, uid interface{}, user *model.User, forceColums
return affected, nil
}

func UserUpdateWithSession(Db *xorm.Session, uid interface{}, user *model.User, forceColums ...string) (int64, error) {
func UserUpdateWithSession(Db *xorm.Session, uid interface{}, user *model.UserProfile, forceColums ...string) (int64, error) {
var (
affected int64
err error


+ 121
- 0
app/db/db_user_virtual_coin_flow_aggregation.go Vedi File

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

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

// BatchSelectUserVirtualCoinFlowAggregations 批量查询数据 TODO::和下面的方法重复了,建议采用下面的 `UserVirtualCoinFlowAggregationFindByParams` 方法
func BatchSelectUserVirtualCoinFlowAggregations(Db *xorm.Engine, params map[string]interface{}) (*[]model.UserVirtualCoinFlowAggregation, error) {
var UserVirtualCoinFlowAggregationData []model.UserVirtualCoinFlowAggregation
if err := Db.In(utils.AnyToString(params["key"]), params["value"]).
Find(&UserVirtualCoinFlowAggregationData); err != nil {
return nil, logx.Warn(err)
}
return &UserVirtualCoinFlowAggregationData, nil
}

// UserVirtualCoinFlowAggregationInsert 插入单条数据
func UserVirtualCoinFlowAggregationInsert(Db *xorm.Engine, UserVirtualCoinFlowAggregation *model.UserVirtualCoinFlowAggregation) (int64, error) {
_, err := Db.InsertOne(UserVirtualCoinFlowAggregation)
if err != nil {
return 0, err
}
return UserVirtualCoinFlowAggregation.Id, nil
}

// BatchAddUserVirtualCoinFlowAggregations 批量新增数据
func BatchAddUserVirtualCoinFlowAggregations(Db *xorm.Engine, UserVirtualCoinFlowAggregationData []*model.UserVirtualCoinFlowAggregation) (int64, error) {
affected, err := Db.Insert(UserVirtualCoinFlowAggregationData)
if err != nil {
return 0, err
}
return affected, nil
}

func GetUserVirtualCoinFlowAggregationCount(Db *xorm.Engine) int {
var UserVirtualCoinFlowAggregation model.UserVirtualCoinFlowAggregation
session := Db.Where("")
count, err := session.Count(&UserVirtualCoinFlowAggregation)
if err != nil {
return 0
}
return int(count)
}

// UserVirtualCoinFlowAggregationDelete 删除记录
func UserVirtualCoinFlowAggregationDelete(Db *xorm.Engine, id interface{}) (int64, error) {
if reflect.TypeOf(id).Kind() == reflect.Slice {
return Db.In("id", id).Delete(model.UserVirtualCoinFlowAggregation{})
} else {
return Db.Where("id = ?", id).Delete(model.UserVirtualCoinFlowAggregation{})
}
}

// UserVirtualCoinFlowAggregationUpdate 更新记录
func UserVirtualCoinFlowAggregationUpdate(Db *xorm.Engine, id interface{}, UserVirtualCoinFlowAggregation *model.UserVirtualCoinFlowAggregation, forceColums ...string) (int64, error) {
var (
affected int64
err error
)
if forceColums != nil {
affected, err = Db.Where("id=?", id).Cols(forceColums...).Update(UserVirtualCoinFlowAggregation)
} else {
affected, err = Db.Where("id=?", id).Update(UserVirtualCoinFlowAggregation)
}
if err != nil {
return 0, err
}
return affected, nil
}

// UserVirtualCoinFlowAggregationGetOneByParams 通过传入的参数查询数据(单条)
func UserVirtualCoinFlowAggregationGetOneByParams(Db *xorm.Engine, params map[string]interface{}) (*model.UserVirtualCoinFlowAggregation, error) {
var m model.UserVirtualCoinFlowAggregation
var query = fmt.Sprintf("%s =?", params["key"])
has, err := Db.Where(query, params["value"]).Get(&m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return &m, nil
}

// UserVirtualCoinFlowAggregationFindByParams 通过传入的参数查询数据(多条)
func UserVirtualCoinFlowAggregationFindByParams(Db *xorm.Engine, params map[string]interface{}) (*[]model.UserVirtualCoinFlowAggregation, error) {
var m []model.UserVirtualCoinFlowAggregation
if params["value"] == nil {
return nil, errors.New("参数有误")
}
if params["key"] == nil {
//查询全部数据
err := Db.Find(&m)
if err != nil {
return nil, logx.Error(err)
}
return &m, nil
} else {
if reflect.TypeOf(params["value"]).Kind() == reflect.Slice {
//指定In查询
if err := Db.In(utils.AnyToString(params["key"]), params["value"]).Find(&m); err != nil {
return nil, logx.Warn(err)
}
return &m, nil
} else {
var query = fmt.Sprintf("%s =?", params["key"])
err := Db.Where(query, params["value"]).Find(&m)
if err != nil {
return nil, logx.Error(err)
}
return &m, nil
}

}
}

+ 1
- 1
app/db/db_user_withdrawapply.go Vedi File

@@ -63,7 +63,7 @@ func UserWithDrawApplyByUIDByTime(Db *xorm.Engine, uid interface{}, stime, etime
return m, nil
}

func UserWithDrawApplyByUIDById(Db *xorm.Engine, id int64) (*model.FinWithdrawApply, error) {
func UserWithDrawApplyByUIDById(Db *xorm.Engine, id string) (*model.FinWithdrawApply, error) {
var m model.FinWithdrawApply
has, err := Db.Where("id = ?", id).Get(&m)
if err != nil {


+ 1
- 1
app/db/dbs_map.go Vedi File

@@ -110,7 +110,7 @@ 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 db_master_id=?", 1, 89608884).Find(&m)
} else {
err = Db.Where("deleted_at != ? AND is_dev = '1' ", 1).Find(&m)
}


+ 1
- 0
app/db/model/fin_withdraw_apply.go Vedi File

@@ -8,6 +8,7 @@ type FinWithdrawApply struct {
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"`
Uid int `json:"uid" xorm:"not null default 0 comment('用户ID') index INT(10)"`
AdmId int `json:"adm_id" xorm:"not null default 0 comment('审核人ID,0为系统自动') INT(10)"`
FeeType int `json:"fee_type" xorm:"not null default 0 comment('审核人ID,0为系统自动') INT(10)"`
Amount string `json:"amount" xorm:"not null default 0.00 comment('提现金额') DECIMAL(10,2)"`
Memo string `json:"memo" xorm:"not null default '' comment('备注,失败请备注原因') VARCHAR(500)"`
Type int `json:"type" xorm:"not null default 1 comment('提现类型;1:手动;2:自动') TINYINT(1)"`


+ 13
- 0
app/db/model/user_virtual_coin_flow_aggregation.go Vedi File

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

type UserVirtualCoinFlowAggregation struct {
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"`
Uid int `json:"uid" xorm:"not null comment('用户id') index INT(11)"`
CoinId int `json:"coin_id" xorm:"not null comment('虚拟币id') INT(11)"`
TodayData string `json:"today_data" xorm:"not null comment('今日数量') DECIMAL(20,8)"`
ThisWeekData string `json:"this_week_data" xorm:"not null comment('本周数量') DECIMAL(20,8)"`
ThisMonthData string `json:"this_month_data" xorm:"not null comment('本月数量') DECIMAL(20,8)"`
NowData string `json:"now_data" xorm:"not null comment('当前数量') DECIMAL(20,8)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"`
}

+ 40
- 0
app/flexible_employment/db/db_flexible_employment_basic.go Vedi File

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

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

type FlexibleEmploymentBasicDb struct {
Db *xorm.Engine `json:"model"`
}

func (flexibleEmploymentBasicDb *FlexibleEmploymentBasicDb) Set() { // set方法
flexibleEmploymentBasicDb.Db = db.Db
}

func (flexibleEmploymentBasicDb *FlexibleEmploymentBasicDb) Get(masterId string) (m *model.FlexibleEmploymentBasic, err error) {
m = new(model.FlexibleEmploymentBasic)
has, err := flexibleEmploymentBasicDb.Db.Where("master_id = ?", masterId).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (flexibleEmploymentBasicDb *FlexibleEmploymentBasicDb) GetBasicByAppKey(appKey string) (m *model.FlexibleEmploymentBasic, err error) {
m = new(model.FlexibleEmploymentBasic)
has, err := flexibleEmploymentBasicDb.Db.Where("app_key = ?", appKey).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

+ 44
- 0
app/flexible_employment/db/db_flexible_employment_ord.go Vedi File

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

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

type FlexibleEmploymentOrdDb struct {
Db *xorm.Engine `json:"model"`
}

func (flexibleEmploymentOrdDb *FlexibleEmploymentOrdDb) Set(masterId string) { // set方法
flexibleEmploymentOrdDb.Db = db.DBs[masterId]
}

func (flexibleEmploymentOrdDb *FlexibleEmploymentOrdDb) Get(requestId string) (m *model.FlexibleEmploymentOrd, err error) {
m = new(model.FlexibleEmploymentOrd)
has, err := flexibleEmploymentOrdDb.Db.Where("request_id = ?", requestId).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (flexibleEmploymentOrdDb *FlexibleEmploymentOrdDb) Update(id interface{}, m *model.FlexibleEmploymentOrd, forceColums ...string) (int64, error) {
var (
affected int64
err error
)
if forceColums != nil {
affected, err = flexibleEmploymentOrdDb.Db.Where("id=?", id).Cols(forceColums...).Update(m)
} else {
affected, err = flexibleEmploymentOrdDb.Db.Where("id=?", id).Update(m)
}
if err != nil {
return 0, err
}
return affected, nil
}

+ 40
- 0
app/flexible_employment/db/db_flexible_employment_pupiao_basic.go Vedi File

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

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

type FlexibleEmploymentPuiaoBasicDb struct {
Db *xorm.Engine `json:"model"`
}

func (flexibleEmploymentPupiaoBasicDb *FlexibleEmploymentPuiaoBasicDb) Set() { // set方法
flexibleEmploymentPupiaoBasicDb.Db = db.Db
}

func (flexibleEmploymentPupiaoBasicDb *FlexibleEmploymentPuiaoBasicDb) GetBasic(masterId string) (m *model.FlexibleEmploymentPupiaoBasic, err error) {
m = new(model.FlexibleEmploymentPupiaoBasic)
has, err := flexibleEmploymentPupiaoBasicDb.Db.Where("master_id = ?", masterId).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (flexibleEmploymentPupiaoBasicDb *FlexibleEmploymentPuiaoBasicDb) GetBasicByAppId(appId string) (m *model.FlexibleEmploymentPupiaoBasic, err error) {
m = new(model.FlexibleEmploymentPupiaoBasic)
has, err := flexibleEmploymentPupiaoBasicDb.Db.Where("app_id = ?", appId).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

+ 44
- 0
app/flexible_employment/db/db_flexible_employment_pupiao_ord.go Vedi File

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

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

type FlexibleEmploymentPupiaoOrdDb struct {
Db *xorm.Engine `json:"model"`
}

func (flexibleEmploymentPupiaoOrdDb *FlexibleEmploymentPupiaoOrdDb) Set(masterId string) { // set方法
flexibleEmploymentPupiaoOrdDb.Db = db.DBs[masterId]
}

func (flexibleEmploymentPupiaoOrdDb *FlexibleEmploymentPupiaoOrdDb) Get(outBatchNo string) (m *model.FlexibleEmploymentPupiaoOrd, err error) {
m = new(model.FlexibleEmploymentPupiaoOrd)
has, err := flexibleEmploymentPupiaoOrdDb.Db.Where("out_batch_no = ?", outBatchNo).Get(m)
if err != nil {
return nil, logx.Error(err)
}
if has == false {
return nil, nil
}
return m, nil
}

func (flexibleEmploymentPupiaoOrdDb *FlexibleEmploymentPupiaoOrdDb) Update(id interface{}, m *model.FlexibleEmploymentPupiaoOrd, forceColums ...string) (int64, error) {
var (
affected int64
err error
)
if forceColums != nil {
affected, err = flexibleEmploymentPupiaoOrdDb.Db.Where("id=?", id).Cols(forceColums...).Update(m)
} else {
affected, err = flexibleEmploymentPupiaoOrdDb.Db.Where("id=?", id).Update(m)
}
if err != nil {
return 0, err
}
return affected, nil
}

+ 13
- 0
app/flexible_employment/db/model/flexible_employment_basic.go Vedi File

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

type FlexibleEmploymentBasic struct {
Id int `json:"id" xorm:"pk autoincr INT(11)"`
AppKey string `json:"app_key" xorm:"app_key"`
AppSecret string `json:"app_secret" xorm:"app_secret"`
SecretId string `json:"secret_id" xorm:"secret_id"`
CallbackUrl string `json:"callback_url" xorm:"callback_url"`
AgreementContent string `json:"agreement_content" xorm:"agreement_content"`
CompanyName string `json:"company_name" xorm:"company_name"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"`
}

+ 18
- 0
app/flexible_employment/db/model/flexible_employment_ord.go Vedi File

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

type FlexibleEmploymentOrd struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"`
ServiceId string `json:"service_id" xorm:"not null default '' comment('服务主体id') VARCHAR(255)"`
RequestId string `json:"request_id" xorm:"not null default '' comment('提现记录ID') VARCHAR(255)"`
Mobile string `json:"mobile" xorm:"not null default '' comment('手机号') VARCHAR(255)"`
Name string `json:"name" xorm:"not null default '' comment('姓名') VARCHAR(255)"`
Amount string `json:"amount" xorm:"not null default 0.00 comment('提现金额') DECIMAL(8,2)"`
Identity string `json:"identity" xorm:"not null default 0.00 comment('证件号码') DECIMAL(8,2)"`
BankAccount string `json:"bank_account" xorm:"not null default 0 comment('入款账号 银行卡提现此字段传入员工绑定的银行卡,支付宝提现此字段请传入员工绑定的支付宝账号') TINYINT(1)"`
SettleType string `json:"settle_type" xorm:"not null default '' comment('商户提现账户类型 银行通道:BANK, 微信通道:WECHAT, 支付宝通道:ALIPAY 例如:传BANK会从商户银行账户扣款') CHAR(50)"`
CallbackDataForTradeResult string `json:"callback_data_for_trade_result" xorm:"not null comment('交易结果通知') TEXT"`
State int `json:"state" xorm:"not null default 0 comment('状态(0:待提交易 1:已提交交易 2:交易成功 3:交易失败)') TINYINT(1)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"`
}

+ 14
- 0
app/flexible_employment/db/model/flexible_employment_pupiao_basic.go Vedi File

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

type FlexibleEmploymentPupiaoBasic struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
MasterId int `json:"master_id" xorm:"not null default 0 comment('站长ID') INT(11)"`
AppId string `json:"app_id" xorm:"not null default '' comment('appId') VARCHAR(255)"`
AppSecret string `json:"app_secret" xorm:"not null default '' comment('appSecret') VARCHAR(255)"`
HrCompanyId string `json:"hr_company_id" xorm:"not null default '' comment('hrcompanyId') VARCHAR(255)"`
SettleAccountId string `json:"settle_account_id" xorm:"not null default '' comment('settleAccountId') VARCHAR(255)"`
CallbackUrl string `json:"callback_url" xorm:"not null default '' comment('回调地址') VARCHAR(255)"`
WithdrawalType int `json:"withdrawal_type" xorm:"not null default 1 comment('提现方式(1:支付宝 2:银行卡)') TINYINT(1)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"`
}

+ 21
- 0
app/flexible_employment/db/model/flexible_employment_pupiao_ord.go Vedi File

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

type FlexibleEmploymentPupiaoOrd struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"not null default 0 comment('用户id') INT(11)"`
WithdrawApplyId int64 `json:"withdraw_apply_id" xorm:"not null default 0 comment('提现记录ID') BIGINT(20)"`
OutBatchNo string `json:"out_batch_no" xorm:"not null default '' comment('外部商户批次订单号') VARCHAR(255)"`
PlatformBatchNo string `json:"platform_batch_no" xorm:"not null default '' comment('平台批次订单号') VARCHAR(255)"`
TotalAmount string `json:"total_amount" xorm:"not null default 0.00 comment('总金额') DECIMAL(8,2)"`
ValidTotalFeeAmount string `json:"valid_total_fee_amount" xorm:"not null default 0.00 comment('平台总服务费金额') DECIMAL(8,2)"`
BatchStatus int `json:"batch_status" xorm:"not null default 0 comment('批次状态(0:待创建 1:制单失败 2:待确认支付 3:支付成功 4:支付失败)') TINYINT(1)"`
SettleType string `json:"settle_type" xorm:"not null default '' comment('结算方式(CARD:银行卡,ALIPAY:支付宝,WECHAT:微信)') CHAR(50)"`
PayeeNo string `json:"payee_no" xorm:"not null default '' comment('收款人账户') CHAR(50)"`
PayeePhone string `json:"payee_phone" xorm:"not null default '' comment('收款人手机号') CHAR(50)"`
PayeeName string `json:"payee_name" xorm:"not null default '' comment('收款人姓名') CHAR(50)"`
PayeeIdCard string `json:"payee_id_card" xorm:"not null default '' comment('收款人身份证号') CHAR(50)"`
CallbackDataForReceiveOrder string `json:"callback_data_for_receive_order" xorm:"not null comment('制单回调通知') TEXT"`
CallbackDataForTradeResult string `json:"callback_data_for_trade_result" xorm:"not null comment('交易结果通知') TEXT"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"`
}

+ 13
- 0
app/flexible_employment/db/model/flexible_employment_pupiao_user_info.go Vedi File

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

type FlexibleEmploymentPupiaoUserInfo struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"not null default 0 INT(11)"`
Name string `json:"name" xorm:"not null default '' comment('姓名') VARCHAR(255)"`
Mobile string `json:"mobile" xorm:"not null default '' comment('手机号') VARCHAR(255)"`
Identity string `json:"identity" xorm:"not null default '' comment('证件号码') VARCHAR(255)"`
BankAccountNo string `json:"bank_account_no" xorm:"not null default '' comment('默认银行账号') VARCHAR(255)"`
AlipayAccountNo string `json:"alipay_account_no" xorm:"not null default '' comment('默认支付宝账号') VARCHAR(255)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"`
}

+ 17
- 0
app/flexible_employment/db/model/flexible_employment_user_info.go Vedi File

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

type FlexibleEmploymentUserInfo struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
Uid int `json:"uid" xorm:"not null default 0 INT(11)"`
Name string `json:"name" xorm:"not null default '' comment('姓名') VARCHAR(255)"`
Mobile string `json:"mobile" xorm:"not null default '' comment('手机号') VARCHAR(255)"`
Identity string `json:"identity" xorm:"not null default '' comment('证件号码') VARCHAR(255)"`
BankAccountNo string `json:"bank_account_no" xorm:"not null default '' comment('默认银行账号') VARCHAR(255)"`
AlipayAccountNo string `json:"alipay_account_no" xorm:"not null default '' comment('默认支付宝账号') VARCHAR(255)"`
IdentityFrontBase64 string `json:"identity_front_base64" xorm:"not null comment('证件头像面图片base64(图片大小不能超过3M)') TEXT"`
IdentityBackgroundBase64 string `json:"identity_background_base64" xorm:"not null comment('证件国徽面图片base64(图片大小不能超过3M)') TEXT"`
ContractId string `json:"contract_id" xorm:"not null comment('合同id') CHAR(50)"`
State int `json:"state" xorm:"not null default 0 comment('状态(0:未签约(员工未同步) 1:待签约(员工已同步,但未确认签约)2:签约文件生成中(用户已确认签署,合同文件正在生成,此状态可发起提现) 3:签约完成 (用户已签约,签约合同生成完成))') TINYINT(1)"`
CreateAt string `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') DATETIME"`
UpdateAt string `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('更新时间') DATETIME"`
}

+ 35
- 0
app/flexible_employment/enum/enum_api.go Vedi File

@@ -0,0 +1,35 @@
package enum

type GongMaoMethodName string

const (
MerchantContractGetList = "/api/merchant/contract/getList"
MerchantEmployeeSyncInfo = "/api/merchant/employee/syncInfo"
MerchantEmployeeSignContract = "/api/merchant/employee/signContract"
MerchantQueryBalance = "/api/merchant/queryBalance"
MerchantDoSinglePayment = "/api/merchant/doSinglePayment"
MerchantEmployeeGetContractStatusByContractId = "/api/merchant/employee/getContractStatusByContractId"
MerchantEmployeeDeleteContract = "/api/merchant/employee/deleteContract"
MerchantEmployeeUpdateEmployee = "/api/merchant/employee/updateEmployee"
)

func (gt GongMaoMethodName) String() string {
switch gt {
case MerchantContractGetList:
return "查询电签时需要的合同模板列表"
case MerchantEmployeeSyncInfo:
return "发起签署"
case MerchantEmployeeSignContract:
return "确认签署"
case MerchantEmployeeGetContractStatusByContractId:
return "通过合同id查询电签结果"
case MerchantEmployeeDeleteContract:
return "员工解除签署"
case MerchantDoSinglePayment:
return "提现"
case MerchantEmployeeUpdateEmployee:
return "更新员工默认手机号或者账号"
default:
return "未知"
}
}

+ 22
- 0
app/flexible_employment/enum/enum_pupiao_api.go Vedi File

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

type PuPiaoMethodName string

const (
OpenApiContractSignApply = "/open/api/contract/signApply"
OpenApiPaymentReceiveOrder = "/open/api/payment/receiveOrder"
OpenApiPaymentConfirmPay = "/open/api/payment/confirmPay"
)

func (gt PuPiaoMethodName) String() string {
switch gt {
case OpenApiContractSignApply:
return "申请签约接口"
case OpenApiPaymentReceiveOrder:
return "发起制单"
case OpenApiPaymentConfirmPay:
return "确认支付"
default:
return "未知"
}
}

+ 9
- 0
app/flexible_employment/md/md_api.go Vedi File

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

type CurlPuPiaoConfirmPayResponse struct {
IsSuccess string `json:"isSuccess"`
Data interface{} `json:"data"`
Charset string `json:"charset"`
ErrorMsg string `json:"errorMsg"`
ErrorCode string `json:"errorCode"`
}

+ 58
- 0
app/flexible_employment/md/md_call_back.go Vedi File

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

type CallbackRequestForPuPiao struct {
AppId string `json:"appId"` //appId
PlatformOrderNo string `json:"platformOrderNo"` //平台订单号
NotifyType string `json:"notifyType"` //通知业务类型
NotifyContent string `json:"notifyContent"` //业务参数加密密文 (根据不同通知类型解密后参数不同,具体请参考通知类型参数说明)
Sign string `json:"sign"` //签名字符串
}

type CallbackRequestForPuPiaoByRECEIVEORDER struct {
PlatformBatchNo string `json:"platformBatchNo"` //平台批次订单号
OutBatchNo string `json:"outBatchNo"` //外部商户批次订单号
TotalCount string `json:"totalCount"` //总笔数
TotalAmount string `json:"totalAmount"` //总金额
ValidTotalCount string `json:"validTotalCount"` //有效订单(平台收单成功)-总笔数
ValidTotalAmount string `json:"validTotalAmount"` //有效订单(平台收单成功)-总金额
ValidTotalFeeAmount string `json:"validTotalFeeAmount"` //有效订单(平台收单成功)-平台总服务费金额
BatchStatus string `json:"batchStatus"` //批次状态 RECEIVE_FAIL:收单失败(整批次下全部失败) WAIT_CONFIRM:待确认支付(有效订单笔数大于0时,为此批次状态)
ItemList []struct {
PlatformOrderNo string `json:"platformOrderNo"` //单笔平台订单号
OutTradeNo string `json:"outTradeNo"` //单笔外部商户订单号(批次下唯一不可重复)
SettleType string `json:"settleType"` //结算方式(CARD:银行卡,ALIPAY:支付宝,WECHAT:微信)
PayeeName string `json:"payeeName"` //收款人姓名
PayeeIdCard string `json:"payeeIdCard"` //收款人身份证号
PayeePhone string `json:"payeePhone"` //收款人手机号
PayeeNo string `json:"payeeNo"` //收款人账户
OrderAmount string `json:"orderAmount"` //订单金额(最多保留两位小数)
OrderStatus string `json:"orderStatus"` //单笔订单状态,见以下取值范围 RECEIVE_FAIL:收单失败 WAIT_CONFIRM:待确认支付
PayeeBankName string `json:"payeeBankName"` //收款人银行名称
PayeeBranchNo string `json:"payeeBranchNo"` //收款人分行联行号
OrderMemo string `json:"orderMemo"` //付款备注摘要
FeeAmount string `json:"feeAmount"` //单笔平台服务费金额
ErrorCode string `json:"errorCode"` //单笔异常code
ErrorMsg string `json:"errorMsg"` //单笔异常msg
} `json:"itemList"` //批次明细list
}

type CallbackRequestForPuPiaoByTRADERESULT struct {
PlatformBatchNo string `json:"platformBatchNo"` //平台批次订单号
OutBatchNo string `json:"outBatchNo"` //外部商户批次订单号
PlatformOrderNo string `json:"platformOrderNo"` //单笔平台订单号
OutTradeNo string `json:"outTradeNo"` //单笔外部商户订单号(批次下唯一不可重复)
SettleType string `json:"settleType"` //结算方式(CARD:银行卡,ALIPAY:支付宝,WECHAT:微信)
PayeeName string `json:"payeeName"` //收款人姓名
PayeeIdCard string `json:"payeeIdCard"` //收款人身份证号
PayeePhone string `json:"payeePhone"` //收款人手机号
PayeeNo string `json:"payeeNo"` //收款人账户
OrderAmount string `json:"orderAmount"` //订单金额(最多保留两位小数)
OrderStatus string `json:"orderStatus"` //单笔订单状态,见以下取值范围 RECEIVE_FAIL:收单失败 WAIT_CONFIRM:待确认支付
TradeTime string `json:"tradeTime"` //交易时间(格式 yyyy-MM-dd HH:mm:ss)
PayeeBankName string `json:"payeeBankName"` //收款人银行名称
PayeeBranchNo string `json:"payeeBranchNo"` //收款人分行联行号
OrderMemo string `json:"orderMemo"` //付款备注摘要
FeeAmount string `json:"feeAmount"` //单笔平台服务费金额
ErrorCode string `json:"errorCode"` //单笔异常code
ErrorMsg string `json:"errorMsg"` //单笔异常msg
}

+ 77
- 0
app/flexible_employment/md/mq.go Vedi File

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

const RobotQrcodeMacLoginQueue = "cloud_issuance_async_mlogin"
const CloudIssuanceMsgCallBackQueue = "cloud_issuance_msg_call_back" //云发单消息回调

type CloudIssuanceAsyncMLogin struct {
UserId string `json:"user_id"` //用户id
MasterId string `json:"master_id"` //站长id
WId string `json:"wId"` //实例id
RobotId int `json:"robot_id"` //机器人id
QrCodeUrl string `json:"qrCodeUrl"`
}

const UserWithdrawApplyExchange = "zhios.app.user.withdraw.apply.exchange"
const ZhiosCapitalPoolOrderTotalExchange = "zhios.capital_pool.order_total.exchange"
const CloudIssuanceMsgCallBackExchange = "zhios.cloud.issuance.msg.callback.exchange"

const DouShenUserRegisterExchange = "zhios.doushen.user.register.exchange"
const FastReturnOrder = "zhios.order.fast.return.exchange"

const (
DouShenUserRegisterRoutKeyForOfficial = "official" // 官方
DouShenUserRegisterRoutKeyForOperationCenter = "operation_center" // 运营中心
DouShenUserRegisterRoutKeyForMyRecommender = "my_recommender" // 我的推荐人
DouShenUserRegisterRoutKeyForMyFans = "my_fans" // 我的粉丝
DouShenUserRegisterRoutKeyForUserRegisterCommUpLv = "user_register_comm_up_lv" // 用户注册自动升级(给推荐人)
FastReturnOrderRoutKeyForOrderPay = "order_pay"
FastReturnOrderRoutKeyForOrderRefund = "order_refund"
FastReturnOrderRoutKeyForOrderSuccess = "order_success"
ZhiosCapitalPoolOrderTotalStr = "order_total"
)

type DouShenUserRegisterMessageStructForOfficial struct {
MasterId string `json:"master_id"`
Phone int64 `json:"phone"`
Uid int64 `json:"uid"`
}
type DouShenUserRegisterMessageStructForMyFans struct {
MasterId string `json:"master_id"`
Phone int64 `json:"phone"`
Uid int64 `json:"uid"`
}
type DouShenUserRegisterMessageStructForMyRecommender struct {
MasterId string `json:"master_id"`
Phone int64 `json:"phone"`
Uid int64 `json:"uid"`
RecommenderUid int64 `json:"recommender_uid"`
RecommenderPhone string `json:"recommender_phone"`
}
type DouShenUserRegisterMessageStructForOperationCenter struct {
MasterId string `json:"master_id"`
Phone int64 `json:"phone"`
Uid int64 `json:"uid"`
OperationCenterUid int64 `json:"operation_center_uid"`
OperationCenterPhone string `json:"operation_center_phone"`
}
type DouShenUserRegisterMessageStructForCommUpLv struct {
MasterId string `json:"master_id"`
Uid int64 `json:"uid"`
}

type ZhiosFatReturnOrderPay struct {
Uid string `json:"uid"`
Mid string `json:"mid"`
Oid string `json:"oid"`
Name string `json:"name"`
Prd string `json:"prd"`
}

type ZhiosCapitalPoolOrderTotal struct {
Uid []string `json:"uid"`
Mid string `json:"mid"`
Runtime int64 `json:"runtime"`
TotalTime int64 `json:"totalTime"`
BonusLevelType int `json:"bonusLevelType"`
Level string `json:"level"`
}

+ 105
- 0
app/flexible_employment/svc/svc_fin_withdraw_apply.go Vedi File

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

import (
"applet/app/db"
"applet/app/db/model"
model2 "applet/app/flexible_employment/db/model"
"applet/app/svc"
"applet/app/utils"
"errors"
"time"
"xorm.io/xorm"
)

func DealFailResult(sess *xorm.Session, apply *model.FinWithdrawApply, masterId, errMsg string) (err error) {
userProfile, err := db.UserFindByIDWithSession(sess, apply.Uid)
if err != nil {
return err
}

//1、修改提现单为失败
apply.State = 3
apply.Memo = errMsg
updateAck, err := sess.Where("id=?", apply.Id).Cols("state", "memo").Update(apply)
if err != nil {
return err
}
if updateAck <= 0 {
return errors.New("更新提现单失败")
}
updateAck, err = sess.Where("request_id=?", apply.Id).Cols("state", "callback_data_for_trade_result").Update(model2.FlexibleEmploymentOrd{
State: 3,
CallbackDataForTradeResult: errMsg,
})
if err != nil {
return err
}
if updateAck <= 0 {
return errors.New("更新工猫记录失败")
}

//2、判断类型 加回手续费
var finUserFlow model.FinUserFlow
has, err := sess.Where("other_id = ?", apply.Id).Get(&finUserFlow)
if err != nil {
return
}
var sysFee = 0.00
if has && apply.FeeType == 1 {
apply.Amount = utils.Float64ToStr(utils.StrToFloat64(apply.Amount) + utils.StrToFloat64(finUserFlow.SysFee))
sysFee = utils.StrToFloat64(finUserFlow.SysFee)
}

//3、退回余额
cb, err := svc.HandleBalanceDistributedLock(masterId, utils.IntToStr(apply.Uid), "withdraw_consume")
if err != nil {
return
}
if cb != nil {
defer cb()
}
var beforeAmount = userProfile.FinValid
userProfile.FinValid = utils.Float64ToStrPrec4(utils.StrToFloat64(beforeAmount) + utils.StrToFloat64(apply.Amount))
_, err = db.UserUpdateWithSession(sess, userProfile.Uid, userProfile, "fin_valid")
if err != nil {
return err
}

//4、插入流水表
newFinUserFlow := model.FinUserFlow{
Type: 0,
Uid: userProfile.Uid,
Amount: apply.Amount,
BeforeAmount: beforeAmount,
AfterAmount: userProfile.FinValid,
OrdType: "withdraw",
OrdAction: 22,
PaymentType: 1,
SysFee: utils.Float64ToStrPrec4(sysFee),
OrdDetail: "",
OtherId: apply.Id,
OrdTitle: "提现退回",
State: 2,
OrdTime: int(apply.CreateAt.Unix()),
CreateAt: time.Now(),
UpdateAt: time.Now(),
}
_, err = db.InsertCommWithSession(sess, &newFinUserFlow)
if err != nil {
return err
}
return nil
}

func DealSuccessResult(sess *xorm.Session, apply *model.FinWithdrawApply) (err error) {
//1、修改提现单为成功
apply.State = 2
updateAck, err := sess.Where("id=?", apply.Id).Cols("state").Update(apply)
if err != nil {
return err
}
if updateAck <= 0 {
return errors.New("更新提现单失败")
}
return nil
}

+ 99
- 0
app/flexible_employment/utils/aes/utils.go Vedi File

@@ -0,0 +1,99 @@
package aes

import (
"bytes"
"crypto/aes"
"encoding/base64"
"fmt"
"net/url"
)

// 加密
func AesEncryptByECB(key []byte, plaintext string) (string, error) {
block, err := aes.NewCipher(key)
if err != nil {
return "", err
}

plainBytes := []byte(plaintext)
// PKCS5Padding
pad := block.BlockSize() - len(plainBytes)%block.BlockSize()
plainBytes = append(plainBytes, bytes.Repeat([]byte{byte(pad)}, pad)...)

// ECB模式
encrypted := make([]byte, len(plainBytes))
for bs, be := 0, block.BlockSize(); bs <= len(plainBytes)-block.BlockSize(); bs, be = bs+block.BlockSize(), be+block.BlockSize() {
block.Encrypt(encrypted[bs:be], plainBytes[bs:be])
}

return url.QueryEscape(base64.StdEncoding.EncodeToString(encrypted)), nil
}

// AesDecryptByECB 解密AES ECB加密的字符串
func AesDecryptByECB(key []byte, ciphertext string) (string, error) {

// 先进行URL解码

decodedCiphertext, err := url.QueryUnescape(ciphertext)

if err != nil {

return "", err

}

// Base64解码

encrypted, err := base64.StdEncoding.DecodeString(decodedCiphertext)

if err != nil {

return "", err

}

block, err := aes.NewCipher(key)

if err != nil {

return "", err

}

// ECB模式

decrypted := make([]byte, len(encrypted))

for bs, be := 0, block.BlockSize(); bs < len(encrypted); bs, be = bs+block.BlockSize(), be+block.BlockSize() {

block.Decrypt(decrypted[bs:be], encrypted[bs:be])

}

// 去除PKCS5Padding

decrypted = PKCS5UnPadding(decrypted)

if decrypted == nil {

return "", fmt.Errorf("invalid PKCS5 padding")

}

return string(decrypted), nil

}

// PKCS5UnPadding 去除PKCS5Padding
func PKCS5UnPadding(data []byte) []byte {
length := len(data)

unpadding := int(data[length-1])

if unpadding > length {

return nil

}
return data[:(length - unpadding)]
}

+ 26
- 0
app/flexible_employment/utils/algorithm.go Vedi File

@@ -0,0 +1,26 @@
package utils

import (
"math/rand"
"time"
)

//RED_PACKET_MIN_MONEY 红包最小金额(单位:分)
const RED_PACKET_MIN_MONEY = 1

//DoubleAverage 二倍均值算法
func DoubleAverage(count, amount int64) int64 {
if count == 1 {
return amount
}
//计算出最大可用金额
max := amount - RED_PACKET_MIN_MONEY*count
//计算出最大可用平均值
avg := max / count
//二倍均值基础上再加上最小金额 防止出现金额为0
avg2 := 2*avg + RED_PACKET_MIN_MONEY
//随机红包金额序列元素,把二倍均值作为随机的最大数
rand.Seed(time.Now().UnixNano())
x := rand.Int63n(avg2) + RED_PACKET_MIN_MONEY
return x
}

+ 60
- 0
app/flexible_employment/utils/rpc_client.go Vedi File

@@ -0,0 +1,60 @@
package utils

import (
"applet/pkg/pb"
"context"
"fmt"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"strconv"
"time"
)

func GetBusinessIntClient(url, port string) pb.BusinessIntClient {
target := fmt.Sprintf("%s:%s", url, port)
conn, err := grpc.Dial(target, grpc.WithInsecure())
if err != nil {
fmt.Println(err)
return nil
}
return pb.NewBusinessIntClient(conn)
}

func GetBusinessExtClient(url, port string) pb.BusinessExtClient {
target := fmt.Sprintf("%s:%s", url, port)
conn, err := grpc.Dial(target, grpc.WithInsecure())
//defer conn.Close()
if err != nil {
fmt.Println(err)
return nil
}
return pb.NewBusinessExtClient(conn)
}

func GetLogicExtClient(url, port string) pb.LogicExtClient {
target := fmt.Sprintf("%s:%s", url, port)
conn, err := grpc.Dial(target, grpc.WithInsecure())
if err != nil {
fmt.Println(err)
return nil
}
return pb.NewLogicExtClient(conn)
}

func GetCtx(token, userId, deviceId, masterId string) context.Context {
if userId == "" {
userId = "1"
}
if deviceId == "" {
deviceId = "1"
}
if token == "" {
token = "0"
}
return metadata.NewOutgoingContext(context.TODO(), metadata.Pairs(
"user_id", userId,
"device_id", deviceId,
"token", token,
"master_id", masterId,
"request_id", strconv.FormatInt(time.Now().UnixNano(), 10)))
}

+ 10
- 0
app/flexible_employment/utils/string.go Vedi File

@@ -0,0 +1,10 @@
package utils

func ContainerStr(slice []string, element string) bool {
for _, e := range slice {
if e == element {
return true
}
}
return false
}

+ 155
- 0
app/lib/flexible_employment/gongmao.go Vedi File

@@ -0,0 +1,155 @@
package flexible_employment

import (
"applet/app/cfg"
"applet/app/utils"
"bytes"
"crypto/md5"
"crypto/tls"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"net/url"
"sort"
"strconv"
"strings"
"time"
)

type GongMao struct {
AppKey string
AppSecret string
Nonce string
Timestamp string
ServiceId string
Sign string
}

const postUrlForPrd = "https://openapi.gongmall.com"
const postUrlForDev = "https://openapi-qa.gongmall.com"

func New(appKey, appSecret, serviceId string) *GongMao {
return &GongMao{
AppKey: appKey,
AppSecret: appSecret,
Nonce: randomString(32),
Timestamp: "", // 生成timestamp(当前毫秒时间戳)
ServiceId: serviceId,
Sign: "",
}
}

// generateSign 生成签名
func (gm *GongMao) generateSign(params map[string]interface{}, appSecret string) string {
var keys []string
for k := range params {
keys = append(keys, k)
}
sort.Strings(keys)
var stringA bytes.Buffer
for _, k := range keys {
if stringA.Len() > 0 {
stringA.WriteString("&")
}
stringA.WriteString(url.QueryEscape(k))
stringA.WriteString("=")
stringA.WriteString(utils.AnyToString(params[k]))
}

stringSignTemp := stringA.String() + "&appSecret=" + appSecret
h := md5.New()
h.Write([]byte(stringSignTemp))
sign := hex.EncodeToString(h.Sum(nil))
return strings.ToUpper(sign)
}

func (gm *GongMao) Curl(uri string, params map[string]interface{}) (result map[string]interface{}, err error) {
// 准备请求参数
gm.Timestamp = strconv.FormatInt(time.Now().UnixNano()/int64(time.Millisecond), 10)
paramData := make(map[string]interface{})
paramData = gm.mergeMaps(map[string]interface{}{
"appKey": gm.AppKey,
"nonce": gm.Nonce,
"serviceId": gm.ServiceId,
"timestamp": gm.Timestamp,
}, params)

// 生成签名
paramData["sign"] = gm.generateSign(paramData, gm.AppSecret)

// 编码请求参数为URL编码的字符串
form := url.Values{}
for key, value := range paramData {
form.Set(key, utils.AnyToString(value))
}
requestBody := form.Encode()

// 构造请求
var url string
fmt.Println("prd::::::::::", cfg.Prd)
if cfg.Prd {
url = postUrlForPrd + uri
} else {
url = postUrlForDev + uri
}
fmt.Println("url::::::::::", url)

req, err := http.NewRequest("POST", url, bytes.NewBufferString(requestBody))
if err != nil {
return
}

// 设置请求头
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")

// 发送请求
client := &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
}
resp, err := client.Do(req)
if err != nil {
return
}
defer resp.Body.Close()

// 读取响应体
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
return
}

// 打印响应内容
fmt.Printf("Response: %s\n", body)

// 解析JSON响应
err = json.Unmarshal(body, &result)
if err != nil {
return
}
return
}

// 合并map
func (gm *GongMao) mergeMaps(map1, map2 map[string]interface{}) map[string]interface{} {
for key, value := range map2 {
map1[key] = value
}
return map1
}

// 随机生成指定位数的大写字母和数字的组合
func randomString(ln int) string {
letters := []rune("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")
b := make([]rune, ln)
r := rand.New(rand.NewSource(time.Now().UnixNano()))
for i := range b {
b[i] = letters[r.Intn(len(letters))]
}

return string(b)
}

+ 117
- 0
app/lib/flexible_employment/pupiao.go Vedi File

@@ -0,0 +1,117 @@
package flexible_employment

import (
"applet/app/cfg"
"bytes"
"crypto/md5"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"sort"
"strconv"
"time"
)

type PuPiao struct {
AppId string
Charset string
Version string
Sign string
RequestId string
AppSecret string
}

const urlForPrd = "https://openapi.gongmall.com"
const urlForDev = "http://api.testlg.cn"

func NewPuPiao(appId, appSecret string) *PuPiao {
return &PuPiao{
AppId: appId,
Charset: "UTF-8",
Version: "1.0",
Sign: "",
RequestId: "",
AppSecret: appSecret,
}
}

// generateSign 生成签名
func (gm *PuPiao) generateSign(params map[string]interface{}, appSecret string) string {
var keys []string
for k := range params {
keys = append(keys, k)
}
sort.Strings(keys)
var stringA = map[string]interface{}{}
for _, k := range keys {
stringA[k] = params[k]
}
str, _ := json.Marshal(stringA)
paramJson := string(str)
stringSignTemp := paramJson + appSecret
h := md5.New()
h.Write([]byte(stringSignTemp))
sign := hex.EncodeToString(h.Sum(nil))
return sign
}

func (gm *PuPiao) Curl(uri string, params map[string]interface{}) (result map[string]interface{}, err error) {
// 准备请求参数
gm.RequestId = strconv.FormatInt(time.Now().UnixNano()/int64(time.Microsecond), 10) //请求Id,每次请求唯一
paramData := make(map[string]interface{})
paramData = gm.mergeMaps(map[string]interface{}{
"appId": gm.AppId,
"charset": gm.Charset,
"requestId": gm.RequestId,
"version": gm.Version,
}, params)

// 生成签名
paramData["sign"] = gm.generateSign(paramData, gm.AppSecret)
b, err := json.Marshal(paramData)
if err != nil {
return
}

// 构造请求
var url string
if cfg.Prd {
url = urlForPrd + uri
} else {
url = urlForDev + uri
}
fmt.Println("url::::::::::", url)
postBody, err := gm.httpPostBody(url, b)
if err != nil {
return
}
// 打印响应内容
fmt.Printf("Response: %s\n", postBody)

// 解析JSON响应
err = json.Unmarshal(postBody, &result)
if err != nil {
return
}
return
}

// 合并map
func (gm *PuPiao) mergeMaps(map1, map2 map[string]interface{}) map[string]interface{} {
for key, value := range map2 {
map1[key] = value
}
return map1
}

func (gm *PuPiao) httpPostBody(url string, msg []byte) ([]byte, error) {
resp, err := http.Post(url, "application/json;charset=utf-8", bytes.NewBuffer(msg))
if err != nil {
return []byte(""), err
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
return body, err
}

+ 3
- 0
app/utils/convert.go Vedi File

@@ -278,6 +278,9 @@ func Float64ToStr(f float64) string {
func Float64ToStrPrec1(f float64) string {
return strconv.FormatFloat(f, 'f', 1, 64)
}
func Float64ToStrPrec4(f float64) string {
return strconv.FormatFloat(f, 'f', 4, 64)
}

func Float32ToStr(f float32) string {
return Float64ToStr(float64(f))


+ 48
- 42
consume/init.go Vedi File

@@ -20,47 +20,46 @@ func initConsumes() {
//jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder
//

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.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.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal
jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy
jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
//jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
//jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
//
jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder

jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser

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
jobs[consumeMd.ZhiosTaskTotal] = ZhiosTaskTotal
//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

//

@@ -80,14 +79,21 @@ func initConsumes() {
//jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume

//////////////////////////////////////// oneCircles /////////////////////////////////////////////////////
//jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
//jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
//
jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume
jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume
jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume
//jobs[consumeMd.OneCirclesSignInCopyGreenEnergyFunName] = OneCirclesSignInCopyGreenEnergyConsume

//////////////////////////////////////// withdraw /////////////////////////////////////////////////////
//jobs[consumeMd.WithdrawConsumeFunName] = WithdrawConsume
//jobs[consumeMd.FlexibleEmploymentWithdrawForGongMaoConsumeFunName] = FlexibleEmploymentWithdrawForGongMaoConsume
//jobs[consumeMd.FlexibleEmploymentWithdrawForPupiaoConsumeFunName] = FlexibleEmploymentWithdrawForPupiaoConsume

//jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume //绿色双链积分
//jobs[consumeMd.ZhiosMallGreenCoinConsumeFunName] = ZhiosMallGreenCoinConsume //绿色双链积分
//jobs[consumeMd.ZhiosOneCirclesCoinConsumeFunName] = ZhiosOneCirclesCoinConsume //一个圈圈虚拟币变化
}

func Run() {


+ 109
- 49
consume/md/consume_key.go Vedi File

@@ -398,6 +398,15 @@ var RabbitMqQueueKeyList = []*MqQueue{
BindKey: "",
ConsumeFunName: "ZhiosMallGreenCoinConsume",
},
{
ExchangeName: "canal.topic",
Name: "user_virtual_coin_flow_aggregation",
Type: TopicQueueType,
IsPersistent: false,
RoutKey: "canal_user_virtual_coin_flow_aggregation",
BindKey: "",
ConsumeFunName: "ZhiosOneCirclesCoinConsume",
},
{
ExchangeName: "canal.topic",
Name: "canal_user_virtual_coin_flow",
@@ -425,6 +434,33 @@ var RabbitMqQueueKeyList = []*MqQueue{
BindKey: "",
ConsumeFunName: "OneCirclesStartLevelDividendConsume",
},
{
ExchangeName: "one.circles",
Name: "one_circles_auto_exchange_green_energy_to_person",
Type: TopicQueueType,
IsPersistent: false,
RoutKey: "auto_exchange_green_energy_to_person",
BindKey: "",
ConsumeFunName: "OneCirclesActivityCoinAutoExchangeGreenEnergyConsume",
},
{
ExchangeName: "one.circles",
Name: "one_circles_auto_exchange_green_energy_to_team",
Type: TopicQueueType,
IsPersistent: false,
RoutKey: "auto_exchange_green_energy_to_team",
BindKey: "",
ConsumeFunName: "OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume",
},
{
ExchangeName: "one.circles",
Name: "one_circles_settlement_public_give_activity_coin",
Type: TopicQueueType,
IsPersistent: false,
RoutKey: "settlement_public_give_activity_coin",
BindKey: "",
ConsumeFunName: "OneCirclesSettlementPublicGiveActivityCoinConsume",
},
{
ExchangeName: "one.circles",
Name: "one_circles_sign_in_green_energy_copy",
@@ -443,56 +479,80 @@ var RabbitMqQueueKeyList = []*MqQueue{
BindKey: "",
ConsumeFunName: "WithdrawConsume",
},
{
ExchangeName: "zhios.app.user.withdraw.apply.flexible.employment.exchange",
Name: "zhios_app_user_withdraw_apply_gongmao_queue",
Type: DirectQueueType,
IsPersistent: false,
RoutKey: "gongmao",
BindKey: "",
ConsumeFunName: "FlexibleEmploymentWithdrawForGongMaoConsume",
},
{
ExchangeName: "zhios.app.user.withdraw.apply.flexible.employment.exchange",
Name: "zhios_app_user_withdraw_apply_pupiao_queue",
Type: DirectQueueType,
IsPersistent: false,
RoutKey: "pupiao",
BindKey: "",
ConsumeFunName: "FlexibleEmploymentWithdrawForPupiaoConsume",
},
}

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"
ZhiosUserRelateFunName = "ZhiosUserRelate"
ZhiosIntegralProxyRechargeFunName = "ZhiosIntegralProxyRecharge"
ZhiosMallGreenCoinConsumeFunName = "ZhiosMallGreenCoinConsume"
ZhiosOneCirclesCoinConsumeFunName = "ZhiosOneCirclesCoinConsume"
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"
OneCirclesActivityCoinAutoExchangeGreenEnergyFunName = "OneCirclesActivityCoinAutoExchangeGreenEnergyConsume"
OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName = "OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume"
OneCirclesSettlementPublicGiveActivityCoinFunName = "OneCirclesSettlementPublicGiveActivityCoinConsume"
WithdrawConsumeFunName = "WithdrawConsume"
FlexibleEmploymentWithdrawForGongMaoConsumeFunName = "FlexibleEmploymentWithdrawForGongMaoConsume"
FlexibleEmploymentWithdrawForPupiaoConsumeFunName = "FlexibleEmploymentWithdrawForPupiaoConsume"
ZhiosTaskTotal = "zhiosTaskTotal"
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"

)

+ 150
- 0
consume/one_circles_activity_coin_auto_exchange_green_energy_consume.go Vedi File

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

import (
"applet/app/cfg"
"applet/app/db"
utils2 "applet/app/utils"
"applet/app/utils/logx"
"applet/consume/md"
"applet/mall/utils"
"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"
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/one_circles"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/enum"
"encoding/json"
"errors"
"fmt"
"github.com/streadway/amqp"
"time"
)

func OneCirclesActivityCoinAutoExchangeGreenEnergyConsume(queue md.MqQueue) {
fmt.Println(">>>>>>>>>>>>OneCirclesActivityCoinAutoExchangeGreenEnergyConsume>>>>>>>>>>>>")
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)

one_circles.Init(cfg.RedisAddr)

var res amqp.Delivery
var ok bool
for {
res, ok = <-delivery
if ok == true {
err = handleOneCirclesActivityCoinAutoExchangeGreenEnergyConsume(res.Body)
if err != nil {
fmt.Println("OneCirclesActivityCoinAutoExchangeGreenEnergyConsume_ERR:::::", err.Error())
utils2.FilePutContents("OneCirclesActivityCoinAutoExchangeGreenEnergyConsume_ERR", utils2.SerializeStr(map[string]interface{}{
"body": res.Body,
"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 handleOneCirclesActivityCoinAutoExchangeGreenEnergyConsume(msgData []byte) error {
time.Sleep(time.Duration(2) * time.Millisecond) //休眠2毫秒
//1、解析mq中queue的数据结构体
var msg *md2.OneCirclesStructForAutoExchangeGreenEnergy
err := json.Unmarshal(msgData, &msg)
if err != nil {
return err
}
engine := db.DBs[msg.MasterId]
//2、查找 `one_circles_green_energy_basic_setting` 基础设置
oneCirclesGreenEnergyBasicSetting, err := db2.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{
"key": "is_open",
"value": 1,
})
if err != nil {
return err
}
if oneCirclesGreenEnergyBasicSetting == nil {
return nil
}

session := engine.NewSession()
defer func() {
session.Close()
if err := recover(); err != nil {
_ = logx.Error(err)
}
}()
session.Begin()
//3.1计算涨价公式
err1, values, _, afterPriceValue := one_circles.NewCalcPriceIncreaseFormula(msg.AutoExchangeNumsAmount, oneCirclesGreenEnergyBasicSetting)
if err1 != nil {
_ = session.Rollback()
return err1
}
//3.2给相应的用户加上个人的绿色积分(可用数量)
err = one_circles.DealUserCoin(session, md2.DealUserCoinReq{
Kind: "add",
Mid: msg.MasterId,
Title: md2.OneCirclesPersonalActiveCoinExchangeGreenEnergy,
TransferType: md2.OneCirclesPersonalActiveCoinExchangeGreenEnergyForUserVirtualCoinFlow,
OrdId: "",
CoinId: oneCirclesGreenEnergyBasicSetting.PersonGreenEnergyCoinId,
Uid: msg.Uid,
Amount: utils.StrToFloat64(values),
})
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::33333", err.Error())
return err
}

//4.1给相应的用户减去个人活跃积分
err = one_circles.DealUserCoin(session, md2.DealUserCoinReq{
Kind: "sub",
Mid: msg.MasterId,
Title: md2.OneCirclesPersonalActiveCoinExchangeToBeGreenEnergy,
TransferType: md2.OneCirclesPersonalActiveCoinExchangeToBeGreenEnergyForUserVirtualCoinFlow,
OrdId: "",
CoinId: msg.CoinId,
Uid: msg.Uid,
Amount: utils.StrToFloat64(msg.Amount),
})
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::33333", err.Error())
return err
}
//4.2减少“原始数量”中的绿色能量
err = one_circles.DealAvailableGreenEnergyCoin(session, int(enum.PersonalActivePointRedemption), utils.StrToFloat64(values), utils.StrToFloat64(msg.AutoExchangeNumsAmount), enum.PersonalActivePointRedemption.String(), oneCirclesGreenEnergyBasicSetting, afterPriceValue)
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::44444", err.Error())
return err
}

//5、修改 one_circles_green_energy_basic_setting 的 now_price
_, err = db2.OneCirclesGreenEnergyBasicSettingUpdate(session, oneCirclesGreenEnergyBasicSetting.Id, oneCirclesGreenEnergyBasicSetting)
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::77777", err.Error())
return err
}
err = session.Commit()
if err != nil {
_ = session.Rollback()
return errors.New("事务提交失败")
}
return nil
}

+ 150
- 0
consume/one_circles_activity_coin_auto_exchange_green_energy_for_team_consume.go Vedi File

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

import (
"applet/app/cfg"
"applet/app/db"
utils2 "applet/app/utils"
"applet/app/utils/logx"
"applet/consume/md"
"applet/mall/utils"
"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"
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/one_circles"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/enum"
"encoding/json"
"errors"
"fmt"
"github.com/streadway/amqp"
"time"
)

func OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume(queue md.MqQueue) {
fmt.Println(">>>>>>>>>>>>OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume>>>>>>>>>>>>")
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)

one_circles.Init(cfg.RedisAddr)

var res amqp.Delivery
var ok bool
for {
res, ok = <-delivery
if ok == true {
err = handleOneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume(res.Body)
if err != nil {
fmt.Println("OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume_ERR:::::", err.Error())
utils2.FilePutContents("OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume_ERR", utils2.SerializeStr(map[string]interface{}{
"body": res.Body,
"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 handleOneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume(msgData []byte) error {
time.Sleep(time.Duration(2) * time.Millisecond) //休眠2毫秒
//1、解析mq中queue的数据结构体
var msg *md2.OneCirclesStructForAutoExchangeGreenEnergy
err := json.Unmarshal(msgData, &msg)
if err != nil {
return err
}
engine := db.DBs[msg.MasterId]
//2、查找 `one_circles_green_energy_basic_setting` 基础设置
oneCirclesGreenEnergyBasicSetting, err := db2.OneCirclesGreenEnergyBasicSettingGetOneByParams(engine, map[string]interface{}{
"key": "is_open",
"value": 1,
})
if err != nil {
return err
}
if oneCirclesGreenEnergyBasicSetting == nil {
return nil
}

session := engine.NewSession()
defer func() {
session.Close()
if err := recover(); err != nil {
_ = logx.Error(err)
}
}()
session.Begin()
//3.1计算涨价公式
err1, values, _, afterPriceValue := one_circles.NewCalcPriceIncreaseFormula(msg.AutoExchangeNumsAmount, oneCirclesGreenEnergyBasicSetting)
if err1 != nil {
_ = session.Rollback()
return err1
}
//3.2给相应的用户加上个人的绿色积分(结算数量)
err = one_circles.DealUserCoin(session, md2.DealUserCoinReq{
Kind: "add",
Mid: msg.MasterId,
Title: md2.OneCirclesTeamActiveCoinExchangeGreenEnergy,
TransferType: md2.OneCirclesTeamActiveCoinExchangeGreenEnergyForUserVirtualCoinFlow,
OrdId: "",
CoinId: oneCirclesGreenEnergyBasicSetting.TeamGreenEnergyCoinId,
Uid: msg.Uid,
Amount: utils.StrToFloat64(values),
})
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::33333", err.Error())
return err
}

//4.1给相应的用户减去团队活跃积分
err = one_circles.DealUserCoin(session, md2.DealUserCoinReq{
Kind: "sub",
Mid: msg.MasterId,
Title: md2.OneCirclesTeamActiveCoinExchangeToBeGreenEnergy,
TransferType: md2.OneCirclesTeamActiveCoinExchangeToBeGreenEnergyForUserVirtualCoinFlow,
OrdId: "",
CoinId: msg.CoinId,
Uid: msg.Uid,
Amount: utils.StrToFloat64(msg.Amount),
})
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::33333", err.Error())
return err
}
//4.2减少“原始数量”中的绿色能量
err = one_circles.DealAvailableGreenEnergyCoin(session, int(enum.TeamActivePointRedemption), utils.StrToFloat64(values), utils.StrToFloat64(msg.AutoExchangeNumsAmount), enum.TeamActivePointRedemption.String(), oneCirclesGreenEnergyBasicSetting, afterPriceValue)
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::44444", err.Error())
return err
}

//5、修改 one_circles_green_energy_basic_setting 的 now_price
_, err = db2.OneCirclesGreenEnergyBasicSettingUpdate(session, oneCirclesGreenEnergyBasicSetting.Id, oneCirclesGreenEnergyBasicSetting)
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::77777", err.Error())
return err
}
err = session.Commit()
if err != nil {
_ = session.Rollback()
return errors.New("事务提交失败")
}
return nil
}

+ 99
- 0
consume/one_circles_settlement_public_activity_coin_consume.go Vedi File

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

import (
"applet/app/cfg"
"applet/app/db"
utils2 "applet/app/utils"
"applet/app/utils/logx"
"applet/consume/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
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/one_circles"
"encoding/json"
"errors"
"fmt"
"github.com/streadway/amqp"
"time"
)

func OneCirclesSettlementPublicGiveActivityCoinConsume(queue md.MqQueue) {
fmt.Println(">>>>>>>>>>>>OneCirclesSettlementPublicGiveActivityCoinConsume>>>>>>>>>>>>")
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)

one_circles.Init(cfg.RedisAddr)

var res amqp.Delivery
var ok bool
for {
res, ok = <-delivery
if ok == true {
err = handleOneCirclesSettlementPublicGiveActivityCoinConsume(res.Body)
if err != nil {
fmt.Println("OneCirclesSettlementPublicGiveActivityCoinConsume_ERR:::::", err.Error())
utils2.FilePutContents("OneCirclesSettlementPublicGiveActivityCoinConsume_ERR", utils2.SerializeStr(map[string]interface{}{
"body": res.Body,
"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 handleOneCirclesSettlementPublicGiveActivityCoinConsume(msgData []byte) error {
time.Sleep(time.Duration(2) * time.Millisecond) //休眠2毫秒
//1、解析mq中queue的数据结构体
var msg *md2.DealUserCoinReq
err := json.Unmarshal(msgData, &msg)
if err != nil {
return err
}
engine := db.DBs[msg.Mid]

session := engine.NewSession()
defer func() {
session.Close()
if err := recover(); err != nil {
_ = logx.Error(err)
}
}()
session.Begin()

err = one_circles.DealUserCoin(session, md2.DealUserCoinReq{
Kind: "add",
Mid: msg.Mid,
Title: msg.Title,
TransferType: msg.TransferType,
OrdId: "",
CoinId: msg.CoinId,
Uid: msg.Uid,
Amount: msg.Amount,
})
if err != nil {
_ = session.Rollback()
fmt.Println("err:::::2222", err)
return err
}

err = session.Commit()
if err != nil {
_ = session.Rollback()
return errors.New("事务提交失败")
}
return nil
}

+ 165
- 0
consume/withdraw_consume_gongmao.go Vedi File

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

import (
"applet/app/cfg"
"applet/app/db"
db2 "applet/app/flexible_employment/db"
"applet/app/flexible_employment/enum"
"applet/app/flexible_employment/svc"
"applet/app/lib/flexible_employment"
"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_order_relate_rule.git/rule/one_circles"
"encoding/json"
"errors"
"fmt"
"github.com/streadway/amqp"
"time"
)

func FlexibleEmploymentWithdrawForGongMaoConsume(queue md.MqQueue) {
fmt.Println(">>>>>>>>>>>>FlexibleEmploymentWithdrawForGongMaoConsume>>>>>>>>>>>>")
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)

one_circles.Init(cfg.RedisAddr)

var res amqp.Delivery
var ok bool
for {
res, ok = <-delivery
if ok == true {
err = handleFlexibleEmploymentWithdrawForGongMaoConsume(res.Body)
fmt.Println("err ::: ", err)
if err != nil {
fmt.Println("FlexibleEmploymentWithdrawForGongMaoConsume_ERR:::::", err.Error())
_ = res.Reject(true) //TODO::拒绝 Ack
//_ = res.Reject(false)
var msg interface{}
json.Unmarshal(res.Body, &msg)
if err.Error() == "Connection timed out" {
//TODO::重新推回队列末尾,避免造成队列堵塞
ch.Publish(queue.ExchangeName, msg, queue.RoutKey)
} else {
//TODO::推入新的队列中备份
utils.FilePutContents("FlexibleEmploymentWithdrawForGongMaoConsume_ERR", utils.SerializeStr(err.Error()))
ch.Publish("zhios.app.user.withdraw.apply.exception.exchange", msg, "gongmao")
}
} else {
err = res.Ack(true)
}
} else {
panic(errors.New("error getting message"))
}
}
fmt.Println("get msg done")
}

func handleFlexibleEmploymentWithdrawForGongMaoConsume(msgData []byte) error {
var ms string
err := json.Unmarshal(msgData, &ms)
if err != nil {
return err
}
time.Sleep(time.Microsecond * 200) // 等待200毫秒
//1、解析mq中queue的数据结构体
var msg struct {
Uid string `json:"uid"`
Nickname string `json:"nickname"`
MasterId string `json:"master_id"`
AppName string `json:"app_name"`
ApplyOrder string `json:"apply_order"`
ActualAmount string `json:"actual_amount"`
MobCfg interface{} `json:"mob_cfg"`
}
err = json.Unmarshal([]byte(ms), &msg)
if err != nil {
return err
}
fmt.Println("gongmao_message:::::::::::>>>>>>>>>")
fmt.Println(msg)
if db.DBs[msg.MasterId] == nil {
return nil
}
engine := db.DBs[msg.MasterId]

//1、查找对应记录
flexibleEmploymentOrdDb := db2.FlexibleEmploymentOrdDb{}
flexibleEmploymentOrdDb.Set(msg.MasterId)
flexibleEmploymentOrd, err := flexibleEmploymentOrdDb.Get(msg.ApplyOrder)
if err != nil {
return err
}
if flexibleEmploymentOrd == nil {
return errors.New("未查询到对应订单记录")
}

flexibleEmploymentBasicDb := db2.FlexibleEmploymentBasicDb{}
flexibleEmploymentBasicDb.Set()
basic, err := flexibleEmploymentBasicDb.Get(msg.MasterId)
if err != nil {
return err
}
gongMao := flexible_employment.New(basic.AppKey, basic.AppSecret, basic.SecretId)
result, err := gongMao.Curl(enum.MerchantDoSinglePayment, map[string]interface{}{
"requestId": flexibleEmploymentOrd.RequestId,
"mobile": flexibleEmploymentOrd.Mobile,
"name": flexibleEmploymentOrd.Name,
"amount": flexibleEmploymentOrd.Amount,
"identity": flexibleEmploymentOrd.Identity,
"bankAccount": flexibleEmploymentOrd.BankAccount,
"dateTime": time.Now().Format("20060102150405"),
"salaryType": flexibleEmploymentOrd.SettleType,
})
if err != nil {
return err
}
var response struct {
Success bool `json:"success"`
ErrorCode string `json:"errorCode"`
ErrorMsg string `json:"errorMsg"`
Data struct {
RequestId string `json:"requestId"`
AppmentTime string `json:"appmentTime"`
} `json:"data"`
}
if err = json.Unmarshal(utils.Serialize(result), &response); err != nil {
return err
}
if !response.Success {
//TODO::发起提现失败,将处理提现失败状态
finWithdrawApply, err := db.UserWithDrawApplyByUIDById(engine, flexibleEmploymentOrd.RequestId)
if err != nil {
return err
}
session := engine.NewSession()
defer session.Close()
session.Begin()
err = svc.DealFailResult(session, finWithdrawApply, msg.MasterId, response.ErrorMsg)
if err != nil {
_ = session.Rollback()
return err
}
return session.Commit()
}
flexibleEmploymentOrd.State = 1
updateAck, err := flexibleEmploymentOrdDb.Update(flexibleEmploymentOrd.Id, flexibleEmploymentOrd, "state")
if err != nil {
return err
}
if updateAck <= 0 {
return errors.New("更新 flexible_employment_ord 状态失败")
}
return nil
}

+ 176
- 0
consume/withdraw_consume_pupiao.go Vedi File

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

import (
"applet/app/cfg"
"applet/app/db"
db2 "applet/app/flexible_employment/db"
"applet/app/flexible_employment/enum"
"applet/app/flexible_employment/svc"
"applet/app/flexible_employment/utils/aes"
"applet/app/lib/flexible_employment"
"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_order_relate_rule.git/rule/one_circles"
"encoding/json"
"errors"
"fmt"
"github.com/streadway/amqp"
"time"
)

func FlexibleEmploymentWithdrawForPupiaoConsume(queue md.MqQueue) {
fmt.Println(">>>>>>>>>>>>FlexibleEmploymentWithdrawForPupiaoConsume>>>>>>>>>>>>")
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)

one_circles.Init(cfg.RedisAddr)

var res amqp.Delivery
var ok bool
for {
res, ok = <-delivery
if ok == true {
err = handleFlexibleEmploymentWithdrawForPupiaoConsume(res.Body)
fmt.Println("err ::: ", err)
if err != nil {
fmt.Println("FlexibleEmploymentWithdrawForPupiaoConsume_ERR:::::", err.Error())
//_ = res.Reject(true)
_ = res.Reject(false)
var msg interface{}
json.Unmarshal(res.Body, &msg)
if err.Error() == "Connection timed out" {
//TODO::重新推回队列末尾,避免造成队列堵塞
ch.Publish(queue.ExchangeName, msg, queue.RoutKey)
} else {
//TODO::推入新的队列中备份
utils.FilePutContents("FlexibleEmploymentWithdrawForPupiaoConsume_ERR", utils.SerializeStr(err.Error()))
ch.Publish("zhios.app.user.withdraw.apply.exception.exchange", msg, "pupiao")
}
} else {
err = res.Ack(true)
}
} else {
panic(errors.New("error getting message"))
}
}
fmt.Println("get msg done")
}

func handleFlexibleEmploymentWithdrawForPupiaoConsume(msgData []byte) error {
time.Sleep(time.Microsecond * 200) // 等待200毫秒
//1、解析mq中queue的数据结构体
var msg struct {
Uid string `json:"uid"`
Nickname string `json:"nickname"`
MasterId string `json:"master_id"`
AppName string `json:"app_name"`
ApplyOrder string `json:"apply_order"`
ActualAmount string `json:"actual_amount"`
Oid string `json:"oid"`
MobCfg string `json:"mob_cfg"`
}
err := json.Unmarshal(msgData, &msg)
if err != nil {
return err
}
fmt.Println("pupiao_message:::::::::::>>>>>>>>>")
fmt.Println(msg)
if db.DBs[msg.MasterId] == nil {
return nil
}
engine := db.DBs[msg.MasterId]

//1、查找对应记录
flexibleEmploymentPupiaoOrdDb := db2.FlexibleEmploymentPupiaoOrdDb{}
flexibleEmploymentPupiaoOrdDb.Set(msg.MasterId)
flexibleEmploymentPupiaoOrd, err := flexibleEmploymentPupiaoOrdDb.Get(msg.Oid)
if err != nil {
return err
}
if flexibleEmploymentPupiaoOrd == nil {
return errors.New("未查询到对应订单记录")
}

flexibleEmploymentPuiaoBasicDb := db2.FlexibleEmploymentPuiaoBasicDb{}
flexibleEmploymentPuiaoBasicDb.Set()
basic, err := flexibleEmploymentPuiaoBasicDb.GetBasic(msg.MasterId)
if err != nil {
return err
}

//2、发起制单
puPiao := flexible_employment.NewPuPiao(basic.AppId, basic.AppSecret)
var userAESData = []map[string]string{
{
"outTradeNo": "o_" + utils.Int64ToStr(flexibleEmploymentPupiaoOrd.WithdrawApplyId),
"settleType": flexibleEmploymentPupiaoOrd.SettleType,
"payeeName": flexibleEmploymentPupiaoOrd.PayeeName,
"payeeIdCard": flexibleEmploymentPupiaoOrd.PayeeIdCard,
"payeePhone": flexibleEmploymentPupiaoOrd.PayeePhone,
"payeeNo": flexibleEmploymentPupiaoOrd.PayeeNo,
"orderAmount": flexibleEmploymentPupiaoOrd.TotalAmount,
},
}
str, _ := json.Marshal(userAESData)
itemAESContent, _ := aes.AesEncryptByECB([]byte(basic.AppSecret), string(str))
result, err := puPiao.Curl(enum.OpenApiPaymentReceiveOrder, map[string]interface{}{
"outBatchNo": flexibleEmploymentPupiaoOrd.OutBatchNo,
"hrcompanyId": basic.HrCompanyId,
"settleAccountId": basic.SettleAccountId,
"totalCount": "1",
"totalAmount": flexibleEmploymentPupiaoOrd.TotalAmount,
"itemAESContent": itemAESContent,
})
if err != nil {
return err
}
var response struct {
IsSuccess string `json:"isSuccess"`
Charset string `json:"charset"`
ErrorCode string `json:"errorCode"`
ErrorMsg string `json:"errorMsg"`
Data struct {
PlatformBatchNo string `json:"platformBatchNo"`
OutBatchNo string `json:"outBatchNo"`
} `json:"data"`
}
if err = json.Unmarshal(utils.Serialize(result), &response); err != nil {
return err
}
if response.IsSuccess == "F" {
flexibleEmploymentPupiaoOrd.BatchStatus = 1
updateAck, err := flexibleEmploymentPupiaoOrdDb.Update(flexibleEmploymentPupiaoOrd.Id, flexibleEmploymentPupiaoOrd, "batch_status")
if err != nil {
return err
}
if updateAck <= 0 {
return errors.New("更新 flexible_employment_pupiao_ord 状态失败")
}
//TODO::制单失败,将处理提现失败状态
finWithdrawApply, err := db.UserWithDrawApplyByUIDById(engine, utils.Int64ToStr(flexibleEmploymentPupiaoOrd.WithdrawApplyId))
if err != nil {
return err
}
session := engine.NewSession()
defer session.Close()
session.Begin()
err = svc.DealFailResult(session, finWithdrawApply, msg.MasterId, response.ErrorMsg)
if err != nil {
_ = session.Rollback()
return err
}
return session.Commit()
}
return nil
}

+ 120
- 0
consume/zhios_one_circles_coin_consume.go Vedi File

@@ -0,0 +1,120 @@
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 ZhiosOneCirclesCoinConsume(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(50)
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(">>>>>>>>>>>>>>>>ZhiosOneCirclesCoinConsume<<<<<<<<<<<<<<<<<<<<<<<<<")
err = handleZhiosOneCirclesCoinConsume(res.Body)
if err != nil {
fmt.Println("handleZhiosOneCirclesCoinConsume:::::", 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 handleZhiosOneCirclesCoinConsume(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 != "31585332" {
return nil
}
engine := db.DBs[masterId]
now := time.Now()

if canalMsg.Type == md.CanalMsgInsertSqlType {
////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 canalMsg.Data[0].CoinId == utils.IntToStr(7) { //TODO::数据量太大,减少查询直接写死
//3、查找 user_public_platoon_double_network_user_coin_record
userVirtualCoinFlowAggregation, err1 := db.UserVirtualCoinFlowAggregationGetOneByParams(engine, map[string]interface{}{
"key": "uid",
"value": canalMsg.Data[0].Uid,
})
if err1 != nil {
return err1
}
if userVirtualCoinFlowAggregation == nil {
//新增记录
_, err3 := db.UserVirtualCoinFlowAggregationInsert(engine, &model.UserVirtualCoinFlowAggregation{
Uid: utils.StrToInt(canalMsg.Data[0].Uid),
CoinId: utils.StrToInt(canalMsg.Data[0].CoinId),
TodayData: canalMsg.Data[0].Amout,
ThisWeekData: canalMsg.Data[0].Amout,
ThisMonthData: canalMsg.Data[0].Amout,
NowData: canalMsg.Data[0].Amout,
CreateAt: now.Format("2006-01-02 15:04:05"),
UpdateAt: now.Format("2006-01-02 15:04:05"),
})
if err3 != nil {
return err3
}
} else {
//更新记录
amount, _ := decimal.NewFromString(canalMsg.Data[0].Amout)
todayData, _ := decimal.NewFromString(userVirtualCoinFlowAggregation.TodayData)
thisWeekData, _ := decimal.NewFromString(userVirtualCoinFlowAggregation.ThisWeekData)
thisMonthData, _ := decimal.NewFromString(userVirtualCoinFlowAggregation.ThisMonthData)
userVirtualCoinFlowAggregation.TodayData = todayData.Add(amount).String()
userVirtualCoinFlowAggregation.ThisWeekData = thisWeekData.Add(amount).String()
userVirtualCoinFlowAggregation.ThisMonthData = thisMonthData.Add(amount).String()
userVirtualCoinFlowAggregation.NowData = canalMsg.Data[0].AfterAmout
_, err2 := db.UserVirtualCoinFlowAggregationUpdate(engine, userVirtualCoinFlowAggregation.Id, userVirtualCoinFlowAggregation, "today_data", "this_week_data", "this_month_data", "now_data")
if err2 != nil {
return err2
}
}
}
}
return nil
}

+ 29
- 21
go.mod Vedi File

@@ -6,7 +6,7 @@ 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_order_relate_rule.git v1.9.10-0.20240426110740-80d1b204e6a4
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
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5
@@ -16,11 +16,11 @@ require (
github.com/cc14514/go-geoip2-db v0.0.0-20190106063142-7b6408a9812a
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-contrib/sessions v1.0.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.19.0
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
@@ -38,7 +38,7 @@ require (
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
google.golang.org/protobuf v1.33.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/yaml.v2 v2.4.0
xorm.io/xorm v1.3.2
@@ -49,44 +49,52 @@ require (
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.11.3 // indirect
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect
github.com/chenzhuoyu/iasm v0.9.1 // indirect
github.com/gabriel-vasile/mimetype v1.4.3 // 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/gorilla/context v1.1.2 // indirect
github.com/gorilla/securecookie v1.1.2 // indirect
github.com/gorilla/sessions v1.2.2 // 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.7 // indirect
github.com/leodido/go-urn v1.4.0 // 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.20 // 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.2.0 // indirect
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.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.12 // 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.7.0 // indirect
golang.org/x/crypto v0.21.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.22.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.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
)

Caricamento…
Annulla
Salva