作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !15
@@ -57,11 +57,11 @@ spec: @@ -57,11 +57,11 @@ spec:
57 - name: POSTGRESQL_USER 57 - name: POSTGRESQL_USER
58 value: "postgres" 58 value: "postgres"
59 - name: POSTGRESQL_PASSWORD 59 - name: POSTGRESQL_PASSWORD
60 - value: "postgres_55_online" 60 + value: "chJVQkg1sys"
61 - name: POSTGRESQL_HOST 61 - name: POSTGRESQL_HOST
62 - value: "112.124.115.55" 62 + value: "114.55.200.59"
63 - name: POSTGRESQL_PORT 63 - name: POSTGRESQL_PORT
64 - value: "15432" 64 + value: "31544"
65 - name: LOG_LEVEL 65 - name: LOG_LEVEL
66 value: "debug" 66 value: "debug"
67 - name: ERROR_BASE_CODE 67 - name: ERROR_BASE_CODE
@@ -52,7 +52,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU @@ -52,7 +52,6 @@ github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfU
52 github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 52 github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
53 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 53 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
54 github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 54 github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
55 -github.com/golang/protobuf v1.3.2 h1:6nsPYzhq5kReh6QImI3k5qWzO4PEbvbIW2cwSfR/6xs=  
56 github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 55 github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
57 github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= 56 github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
58 github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= 57 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 @@ -92,7 +91,6 @@ github.com/klauspost/compress v1.8.2 h1:Bx0qjetmNjdFXASH02NSAREKpiaDwkO1DRZ3dV2K
92 github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= 91 github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
93 github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w= 92 github.com/klauspost/cpuid v1.2.1 h1:vJi+O/nMdFt0vqm8NZBI6wzALWdA2X+egi0ogNyrC/w=
94 github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek= 93 github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
95 -github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=  
96 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 94 github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
97 github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= 95 github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
98 github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= 96 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 @@ -137,7 +135,6 @@ github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFR
137 github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= 135 github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
138 github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg= 136 github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg=
139 github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA= 137 github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
140 -github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4=  
141 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= 138 github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
142 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM= 139 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
143 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= 140 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 @@ -147,9 +144,7 @@ github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXc
147 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 144 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
148 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 145 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
149 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= 146 github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
150 -github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=  
151 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 147 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
152 -github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=  
153 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 148 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
154 github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= 149 github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
155 github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= 150 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 @@ -184,7 +179,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
184 golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= 179 golang.org/x/crypto v0.0.0-20190404164418-38d8ce5564a5/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
185 golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 180 golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
186 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 181 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
187 -golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf h1:fnPsqIDRbCSgumaMCRpoIoF2s4qxv0xSSS0BVZUE/ss=  
188 golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 182 golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
189 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 183 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
190 golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM= 184 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 @@ -206,7 +200,6 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
206 golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= 200 golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks=
207 golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 201 golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
208 golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 202 golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
209 -golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g=  
210 golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 203 golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
211 golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA= 204 golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
212 golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= 205 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 @@ -221,17 +214,13 @@ golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7w
221 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 214 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
222 golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 215 golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
223 golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 216 golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
224 -golang.org/x/sys v0.0.0-20191010194322-b09406accb47 h1:/XfQ9z7ib8eEJX2hdgFTZJ/ntt0swNk5oYBziWeTCvY=  
225 golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 217 golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
226 golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 218 golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
227 -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=  
228 golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 219 golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
229 -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=  
230 golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 220 golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
231 golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e h1:AyodaIpKjppX+cBfTASF2E1US3H2JFBj920Ot3rtDjs= 221 golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e h1:AyodaIpKjppX+cBfTASF2E1US3H2JFBj920Ot3rtDjs=
232 golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 222 golang.org/x/sys v0.0.0-20201214210602-f9fddec55a1e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
233 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 223 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
234 -golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=  
235 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 224 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
236 golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= 225 golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
237 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 226 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 @@ -242,7 +231,6 @@ golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3
242 golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 231 golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
243 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 232 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
244 golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 233 golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
245 -golang.org/x/tools v0.0.0-20200117065230-39095c1d176c h1:FodBYPZKH5tAN2O60HlglMwXGAeV/4k+NKbli79M/2c=  
246 golang.org/x/tools v0.0.0-20200117065230-39095c1d176c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= 234 golang.org/x/tools v0.0.0-20200117065230-39095c1d176c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
247 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 235 golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
248 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 236 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 @@ -279,7 +267,6 @@ gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkep
279 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 267 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
280 gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 268 gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
281 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 269 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
282 -gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=  
283 gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 270 gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
284 gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= 271 gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
285 gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= 272 gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
@@ -2,6 +2,7 @@ package subscriber @@ -2,6 +2,7 @@ package subscriber
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 +
5 coreDomain "github.com/linmadan/egglib-go/core/domain" 6 coreDomain "github.com/linmadan/egglib-go/core/domain"
6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
7 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" 8 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
  1 +package subscriber
  2 +
  3 +import (
  4 + "fmt"
  5 + "github.com/linmadan/egglib-go/core/domain"
  6 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
  7 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event"
  8 +)
  9 +
  10 +type WorthServiceSubscriber struct {
  11 +}
  12 +
  13 +func (subscriber *WorthServiceSubscriber) HandleEvent(domainEvent domain.DomainEvent) error {
  14 + worthServiceGateway, err := factory.CreateWorthServiceGateway(nil)
  15 + if err != nil {
  16 + fmt.Println(err.Error())
  17 + return nil
  18 + }
  19 + switch domainEvent.EventType() {
  20 + case event.USER_CHANGE_PHONE:
  21 + phoneChangedEvent := domainEvent.(*event.PhoneChanged)
  22 + data, err := worthServiceGateway.ChangePhoneCallback(phoneChangedEvent.OldPhone, phoneChangedEvent.NewPhone)
  23 + if err != nil {
  24 + fmt.Println(err.Error())
  25 + return nil
  26 + }
  27 + fmt.Println(data)
  28 + break
  29 + }
  30 + return nil
  31 +}
  32 +
  33 +func (subscriber *WorthServiceSubscriber) SubscribedToEventTypes() []string {
  34 + return []string{
  35 + event.USER_CHANGE_PHONE,
  36 + }
  37 +}
@@ -110,5 +110,10 @@ func CreateExchangeSuMoneyService(options map[string]interface{}) (service.Excha @@ -110,5 +110,10 @@ func CreateExchangeSuMoneyService(options map[string]interface{}) (service.Excha
110 return domainService.NewExchangeSuMoneyService(transactionContext) 110 return domainService.NewExchangeSuMoneyService(transactionContext)
111 } 111 }
112 112
113 -  
114 - 113 +func CreateChangePhoneService(options map[string]interface{}) (service.ChangePhoneService, error) {
  114 + var transactionContext *pgTransaction.TransactionContext
  115 + if value, ok := options["transactionContext"]; ok {
  116 + transactionContext = value.(*pgTransaction.TransactionContext)
  117 + }
  118 + return domainService.NewChangePhoneService(transactionContext)
  119 +}
