作者 Administrator

合并分支 'dev' 到 'master'

Dev



查看合并请求 !17
... ... @@ -52,7 +52,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
... ... @@ -92,7 +91,6 @@ github.com/klauspost/compress v1.8.2 h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2K
github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
... ... @@ -137,7 +135,6 @@ github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg=
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
... ... @@ -147,9 +144,7 @@ github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXc
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
... ... @@ -184,7 +179,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf h1:fnPsqIDRbCSgumaMCRpoIoF2s4qxv0xSSS0BVZUE/ss=
golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
... ... @@ -206,7 +200,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
... ... @@ -221,17 +214,13 @@ golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=
golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e h1:AyodaIpKjppX+cBfTASF2E1US3H2JFBj920Ot3rtDjs=
golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
... ... @@ -242,7 +231,6 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20200117065230-39095c1d176c h1:FodBYPZKH5tAN2O60HlglMwXGAeV/4k+NKbli79M/2c=
golang.org/x/tools v0.0.0-20200117065230-39095c1d176c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
... ... @@ -279,7 +267,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
... ...
package subscriber
import (
"fmt"
"github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event"
)
type WorthServiceSubscriber struct {
}
func (subscriber *WorthServiceSubscriber) HandleEvent(domainEvent domain.DomainEvent) error {
worthServiceGateway, err := factory.CreateWorthServiceGateway(nil)
if err != nil {
fmt.Println(err.Error())
return nil
}
switch domainEvent.EventType() {
case event.USER_CHANGE_PHONE:
phoneChangedEvent := domainEvent.(*event.PhoneChanged)
data, err := worthServiceGateway.ChangePhoneCallback(phoneChangedEvent.OldPhone, phoneChangedEvent.NewPhone)
if err != nil {
fmt.Println(err.Error())
return nil
}
fmt.Println(data)
break
}
return nil
}
func (subscriber *WorthServiceSubscriber) SubscribedToEventTypes() []string {
return []string{
event.USER_CHANGE_PHONE,
}
}
... ...
... ... @@ -110,5 +110,10 @@ func CreateExchangeSuMoneyService(options map[string]interface{}) (service.Excha
return domainService.NewExchangeSuMoneyService(transactionContext)
}
func CreateChangePhoneService(options map[string]interface{}) (service.ChangePhoneService, error) {
var transactionContext *pgTransaction.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pgTransaction.TransactionContext)
}
return domainService.NewChangePhoneService(transactionContext)
}
... ...
... ... @@ -9,3 +9,7 @@ func CreateAbilityServiceGateway(options map[string]interface{}) (serviceGateway
func CreateMmmOpenApiServiceGateway(options map[string]interface{}) (serviceGateway.MmmOpenApiServiceGateway, error) {
return serviceGateway.NewHttplibMmmOpenApiServiceGateway(), nil
}
func CreateWorthServiceGateway(options map[string]interface{}) (serviceGateway.WorthServiceGateway, error) {
return serviceGateway.NewHttplibWorthServiceGateway(), nil
}
... ...
... ... @@ -62,7 +62,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
// 现金池仓储初始化
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -271,7 +271,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
// 现金池仓储初始化
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -338,7 +338,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
}
// 现金池为空时处理
if count == 0 {
return map[string] interface{} {
return map[string]interface{}{
"cashPoolId": 0,
"cash": 0,
"companyId": getCashPoolQuery.CompanyId,
... ... @@ -543,7 +543,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
var t2 = activity.Deadline
// 获取兑换活动前先更新兑换活动倒计时命令
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
ExchangeCashActivityId: activity.ActivityId,
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算倒计时
Deadline: activity.Deadline,
... ... @@ -579,7 +579,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
//suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
cash, _ := decimal.NewFromFloatWithExponent(activity.ExchangedCash, -2).Float64()
suMoney, _ := decimal.NewFromFloatWithExponent(activity.ExchangedSuMoney, -2).Float64()
activityFormat := map[string]interface{} {
activityFormat := map[string]interface{}{
"activityId": activity.ActivityId,
"exchangeActivityName": activity.ExchangeActivityName,
"companyId": activity.CompanyId,
... ... @@ -647,7 +647,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
var t2 = activityFound.Deadline.Local()
// 更新兑换现金活动倒计时命令
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
ExchangeCashActivityId: activityFound.ActivityId,
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
Deadline: activityFound.Deadline.Local(),
... ... @@ -684,7 +684,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
//suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedSuMoney), 64)
cash, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedCash, -2).Float64()
suMoney, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedSuMoney, -2).Float64()
activityWithTs := map[string]interface{} {
activityWithTs := map[string]interface{}{
"activityId": activityFound.ActivityId,
"exchangeActivityName": activityFound.ExchangeActivityName,
"companyId": activityFound.CompanyId,
... ... @@ -798,7 +798,7 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA
var t2 = activityFound.Deadline
// 更新兑换现金活动倒计时命令
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand {
updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
ExchangeCashActivityId: activityFound.ActivityId,
CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
Deadline: activityFound.Deadline,
... ... @@ -877,7 +877,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
// 现金池仓储初始化
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -970,7 +970,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
if updateExchangeCashActivityCommand.ExchangeRate != activityFoundRate && updateExchangeCashActivityCommand.ExchangeRate != 0 { // 更新兑换活动兑换汇率
// 判断兑换活动清单中现金总金额是否超过平台未兑换现金值
if activityFoundExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolFoundUnExchangeCash {
if activityFoundExchangedSuMoney*updateExchangeCashActivityCommand.ExchangeRate > cashPoolFoundUnExchangeCash {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
}
... ... @@ -988,7 +988,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
// 更新兑换清单命令
exchangeCash, _ := decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangeRate).Mul(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand {
updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand{
//ExchangedCash: updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney,
ExchangedCash: exchangeCash,
ExchangedSuMoney: personFoundExchangedSuMoney,
... ... @@ -1000,7 +1000,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
}
// 保存素币兑换清单更新
if _, err := exchangeCashPersonListRepository.Save(personFound);err != nil {
if _, err := exchangeCashPersonListRepository.Save(personFound); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
... ... @@ -1169,7 +1169,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
// 现金池仓储初始化
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -1218,9 +1218,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney
activityFoundExchangedCash := activityFound.ExchangedCash
// TODO 更改:根据uid和companyId,判断当前员工是否有效
//更改:根据uid和companyId,判断当前员工是否有效
getEmployee := map[string]interface{}{
"account": personFound.EmployeeInfo.EmployeeAccount,
"uid": personFound.EmployeeInfo.Uid,
//"account": personFound.EmployeeInfo.EmployeeAccount,
"companyId": activityFound.CompanyId,
}
employeeFound, err := employeeRepository.FindOne(getEmployee)
... ... @@ -1338,7 +1339,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
// 判断是否超过平台未兑换现金
if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {
if (activityUpdated.ExchangedSuMoney - activityFoundExchangedSuMoney) * activityUpdated.Rate > cashPoolFoundUnExchangeCash {
if (activityUpdated.ExchangedSuMoney-activityFoundExchangedSuMoney)*activityUpdated.Rate > cashPoolFoundUnExchangeCash {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
}
}
... ... @@ -1443,7 +1444,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
// 现金池仓储初始化
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -1535,8 +1536,9 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash // 当前公司现金池未兑换现金
cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash // 当前公司现金池已兑换现金
// TODO 更改:根据uid和companyId,判断当前员工是否有效
// 更改:根据uid、account和companyId,判断当前员工是否有效(身份有效、手机账号有效)
getEmployee := map[string]interface{}{
"uid": createExchangeCashPersonCommand.Uid,
"account": createExchangeCashPersonCommand.PersonAccount,
"companyId": activityFound.CompanyId,
}
... ... @@ -1563,8 +1565,9 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
}
employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值
// TODO 更改:根据uid和activityId判断当前员工是否已经在素币兑换清单中,
// 更改:根据uid、employeeAccount和activityId判断当前员工是否已经在素币兑换清单中,
personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{
"uid": employeeFound.EmployeeInfo.Uid,
"employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
"activityId": activityFound.ActivityId,
})
... ... @@ -1693,7 +1696,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
}
// 判断是否超过平台未兑换现金
if createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate > cashPoolFoundUnExchangeCash {
if createExchangeCashPersonCommand.ExchangedSuMoney*activityFound.Rate > cashPoolFoundUnExchangeCash {
row := []interface{}{
createExchangeCashPersonCommand.PersonName,
createExchangeCashPersonCommand.PersonAccount,
... ... @@ -2271,7 +2274,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
// 现金池仓储初始化
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -2429,7 +2432,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash
// 判断是否超过平台未兑换现金
if createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate > cashPoolFoundUnExchangeCash {
if createExchangeCashPersonCommand.ExchangedSuMoney*activityFound.Rate > cashPoolFoundUnExchangeCash {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
}
... ... @@ -2665,7 +2668,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
// 现金池仓储初始化
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -2999,17 +3002,47 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ
}
// 兑换素币清单排行榜
for i, _ := range exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int}) {
uid := exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int})[i].Uid
for i, _ := range exchangeCashListRankingStatistics["people"].([]struct {
Uid int64
EmployeeName string
SuMoney float64
Cash float64
Ranking int
}) {
uid := exchangeCashListRankingStatistics["people"].([]struct {
Uid int64
EmployeeName string
SuMoney float64
Cash float64
Ranking int
})[i].Uid
if uidName[uid] != nil {
exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int})[i].EmployeeName = uidName[uid].(string)
exchangeCashListRankingStatistics["people"].([]struct {
Uid int64
EmployeeName string
SuMoney float64
Cash float64
Ranking int
})[i].EmployeeName = uidName[uid].(string)
}
}
// 个人素币兑换清单
if exchangeCashListRankingStatistics["currentEmployee"] != nil {
currentEmployeeExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct{Uid int64;EmployeeName string;SuMoney float64; Cash float64;Ranking int})
uidExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct{Uid int64;EmployeeName string;SuMoney float64; Cash float64;Ranking int}).Uid
currentEmployeeExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct {
Uid int64
EmployeeName string
SuMoney float64
Cash float64
Ranking int
})
uidExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct {
Uid int64
EmployeeName string
SuMoney float64
Cash float64
Ranking int
}).Uid
if uidName[uidExchangeCashList] != nil {
currentEmployeeExchangeCashList.EmployeeName = uidName[uidExchangeCashList].(string)
}
... ...
... ... @@ -17,11 +17,11 @@ import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
)
// 任务服务
// TaskService 任务服务
type TaskService struct {
}
// 对抢单任务进行确认
// ConfirmRobTask 对抢单任务进行确认
func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.ConfirmRobTaskCommand) (interface{}, error) {
if err := confirmRobTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -935,7 +935,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
if sponsorInvalid == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者")
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者:"+ sponsorInvalid.EmployeeInfo.EmployeeName)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者:"+sponsorInvalid.EmployeeInfo.EmployeeName)
}
// 获取任务指派人
... ... @@ -959,7 +959,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
if employeeInvalid == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:" + employeeInvalid.EmployeeInfo.EmployeeName)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:"+employeeInvalid.EmployeeInfo.EmployeeName)
}
assignedPerson = employee.EmployeeInfo
}
... ... @@ -1308,7 +1308,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
if employeeInvalid == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:" + employeeInvalid.EmployeeInfo.EmployeeName)
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:"+employeeInvalid.EmployeeInfo.EmployeeName)
}
updateData["assignedPerson"] = employee.EmployeeInfo
} else {
... ...
... ... @@ -3,9 +3,11 @@ package service
import (
"encoding/json"
"github.com/linmadan/egglib-go/core/application"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/event/subscriber"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/unifiedUserCenter/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
"time"
)
... ... @@ -27,8 +29,9 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
_ = transactionContext.RollbackTransaction()
}()
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -37,6 +40,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
} else {
employeeRepository = value
}
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -45,10 +49,36 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
} else {
employeeDao = value
}
var cashPoolDao *dao.CashPoolDao
if value, err := factory.CreateCashPoolDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
cashPoolDao = value
}
// 修改手机号事件订阅初始化
var changePhoneService service.ChangePhoneService
if value, err := factory.CreateChangePhoneService(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
changePhoneService = value
err := changePhoneService.Subscribe(&subscriber.WorthServiceSubscriber{})
if err != nil {
return nil, err
}
}
var companyId int64
var uid int64
var employeeName string
var employeeAccount string
var oldPhone string
var newPhone string
var employeeAvatarUrl string
var isPrincipal bool
var status int
... ... @@ -74,6 +104,12 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
if value, ok := data["avatar"]; ok {
employeeAvatarUrl = value.(string)
}
if value, ok := data["old_phone"]; ok {
oldPhone = value.(string)
}
if value, ok := data["new_phone"]; ok {
newPhone = value.(string)
}
if value, ok := data["admin_type"]; ok {
if int(value.(float64)) == 2 {
isPrincipal = true
... ... @@ -99,6 +135,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
editEmployees = append(editEmployees, editEmployee.(map[string]interface{}))
}
}
if syncEmployeeCallbackCommand.Module == "employee" {
switch syncEmployeeCallbackCommand.Action {
case "import":
... ... @@ -247,6 +284,36 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
break
case "changePhoneAllCompany": // 修改手机号
// 修改用户数据
if ok, err := employeeDao.EmployeeExist(oldPhone); err != nil {
return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
if ok {
err := employeeDao.ChangePhone(oldPhone, newPhone)
if err != nil {
return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
}
}
// 修改业务数据-素币兑换清单
if ok, err := cashPoolDao.ExchangeCashPersonListExist(oldPhone); err != nil {
return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
if ok {
errUpdateExchangeCashPersonList := cashPoolDao.UpdateExchangeCashPersonListUserInfo(oldPhone, newPhone)
if errUpdateExchangeCashPersonList != nil {
return false, application.ThrowError(application.TRANSACTION_ERROR, errUpdateExchangeCashPersonList.Error())
}
}
}
// 发布修改手机号事件
if err := changePhoneService.ChangePhone(oldPhone, newPhone); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
break
default:
return false, nil
}
... ...
... ... @@ -6,6 +6,7 @@ const SERVICE_NAME = "mmm-worth"
var ABILITY_SERVICE_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
var MMM_OPEN_API_SERVICE_HOST = "https://mmm-open-api-dev.fjmaimaimai.com"
var WORTH_SERVICE_GATEWAY_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
var LOG_LEVEL = "debug"
var LOG_File = "logs/app.log"
... ...
... ... @@ -2,7 +2,7 @@ package constant
import "os"
var POSTGRESQL_DB_NAME = "mmm_worth"
var POSTGRESQL_DB_NAME = "mmmworth_dev"
var POSTGRESQL_USER = "postgres"
var POSTGRESQL_PASSWORD = "1993618jack"
var POSTGRESQL_HOST = "127.0.0.1"
... ...
package event
import coreDomain "github.com/linmadan/egglib-go/core/domain"
const USER_CHANGE_PHONE = "user-change-phone"
type PhoneChanged struct {
coreDomain.BaseEvent
OldPhone string `json:"oldPhone"` // 旧手机号
NewPhone string `json:"newPhone"` // 新手机号
}
func (event *PhoneChanged) EventType() string {
return USER_CHANGE_PHONE
}
... ...
... ... @@ -54,7 +54,6 @@ func (exchangeCashActivity *ExchangeCashActivity) Update(data map[string]interfa
if createTime, ok := data["createTime"]; ok && createTime.(time.Time).IsZero() {
exchangeCashActivity.CreateTime = createTime.(time.Time)
}
exchangeCashActivity.CreateTime = time.Now()
return nil
}
... ...
package service
import coreDomain "github.com/linmadan/egglib-go/core/domain"
type ChangePhoneService interface {
coreDomain.DomainEventPublisher
ChangePhone(oldPhone string, newPhone string) error
}
... ...
... ... @@ -6,3 +6,12 @@
package service
import (
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
)
type ExchangeCashService interface {
coreDomain.DomainEventPublisher
ExchangeCash(uid int64, operatorUid int64, suMoney float64, activityId int64, recordDescription string) (*domain.SuMoneyTransactionRecord, error)
}
\ No newline at end of file
... ...
package dao
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
type BidInfosDao struct {
transactionContext *pgTransaction.TransactionContext
}
//TODO ChangeBidInfosSuccessfulBidderAccount
func (dao *BidInfosDao) ChangeBidInfosSuccessfulBidderAccount(uid int64, newAccount string) {
}
func NewBidInfosDao(transactionContext *pgTransaction.TransactionContext) (*BidInfosDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &BidInfosDao{
transactionContext: transactionContext,
}, nil
}
}
... ...
package dao
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
type BidderInfosDao struct {
transactionContext *pgTransaction.TransactionContext
}
//TODO ChangeBidderInfosBidderAccount
func (dao *BidderInfosDao) ChangeBidderInfosBidderAccount() {
}
func NewBidderInfosDao(transactionContext *pgTransaction.TransactionContext) (*BidderInfosDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &BidderInfosDao{
transactionContext: transactionContext,
}, nil
}
}
... ...
... ... @@ -2,6 +2,7 @@ package dao
import (
"fmt"
"github.com/go-pg/pg"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
)
... ... @@ -19,13 +20,13 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map
if err := tx.Model(exchangeCashPersonListModels).
ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS activity_exchanged_su_money").
Where("exchange_cash_person_list.activity_id = ?", activityId).
Select(&activityExchangedSuMoney); err !=nil {
Select(&activityExchangedSuMoney); err != nil {
return nil, err
}
if err := tx.Model(exchangeCashPersonListModels).
ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS activity_exchanged_cash").
Where("exchange_cash_person_list.activity_id = ?", activityId).
Select(&activityExchangedCash); err !=nil {
Select(&activityExchangedCash); err != nil {
return nil, err
}
return map[string]interface{}{
... ... @@ -34,6 +35,27 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map
}, nil
}
// ExchangeCashPersonListExist 判断素币兑换清单是否存在
func (dao *CashPoolDao) ExchangeCashPersonListExist(oldPhone string) (bool, error) {
tx := dao.transactionContext.PgTx
m := models.ExchangeCashPersonList{}
query := tx.Model(&m).Where("employee_account=?", oldPhone)
ok, err := query.Exists()
return ok, err
}
// UpdateExchangeCashPersonListUserInfo 更新素币兑换清单用户信息
func (dao *CashPoolDao) UpdateExchangeCashPersonListUserInfo(oldPhone string, newPhone string) error {
tx := dao.transactionContext.PgTx
if _, err := tx.Query(
pg.Scan(),
"UPDATE exchange_cash_person_lists SET employee_account = ? WHERE employee_account = ?",
newPhone, oldPhone); err != nil {
return err
}
return nil
}
// 返回兑换活动清单榜单
func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) {
var retPeople []struct {
... ... @@ -67,7 +89,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryPeople = queryPeople.Where("e.company_id = ?", companyId)
}
if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){
if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0) {
queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId)
}
queryPeople = queryPeople.Group("exchange_cash_person_list.uid")
... ... @@ -104,7 +126,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryPeopleAll = queryPeopleAll.Where("e.company_id = ?", companyId)
}
if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){
if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0) {
queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId)
}
queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid")
... ... @@ -172,7 +194,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
return nil, err
}
return map[string]interface{} {
return map[string]interface{}{
"people": retPeople, // 员工排行榜
"count": count, // 计数
"currentEmployee": currentEmployee, // 当前员工排名
... ...
... ... @@ -57,6 +57,27 @@ func (dao *EmployeeDao) ChangePrincipal(companyId int64, employeeAccount string)
return nil
}
// EmployeeExist 判断员工是否存在
func (dao *EmployeeDao) EmployeeExist(oldPhone string) (bool, error) {
tx := dao.transactionContext.PgTx
m := models.Employee{}
query := tx.Model(&m).Where("employee_account=?", oldPhone)
ok, err := query.Exists()
return ok, err
}
// ChangePhone 修改用户手机号
func (dao *EmployeeDao) ChangePhone(oldPhone string, newPhone string) error {
tx := dao.transactionContext.PgTx
if _, err := tx.Query(
pg.Scan(),
"UPDATE employees SET employee_account=? WHERE employee_account=?",
newPhone, oldPhone); err != nil {
return err
}
return nil
}
// 更新用户素币
func (dao *EmployeeDao) TransferSuMoney(uid int64, suMoney float64) error {
tx := dao.transactionContext.PgTx
... ... @@ -139,7 +160,7 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{
}
// 计算系统已兑换现金素币、未兑换素币
func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] interface{}, error) {
func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string]interface{}, error) {
var systemUnExchangeSuMoney float64
var systemExchangedSuMoney float64
var systemExchangedSuMoneyRestore float64
... ... @@ -172,14 +193,14 @@ func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] int
Select(&systemExchangedSuMoneyRestore); err != nil {
return nil, err
}
return map[string] interface{} {
return map[string]interface{}{
"systemUnExchangeSuMoney": systemUnExchangeSuMoney,
"systemExchangedSuMoney": systemExchangedSuMoney - systemExchangedSuMoneyRestore,
},nil
}, nil
}
// 计算现金池已兑换现金、未兑换现金
func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interface{}, error) {
func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string]interface{}, error) {
tx := dao.transactionContext.PgTx
var (
systemUnExchangeCash float64
... ... @@ -192,7 +213,7 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf
Where("cash_pool.company_id = ?", companyId).
Order("id DESC").
Limit(1).
Select(&systemExchangedCash) ; err != nil {
Select(&systemExchangedCash); err != nil {
return nil, err
}
// 系统未兑换现金
... ... @@ -201,10 +222,10 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf
Where("cash_pool.company_id = ?", companyId).
Order("id DESC").
Limit(1).
Select(&systemUnExchangeCash) ; err != nil {
Select(&systemUnExchangeCash); err != nil {
return nil, err
}
return map[string] interface{} {
return map[string]interface{}{
"systemUnExchangeCash": systemUnExchangeCash,
"systemExchangedCash": systemExchangedCash,
}, nil
... ...
package dao
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
type OffTaskRecordsDao struct {
transactionContext *pgTransaction.TransactionContext
}
//TODO ChangeOffTaskRecordsOperatorAccount
func (dao *OffTaskRecordsDao) ChangeOffTaskRecordsOperatorAccount() {
}
func NewOffTaskRecordsDao(transactionContext *pgTransaction.TransactionContext) (*OffTaskRecordsDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &OffTaskRecordsDao{
transactionContext: transactionContext,
}, nil
}
}
... ...
package dao
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
type RejectTaskRecordsDao struct {
transactionContext *pgTransaction.TransactionContext
}
//TODO ChangeRejectTaskRecordsOperatorAccount
func (dao *RejectTaskRecordsDao) ChangeRejectTaskRecordsOperatorAccount() {
}
func NewRejectTaskRecordsDao(transactionContext *pgTransaction.TransactionContext) (*RejectTaskRecordsDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &RejectTaskRecordsDao{
transactionContext: transactionContext,
}, nil
}
}
... ...
package dao
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
type RobInfosDao struct {
transactionContext *pgTransaction.TransactionContext
}
//TODO ChangeRobInfosReceiverAccount
func (dao *RobInfosDao) ChangeRobInfosReceiverAccount() {
}
func NewRobInfosDao(transactionContext *pgTransaction.TransactionContext) (*RobInfosDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &RobInfosDao{
transactionContext: transactionContext,
}, nil
}
}
... ...
package dao
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
type SentNotificationDao struct {
transactionContext *pgTransaction.TransactionContext
}
// ChangeSentNotificationReceiverAccount TODO 修改已发送通知用户信息
func (dao *SentNotificationDao) ChangeSentNotificationReceiverAccount() {
}
func NewSentNotificationDao(transactionContext *pgTransaction.TransactionContext) (*SentNotificationDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &SentNotificationDao{
transactionContext: transactionContext,
}, nil
}
}
... ...
package dao
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
)
type SuMoneyTransactionRecordsDao struct {
transactionContext *pgTransaction.TransactionContext
}
// ChangeSuMoneyTransactionRecordsEmployeeAccount TODO 修改素币流水记录用户信息
func (dao *SuMoneyTransactionRecordsDao) ChangeSuMoneyTransactionRecordsEmployeeAccount() {
}
// ChangeSuMoneyTransactionRecordsOperatorAccount TODO 素币流水记操作人信息
func (dao *SuMoneyTransactionRecordsDao) ChangeSuMoneyTransactionRecordsOperatorAccount() {
}
func NewSuMoneyTransactionRecordsDao(transactionContext *pgTransaction.TransactionContext) (*SuMoneyTransactionRecordsDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &SuMoneyTransactionRecordsDao{
transactionContext: transactionContext,
}, nil
}
}
... ...
... ... @@ -362,6 +362,26 @@ func (dao *TaskDao) CalculatePersonTask(uid int64, companyId int) (map[string]in
}, nil
}
//TODO ChangeSponsorAccount 修改sponsor手机号 jsonb
func (dao *TaskDao) ChangeSponsorAccount() {
}
//TODO ChangeParticipatorAccount 修改participator手机号 jsonb_array
func (dao *TaskDao) ChangeParticipatorAccount() {
}
//TODO ChangeTaskPercentageContributorAccount 修改task_percentage contributor手机号 jsonb_array
func (dao *TaskDao) ChangeTaskPercentageContributorAccount() {
}
//TODO ChangeAssignedPersonAccount 修改assigned_person手机号 jsonb
func (dao *TaskDao) ChangeAssignedPersonAccount() {
}
func NewTaskDao(transactionContext *pgTransaction.TransactionContext) (*TaskDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
... ...
package domain_service
import (
"fmt"
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event"
)
type ChangePhoneService struct {
coreDomain.BaseEventPublisher
transactionContext *pgTransaction.TransactionContext
}
func (service *ChangePhoneService) ChangePhone(oldPhone string, newPhone string) error {
changePhoneEvent := new(event.PhoneChanged)
changePhoneEvent.OldPhone = oldPhone
changePhoneEvent.NewPhone = newPhone
if err := service.Publish(changePhoneEvent); err != nil {
return err
}
return nil
}
func NewChangePhoneService(transactionContext *pgTransaction.TransactionContext) (*ChangePhoneService, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &ChangePhoneService{
transactionContext: transactionContext,
}, nil
}
}
... ...
package service_gateway
import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/constant"
"strings"
"time"
)
type HttplibWorthServiceGateway struct {
httplibBaseServiceGateway
}
// ChangePhoneCallback 修改手机号码回调,通知价值APP端中台
func (serviceGateway *HttplibWorthServiceGateway) ChangePhoneCallback(oldPhone string, newPhone string) (map[string]interface{}, error) {
url := strings.Join([]string{serviceGateway.baseURL, "/v1/auth/forceRevoke"}, "/")
request := serviceGateway.createRequest(url, "post")
options := make(map[string]interface{})
options["phone"] = oldPhone
request.JSONBody(options)
response := make(map[string]interface{})
request.ToJSON(&response)
data, err := serviceGateway.responseHandle(response)
return data, err
}
func NewHttplibWorthServiceGateway() *HttplibWorthServiceGateway {
return &HttplibWorthServiceGateway{
httplibBaseServiceGateway: httplibBaseServiceGateway{
baseURL: constant.ABILITY_SERVICE_HOST,
connectTimeout: 100 * time.Second,
readWriteTimeout: 30 * time.Second,
},
}
}
... ...
... ... @@ -14,3 +14,7 @@ type AbilityServiceGateway interface {
type MmmOpenApiServiceGateway interface {
PushInfo(msgType int, uids []int64, title string, content string, ext map[string]interface{}) (map[string]interface{}, error)
}
type WorthServiceGateway interface {
ChangePhoneCallback(oldPhone string, newPhone string) (map[string]interface{}, error)
}
... ...
... ... @@ -8,7 +8,7 @@ import (
/**
* @Author SteveChan
* @Description //TODO
* @Description
* @Date 16:50 2020/12/10
* @Param
* @return
... ... @@ -34,7 +34,7 @@ func StringSliceEqualBCE(a, b []int) bool {
/**
* @Author SteveChan
* @Description //TODO
* @Description
* @Date 16:50 2020/12/10
* @Param
* @return
... ... @@ -50,7 +50,7 @@ func IsContain(items []interface{}, item string) bool {
/**
* @Author SteveChan
* @Description //TODO
* @Description
* @Date 16:50 2020/12/10
* @Param
* @return
... ... @@ -80,7 +80,7 @@ func (l LocalDate) MarshalJSON() ([]byte, error) {
/**
* @Author SteveChan
* @Description //TODO
* @Description
* @Date 16:49 2020/12/10
* @Param
* @return
... ...