作者 陈志颖

feat:修改基础设施层资源库,更新应用层素币管理模块,完善增删改查功能

@@ -3,6 +3,7 @@ module gitlab.fjmaimaimai.com/linmadan/mmm-worth @@ -3,6 +3,7 @@ module gitlab.fjmaimaimai.com/linmadan/mmm-worth
3 go 1.14 3 go 1.14
4 4
5 require ( 5 require (
  6 + github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.1
6 github.com/ajg/form v1.5.1 // indirect 7 github.com/ajg/form v1.5.1 // indirect
7 github.com/astaxie/beego v1.12.1 8 github.com/astaxie/beego v1.12.1
8 github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect 9 github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
  1 +github.com/360EntSecGroup-Skylar/excelize v1.4.1 h1:l55mJb6rkkaUzOpSsgEeKYtS6/0gHwBYyfo5Jcjv/Ks=
  2 +github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.1 h1:j56fC19WoD3z+u+ZHxm2XwRGyS1XmdSMk7058BLhdsM=
  3 +github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.1/go.mod h1:gXEhMjm1VadSGjAzyDlBxmdYglP8eJpYWxpwJnmXRWw=
1 github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo= 4 github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
2 github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= 5 github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
3 github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM= 6 github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM=
@@ -84,6 +87,8 @@ github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope @@ -84,6 +87,8 @@ github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope
84 github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= 87 github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
85 github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= 88 github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
86 github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= 89 github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
  90 +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
  91 +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
87 github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs= 92 github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs=
88 github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= 93 github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ=
89 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 94 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
@@ -98,6 +103,10 @@ github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6J @@ -98,6 +103,10 @@ github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6J
98 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 103 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
99 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 104 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
100 github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= 105 github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
  106 +github.com/richardlehane/mscfb v1.0.3 h1:rD8TBkYWkObWO0oLDFCbwMeZ4KoalxQy+QgniCj3nKI=
  107 +github.com/richardlehane/mscfb v1.0.3/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
  108 +github.com/richardlehane/msoleps v1.0.1 h1:RfrALnSNXzmXLbGct/P2b4xkFz4e8Gmj/0Vj9M9xC1o=
  109 +github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
101 github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0= 110 github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
102 github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM= 111 github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
103 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo= 112 github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
@@ -119,6 +128,7 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0 @@ -119,6 +128,7 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
119 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= 128 github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
120 github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= 129 github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
121 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= 130 github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
  131 +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
122 github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0= 132 github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
123 github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= 133 github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
124 github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= 134 github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
@@ -134,6 +144,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo @@ -134,6 +144,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo
134 github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= 144 github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
135 github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= 145 github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
136 github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= 146 github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
  147 +github.com/xuri/efp v0.0.0-20200605144744-ba689101faaf h1:spotWVWg9DP470pPFQ7LaYtUqDpWEOS/BUrSmwFZE4k=
  148 +github.com/xuri/efp v0.0.0-20200605144744-ba689101faaf/go.mod h1:uBiSUepVYMhGTfDeBKKasV4GpgBlzJ46gXUBAqV8qLk=
137 github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY= 149 github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY=
138 github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= 150 github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
139 github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= 151 github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA=
@@ -150,6 +162,10 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U @@ -150,6 +162,10 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U
150 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= 162 golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
151 golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf h1:fnPsqIDRbCSgumaMCRpoIoF2s4qxv0xSSS0BVZUE/ss= 163 golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf h1:fnPsqIDRbCSgumaMCRpoIoF2s4qxv0xSSS0BVZUE/ss=
152 golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= 164 golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
  165 +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
  166 +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
  167 +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
  168 +golang.org/x/image v0.0.0-20200922025426-e59bae62ef32/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
153 golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 169 golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
154 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 170 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
155 golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 171 golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
@@ -160,6 +176,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL @@ -160,6 +176,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
160 golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 176 golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
161 golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g= 177 golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g=
162 golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= 178 golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
  179 +golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
  180 +golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
163 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 181 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
164 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 182 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
165 golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 183 golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
@@ -173,9 +191,13 @@ golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7w @@ -173,9 +191,13 @@ golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7w
173 golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 191 golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
174 golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8= 192 golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
175 golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 193 golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
  194 +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
  195 +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
176 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= 196 golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
177 golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= 197 golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
178 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 198 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
  199 +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
  200 +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
179 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 201 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
180 golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 202 golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
181 golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 203 golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
@@ -198,5 +220,6 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= @@ -198,5 +220,6 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
198 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 220 gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
199 gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= 221 gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
200 gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 222 gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
  223 +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
201 mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w= 224 mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w=
202 mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ= 225 mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ=
@@ -28,3 +28,11 @@ func CreateNotificationDao(options map[string]interface{}) (*dao.NotificationDao @@ -28,3 +28,11 @@ func CreateNotificationDao(options map[string]interface{}) (*dao.NotificationDao
28 } 28 }
29 return dao.NewNotificationDao(transactionContext) 29 return dao.NewNotificationDao(transactionContext)
30 } 30 }
  31 +
  32 +func CreateCashPoolDao(options map[string]interface{}) (*dao.CashPoolDao, error) {
  33 + var transactionContext *pg.TransactionContext
  34 + if value, ok := options["transactionContext"]; ok {
  35 + transactionContext = value.(*pg.TransactionContext)
  36 + }
  37 + return dao.NewCashPoolDao(transactionContext)
  38 +}
