瀏覽代碼

update

master
dengbiao 3 月之前
父節點
當前提交
acf7717b55
共有 2 個文件被更改,包括 44 次插入52 次删除
  1. +12
    -12
      consume/init.go
  2. +32
    -40
      consume/one_circles_activity_coin_auto_exchange_green_energy_consume.go

+ 12
- 12
consume/init.go 查看文件

@@ -75,21 +75,21 @@ func initConsumes() {
//jobs[consumeMd.MallAddSupplyGoodsFunName] = MallAddSupplyGoodsConsume

//////////////////////////////////////// bigData /////////////////////////////////////////////////////
jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume
jobs[consumeMd.CanalGuideOrderForNumericalStatementConsumeFunName] = CanalGuideOrderForNumericalStatementConsume
//jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
//jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
//jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
//jobs[consumeMd.CanalUserVirtualCcoinFlowFunName] = CanalUserVirtualCoinFlowConsume
//jobs[consumeMd.CanalGuideOrderForNumericalStatementConsumeFunName] = CanalGuideOrderForNumericalStatementConsume

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

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

//////////////////////////////////////// withdraw /////////////////////////////////////////////////////
//jobs[consumeMd.WithdrawConsumeFunName] = WithdrawConsume


+ 32
- 40
consume/one_circles_activity_coin_auto_exchange_green_energy_consume.go 查看文件

@@ -32,7 +32,7 @@ func OneCirclesActivityCoinAutoExchangeGreenEnergyConsume(queue md.MqQueue) {
//1、将自己绑定到交换机上
ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey)
//2、取出数据进行消费
ch.Qos(40)
ch.Qos(50)
delivery := ch.Consume(queue.Name, false)

one_circles.Init(cfg.RedisAddr)
@@ -61,7 +61,7 @@ func OneCirclesActivityCoinAutoExchangeGreenEnergyConsume(queue md.MqQueue) {
}

func handleOneCirclesActivityCoinAutoExchangeGreenEnergyConsume(msgData []byte) error {
time.Sleep(time.Duration(100) * time.Microsecond) //休眠0.1毫秒
time.Sleep(time.Duration(10) * time.Microsecond) //休眠0.1毫秒
//1、解析mq中queue的数据结构体
var msg *md2.OneCirclesStructForAutoExchangeGreenEnergy
err := json.Unmarshal(msgData, &msg)
@@ -77,16 +77,6 @@ func handleOneCirclesActivityCoinAutoExchangeGreenEnergyConsume(msgData []byte)
if cb != nil {
defer cb() // 释放锁
}
//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() {
@@ -96,30 +86,8 @@ func handleOneCirclesActivityCoinAutoExchangeGreenEnergyConsume(msgData []byte)
}
}()
session.Begin()
//3.1计算涨价公式
err1, values, _, afterPriceValue := one_circles.NewCalcPriceIncreaseFormula(msg.AutoExchangeNumsAmount, oneCirclesGreenEnergyBasicSetting)
if err1 != nil {
_ = session.Rollback()
return err1
}
//3.2给相应的用户加上个人的绿色积分(可用数量)
err = rule.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给相应的用户减去个人活跃积分
//3给相应的用户减去个人活跃积分
err = rule.DealUserCoin(session, md2.DealUserCoinReq{
Kind: "sub",
Mid: msg.MasterId,
@@ -135,21 +103,45 @@ func handleOneCirclesActivityCoinAutoExchangeGreenEnergyConsume(msgData []byte)
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)

//4.1计算涨价公式
err1, values, _, afterPriceValue := one_circles.NewCalcPriceIncreaseFormula(msg.AutoExchangeNumsAmount, oneCirclesGreenEnergyBasicSetting)
if err1 != nil {
_ = session.Rollback()
return err1
}
//4.2给相应的用户加上个人的绿色积分(可用数量)
err = rule.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:::::44444", err.Error())
return err
}

//5、修改 one_circles_green_energy_basic_setting 的 now_price
_, err = db2.OneCirclesGreenEnergyBasicSettingUpdate(session, oneCirclesGreenEnergyBasicSetting.Id, oneCirclesGreenEnergyBasicSetting)
//5减少“原始数量”中的绿色能量
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:::::77777", err.Error())
fmt.Println("err:::::555555", err.Error())
return err
}

//6、修改 one_circles_green_energy_basic_setting 的 now_price
db2.OneCirclesGreenEnergyBasicSettingUpdate(session, oneCirclesGreenEnergyBasicSetting.Id, oneCirclesGreenEnergyBasicSetting)
//if err != nil {
// _ = session.Rollback()
// fmt.Println("err:::::666666", err.Error())
// return err
//}
err = session.Commit()
if err != nil {
_ = session.Rollback()


Loading…
取消
儲存