dengbiao пре 7 месеци
родитељ
комит
6da1c473cd
6 измењених фајлова са 19 додато и 106 уклоњено
  1. +9
    -9
      rule/micro_applications/happy_orchard_user_waters.go
  2. +0
    -91
      rule/one_circles/coin_settlement.go
  3. +3
    -2
      rule/one_circles/one_circles_auto_release_green_energy.go
  4. +2
    -1
      rule/one_circles/one_circles_community_dividends.go
  5. +2
    -1
      rule/one_circles/one_circles_public_platoon_give_activty_coin.go
  6. +3
    -2
      rule/one_circles/one_circles_sign_in_green_energy_settlement.go

+ 9
- 9
rule/micro_applications/happy_orchard_user_waters.go Прегледај датотеку

@@ -40,7 +40,7 @@ func DealUserWaters(engine *xorm.Engine, kind string, args interface{}) (err err
}
err = handelWatering(engine, *req, *happyOrchardBasicSetting)
if err != nil {
return err
return
}
break
case enum.DealUserWatersKindForSevenDaysSign:
@@ -51,7 +51,7 @@ func DealUserWaters(engine *xorm.Engine, kind string, args interface{}) (err err
}
err = handelSevenDaysSign(engine, *req, *happyOrchardBasicSetting)
if err != nil {
return err
return
}
break
case enum.DealUserWatersKindForTimerSign:
@@ -62,7 +62,7 @@ func DealUserWaters(engine *xorm.Engine, kind string, args interface{}) (err err
}
err = handelTimerSign(engine, *req, *happyOrchardBasicSetting)
if err != nil {
return err
return
}
break
case enum.DealUserWatersKindForPlaceOrderReward:
@@ -73,7 +73,7 @@ func DealUserWaters(engine *xorm.Engine, kind string, args interface{}) (err err
}
err = handelPlaceOrderReward(engine, *req, *happyOrchardBasicSetting)
if err != nil {
return err
return
}
break
case enum.DealUserWatersKindForSharingAssistance:
@@ -84,7 +84,7 @@ func DealUserWaters(engine *xorm.Engine, kind string, args interface{}) (err err
}
err = handelSharingAssistance(engine, *req, *happyOrchardBasicSetting)
if err != nil {
return err
return
}
break
case enum.DealUserWatersKindForInvitingNewPlayers:
@@ -95,7 +95,7 @@ func DealUserWaters(engine *xorm.Engine, kind string, args interface{}) (err err
}
err = handelInvitingNewPlayers(engine, *req, *happyOrchardBasicSetting)
if err != nil {
return err
return
}
break
case enum.DealUserWatersKindForBrowsingInterface:
@@ -106,7 +106,7 @@ func DealUserWaters(engine *xorm.Engine, kind string, args interface{}) (err err
}
err = handelBrowsingInterface(engine, *req, *happyOrchardBasicSetting)
if err != nil {
return err
return
}
break
case enum.DealUserWatersKindForPlayGoldenEggGame:
@@ -117,7 +117,7 @@ func DealUserWaters(engine *xorm.Engine, kind string, args interface{}) (err err
}
err = handelPlayGoldenEggGame(engine, *req, *happyOrchardBasicSetting)
if err != nil {
return err
return
}
break
case enum.DealUserWatersKindForPlayRaffleGame:
@@ -128,7 +128,7 @@ func DealUserWaters(engine *xorm.Engine, kind string, args interface{}) (err err
}
err = handelPlayRaffleGame(engine, *req, *happyOrchardBasicSetting)
if err != nil {
return err
return
}
break
}


+ 0
- 91
rule/one_circles/coin_settlement.go Прегледај датотеку

@@ -1,91 +0,0 @@
package one_circles

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md"
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/svc"
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils"
"errors"
"fmt"
"github.com/shopspring/decimal"
"strconv"
"time"
"xorm.io/xorm"
)