@@ -110,13 +110,5 @@ func CreateExchangeSuMoneyService(options map[string]interface{}) (service.Excha @@ -110,13 +110,5 @@ func CreateExchangeSuMoneyService(options map[string]interface{}) (service.Excha
110 return domainService.NewExchangeSuMoneyService(transactionContext) 110 return domainService.NewExchangeSuMoneyService(transactionContext)
111 } 111 }
112 112
113 -func CreateInputCashPoolService(options map[string]interface{}) (service.InputCashPoolService, error) {  
114 - var transactionContext *pgTransaction.TransactionContext  
115 - if value, ok := options["transactionContext"]; ok {  
116 - transactionContext = value.(*pgTransaction.TransactionContext)  
117 - }  
118 - return domainService.NewCashPoolService(transactionContext)  
119 -}  
120 -  
121 113
122 114
@@ -216,16 +216,16 @@ func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMone @@ -216,16 +216,16 @@ func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMone
216 transactionContext.RollbackTransaction() 216 transactionContext.RollbackTransaction()
217 }() 217 }()
218 218
219 - var employeeDao *dao.EmployeeDao  
220 - if value, err := factory.CreateEmployeeDao(map[string]interface{}{ 219 + var cashPoolDao *dao.CashPoolDao
  220 + if value, err := factory.CreateCashPoolDao(map[string]interface{}{
221 "transactionContext": transactionContext, 221 "transactionContext": transactionContext,
222 }); err != nil { 222 }); err != nil {
223 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 223 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
224 } else { 224 } else {
225 - employeeDao = value 225 + cashPoolDao = value
226 } 226 }
227 227
228 - if systemSuMoneyStatistics, err := employeeDao.CalculateSystemCash(systemSuMoneyStatisticsCommand.CompanyId); err != nil { 228 + if systemSuMoneyStatistics, err := cashPoolDao.CalculateSystemCash(systemSuMoneyStatisticsCommand.CompanyId); err != nil {
229 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 229 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
230 } else { 230 } else {
231 if err := transactionContext.CommitTransaction(); err != nil { 231 if err := transactionContext.CommitTransaction(); err != nil {
@@ -8,14 +8,15 @@ import ( @@ -8,14 +8,15 @@ import (
8 8
9 // 创建现金池 9 // 创建现金池
10 type CreateCashPoolCommand struct { 10 type CreateCashPoolCommand struct {
  11 + //Uid int64 `json:"uid"` // 统一用户id
11 //CashPoolId int64 `json:"cashPoolId" valid:"Required"` // 现金池ID 12 //CashPoolId int64 `json:"cashPoolId" valid:"Required"` // 现金池ID
12 - CompanyId int64 `json:"companyId" valid:"Required"` // 公司ID 13 + CompanyId int64 `json:"companyId"` // 公司ID
13 Cash float64 `json:"cash" valid:"Required"` // 投入的现金值 14 Cash float64 `json:"cash" valid:"Required"` // 投入的现金值
14 - ExchangedCash float64 `json:"exchangedCash,omitempty"` // 现金池已兑换现金值  
15 - UnExchangeCash float64 `json:"unExchangeCash,omitempty"` // 现金池未兑换现金值  
16 - ExchangedSuMoney float64 `json:"exchangedSuMoney,omitempty"` // 现金池已兑换素币值  
17 - UnExchangeSuMoney float64 `json:"unExchangeSuMoney,omitempty"` // 现金池未兑换素币值  
18 - Operator int64 `json:"operator,omitempty"` // 操作人UID 15 + //ExchangedCash float64 `json:"exchangedCash,omitempty"` // 现金池已兑换现金值
  16 + //UnExchangeCash float64 `json:"unExchangeCash,omitempty"` // 现金池未兑换现金值
  17 + //ExchangedSuMoney float64 `json:"exchangedSuMoney,omitempty"` // 现金池已兑换素币值
  18 + //UnExchangeSuMoney float64 `json:"unExchangeSuMoney,omitempty"` // 现金池未兑换素币值
  19 + //Operator int64 `json:"operator,omitempty"` // 操作人UID
19 } 20 }
20 21
21 func (createCashPoolCommand *CreateCashPoolCommand) ValidateCommand() error { 22 func (createCashPoolCommand *CreateCashPoolCommand) ValidateCommand() error {
@@ -3,7 +3,6 @@ package command @@ -3,7 +3,6 @@ package command
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "github.com/astaxie/beego/validation" 5 "github.com/astaxie/beego/validation"
6 - "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"  
7 "time" 6 "time"
8 ) 7 )
9 8
@@ -11,13 +10,14 @@ import ( @@ -11,13 +10,14 @@ import (
11 type CreateExchangeCashActivityCommand struct { 10 type CreateExchangeCashActivityCommand struct {
12 CompanyId int64 `json:"companyId" valid:"Required"` // 公司id 11 CompanyId int64 `json:"companyId" valid:"Required"` // 公司id
13 ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称 12 ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称
14 - CashPool *domain.CashPool `json:"cashPool"` // 兑换现金活动关联的现金池,最新的现金池 13 + //CashPool *domain.CashPool `json:"cashPool"` // 兑换现金活动关联的现金池,最新的现金池
15 Deadline time.Time `json:"deadline"` // 活动截止时间 14 Deadline time.Time `json:"deadline"` // 活动截止时间
16 CountDown int64 `json:"countDown"` // 活动倒计时 15 CountDown int64 `json:"countDown"` // 活动倒计时
17 ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币 16 ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币
18 ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金 17 ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金
19 ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率 18 ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率
20 - ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeList"` // 兑换活动清单 19 + CreateTime time.Time `json:"createTime"` // 创建时间
  20 + //ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeList"` // 兑换活动清单
21 } 21 }
22 22
23 func (createExchangeActivityCommand *CreateExchangeCashActivityCommand) ValidateCommand() error { 23 func (createExchangeActivityCommand *CreateExchangeCashActivityCommand) ValidateCommand() error {
@@ -3,20 +3,19 @@ package command @@ -3,20 +3,19 @@ package command
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "github.com/astaxie/beego/validation" 5 "github.com/astaxie/beego/validation"
6 - "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"  
7 "time" 6 "time"
8 ) 7 )
9 8
10 type UpdateExchangeCashActivityCommand struct { 9 type UpdateExchangeCashActivityCommand struct {
11 ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id 10 ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id
12 - CompanyId int64 `json:"companyId" valid:"Required"` // 公司id 11 + //CompanyId int64 `json:"companyId" valid:"Required"` // 公司id
13 ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称 12 ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称
14 Deadline time.Time `json:"deadline"` // 活动截止时间 13 Deadline time.Time `json:"deadline"` // 活动截止时间
15 CountDown int64 `json:"countDown"` // 活动倒计时 14 CountDown int64 `json:"countDown"` // 活动倒计时
16 ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币 15 ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币
17 ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金 16 ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金
18 ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率 17 ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率
19 - ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeCashPeople"` // 兑换活动清单 18 + //ExchangeCashPeople []*domain.ExchangeCashPersonList `json:"exchangeCashPeople"` // 兑换活动清单
20 } 19 }
21 20
22 func (updateExchangeCashActivity *UpdateExchangeCashActivityCommand) ValidateCommand() error { 21 func (updateExchangeCashActivity *UpdateExchangeCashActivityCommand) ValidateCommand() error {
@@ -2,13 +2,14 @@ package service @@ -2,13 +2,14 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "github.com/linmadan/egglib-go/utils/tool_funs"
  6 + "time"
5 7
6 "github.com/linmadan/egglib-go/core/application" 8 "github.com/linmadan/egglib-go/core/application"
7 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" 9 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
8 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command" 10 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
9 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query" 11 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
10 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" 12 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
11 - "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"  
12 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" 13 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
13 ) 14 )
14 15
@@ -16,93 +17,104 @@ import ( @@ -16,93 +17,104 @@ import (
16 type CashPoolService struct { 17 type CashPoolService struct {
17 } 18 }
18 19
19 -// 投入现金  
20 -func (cashPoolService *CashPoolService) OperationCashPool(createCashPoolCommand *command.CreateCashPoolCommand) (interface{}, error) { 20 +// 投入现金池
  21 +func (cashPoolService *CashPoolService) CreateCashPool(createCashPoolCommand *command.CreateCashPoolCommand) (interface{}, error) {
  22 + // 校验命令
21 if err := createCashPoolCommand.ValidateCommand(); err != nil { 23 if err := createCashPoolCommand.ValidateCommand(); err != nil {
22 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 24 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
23 } 25 }
24 26
  27 + // 新建现金池事务
25 transactionContext, err := factory.CreateTransactionContext(nil) 28 transactionContext, err := factory.CreateTransactionContext(nil)
26 -  
27 if err != nil { 29 if err != nil {
28 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 30 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
29 } 31 }
30 -  
31 if err := transactionContext.StartTransaction(); err != nil { 32 if err := transactionContext.StartTransaction(); err != nil {
32 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 33 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
33 } 34 }
34 -  
35 defer func() { 35 defer func() {
36 transactionContext.RollbackTransaction() 36 transactionContext.RollbackTransaction()
37 }() 37 }()
38 38
39 - var employeeDao *dao.EmployeeDao  
40 - if value, err := factory.CreateEmployeeDao(map[string]interface{}{ 39 + // 新建现金池数据访问对象
  40 + var cashPoolDao *dao.CashPoolDao
  41 + if value, err := factory.CreateCashPoolDao(map[string]interface{}{
41 "transactionContext": transactionContext, 42 "transactionContext": transactionContext,
42 }); err != nil { 43 }); err != nil {
43 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 44 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
44 } else { 45 } else {
45 - employeeDao = value 46 + cashPoolDao = value
46 } 47 }
47 48
  49 + // 获取系统已兑换现金值
48 var systemExchangedCash float64 50 var systemExchangedCash float64
49 - if value, err := employeeDao.CalculateSystemCash(createCashPoolCommand.CompanyId); err != nil { 51 + if value, err := cashPoolDao.CalculateSystemCash(createCashPoolCommand.CompanyId); err != nil {
50 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 52 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
51 } else { 53 } else {
52 systemExchangedCash = value 54 systemExchangedCash = value
53 } 55 }
54 56
  57 + // 获取系统素币兑换情况
55 var ( 58 var (
56 systemChangedSuMoney float64 59 systemChangedSuMoney float64
57 systemUnChangeSuMoney float64 60 systemUnChangeSuMoney float64
58 ) 61 )
59 - if value1, value2, err := employeeDao.CalculateSystemSuMoney(createCashPoolCommand.CompanyId); err != nil { 62 + if value1, value2, err := cashPoolDao.CalculateSystemSuMoney(createCashPoolCommand.CompanyId); err != nil {
60 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 63 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
61 } else { 64 } else {
62 systemChangedSuMoney = value1 65 systemChangedSuMoney = value1
63 systemUnChangeSuMoney = value2 66 systemUnChangeSuMoney = value2
64 } 67 }
65 68
66 - var inputCashPoolService service.InputCashPoolService 69 + newCashPool := &domain.CashPool{
  70 + CompanyId: createCashPoolCommand.CompanyId,
  71 + Cash: createCashPoolCommand.Cash,
  72 + ExchangedCash: systemExchangedCash,
  73 + UnExchangeCash: 0,
  74 + ExchangedSuMoney: systemChangedSuMoney,
  75 + UnExchangeSuMoney: systemUnChangeSuMoney,
  76 + Rate: 0,
  77 + CreateTime: time.Now(),
  78 + }
67 79
68 - if value, err := factory.CreateInputCashPoolService(map[string]interface{}{ 80 + var cashPoolRepository domain.CashPoolRepository
  81 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
69 "transactionContext": transactionContext, 82 "transactionContext": transactionContext,
70 }); err != nil { 83 }); err != nil {
71 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 84 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
72 } else { 85 } else {
73 - inputCashPoolService = value 86 + cashPoolRepository = value
74 } 87 }
75 88
76 - if task, err := inputCashPoolService.Input(createCashPoolCommand.CompanyId, createCashPoolCommand.Operator, createCashPoolCommand.Cash, systemChangedSuMoney, systemUnChangeSuMoney, systemExchangedCash); err != nil { 89 + if activity, err := cashPoolRepository.Save(newCashPool); err != nil {
77 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 90 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
78 } else { 91 } else {
79 if err := transactionContext.CommitTransaction(); err != nil { 92 if err := transactionContext.CommitTransaction(); err != nil {
80 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 93 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
81 } 94 }
82 - return task, nil 95 + return activity, nil
83 } 96 }
84 } 97 }
85 98
86 // 返回现金池 99 // 返回现金池
87 -func (cashPoolService *CashPoolService) CashPool(getCashPoolQuery *query.GetCashPoolQuery) (interface{}, error) { 100 +func (cashPoolService *CashPoolService) GetCashPool(getCashPoolQuery *query.GetCashPoolQuery) (interface{}, error) {
88 if err := getCashPoolQuery.ValidateQuery(); err != nil { 101 if err := getCashPoolQuery.ValidateQuery(); err != nil {
89 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 102 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
90 } 103 }
91 104
  105 + // 新建事务
92 transactionContext, err := factory.CreateTransactionContext(nil) 106 transactionContext, err := factory.CreateTransactionContext(nil)
93 -  
94 if err != nil { 107 if err != nil {
95 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 108 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
96 } 109 }
97 -  
98 if err := transactionContext.StartTransaction(); err != nil { 110 if err := transactionContext.StartTransaction(); err != nil {
99 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 111 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
100 } 112 }
101 -  
102 defer func() { 113 defer func() {
103 transactionContext.RollbackTransaction() 114 transactionContext.RollbackTransaction()
104 }() 115 }()
105 116
  117 + // 现金池资源库
106 var cashPoolRepository domain.CashPoolRepository 118 var cashPoolRepository domain.CashPoolRepository
107 if value, err := factory.CreateCashPoolRepository(map[string]interface{}{ 119 if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
108 "transactionContext": transactionContext, 120 "transactionContext": transactionContext,
@@ -111,274 +123,457 @@ func (cashPoolService *CashPoolService) CashPool(getCashPoolQuery *query.GetCash @@ -111,274 +123,457 @@ func (cashPoolService *CashPoolService) CashPool(getCashPoolQuery *query.GetCash
111 } else { 123 } else {
112 cashPoolRepository = value 124 cashPoolRepository = value
113 } 125 }
114 -  
115 - cashPool, err := cashPoolRepository.FindOne(map[string]interface{}{})  
116 -  
117 - if err != nil { 126 + if count, cashPools, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(getCashPoolQuery)); err != nil {
118 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 127 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
119 - }  
120 -  
121 - if cashPool == nil {  
122 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getCashPoolQuery.CompanyId)))  
123 } else { 128 } else {
124 - return cashPool, nil 129 + if err := transactionContext.CommitTransaction(); err != nil {
  130 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  131 + }
  132 + return map[string]interface{}{
  133 + "count": count,
  134 + "cashPools": cashPools,
  135 + }, nil
125 } 136 }
126 } 137 }
127 138
128 -// TODO 返回兑换现金活动  
129 -func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCashActivityQuery *query.ListExchangeCashActivityQuery) (interface{}, error) {  
130 - if err := listExchangeCashActivityQuery.ValidateQuery(); err != nil { 139 +// 新增兑换现金活动
  140 +func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchangeCashActivityCommand *command.CreateExchangeCashActivityCommand) (interface{}, error) {
  141 + // 校验新增任务命令
  142 + if err := createExchangeCashActivityCommand.ValidateCommand(); err != nil {
131 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 143 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
132 } 144 }
133 145
  146 + // 新建校验任务事务
134 transactionContext, err := factory.CreateTransactionContext(nil) 147 transactionContext, err := factory.CreateTransactionContext(nil)
135 -  
136 if err != nil { 148 if err != nil {
137 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 149 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
138 } 150 }
139 -  
140 if err := transactionContext.StartTransaction(); err != nil { 151 if err := transactionContext.StartTransaction(); err != nil {
141 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 152 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
142 } 153 }
143 -  
144 defer func() { 154 defer func() {
145 transactionContext.RollbackTransaction() 155 transactionContext.RollbackTransaction()
146 }() 156 }()
147 157
148 - return nil, nil  
149 -}  
150 -  
151 -// TODO 新增兑换现金活动  
152 -func (cashPoolService *CashPoolService) CreateExchangeCashActivity(createExchangeCashActivityCommand *command.CreateExchangeCashActivityCommand) (interface{}, error) {  
153 - if err := createExchangeCashActivityCommand.ValidateCommand(); err != nil {  
154 - return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 158 + // 创建兑换活动
  159 + newActivity := &domain.ExchangeCashActivity{
  160 + ExchangeActivityName: createExchangeCashActivityCommand.ExchangeActivityName,
  161 + CompanyId: createExchangeCashActivityCommand.CompanyId,
  162 + ExchangedCash: createExchangeCashActivityCommand.ExchangedCash,
  163 + ExchangedSuMoney: createExchangeCashActivityCommand.ExchangedSuMoney,
  164 + Deadline: createExchangeCashActivityCommand.Deadline,
  165 + CountDown: createExchangeCashActivityCommand.CountDown,
  166 + Rate: createExchangeCashActivityCommand.ExchangeRate,
155 } 167 }
156 168
157 - transactionContext, err := factory.CreateTransactionContext(nil)  
158 -  
159 - if err != nil {  
160 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 169 + // 兑换活动资源库
  170 + var exchangeCashActivityRepository domain.ExchangeActivityRepository
  171 + if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
  172 + "transactionContext": transactionContext,
  173 + }); err != nil {
  174 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  175 + } else {
  176 + exchangeCashActivityRepository = value
161 } 177 }
162 178
163 - if err := transactionContext.StartTransaction(); err != nil { 179 + if activity, err := exchangeCashActivityRepository.Save(newActivity); err != nil {
  180 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  181 + } else {
  182 + if err := transactionContext.CommitTransaction(); err != nil {
164 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 183 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
165 } 184 }
166 -  
167 - defer func() {  
168 - transactionContext.RollbackTransaction()  
169 - }()  
170 -  
171 - return nil, nil 185 + return activity, nil
  186 + }
172 } 187 }
173 188
174 -// TODO 返回兑换现金活动列表  
175 -func (cashPoolService *CashPoolService) ExchangeCashActivityList(listExchangeCashActivityQuery *query.ListExchangeCashActivityQuery) (interface{}, error) { 189 +// 返回兑换现金活动列表
  190 +func (cashPoolService *CashPoolService) ListExchangeCashActivity(listExchangeCashActivityQuery *query.ListExchangeCashActivityQuery) (interface{}, error) {
176 if err := listExchangeCashActivityQuery.ValidateQuery(); err != nil { 191 if err := listExchangeCashActivityQuery.ValidateQuery(); err != nil {
177 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 192 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
178 } 193 }
179 194
180 transactionContext, err := factory.CreateTransactionContext(nil) 195 transactionContext, err := factory.CreateTransactionContext(nil)
181 -  
182 if err != nil { 196 if err != nil {
183 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 197 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
184 } 198 }
185 -  
186 if err := transactionContext.StartTransaction(); err != nil { 199 if err := transactionContext.StartTransaction(); err != nil {
187 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 200 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
188 } 201 }
189 -  
190 defer func() { 202 defer func() {
191 transactionContext.RollbackTransaction() 203 transactionContext.RollbackTransaction()
192 }() 204 }()
193 205
194 - return nil, nil 206 + var cashPoolRepository domain.CashPoolRepository
  207 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
  208 + "transactionContext": transactionContext,
  209 + }); err != nil {
  210 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  211 + } else {
  212 + cashPoolRepository = value
  213 + }
  214 +
  215 + if count, activities, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(listExchangeCashActivityQuery)); err != nil {
  216 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  217 + } else {
  218 + if err := transactionContext.CommitTransaction(); err != nil {
  219 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  220 + }
  221 + return map[string]interface{}{
  222 + "count": count,
  223 + "activities": activities,
  224 + }, nil
  225 + }
195 } 226 }
196 227
197 -// TODO 移除兑换现金活动 228 +// 移除兑换现金活动
198 func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchangeCashActivityCommand *command.RemoveExchangeCashActivityCommand) (interface{}, error) { 229 func (cashPoolService *CashPoolService) RemoveExchangeCashActivity(removeExchangeCashActivityCommand *command.RemoveExchangeCashActivityCommand) (interface{}, error) {
199 if err := removeExchangeCashActivityCommand.ValidateCommand(); err != nil { 230 if err := removeExchangeCashActivityCommand.ValidateCommand(); err != nil {
200 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 231 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
201 } 232 }
202 233
203 transactionContext, err := factory.CreateTransactionContext(nil) 234 transactionContext, err := factory.CreateTransactionContext(nil)
204 -  
205 if err != nil { 235 if err != nil {
206 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 236 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
207 } 237 }
208 -  
209 if err := transactionContext.StartTransaction(); err != nil { 238 if err := transactionContext.StartTransaction(); err != nil {
210 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 239 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
211 } 240 }
212 -  
213 defer func() { 241 defer func() {
214 transactionContext.RollbackTransaction() 242 transactionContext.RollbackTransaction()
215 }() 243 }()
216 244
217 - return nil, nil 245 + var exchangeCashActivityRepository domain.ExchangeActivityRepository
  246 + if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
  247 + "transactionContext": transactionContext,
  248 + }); err != nil {
  249 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  250 + } else {
  251 + exchangeCashActivityRepository = value
  252 + }
  253 +
  254 + activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": removeExchangeCashActivityCommand.ExchangeCashActivityId})
  255 + if err != nil {
  256 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  257 + }
  258 + if activity == nil {
  259 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeExchangeCashActivityCommand.ExchangeCashActivityId)))
  260 + }
  261 +
  262 + if activityDeleted, err := exchangeCashActivityRepository.Remove(activity); err != nil {
  263 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  264 + } else {
  265 + if err := transactionContext.CommitTransaction(); err != nil {
  266 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  267 + }
  268 + return activityDeleted, nil
  269 + }
