Browse Source

1

order_statistics
dengbiao 6 months ago
parent
commit
9e8898c768
5 changed files with 106 additions and 21 deletions
  1. +3
    -2
      app/db/dbs_map.go
  2. +79
    -0
      app/flexible_employment/svc/svc_fin_withdraw_apply.go
  3. +1
    -1
      app/lib/flexible_employment/pupiao.go
  4. +8
    -8
      consume/init.go
  5. +15
    -10
      consume/withdraw_consume_pupiao.go

+ 3
- 2
app/db/dbs_map.go View File

@@ -109,8 +109,9 @@ func GetAllDatabaseDev() *[]model.DbMapping {
var err error
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)
fmt.Println("notice:LOCAL TEST, only masterId:** 123456 ** available!")
err = Db.Where("deleted_at != ? AND is_dev = '1' AND db_master_id=?", 1, 123456).
Or("db_master_id = ?", 32053480).Find(&m)
} else {
err = Db.Where("deleted_at != ? AND is_dev = '1' ", 1).Find(&m)
}


+ 79
- 0
app/flexible_employment/svc/svc_fin_withdraw_apply.go View File

@@ -90,6 +90,85 @@ func DealFailResult(sess *xorm.Session, apply *model.FinWithdrawApply, masterId,
}
return nil
}
func DealFailResultForPuPiao(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、修改提现单为成功


+ 1
- 1
app/lib/flexible_employment/pupiao.go View File

@@ -23,7 +23,7 @@ type PuPiao struct {
AppSecret string
}

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

func NewPuPiao(appId, appSecret string) *PuPiao {


+ 8
- 8
consume/init.go View File

@@ -80,17 +80,17 @@ func initConsumes() {

//////////////////////////////////////// oneCircles /////////////////////////////////////////////////////

jobs[consumeMd.OneCirclesSignInGreenEnergyFunName] = OneCirclesSignInGreenEnergyConsume
jobs[consumeMd.OneCirclesStartLevelDividendFunName] = OneCirclesStartLevelDividendConsume
jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyConsume
jobs[consumeMd.OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamFunName] = OneCirclesActivityCoinAutoExchangeGreenEnergyForTeamConsume
jobs[consumeMd.OneCirclesSettlementPublicGiveActivityCoinFunName] = OneCirclesSettlementPublicGiveActivityCoinConsume
//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.WithdrawConsumeFunName] = WithdrawConsume
jobs[consumeMd.FlexibleEmploymentWithdrawForGongMaoConsumeFunName] = FlexibleEmploymentWithdrawForGongMaoConsume
jobs[consumeMd.FlexibleEmploymentWithdrawForPupiaoConsumeFunName] = FlexibleEmploymentWithdrawForPupiaoConsume

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


+ 15
- 10
consume/withdraw_consume_pupiao.go View File

@@ -68,19 +68,24 @@ func FlexibleEmploymentWithdrawForPupiaoConsume(queue md.MqQueue) {
}

func handleFlexibleEmploymentWithdrawForPupiaoConsume(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"`
Oid string `json:"oid"`
MobCfg string `json:"mob_cfg"`
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 interface{} `json:"mob_cfg"`
}
err := json.Unmarshal(msgData, &msg)
err = json.Unmarshal([]byte(ms), &msg)
if err != nil {
return err
}
@@ -165,7 +170,7 @@ func handleFlexibleEmploymentWithdrawForPupiaoConsume(msgData []byte) error {
session := engine.NewSession()
defer session.Close()
session.Begin()
err = svc.DealFailResult(session, finWithdrawApply, msg.MasterId, response.ErrorMsg)
err = svc.DealFailResultForPuPiao(session, finWithdrawApply, msg.MasterId, response.ErrorMsg)
if err != nil {
_ = session.Rollback()
return err


Loading…
Cancel
Save