// DealUserCoin 处理给用户虚拟币积分
func DealUserCoin(session *xorm.Session, req md.DealUserCoinReq) (err error) {
if req.Amount < 0 {
req.Amount = 0
}
//1、分布式锁阻拦
requestIdPrefix := fmt.Sprintf(md2.DealUserCoinRequestIdPrefix, req.Mid, req.CoinId, req.Uid)
cb, err := svc.HandleDistributedLock(req.Mid, strconv.Itoa(req.Uid), requestIdPrefix)
if err != nil {
return err
}
if cb != nil {
defer cb() // 释放锁
}

//2、计算&&组装数据
now := time.Now()
coinAmount, err := svc.GetUserCoinAmount(session, req.Mid, req.CoinId, req.Uid)
if err != nil {
return err
}
coinAmountValue := decimal.NewFromFloat(zhios_order_relate_utils.StrToFloat64(coinAmount))
amountValue := decimal.NewFromFloat(req.Amount).RoundFloor(8)

var userVirtualCoinFlow model.UserVirtualCoinFlow
userVirtualCoinFlow.CoinId = req.CoinId
userVirtualCoinFlow.Title = req.Title
userVirtualCoinFlow.TransferType = req.TransferType
userVirtualCoinFlow.Uid = req.Uid
userVirtualCoinFlow.ToUid = req.ToUid
userVirtualCoinFlow.OrdId = req.OrdId
userVirtualCoinFlow.BeforeAmout = coinAmount
userVirtualCoinFlow.Amout = amountValue.String()
userVirtualCoinFlow.CreateTime = now

if req.Kind == "add" {
userVirtualCoinFlow.Direction = 1
userVirtualCoinFlow.AfterAmout = coinAmountValue.Add(amountValue).RoundFloor(8).String()
} else if req.Kind == "sub" {
userVirtualCoinFlow.Direction = 2
userVirtualCoinFlow.AfterAmout = coinAmountValue.Sub(amountValue).RoundFloor(8).String()
} else {
err = errors.New("错误的kind类型")
return err
}
if zhios_order_relate_utils.StrToFloat64(userVirtualCoinFlow.AfterAmout) < 0 {
var coin model.VirtualCoin
_, err = session.Where("id = ?", req.CoinId).Get(&coin)
if err != nil {
return err
}
zhios_order_relate_utils.FilePutContents("virtual_coin_not", zhios_order_relate_utils.SerializeStr(map[string]interface{}{
"uid": userVirtualCoinFlow.Uid,
"amount": userVirtualCoinFlow.Amout,
"before_amount": userVirtualCoinFlow.BeforeAmout,
"after_amount": userVirtualCoinFlow.AfterAmout,
"coin_id": userVirtualCoinFlow.CoinId,
}))
return errors.New("用户" + zhios_order_relate_utils.IntToStr(userVirtualCoinFlow.Uid) + "的" + coin.Name + "不足")
}
//3、插入 `user_virtual_coin_flow` 记录
_, err = db.UserVirtualCoinFlowInsert(session, &userVirtualCoinFlow)
if err != nil {
return err
}

//4、修改 `user_virtual_amount`的amount值 && 及缓存
err = svc.SetCacheUserVirtualAmount(session, req.Mid, userVirtualCoinFlow.AfterAmout, req.CoinId, req.Uid, true)
if err != nil {
return err
}

return nil
}

+ 3
- 2
rule/one_circles/one_circles_auto_release_green_energy.go Прегледај датотеку

@@ -4,6 +4,7 @@ import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model"
"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"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/cache"
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx"
"errors"
@@ -71,7 +72,7 @@ func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err e
session.Begin()

//4.2给相应的用户加上个人的绿色积分(可用数量)
err = DealUserCoin(session, md.DealUserCoinReq{
err = rule.DealUserCoin(session, md.DealUserCoinReq{
Kind: "add",
Mid: masterId,
Title: md.OneCirclesSettlementGreenEnergyExchangeGreenEnergy,
@@ -83,7 +84,7 @@ func AutoReleaseExchangeGreenEnergy(engine *xorm.Engine, masterId string) (err e
})

//4.2给相应的用户减少个人的绿色积分(结算数量)
err = DealUserCoin(session, md.DealUserCoinReq{
err = rule.DealUserCoin(session, md.DealUserCoinReq{
Kind: "sub",
Mid: masterId,
Title: md.OneCirclesSettlementGreenEnergyExchangeTobeGreenEnergy,


+ 2
- 1
rule/one_circles/one_circles_community_dividends.go Прегледај датотеку

@@ -3,6 +3,7 @@ package one_circles
import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model"
"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"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/enum"
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils"
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx"
@@ -50,7 +51,7 @@ func CommunityDividends(engine *xorm.Engine, masterId string) (err error) {

for _, v := range list {
//4、 给相应的用户加上分红权益
err = DealUserCoin(session, md.DealUserCoinReq{
err = rule.DealUserCoin(session, md.DealUserCoinReq{
Kind: "add",
Mid: masterId,
Title: md.OneCirclesCommunityDividends,


+ 2
- 1
rule/one_circles/one_circles_public_platoon_give_activty_coin.go Прегледај датотеку

@@ -5,6 +5,7 @@ import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model"
"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"
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/md"
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/cache"
@@ -165,7 +166,7 @@ func SettlementPublicGiveActivityCoin(engine *xorm.Engine, masterId string, uid
session.Begin()

//给相应的用户加上"个人"活跃积分
err = DealUserCoin(session, md.DealUserCoinReq{
err = rule.DealUserCoin(session, md.DealUserCoinReq{
Kind: "add",
Mid: masterId,
Title: md.OneCirclesWatchAdRewardPersonalActiveCoin,


+ 3
- 2
rule/one_circles/one_circles_sign_in_green_energy_settlement.go Прегледај датотеку

@@ -5,6 +5,7 @@ import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model"
"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"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/enum"
md2 "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule/one_circles/svc"
@@ -126,7 +127,7 @@ func HandleSettlementSignInGreenEnergy(engine *xorm.Engine, masterId string, id

var reduceTotalGreenEnergy float64
//4.2给相应的用户加上个人的绿色积分(可用数量)
err = DealUserCoin(session, md.DealUserCoinReq{
err = rule.DealUserCoin(session, md.DealUserCoinReq{
Kind: "add",
Mid: masterId,
Title: md.OneCirclesGreenEnergySignInSettlementPersonalReward,
@@ -183,7 +184,7 @@ func HandleSettlementSignInGreenEnergy(engine *xorm.Engine, masterId string, id
}
}

err = DealUserCoin(session, md.DealUserCoinReq{
err = rule.DealUserCoin(session, md.DealUserCoinReq{
Kind: "add",
Mid: masterId,
Title: md.OneCirclesGreenEnergySignInSettlementTeamReward,


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