218 } 270 }
219 271
220 -// TODO 返回兑换现金活动 272 +// 返回兑换现金活动
221 func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashActivityQuery *query.GetExchangeCashActivityQuery) (interface{}, error) { 273 func (cashPoolService *CashPoolService) GetExchangeCashActivity(getExchangeCashActivityQuery *query.GetExchangeCashActivityQuery) (interface{}, error) {
222 if err := getExchangeCashActivityQuery.ValidateQuery(); err != nil { 274 if err := getExchangeCashActivityQuery.ValidateQuery(); err != nil {
223 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 275 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
224 } 276 }
225 277
226 transactionContext, err := factory.CreateTransactionContext(nil) 278 transactionContext, err := factory.CreateTransactionContext(nil)
227 -  
228 if err != nil { 279 if err != nil {
229 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 280 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
230 } 281 }
231 -  
232 if err := transactionContext.StartTransaction(); err != nil { 282 if err := transactionContext.StartTransaction(); err != nil {
233 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 283 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
234 } 284 }
235 -  
236 defer func() { 285 defer func() {
237 transactionContext.RollbackTransaction() 286 transactionContext.RollbackTransaction()
238 }() 287 }()
239 288
240 - return nil, nil 289 + var exchangeCashActivityRepository domain.ExchangeActivityRepository
  290 + if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
  291 + "transactionContext": transactionContext,
  292 + }); err != nil {
  293 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  294 + } else {
  295 + exchangeCashActivityRepository = value
  296 + }
  297 + activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": getExchangeCashActivityQuery.ExchangeCashActivityId})
  298 + if err != nil {
  299 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  300 + }
  301 + if activity == nil {
  302 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getExchangeCashActivityQuery.ExchangeCashActivityId)))
  303 + } else {
  304 + if err := transactionContext.CommitTransaction(); err != nil {
  305 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  306 + }
  307 + return activity, nil
  308 + }
241 } 309 }
242 310
243 -// TODO 更新兑换现金活动 311 +// 更新兑换现金活动
244 func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchangeCashActivityCommand *command.UpdateExchangeCashActivityCommand) (interface{}, error) { 312 func (cashPoolService *CashPoolService) UpdateExchangeCashActivity(updateExchangeCashActivityCommand *command.UpdateExchangeCashActivityCommand) (interface{}, error) {
245 if err := updateExchangeCashActivityCommand.ValidateCommand(); err != nil { 313 if err := updateExchangeCashActivityCommand.ValidateCommand(); err != nil {
246 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 314 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
247 } 315 }
248 316
249 transactionContext, err := factory.CreateTransactionContext(nil) 317 transactionContext, err := factory.CreateTransactionContext(nil)
250 -  
251 if err != nil { 318 if err != nil {
252 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 319 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
253 } 320 }
254 -  
255 if err := transactionContext.StartTransaction(); err != nil { 321 if err := transactionContext.StartTransaction(); err != nil {
256 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 322 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
257 } 323 }
258 -  
259 defer func() { 324 defer func() {
260 transactionContext.RollbackTransaction() 325 transactionContext.RollbackTransaction()
261 }() 326 }()
262 327
263 - return nil, nil 328 + var exchangeCashActivityRepository domain.ExchangeActivityRepository
  329 + if value, err := factory.CreateExchangeCashActivityRepository(map[string]interface{}{
  330 + "transactionContext": transactionContext,
  331 + }); err != nil {
  332 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  333 + } else {
  334 + exchangeCashActivityRepository = value
  335 + }
  336 +
  337 + activity, err := exchangeCashActivityRepository.FindOne(map[string]interface{}{"activityId": updateExchangeCashActivityCommand.ExchangeCashActivityId})
  338 + if err != nil {
  339 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  340 + }
  341 + if activity == nil {
  342 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId)))
  343 + }
  344 +
  345 + if activity == nil {
  346 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashActivityCommand.ExchangeCashActivityId)))
  347 + }
  348 +
  349 + if err := activity.Update(tool_funs.SimpleStructToMap(updateExchangeCashActivityCommand)); err != nil {
  350 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  351 + }
  352 +
  353 + if activityUpdated, err := exchangeCashActivityRepository.Save(activity); err != nil {
  354 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  355 + } else {
  356 + if err := transactionContext.CommitTransaction(); err != nil {
  357 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  358 + }
  359 + return activityUpdated, nil
  360 + }