@@ -9,3 +9,7 @@ func CreateAbilityServiceGateway(options map[string]interface{}) (serviceGateway @@ -9,3 +9,7 @@ func CreateAbilityServiceGateway(options map[string]interface{}) (serviceGateway
9 func CreateMmmOpenApiServiceGateway(options map[string]interface{}) (serviceGateway.MmmOpenApiServiceGateway, error) { 9 func CreateMmmOpenApiServiceGateway(options map[string]interface{}) (serviceGateway.MmmOpenApiServiceGateway, error) {
10 return serviceGateway.NewHttplibMmmOpenApiServiceGateway(), nil 10 return serviceGateway.NewHttplibMmmOpenApiServiceGateway(), nil
11 } 11 }
  12 +
  13 +func CreateWorthServiceGateway(options map[string]interface{}) (serviceGateway.WorthServiceGateway, error) {
  14 + return serviceGateway.NewHttplibWorthServiceGateway(), nil
  15 +}
@@ -62,7 +62,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -62,7 +62,7 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
62 62
63 // 现金池仓储初始化 63 // 现金池仓储初始化
64 var cashPoolRepository domain.CashPoolRepository 64 var cashPoolRepository domain.CashPoolRepository
65 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 65 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
66 "transactionContext": transactionContext, 66 "transactionContext": transactionContext,
67 }); err != nil { 67 }); err != nil {
68 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 68 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -97,19 +97,19 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -97,19 +97,19 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
97 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 97 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
98 } 98 }
99 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 平台已兑换素币 99 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 平台已兑换素币
100 - systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 平台未兑换素币 100 + systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 平台未兑换素币
101 101
102 // 获取当前公司现金池 102 // 获取当前公司现金池
103 count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(createCashPoolCommand)) 103 count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(createCashPoolCommand))
104 if err != nil { 104 if err != nil {
105 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 105 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
106 } 106 }
107 - if len(cashPools) > 0 { // 更新现金池 107 + if len(cashPools) > 0 { // 更新现金池
108 cashPoolExchangeCash := cashPools[0].ExchangedCash 108 cashPoolExchangeCash := cashPools[0].ExchangedCash
109 cashPoolUnExchangeCash := cashPools[0].UnExchangeCash 109 cashPoolUnExchangeCash := cashPools[0].UnExchangeCash
110 cashPoolCash := cashPools[0].Cash 110 cashPoolCash := cashPools[0].Cash
111 111
112 - if createCashPoolCommand.Cash < cashPoolExchangeCash { 112 + if createCashPoolCommand.Cash < cashPoolExchangeCash {
113 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "投入的现金值必须大于当前已兑换现金值") 113 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "投入的现金值必须大于当前已兑换现金值")
114 } 114 }
115 115
@@ -125,16 +125,16 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -125,16 +125,16 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
125 var lastActivityRate float64 125 var lastActivityRate float64
126 listExchangeCashActivityQuery := map[string]interface{}{ 126 listExchangeCashActivityQuery := map[string]interface{}{
127 "companyId": createCashPoolCommand.CompanyId, 127 "companyId": createCashPoolCommand.CompanyId,
128 - "order": "deadline DESC",  
129 - "nearest": true,  
130 - "limit": 1, 128 + "order": "deadline DESC",
  129 + "nearest": true,
  130 + "limit": 1,
131 } 131 }
132 if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil { 132 if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
133 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 133 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
134 } else { 134 } else {
135 if len(activities) > 0 { 135 if len(activities) > 0 {
136 lastActivityRate = activities[0].Rate 136 lastActivityRate = activities[0].Rate
137 - } else { // 未查询到相关兑换活动 137 + } else { // 未查询到相关兑换活动
138 lastActivityRate = 0 138 lastActivityRate = 0
139 } 139 }
140 } 140 }
@@ -143,15 +143,15 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -143,15 +143,15 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
143 143
144 // 更新现金池命令 144 // 更新现金池命令
145 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 145 updateCashPoolCommand := &command.UpdateCashPoolCommand{
146 - CashPoolId: cashPools[0].CashPoolId,  
147 - Cash: createCashPoolCommand.Cash, 146 + CashPoolId: cashPools[0].CashPoolId,
  147 + Cash: createCashPoolCommand.Cash,
148 ExchangedCash: cashPoolExchangeCash, 148 ExchangedCash: cashPoolExchangeCash,
149 //UnExchangeCash: cashPoolUnExchangeCash + (createCashPoolCommand.Cash - cashPoolCash), 149 //UnExchangeCash: cashPoolUnExchangeCash + (createCashPoolCommand.Cash - cashPoolCash),
150 - UnExchangeCash: unExchangeCash,  
151 - ExchangedSuMoney: systemExchangedSuMoney, 150 + UnExchangeCash: unExchangeCash,
  151 + ExchangedSuMoney: systemExchangedSuMoney,
152 UnExchangeSuMoney: systemUnExchangeSuMoney, 152 UnExchangeSuMoney: systemUnExchangeSuMoney,
153 - Rate: newRate,  
154 - LastRate: lastActivityRate, 153 + Rate: newRate,
  154 + LastRate: lastActivityRate,
155 } 155 }
156 156
157 // 更新现金池 157 // 更新现金池
@@ -180,36 +180,36 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co @@ -180,36 +180,36 @@ func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *co
180 cashPool.LastRate, _ = decimal.NewFromFloatWithExponent(cashPool.LastRate, -2).Float64() 180 cashPool.LastRate, _ = decimal.NewFromFloatWithExponent(cashPool.LastRate, -2).Float64()
181 return cashPool, nil 181 return cashPool, nil
182 } 182 }
183 - } else { // 新增现金池 183 + } else { // 新增现金池
184 // 获取上次兑换活动兑换汇率查询 184 // 获取上次兑换活动兑换汇率查询
185 var lastActivityRate float64 185 var lastActivityRate float64
186 listExchangeCashActivityQuery := map[string]interface{}{ 186 listExchangeCashActivityQuery := map[string]interface{}{
187 "companyId": createCashPoolCommand.CompanyId, 187 "companyId": createCashPoolCommand.CompanyId,
188 - "order": "deadline DESC",  
189 - "nearest": true,  
190 - "limit": 1, 188 + "order": "deadline DESC",
  189 + "nearest": true,
  190 + "limit": 1,
191 } 191 }
192 if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil { 192 if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
193 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 193 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
194 } else { 194 } else {
195 if len(activities) > 0 { 195 if len(activities) > 0 {
196 lastActivityRate = activities[0].Rate 196 lastActivityRate = activities[0].Rate
197 - } else { // 未查询到相关兑换活动 197 + } else { // 未查询到相关兑换活动
198 lastActivityRate = 0 198 lastActivityRate = 0
199 } 199 }
200 } 200 }
201 201
202 // 更新现金池 202 // 更新现金池
203 newCashPool := &domain.CashPool{ 203 newCashPool := &domain.CashPool{
204 - CompanyId: createCashPoolCommand.CompanyId,  
205 - Cash: createCashPoolCommand.Cash,  
206 - ExchangedCash: 0,  
207 - UnExchangeCash: createCashPoolCommand.Cash,  
208 - ExchangedSuMoney: systemExchangedSuMoney, 204 + CompanyId: createCashPoolCommand.CompanyId,
  205 + Cash: createCashPoolCommand.Cash,
  206 + ExchangedCash: 0,
  207 + UnExchangeCash: createCashPoolCommand.Cash,
  208 + ExchangedSuMoney: systemExchangedSuMoney,
209 UnExchangeSuMoney: systemUnExchangeSuMoney, 209 UnExchangeSuMoney: systemUnExchangeSuMoney,
210 - LastRate: lastActivityRate,  
211 - Rate: 0,  
212 - CreateTime: time.Now().Local(), 210 + LastRate: lastActivityRate,
  211 + Rate: 0,
  212 + CreateTime: time.Now().Local(),
213 } 213 }
214 if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil { 214 if cashPool, err := cashPoolRepository.Save(newCashPool); err != nil {
215 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 215 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -271,7 +271,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC @@ -271,7 +271,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
271 271
272 // 现金池仓储初始化 272 // 现金池仓储初始化
273 var cashPoolRepository domain.CashPoolRepository 273 var cashPoolRepository domain.CashPoolRepository
274 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 274 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
275 "transactionContext": transactionContext, 275 "transactionContext": transactionContext,
276 }); err != nil { 276 }); err != nil {
277 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 277 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -304,16 +304,16 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC @@ -304,16 +304,16 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
304 var lastActivityRate float64 304 var lastActivityRate float64
305 listExchangeCashActivityQuery := map[string]interface{}{ 305 listExchangeCashActivityQuery := map[string]interface{}{
306 "companyId": getCashPoolQuery.CompanyId, 306 "companyId": getCashPoolQuery.CompanyId,
307 - "order": "deadline DESC",  
308 - "nearest": true,  
309 - "limit": 1, 307 + "order": "deadline DESC",
  308 + "nearest": true,
  309 + "limit": 1,
310 } 310 }
311 if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil { 311 if _, activities, err := exchangeActivityRepository.Find(listExchangeCashActivityQuery); err != nil {
312 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 312 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
313 } else { 313 } else {
314 if len(activities) > 0 { 314 if len(activities) > 0 {
315 lastActivityRate = activities[0].Rate 315 lastActivityRate = activities[0].Rate
316 - } else { // 未查询到相关兑换活动 316 + } else { // 未查询到相关兑换活动
317 lastActivityRate = 0 317 lastActivityRate = 0
318 } 318 }
319 } 319 }
@@ -327,7 +327,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC @@ -327,7 +327,7 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
327 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司") 327 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的公司")
328 } 328 }
329 //systemUnExchangeSuMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)), 64) // 平台未兑换素币 329 //systemUnExchangeSuMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64)), 64) // 平台未兑换素币
330 - systemUnExchangeSuMoney, _ := decimal.NewFromFloatWithExponent(systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64), -2).Float64() // 平台未兑换素币 330 + systemUnExchangeSuMoney, _ := decimal.NewFromFloatWithExponent(systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64), -2).Float64() // 平台未兑换素币
331 331
332 // 查找当前公司现金池 332 // 查找当前公司现金池
333 if count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(getCashPoolQuery)); err != nil { 333 if count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(getCashPoolQuery)); err != nil {
@@ -338,17 +338,17 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC @@ -338,17 +338,17 @@ func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetC
338 } 338 }
339 // 现金池为空时处理 339 // 现金池为空时处理
340 if count == 0 { 340 if count == 0 {
341 - return map[string] interface{} {  
342 - "cashPoolId": 0,  
343 - "cash": 0,  
344 - "companyId": getCashPoolQuery.CompanyId,  
345 - "exchangedCash": 0,  
346 - "unExchangeCash": 0,  
347 - "exchangedSuMoney": 0, 341 + return map[string]interface{}{
  342 + "cashPoolId": 0,
  343 + "cash": 0,
  344 + "companyId": getCashPoolQuery.CompanyId,
  345 + "exchangedCash": 0,
  346 + "unExchangeCash": 0,
  347 + "exchangedSuMoney": 0,
348 "unExchangeSuMoney": systemUnExchangeSuMoney, 348 "unExchangeSuMoney": systemUnExchangeSuMoney,
349 - "rate": 0, // 平均兑换汇率  
350 - "lastRate": 0, // 上期活动兑换汇率  
351 - "createTime": time.Now().Local(), 349 + "rate": 0, // 平均兑换汇率
  350 + "lastRate": 0, // 上期活动兑换汇率
  351 + "createTime": time.Now().Local(),
352 }, nil 352 }, nil
353 } else { 353 } else {
354 //cashPools[0].Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].Rate), 64) 354 //cashPools[0].Rate, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", cashPools[0].Rate), 64)
@@ -426,13 +426,13 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang @@ -426,13 +426,13 @@ func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchang
426 // 创建兑换活动命令 426 // 创建兑换活动命令
427 newActivity := &domain.ExchangeCashActivity{ 427 newActivity := &domain.ExchangeCashActivity{
428 ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName, 428 ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName,
429 - CompanyId: createExchangeCashActivityCommand.CompanyId,  
430 - ExchangedCash: 0,  
431 - ExchangedSuMoney: 0,  
432 - Deadline: t2,  
433 - CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算活动截止倒计时  
434 - Rate: createExchangeCashActivityCommand.ExchangeRate,  
435 - CreateTime: time.Now().Local(), 429 + CompanyId: createExchangeCashActivityCommand.CompanyId,
  430 + ExchangedCash: 0,
  431 + ExchangedSuMoney: 0,
  432 + Deadline: t2,
  433 + CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算活动截止倒计时
  434 + Rate: createExchangeCashActivityCommand.ExchangeRate,
  435 + CreateTime: time.Now().Local(),
436 } 436 }
437 437
438 // 倒计时结束判断 438 // 倒计时结束判断
@@ -543,13 +543,13 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma @@ -543,13 +543,13 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
543 var t2 = activity.Deadline 543 var t2 = activity.Deadline
544 544
545 // 获取兑换活动前先更新兑换活动倒计时命令 545 // 获取兑换活动前先更新兑换活动倒计时命令
546 - updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { 546 + updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
547 ExchangeCashActivityId: activity.ActivityId, 547 ExchangeCashActivityId: activity.ActivityId,
548 - CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算倒计时  
549 - Deadline: activity.Deadline,  
550 - ExchangedSuMoney: activity.ExchangedSuMoney,  
551 - ExchangedCash: activity.ExchangedCash,  
552 - ExchangeRate: activity.Rate, 548 + CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)), // 计算倒计时
  549 + Deadline: activity.Deadline,
  550 + ExchangedSuMoney: activity.ExchangedSuMoney,
  551 + ExchangedCash: activity.ExchangedCash,
  552 + ExchangeRate: activity.Rate,
553 } 553 }
554 554
555 // 倒计时结束处理 555 // 倒计时结束处理
@@ -579,16 +579,16 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma @@ -579,16 +579,16 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
579 //suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64) 579 //suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activity.ExchangedSuMoney), 64)
580 cash, _ := decimal.NewFromFloatWithExponent(activity.ExchangedCash, -2).Float64() 580 cash, _ := decimal.NewFromFloatWithExponent(activity.ExchangedCash, -2).Float64()
581 suMoney, _ := decimal.NewFromFloatWithExponent(activity.ExchangedSuMoney, -2).Float64() 581 suMoney, _ := decimal.NewFromFloatWithExponent(activity.ExchangedSuMoney, -2).Float64()
582 - activityFormat := map[string]interface{} {  
583 - "activityId": activity.ActivityId, 582 + activityFormat := map[string]interface{}{
  583 + "activityId": activity.ActivityId,
584 "exchangeActivityName": activity.ExchangeActivityName, 584 "exchangeActivityName": activity.ExchangeActivityName,
585 - "companyId": activity.CompanyId,  
586 - "exchangedCash": cash,  
587 - "exchangedSuMoney": suMoney,  
588 - "deadline": activity.Deadline.Local(),  
589 - "countDown": activity.CountDown,  
590 - "rate": activity.Rate,  
591 - "createTime": activity.CreateTime.Local(), 585 + "companyId": activity.CompanyId,
  586 + "exchangedCash": cash,
  587 + "exchangedSuMoney": suMoney,
  588 + "deadline": activity.Deadline.Local(),
  589 + "countDown": activity.CountDown,
  590 + "rate": activity.Rate,
  591 + "createTime": activity.CreateTime.Local(),
592 } 592 }
593 activitiesFormat = append(activitiesFormat, activityFormat) 593 activitiesFormat = append(activitiesFormat, activityFormat)
594 } 594 }
@@ -598,7 +598,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma @@ -598,7 +598,7 @@ func (cashPoolService *CashPoolService) SearchExchangeCashActivity(activityComma
598 } 598 }
599 599
600 return map[string]interface{}{ 600 return map[string]interface{}{
601 - "count": count, 601 + "count": count,
602 "activities": activitiesFormat, 602 "activities": activitiesFormat,
603 }, nil 603 }, nil
604 } 604 }
@@ -633,12 +633,12 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -633,12 +633,12 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
633 633
634 // 查找兑换现金活动 634 // 查找兑换现金活动
635 if count, activitiesFound, err := exchangeActivityRepository.Find(map[string]interface{}{ 635 if count, activitiesFound, err := exchangeActivityRepository.Find(map[string]interface{}{
636 - "companyId": listExchangeCashActivityQuery.CompanyId, 636 + "companyId": listExchangeCashActivityQuery.CompanyId,
637 "activityNameMatch": listExchangeCashActivityQuery.ActivityNameMatch, 637 "activityNameMatch": listExchangeCashActivityQuery.ActivityNameMatch,
638 - "offset": listExchangeCashActivityQuery.Offset,  
639 - "limit": listExchangeCashActivityQuery.Limit,  
640 - "countdown": 0,  
641 - "isEnd": listExchangeCashActivityQuery.IsEnd, 638 + "offset": listExchangeCashActivityQuery.Offset,
  639 + "limit": listExchangeCashActivityQuery.Limit,
  640 + "countdown": 0,
  641 + "isEnd": listExchangeCashActivityQuery.IsEnd,
642 }); err != nil { 642 }); err != nil {
643 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 643 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
644 } else { 644 } else {
@@ -647,13 +647,13 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -647,13 +647,13 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
647 var t2 = activityFound.Deadline.Local() 647 var t2 = activityFound.Deadline.Local()
648 648
649 // 更新兑换现金活动倒计时命令 649 // 更新兑换现金活动倒计时命令
650 - updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { 650 + updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
651 ExchangeCashActivityId: activityFound.ActivityId, 651 ExchangeCashActivityId: activityFound.ActivityId,
652 - CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),  
653 - Deadline: activityFound.Deadline.Local(),  
654 - ExchangedSuMoney: activityFound.ExchangedSuMoney,  
655 - ExchangedCash: activityFound.ExchangedCash,  
656 - ExchangeRate: activityFound.Rate, 652 + CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
  653 + Deadline: activityFound.Deadline.Local(),
  654 + ExchangedSuMoney: activityFound.ExchangedSuMoney,
  655 + ExchangedCash: activityFound.ExchangedCash,
  656 + ExchangeRate: activityFound.Rate,
657 } 657 }
658 658
659 // 倒计时结束处理 659 // 倒计时结束处理
@@ -684,16 +684,16 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -684,16 +684,16 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
684 //suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedSuMoney), 64) 684 //suMoney, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", activityFound.ExchangedSuMoney), 64)
685 cash, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedCash, -2).Float64() 685 cash, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedCash, -2).Float64()
686 suMoney, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedSuMoney, -2).Float64() 686 suMoney, _ := decimal.NewFromFloatWithExponent(activityFound.ExchangedSuMoney, -2).Float64()
687 - activityWithTs := map[string]interface{} {  
688 - "activityId": activityFound.ActivityId, 687 + activityWithTs := map[string]interface{}{
  688 + "activityId": activityFound.ActivityId,
689 "exchangeActivityName": activityFound.ExchangeActivityName, 689 "exchangeActivityName": activityFound.ExchangeActivityName,
690 - "companyId": activityFound.CompanyId,  
691 - "exchangedCash": cash,  
692 - "exchangedSuMoney": suMoney,  
693 - "deadline": activityFound.Deadline.Local().UnixNano() / 1e6, // 秒级时间戳转换  
694 - "countDown": activityFound.CountDown,  
695 - "rate": activityFound.Rate,  
696 - "createTime": activityFound.CreateTime.Local(), 690 + "companyId": activityFound.CompanyId,
  691 + "exchangedCash": cash,
  692 + "exchangedSuMoney": suMoney,
  693 + "deadline": activityFound.Deadline.Local().UnixNano() / 1e6, // 秒级时间戳转换
  694 + "countDown": activityFound.CountDown,
  695 + "rate": activityFound.Rate,
  696 + "createTime": activityFound.CreateTime.Local(),
697 } 697 }
698 activitiesWithTs = append(activitiesWithTs, activityWithTs) 698 activitiesWithTs = append(activitiesWithTs, activityWithTs)
699 } 699 }
@@ -703,7 +703,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas @@ -703,7 +703,7 @@ func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCas
703 } 703 }
704 704
705 return map[string]interface{}{ 705 return map[string]interface{}{
706 - "count": count, 706 + "count": count,
707 "activities": activitiesWithTs, 707 "activities": activitiesWithTs,
708 }, nil 708 }, nil
709 } 709 }
@@ -798,13 +798,13 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA @@ -798,13 +798,13 @@ func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashA
798 var t2 = activityFound.Deadline 798 var t2 = activityFound.Deadline
799 799
800 // 更新兑换现金活动倒计时命令 800 // 更新兑换现金活动倒计时命令
801 - updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand { 801 + updateExchangeCashActivity := &command.UpdateExchangeCashActivityCommand{
802 ExchangeCashActivityId: activityFound.ActivityId, 802 ExchangeCashActivityId: activityFound.ActivityId,
803 - CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),  
804 - Deadline: activityFound.Deadline,  
805 - ExchangedSuMoney: activityFound.ExchangedSuMoney,  
806 - ExchangedCash: activityFound.ExchangedCash,  
807 - ExchangeRate: activityFound.Rate, 803 + CountDown: int64(math.Ceil(t2.Sub(t1).Hours() / 24)),
  804 + Deadline: activityFound.Deadline,
  805 + ExchangedSuMoney: activityFound.ExchangedSuMoney,
  806 + ExchangedCash: activityFound.ExchangedCash,
  807 + ExchangeRate: activityFound.Rate,
808 } 808 }
809 809
810 // 倒计时结束处理 810 // 倒计时结束处理
@@ -877,7 +877,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -877,7 +877,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
877 877
878 // 现金池仓储初始化 878 // 现金池仓储初始化
879 var cashPoolRepository domain.CashPoolRepository 879 var cashPoolRepository domain.CashPoolRepository
880 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 880 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
881 "transactionContext": transactionContext, 881 "transactionContext": transactionContext,
882 }); err != nil { 882 }); err != nil {
883 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 883 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -903,8 +903,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -903,8 +903,8 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
903 if activityFound == nil { 903 if activityFound == nil {
904 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId))) 904 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId)))
905 } 905 }
906 - activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前活动已兑换素币  
907 - activityFoundExchangedCash := activityFound.ExchangedCash // 当前活动已兑换现金 906 + activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前活动已兑换素币
  907 + activityFoundExchangedCash := activityFound.ExchangedCash // 当前活动已兑换现金