264 } 361 }
265 362
266 -// TODO 新建兑换现金人员 363 +// 新建兑换现金人员
267 func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) { 364 func (cashPoolService *CashPoolService) CreateExchangeCashPerson(createExchangeCashPersonCommand *command.CreateExchangeCashPersonCommand) (interface{}, error) {
268 if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil { 365 if err := createExchangeCashPersonCommand.ValidateCommand(); err != nil {
269 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 366 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
270 } 367 }
271 368
272 transactionContext, err := factory.CreateTransactionContext(nil) 369 transactionContext, err := factory.CreateTransactionContext(nil)
273 -  
274 if err != nil { 370 if err != nil {
275 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 371 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
276 } 372 }
277 -  
278 if err := transactionContext.StartTransaction(); err != nil { 373 if err := transactionContext.StartTransaction(); err != nil {
279 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 374 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
280 } 375 }
281 -  
282 defer func() { 376 defer func() {
283 transactionContext.RollbackTransaction() 377 transactionContext.RollbackTransaction()
284 }() 378 }()
285 379
286 - return nil, nil 380 + // 创建兑换清单
  381 + newPerson := &domain.ExchangeCashPersonList{
  382 + CompanyId: createExchangeCashPersonCommand.ExchangeCashPerson.CompanyId,
  383 + ExchangeCashActivityId: createExchangeCashPersonCommand.ExchangeCashActivityId,
  384 + ExchangeCashPerson: createExchangeCashPersonCommand.ExchangeCashPerson,
  385 + ExchangedSuMoney: createExchangeCashPersonCommand.ExchangedSuMoney,
  386 + ExchangedCash: createExchangeCashPersonCommand.ExchangedCash,
  387 + }
  388 +
  389 + // 兑换活动资源库
  390 + var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
  391 + if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
  392 + "transactionContext": transactionContext,
  393 + }); err != nil {
  394 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  395 + } else {
  396 + exchangeCashPersonListRepository = value
  397 + }
  398 +
  399 + if person, err := exchangeCashPersonListRepository.Save(newPerson); err != nil {
  400 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  401 + } else {
  402 + if err := transactionContext.CommitTransaction(); err != nil {
  403 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  404 + }
  405 + return person, nil
  406 + }
287 } 407 }
288 408
289 -// TODO 返回兑换现金人员 409 +// 返回兑换现金人员
290 func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPersonQuery *query.GetExchangeCashPersonQuery) (interface{}, error) { 410 func (cashPoolService *CashPoolService) GetExchangeCashPerson(getExchangeCashPersonQuery *query.GetExchangeCashPersonQuery) (interface{}, error) {
291 if err := getExchangeCashPersonQuery.ValidateQuery(); err != nil { 411 if err := getExchangeCashPersonQuery.ValidateQuery(); err != nil {
292 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 412 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
293 } 413 }
294 414
295 transactionContext, err := factory.CreateTransactionContext(nil) 415 transactionContext, err := factory.CreateTransactionContext(nil)
296 -  
297 if err != nil { 416 if err != nil {
298 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 417 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
299 } 418 }
300 -  
301 if err := transactionContext.StartTransaction(); err != nil { 419 if err := transactionContext.StartTransaction(); err != nil {
302 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 420 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
303 } 421 }
304 -  
305 defer func() { 422 defer func() {
306 transactionContext.RollbackTransaction() 423 transactionContext.RollbackTransaction()
307 }() 424 }()
308 425
309 - return nil, nil 426 + var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
  427 + if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
  428 + "transactionContext": transactionContext,
  429 + }); err != nil {
  430 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  431 + } else {
  432 + exchangeCashPersonListRepository = value
  433 + }
  434 + person, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{"personId": getExchangeCashPersonQuery.ExchangeCashPersonId})
  435 + if err != nil {
  436 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  437 + }
  438 + if person == nil {
  439 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getExchangeCashPersonQuery.ExchangeCashPersonId)))
  440 + } else {
  441 + if err := transactionContext.CommitTransaction(); err != nil {
  442 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  443 + }
  444 + return person, nil
  445 + }
310 } 446 }
311 447
312 -// TODO 返回兑换现金人员列表 448 +// 返回兑换现金人员列表
313 func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashPersonQuery *query.ListExchangeCashPersonQuery) (interface{}, error) { 449 func (cashPoolService *CashPoolService) ListExchangeCashPerson(listExchangeCashPersonQuery *query.ListExchangeCashPersonQuery) (interface{}, error) {
314 if err := listExchangeCashPersonQuery.ValidateQuery(); err != nil { 450 if err := listExchangeCashPersonQuery.ValidateQuery(); err != nil {
315 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 451 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
316 } 452 }
317 453
318 transactionContext, err := factory.CreateTransactionContext(nil) 454 transactionContext, err := factory.CreateTransactionContext(nil)
319 -  
320 if err != nil { 455 if err != nil {
321 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 456 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
322 } 457 }
323 -  
324 if err := transactionContext.StartTransaction(); err != nil { 458 if err := transactionContext.StartTransaction(); err != nil {
325 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 459 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
326 } 460 }
327 -  
328 defer func() { 461 defer func() {
329 transactionContext.RollbackTransaction() 462 transactionContext.RollbackTransaction()
330 }() 463 }()
331 464
332 - return nil, nil 465 + var cashPoolRepository domain.CashPoolRepository
  466 + if value, err := factory.CreateCashPoolRepository(map[string]interface{}{
  467 + "transactionContext": transactionContext,
  468 + }); err != nil {
  469 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  470 + } else {
  471 + cashPoolRepository = value
  472 + }
  473 +
  474 + if count, people, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(listExchangeCashPersonQuery)); err != nil {
  475 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  476 + } else {
  477 + if err := transactionContext.CommitTransaction(); err != nil {
  478 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  479 + }
  480 + return map[string]interface{}{
  481 + "count": count,
  482 + "people": people,
  483 + }, nil
  484 + }
333 } 485 }
334 486
335 -// TODO 移除兑换现金人员 487 +// 移除兑换现金人员
336 func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeCashPersonCommand *command.RemoveExchangeCashPersonCommand) (interface{}, error) { 488 func (cashPoolService *CashPoolService) RemoveExchangeCashPerson(removeExchangeCashPersonCommand *command.RemoveExchangeCashPersonCommand) (interface{}, error) {
337 if err := removeExchangeCashPersonCommand.ValidateCommand(); err != nil { 489 if err := removeExchangeCashPersonCommand.ValidateCommand(); err != nil {
338 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 490 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
339 } 491 }
340 492
341 transactionContext, err := factory.CreateTransactionContext(nil) 493 transactionContext, err := factory.CreateTransactionContext(nil)
342 -  
343 if err != nil { 494 if err != nil {
344 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 495 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
345 } 496 }
346 -  
347 if err := transactionContext.StartTransaction(); err != nil { 497 if err := transactionContext.StartTransaction(); err != nil {
348 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 498 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
349 } 499 }
350 -  
351 defer func() { 500 defer func() {
352 transactionContext.RollbackTransaction() 501 transactionContext.RollbackTransaction()
353 }() 502 }()
354 503
355 - return nil, nil 504 + var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
  505 + if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
  506 + "transactionContext": transactionContext,
  507 + }); err != nil {
  508 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  509 + } else {
  510 + exchangeCashPersonListRepository = value
  511 + }
  512 +
  513 + person, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{"personId": removeExchangeCashPersonCommand.ExchangeCashPersonId})
  514 + if err != nil {
  515 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  516 + }
  517 + if person == nil {
  518 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeExchangeCashPersonCommand.ExchangeCashPersonId)))
  519 + }
  520 +
  521 + if personDeleted, err := exchangeCashPersonListRepository.Remove(person); err != nil {
  522 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  523 + } else {
  524 + if err := transactionContext.CommitTransaction(); err != nil {
  525 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  526 + }
  527 + return personDeleted, nil
  528 + }
356 } 529 }
357 530
358 -// TODO 更新兑换现金人员  
359 -func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeCashCommand *command.UpdateExchangeCashPersonCommand) (interface{}, error) {  
360 - if err := updateExchangeCashCommand.ValidateCommand(); err != nil { 531 +// 更新兑换现金人员
  532 +func (cashPoolService *CashPoolService) UpdateExchangeCashPerson(updateExchangeCashPersonCommand *command.UpdateExchangeCashPersonCommand) (interface{}, error) {
  533 + if err := updateExchangeCashPersonCommand.ValidateCommand(); err != nil {
361 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 534 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
362 } 535 }
363 536
364 transactionContext, err := factory.CreateTransactionContext(nil) 537 transactionContext, err := factory.CreateTransactionContext(nil)
365 -  
366 if err != nil { 538 if err != nil {
367 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 539 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
368 } 540 }
369 -  
370 if err := transactionContext.StartTransaction(); err != nil { 541 if err := transactionContext.StartTransaction(); err != nil {
371 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 542 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
372 } 543 }
373 -  
374 defer func() { 544 defer func() {
375 transactionContext.RollbackTransaction() 545 transactionContext.RollbackTransaction()
376 }() 546 }()
377 547
378 // TODO 新增流水记录 548 // TODO 新增流水记录
379 549
  550 + var exchangeCashPersonListRepository domain.ExchangeCashPersonListRepository
  551 + if value, err := factory.CreateExchangeCashPersonListRepository(map[string]interface{}{
  552 + "transactionContext": transactionContext,
  553 + }); err != nil {
  554 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  555 + } else {
  556 + exchangeCashPersonListRepository = value
  557 + }
380 558
381 - return nil, nil 559 + person, err := exchangeCashPersonListRepository.FindOne(map[string]interface{}{"personId": updateExchangeCashPersonCommand.ExchangeCashPersonId})
  560 + if err != nil {
  561 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  562 + }
  563 + if person == nil {
  564 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateExchangeCashPersonCommand.ExchangeCashPersonId)))
  565 + }
  566 + if err := person.Update(tool_funs.SimpleStructToMap(updateExchangeCashPersonCommand)); err != nil {
  567 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  568 + }
  569 + if personUpdated, err := exchangeCashPersonListRepository.Save(person); err != nil {
  570 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  571 + } else {
  572 + if err := transactionContext.CommitTransaction(); err != nil {
  573 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  574 + }
  575 + return personUpdated, nil
  576 + }
382 } 577 }
383 578
384 func NewCashPoolService(options map[string]interface{}) *CashPoolService { 579 func NewCashPoolService(options map[string]interface{}) *CashPoolService {
@@ -774,9 +774,12 @@ func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *qu @@ -774,9 +774,12 @@ func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *qu
774 774
775 // 创建新任务 775 // 创建新任务
776 func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTaskCommand) (interface{}, error) { 776 func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTaskCommand) (interface{}, error) {
  777 + // 校验创建任务命令
777 if err := createTaskCommand.ValidateCommand(); err != nil { 778 if err := createTaskCommand.ValidateCommand(); err != nil {
778 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 779 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
779 } 780 }
  781 +
  782 + // 新建事务
780 transactionContext, err := factory.CreateTransactionContext(nil) 783 transactionContext, err := factory.CreateTransactionContext(nil)
781 if err != nil { 784 if err != nil {
782 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 785 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
@@ -787,6 +790,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -787,6 +790,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
787 defer func() { 790 defer func() {
788 transactionContext.RollbackTransaction() 791 transactionContext.RollbackTransaction()
789 }() 792 }()
  793 +
  794 + // 新建任务数据访问对象
790 var taskDao *dao.TaskDao 795 var taskDao *dao.TaskDao
791 if value, err := factory.CreateTaskDao(map[string]interface{}{ 796 if value, err := factory.CreateTaskDao(map[string]interface{}{
792 "transactionContext": transactionContext, 797 "transactionContext": transactionContext,
@@ -795,6 +800,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -795,6 +800,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
795 } else { 800 } else {
796 taskDao = value 801 taskDao = value
797 } 802 }
  803 +
  804 + // 获取任务发布者信息
798 var employeeRepository domain.EmployeeRepository 805 var employeeRepository domain.EmployeeRepository
799 if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ 806 if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
800 "transactionContext": transactionContext, 807 "transactionContext": transactionContext,
@@ -803,6 +810,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -803,6 +810,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
803 } else { 810 } else {
804 employeeRepository = value 811 employeeRepository = value
805 } 812 }
  813 +
806 sponsor, err := employeeRepository.FindOne(map[string]interface{}{ 814 sponsor, err := employeeRepository.FindOne(map[string]interface{}{
807 "uid": createTaskCommand.Sponsor, 815 "uid": createTaskCommand.Sponsor,
808 }) 816 })
@@ -812,6 +820,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -812,6 +820,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
812 if sponsor == nil { 820 if sponsor == nil {
813 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者") 821 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者")
814 } 822 }
  823 +
  824 + // 获取任务指派人
815 var assignedPerson *domain.EmployeeInfo 825 var assignedPerson *domain.EmployeeInfo
816 if createTaskCommand.AssignedPerson != 0 { 826 if createTaskCommand.AssignedPerson != 0 {
817 employee, err := employeeRepository.FindOne(map[string]interface{}{ 827 employee, err := employeeRepository.FindOne(map[string]interface{}{
@@ -825,6 +835,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -825,6 +835,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
825 } 835 }
826 assignedPerson = employee.EmployeeInfo 836 assignedPerson = employee.EmployeeInfo
827 } 837 }
  838 +
  839 + // 创建新任务
828 newTask := &domain.Task{ 840 newTask := &domain.Task{
829 TaskStatus: domain.TASK_STATUS_UNRELEASED, 841 TaskStatus: domain.TASK_STATUS_UNRELEASED,
830 CompanyId: createTaskCommand.CompanyId, 842 CompanyId: createTaskCommand.CompanyId,
@@ -847,6 +859,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask @@ -847,6 +859,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
847 PlannedCompletionTime: createTaskCommand.PlannedCompletionTime, 859 PlannedCompletionTime: createTaskCommand.PlannedCompletionTime,
848 CreateTime: time.Now(), 860 CreateTime: time.Now(),
849 } 861 }
  862 +
850 var taskRepository domain.TaskRepository 863 var taskRepository domain.TaskRepository
851 if value, err := factory.CreateTaskRepository(map[string]interface{}{ 864 if value, err := factory.CreateTaskRepository(map[string]interface{}{
852 "transactionContext": transactionContext, 865 "transactionContext": transactionContext,
@@ -6,25 +6,25 @@ import "time" @@ -6,25 +6,25 @@ import "time"
6 type CashPool struct { 6 type CashPool struct {
7 CashPoolId int64 `json:"cashPoolId"` // 现金池id 7 CashPoolId int64 `json:"cashPoolId"` // 现金池id
8 CompanyId int64 `json:"companyId"` // 公司id 8 CompanyId int64 `json:"companyId"` // 公司id
9 - Cash float64 `json:"cashPool"` // 投入现金池的现金 9 + Cash float64 `json:"cash"` // 投入现金池的现金
10 ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金 10 ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
11 UnExchangeCash float64 `json:"unExchangeCash"` // 未兑换的现金 11 UnExchangeCash float64 `json:"unExchangeCash"` // 未兑换的现金
12 ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币 12 ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币
13 UnExchangeSuMoney float64 `json:"unExchangeSuMoney"` // 未兑换的素币 13 UnExchangeSuMoney float64 `json:"unExchangeSuMoney"` // 未兑换的素币
14 - Operator *EmployeeInfo `json:"operator"` // 操作人 14 + //Operator *EmployeeInfo `json:"operator"` // 操作人
15 Rate float64 `json:"rate"` // 平均兑换汇率 15 Rate float64 `json:"rate"` // 平均兑换汇率
16 CreateTime time.Time `json:"createTime"` // 现金投入现金池时间 16 CreateTime time.Time `json:"createTime"` // 现金投入现金池时间
17 } 17 }
18 18
19 type CashPoolRepository interface { 19 type CashPoolRepository interface {
20 Save(cashPool *CashPool) (*CashPool, error) 20 Save(cashPool *CashPool) (*CashPool, error)
21 - FindOne(queryOptions map[string]interface{}) (*CashPool, error) 21 + Find(queryOptions map[string]interface{}) (int64, []*CashPool, error)
22 } 22 }
23 23
24 func (cashPool *CashPool) Identity() interface{} { 24 func (cashPool *CashPool) Identity() interface{} {
25 - if cashPool.CompanyId == 0 { 25 + if cashPool.CashPoolId == 0 {
26 return nil 26 return nil
27 } 27 }
28 - return cashPool.CompanyId 28 + return cashPool.CashPoolId
29 } 29 }
30 30
@@ -4,18 +4,18 @@ import "time" @@ -4,18 +4,18 @@ import "time"
4 4
5 // 兑换现金活动 5 // 兑换现金活动
6 type ExchangeCashActivity struct { 6 type ExchangeCashActivity struct {
7 - ExchangeCashActivityId int64 `json:"exchangeActivityId"` // 兑换现金活动id 7 + ActivityId int64 `json:"activityId"` // 兑换现金活动id
8 ExchangeActivityName string `json:"exchangeActivityName"` // 兑换现金活动名称 8 ExchangeActivityName string `json:"exchangeActivityName"` // 兑换现金活动名称
9 CompanyId int64 `json:"companyId"` // 公司ID 9 CompanyId int64 `json:"companyId"` // 公司ID
10 ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金 10 ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
11 ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币 11 ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币
12 CreateTime time.Time `json:"createTime"` // 创建兑换现金活动时间 12 CreateTime time.Time `json:"createTime"` // 创建兑换现金活动时间
13 Deadline time.Time `json:"deadline"` // 兑换现金活动截止时间 13 Deadline time.Time `json:"deadline"` // 兑换现金活动截止时间
14 - CountDown string `json:"countDown"` // 兑换现金活动结束倒计时 14 + CountDown int64 `json:"countDown"` // 兑换现金活动结束倒计时
15 Rate float64 `json:"rate"` // 兑换汇率 15 Rate float64 `json:"rate"` // 兑换汇率
16 - LastRate float64 `json:"lastRate"` // 上期兑换汇率  
17 - Operator *EmployeeInfo `json:"operator"` // 活动发布人  
18 - ExchangeCashPeople []*ExchangeCashPersonList `json:"exchangeCashPeople"` // 兑换现金人员清单 16 + //LastRate float64 `json:"lastRate"` // 上期兑换汇率
  17 + //Operator *EmployeeInfo `json:"operator"` // 活动发布人
  18 + //ExchangeCashPeople []*ExchangeCashPersonList `json:"exchangeCashPeople"` // 兑换现金人员清单
19 } 19 }
20 20
21 type ExchangeActivityRepository interface { 21 type ExchangeActivityRepository interface {
@@ -26,23 +26,29 @@ type ExchangeActivityRepository interface { @@ -26,23 +26,29 @@ type ExchangeActivityRepository interface {
26 } 26 }
27 27
28 func (exchangeCashActivity *ExchangeCashActivity) Identity() interface{} { 28 func (exchangeCashActivity *ExchangeCashActivity) Identity() interface{} {
29 - if exchangeCashActivity.ExchangeCashActivityId == 0 { 29 + if exchangeCashActivity.ActivityId == 0 {
30 return nil 30 return nil
31 } 31 }
32 - return exchangeCashActivity.ExchangeCashActivityId 32 + return exchangeCashActivity.ActivityId
33 } 33 }
34 34
35 -func (exchangeCashActivity *ExchangeCashActivity) TransferSuMoney(rate float64) error {  
36 - exchangeCashActivity.ExchangedSuMoney = exchangeCashActivity.ExchangedCash * rate 35 +// TODO
  36 +func (exchangeCashActivity *ExchangeCashActivity) Update(data map[string]interface{}) error {
  37 +
37 return nil 38 return nil
38 } 39 }
39 40
40 -func (exchangeCashActivity *ExchangeCashActivity) TransferLastRate(lastRate float64) error {  
41 - exchangeCashActivity.LastRate = lastRate 41 +func (exchangeCashActivity *ExchangeCashActivity) TransferSuMoney(rate float64) error {
  42 + exchangeCashActivity.ExchangedSuMoney = exchangeCashActivity.ExchangedCash * rate
42 return nil 43 return nil
43 } 44 }
44 45
  46 +//func (exchangeCashActivity *ExchangeCashActivity) TransferLastRate(lastRate float64) error {
  47 +// exchangeCashActivity.LastRate = lastRate
  48 +// return nil
  49 +//}
  50 +
45 func (exchangeCashActivity *ExchangeCashActivity) TransferCountDown() error { 51 func (exchangeCashActivity *ExchangeCashActivity) TransferCountDown() error {
46 - exchangeCashActivity.CountDown = string(time.Until(exchangeCashActivity.Deadline)) 52 + exchangeCashActivity.CountDown = int64(time.Until(exchangeCashActivity.Deadline))
47 return nil 53 return nil
48 } 54 }
@@ -23,3 +23,9 @@ func (exchangeCashPersonList *ExchangeCashPersonList) Identity() interface{} { @@ -23,3 +23,9 @@ func (exchangeCashPersonList *ExchangeCashPersonList) Identity() interface{} {
23 } 23 }
24 return exchangeCashPersonList.ExchangeCashPersonListId 24 return exchangeCashPersonList.ExchangeCashPersonListId
25 } 25 }
  26 +
  27 +// TODO
  28 +func (exchangeCashPersonList *ExchangeCashPersonList) Update(data map[string]interface{}) error {
  29 +
  30 + return nil
  31 +}
1 -package service  
2 -  
3 -import (  
4 - coreDomain "github.com/linmadan/egglib-go/core/domain"  
5 - "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"  
6 -)  
7 -  
8 -type InputCashPoolService interface {  
9 - coreDomain.DomainEventPublisher  
10 - Input(companyId int64, operatorUid int64, cash float64, exchangedSuMoney float64, unExchangeSuMoney float64, exchangedCash float64) (*domain.CashPool, error)  
11 -}  
  1 +package dao
  2 +
  3 +import (
  4 + "fmt"
  5 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  6 + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
  7 +)
  8 +
  9 +type CashPoolDao struct {
  10 + transactionContext *pgTransaction.TransactionContext
  11 +}
  12 +
  13 +// 计算系统素币
  14 +func (dao *CashPoolDao) CalculateSystemSuMoney(companyId int64) ( float64, float64, error) {
  15 + var systemUnExchangeSuMoney float64
  16 + var systemExchangedSuMoney float64
  17 +
  18 + tx := dao.transactionContext.PgTx
  19 +
  20 + employeeModel := new(models.Employee)
  21 + if err := tx.Model(employeeModel).
  22 + ColumnExpr("sum(employee.su_money) AS system_unExchange_su_money").
  23 + Where("employee.company_id = ?", companyId).
  24 + Select(&systemUnExchangeSuMoney); err != nil {
  25 + return 0, 0, err
  26 + }
  27 +
  28 + exchangeCashActivityModel := new(models.ExchangeCashActivity)
  29 + if err := tx.Model(exchangeCashActivityModel).
  30 + ColumnExpr("sum(exchange_cash_activity.exchanged_su_money) AS system_changed_su_money").
  31 + Where("exchange_cash_activity.company_id = ?", companyId).
  32 + Select(&systemExchangedSuMoney); err != nil {
  33 + return 0, 0, err
  34 + }
  35 +
  36 + return systemUnExchangeSuMoney, systemExchangedSuMoney, nil
  37 +}
  38 +
  39 +// 计算系统已兑换现金
  40 +func (dao *CashPoolDao) CalculateSystemCash(companyId int64) (float64, error) {
  41 + var systemExchangedCash float64 // 系统已兑换现金
  42 +
  43 + tx := dao.transactionContext.PgTx
  44 + exchangeCashActivityModel := new(models.ExchangeCashActivity)
  45 +
  46 + if err := tx.Model(exchangeCashActivityModel).
  47 + ColumnExpr("sum(exchange_cash_activity.exchanged_cash) AS system_exchanged_cash").
  48 + Where("exchange_cash_activity.company_id = ?", companyId).
  49 + Select(&systemExchangedCash) ; err != nil {
  50 + return 0, err
  51 + }
  52 +
  53 + return systemExchangedCash, nil
  54 +}
  55 +
  56 +func NewCashPoolDao(transactionContext *pgTransaction.TransactionContext) (*CashPoolDao, error) {
  57 + if transactionContext == nil {
  58 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  59 + } else {
  60 + return &CashPoolDao{
  61 + transactionContext: transactionContext,
  62 + }, nil
  63 + }
  64 +}
@@ -143,49 +143,6 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction @@ -143,49 +143,6 @@ func (dao *EmployeeDao) CalculateSuMoneyTransactionRecord(uid int64, transaction
143 }, nil 143 }, nil
144 } 144 }
145 145
146 -// 计算系统素币  
147 -func (dao *EmployeeDao) CalculateSystemSuMoney(companyId int64) ( float64, float64, error) {  
148 - var systemUnExchangeSuMoney float64  
149 - var systemExchangedSuMoney float64  
150 -  
151 - tx := dao.transactionContext.PgTx  
152 -  
153 - employeeModel := new(models.Employee)  
154 - if err := tx.Model(employeeModel).  
155 - ColumnExpr("sum(employee.su_money) AS system_unExchange_su_money").  
156 - Where("employee.company_id = ?", companyId).  
157 - Select(&systemUnExchangeSuMoney); err != nil {  
158 - return 0, 0, err  
159 - }  
160 -  
161 - exchangeCashActivityModel := new(models.ExchangeCashActivity)  
162 - if err := tx.Model(exchangeCashActivityModel).  
163 - ColumnExpr("sum(exchange_cash_activity.exchanged_su_money) AS system_changed_su_money").  
164 - Where("exchange_cash_activity.company_id = ?", companyId).  
165 - Select(&systemExchangedSuMoney); err != nil {  
166 - return 0, 0, err  
167 - }  
168 -  
169 - return systemUnExchangeSuMoney, systemExchangedSuMoney, nil  
170 -}  
171 -  
172 -// 计算系统已兑换现金  
173 -func (dao *EmployeeDao) CalculateSystemCash(companyId int64) (float64, error) {  
174 - var systemExchangedCash float64 // 系统已兑换现金  
175 -  
176 - tx := dao.transactionContext.PgTx  
177 - exchangeCashActivityModel := new(models.ExchangeCashActivity)  
178 -  
179 - if err := tx.Model(exchangeCashActivityModel).  
180 - ColumnExpr("sum(exchange_cash_activity.exchanged_cash) AS system_exchanged_cash").  
181 - Where("exchange_cash_activity.company_id = ?", companyId).  
182 - Select(&systemExchangedCash) ; err != nil {  
183 - return 0, err  
184 - }  
185 -  
186 - return systemExchangedCash, nil  
187 -}  
188 -  
189 func NewEmployeeDao(transactionContext *pgTransaction.TransactionContext) (*EmployeeDao, error) { 146 func NewEmployeeDao(transactionContext *pgTransaction.TransactionContext) (*EmployeeDao, error) {
190 if transactionContext == nil { 147 if transactionContext == nil {
191 return nil, fmt.Errorf("transactionContext参数不能为nil") 148 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"  
8 - "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/repository"  
9 - "time"  
10 -)  
11 -  
12 -type CashPoolService struct {  
13 - coreDomain.BaseEventPublisher  
14 - transactionContext *pgTransaction.TransactionContext  
15 -}  
16 -  
17 -func (service *CashPoolService) Input(companyId int64, operatorUid int64, cash float64, systemUnExchangeSuMoney float64, systemExchangedSuMoney float64, systemExchangedCash float64) (*domain.CashPool, error) {  
18 - var cashPoolRepository domain.CashPoolRepository  
19 - var employeeRepository domain.EmployeeRepository  
20 -  
21 - if repository, err := repository.NewEmployeeRepository(service.transactionContext); err != nil {  
22 - return nil, err  
23 - } else {  
24 - employeeRepository = repository  
25 - }  
26 -  
27 - operator, err := employeeRepository.FindOne(map[string]interface{}{  
28 - "uid": operatorUid,  
29 - })  
30 - if err != nil {  
31 - return nil, err  
32 - }  
33 - if operator == nil {  
34 - return nil, fmt.Errorf("无效的操作者")  
35 - }  
36 -  
37 - currentCashPool, err := cashPoolRepository.FindOne(map[string]interface{}{  
38 - "companyId": companyId,  
39 - })  
40 - if err != nil {  
41 - return nil, err  
42 - }  
43 - if currentCashPool.ExchangedCash > cash {  
44 - return nil, fmt.Errorf("当前投入现金少于系统已兑换现金值")  
45 - }  
46 -  
47 - cashPoolInfo := &domain.CashPool{  
48 - CompanyId: companyId,  
49 - Cash: cash,  
50 - ExchangedCash: systemExchangedCash,  
51 - UnExchangeCash: currentCashPool.UnExchangeCash + cash,  
52 - ExchangedSuMoney: systemExchangedSuMoney,  
53 - UnExchangeSuMoney: systemUnExchangeSuMoney,  
54 - Rate: systemExchangedCash / systemExchangedSuMoney,  
55 - Operator: operator.EmployeeInfo,  
56 - CreateTime: time.Now(),  
57 - }  
58 -  
59 - if cashPool, err := cashPoolRepository.Save(cashPoolInfo); err != nil {  
60 - return nil, err  
61 - } else {  
62 - return cashPool, nil  
63 - }  
64 -}  
65 -  
66 -func NewCashPoolService(transactionContext *pgTransaction.TransactionContext) (*CashPoolService, error) {  
67 - if transactionContext == nil {  
68 - return nil, fmt.Errorf("transactionContext参数不能为nil")  
69 - } else {  
70 - return &CashPoolService{  
71 - transactionContext: transactionContext,  
72 - }, nil  
73 - }  
74 -}  
@@ -3,6 +3,7 @@ package models @@ -3,6 +3,7 @@ package models
3 type CashPool struct { 3 type CashPool struct {
4 TableName string `pg:"cash_pools,alias:cash_pool"` 4 TableName string `pg:"cash_pools,alias:cash_pool"`
5 Id int64 `pg:",pk"` // 现金池id 5 Id int64 `pg:",pk"` // 现金池id
  6 + Cash float64 // 投入的现金
6 CompanyId int64 // 公司id 7 CompanyId int64 // 公司id
7 ExchangedCash float64 // 系统已兑换现金 8 ExchangedCash float64 // 系统已兑换现金
8 UnExchangeCash float64 // 系统未兑换现金 9 UnExchangeCash float64 // 系统未兑换现金
1 package models 1 package models
2 2
3 import ( 3 import (
4 - "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"  
5 "time" 4 "time"
6 ) 5 )
7 6
@@ -11,12 +10,12 @@ type ExchangeCashActivity struct { @@ -11,12 +10,12 @@ type ExchangeCashActivity struct {
11 CompanyId int64 // 公司ID 10 CompanyId int64 // 公司ID
12 ActivityName string // 兑换活动名称 11 ActivityName string // 兑换活动名称
13 Deadline time.Time // 兑换活动结束时间 12 Deadline time.Time // 兑换活动结束时间
14 - CountDown string // 兑换活动结束倒计时 13 + CountDown int64 // 兑换活动结束倒计时
15 ExchangedCash float64 // 已兑换现金 14 ExchangedCash float64 // 已兑换现金
16 ExchangedSuMoney float64 // 已兑换素币 15 ExchangedSuMoney float64 // 已兑换素币
17 ExchangeRate float64 // 兑换汇率 16 ExchangeRate float64 // 兑换汇率
18 - LastExchangeRate float64 // 上期活动兑换汇率  
19 - ExchangeSuMoneyList []*domain.ExchangeCashPersonList `pg:",array"` // 素币兑换人员清单  
20 - Sponsor *domain.EmployeeInfo // 活动发布人 17 + //LastExchangeRate float64 // 上期活动兑换汇率
  18 + //ExchangeSuMoneyList []*domain.ExchangeCashPersonList `pg:",array"` // 素币兑换人员清单
  19 + //Sponsor *domain.EmployeeInfo // 活动发布人
21 CreateTime time.Time // 创建时间 20 CreateTime time.Time // 创建时间
22 } 21 }
@@ -17,14 +17,14 @@ func (repository *CashPoolRepository) Save(cashPool *domain.CashPool) (*domain.C @@ -17,14 +17,14 @@ func (repository *CashPoolRepository) Save(cashPool *domain.CashPool) (*domain.C
17 if cashPool.Identity() == nil { 17 if cashPool.Identity() == nil {
18 if _, err := tx.QueryOne( 18 if _, err := tx.QueryOne(
19 pg.Scan(&cashPool.CashPoolId, &cashPool.Cash, &cashPool.CompanyId, &cashPool.ExchangedCash, &cashPool.UnExchangeCash, &cashPool.ExchangedSuMoney, &cashPool.UnExchangeSuMoney, &cashPool.Rate), 19 pg.Scan(&cashPool.CashPoolId, &cashPool.Cash, &cashPool.CompanyId, &cashPool.ExchangedCash, &cashPool.UnExchangeCash, &cashPool.ExchangedSuMoney, &cashPool.UnExchangeSuMoney, &cashPool.Rate),
20 - "INSERT INTO cash_pool (cash, company_id, exchanged_cash, unExchange_cash, exchanged_su_money, unExchange_su_money, rate) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, exchanged_cash, unExchange_cash, exchanged_su_money, unExchange_su_money", 20 + "INSERT INTO cash_pools (cash, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate) VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING id, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate",
21 cashPool.Cash, cashPool.CompanyId, cashPool.ExchangedCash, cashPool.UnExchangeCash, cashPool.ExchangedSuMoney, cashPool.UnExchangeSuMoney, cashPool.Rate); err != nil { 21 cashPool.Cash, cashPool.CompanyId, cashPool.ExchangedCash, cashPool.UnExchangeCash, cashPool.ExchangedSuMoney, cashPool.UnExchangeSuMoney, cashPool.Rate); err != nil {
22 return cashPool, err 22 return cashPool, err
23 } 23 }
24 } else { 24 } else {
25 if _, err := tx.QueryOne( 25 if _, err := tx.QueryOne(
26 pg.Scan(&cashPool.CashPoolId, &cashPool.Cash, &cashPool.CompanyId, &cashPool.ExchangedCash, &cashPool.UnExchangeCash, &cashPool.ExchangedSuMoney, &cashPool.UnExchangeSuMoney, &cashPool.Rate), 26 pg.Scan(&cashPool.CashPoolId, &cashPool.Cash, &cashPool.CompanyId, &cashPool.ExchangedCash, &cashPool.UnExchangeCash, &cashPool.ExchangedSuMoney, &cashPool.UnExchangeSuMoney, &cashPool.Rate),
27 - "UPDATE cash_pool SET cash=?, company_id=? exchanged_cash, unExchange_cash, exchanged_su_money, unExchange_su_money, rate WHERE company_id=? RETURNING id, company_id, exchanged_cash, unExchange_cash, exchanged_su_money, unExchange_su_money, rate", 27 + "UPDATE cash_pools SET cash=?, company_id=? exchanged_cash=?, un_exchange_cash=?, exchanged_su_money=?, un_exchange_su_money=?, rate=? WHERE company_id=? RETURNING id, company_id, exchanged_cash, un_exchange_cash, exchanged_su_money, un_exchange_su_money, rate",
28 cashPool.Cash, cashPool.CompanyId, cashPool.ExchangedCash, cashPool.UnExchangeCash, cashPool.ExchangedSuMoney, cashPool.UnExchangeSuMoney, cashPool.Rate, cashPool.Identity()); err != nil { 28 cashPool.Cash, cashPool.CompanyId, cashPool.ExchangedCash, cashPool.UnExchangeCash, cashPool.ExchangedSuMoney, cashPool.UnExchangeSuMoney, cashPool.Rate, cashPool.Identity()); err != nil {
29 return cashPool, err 29 return cashPool, err
30 } 30 }
@@ -32,25 +32,42 @@ func (repository *CashPoolRepository) Save(cashPool *domain.CashPool) (*domain.C @@ -32,25 +32,42 @@ func (repository *CashPoolRepository) Save(cashPool *domain.CashPool) (*domain.C
32 return cashPool, nil 32 return cashPool, nil
33 } 33 }
34 34
35 -func (repository *CashPoolRepository) FindOne(queryOptions map[string]interface{}) (*domain.CashPool, error) { 35 +func (repository *CashPoolRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.CashPool, error) {
36 tx := repository.transactionContext.PgTx 36 tx := repository.transactionContext.PgTx
37 - cashPoolModel := new(models.CashPool)  
38 - query := tx.Model(cashPoolModel) 37 + var cashPoolModels []*models.CashPool
  38 + cashPools := make([]*domain.CashPool, 0)
  39 + query := tx.Model(&cashPoolModels)
39 // 根据公司id查找现金池 40 // 根据公司id查找现金池
40 if companyId, ok := queryOptions["companyId"]; ok { 41 if companyId, ok := queryOptions["companyId"]; ok {
41 - query = query.Where("cash_pool.company_id = ?", companyId) 42 + query = query.Where("cash_pools.company_id = ?", companyId)
  43 + }
  44 + if offset, ok := queryOptions["offset"]; ok {
  45 + offset := offset.(int)
  46 + if offset > -1 {
  47 + query = query.Offset(offset)
42 } 48 }
43 - if err := query.First(); err != nil {  
44 - if err.Error() == "pg: no rows in result set" {  
45 - return nil, fmt.Errorf("没有此资源")  
46 } else { 49 } else {
47 - return nil, err 50 + query = query.Offset(0)
  51 + }
  52 + if limit, ok := queryOptions["limit"]; ok {
  53 + limit := limit.(int)
  54 + if limit > -1 {
  55 + query = query.Limit(limit)
48 } 56 }
  57 + } else {
  58 + query = query.Limit(20)
49 } 59 }
50 - if cashPoolModel.CompanyId == 0 {  
51 - return nil, nil 60 + if count, err := query.Order("id DESC").SelectAndCount(); err != nil {
  61 + return 0, cashPools, err
52 } else { 62 } else {
53 - return repository.transformPgModelToDomainModel(cashPoolModel) 63 + for _, cashPoolModel := range cashPoolModels {
  64 + if cashPool, err := repository.transformPgModelToDomainModel(cashPoolModel); err != nil {
  65 + return 0, cashPools, err
  66 + } else {
  67 + cashPools = append(cashPools, cashPool)
  68 + }
  69 + }
  70 + return int64(count), cashPools, nil
54 } 71 }
55 } 72 }
56 73
@@ -58,6 +75,12 @@ func (repository *CashPoolRepository) transformPgModelToDomainModel(cashPoolMode @@ -58,6 +75,12 @@ func (repository *CashPoolRepository) transformPgModelToDomainModel(cashPoolMode
58 return &domain.CashPool{ 75 return &domain.CashPool{
59 CashPoolId: cashPoolModel.Id, 76 CashPoolId: cashPoolModel.Id,
60 CompanyId: cashPoolModel.CompanyId, 77 CompanyId: cashPoolModel.CompanyId,
  78 + Cash: cashPoolModel.Cash,
  79 + ExchangedCash: cashPoolModel.ExchangedCash,
  80 + UnExchangeCash: cashPoolModel.UnExchangeCash,
  81 + ExchangedSuMoney: cashPoolModel.ExchangedSuMoney,
  82 + UnExchangeSuMoney: cashPoolModel.UnExchangeSuMoney,
  83 + Rate: cashPoolModel.Rate,
61 }, nil 84 }, nil
62 } 85 }
63 86
@@ -17,16 +17,16 @@ func (repository *ExchangeCashActivityRepository) Save(exchangeCashActivity *dom @@ -17,16 +17,16 @@ func (repository *ExchangeCashActivityRepository) Save(exchangeCashActivity *dom
17 tx := repository.transactionContext.PgTx 17 tx := repository.transactionContext.PgTx
18 if exchangeCashActivity.Identity() == nil { 18 if exchangeCashActivity.Identity() == nil {
19 if _, err := tx.QueryOne( 19 if _, err := tx.QueryOne(
20 - pg.Scan(&exchangeCashActivity.ExchangeCashActivityId, &exchangeCashActivity.ExchangeActivityName),  
21 - "INSERT INTO exchange_cash_activity () VALUES () RETURNING id, " ,  
22 - exchangeCashActivity.ExchangeActivityName); err != nil { 20 + pg.Scan(&exchangeCashActivity.ActivityId, &exchangeCashActivity.CompanyId, &exchangeCashActivity.ExchangeActivityName, &exchangeCashActivity.Deadline, &exchangeCashActivity.CountDown, &exchangeCashActivity.ExchangedCash, &exchangeCashActivity.ExchangedSuMoney, &exchangeCashActivity.Rate),
  21 + "INSERT INTO exchange_cash_activities ( company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate) VALUES (?, ?, ?, ?, ?, ?, ? ) RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate" ,
  22 + exchangeCashActivity.CompanyId, exchangeCashActivity.ExchangeActivityName, exchangeCashActivity.Deadline, exchangeCashActivity.CountDown, exchangeCashActivity.ExchangedCash, exchangeCashActivity.ExchangedSuMoney, exchangeCashActivity.Rate); err != nil {
23 return exchangeCashActivity, err 23 return exchangeCashActivity, err
24 } 24 }
25 } else { 25 } else {
26 if _, err := tx.QueryOne( 26 if _, err := tx.QueryOne(
27 - pg.Scan(&exchangeCashActivity.ExchangeCashActivityId, &exchangeCashActivity.ExchangeActivityName),  
28 - "UPDATE exchange_cash_activity SET exchange_activity_name=?, WHERE id=? RETURNING id, exchange_cash_activity_name",  
29 - exchangeCashActivity.ExchangeActivityName); err != nil { 27 + pg.Scan(&exchangeCashActivity.ActivityId, &exchangeCashActivity.ExchangeActivityName),
  28 + "UPDATE exchange_cash_activities SET company_id=?, activity_name=?, deadline=?, count_down=?, exchanged_cash=?, exchanged_su_money=?, exchange_rate=?, create_time=?, WHERE id=? RETURNING id, company_id, activity_name, deadline, count_down, exchanged_cash, exchanged_su_money, exchange_rate",
  29 + exchangeCashActivity.CompanyId, exchangeCashActivity.ExchangeActivityName, exchangeCashActivity.Deadline, exchangeCashActivity.CountDown, exchangeCashActivity.ExchangedCash, exchangeCashActivity.ExchangedSuMoney, exchangeCashActivity.Rate); err != nil {
30 return exchangeCashActivity, err 30 return exchangeCashActivity, err
31 } 31 }
32 } 32 }
@@ -104,7 +104,7 @@ func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]i @@ -104,7 +104,7 @@ func (repository *ExchangeCashActivityRepository) Find(queryOptions map[string]i
104 func (repository *ExchangeCashActivityRepository) Remove(exchangeCashActivity *domain.ExchangeCashActivity) (*domain.ExchangeCashActivity, error) { 104 func (repository *ExchangeCashActivityRepository) Remove(exchangeCashActivity *domain.ExchangeCashActivity) (*domain.ExchangeCashActivity, error) {
105 tx := repository.transactionContext.PgTx 105 tx := repository.transactionContext.PgTx
106 exchangeCashActivityModel := new(models.ExchangeCashActivity) 106 exchangeCashActivityModel := new(models.ExchangeCashActivity)
107 - exchangeCashActivity.ExchangeCashActivityId = exchangeCashActivity.Identity().(int64) 107 + exchangeCashActivity.ActivityId = exchangeCashActivity.Identity().(int64)
108 if _, err := tx.Model(exchangeCashActivityModel).WherePK().Delete(); err != nil { 108 if _, err := tx.Model(exchangeCashActivityModel).WherePK().Delete(); err != nil {
109 return exchangeCashActivity, err 109 return exchangeCashActivity, err
110 } 110 }
@@ -113,7 +113,7 @@ func (repository *ExchangeCashActivityRepository) Remove(exchangeCashActivity *d @@ -113,7 +113,7 @@ func (repository *ExchangeCashActivityRepository) Remove(exchangeCashActivity *d
113 113
114 func (repository *ExchangeCashActivityRepository) transformPgModelToDomainModel(exchangeCashActivity *models.ExchangeCashActivity) (*domain.ExchangeCashActivity, error) { 114 func (repository *ExchangeCashActivityRepository) transformPgModelToDomainModel(exchangeCashActivity *models.ExchangeCashActivity) (*domain.ExchangeCashActivity, error) {
115 return &domain.ExchangeCashActivity{ 115 return &domain.ExchangeCashActivity{
116 - ExchangeCashActivityId: exchangeCashActivity.Id, 116 + ActivityId: exchangeCashActivity.Id,
117 ExchangeActivityName: exchangeCashActivity.ActivityName, 117 ExchangeActivityName: exchangeCashActivity.ActivityName,
118 CompanyId: exchangeCashActivity.CompanyId, 118 CompanyId: exchangeCashActivity.CompanyId,
119 ExchangedCash: exchangeCashActivity.ExchangedCash, 119 ExchangedCash: exchangeCashActivity.ExchangedCash,
@@ -122,9 +122,9 @@ func (repository *ExchangeCashActivityRepository) transformPgModelToDomainModel( @@ -122,9 +122,9 @@ func (repository *ExchangeCashActivityRepository) transformPgModelToDomainModel(
122 Deadline: exchangeCashActivity.Deadline, 122 Deadline: exchangeCashActivity.Deadline,
123 CountDown: exchangeCashActivity.CountDown, 123 CountDown: exchangeCashActivity.CountDown,
124 Rate: exchangeCashActivity.ExchangeRate, 124 Rate: exchangeCashActivity.ExchangeRate,
125 - LastRate: exchangeCashActivity.LastExchangeRate,  
126 - Operator: exchangeCashActivity.Sponsor,  
127 - ExchangeCashPeople: exchangeCashActivity.ExchangeSuMoneyList, 125 + //LastRate: exchangeCashActivity.LastExchangeRate,
  126 + //Operator: exchangeCashActivity.Sponsor,
  127 + //ExchangeCashPeople: exchangeCashActivity.ExchangeSuMoneyList,
128 }, nil 128 }, nil
129 } 129 }
130 func NewExchangeCashActivityRepository(transactionContext *pgTransaction.TransactionContext) (*ExchangeCashActivityRepository, error) { 130 func NewExchangeCashActivityRepository(transactionContext *pgTransaction.TransactionContext) (*ExchangeCashActivityRepository, error) {
@@ -2,12 +2,14 @@ package controllers @@ -2,12 +2,14 @@ package controllers
2 2
3 import ( 3 import (
4 "encoding/json" 4 "encoding/json"
5 - 5 + "fmt"
  6 + "github.com/360EntSecGroup-Skylar/excelize/v2"
6 "github.com/astaxie/beego" 7 "github.com/astaxie/beego"
7 "github.com/linmadan/egglib-go/web/beego/utils" 8 "github.com/linmadan/egglib-go/web/beego/utils"
8 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command" 9 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/command"
9 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query" 10 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
10 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service" 11 "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/service"
  12 + "path"
11 ) 13 )
12 14
13 type SuMoneyController struct { 15 type SuMoneyController struct {
@@ -131,7 +133,7 @@ func (controller *SuMoneyController) CashInput() { @@ -131,7 +133,7 @@ func (controller *SuMoneyController) CashInput() {
131 133
132 json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createCashPoolCommand) 134 json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createCashPoolCommand)
133 135
134 - data, err := cashPoolService.OperationCashPool(createCashPoolCommand) 136 + data, err := cashPoolService.CreateCashPool(createCashPoolCommand)
135 137
136 var response utils.JsonResponse 138 var response utils.JsonResponse
137 139
@@ -146,13 +148,15 @@ func (controller *SuMoneyController) CashInput() { @@ -146,13 +148,15 @@ func (controller *SuMoneyController) CashInput() {
146 } 148 }
147 149
148 // 返回现金池 150 // 返回现金池
149 -func (controller *SuMoneyController) CashPool() { 151 +func (controller *SuMoneyController) GetCashPool() {
150 cashPoolService := service.NewCashPoolService(nil) 152 cashPoolService := service.NewCashPoolService(nil)
151 getCashPoolQuery := &query.GetCashPoolQuery{} 153 getCashPoolQuery := &query.GetCashPoolQuery{}
152 154
153 - json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), getCashPoolQuery) 155 + //json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), getCashPoolQuery)
  156 + companyId, _ := controller.GetInt64("companyId")
  157 + getCashPoolQuery.CompanyId = companyId
154 158
155 - data, err := cashPoolService.CashPool(getCashPoolQuery) 159 + data, err := cashPoolService.GetCashPool(getCashPoolQuery)
156 160
157 var response utils.JsonResponse 161 var response utils.JsonResponse
158 162
@@ -265,7 +269,7 @@ func (controller *SuMoneyController) RemoveExchangeActivities () { @@ -265,7 +269,7 @@ func (controller *SuMoneyController) RemoveExchangeActivities () {
265 } 269 }
266 270
267 // 返回兑换现金活动 271 // 返回兑换现金活动
268 -func (controller *SuMoneyController) GerExchangeCashActivity () { 272 +func (controller *SuMoneyController) GetExchangeCashActivity () {
269 cashPoolService := service.NewCashPoolService(nil) 273 cashPoolService := service.NewCashPoolService(nil)
270 getExchangeCashActivityQuery := &query.GetExchangeCashActivityQuery{} 274 getExchangeCashActivityQuery := &query.GetExchangeCashActivityQuery{}
271 275
@@ -406,23 +410,60 @@ func (controller *SuMoneyController) GetExchangeCashPerson () { @@ -406,23 +410,60 @@ func (controller *SuMoneyController) GetExchangeCashPerson () {
406 controller.ServeJSON() 410 controller.ServeJSON()
407 } 411 }
408 412
409 -// TODO 导入素币兑换清单 413 +// 导入素币兑换清单
410 func (controller *SuMoneyController) ImportExchangeList () { 414 func (controller *SuMoneyController) ImportExchangeList () {
411 cashPoolService := service.NewCashPoolService(nil) 415 cashPoolService := service.NewCashPoolService(nil)
412 createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{} 416 createExchangeCashPersonCommand := &command.CreateExchangeCashPersonCommand{}
413 417
414 - // TODO 批量导入 418 + file, h, _ := controller.GetFile("file") //获取上传的文件
  419 + ext := path.Ext(h.Filename)
415 420
416 - json.Unmarshal(controller.Ctx.Input.GetData("requestBody").([]byte), createExchangeCashPersonCommand) 421 + //验证后缀名是否符合要求
  422 + AllowExtMap := map[string]bool{
  423 + ".xlsx":true,
  424 + }
  425 + if _,ok:=AllowExtMap[ext];!ok{
  426 + controller.Ctx.WriteString( "后缀名不符合上传要求" )
  427 + return
  428 + }
417 429
418 - data, err := cashPoolService.CreateExchangeCashPerson(createExchangeCashPersonCommand) 430 + xlsx, err := excelize.OpenReader(file)
  431 + if err != nil {
  432 + fmt.Println(err)
  433 + return
  434 + }
419 435
420 var response utils.JsonResponse 436 var response utils.JsonResponse
421 437
  438 + dataList := make([]interface{}, 0)
  439 +
  440 + rows, _ := xlsx.GetRows("Sheet1")
  441 +
  442 + fmt.Print(rows)
  443 +
  444 + for i, row := range rows {
  445 + if i > 0 {
  446 + for _, _ = range row {
  447 + //fmt.Print(row[0], "\t")
  448 + //fmt.Print(row[1], "\t")
  449 + //fmt.Print(row[2], "\t")
  450 + //fmt.Print(row[3], "\t")
  451 +
  452 + //createExchangeCashPersonCommand.ExchangeCashPerson.EmployeeInfo.EmployeeName = row[0]
  453 + //createExchangeCashPersonCommand.ExchangeCashPerson.EmployeeInfo.EmployeeAccount = row[1]
  454 + //createExchangeCashPersonCommand.ExchangedCash, _ = strconv.ParseFloat(row[2],64)
  455 + //createExchangeCashPersonCommand.ExchangedSuMoney, _ = strconv.ParseFloat(row[3], 64)
  456 +
  457 + data, err := cashPoolService.CreateExchangeCashPerson(createExchangeCashPersonCommand)
  458 +
422 if err != nil { 459 if err != nil {
423 response = utils.ResponseError(controller.Ctx, err) 460 response = utils.ResponseError(controller.Ctx, err)
424 } else { 461 } else {
425 - response = utils.ResponseData(controller.Ctx, data) 462 + dataList = append(dataList, data)
  463 + response = utils.ResponseData(controller.Ctx, dataList)
  464 + }
  465 + }
  466 + }
426 } 467 }
427 468
428 controller.Data["json"] = response 469 controller.Data["json"] = response
@@ -15,7 +15,7 @@ func init() { @@ -15,7 +15,7 @@ func init() {
15 15
16 /**********************************************现金池*******************************************/ 16 /**********************************************现金池*******************************************/
17 beego.Router("/cash-pool/input", &controllers.SuMoneyController{}, "POST:CashInput") // 现金池投入 17 beego.Router("/cash-pool/input", &controllers.SuMoneyController{}, "POST:CashInput") // 现金池投入
18 - beego.Router("/cash-pool/cash-pool-statistics", &controllers.SuMoneyController{}, "GET:CashPool") // 返回现金池统计 18 + beego.Router("/cash-pool/cash-pool", &controllers.SuMoneyController{}, "GET:GetCashPool") // 返回现金池统计
19 19
20 beego.Router("/cash-pool/activity/", &controllers.SuMoneyController{}, "GET:ListExchangeActivities") // 返回兑换活动列表 20 beego.Router("/cash-pool/activity/", &controllers.SuMoneyController{}, "GET:ListExchangeActivities") // 返回兑换活动列表
21 beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "GET:ListExchangeActivities") // 返回兑换活动 21 beego.Router("/cash-pool/activity/:activityId", &controllers.SuMoneyController{}, "GET:ListExchangeActivities") // 返回兑换活动