908 908
909 // 获取当前公司现金池 909 // 获取当前公司现金池
910 cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{ 910 cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
@@ -968,9 +968,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -968,9 +968,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
968 // 获取当前兑换活动汇率 968 // 获取当前兑换活动汇率
969 activityFoundRate := activityFound.Rate 969 activityFoundRate := activityFound.Rate
970 970
971 - if updateExchangeCashActivityCommand.ExchangeRate != activityFoundRate && updateExchangeCashActivityCommand.ExchangeRate != 0 { // 更新兑换活动兑换汇率 971 + if updateExchangeCashActivityCommand.ExchangeRate != activityFoundRate && updateExchangeCashActivityCommand.ExchangeRate != 0 { // 更新兑换活动兑换汇率
972 // 判断兑换活动清单中现金总金额是否超过平台未兑换现金值 972 // 判断兑换活动清单中现金总金额是否超过平台未兑换现金值
973 - if activityFoundExchangedSuMoney * updateExchangeCashActivityCommand.ExchangeRate > cashPoolFoundUnExchangeCash { 973 + if activityFoundExchangedSuMoney*updateExchangeCashActivityCommand.ExchangeRate > cashPoolFoundUnExchangeCash {
974 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金") 974 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
975 } 975 }
976 976
@@ -988,9 +988,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -988,9 +988,9 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
988 988
989 // 更新兑换清单命令 989 // 更新兑换清单命令
990 exchangeCash, _ := decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangeRate).Mul(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64() 990 exchangeCash, _ := decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangeRate).Mul(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
991 - updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand { 991 + updateExchangeCashPerson := &command.UpdateExchangeCashPersonCommand{
992 //ExchangedCash: updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney, 992 //ExchangedCash: updateExchangeCashActivityCommand.ExchangeRate * personFoundExchangedSuMoney,
993 - ExchangedCash: exchangeCash, 993 + ExchangedCash: exchangeCash,
994 ExchangedSuMoney: personFoundExchangedSuMoney, 994 ExchangedSuMoney: personFoundExchangedSuMoney,
995 } 995 }
996 996
@@ -1000,7 +1000,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -1000,7 +1000,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
1000 } 1000 }
1001 1001
1002 // 保存素币兑换清单更新 1002 // 保存素币兑换清单更新
1003 - if _, err := exchangeCashPersonListRepository.Save(personFound);err != nil { 1003 + if _, err := exchangeCashPersonListRepository.Save(personFound); err != nil {
1004 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1004 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1005 } 1005 }
1006 } 1006 }
@@ -1034,16 +1034,16 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang @@ -1034,16 +1034,16 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchang
1034 exchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64() 1034 exchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64()
1035 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64() 1035 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(updateExchangeCashActivityCommand.ExchangedCash).Sub(decimal.NewFromFloat(activityFoundExchangedCash))).Float64()
1036 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 1036 updateCashPoolCommand := &command.UpdateCashPoolCommand{
1037 - CashPoolId: cashPoolFound.CashPoolId, 1037 + CashPoolId: cashPoolFound.CashPoolId,
1038 //ExchangedCash: cashPoolFoundExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash), 1038 //ExchangedCash: cashPoolFoundExchangedCash + (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash),
1039 //UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash), 1039 //UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashActivityCommand.ExchangedCash - activityFoundExchangedCash),
1040 - ExchangedCash: exchangedCash,  
1041 - UnExchangeCash: unExchangeCash,  
1042 - ExchangedSuMoney: systemExchangedSuMoney,  
1043 - UnExchangeSuMoney: systemUnExchangeSuMoney,  
1044 - Rate: rate,  
1045 - LastRate: cashPoolFound.LastRate,  
1046 - Cash: cashPoolFound.Cash, 1040 + ExchangedCash: exchangedCash,
  1041 + UnExchangeCash: unExchangeCash,
  1042 + ExchangedSuMoney: systemExchangedSuMoney,
  1043 + UnExchangeSuMoney: systemUnExchangeSuMoney,
  1044 + Rate: rate,
  1045 + LastRate: cashPoolFound.LastRate,
  1046 + Cash: cashPoolFound.Cash,
1047 } 1047 }
1048 1048
1049 // 更新现金池 1049 // 更新现金池
@@ -1169,7 +1169,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1169,7 +1169,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1169 1169
1170 // 现金池仓储初始化 1170 // 现金池仓储初始化
1171 var cashPoolRepository domain.CashPoolRepository 1171 var cashPoolRepository domain.CashPoolRepository
1172 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 1172 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
1173 "transactionContext": transactionContext, 1173 "transactionContext": transactionContext,
1174 }); err != nil { 1174 }); err != nil {
1175 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1175 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -1218,9 +1218,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1218,9 +1218,10 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1218 activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney 1218 activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney
1219 activityFoundExchangedCash := activityFound.ExchangedCash 1219 activityFoundExchangedCash := activityFound.ExchangedCash
1220 1220
1221 - // TODO 更改:根据uid和companyId,判断当前员工是否有效 1221 + //更改:根据uid和companyId,判断当前员工是否有效
1222 getEmployee := map[string]interface{}{ 1222 getEmployee := map[string]interface{}{
1223 - "account": personFound.EmployeeInfo.EmployeeAccount, 1223 + "uid": personFound.EmployeeInfo.Uid,
  1224 + //"account": personFound.EmployeeInfo.EmployeeAccount,
1224 "companyId": activityFound.CompanyId, 1225 "companyId": activityFound.CompanyId,
1225 } 1226 }
1226 employeeFound, err := employeeRepository.FindOne(getEmployee) 1227 employeeFound, err := employeeRepository.FindOne(getEmployee)
@@ -1257,15 +1258,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1257,15 +1258,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1257 // 更新素币兑换活动命令 1258 // 更新素币兑换活动命令
1258 exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Float64() 1259 exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Float64()
1259 exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64() 1260 exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()
1260 - updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 1261 + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
1261 ExchangeCashActivityId: personFound.ExchangeCashActivityId, 1262 ExchangeCashActivityId: personFound.ExchangeCashActivityId,
1262 //ExchangedSuMoney: activityFoundExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney), 1263 //ExchangedSuMoney: activityFoundExchangedSuMoney + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney),
1263 //ExchangedCash: activityFoundExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate, 1264 //ExchangedCash: activityFoundExchangedCash + (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityFound.Rate,
1264 - ExchangedSuMoney: exchangedSuMoney,  
1265 - ExchangedCash: exchangedCash,  
1266 - Deadline: activityFound.Deadline,  
1267 - CountDown: activityFound.CountDown,  
1268 - ExchangeRate: activityFound.Rate, 1265 + ExchangedSuMoney: exchangedSuMoney,
  1266 + ExchangedCash: exchangedCash,
  1267 + Deadline: activityFound.Deadline,
  1268 + CountDown: activityFound.CountDown,
  1269 + ExchangeRate: activityFound.Rate,
1269 } 1270 }
1270 1271
1271 // 操作素币服务以及生成素币兑换流水记录命令 1272 // 操作素币服务以及生成素币兑换流水记录命令
@@ -1278,11 +1279,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1278,11 +1279,11 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1278 } 1279 }
1279 1280
1280 // 判断操作素币类型 1281 // 判断操作素币类型
1281 - if updateExchangeCashPersonCommand.ExchangedSuMoney > personFoundExchangedSuMoney { // 追加素币兑换 1282 + if updateExchangeCashPersonCommand.ExchangedSuMoney > personFoundExchangedSuMoney { // 追加素币兑换
1282 //operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) 1283 //operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
1283 operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64() 1284 operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64()
1284 operationSuMoneyCommand.OperationType = 4 1285 operationSuMoneyCommand.OperationType = 4
1285 - } else { // 撤回素币兑换 1286 + } else { // 撤回素币兑换
1286 //operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) 1287 //operationSuMoneyCommand.SuMoney = math.Abs(updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney)
1287 operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64() 1288 operationSuMoneyCommand.SuMoney, _ = decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Abs().Float64()
1288 operationSuMoneyCommand.OperationType = 41 1289 operationSuMoneyCommand.OperationType = 41
@@ -1338,7 +1339,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1338,7 +1339,7 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1338 1339
1339 // 判断是否超过平台未兑换现金 1340 // 判断是否超过平台未兑换现金
1340 if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney { 1341 if activityUpdated.ExchangedSuMoney > activityFoundExchangedSuMoney {
1341 - if (activityUpdated.ExchangedSuMoney - activityFoundExchangedSuMoney) * activityUpdated.Rate > cashPoolFoundUnExchangeCash { 1342 + if (activityUpdated.ExchangedSuMoney-activityFoundExchangedSuMoney)*activityUpdated.Rate > cashPoolFoundUnExchangeCash {
1342 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金") 1343 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
1343 } 1344 }
1344 } 1345 }
@@ -1359,15 +1360,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC @@ -1359,15 +1360,15 @@ func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeC
1359 // 更新现金池命令 1360 // 更新现金池命令
1360 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub((decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Mul(decimal.NewFromFloat(activityUpdated.Rate))).Float64() 1361 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub((decimal.NewFromFloat(updateExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney))).Mul(decimal.NewFromFloat(activityUpdated.Rate))).Float64()
1361 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 1362 updateCashPoolCommand := &command.UpdateCashPoolCommand{
1362 - CashPoolId: cashPoolFound.CashPoolId,  
1363 - Cash: cashPoolFound.Cash,  
1364 - ExchangedCash: systemExchangedCash, 1363 + CashPoolId: cashPoolFound.CashPoolId,
  1364 + Cash: cashPoolFound.Cash,
  1365 + ExchangedCash: systemExchangedCash,
1365 //UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityUpdated.Rate, 1366 //UnExchangeCash: cashPoolFoundUnExchangeCash - (updateExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney) * activityUpdated.Rate,
1366 UnExchangeCash: unExchangeCash, 1367 UnExchangeCash: unExchangeCash,
1367 Rate: newRate, 1368 Rate: newRate,
1368 ExchangedSuMoney: systemExchangedSuMoney, 1369 ExchangedSuMoney: systemExchangedSuMoney,
1369 UnExchangeSuMoney: systemUnExchangeSuMoney, 1370 UnExchangeSuMoney: systemUnExchangeSuMoney,
1370 - LastRate: cashPoolFound.LastRate, 1371 + LastRate: cashPoolFound.LastRate,
1371 } 1372 }
1372 1373
1373 // 更新现金池 1374 // 更新现金池
@@ -1443,7 +1444,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1443,7 +1444,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1443 1444
1444 // 现金池仓储初始化 1445 // 现金池仓储初始化
1445 var cashPoolRepository domain.CashPoolRepository 1446 var cashPoolRepository domain.CashPoolRepository
1446 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 1447 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
1447 "transactionContext": transactionContext, 1448 "transactionContext": transactionContext,
1448 }); err != nil { 1449 }); err != nil {
1449 return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1450 return []interface{}{}, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -1505,8 +1506,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1505,8 +1506,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1505 failureDataList = append(failureDataList, row) 1506 failureDataList = append(failureDataList, row)
1506 continue 1507 continue
1507 } 1508 }
1508 - activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前兑换活动未兑换素币  
1509 - activityFoundExchangedCash := activityFound.ExchangedCash // 当前兑换活动已兑换素币 1509 + activityFoundExchangedSuMoney := activityFound.ExchangedSuMoney // 当前兑换活动未兑换素币
  1510 + activityFoundExchangedCash := activityFound.ExchangedCash // 当前兑换活动已兑换素币
1510 1511
1511 // 获取当前公司现金池 1512 // 获取当前公司现金池
1512 cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{ 1513 cashPoolFound, err := cashPoolRepository.FindOne(map[string]interface{}{
@@ -1532,12 +1533,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1532,12 +1533,13 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1532 failureDataList = append(failureDataList, row) 1533 failureDataList = append(failureDataList, row)
1533 continue 1534 continue
1534 } 1535 }
1535 - cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash // 当前公司现金池未兑换现金  
1536 - cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash // 当前公司现金池已兑换现金 1536 + cashPoolFoundUnExchangeCash := cashPoolFound.UnExchangeCash // 当前公司现金池未兑换现金
  1537 + cashPoolFoundExchangedCash := cashPoolFound.ExchangedCash // 当前公司现金池已兑换现金
1537 1538
1538 - // TODO 更改:根据uid和companyId,判断当前员工是否有效 1539 + // 更改:根据uid、account和companyId,判断当前员工是否有效(身份有效、手机账号有效)
1539 getEmployee := map[string]interface{}{ 1540 getEmployee := map[string]interface{}{
1540 - "account": createExchangeCashPersonCommand.PersonAccount, 1541 + "uid": createExchangeCashPersonCommand.Uid,
  1542 + "account": createExchangeCashPersonCommand.PersonAccount,
1541 "companyId": activityFound.CompanyId, 1543 "companyId": activityFound.CompanyId,
1542 } 1544 }
1543 employeeFound, err := employeeRepository.FindOne(getEmployee) 1545 employeeFound, err := employeeRepository.FindOne(getEmployee)
@@ -1561,14 +1563,15 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1561,14 +1563,15 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1561 failureDataList = append(failureDataList, row) 1563 failureDataList = append(failureDataList, row)
1562 continue 1564 continue
1563 } 1565 }
1564 - employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值 1566 + employeeFoundSuMoney := employeeFound.SuMoney // 当前导入员工持有的素币值
1565 1567
1566 - // TODO 更改:根据uid和activityId判断当前员工是否已经在素币兑换清单中, 1568 + // 更改:根据uid、employeeAccount和activityId判断当前员工是否已经在素币兑换清单中,
1567 personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{ 1569 personFound, _ := exchangeCashPersonListRepository.FindOne(map[string]interface{}{
  1570 + "uid": employeeFound.EmployeeInfo.Uid,
1568 "employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount, 1571 "employeeAccount": employeeFound.EmployeeInfo.EmployeeAccount,
1569 - "activityId": activityFound.ActivityId, 1572 + "activityId": activityFound.ActivityId,
1570 }) 1573 })
1571 - if personFound == nil { // 当前人员不在兑换素币清单中,新增兑换素币清单 1574 + if personFound == nil { // 当前人员不在兑换素币清单中,新增兑换素币清单
1572 // 判断该员工兑换的素币是否超过本人持有的素币 1575 // 判断该员工兑换的素币是否超过本人持有的素币
1573 if createExchangeCashPersonCommand.ExchangedSuMoney > employeeFoundSuMoney { 1576 if createExchangeCashPersonCommand.ExchangedSuMoney > employeeFoundSuMoney {
1574 row := []interface{}{ 1577 row := []interface{}{
@@ -1591,8 +1594,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1591,8 +1594,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1591 EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount, 1594 EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount,
1592 }, 1595 },
1593 ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId, 1596 ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
1594 - ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,  
1595 - ExchangedCash: newPersonExchangedCash, 1597 + ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
  1598 + ExchangedCash: newPersonExchangedCash,
1596 } 1599 }
1597 personSaved, err := exchangeCashPersonListRepository.Save(newPerson) 1600 personSaved, err := exchangeCashPersonListRepository.Save(newPerson)
1598 if err != nil { 1601 if err != nil {
@@ -1617,11 +1620,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1617,11 +1620,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1617 } 1620 }
1618 1621
1619 // 操作素币,生成素币流水 1622 // 操作素币,生成素币流水
1620 - operationSuMoneyCommand := &command.OperationSuMoneyCommand{ 1623 + operationSuMoneyCommand := &command.OperationSuMoneyCommand{
1621 Uid: employeeFound.EmployeeInfo.Uid, 1624 Uid: employeeFound.EmployeeInfo.Uid,
1622 Operator: createExchangeCashPersonCommand.Operator, 1625 Operator: createExchangeCashPersonCommand.Operator,
1623 SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney, 1626 SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
1624 - OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励 1627 + OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
1625 OperationDescription: "参与" + activityFound.ExchangeActivityName, 1628 OperationDescription: "参与" + activityFound.ExchangeActivityName,
1626 } 1629 }
1627 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 1630 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
@@ -1649,16 +1652,16 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1649,16 +1652,16 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1649 // 更新兑换活动 1652 // 更新兑换活动
1650 exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64() 1653 exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
1651 exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64() 1654 exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()
1652 - updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 1655 + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
1653 ExchangeCashActivityId: personSaved.ExchangeCashActivityId, 1656 ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
1654 ExchangeActivityName: activityFound.ExchangeActivityName, 1657 ExchangeActivityName: activityFound.ExchangeActivityName,
1655 //ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney, 1658 //ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
1656 //ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate, 1659 //ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
1657 - ExchangedSuMoney: exchangedSuMoney,  
1658 - ExchangedCash: exchangedCash,  
1659 - Deadline: activityFound.Deadline,  
1660 - CountDown: activityFound.CountDown,  
1661 - ExchangeRate: activityFound.Rate, 1660 + ExchangedSuMoney: exchangedSuMoney,
  1661 + ExchangedCash: exchangedCash,
  1662 + Deadline: activityFound.Deadline,
  1663 + CountDown: activityFound.CountDown,
  1664 + ExchangeRate: activityFound.Rate,
1662 } 1665 }
1663 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 1666 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
1664 row := []interface{}{ 1667 row := []interface{}{
@@ -1693,7 +1696,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1693,7 +1696,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1693 } 1696 }
1694 1697
1695 // 判断是否超过平台未兑换现金 1698 // 判断是否超过平台未兑换现金
1696 - if createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate > cashPoolFoundUnExchangeCash { 1699 + if createExchangeCashPersonCommand.ExchangedSuMoney*activityFound.Rate > cashPoolFoundUnExchangeCash {
1697 row := []interface{}{ 1700 row := []interface{}{
1698 createExchangeCashPersonCommand.PersonName, 1701 createExchangeCashPersonCommand.PersonName,
1699 createExchangeCashPersonCommand.PersonAccount, 1702 createExchangeCashPersonCommand.PersonAccount,
@@ -1727,7 +1730,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1727,7 +1730,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1727 continue 1730 continue
1728 } 1731 }
1729 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币 1732 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币
1730 - systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币 1733 + systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币
1731 1734
1732 // 更新现金池 1735 // 更新现金池
1733 var newRate float64 1736 var newRate float64
@@ -1737,19 +1740,19 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1737,19 +1740,19 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1737 //newRate = (cashPoolFoundExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney 1740 //newRate = (cashPoolFoundExchangedCash + personSaved.ExchangedCash) / systemExchangedSuMoney
1738 newRate, _ = decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64() 1741 newRate, _ = decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Div(decimal.NewFromFloat(systemExchangedSuMoney)).Float64()
1739 } 1742 }
1740 - newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()  
1741 - unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64() 1743 + newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
  1744 + unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
1742 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 1745 updateCashPoolCommand := &command.UpdateCashPoolCommand{
1743 - CashPoolId: cashPoolFound.CashPoolId,  
1744 - Cash: cashPoolFound.Cash, 1746 + CashPoolId: cashPoolFound.CashPoolId,
  1747 + Cash: cashPoolFound.Cash,
1745 //ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash, 1748 //ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
1746 //UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash, 1749 //UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
1747 - ExchangedCash: newExchangedCash, 1750 + ExchangedCash: newExchangedCash,
1748 UnExchangeCash: unExchangeCash, 1751 UnExchangeCash: unExchangeCash,
1749 ExchangedSuMoney: systemExchangedSuMoney, 1752 ExchangedSuMoney: systemExchangedSuMoney,
1750 UnExchangeSuMoney: systemUnExchangeSuMoney, 1753 UnExchangeSuMoney: systemUnExchangeSuMoney,
1751 Rate: newRate, 1754 Rate: newRate,
1752 - LastRate: cashPoolFound.LastRate, 1755 + LastRate: cashPoolFound.LastRate,
1753 } 1756 }
1754 if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil { 1757 if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
1755 row := []interface{}{ 1758 row := []interface{}{
@@ -1782,10 +1785,10 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1782,10 +1785,10 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1782 failureDataList = append(failureDataList, row) 1785 failureDataList = append(failureDataList, row)
1783 continue 1786 continue
1784 } 1787 }
1785 - } else { // 当前人员存在兑换素币清单中  
1786 - personFoundExchangedSuMoney := personFound.ExchangedSuMoney // 当前素币清单已兑换素币  
1787 - personFoundExchangedCash := personFound.ExchangedCash // 当前素币清单已兑换现金  
1788 - if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于本人已兑换素币,撤回兑换素币 1788 + } else { // 当前人员存在兑换素币清单中
  1789 + personFoundExchangedSuMoney := personFound.ExchangedSuMoney // 当前素币清单已兑换素币
  1790 + personFoundExchangedCash := personFound.ExchangedCash // 当前素币清单已兑换现金
  1791 + if createExchangeCashPersonCommand.ExchangedSuMoney < personFoundExchangedSuMoney { // 当前兑换的素币小于本人已兑换素币,撤回兑换素币
1789 // 素币减量 1792 // 素币减量
1790 //suMoneyDecrement := personFoundExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney 1793 //suMoneyDecrement := personFoundExchangedSuMoney - createExchangeCashPersonCommand.ExchangedSuMoney
1791 suMoneyDecrement, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64() 1794 suMoneyDecrement, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
@@ -1796,14 +1799,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1796,14 +1799,14 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1796 1799
1797 // 更新兑换素币清单 1800 // 更新兑换素币清单
1798 exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64() 1801 exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64()
1799 - exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64() 1802 + exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
1800 updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{ 1803 updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
1801 - ListId: personFound.ListId, 1804 + ListId: personFound.ListId,
1802 //ExchangedSuMoney: personFoundExchangedSuMoney - suMoneyDecrement, 1805 //ExchangedSuMoney: personFoundExchangedSuMoney - suMoneyDecrement,
1803 //ExchangedCash: personFoundExchangedCash - cashDecrement, 1806 //ExchangedCash: personFoundExchangedCash - cashDecrement,
1804 ExchangedSuMoney: exchangedSuMoney, 1807 ExchangedSuMoney: exchangedSuMoney,
1805 - ExchangedCash: exchangedCash,  
1806 - Operator: createExchangeCashPersonCommand.Operator, 1808 + ExchangedCash: exchangedCash,
  1809 + Operator: createExchangeCashPersonCommand.Operator,
1807 } 1810 }
1808 if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil { 1811 if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
1809 row := []interface{}{ 1812 row := []interface{}{
@@ -1838,17 +1841,17 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1838,17 +1841,17 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1838 } 1841 }
1839 1842
1840 // 更新素币兑换活动 1843 // 更新素币兑换活动
1841 - newExchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64() 1844 + newExchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(suMoneyDecrement)).Float64()
1842 newExchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64() 1845 newExchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
1843 - updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 1846 + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
1844 ExchangeCashActivityId: personFound.ExchangeCashActivityId, 1847 ExchangeCashActivityId: personFound.ExchangeCashActivityId,
1845 //ExchangedSuMoney: activityFoundExchangedSuMoney - suMoneyDecrement, 1848 //ExchangedSuMoney: activityFoundExchangedSuMoney - suMoneyDecrement,
1846 //ExchangedCash: activityFoundExchangedCash - cashDecrement, 1849 //ExchangedCash: activityFoundExchangedCash - cashDecrement,
1847 - ExchangedSuMoney: newExchangedSuMoney,  
1848 - ExchangedCash: newExchangedCash,  
1849 - Deadline: activityFound.Deadline,  
1850 - CountDown: activityFound.CountDown,  
1851 - ExchangeRate: activityFound.Rate, 1850 + ExchangedSuMoney: newExchangedSuMoney,
  1851 + ExchangedCash: newExchangedCash,
  1852 + Deadline: activityFound.Deadline,
  1853 + CountDown: activityFound.CountDown,
  1854 + ExchangeRate: activityFound.Rate,
1852 } 1855 }
1853 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 1856 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
1854 row := []interface{}{ 1857 row := []interface{}{
@@ -1887,7 +1890,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1887,7 +1890,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1887 Uid: employeeFound.EmployeeInfo.Uid, 1890 Uid: employeeFound.EmployeeInfo.Uid,
1888 Operator: createExchangeCashPersonCommand.Operator, 1891 Operator: createExchangeCashPersonCommand.Operator,
1889 SuMoney: suMoneyDecrement, 1892 SuMoney: suMoneyDecrement,
1890 - OperationType: 41, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励 1893 + OperationType: 41, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
1891 OperationDescription: activityFound.ExchangeActivityName + "调整", 1894 OperationDescription: activityFound.ExchangeActivityName + "调整",
1892 } 1895 }
1893 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 1896 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
@@ -1935,7 +1938,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1935,7 +1938,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1935 continue 1938 continue
1936 } 1939 }
1937 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币 1940 systemExchangedSuMoney := systemSuMoneyStatistics["systemExchangedSuMoney"].(float64) // 公司已兑换素币
1938 - systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币 1941 + systemUnExchangeSuMoney := systemSuMoneyStatistics["systemUnExchangeSuMoney"].(float64) // 公司未兑换素币
1939 1942
1940 // 更新现金池 1943 // 更新现金池
1941 var newRate float64 1944 var newRate float64
@@ -1948,8 +1951,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1948,8 +1951,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1948 cashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64() 1951 cashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(cashDecrement)).Float64()
1949 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(cashDecrement)).Float64() 1952 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(cashDecrement)).Float64()
1950 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 1953 updateCashPoolCommand := &command.UpdateCashPoolCommand{
1951 - CashPoolId: cashPoolFound.CashPoolId,  
1952 - Cash: cashPoolFound.Cash, 1954 + CashPoolId: cashPoolFound.CashPoolId,
  1955 + Cash: cashPoolFound.Cash,
1953 //ExchangedCash: cashPoolFoundExchangedCash - cashDecrement, 1956 //ExchangedCash: cashPoolFoundExchangedCash - cashDecrement,
1954 //UnExchangeCash: cashPoolFoundUnExchangeCash + cashDecrement, 1957 //UnExchangeCash: cashPoolFoundUnExchangeCash + cashDecrement,
1955 ExchangedCash: cashPoolExchangedCash, 1958 ExchangedCash: cashPoolExchangedCash,
@@ -1957,7 +1960,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1957,7 +1960,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1957 ExchangedSuMoney: systemExchangedSuMoney, 1960 ExchangedSuMoney: systemExchangedSuMoney,
1958 UnExchangeSuMoney: systemUnExchangeSuMoney, 1961 UnExchangeSuMoney: systemUnExchangeSuMoney,
1959 Rate: newRate, 1962 Rate: newRate,
1960 - LastRate: cashPoolFound.LastRate, 1963 + LastRate: cashPoolFound.LastRate,
1961 } 1964 }
1962 if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil { 1965 if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
1963 row := []interface{}{ 1966 row := []interface{}{
@@ -1990,7 +1993,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -1990,7 +1993,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
1990 failureDataList = append(failureDataList, row) 1993 failureDataList = append(failureDataList, row)
1991 continue 1994 continue
1992 } 1995 }
1993 - } else { // 当前兑换素币大于等于已兑换素币,追加兑换素币 1996 + } else { // 当前兑换素币大于等于已兑换素币,追加兑换素币
1994 // 素币增量 1997 // 素币增量
1995 //suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney 1998 //suMoneyIncrement := createExchangeCashPersonCommand.ExchangedSuMoney - personFoundExchangedSuMoney
1996 suMoneyIncrement, _ := decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64() 1999 suMoneyIncrement, _ := decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
@@ -2014,12 +2017,12 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2014,12 +2017,12 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2014 exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Add(decimal.NewFromFloat(suMoneyIncrement)).Float64() 2017 exchangedSuMoney, _ := decimal.NewFromFloat(personFoundExchangedSuMoney).Add(decimal.NewFromFloat(suMoneyIncrement)).Float64()
2015 exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64() 2018 exchangedCash, _ := decimal.NewFromFloat(personFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64()
2016 updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{ 2019 updateExchangeCashPersonCommand := &command.UpdateExchangeCashPersonCommand{
2017 - ListId: personFound.ListId, 2020 + ListId: personFound.ListId,
2018 //ExchangedSuMoney: personFoundExchangedSuMoney + suMoneyIncrement, 2021 //ExchangedSuMoney: personFoundExchangedSuMoney + suMoneyIncrement,
2019 //ExchangedCash: personFoundExchangedCash + cashIncrement, 2022 //ExchangedCash: personFoundExchangedCash + cashIncrement,
2020 ExchangedSuMoney: exchangedSuMoney, 2023 ExchangedSuMoney: exchangedSuMoney,
2021 - ExchangedCash: exchangedCash,  
2022 - Operator: createExchangeCashPersonCommand.Operator, 2024 + ExchangedCash: exchangedCash,
  2025 + Operator: createExchangeCashPersonCommand.Operator,
2023 } 2026 }
2024 if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil { 2027 if err := personFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
2025 row := []interface{}{ 2028 row := []interface{}{
@@ -2060,11 +2063,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2060,11 +2063,11 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2060 ExchangeCashActivityId: personFound.ExchangeCashActivityId, 2063 ExchangeCashActivityId: personFound.ExchangeCashActivityId,
2061 //ExchangedSuMoney: activityFoundExchangedSuMoney + suMoneyIncrement, 2064 //ExchangedSuMoney: activityFoundExchangedSuMoney + suMoneyIncrement,
2062 //ExchangedCash: activityFoundExchangedCash + cashIncrement, 2065 //ExchangedCash: activityFoundExchangedCash + cashIncrement,
2063 - ExchangedSuMoney: newExchangedSuMoney,  
2064 - ExchangedCash: newExchangedCash,  
2065 - Deadline: activityFound.Deadline,  
2066 - CountDown: activityFound.CountDown,  
2067 - ExchangeRate: activityFound.Rate, 2066 + ExchangedSuMoney: newExchangedSuMoney,
  2067 + ExchangedCash: newExchangedCash,
  2068 + Deadline: activityFound.Deadline,
  2069 + CountDown: activityFound.CountDown,
  2070 + ExchangeRate: activityFound.Rate,
2068 } 2071 }
2069 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil { 2072 if err := activityFound.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
2070 row := []interface{}{ 2073 row := []interface{}{
@@ -2103,7 +2106,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2103,7 +2106,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2103 Uid: employeeFound.EmployeeInfo.Uid, 2106 Uid: employeeFound.EmployeeInfo.Uid,
2104 Operator: createExchangeCashPersonCommand.Operator, 2107 Operator: createExchangeCashPersonCommand.Operator,
2105 SuMoney: suMoneyIncrement, 2108 SuMoney: suMoneyIncrement,
2106 - OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励 2109 + OperationType: 4, // 操作类型->记录类型对应:1->3: 增加 2->4: 扣除 3->1: 兑换物资 4->5: 兑换现金活动 41->6: 撤回兑换现金素币 5->2: 任务奖励
2107 OperationDescription: activityFound.ExchangeActivityName + "调整", 2110 OperationDescription: activityFound.ExchangeActivityName + "调整",
2108 } 2111 }
2109 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription) 2112 task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription)
@@ -2176,8 +2179,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2176,8 +2179,8 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2176 newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64() 2179 newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(cashIncrement)).Float64()
2177 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(cashIncrement)).Float64() 2180 unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(cashIncrement)).Float64()
2178 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 2181 updateCashPoolCommand := &command.UpdateCashPoolCommand{
2179 - CashPoolId: cashPoolFound.CashPoolId,  
2180 - Cash: cashPoolFound.Cash, 2182 + CashPoolId: cashPoolFound.CashPoolId,
  2183 + Cash: cashPoolFound.Cash,
2181 //ExchangedCash: cashPoolFoundExchangedCash + cashIncrement, 2184 //ExchangedCash: cashPoolFoundExchangedCash + cashIncrement,
2182 //UnExchangeCash: cashPoolFoundUnExchangeCash - cashIncrement, 2185 //UnExchangeCash: cashPoolFoundUnExchangeCash - cashIncrement,
2183 ExchangedCash: newCashPoolExchangedCash, 2186 ExchangedCash: newCashPoolExchangedCash,
@@ -2185,7 +2188,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc @@ -2185,7 +2188,7 @@ func (cashPoolService *CashPoolService) ImportCreateExchangeCashPerson(createExc
2185 ExchangedSuMoney: systemExchangedSuMoney, 2188 ExchangedSuMoney: systemExchangedSuMoney,
2186 UnExchangeSuMoney: systemUnExchangeSuMoney, 2189 UnExchangeSuMoney: systemUnExchangeSuMoney,
2187 Rate: newRate, 2190 Rate: newRate,
2188 - LastRate: cashPoolFound.LastRate, 2191 + LastRate: cashPoolFound.LastRate,
2189 } 2192 }
2190 if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil { 2193 if err := cashPoolFound.Update(tool_funs.SimpleStructToMap(updateCashPoolCommand)); err != nil {
2191 row := []interface{}{ 2194 row := []interface{}{
@@ -2271,7 +2274,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2271,7 +2274,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2271 2274
2272 // 现金池仓储初始化 2275 // 现金池仓储初始化
2273 var cashPoolRepository domain.CashPoolRepository 2276 var cashPoolRepository domain.CashPoolRepository
2274 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 2277 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
2275 "transactionContext": transactionContext, 2278 "transactionContext": transactionContext,
2276 }); err != nil { 2279 }); err != nil {
2277 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 2280 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -2319,7 +2322,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2319,7 +2322,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2319 2322
2320 // 判断当前员工是否有效 2323 // 判断当前员工是否有效
2321 getEmployee := map[string]interface{}{ 2324 getEmployee := map[string]interface{}{
2322 - "uid": createExchangeCashPersonCommand.Uid, 2325 + "uid": createExchangeCashPersonCommand.Uid,
2323 "companyId": activityFound.CompanyId, 2326 "companyId": activityFound.CompanyId,
2324 } 2327 }
2325 employeeFound, err := employeeRepository.FindOne(getEmployee) 2328 employeeFound, err := employeeRepository.FindOne(getEmployee)
@@ -2334,7 +2337,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2334,7 +2337,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2334 // 判断当前员工是否已经存在兑换素币清单中 2337 // 判断当前员工是否已经存在兑换素币清单中
2335 if _, people, err := exchangeCashPersonListRepository.Find(map[string]interface{}{ 2338 if _, people, err := exchangeCashPersonListRepository.Find(map[string]interface{}{
2336 "exchangeCashActivityId": activityFound.ActivityId, 2339 "exchangeCashActivityId": activityFound.ActivityId,
2337 - "uid": employeeFound.EmployeeInfo.Uid, 2340 + "uid": employeeFound.EmployeeInfo.Uid,
2338 }); err != nil { 2341 }); err != nil {
2339 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 2342 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
2340 } else { 2343 } else {
@@ -2358,8 +2361,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2358,8 +2361,8 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2358 EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount, 2361 EmployeeAccount: employeeFound.EmployeeInfo.EmployeeAccount,
2359 }, 2362 },
2360 ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId, 2363 ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
2361 - ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,  
2362 - ExchangedCash: newPersonExchangedCash, 2364 + ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
  2365 + ExchangedCash: newPersonExchangedCash,
2363 } 2366 }
2364 2367
2365 // 保存兑换素币清单 2368 // 保存兑换素币清单
@@ -2369,7 +2372,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2369,7 +2372,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2369 } 2372 }
2370 2373
2371 // 操作素币命令 2374 // 操作素币命令
2372 - operationSuMoneyCommand := &command.OperationSuMoneyCommand{ 2375 + operationSuMoneyCommand := &command.OperationSuMoneyCommand{
2373 Uid: employeeFound.EmployeeInfo.Uid, 2376 Uid: employeeFound.EmployeeInfo.Uid,
2374 Operator: createExchangeCashPersonCommand.Operator, 2377 Operator: createExchangeCashPersonCommand.Operator,
2375 SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney, 2378 SuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
@@ -2387,18 +2390,18 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2387,18 +2390,18 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2387 } 2390 }
2388 2391
2389 // 更新兑换活动命令 2392 // 更新兑换活动命令
2390 - exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()  
2391 - exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()  
2392 - updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 2393 + exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney)).Float64()
  2394 + exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Add(decimal.NewFromFloat(createExchangeCashPersonCommand.ExchangedSuMoney).Mul(decimal.NewFromFloat(activityFound.Rate))).Float64()
  2395 + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
2393 ExchangeCashActivityId: personSaved.ExchangeCashActivityId, 2396 ExchangeCashActivityId: personSaved.ExchangeCashActivityId,
2394 ExchangeActivityName: activityFound.ExchangeActivityName, 2397 ExchangeActivityName: activityFound.ExchangeActivityName,
2395 //ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney, 2398 //ExchangedSuMoney: activityFoundExchangedSuMoney + createExchangeCashPersonCommand.ExchangedSuMoney,
2396 //ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate, 2399 //ExchangedCash: activityFoundExchangedCash + createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate,
2397 - ExchangedSuMoney: exchangedSuMoney,  
2398 - ExchangedCash: exchangedCash,  
2399 - Deadline: activityFound.Deadline,  
2400 - CountDown: activityFound.CountDown,  
2401 - ExchangeRate: activityFound.Rate, 2400 + ExchangedSuMoney: exchangedSuMoney,
  2401 + ExchangedCash: exchangedCash,
  2402 + Deadline: activityFound.Deadline,
  2403 + CountDown: activityFound.CountDown,
  2404 + ExchangeRate: activityFound.Rate,
2402 } 2405 }
2403 2406
2404 // 更新兑换活动 2407 // 更新兑换活动
@@ -2429,7 +2432,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2429,7 +2432,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2429 cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash 2432 cashPoolFoundExchangedCash := cashPoolsFound[0].ExchangedCash
2430 2433
2431 // 判断是否超过平台未兑换现金 2434 // 判断是否超过平台未兑换现金
2432 - if createExchangeCashPersonCommand.ExchangedSuMoney * activityFound.Rate > cashPoolFoundUnExchangeCash { 2435 + if createExchangeCashPersonCommand.ExchangedSuMoney*activityFound.Rate > cashPoolFoundUnExchangeCash {
2433 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金") 2436 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已超过投入现金池的未兑换现金")
2434 } 2437 }
2435 2438
@@ -2454,11 +2457,11 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2454,11 +2457,11 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2454 } 2457 }
2455 2458
2456 // 更新现金池命令 2459 // 更新现金池命令
2457 - newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()  
2458 - unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64() 2460 + newCashPoolExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Add(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
  2461 + unExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Sub(decimal.NewFromFloat(personSaved.ExchangedCash)).Float64()
2459 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 2462 updateCashPoolCommand := &command.UpdateCashPoolCommand{
2460 - CashPoolId: cashPoolsFound[0].CashPoolId,  
2461 - Cash: cashPoolsFound[0].Cash, 2463 + CashPoolId: cashPoolsFound[0].CashPoolId,
  2464 + Cash: cashPoolsFound[0].Cash,
2462 //ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash, 2465 //ExchangedCash: cashPoolFoundExchangedCash + personSaved.ExchangedCash,
2463 //UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash, 2466 //UnExchangeCash: cashPoolFoundUnExchangeCash - personSaved.ExchangedCash,
2464 ExchangedCash: newCashPoolExchangedCash, 2467 ExchangedCash: newCashPoolExchangedCash,
@@ -2466,7 +2469,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC @@ -2466,7 +2469,7 @@ func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeC
2466 ExchangedSuMoney: systemExchangedSuMoney, 2469 ExchangedSuMoney: systemExchangedSuMoney,
2467 UnExchangeSuMoney: systemUnExchangeSuMoney, 2470 UnExchangeSuMoney: systemUnExchangeSuMoney,
2468 Rate: newRate, 2471 Rate: newRate,
2469 - LastRate: cashPoolsFound[0].LastRate, 2472 + LastRate: cashPoolsFound[0].LastRate,
2470 } 2473 }
2471 2474
2472 // 更新现金池 2475 // 更新现金池
@@ -2589,8 +2592,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP @@ -2589,8 +2592,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP
2589 // 获取该公司活动下所有兑换员工 2592 // 获取该公司活动下所有兑换员工
2590 if count, people, err := exchangeCashPersonListRepository.FindAll(map[string]interface{}{ 2593 if count, people, err := exchangeCashPersonListRepository.FindAll(map[string]interface{}{
2591 "exchangeCashActivityIds": activityIds, 2594 "exchangeCashActivityIds": activityIds,
2592 - "offset": listExchangeCashPersonQuery.Offset,  
2593 - "limit": listExchangeCashPersonQuery.Limit, 2595 + "offset": listExchangeCashPersonQuery.Offset,
  2596 + "limit": listExchangeCashPersonQuery.Limit,
2594 }); err != nil { 2597 }); err != nil {
2595 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 2598 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
2596 } else { 2599 } else {
@@ -2602,8 +2605,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP @@ -2602,8 +2605,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP
2602 people[i].ExchangedCash, _ = decimal.NewFromFloatWithExponent(people[i].ExchangedCash, -2).Float64() 2605 people[i].ExchangedCash, _ = decimal.NewFromFloatWithExponent(people[i].ExchangedCash, -2).Float64()
2603 } 2606 }
2604 return map[string]interface{}{ 2607 return map[string]interface{}{
2605 - "count": count,  
2606 - "people": people, 2608 + "count": count,
  2609 + "people": people,
2607 }, nil 2610 }, nil
2608 } 2611 }
2609 } 2612 }
@@ -2620,8 +2623,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP @@ -2620,8 +2623,8 @@ func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashP
2620 people[i].ExchangedCash, _ = decimal.NewFromFloatWithExponent(people[i].ExchangedCash, -2).Float64() 2623 people[i].ExchangedCash, _ = decimal.NewFromFloatWithExponent(people[i].ExchangedCash, -2).Float64()
2621 } 2624 }
2622 return map[string]interface{}{ 2625 return map[string]interface{}{
2623 - "count": count,  
2624 - "people": people, 2626 + "count": count,
  2627 + "people": people,
2625 }, nil 2628 }, nil
2626 } 2629 }
2627 } 2630 }
@@ -2665,7 +2668,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -2665,7 +2668,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
2665 2668
2666 // 现金池仓储初始化 2669 // 现金池仓储初始化
2667 var cashPoolRepository domain.CashPoolRepository 2670 var cashPoolRepository domain.CashPoolRepository
2668 - if value, err := factory.CreateCashPoolRepository(map[string] interface{} { 2671 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
2669 "transactionContext": transactionContext, 2672 "transactionContext": transactionContext,
2670 }); err != nil { 2673 }); err != nil {
2671 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 2674 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -2732,7 +2735,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -2732,7 +2735,7 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
2732 2735
2733 // 判断当前员工是否有效 2736 // 判断当前员工是否有效
2734 getEmployee := map[string]interface{}{ 2737 getEmployee := map[string]interface{}{
2735 - "uid": personFound.EmployeeInfo.Uid, 2738 + "uid": personFound.EmployeeInfo.Uid,
2736 "companyId": activityFound.CompanyId, 2739 "companyId": activityFound.CompanyId,
2737 } 2740 }
2738 employeeFound, err := employeeRepository.FindOne(getEmployee) 2741 employeeFound, err := employeeRepository.FindOne(getEmployee)
@@ -2745,16 +2748,16 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -2745,16 +2748,16 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
2745 2748
2746 // 更新兑换素币活动命令 2749 // 更新兑换素币活动命令
2747 exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64() 2750 exchangedSuMoney, _ := decimal.NewFromFloat(activityFoundExchangedSuMoney).Sub(decimal.NewFromFloat(personFoundExchangedSuMoney)).Float64()
2748 - exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()  
2749 - updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{ 2751 + exchangedCash, _ := decimal.NewFromFloat(activityFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
  2752 + updateExchangeCashActivityCommand := &command.UpdateExchangeCashActivityCommand{
2750 ExchangeCashActivityId: personFound.ExchangeCashActivityId, 2753 ExchangeCashActivityId: personFound.ExchangeCashActivityId,
2751 //ExchangedSuMoney: activityFoundExchangedSuMoney - personFoundExchangedSuMoney, 2754 //ExchangedSuMoney: activityFoundExchangedSuMoney - personFoundExchangedSuMoney,
2752 //ExchangedCash: activityFoundExchangedCash - personFoundExchangedCash, 2755 //ExchangedCash: activityFoundExchangedCash - personFoundExchangedCash,
2753 - ExchangedSuMoney: exchangedSuMoney,  
2754 - ExchangedCash: exchangedCash,  
2755 - Deadline: activityFound.Deadline,  
2756 - CountDown: activityFound.CountDown,  
2757 - ExchangeRate: activityFound.Rate, 2756 + ExchangedSuMoney: exchangedSuMoney,
  2757 + ExchangedCash: exchangedCash,
  2758 + Deadline: activityFound.Deadline,
  2759 + CountDown: activityFound.CountDown,
  2760 + ExchangeRate: activityFound.Rate,
2758 } 2761 }
2759 2762
2760 // 更新兑换活动 2763 // 更新兑换活动
@@ -2772,11 +2775,11 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -2772,11 +2775,11 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
2772 } 2775 }
2773 2776
2774 // 操作素币命令 2777 // 操作素币命令
2775 - operationSuMoneyCommand := &command.OperationSuMoneyCommand{ 2778 + operationSuMoneyCommand := &command.OperationSuMoneyCommand{
2776 Uid: personFound.EmployeeInfo.Uid, 2779 Uid: personFound.EmployeeInfo.Uid,
2777 Operator: removeExchangeCashPersonCommand.Operator, 2780 Operator: removeExchangeCashPersonCommand.Operator,
2778 SuMoney: personFoundExchangedSuMoney, 2781 SuMoney: personFoundExchangedSuMoney,
2779 - OperationType: 41, // 删除兑换素币清单,撤回已兑换素币 2782 + OperationType: 41, // 删除兑换素币清单,撤回已兑换素币
2780 OperationDescription: activityFound.ExchangeActivityName + "调整", 2783 OperationDescription: activityFound.ExchangeActivityName + "调整",
2781 } 2784 }
2782 2785
@@ -2824,12 +2827,12 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC @@ -2824,12 +2827,12 @@ func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeC
2824 } 2827 }
2825 2828
2826 // 更新现金池命令 2829 // 更新现金池命令
2827 - newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()  
2828 - UnExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(personFoundExchangedCash)).Float64() 2830 + newExchangedCash, _ := decimal.NewFromFloat(cashPoolFoundExchangedCash).Sub(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
  2831 + UnExchangeCash, _ := decimal.NewFromFloat(cashPoolFoundUnExchangeCash).Add(decimal.NewFromFloat(personFoundExchangedCash)).Float64()
2829 updateCashPoolCommand := &command.UpdateCashPoolCommand{ 2832 updateCashPoolCommand := &command.UpdateCashPoolCommand{
2830 - CashPoolId: cashPoolsFound[0].CashPoolId,  
2831 - Cash: cashPoolsFound[0].Cash,  
2832 - LastRate: cashPoolsFound[0].LastRate, 2833 + CashPoolId: cashPoolsFound[0].CashPoolId,
  2834 + Cash: cashPoolsFound[0].Cash,
  2835 + LastRate: cashPoolsFound[0].LastRate,
2833 //ExchangedCash: cashPoolFoundExchangedCash - personFoundExchangedCash, 2836 //ExchangedCash: cashPoolFoundExchangedCash - personFoundExchangedCash,
2834 //UnExchangeCash: cashPoolFoundUnExchangeCash + personFoundExchangedCash, 2837 //UnExchangeCash: cashPoolFoundUnExchangeCash + personFoundExchangedCash,
2835 ExchangedCash: newExchangedCash, 2838 ExchangedCash: newExchangedCash,
@@ -2999,17 +3002,47 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ @@ -2999,17 +3002,47 @@ func (cashPoolService *CashPoolService) ExchangeListRanking(exchangeListRankingQ
2999 } 3002 }
3000 3003
3001 // 兑换素币清单排行榜 3004 // 兑换素币清单排行榜
3002 - for i, _ := range exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int}) {  
3003 - uid := exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int})[i].Uid 3005 + for i, _ := range exchangeCashListRankingStatistics["people"].([]struct {
  3006 + Uid int64
  3007 + EmployeeName string
  3008 + SuMoney float64
  3009 + Cash float64
  3010 + Ranking int
  3011 + }) {
  3012 + uid := exchangeCashListRankingStatistics["people"].([]struct {
  3013 + Uid int64
  3014 + EmployeeName string
  3015 + SuMoney float64
  3016 + Cash float64
  3017 + Ranking int
  3018 + })[i].Uid
3004 if uidName[uid] != nil { 3019 if uidName[uid] != nil {
3005 - exchangeCashListRankingStatistics["people"].([]struct{Uid int64; EmployeeName string; SuMoney float64; Cash float64; Ranking int})[i].EmployeeName = uidName[uid].(string) 3020 + exchangeCashListRankingStatistics["people"].([]struct {
  3021 + Uid int64
  3022 + EmployeeName string
  3023 + SuMoney float64
  3024 + Cash float64
  3025 + Ranking int
  3026 + })[i].EmployeeName = uidName[uid].(string)
3006 } 3027 }
3007 } 3028 }
3008 3029
3009 // 个人素币兑换清单 3030 // 个人素币兑换清单
3010 if exchangeCashListRankingStatistics["currentEmployee"] != nil { 3031 if exchangeCashListRankingStatistics["currentEmployee"] != nil {
3011 - currentEmployeeExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct{Uid int64;EmployeeName string;SuMoney float64; Cash float64;Ranking int})  
3012 - uidExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct{Uid int64;EmployeeName string;SuMoney float64; Cash float64;Ranking int}).Uid 3032 + currentEmployeeExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct {
  3033 + Uid int64
  3034 + EmployeeName string
  3035 + SuMoney float64
  3036 + Cash float64
  3037 + Ranking int
  3038 + })
  3039 + uidExchangeCashList := exchangeCashListRankingStatistics["currentEmployee"].(struct {
  3040 + Uid int64
  3041 + EmployeeName string
  3042 + SuMoney float64
  3043 + Cash float64
  3044 + Ranking int
  3045 + }).Uid
3013 if uidName[uidExchangeCashList] != nil { 3046 if uidName[uidExchangeCashList] != nil {
3014 currentEmployeeExchangeCashList.EmployeeName = uidName[uidExchangeCashList].(string) 3047 currentEmployeeExchangeCashList.EmployeeName = uidName[uidExchangeCashList].(string)
3015 } 3048 }
@@ -17,11 +17,11 @@ import ( @@ -17,11 +17,11 @@ import (
17 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" 17 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
18 ) 18 )
19 19
20 -// 任务服务 20 +// TaskService 任务服务
21 type TaskService struct { 21 type TaskService struct {
22 } 22 }
23 23
24 -// 对抢单任务进行确认 24 +// ConfirmRobTask 对抢单任务进行确认
25 func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.ConfirmRobTaskCommand) (interface{}, error) { 25 func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.ConfirmRobTaskCommand) (interface{}, error) {
26 if err := confirmRobTaskCommand.ValidateCommand(); err != nil { 26 if err := confirmRobTaskCommand.ValidateCommand(); err != nil {
27 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 27 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
@@ -411,11 +411,11 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac @@ -411,11 +411,11 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac
411 411
412 // 搜索任务 412 // 搜索任务
413 func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTaskCommand) (interface{}, error) { 413 func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTaskCommand) (interface{}, error) {
414 - if err := searchTaskCommand.ValidateCommand(); err != nil { // 校验搜索命令 414 + if err := searchTaskCommand.ValidateCommand(); err != nil { // 校验搜索命令
415 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 415 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
416 } 416 }
417 417
418 - transactionContext, err := factory.CreateTransactionContext(nil) // 工厂类创建事务上下文 418 + transactionContext, err := factory.CreateTransactionContext(nil) // 工厂类创建事务上下文
419 if err != nil { 419 if err != nil {
420 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 420 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
421 } 421 }
@@ -918,7 +918,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -918,7 +918,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
918 } 918 }
919 919
920 sponsor, err := employeeRepository.FindOne(map[string]interface{}{ 920 sponsor, err := employeeRepository.FindOne(map[string]interface{}{
921 - "uid": createTaskCommand.Sponsor, 921 + "uid": createTaskCommand.Sponsor,
922 "status": 1, 922 "status": 1,
923 }) 923 })
924 if err != nil { 924 if err != nil {
@@ -935,14 +935,14 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -935,14 +935,14 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
935 if sponsorInvalid == nil { 935 if sponsorInvalid == nil {
936 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者") 936 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者")
937 } 937 }
938 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者:"+ sponsorInvalid.EmployeeInfo.EmployeeName) 938 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者:"+sponsorInvalid.EmployeeInfo.EmployeeName)
939 } 939 }
940 940
941 // 获取任务指派人 941 // 获取任务指派人
942 var assignedPerson *domain.EmployeeInfo 942 var assignedPerson *domain.EmployeeInfo
943 if createTaskCommand.AssignedPerson != 0 { 943 if createTaskCommand.AssignedPerson != 0 {
944 employee, err := employeeRepository.FindOne(map[string]interface{}{ 944 employee, err := employeeRepository.FindOne(map[string]interface{}{
945 - "uid": createTaskCommand.AssignedPerson, 945 + "uid": createTaskCommand.AssignedPerson,
946 "status": 1, 946 "status": 1,
947 }) 947 })
948 if err != nil { 948 if err != nil {
@@ -959,7 +959,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -959,7 +959,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
959 if employeeInvalid == nil { 959 if employeeInvalid == nil {
960 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员") 960 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
961 } 961 }
962 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:" + employeeInvalid.EmployeeInfo.EmployeeName) 962 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:"+employeeInvalid.EmployeeInfo.EmployeeName)
963 } 963 }
964 assignedPerson = employee.EmployeeInfo 964 assignedPerson = employee.EmployeeInfo
965 } 965 }
@@ -978,7 +978,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -978,7 +978,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
978 CustomerValues: createTaskCommand.CustomerValues, 978 CustomerValues: createTaskCommand.CustomerValues,
979 TaskNature: createTaskCommand.TaskNature, 979 TaskNature: createTaskCommand.TaskNature,
980 SuMoney: createTaskCommand.SuMoney, 980 SuMoney: createTaskCommand.SuMoney,
981 - MinSuMoney: createTaskCommand.MinSuMoney, 981 + MinSuMoney: createTaskCommand.MinSuMoney,
982 MaxSuMoney: createTaskCommand.MaxSuMoney, 982 MaxSuMoney: createTaskCommand.MaxSuMoney,
983 AcceptanceStandard: createTaskCommand.AcceptanceStandard, 983 AcceptanceStandard: createTaskCommand.AcceptanceStandard,
984 TaskDescription: createTaskCommand.TaskDescription, 984 TaskDescription: createTaskCommand.TaskDescription,
@@ -1150,7 +1150,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter @@ -1150,7 +1150,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
1150 } 1150 }
1151 1151
1152 // 返回任务素币奖励范围 1152 // 返回任务素币奖励范围
1153 - if taskDto.TaskStatus != 5 && task.MinSuMoney == 0 && task.MaxSuMoney == 0 { 1153 + if taskDto.TaskStatus != 5 && task.MinSuMoney == 0 && task.MaxSuMoney == 0 {
1154 taskDto.MinSuMoney = 0 1154 taskDto.MinSuMoney = 0
1155 taskDto.MaxSuMoney = task.SuMoney 1155 taskDto.MaxSuMoney = task.SuMoney
1156 } 1156 }
@@ -1291,7 +1291,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask @@ -1291,7 +1291,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
1291 employeeRepository = value 1291 employeeRepository = value
1292 } 1292 }
1293 employee, err := employeeRepository.FindOne(map[string]interface{}{ 1293 employee, err := employeeRepository.FindOne(map[string]interface{}{
1294 - "uid": updateTaskCommand.AssignedPerson, 1294 + "uid": updateTaskCommand.AssignedPerson,
1295 "status": 1, 1295 "status": 1,
1296 }) 1296 })
1297 if err != nil { 1297 if err != nil {
@@ -1308,7 +1308,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask @@ -1308,7 +1308,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
1308 if employeeInvalid == nil { 1308 if employeeInvalid == nil {
1309 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员") 1309 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
1310 } 1310 }
1311 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:" + employeeInvalid.EmployeeInfo.EmployeeName) 1311 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:"+employeeInvalid.EmployeeInfo.EmployeeName)
1312 } 1312 }
1313 updateData["assignedPerson"] = employee.EmployeeInfo 1313 updateData["assignedPerson"] = employee.EmployeeInfo
1314 } else { 1314 } else {
@@ -1457,7 +1457,7 @@ func (taskService *TaskService) ListTask(listTaskQuery *query.ListTaskQuery) (in @@ -1457,7 +1457,7 @@ func (taskService *TaskService) ListTask(listTaskQuery *query.ListTaskQuery) (in
1457 } 1457 }
1458 var retTasks []*domain.Task 1458 var retTasks []*domain.Task
1459 for _, task := range tasks { 1459 for _, task := range tasks {
1460 - if task.TaskStatus != 5 && task.MinSuMoney == 0 && task.MaxSuMoney == 0 { 1460 + if task.TaskStatus != 5 && task.MinSuMoney == 0 && task.MaxSuMoney == 0 {
1461 task.MinSuMoney = 0 1461 task.MinSuMoney = 0
1462 task.MaxSuMoney = task.SuMoney 1462 task.MaxSuMoney = task.SuMoney
1463 } 1463 }
@@ -3,9 +3,11 @@ package service @@ -3,9 +3,11 @@ package service
3 import ( 3 import (
4 "encoding/json" 4 "encoding/json"
5 "github.com/linmadan/egglib-go/core/application" 5 "github.com/linmadan/egglib-go/core/application"
  6 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/event/subscriber"
6 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" 7 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
7 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/unifiedUserCenter/command" 8 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/unifiedUserCenter/command"
8 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" 9 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  10 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
9 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" 11 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
10 "time" 12 "time"
11 ) 13 )
@@ -27,8 +29,9 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s @@ -27,8 +29,9 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
27 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 29 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
28 } 30 }
29 defer func() { 31 defer func() {
30 - transactionContext.RollbackTransaction() 32 + _ = transactionContext.RollbackTransaction()
31 }() 33 }()
  34 +
32 var employeeRepository domain.EmployeeRepository 35 var employeeRepository domain.EmployeeRepository
33 if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ 36 if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
34 "transactionContext": transactionContext, 37 "transactionContext": transactionContext,
@@ -37,6 +40,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s @@ -37,6 +40,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
37 } else { 40 } else {
38 employeeRepository = value 41 employeeRepository = value
39 } 42 }
  43 +
40 var employeeDao *dao.EmployeeDao 44 var employeeDao *dao.EmployeeDao
41 if value, err := factory.CreateEmployeeDao(map[string]interface{}{ 45 if value, err := factory.CreateEmployeeDao(map[string]interface{}{
42 "transactionContext": transactionContext, 46 "transactionContext": transactionContext,
@@ -45,10 +49,36 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s @@ -45,10 +49,36 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
45 } else { 49 } else {
46 employeeDao = value 50 employeeDao = value
47 } 51 }
  52 +
  53 + var cashPoolDao *dao.CashPoolDao
  54 + if value, err := factory.CreateCashPoolDao(map[string]interface{}{
  55 + "transactionContext": transactionContext,
  56 + }); err != nil {
  57 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  58 + } else {
  59 + cashPoolDao = value
  60 + }
  61 +
  62 + // 修改手机号事件订阅初始化
  63 + var changePhoneService service.ChangePhoneService
  64 + if value, err := factory.CreateChangePhoneService(map[string]interface{}{
  65 + "transactionContext": transactionContext,
  66 + }); err != nil {
  67 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  68 + } else {
  69 + changePhoneService = value
  70 + err := changePhoneService.Subscribe(&subscriber.WorthServiceSubscriber{})
  71 + if err != nil {
  72 + return nil, err
  73 + }
  74 + }
  75 +
48 var companyId int64 76 var companyId int64
49 var uid int64 77 var uid int64
50 var employeeName string 78 var employeeName string
51 var employeeAccount string 79 var employeeAccount string
  80 + var oldPhone string
  81 + var newPhone string
52 var employeeAvatarUrl string 82 var employeeAvatarUrl string
53 var isPrincipal bool 83 var isPrincipal bool
54 var status int 84 var status int
@@ -74,6 +104,12 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s @@ -74,6 +104,12 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
74 if value, ok := data["avatar"]; ok { 104 if value, ok := data["avatar"]; ok {
75 employeeAvatarUrl = value.(string) 105 employeeAvatarUrl = value.(string)
76 } 106 }
  107 + if value, ok := data["old_phone"]; ok {
  108 + oldPhone = value.(string)
  109 + }
  110 + if value, ok := data["new_phone"]; ok {
  111 + newPhone = value.(string)
  112 + }
77 if value, ok := data["admin_type"]; ok { 113 if value, ok := data["admin_type"]; ok {
78 if int(value.(float64)) == 2 { 114 if int(value.(float64)) == 2 {
79 isPrincipal = true 115 isPrincipal = true
@@ -89,16 +125,17 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s @@ -89,16 +125,17 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
89 uids = append(uids, int64(uid.(float64))) 125 uids = append(uids, int64(uid.(float64)))
90 } 126 }
91 } 127 }
92 - if value, ok := data["add"]; ok { // 添加员工 128 + if value, ok := data["add"]; ok { // 添加员工
93 for _, addEmployee := range value.([]interface{}) { 129 for _, addEmployee := range value.([]interface{}) {
94 addEmployees = append(addEmployees, addEmployee.(map[string]interface{})) 130 addEmployees = append(addEmployees, addEmployee.(map[string]interface{}))
95 } 131 }
96 } 132 }
97 - if value, ok := data["edit"]; ok { // 编辑员工 133 + if value, ok := data["edit"]; ok { // 编辑员工
98 for _, editEmployee := range value.([]interface{}) { 134 for _, editEmployee := range value.([]interface{}) {
99 editEmployees = append(editEmployees, editEmployee.(map[string]interface{})) 135 editEmployees = append(editEmployees, editEmployee.(map[string]interface{}))
100 } 136 }
101 } 137 }
  138 +
102 if syncEmployeeCallbackCommand.Module == "employee" { 139 if syncEmployeeCallbackCommand.Module == "employee" {
103 switch syncEmployeeCallbackCommand.Action { 140 switch syncEmployeeCallbackCommand.Action {
104 case "import": 141 case "import":
@@ -144,8 +181,8 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s @@ -144,8 +181,8 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
144 EmployeeAvatarUrl: employeeAvatarUrl, 181 EmployeeAvatarUrl: employeeAvatarUrl,
145 IsPrincipal: isPrincipal, 182 IsPrincipal: isPrincipal,
146 }, 183 },
147 - Status: status,  
148 - SuMoney: 0, 184 + Status: status,
  185 + SuMoney: 0,
149 CreateTime: time.Now(), 186 CreateTime: time.Now(),
150 } 187 }
151 188
@@ -206,8 +243,8 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s @@ -206,8 +243,8 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
206 EmployeeAvatarUrl: employeeAvatarUrl, 243 EmployeeAvatarUrl: employeeAvatarUrl,
207 IsPrincipal: isPrincipal, 244 IsPrincipal: isPrincipal,
208 }, 245 },
209 - Status: status,  
210 - SuMoney: 0, 246 + Status: status,
  247 + SuMoney: 0,
211 CreateTime: time.Now(), 248 CreateTime: time.Now(),
212 } 249 }
213 if _, err := employeeRepository.Save(employee); err != nil { 250 if _, err := employeeRepository.Save(employee); err != nil {
@@ -247,6 +284,22 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s @@ -247,6 +284,22 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
247 return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 284 return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
248 } 285 }
249 break 286 break
  287 + case "changePhoneAllCompany": // 修改手机号
  288 + // 修改用户数据
  289 + err := employeeDao.ChangePhone(oldPhone, newPhone)
  290 + if err != nil {
  291 + return false, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  292 + }
  293 + // 修改业务数据-素币兑换清单
  294 + errUpdateExchangeCashPersonList := cashPoolDao.UpdateExchangeCashPersonListUserInfo(oldPhone, newPhone)
  295 + if errUpdateExchangeCashPersonList != nil {
  296 + return false, application.ThrowError(application.TRANSACTION_ERROR, errUpdateExchangeCashPersonList.Error())
  297 + }
  298 + // 发布修改手机号事件
  299 + if err := changePhoneService.ChangePhone(oldPhone, newPhone); err != nil {
  300 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  301 + }
  302 + break
250 default: 303 default:
251 return false, nil 304 return false, nil
252 } 305 }
@@ -6,6 +6,7 @@ const SERVICE_NAME = "mmm-worth" @@ -6,6 +6,7 @@ const SERVICE_NAME = "mmm-worth"
6 6
7 var ABILITY_SERVICE_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" 7 var ABILITY_SERVICE_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
8 var MMM_OPEN_API_SERVICE_HOST = "https://mmm-open-api-dev.fjmaimaimai.com" 8 var MMM_OPEN_API_SERVICE_HOST = "https://mmm-open-api-dev.fjmaimaimai.com"
  9 +var WORTH_SERVICE_GATEWAY_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
9 10
10 var LOG_LEVEL = "debug" 11 var LOG_LEVEL = "debug"
11 var LOG_File = "logs/app.log" 12 var LOG_File = "logs/app.log"
@@ -2,7 +2,7 @@ package constant @@ -2,7 +2,7 @@ package constant
2 2
3 import "os" 3 import "os"
4 4
5 -var POSTGRESQL_DB_NAME = "mmm_worth" 5 +var POSTGRESQL_DB_NAME = "mmmworth_dev"
6 var POSTGRESQL_USER = "postgres" 6 var POSTGRESQL_USER = "postgres"
7 var POSTGRESQL_PASSWORD = "1993618jack" 7 var POSTGRESQL_PASSWORD = "1993618jack"
8 var POSTGRESQL_HOST = "127.0.0.1" 8 var POSTGRESQL_HOST = "127.0.0.1"
  1 +package event
  2 +
  3 +import coreDomain "github.com/linmadan/egglib-go/core/domain"
  4 +
  5 +const USER_CHANGE_PHONE = "user-change-phone"
  6 +
  7 +type PhoneChanged struct {
  8 + coreDomain.BaseEvent
  9 + OldPhone string `json:"oldPhone"` // 旧手机号
  10 + NewPhone string `json:"newPhone"` // 新手机号
  11 +}
  12 +
  13 +func (event *PhoneChanged) EventType() string {
  14 + return USER_CHANGE_PHONE
  15 +}
@@ -54,7 +54,6 @@ func (exchangeCashActivity *ExchangeCashActivity) Update(data map[string]interfa @@ -54,7 +54,6 @@ func (exchangeCashActivity *ExchangeCashActivity) Update(data map[string]interfa
54 if createTime, ok := data["createTime"]; ok && createTime.(time.Time).IsZero() { 54 if createTime, ok := data["createTime"]; ok && createTime.(time.Time).IsZero() {
55 exchangeCashActivity.CreateTime = createTime.(time.Time) 55 exchangeCashActivity.CreateTime = createTime.(time.Time)
56 } 56 }
57 - exchangeCashActivity.CreateTime = time.Now()  
58 return nil 57 return nil
59 } 58 }
60 59
  1 +package service
  2 +
  3 +import coreDomain "github.com/linmadan/egglib-go/core/domain"
  4 +
  5 +type ChangePhoneService interface {
  6 + coreDomain.DomainEventPublisher
  7 + ChangePhone(oldPhone string, newPhone string) error
  8 +}
@@ -6,3 +6,12 @@ @@ -6,3 +6,12 @@
6 6
7 package service 7 package service
8 8
  9 +import (
  10 + coreDomain "github.com/linmadan/egglib-go/core/domain"
  11 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
  12 +)
  13 +
  14 +type ExchangeCashService interface {
  15 + coreDomain.DomainEventPublisher
  16 + ExchangeCash(uid int64, operatorUid int64, suMoney float64, activityId int64, recordDescription string) (*domain.SuMoneyTransactionRecord, error)
  17 +}
  1 +package dao
  2 +
  3 +import (
  4 + "fmt"
  5 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  6 +)
  7 +
  8 +type BidInfosDao struct {
  9 + transactionContext *pgTransaction.TransactionContext
  10 +}
  11 +
  12 +//TODO ChangeBidInfosSuccessfulBidderAccount
  13 +func (dao *BidInfosDao) ChangeBidInfosSuccessfulBidderAccount(uid int64, newAccount string) {
  14 +
  15 +}
  16 +
  17 +func NewBidInfosDao(transactionContext *pgTransaction.TransactionContext) (*BidInfosDao, error) {
  18 + if transactionContext == nil {
  19 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  20 + } else {
  21 + return &BidInfosDao{
  22 + transactionContext: transactionContext,
  23 + }, nil
  24 + }
  25 +}
  1 +package dao
  2 +
  3 +import (
  4 + "fmt"
  5 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  6 +)
  7 +
  8 +type BidderInfosDao struct {
  9 + transactionContext *pgTransaction.TransactionContext
  10 +}
  11 +
  12 +//TODO ChangeBidderInfosBidderAccount
  13 +func (dao *BidderInfosDao) ChangeBidderInfosBidderAccount() {
  14 +
  15 +}
  16 +
  17 +func NewBidderInfosDao(transactionContext *pgTransaction.TransactionContext) (*BidderInfosDao, error) {
  18 + if transactionContext == nil {
  19 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  20 + } else {
  21 + return &BidderInfosDao{
  22 + transactionContext: transactionContext,
  23 + }, nil
  24 + }
  25 +}
@@ -2,6 +2,7 @@ package dao @@ -2,6 +2,7 @@ package dao
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "github.com/go-pg/pg"
5 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
6 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models" 7 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
7 ) 8 )
@@ -19,37 +20,49 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map @@ -19,37 +20,49 @@ func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map
19 if err := tx.Model(exchangeCashPersonListModels). 20 if err := tx.Model(exchangeCashPersonListModels).
20 ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS activity_exchanged_su_money"). 21 ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS activity_exchanged_su_money").
21 Where("exchange_cash_person_list.activity_id = ?", activityId). 22 Where("exchange_cash_person_list.activity_id = ?", activityId).
22 - Select(&activityExchangedSuMoney); err !=nil { 23 + Select(&activityExchangedSuMoney); err != nil {
23 return nil, err 24 return nil, err
24 } 25 }
25 if err := tx.Model(exchangeCashPersonListModels). 26 if err := tx.Model(exchangeCashPersonListModels).
26 ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS activity_exchanged_cash"). 27 ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS activity_exchanged_cash").
27 Where("exchange_cash_person_list.activity_id = ?", activityId). 28 Where("exchange_cash_person_list.activity_id = ?", activityId).
28 - Select(&activityExchangedCash); err !=nil { 29 + Select(&activityExchangedCash); err != nil {
29 return nil, err 30 return nil, err
30 } 31 }
31 return map[string]interface{}{ 32 return map[string]interface{}{
32 "activityExchangedSuMoney": activityExchangedSuMoney, 33 "activityExchangedSuMoney": activityExchangedSuMoney,
33 - "activityExchangedCash": activityExchangedCash, 34 + "activityExchangedCash": activityExchangedCash,
34 }, nil 35 }, nil
35 } 36 }
36 37
  38 +// UpdateExchangeCashPersonListUserInfo 更新素币兑换清单用户信息
  39 +func (dao *CashPoolDao) UpdateExchangeCashPersonListUserInfo(oldPhone string, newPhone string) error {
  40 + tx := dao.transactionContext.PgTx
  41 + if _, err := tx.QueryOne(
  42 + pg.Scan(),
  43 + "UPDATE exchange_cash_person_lists SET employee_account = ? WHERE employee_account = ?",
  44 + newPhone, oldPhone); err != nil {
  45 + return err
  46 + }
  47 + return nil
  48 +}
  49 +
37 // 返回兑换活动清单榜单 50 // 返回兑换活动清单榜单
38 func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) { 51 func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) {
39 var retPeople []struct { 52 var retPeople []struct {
40 - Uid int64 53 + Uid int64
41 EmployeeName string 54 EmployeeName string
42 - SuMoney float64  
43 - Cash float64  
44 - Ranking int 55 + SuMoney float64
  56 + Cash float64
  57 + Ranking int
45 } 58 }
46 59
47 var retEmployee []struct { 60 var retEmployee []struct {
48 - Uid int64 61 + Uid int64
49 EmployeeName string 62 EmployeeName string
50 - SuMoney float64  
51 - Cash float64  
52 - Ranking int 63 + SuMoney float64
  64 + Cash float64
  65 + Ranking int
53 } 66 }
54 67
55 tx := dao.transactionContext.PgTx 68 tx := dao.transactionContext.PgTx
@@ -67,7 +80,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac @@ -67,7 +80,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
67 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 80 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
68 queryPeople = queryPeople.Where("e.company_id = ?", companyId) 81 queryPeople = queryPeople.Where("e.company_id = ?", companyId)
69 } 82 }
70 - if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){ 83 + if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0) {
71 queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId) 84 queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId)
72 } 85 }
73 queryPeople = queryPeople.Group("exchange_cash_person_list.uid") 86 queryPeople = queryPeople.Group("exchange_cash_person_list.uid")
@@ -104,7 +117,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac @@ -104,7 +117,7 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
104 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { 117 if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
105 queryPeopleAll = queryPeopleAll.Where("e.company_id = ?", companyId) 118 queryPeopleAll = queryPeopleAll.Where("e.company_id = ?", companyId)
106 } 119 }
107 - if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){ 120 + if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0) {
108 queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId) 121 queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId)
109 } 122 }
110 queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid") 123 queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid")
@@ -172,12 +185,12 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac @@ -172,12 +185,12 @@ func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interfac
172 return nil, err 185 return nil, err
173 } 186 }
174 187
175 - return map[string]interface{} {  
176 - "people": retPeople, // 员工排行榜  
177 - "count": count, // 计数  
178 - "currentEmployee": currentEmployee, // 当前员工排名  
179 - "exchangedSuMoney": activityExchangedSuMoney, // 清单已兑换素币  
180 - "exchangedCash": activityExchangedCash, // 清单已兑换现金 188 + return map[string]interface{}{
  189 + "people": retPeople, // 员工排行榜
  190 + "count": count, // 计数
  191 + "currentEmployee": currentEmployee, // 当前员工排名
  192 + "exchangedSuMoney": activityExchangedSuMoney, // 清单已兑换素币
  193 + "exchangedCash": activityExchangedCash, // 清单已兑换现金
181 }, nil 194 }, nil
182 } 195 }
183 196
@@ -189,4 +202,4 @@ func NewCashPoolDao(transactionContext *pgTransaction.TransactionContext) (*Cash @@ -189,4 +202,4 @@ func NewCashPoolDao(transactionContext *pgTransaction.TransactionContext) (*Cash
189 transactionContext: transactionContext, 202 transactionContext: transactionContext,
190 }, nil 203 }, nil
191 } 204 }
192 -}  
  205 +}
@@ -57,6 +57,18 @@ func (dao *EmployeeDao) ChangePrincipal(companyId int64, employeeAccount string) @@ -57,6 +57,18 @@ func (dao *EmployeeDao) ChangePrincipal(companyId int64, employeeAccount string)
57 return nil 57 return nil
58 } 58 }
59 59
  60 +// ChangePhone 修改用户手机号
  61 +func (dao *EmployeeDao) ChangePhone(oldPhone string, newPhone string) error {
  62 + tx := dao.transactionContext.PgTx
  63 + if _, err := tx.QueryOne(
  64 + pg.Scan(),
  65 + "UPDATE employees SET employee_account=? WHERE employee_account=?",
  66 + newPhone, oldPhone); err != nil {
  67 + return err
  68 + }
  69 + return nil
  70 +}
  71 +
60 // 更新用户素币 72 // 更新用户素币
61 func (dao *EmployeeDao) TransferSuMoney(uid int64, suMoney float64) error { 73 func (dao *EmployeeDao) TransferSuMoney(uid int64, suMoney float64) error {
62 tx := dao.transactionContext.PgTx 74 tx := dao.transactionContext.PgTx
@@ -139,7 +151,7 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{ @@ -139,7 +151,7 @@ func (dao *EmployeeDao) CalculatePersonSuMoney(uid int64) (map[string]interface{
139 } 151 }
140 152
141 // 计算系统已兑换现金素币、未兑换素币 153 // 计算系统已兑换现金素币、未兑换素币
142 -func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] interface{}, error) { 154 +func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string]interface{}, error) {
143 var systemUnExchangeSuMoney float64 155 var systemUnExchangeSuMoney float64
144 var systemExchangedSuMoney float64 156 var systemExchangedSuMoney float64
145 var systemExchangedSuMoneyRestore float64 157 var systemExchangedSuMoneyRestore float64
@@ -172,18 +184,18 @@ func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] int @@ -172,18 +184,18 @@ func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) (map[string] int
172 Select(&systemExchangedSuMoneyRestore); err != nil { 184 Select(&systemExchangedSuMoneyRestore); err != nil {
173 return nil, err 185 return nil, err
174 } 186 }
175 - return map[string] interface{} { 187 + return map[string]interface{}{
176 "systemUnExchangeSuMoney": systemUnExchangeSuMoney, 188 "systemUnExchangeSuMoney": systemUnExchangeSuMoney,
177 - "systemExchangedSuMoney": systemExchangedSuMoney - systemExchangedSuMoneyRestore,  
178 - },nil 189 + "systemExchangedSuMoney": systemExchangedSuMoney - systemExchangedSuMoneyRestore,
  190 + }, nil
179 } 191 }
180 192
181 // 计算现金池已兑换现金、未兑换现金 193 // 计算现金池已兑换现金、未兑换现金
182 -func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interface{}, error) { 194 +func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string]interface{}, error) {
183 tx := dao.transactionContext.PgTx 195 tx := dao.transactionContext.PgTx
184 var ( 196 var (
185 systemUnExchangeCash float64 197 systemUnExchangeCash float64
186 - systemExchangedCash float64 198 + systemExchangedCash float64
187 ) 199 )
188 // 系统已兑换现金 200 // 系统已兑换现金
189 cashPool := new(models.CashPool) 201 cashPool := new(models.CashPool)
@@ -192,7 +204,7 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf @@ -192,7 +204,7 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf
192 Where("cash_pool.company_id = ?", companyId). 204 Where("cash_pool.company_id = ?", companyId).
193 Order("id DESC"). 205 Order("id DESC").
194 Limit(1). 206 Limit(1).
195 - Select(&systemExchangedCash) ; err != nil { 207 + Select(&systemExchangedCash); err != nil {
196 return nil, err 208 return nil, err
197 } 209 }
198 // 系统未兑换现金 210 // 系统未兑换现金
@@ -201,22 +213,22 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf @@ -201,22 +213,22 @@ func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (map[string] interf
201 Where("cash_pool.company_id = ?", companyId). 213 Where("cash_pool.company_id = ?", companyId).
202 Order("id DESC"). 214 Order("id DESC").
203 Limit(1). 215 Limit(1).
204 - Select(&systemUnExchangeCash) ; err != nil { 216 + Select(&systemUnExchangeCash); err != nil {
205 return nil, err 217 return nil, err
206 } 218 }
207 - return map[string] interface{} { 219 + return map[string]interface{}{
208 "systemUnExchangeCash": systemUnExchangeCash, 220 "systemUnExchangeCash": systemUnExchangeCash,
209 - "systemExchangedCash": systemExchangedCash, 221 + "systemExchangedCash": systemExchangedCash,
210 }, nil 222 }, nil
211 } 223 }
212 224
213 // 计算个人素币收支(素币明细收支) 225 // 计算个人素币收支(素币明细收支)
214 func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transactionStartTime time.Time, transactionEndTime time.Time) (map[string]interface{}, error) { 226 func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transactionStartTime time.Time, transactionEndTime time.Time) (map[string]interface{}, error) {
215 var ( 227 var (
216 - incomeSuMoney float64 // 收入的素币(2:任务奖励,3:增加)  
217 - expendSuMoney float64 // 消耗的素币(1:兑换物资,4:扣除)  
218 - expendSuMoneyExchange float64 // 5: 兑换现金  
219 - incomeSuMoneyExchangeRestore float64 // 6: 兑换素币撤回 228 + incomeSuMoney float64 // 收入的素币(2:任务奖励,3:增加)
  229 + expendSuMoney float64 // 消耗的素币(1:兑换物资,4:扣除)
  230 + expendSuMoneyExchange float64 // 5: 兑换现金
  231 + incomeSuMoneyExchangeRestore float64 // 6: 兑换素币撤回
220 ) 232 )
221 tx := dao.transactionContext.PgTx 233 tx := dao.transactionContext.PgTx
222 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) 234 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
@@ -261,7 +273,7 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction @@ -261,7 +273,7 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction
261 return nil, err 273 return nil, err
262 } 274 }
263 return map[string]interface{}{ 275 return map[string]interface{}{
264 - "incomeSuMoney": incomeSuMoney, // 个人素币收入 276 + "incomeSuMoney": incomeSuMoney, // 个人素币收入
265 "expendSuMoney": expendSuMoney + (expendSuMoneyExchange - incomeSuMoneyExchangeRestore), // 个人素币支出 277 "expendSuMoney": expendSuMoney + (expendSuMoneyExchange - incomeSuMoneyExchangeRestore), // 个人素币支出
266 }, nil 278 }, nil
267 } 279 }
@@ -269,8 +281,8 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction @@ -269,8 +281,8 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction
269 // 计算个人贡献值收支(贡献明细收支) 281 // 计算个人贡献值收支(贡献明细收支)
270 func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, transactionStartTime time.Time, transactionEndTime time.Time) (map[string]interface{}, error) { 282 func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, transactionStartTime time.Time, transactionEndTime time.Time) (map[string]interface{}, error) {
271 var ( 283 var (
272 - incomeContributions float64 // 收入的贡献值(2:任务奖励,3:增加)  
273 - expendContributions float64 // 支出的贡献值 (4: 扣除) 284 + incomeContributions float64 // 收入的贡献值(2:任务奖励,3:增加)
  285 + expendContributions float64 // 支出的贡献值 (4: 扣除)
274 ) 286 )
275 tx := dao.transactionContext.PgTx 287 tx := dao.transactionContext.PgTx
276 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord) 288 suMoneyTransactionRecordModel := new(models.SuMoneyTransactionRecord)
@@ -301,37 +313,37 @@ func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, trans @@ -301,37 +313,37 @@ func (dao *EmployeeDao) CalculateContributionsTransactionRecord(uid int64, trans
301 return nil, err 313 return nil, err
302 } 314 }
303 return map[string]interface{}{ 315 return map[string]interface{}{
304 - "incomeContributions": incomeContributions, // 个人贡献值收入  
305 - "expendContributions": expendContributions, // 个人贡献支出  
306 - "contributions": incomeContributions - expendContributions, // 个人贡献值 316 + "incomeContributions": incomeContributions, // 个人贡献值收入
  317 + "expendContributions": expendContributions, // 个人贡献支出
  318 + "contributions": incomeContributions - expendContributions, // 个人贡献值
307 }, nil 319 }, nil
308 } 320 }
309 321
310 // 贡献值、财富值总榜和年榜, 322 // 贡献值、财富值总榜和年榜,
311 func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]interface{}) (interface{}, error) { 323 func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]interface{}) (interface{}, error) {
312 - var retWealth []struct { // 个人财富值  
313 - Uid int64  
314 - EmployeeName string 324 + var retWealth []struct { // 个人财富值
  325 + Uid int64
  326 + EmployeeName string
315 EmployeeSuMoney float64 327 EmployeeSuMoney float64
316 - Ranking int 328 + Ranking int
317 } 329 }
318 - var retEmployeeWealth []struct { // 个人贡献值  
319 - Uid int64  
320 - EmployeeName string 330 + var retEmployeeWealth []struct { // 个人贡献值
  331 + Uid int64
  332 + EmployeeName string
321 EmployeeSuMoney float64 333 EmployeeSuMoney float64
322 - Ranking int 334 + Ranking int
323 } 335 }
324 - var retContributions []struct { // 员工贡献值  
325 - Uid int64  
326 - EmployeeName string 336 + var retContributions []struct { // 员工贡献值
  337 + Uid int64
  338 + EmployeeName string
327 EmployeesContributions float64 339 EmployeesContributions float64
328 - Ranking int 340 + Ranking int
329 } 341 }
330 - var retEmployeeContributions []struct { // 员工贡献值  
331 - Uid int64  
332 - EmployeeName string 342 + var retEmployeeContributions []struct { // 员工贡献值
  343 + Uid int64
  344 + EmployeeName string
333 EmployeesContributions float64 345 EmployeesContributions float64
334 - Ranking int 346 + Ranking int
335 } 347 }
336 348
337 tx := dao.transactionContext.PgTx 349 tx := dao.transactionContext.PgTx
@@ -496,23 +508,23 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter @@ -496,23 +508,23 @@ func (dao *EmployeeDao) ContributionsWealthRanking(queryOptions map[string]inter
496 } 508 }
497 509
498 return map[string]interface{}{ 510 return map[string]interface{}{
499 - "employeesWealth": retWealth,  
500 - "employeesContributions": retContributions, 511 + "employeesWealth": retWealth,
  512 + "employeesContributions": retContributions,
501 "currentEmployeeContributions": retCurrentEmployeeContributions, 513 "currentEmployeeContributions": retCurrentEmployeeContributions,
502 - "currentEmployeeWealth": retCurrentEmployeeWealth, 514 + "currentEmployeeWealth": retCurrentEmployeeWealth,
503 }, nil 515 }, nil
504 } 516 }
505 517
506 // 公司员工贡献值分组统计 518 // 公司员工贡献值分组统计
507 func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) { 519 func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) {
508 - var ret []struct { // 员工贡献值  
509 - Uid int  
510 - EmployeeName string 520 + var ret []struct { // 员工贡献值
  521 + Uid int
  522 + EmployeeName string
511 EmployeesContributions float64 523 EmployeesContributions float64
512 } 524 }
513 - var retDecrease []struct { // 员工减少的贡献值  
514 - Uid int  
515 - EmployeeName string 525 + var retDecrease []struct { // 员工减少的贡献值
  526 + Uid int
  527 + EmployeeName string
516 EmployeesContributions float64 528 EmployeesContributions float64
517 } 529 }
518 tx := dao.transactionContext.PgTx 530 tx := dao.transactionContext.PgTx
@@ -562,8 +574,8 @@ func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime @@ -562,8 +574,8 @@ func (dao *EmployeeDao) CalculateEmployeesContributions(companyId int, startTime
562 // 公司员工财富值分组统计 574 // 公司员工财富值分组统计
563 func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) { 575 func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time.Time, endTime time.Time) (map[string]interface{}, error) {
564 var ret []struct { 576 var ret []struct {
565 - Uid int  
566 - EmployeeName string 577 + Uid int
  578 + EmployeeName string
567 EmployeeSuMoney float64 579 EmployeeSuMoney float64
568 } 580 }
569 tx := dao.transactionContext.PgTx 581 tx := dao.transactionContext.PgTx
@@ -574,7 +586,7 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time. @@ -574,7 +586,7 @@ func (dao *EmployeeDao) CalculateEmployeesSuMoney(companyId int, startTime time.
574 ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money"). 586 ColumnExpr("sum(su_money_transaction_record.su_money) AS employee_su_money").
575 Where(`e.company_id = ?`, companyId). 587 Where(`e.company_id = ?`, companyId).
576 //Where(`e.status = ?`, 1). 588 //Where(`e.status = ?`, 1).
577 - Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的 589 + Where(`su_money_transaction_record.record_type IN (?)`, pg.In([]int{2, 3})). // 增加,任务奖励的
578 Where(`su_money_transaction_record.create_time > ?`, startTime). 590 Where(`su_money_transaction_record.create_time > ?`, startTime).
579 Where(`su_money_transaction_record.create_time < ?`, endTime). 591 Where(`su_money_transaction_record.create_time < ?`, endTime).
580 Group("su_money_transaction_record.employee"). 592 Group("su_money_transaction_record.employee").
  1 +package dao
  2 +
  3 +import (
  4 + "fmt"
  5 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  6 +)
  7 +
  8 +type OffTaskRecordsDao struct {
  9 + transactionContext *pgTransaction.TransactionContext
  10 +}
  11 +
  12 +//TODO ChangeOffTaskRecordsOperatorAccount
  13 +func (dao *OffTaskRecordsDao) ChangeOffTaskRecordsOperatorAccount() {
  14 +
  15 +}
  16 +
  17 +func NewOffTaskRecordsDao(transactionContext *pgTransaction.TransactionContext) (*OffTaskRecordsDao, error) {
  18 + if transactionContext == nil {
  19 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  20 + } else {
  21 + return &OffTaskRecordsDao{
  22 + transactionContext: transactionContext,
  23 + }, nil
  24 + }
  25 +}
  1 +package dao
  2 +
  3 +import (
  4 + "fmt"
  5 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  6 +)
  7 +
  8 +type RejectTaskRecordsDao struct {
  9 + transactionContext *pgTransaction.TransactionContext
  10 +}
  11 +
  12 +//TODO ChangeRejectTaskRecordsOperatorAccount
  13 +func (dao *RejectTaskRecordsDao) ChangeRejectTaskRecordsOperatorAccount() {
  14 +
  15 +}
  16 +
  17 +func NewRejectTaskRecordsDao(transactionContext *pgTransaction.TransactionContext) (*RejectTaskRecordsDao, error) {
  18 + if transactionContext == nil {
  19 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  20 + } else {
  21 + return &RejectTaskRecordsDao{
  22 + transactionContext: transactionContext,
  23 + }, nil
  24 + }
  25 +}
  1 +package dao
  2 +
  3 +import (
  4 + "fmt"
  5 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  6 +)
  7 +
  8 +type RobInfosDao struct {
  9 + transactionContext *pgTransaction.TransactionContext
  10 +}
  11 +
  12 +//TODO ChangeRobInfosReceiverAccount
  13 +func (dao *RobInfosDao) ChangeRobInfosReceiverAccount() {
  14 +
  15 +}
  16 +
  17 +func NewRobInfosDao(transactionContext *pgTransaction.TransactionContext) (*RobInfosDao, error) {
  18 + if transactionContext == nil {
  19 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  20 + } else {
  21 + return &RobInfosDao{
  22 + transactionContext: transactionContext,
  23 + }, nil
  24 + }
  25 +}
  1 +package dao
  2 +
  3 +import (
  4 + "fmt"
  5 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  6 +)
  7 +
  8 +type SentNotificationDao struct {
  9 + transactionContext *pgTransaction.TransactionContext
  10 +}
  11 +
  12 +// ChangeSentNotificationReceiverAccount TODO 修改已发送通知用户信息
  13 +func (dao *SentNotificationDao) ChangeSentNotificationReceiverAccount() {
  14 +
  15 +}
  16 +
  17 +func NewSentNotificationDao(transactionContext *pgTransaction.TransactionContext) (*SentNotificationDao, error) {
  18 + if transactionContext == nil {
  19 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  20 + } else {
  21 + return &SentNotificationDao{
  22 + transactionContext: transactionContext,
  23 + }, nil
  24 + }
  25 +}
  1 +package dao
  2 +
  3 +import (
  4 + "fmt"
  5 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  6 +)
  7 +
  8 +type SuMoneyTransactionRecordsDao struct {
  9 + transactionContext *pgTransaction.TransactionContext
  10 +}
  11 +
  12 +// ChangeSuMoneyTransactionRecordsEmployeeAccount TODO 修改素币流水记录用户信息
  13 +func (dao *SuMoneyTransactionRecordsDao) ChangeSuMoneyTransactionRecordsEmployeeAccount() {
  14 +
  15 +}
  16 +
  17 +// ChangeSuMoneyTransactionRecordsOperatorAccount TODO 素币流水记操作人信息
  18 +func (dao *SuMoneyTransactionRecordsDao) ChangeSuMoneyTransactionRecordsOperatorAccount() {
  19 +
  20 +}
  21 +
  22 +func NewSuMoneyTransactionRecordsDao(transactionContext *pgTransaction.TransactionContext) (*SuMoneyTransactionRecordsDao, error) {
  23 + if transactionContext == nil {
  24 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  25 + } else {
  26 + return &SuMoneyTransactionRecordsDao{
  27 + transactionContext: transactionContext,
  28 + }, nil
  29 + }
  30 +}
@@ -362,6 +362,26 @@ func (dao *TaskDao) CalculatePersonTask(uid int64, companyId int) (map[string]in @@ -362,6 +362,26 @@ func (dao *TaskDao) CalculatePersonTask(uid int64, companyId int) (map[string]in
362 }, nil 362 }, nil
363 } 363 }
364 364
  365 +//TODO ChangeSponsorAccount 修改sponsor手机号 jsonb
  366 +func (dao *TaskDao) ChangeSponsorAccount() {
  367 +
  368 +}
  369 +
  370 +//TODO ChangeParticipatorAccount 修改participator手机号 jsonb_array
  371 +func (dao *TaskDao) ChangeParticipatorAccount() {
  372 +
  373 +}
  374 +
  375 +//TODO ChangeTaskPercentageContributorAccount 修改task_percentage contributor手机号 jsonb_array
  376 +func (dao *TaskDao) ChangeTaskPercentageContributorAccount() {
  377 +
  378 +}
  379 +
  380 +//TODO ChangeAssignedPersonAccount 修改assigned_person手机号 jsonb
  381 +func (dao *TaskDao) ChangeAssignedPersonAccount() {
  382 +
  383 +}
  384 +
365 func NewTaskDao(transactionContext *pgTransaction.TransactionContext) (*TaskDao, error) { 385 func NewTaskDao(transactionContext *pgTransaction.TransactionContext) (*TaskDao, error) {
366 if transactionContext == nil { 386 if transactionContext == nil {
367 return nil, fmt.Errorf("transactionContext参数不能为nil") 387 return nil, fmt.Errorf("transactionContext参数不能为nil")
  1 +package domain_service
  2 +
  3 +import (
  4 + "fmt"
  5 + coreDomain "github.com/linmadan/egglib-go/core/domain"
  6 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  7 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/event"
  8 +)
  9 +
  10 +type ChangePhoneService struct {
  11 + coreDomain.BaseEventPublisher
  12 + transactionContext *pgTransaction.TransactionContext
  13 +}
  14 +
  15 +func (service *ChangePhoneService) ChangePhone(oldPhone string, newPhone string) error {
  16 + changePhoneEvent := new(event.PhoneChanged)
  17 + changePhoneEvent.OldPhone = oldPhone
  18 + changePhoneEvent.NewPhone = newPhone
  19 + if err := service.Publish(changePhoneEvent); err != nil {
  20 + return err
  21 + }
  22 + return nil
  23 +}
  24 +
  25 +func NewChangePhoneService(transactionContext *pgTransaction.TransactionContext) (*ChangePhoneService, error) {
  26 + if transactionContext == nil {
  27 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  28 + } else {
  29 + return &ChangePhoneService{
  30 + transactionContext: transactionContext,
  31 + }, nil
  32 + }
  33 +}
  1 +package service_gateway
  2 +
  3 +import (
  4 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/constant"
  5 + "strings"
  6 + "time"
  7 +)
  8 +
  9 +type HttplibWorthServiceGateway struct {
  10 + httplibBaseServiceGateway
  11 +}
  12 +
  13 +// ChangePhoneCallback 修改手机号码回调,通知价值APP端中台
  14 +func (serviceGateway *HttplibWorthServiceGateway) ChangePhoneCallback(oldPhone string, newPhone string) (map[string]interface{}, error) {
  15 + url := strings.Join([]string{serviceGateway.baseURL, "/v1/auth/forceRevoke"}, "/")
  16 + request := serviceGateway.createRequest(url, "post")
  17 + options := make(map[string]interface{})
  18 + options["phone"] = oldPhone
  19 + options["newPhone"] = newPhone
  20 + request.JSONBody(options)
  21 + response := make(map[string]interface{})
  22 + request.ToJSON(&response)
  23 + data, err := serviceGateway.responseHandle(response)
  24 + return data, err
  25 +}
  26 +
  27 +func NewHttplibWorthServiceGateway() *HttplibWorthServiceGateway {
  28 + return &HttplibWorthServiceGateway{
  29 + httplibBaseServiceGateway: httplibBaseServiceGateway{
  30 + baseURL: constant.ABILITY_SERVICE_HOST,
  31 + connectTimeout: 100 * time.Second,
  32 + readWriteTimeout: 30 * time.Second,
  33 + },
  34 + }
  35 +}
@@ -14,3 +14,7 @@ type AbilityServiceGateway interface { @@ -14,3 +14,7 @@ type AbilityServiceGateway interface {
14 type MmmOpenApiServiceGateway interface { 14 type MmmOpenApiServiceGateway interface {
15 PushInfo(msgType int, uids []int64, title string, content string, ext map[string]interface{}) (map[string]interface{}, error) 15 PushInfo(msgType int, uids []int64, title string, content string, ext map[string]interface{}) (map[string]interface{}, error)
16 } 16 }
  17 +
  18 +type WorthServiceGateway interface {
  19 + ChangePhoneCallback(oldPhone string, newPhone string) (map[string]interface{}, error)
  20 +}
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 8
9 /** 9 /**
10 * @Author SteveChan 10 * @Author SteveChan
11 - * @Description //TODO 11 + * @Description
12 * @Date 16:50 2020/12/10 12 * @Date 16:50 2020/12/10
13 * @Param 13 * @Param
14 * @return 14 * @return
@@ -34,7 +34,7 @@ func StringSliceEqualBCE(a, b []int) bool { @@ -34,7 +34,7 @@ func StringSliceEqualBCE(a, b []int) bool {
34 34
35 /** 35 /**
36 * @Author SteveChan 36 * @Author SteveChan
37 - * @Description //TODO 37 + * @Description
38 * @Date 16:50 2020/12/10 38 * @Date 16:50 2020/12/10
39 * @Param 39 * @Param
40 * @return 40 * @return
@@ -50,7 +50,7 @@ func IsContain(items []interface{}, item string) bool { @@ -50,7 +50,7 @@ func IsContain(items []interface{}, item string) bool {
50 50
51 /** 51 /**
52 * @Author SteveChan 52 * @Author SteveChan
53 - * @Description //TODO 53 + * @Description
54 * @Date 16:50 2020/12/10 54 * @Date 16:50 2020/12/10
55 * @Param 55 * @Param
56 * @return 56 * @return
@@ -80,7 +80,7 @@ func (l LocalDate) MarshalJSON() ([]byte, error) { @@ -80,7 +80,7 @@ func (l LocalDate) MarshalJSON() ([]byte, error) {
80 80
81 /** 81 /**
82 * @Author SteveChan 82 * @Author SteveChan
83 - * @Description //TODO 83 + * @Description
84 * @Date 16:49 2020/12/10 84 * @Date 16:49 2020/12/10
85 * @Param 85 * @Param
86 * @return 86 * @return