合并分支 'dev' 到 'master'
Dev 查看合并请求 !4
正在显示
79 个修改的文件
包含
2807 行增加
和
85 行删除
@@ -6,6 +6,8 @@ | @@ -6,6 +6,8 @@ | ||
6 | # Folders | 6 | # Folders |
7 | _obj | 7 | _obj |
8 | _test | 8 | _test |
9 | +public/file | ||
10 | +logs | ||
9 | 11 | ||
10 | # Architecture specific extensions/prefixes | 12 | # Architecture specific extensions/prefixes |
11 | *.[568vq] | 13 | *.[568vq] |
@@ -23,3 +25,4 @@ _testmain.go | @@ -23,3 +25,4 @@ _testmain.go | ||
23 | *.test | 25 | *.test |
24 | .log | 26 | .log |
25 | .idea | 27 | .idea |
28 | + |
1 | -FROM golang:latest | ||
2 | -MAINTAINER linmadan <772181827@qq.com> | 1 | +FROM 192.168.0.243:5000/mmm/mmm-worth:20201122 |
2 | +#FROM golang:latest | ||
3 | +#MAINTAINER linmadan <772181827@qq.com> | ||
3 | ENV APP_DIR $GOPATH/src/mmm-worth | 4 | ENV APP_DIR $GOPATH/src/mmm-worth |
4 | RUN mkdir -p $APP_DIR | 5 | RUN mkdir -p $APP_DIR |
5 | WORKDIR $APP_DIR/ | 6 | WORKDIR $APP_DIR/ |
@@ -10,6 +11,6 @@ COPY ./main.go main.go | @@ -10,6 +11,6 @@ COPY ./main.go main.go | ||
10 | RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"] | 11 | RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"] |
11 | ENV GO111MODULE on | 12 | ENV GO111MODULE on |
12 | ENV GOPROXY https://goproxy.io | 13 | ENV GOPROXY https://goproxy.io |
13 | -RUN ["go","mod","tidy"] | 14 | +#RUN ["go","mod","tidy"] |
14 | RUN ["go","build"] | 15 | RUN ["go","build"] |
15 | ENTRYPOINT ["./mmm-worth"] | 16 | ENTRYPOINT ["./mmm-worth"] |
@@ -39,9 +39,6 @@ spec: | @@ -39,9 +39,6 @@ spec: | ||
39 | operator: In | 39 | operator: In |
40 | values: | 40 | values: |
41 | - cn-hangzhou.i-bp1djh1xn7taumbue1ze | 41 | - cn-hangzhou.i-bp1djh1xn7taumbue1ze |
42 | - - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
43 | - - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
44 | - - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
45 | containers: | 42 | containers: |
46 | - name: mmm-worth | 43 | - name: mmm-worth |
47 | image: 192.168.0.243:5000/mmm/mmm-worth:dev | 44 | image: 192.168.0.243:5000/mmm/mmm-worth:dev |
@@ -57,11 +54,11 @@ spec: | @@ -57,11 +54,11 @@ spec: | ||
57 | - name: POSTGRESQL_USER | 54 | - name: POSTGRESQL_USER |
58 | value: "postgres" | 55 | value: "postgres" |
59 | - name: POSTGRESQL_PASSWORD | 56 | - name: POSTGRESQL_PASSWORD |
60 | - value: "postgres_15432" | 57 | + value: "eagle1010" |
61 | - name: POSTGRESQL_HOST | 58 | - name: POSTGRESQL_HOST |
62 | - value: "101.37.68.23" | 59 | + value: "114.55.200.59" |
63 | - name: POSTGRESQL_PORT | 60 | - name: POSTGRESQL_PORT |
64 | - value: "15432" | 61 | + value: "31543" |
65 | - name: LOG_LEVEL | 62 | - name: LOG_LEVEL |
66 | value: "debug" | 63 | value: "debug" |
67 | - name: ERROR_BASE_CODE | 64 | - name: ERROR_BASE_CODE |
deploy/k8s/test/install.sh
100644 → 100755
@@ -39,9 +39,6 @@ spec: | @@ -39,9 +39,6 @@ spec: | ||
39 | operator: In | 39 | operator: In |
40 | values: | 40 | values: |
41 | - cn-hangzhou.i-bp1djh1xn7taumbue1ze | 41 | - cn-hangzhou.i-bp1djh1xn7taumbue1ze |
42 | - - cn-hangzhou.i-bp1djh1xn7taumbue1zd | ||
43 | - - cn-hangzhou.i-bp1euf5u1ph9kbhtndhb | ||
44 | - - cn-hangzhou.i-bp1hyp5oips9cdwxxgxy | ||
45 | containers: | 42 | containers: |
46 | - name: mmm-worth | 43 | - name: mmm-worth |
47 | image: 192.168.0.243:5000/mmm/mmm-worth:test | 44 | image: 192.168.0.243:5000/mmm/mmm-worth:test |
@@ -57,11 +54,11 @@ spec: | @@ -57,11 +54,11 @@ spec: | ||
57 | - name: POSTGRESQL_USER | 54 | - name: POSTGRESQL_USER |
58 | value: "postgres" | 55 | value: "postgres" |
59 | - name: POSTGRESQL_PASSWORD | 56 | - name: POSTGRESQL_PASSWORD |
60 | - value: "postgres_15432" | 57 | + value: "eagle1010" |
61 | - name: POSTGRESQL_HOST | 58 | - name: POSTGRESQL_HOST |
62 | - value: "101.37.68.23" | 59 | + value: "114.55.200.59" |
63 | - name: POSTGRESQL_PORT | 60 | - name: POSTGRESQL_PORT |
64 | - value: "15432" | 61 | + value: "31543" |
65 | - name: LOG_LEVEL | 62 | - name: LOG_LEVEL |
66 | value: "debug" | 63 | value: "debug" |
67 | - name: ERROR_BASE_CODE | 64 | - name: ERROR_BASE_CODE |
@@ -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 |
@@ -13,13 +14,14 @@ require ( | @@ -13,13 +14,14 @@ require ( | ||
13 | github.com/gorilla/websocket v1.4.2 // indirect | 14 | github.com/gorilla/websocket v1.4.2 // indirect |
14 | github.com/imkira/go-interpol v1.1.0 // indirect | 15 | github.com/imkira/go-interpol v1.1.0 // indirect |
15 | github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect | 16 | github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect |
16 | - github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 | 17 | + github.com/linmadan/egglib-go v0.0.0-20201125083542-25358a549edb |
17 | github.com/mattn/go-colorable v0.1.6 // indirect | 18 | github.com/mattn/go-colorable v0.1.6 // indirect |
18 | github.com/moul/http2curl v1.0.0 // indirect | 19 | github.com/moul/http2curl v1.0.0 // indirect |
19 | github.com/onsi/ginkgo v1.10.3 | 20 | github.com/onsi/ginkgo v1.10.3 |
20 | github.com/onsi/gomega v1.7.1 | 21 | github.com/onsi/gomega v1.7.1 |
21 | github.com/sergi/go-diff v1.1.0 // indirect | 22 | github.com/sergi/go-diff v1.1.0 // indirect |
22 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect | 23 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect |
24 | + github.com/shopspring/decimal v1.2.0 | ||
23 | github.com/smartystreets/goconvey v1.6.4 // indirect | 25 | github.com/smartystreets/goconvey v1.6.4 // indirect |
24 | github.com/valyala/fasthttp v1.9.0 // indirect | 26 | github.com/valyala/fasthttp v1.9.0 // indirect |
25 | github.com/xeipuuv/gojsonschema v1.2.0 // indirect | 27 | github.com/xeipuuv/gojsonschema v1.2.0 // indirect |
@@ -27,6 +29,7 @@ require ( | @@ -27,6 +29,7 @@ require ( | ||
27 | github.com/yudai/gojsondiff v1.0.0 // indirect | 29 | github.com/yudai/gojsondiff v1.0.0 // indirect |
28 | github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect | 30 | github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect |
29 | github.com/yudai/pp v2.0.1+incompatible // indirect | 31 | github.com/yudai/pp v2.0.1+incompatible // indirect |
32 | + golang.org/x/tools v0.0.0-20200117065230-39095c1d176c | ||
30 | ) | 33 | ) |
31 | 34 | ||
32 | replace gitlab.fjmaimaimai.com/linmadan/mmm-worth => ../mmm-worth | 35 | replace gitlab.fjmaimaimai.com/linmadan/mmm-worth => ../mmm-worth |
1 | +github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.1 h1:j56fC19WoD3z+u+ZHxm2XwRGyS1XmdSMk7058BLhdsM= | ||
2 | +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= | 3 | 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= | 4 | github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= |
3 | github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM= | 5 | github.com/OwnLocal/goes v1.0.0/go.mod h1:8rIFjBGTue3lCU0wplczcUgt9Gxgrkkrw7etMIcn8TM= |
@@ -79,11 +81,15 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | @@ -79,11 +81,15 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= | ||
79 | github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= | 81 | github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= |
80 | github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 h1:zJZsqJ1wFMYb2yrja5S3OZ+oASx4irRksZ8+emFs56M= | 82 | github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 h1:zJZsqJ1wFMYb2yrja5S3OZ+oASx4irRksZ8+emFs56M= |
81 | github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9/go.mod h1:S1zYn9bb6h+Qzu1aOO8raFhHniewOBaif3YvA9qA6lk= | 83 | github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9/go.mod h1:S1zYn9bb6h+Qzu1aOO8raFhHniewOBaif3YvA9qA6lk= |
84 | +github.com/linmadan/egglib-go v0.0.0-20201125083542-25358a549edb h1:Ocxw5BWyRrRkTHSsTmQx0UnGsAYZDOwa3K9oGlXF8Jo= | ||
85 | +github.com/linmadan/egglib-go v0.0.0-20201125083542-25358a549edb/go.mod h1:S1zYn9bb6h+Qzu1aOO8raFhHniewOBaif3YvA9qA6lk= | ||
82 | github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= | 86 | github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE= |
83 | github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= | 87 | github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= |
84 | github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= | 88 | github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= |
85 | github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= | 89 | 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= | 90 | github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= |
91 | +github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw= | ||
92 | +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= | 93 | github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs= |
88 | github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ= | 94 | 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= | 95 | github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= |
@@ -98,10 +104,16 @@ github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6J | @@ -98,10 +104,16 @@ github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6J | ||
98 | github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | 104 | 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= | 105 | 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= | 106 | github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= |
107 | +github.com/richardlehane/mscfb v1.0.3 h1:rD8TBkYWkObWO0oLDFCbwMeZ4KoalxQy+QgniCj3nKI= | ||
108 | +github.com/richardlehane/mscfb v1.0.3/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk= | ||
109 | +github.com/richardlehane/msoleps v1.0.1 h1:RfrALnSNXzmXLbGct/P2b4xkFz4e8Gmj/0Vj9M9xC1o= | ||
110 | +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= | 111 | 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= | 112 | 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= | 113 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo= |
104 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg= | 114 | github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg= |
115 | +github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= | ||
116 | +github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= | ||
105 | github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= | 117 | github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw= |
106 | github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg= | 118 | github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg= |
107 | github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA= | 119 | github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA= |
@@ -119,6 +131,8 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0 | @@ -119,6 +131,8 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0 | ||
119 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= | 131 | github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= |
120 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= | 132 | github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= |
121 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | 133 | github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= |
134 | +github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0= | ||
135 | +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= | 136 | 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= | 137 | github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= |
124 | github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= | 138 | github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= |
@@ -134,6 +148,8 @@ github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHo | @@ -134,6 +148,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= | 148 | 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= | 149 | github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= |
136 | github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= | 150 | github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= |
151 | +github.com/xuri/efp v0.0.0-20200605144744-ba689101faaf h1:spotWVWg9DP470pPFQ7LaYtUqDpWEOS/BUrSmwFZE4k= | ||
152 | +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= | 153 | 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= | 154 | 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= | 155 | github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= |
@@ -150,6 +166,11 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U | @@ -150,6 +166,11 @@ 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= | 166 | 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= | 167 | 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= | 168 | golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= |
169 | +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | ||
170 | +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM= | ||
171 | +golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= | ||
172 | +golang.org/x/image v0.0.0-20200922025426-e59bae62ef32 h1:E+SEVulmY8U4+i6vSB88YSc2OKAFfvbHPU/uDTdQu7M= | ||
173 | +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= | 174 | 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= | 175 | 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= | 176 | golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= |
@@ -160,6 +181,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL | @@ -160,6 +181,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= | 181 | 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= | 182 | 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= | 183 | golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= |
184 | +golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA= | ||
185 | +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= | 186 | 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= | 187 | 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= | 188 | golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= |
@@ -173,12 +196,17 @@ golang.org/x/sys v0.0.0-20191010194322-b09406accb47/go.mod h1:h1NjWce9XRLGQEsW7w | @@ -173,12 +196,17 @@ 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= | 196 | 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= | 197 | 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= | 198 | golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= |
199 | +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884= | ||
200 | +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= | 201 | golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= |
177 | golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs= | 202 | 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= | 203 | golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= |
204 | +golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= | ||
205 | +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= | 206 | 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= | 207 | 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= | 208 | golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= |
209 | +golang.org/x/tools v0.0.0-20200117065230-39095c1d176c h1:FodBYPZKH5tAN2O60HlglMwXGAeV/4k+NKbli79M/2c= | ||
182 | golang.org/x/tools v0.0.0-20200117065230-39095c1d176c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= | 210 | golang.org/x/tools v0.0.0-20200117065230-39095c1d176c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= |
183 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= | 211 | golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= |
184 | google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= | 212 | google.golang.org/appengine v1.6.2/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= |
@@ -198,5 +226,7 @@ gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | @@ -198,5 +226,7 @@ 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= | 226 | gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
199 | gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= | 227 | gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I= |
200 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= | 228 | gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
229 | +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= | ||
230 | +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= | 231 | mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w= |
202 | mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ= | 232 | mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ= |
@@ -21,6 +21,7 @@ func (configService *ConfigService) ListTaskStatus(listTaskStatusQuery *query.Li | @@ -21,6 +21,7 @@ func (configService *ConfigService) ListTaskStatus(listTaskStatusQuery *query.Li | ||
21 | 4: "待验收", | 21 | 4: "待验收", |
22 | 5: "已完成", | 22 | 5: "已完成", |
23 | 7: "待确认", | 23 | 7: "待确认", |
24 | + 8: "已过期", | ||
24 | } | 25 | } |
25 | var list []map[string]interface{} | 26 | var list []map[string]interface{} |
26 | for key, value := range taskStatusMap { | 27 | for key, value := range taskStatusMap { |
@@ -165,7 +166,7 @@ func (configService *ConfigService) ListBidTimeMatch(listBidTimeMatchQuery *quer | @@ -165,7 +166,7 @@ func (configService *ConfigService) ListBidTimeMatch(listBidTimeMatchQuery *quer | ||
165 | }, nil | 166 | }, nil |
166 | } | 167 | } |
167 | 168 | ||
168 | -// 返回员工权限字典列表(1任务管理,2素币管理,3成员管理) | 169 | +// 返回员工权限字典列表(1任务管理,2素币管理,3成员管理,4标签管理,5排行榜管理) |
169 | func (configService *ConfigService) ListEmployeePermission(listEmployeePermissionQuery *query.ListEmployeePermissionQuery) (interface{}, error) { | 170 | func (configService *ConfigService) ListEmployeePermission(listEmployeePermissionQuery *query.ListEmployeePermissionQuery) (interface{}, error) { |
170 | if err := listEmployeePermissionQuery.ValidateQuery(); err != nil { | 171 | if err := listEmployeePermissionQuery.ValidateQuery(); err != nil { |
171 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 172 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
@@ -175,6 +176,7 @@ func (configService *ConfigService) ListEmployeePermission(listEmployeePermissio | @@ -175,6 +176,7 @@ func (configService *ConfigService) ListEmployeePermission(listEmployeePermissio | ||
175 | 2: "素币管理", | 176 | 2: "素币管理", |
176 | 3: "成员管理", | 177 | 3: "成员管理", |
177 | 4: "标签管理", | 178 | 4: "标签管理", |
179 | + 5: "排行榜管理", | ||
178 | } | 180 | } |
179 | var list []map[string]interface{} | 181 | var list []map[string]interface{} |
180 | for key, value := range employeePermissionMap { | 182 | for key, value := range employeePermissionMap { |
@@ -2,6 +2,7 @@ package command | @@ -2,6 +2,7 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "time" | ||
5 | 6 | ||
6 | "github.com/astaxie/beego/validation" | 7 | "github.com/astaxie/beego/validation" |
7 | ) | 8 | ) |
@@ -15,6 +16,8 @@ type CreateEmployeeCommand struct { | @@ -15,6 +16,8 @@ type CreateEmployeeCommand struct { | ||
15 | EmployeeAccount string `json:"employeeAccount,omitempty"` | 16 | EmployeeAccount string `json:"employeeAccount,omitempty"` |
16 | // 员工头像URL | 17 | // 员工头像URL |
17 | EmployeeAvatarUrl string `json:"employeeAvatarUrl,omitempty"` | 18 | EmployeeAvatarUrl string `json:"employeeAvatarUrl,omitempty"` |
19 | + // 创建时间 | ||
20 | + CreateTime time.Time `json:"createTime"` | ||
18 | } | 21 | } |
19 | 22 | ||
20 | func (createEmployeeCommand *CreateEmployeeCommand) ValidateCommand() error { | 23 | func (createEmployeeCommand *CreateEmployeeCommand) ValidateCommand() error { |
@@ -2,6 +2,7 @@ package command | @@ -2,6 +2,7 @@ package command | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "time" | ||
5 | 6 | ||
6 | "github.com/astaxie/beego/validation" | 7 | "github.com/astaxie/beego/validation" |
7 | ) | 8 | ) |
@@ -17,6 +18,8 @@ type UpdateEmployeeCommand struct { | @@ -17,6 +18,8 @@ type UpdateEmployeeCommand struct { | ||
17 | EmployeeAvatarUrl string `json:"employeeAvatarUrl,omitempty"` | 18 | EmployeeAvatarUrl string `json:"employeeAvatarUrl,omitempty"` |
18 | // 员工权限集合 | 19 | // 员工权限集合 |
19 | Permissions []int `json:"permissions,omitempty"` | 20 | Permissions []int `json:"permissions,omitempty"` |
21 | + // 创建时间 | ||
22 | + CreateTime time.Time `json:"createTime"` | ||
20 | } | 23 | } |
21 | 24 | ||
22 | func (updateEmployeeCommand *UpdateEmployeeCommand) ValidateCommand() error { | 25 | func (updateEmployeeCommand *UpdateEmployeeCommand) ValidateCommand() error { |
@@ -13,6 +13,8 @@ type ListEmployeeQuery struct { | @@ -13,6 +13,8 @@ type ListEmployeeQuery struct { | ||
13 | EmployeeNameMatch string `json:"employeeNameMatch,omitempty"` | 13 | EmployeeNameMatch string `json:"employeeNameMatch,omitempty"` |
14 | // 查询偏离量 | 14 | // 查询偏离量 |
15 | Offset int `json:"offset,omitempty"` | 15 | Offset int `json:"offset,omitempty"` |
16 | + // 员工状态(启用或者禁用) | ||
17 | + Status int `json:"status"` | ||
16 | // 查询限制 | 18 | // 查询限制 |
17 | Limit int `json:"limit,omitempty"` | 19 | Limit int `json:"limit,omitempty"` |
18 | } | 20 | } |
@@ -8,6 +8,7 @@ import ( | @@ -8,6 +8,7 @@ import ( | ||
8 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/employee/query" | 8 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/employee/query" |
9 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" | 9 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" |
10 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | 10 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" |
11 | + "time" | ||
11 | ) | 12 | ) |
12 | 13 | ||
13 | // 员工服务 | 14 | // 员工服务 |
@@ -36,6 +37,7 @@ func (employeeService *EmployeeService) CreateEmployee(createEmployeeCommand *co | @@ -36,6 +37,7 @@ func (employeeService *EmployeeService) CreateEmployee(createEmployeeCommand *co | ||
36 | EmployeeAccount: createEmployeeCommand.EmployeeAccount, | 37 | EmployeeAccount: createEmployeeCommand.EmployeeAccount, |
37 | }, | 38 | }, |
38 | SuMoney: 0, | 39 | SuMoney: 0, |
40 | + CreateTime: time.Now(), | ||
39 | } | 41 | } |
40 | var employeeRepository domain.EmployeeRepository | 42 | var employeeRepository domain.EmployeeRepository |
41 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ | 43 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ |
@@ -122,6 +124,7 @@ func (employeeService *EmployeeService) UpdateEmployee(updateEmployeeCommand *co | @@ -122,6 +124,7 @@ func (employeeService *EmployeeService) UpdateEmployee(updateEmployeeCommand *co | ||
122 | if employee == nil { | 124 | if employee == nil { |
123 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateEmployeeCommand.Uid))) | 125 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateEmployeeCommand.Uid))) |
124 | } | 126 | } |
127 | + updateEmployeeCommand.CreateTime = time.Now() | ||
125 | if err := employee.Update(tool_funs.SimpleStructToMap(updateEmployeeCommand)); err != nil { | 128 | if err := employee.Update(tool_funs.SimpleStructToMap(updateEmployeeCommand)); err != nil { |
126 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 129 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
127 | } | 130 | } |
@@ -180,6 +183,7 @@ func (employeeService *EmployeeService) ListEmployee(listEmployeeQuery *query.Li | @@ -180,6 +183,7 @@ func (employeeService *EmployeeService) ListEmployee(listEmployeeQuery *query.Li | ||
180 | if err := listEmployeeQuery.ValidateQuery(); err != nil { | 183 | if err := listEmployeeQuery.ValidateQuery(); err != nil { |
181 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 184 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
182 | } | 185 | } |
186 | + | ||
183 | transactionContext, err := factory.CreateTransactionContext(nil) | 187 | transactionContext, err := factory.CreateTransactionContext(nil) |
184 | if err != nil { | 188 | if err != nil { |
185 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 189 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -190,6 +194,7 @@ func (employeeService *EmployeeService) ListEmployee(listEmployeeQuery *query.Li | @@ -190,6 +194,7 @@ func (employeeService *EmployeeService) ListEmployee(listEmployeeQuery *query.Li | ||
190 | defer func() { | 194 | defer func() { |
191 | transactionContext.RollbackTransaction() | 195 | transactionContext.RollbackTransaction() |
192 | }() | 196 | }() |
197 | + | ||
193 | var employeeRepository domain.EmployeeRepository | 198 | var employeeRepository domain.EmployeeRepository |
194 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ | 199 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ |
195 | "transactionContext": transactionContext, | 200 | "transactionContext": transactionContext, |
@@ -198,7 +203,13 @@ func (employeeService *EmployeeService) ListEmployee(listEmployeeQuery *query.Li | @@ -198,7 +203,13 @@ func (employeeService *EmployeeService) ListEmployee(listEmployeeQuery *query.Li | ||
198 | } else { | 203 | } else { |
199 | employeeRepository = value | 204 | employeeRepository = value |
200 | } | 205 | } |
201 | - if count, employees, err := employeeRepository.Find(tool_funs.SimpleStructToMap(listEmployeeQuery)); err != nil { | 206 | + |
207 | + if count, employees, err := employeeRepository.Find(map[string]interface{}{ | ||
208 | + "companyId": listEmployeeQuery.CompanyId, | ||
209 | + "employeeNameMatch": listEmployeeQuery.EmployeeNameMatch, | ||
210 | + "offset": listEmployeeQuery.Offset, | ||
211 | + "limit": listEmployeeQuery.Limit, | ||
212 | + }); err != nil { | ||
202 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 213 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
203 | } else { | 214 | } else { |
204 | if err := transactionContext.CommitTransaction(); err != nil { | 215 | if err := transactionContext.CommitTransaction(); err != nil { |
@@ -28,3 +28,19 @@ func CreateNotificationDao(options map[string]interface{}) (*dao.NotificationDao | @@ -28,3 +28,19 @@ 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 | +} | ||
39 | + | ||
40 | +func CreateListIntervalDao(options map[string]interface{}) (*dao.ListIntervalDao, error) { | ||
41 | + var transactionContext *pg.TransactionContext | ||
42 | + if value, ok := options["transactionContext"]; ok { | ||
43 | + transactionContext = value.(*pg.TransactionContext) | ||
44 | + } | ||
45 | + return dao.NewListIntervalDao(transactionContext) | ||
46 | +} |
@@ -109,3 +109,6 @@ func CreateExchangeSuMoneyService(options map[string]interface{}) (service.Excha | @@ -109,3 +109,6 @@ func CreateExchangeSuMoneyService(options map[string]interface{}) (service.Excha | ||
109 | } | 109 | } |
110 | return domainService.NewExchangeSuMoneyService(transactionContext) | 110 | return domainService.NewExchangeSuMoneyService(transactionContext) |
111 | } | 111 | } |
112 | + | ||
113 | + | ||
114 | + |
@@ -85,3 +85,35 @@ func CreateSentNotificationRepository(options map[string]interface{}) (domain.Se | @@ -85,3 +85,35 @@ func CreateSentNotificationRepository(options map[string]interface{}) (domain.Se | ||
85 | } | 85 | } |
86 | return repository.NewSentNotificationRepository(transactionContext) | 86 | return repository.NewSentNotificationRepository(transactionContext) |
87 | } | 87 | } |
88 | + | ||
89 | +func CreateCashPoolRepository(options map[string]interface{}) (domain.CashPoolRepository, error) { | ||
90 | + var transactionContext *pg.TransactionContext | ||
91 | + if value, ok := options["transactionContext"]; ok { | ||
92 | + transactionContext = value.(*pg.TransactionContext) | ||
93 | + } | ||
94 | + return repository.NewCashPoolRepository(transactionContext) | ||
95 | +} | ||
96 | + | ||
97 | +func CreateExchangeCashActivityRepository(options map[string]interface{}) (domain.ExchangeActivityRepository, error) { | ||
98 | + var transactionContext *pg.TransactionContext | ||
99 | + if value, ok := options["transactionContext"]; ok { | ||
100 | + transactionContext = value.(*pg.TransactionContext) | ||
101 | + } | ||
102 | + return repository.NewExchangeCashActivityRepository(transactionContext) | ||
103 | +} | ||
104 | + | ||
105 | +func CreateExchangeCashPersonListRepository(options map[string]interface{}) (domain.ExchangeCashPersonListRepository, error) { | ||
106 | + var transactionContext *pg.TransactionContext | ||
107 | + if value, ok := options["transactionContext"]; ok { | ||
108 | + transactionContext = value.(*pg.TransactionContext) | ||
109 | + } | ||
110 | + return repository.NewExchangeCashPersonListRepository(transactionContext) | ||
111 | +} | ||
112 | + | ||
113 | +func CreateListIntervalRepository(options map[string]interface{}) (domain.ListIntervalRepository, error) { | ||
114 | + var transactionContext *pg.TransactionContext | ||
115 | + if value, ok := options["transactionContext"]; ok { | ||
116 | + transactionContext = value.(*pg.TransactionContext) | ||
117 | + } | ||
118 | + return repository.NewListIntervalRepository(transactionContext) | ||
119 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | + "time" | ||
7 | +) | ||
8 | + | ||
9 | +type CreateListIntervalCommand struct { | ||
10 | + CompanyId int `json:"companyId" valid:"Required"` // 公司id | ||
11 | + ListIntervalStartTime time.Time `json:"listIntervalStartTime"` // 排行榜开始时间 | ||
12 | + ListIntervalEndTime time.Time `json:"listIntervalEndTime"` // 排行榜结束时间 | ||
13 | +} | ||
14 | + | ||
15 | +func (createListIntervalCommand *CreateListIntervalCommand) ValidateCommand() error { | ||
16 | + valid := validation.Validation{} | ||
17 | + b, err := valid.Valid(createListIntervalCommand) | ||
18 | + if err != nil { | ||
19 | + return err | ||
20 | + } | ||
21 | + if !b { | ||
22 | + for _, validErr := range valid.Errors { | ||
23 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
24 | + } | ||
25 | + } | ||
26 | + return nil | ||
27 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type RemoveListIntervalCommand struct { | ||
9 | + ListIntervalId int `json:"listIntervalId" valid:"Required"` // 排行榜Id | ||
10 | +} | ||
11 | + | ||
12 | +func (removeListIntervalCommand *RemoveListIntervalCommand) ValidateCommand() error { | ||
13 | + valid := validation.Validation{} | ||
14 | + b, err := valid.Valid(removeListIntervalCommand) | ||
15 | + if err != nil { | ||
16 | + return err | ||
17 | + } | ||
18 | + if !b { | ||
19 | + for _, validErr := range valid.Errors { | ||
20 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
21 | + } | ||
22 | + } | ||
23 | + return nil | ||
24 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | + "time" | ||
7 | +) | ||
8 | + | ||
9 | +type UpdateListIntervalCommand struct { | ||
10 | + ListIntervalId int `json:"listIntervalId" valid:"Required"` // 排行榜id | ||
11 | + ListIntervalStartTime time.Time `json:"listIntervalStartTime"` // 排行榜开始时间 | ||
12 | + ListIntervalEndTime time.Time `json:"listIntervalEndTime"` // 排行榜结束时间 | ||
13 | +} | ||
14 | + | ||
15 | +func (updateListIntervalCommand *UpdateListIntervalCommand) ValidateCommand() error { | ||
16 | + valid := validation.Validation{} | ||
17 | + b, err := valid.Valid(updateListIntervalCommand) | ||
18 | + if err != nil { | ||
19 | + return err | ||
20 | + } | ||
21 | + if !b { | ||
22 | + for _, validErr := range valid.Errors { | ||
23 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
24 | + } | ||
25 | + } | ||
26 | + return nil | ||
27 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type GetListIntervalQuery struct { | ||
9 | + ListIntervalId int `json:"listIntervalId"` // 排行榜id | ||
10 | +} | ||
11 | + | ||
12 | +func (getListIntervalQuery *GetListIntervalQuery) ValidateQuery() error { | ||
13 | + valid := validation.Validation{} | ||
14 | + b, err := valid.Valid(getListIntervalQuery) | ||
15 | + if err != nil { | ||
16 | + return err | ||
17 | + } | ||
18 | + if !b { | ||
19 | + for _, validErr := range valid.Errors { | ||
20 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
21 | + } | ||
22 | + } | ||
23 | + return nil | ||
24 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type ListListIntervalQuery struct { | ||
9 | + CompanyId int `json:"companyId"` // 公司id | ||
10 | + Offset int `json:"offset,omitempty"` // 查询偏离量 | ||
11 | + Limit int `json:"limit,omitempty"` // 查询限制 | ||
12 | + } | ||
13 | + | ||
14 | +func (listListIntervalQuery *ListListIntervalQuery) ValidateQuery() error { | ||
15 | + valid := validation.Validation{} | ||
16 | + b, err := valid.Valid(listListIntervalQuery) | ||
17 | + if err != nil { | ||
18 | + return err | ||
19 | + } | ||
20 | + if !b { | ||
21 | + for _, validErr := range valid.Errors { | ||
22 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
23 | + } | ||
24 | + } | ||
25 | + return nil | ||
26 | +} |
1 | +package service | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/linmadan/egglib-go/core/application" | ||
6 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
7 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" | ||
8 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/listInterval/command" | ||
9 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/listInterval/query" | ||
10 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | ||
11 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" | ||
12 | + "time" | ||
13 | +) | ||
14 | + | ||
15 | +type ListIntervalService struct { | ||
16 | +} | ||
17 | + | ||
18 | +// 创建排行榜时间 | ||
19 | +func (listIntervalService *ListIntervalService) CreateListInterval(createListIntervalCommand *command.CreateListIntervalCommand) (interface{}, error) { | ||
20 | + if err := createListIntervalCommand.ValidateCommand(); err != nil { | ||
21 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
22 | + } | ||
23 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
24 | + if err != nil { | ||
25 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
26 | + } | ||
27 | + if err := transactionContext.StartTransaction(); err != nil { | ||
28 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
29 | + } | ||
30 | + defer func() { | ||
31 | + transactionContext.RollbackTransaction() | ||
32 | + }() | ||
33 | + | ||
34 | + // 排行榜时间仓储初始化 | ||
35 | + var listIntervalRepository domain.ListIntervalRepository | ||
36 | + if value, err := factory.CreateListIntervalRepository(map[string]interface{}{ | ||
37 | + "transactionContext": transactionContext, | ||
38 | + }); err != nil { | ||
39 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
40 | + } else { | ||
41 | + listIntervalRepository = value | ||
42 | + } | ||
43 | + | ||
44 | + // 排行榜管理DAO初始化 | ||
45 | + var listIntervalDao *dao.ListIntervalDao | ||
46 | + if value, err := factory.CreateListIntervalDao(map[string]interface{}{ | ||
47 | + "transactionContext": transactionContext, | ||
48 | + }); err != nil { | ||
49 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
50 | + } else { | ||
51 | + listIntervalDao = value | ||
52 | + } | ||
53 | + | ||
54 | + // 获取当前最新排行榜时间 | ||
55 | + listListIntervalQuery := &query.ListListIntervalQuery { | ||
56 | + CompanyId: createListIntervalCommand.CompanyId, | ||
57 | + Offset: 0, | ||
58 | + Limit: 1, | ||
59 | + } | ||
60 | + | ||
61 | + // 获取上个年榜时间 | ||
62 | + _, listIntervals, err := listIntervalRepository.Find(tool_funs.SimpleStructToMap(listListIntervalQuery)) | ||
63 | + if err != nil { | ||
64 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
65 | + } | ||
66 | + | ||
67 | + startTime := time.Date(createListIntervalCommand.ListIntervalStartTime.Local().Year(), createListIntervalCommand.ListIntervalStartTime.Local().Month(), createListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local) | ||
68 | + endTime := time.Date(createListIntervalCommand.ListIntervalEndTime.Local().Year(), createListIntervalCommand.ListIntervalEndTime.Local().Month(), createListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local) | ||
69 | + | ||
70 | + // 判断年榜时间是否重叠 | ||
71 | + if len(listIntervals) > 0 { | ||
72 | + ok := listIntervalDao.RankPeriodCheckTime(startTime.Local().Unix(), endTime.Local().Unix(), 0, listIntervals[0].CompanyId) | ||
73 | + if !ok { | ||
74 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠") | ||
75 | + } | ||
76 | + } | ||
77 | + | ||
78 | + // 创建排行榜时间 | ||
79 | + newListInterval := &domain.ListInterval { | ||
80 | + CompanyId: createListIntervalCommand.CompanyId, | ||
81 | + IntervalStartTime: startTime, | ||
82 | + IntervalEndTime: endTime, | ||
83 | + } | ||
84 | + listInterval, err := listIntervalRepository.Save(newListInterval) | ||
85 | + if err != nil { | ||
86 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
87 | + } | ||
88 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
89 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
90 | + } | ||
91 | + return listInterval, nil | ||
92 | +} | ||
93 | + | ||
94 | +// 返回排行榜时间列表 | ||
95 | +func (listIntervalService *ListIntervalService) ListListInterval(listListIntervalQuery *query.ListListIntervalQuery) (interface{}, error) { | ||
96 | + if err := listListIntervalQuery.ValidateQuery(); err != nil { | ||
97 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
98 | + } | ||
99 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
100 | + if err != nil { | ||
101 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
102 | + } | ||
103 | + if err := transactionContext.StartTransaction(); err != nil { | ||
104 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
105 | + } | ||
106 | + defer func() { | ||
107 | + transactionContext.RollbackTransaction() | ||
108 | + }() | ||
109 | + | ||
110 | + var listIntervalRepository domain.ListIntervalRepository | ||
111 | + if value, err := factory.CreateListIntervalRepository(map[string]interface{}{ | ||
112 | + "transactionContext": transactionContext, | ||
113 | + }); err != nil { | ||
114 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
115 | + } else { | ||
116 | + listIntervalRepository = value | ||
117 | + } | ||
118 | + | ||
119 | + if count, listIntervals, err := listIntervalRepository.Find(tool_funs.SimpleStructToMap(listListIntervalQuery)); err != nil { | ||
120 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
121 | + } else { | ||
122 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
123 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
124 | + } | ||
125 | + return map[string]interface{}{ | ||
126 | + "count": count, | ||
127 | + "listIntervals": listIntervals, | ||
128 | + }, nil | ||
129 | + } | ||
130 | +} | ||
131 | + | ||
132 | +// 返回排行榜时间 | ||
133 | +func (listIntervalService *ListIntervalService) GetListInterval(getListIntervalQuery *query.GetListIntervalQuery) (interface{}, error) { | ||
134 | + if err := getListIntervalQuery.ValidateQuery(); err != nil { | ||
135 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
136 | + } | ||
137 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
138 | + if err != nil { | ||
139 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
140 | + } | ||
141 | + if err := transactionContext.StartTransaction(); err != nil { | ||
142 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
143 | + } | ||
144 | + defer func() { | ||
145 | + transactionContext.RollbackTransaction() | ||
146 | + }() | ||
147 | + | ||
148 | + var listIntervalRepository domain.ListIntervalRepository | ||
149 | + if value, err := factory.CreateListIntervalRepository(map[string]interface{}{ | ||
150 | + "transactionContext": transactionContext, | ||
151 | + }); err != nil { | ||
152 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
153 | + } else { | ||
154 | + listIntervalRepository = value | ||
155 | + } | ||
156 | + | ||
157 | + listInterval, err := listIntervalRepository.FindOne(map[string]interface{}{"listId": getListIntervalQuery.ListIntervalId}) | ||
158 | + if err != nil { | ||
159 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
160 | + } | ||
161 | + if listInterval == nil { | ||
162 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getListIntervalQuery.ListIntervalId))) | ||
163 | + } else { | ||
164 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
165 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
166 | + } | ||
167 | + return listInterval, nil | ||
168 | + } | ||
169 | +} | ||
170 | + | ||
171 | +// 更新排行榜时间 | ||
172 | +func (listIntervalService *ListIntervalService) UpdateListInterval(updateListIntervalCommand *command.UpdateListIntervalCommand) (interface{}, error) { | ||
173 | + if err := updateListIntervalCommand.ValidateCommand(); err != nil { | ||
174 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
175 | + } | ||
176 | + | ||
177 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
178 | + if err != nil { | ||
179 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
180 | + } | ||
181 | + if err := transactionContext.StartTransaction(); err != nil { | ||
182 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
183 | + } | ||
184 | + defer func() { | ||
185 | + transactionContext.RollbackTransaction() | ||
186 | + }() | ||
187 | + | ||
188 | + // 排行榜管理仓储初始化 | ||
189 | + var listIntervalRepository domain.ListIntervalRepository | ||
190 | + if value, err := factory.CreateListIntervalRepository(map[string]interface{}{ | ||
191 | + "transactionContext": transactionContext, | ||
192 | + }); err != nil { | ||
193 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
194 | + } else { | ||
195 | + listIntervalRepository = value | ||
196 | + } | ||
197 | + | ||
198 | + // 排行榜管理DAO初始化 | ||
199 | + var listIntervalDao *dao.ListIntervalDao | ||
200 | + if value, err := factory.CreateListIntervalDao(map[string]interface{}{ | ||
201 | + "transactionContext": transactionContext, | ||
202 | + }); err != nil { | ||
203 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
204 | + } else { | ||
205 | + listIntervalDao = value | ||
206 | + } | ||
207 | + | ||
208 | + // 获取当前年榜 | ||
209 | + listIntervalFound, err := listIntervalRepository.FindOne(map[string]interface{}{"listId": updateListIntervalCommand.ListIntervalId}) | ||
210 | + if err != nil { | ||
211 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
212 | + } | ||
213 | + if listIntervalFound == nil { | ||
214 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateListIntervalCommand.ListIntervalId))) | ||
215 | + } | ||
216 | + | ||
217 | + // 当前更新的开始结束时间 | ||
218 | + startTime := time.Date(updateListIntervalCommand.ListIntervalStartTime.Local().Year(), updateListIntervalCommand.ListIntervalStartTime.Local().Month(), updateListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local) | ||
219 | + endTime := time.Date(updateListIntervalCommand.ListIntervalEndTime.Local().Year(), updateListIntervalCommand.ListIntervalEndTime.Local().Month(), updateListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local) | ||
220 | + | ||
221 | + updateListIntervalCommand.ListIntervalStartTime = startTime | ||
222 | + updateListIntervalCommand.ListIntervalEndTime = endTime | ||
223 | + | ||
224 | + // 判断年榜时间是否重叠 | ||
225 | + ok := listIntervalDao.RankPeriodCheckTime(startTime.Unix(), endTime.Unix(), listIntervalFound.ListIntervalId, listIntervalFound.CompanyId) | ||
226 | + if !ok { | ||
227 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠") | ||
228 | + } | ||
229 | + | ||
230 | + // 更新年榜 | ||
231 | + if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil { | ||
232 | + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | ||
233 | + } | ||
234 | + if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil { | ||
235 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
236 | + } else { | ||
237 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
238 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
239 | + } | ||
240 | + return listIntervalUpdated, nil | ||
241 | + } | ||
242 | +} | ||
243 | + | ||
244 | +// 移除排行榜时间 | ||
245 | +func (listIntervalService *ListIntervalService) RemoveListInterval(removeListIntervalCommand *command.RemoveListIntervalCommand) (interface{}, error) { | ||
246 | + if err := removeListIntervalCommand.ValidateCommand(); err != nil { | ||
247 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
248 | + } | ||
249 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
250 | + if err != nil { | ||
251 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
252 | + } | ||
253 | + if err := transactionContext.StartTransaction(); err != nil { | ||
254 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
255 | + } | ||
256 | + defer func() { | ||
257 | + transactionContext.RollbackTransaction() | ||
258 | + }() | ||
259 | + | ||
260 | + var listIntervalRepository domain.ListIntervalRepository | ||
261 | + if value, err := factory.CreateListIntervalRepository(map[string]interface{}{ | ||
262 | + "transactionContext": transactionContext, | ||
263 | + }); err != nil { | ||
264 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
265 | + } else { | ||
266 | + listIntervalRepository = value | ||
267 | + } | ||
268 | + | ||
269 | + listInterval, err := listIntervalRepository.FindOne(map[string]interface{}{"listId": removeListIntervalCommand.ListIntervalId}) | ||
270 | + if err != nil { | ||
271 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
272 | + } | ||
273 | + if listInterval == nil { | ||
274 | + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeListIntervalCommand.ListIntervalId))) | ||
275 | + } | ||
276 | + | ||
277 | + if listInterval, err := listIntervalRepository.Remove(listInterval); err != nil { | ||
278 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
279 | + } else { | ||
280 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
281 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
282 | + } | ||
283 | + return listInterval, nil | ||
284 | + } | ||
285 | +} | ||
286 | + | ||
287 | +func NewListIntervalService(options map[string] interface{}) *ListIntervalService { | ||
288 | + newListIntervalService := &ListIntervalService{} | ||
289 | + return newListIntervalService | ||
290 | +} |
@@ -28,6 +28,7 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned | @@ -28,6 +28,7 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned | ||
28 | defer func() { | 28 | defer func() { |
29 | transactionContext.RollbackTransaction() | 29 | transactionContext.RollbackTransaction() |
30 | }() | 30 | }() |
31 | + | ||
31 | var notificationRepository domain.NotificationRepository | 32 | var notificationRepository domain.NotificationRepository |
32 | if value, err := factory.CreateNotificationRepository(map[string]interface{}{ | 33 | if value, err := factory.CreateNotificationRepository(map[string]interface{}{ |
33 | "transactionContext": transactionContext, | 34 | "transactionContext": transactionContext, |
@@ -36,6 +37,7 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned | @@ -36,6 +37,7 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned | ||
36 | } else { | 37 | } else { |
37 | notificationRepository = value | 38 | notificationRepository = value |
38 | } | 39 | } |
40 | + | ||
39 | var sentNotificationRepository domain.SentNotificationRepository | 41 | var sentNotificationRepository domain.SentNotificationRepository |
40 | if value, err := factory.CreateSentNotificationRepository(map[string]interface{}{ | 42 | if value, err := factory.CreateSentNotificationRepository(map[string]interface{}{ |
41 | "transactionContext": transactionContext, | 43 | "transactionContext": transactionContext, |
@@ -44,6 +46,7 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned | @@ -44,6 +46,7 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned | ||
44 | } else { | 46 | } else { |
45 | sentNotificationRepository = value | 47 | sentNotificationRepository = value |
46 | } | 48 | } |
49 | + | ||
47 | var taskDao *dao.TaskDao | 50 | var taskDao *dao.TaskDao |
48 | if value, err := factory.CreateTaskDao(map[string]interface{}{ | 51 | if value, err := factory.CreateTaskDao(map[string]interface{}{ |
49 | "transactionContext": transactionContext, | 52 | "transactionContext": transactionContext, |
@@ -52,6 +55,13 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned | @@ -52,6 +55,13 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned | ||
52 | } else { | 55 | } else { |
53 | taskDao = value | 56 | taskDao = value |
54 | } | 57 | } |
58 | + | ||
59 | + // 更新已过期竞标任务状态 | ||
60 | + if err := taskDao.UpdateExpiredPlannedCompletionTimeBidTask(); err != nil { | ||
61 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
62 | + } | ||
63 | + | ||
64 | + // 返回快过期任务并发送消息 | ||
55 | if tasks, err := taskDao.ListNearThePlannedCompletionTimeTask(); err != nil { | 65 | if tasks, err := taskDao.ListNearThePlannedCompletionTimeTask(); err != nil { |
56 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 66 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
57 | } else { | 67 | } else { |
@@ -88,6 +98,7 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned | @@ -88,6 +98,7 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned | ||
88 | } | 98 | } |
89 | } | 99 | } |
90 | } | 100 | } |
101 | + | ||
91 | if err := transactionContext.CommitTransaction(); err != nil { | 102 | if err := transactionContext.CommitTransaction(); err != nil { |
92 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 103 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
93 | } else { | 104 | } else { |
@@ -108,6 +119,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime | @@ -108,6 +119,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime | ||
108 | defer func() { | 119 | defer func() { |
109 | transactionContext.RollbackTransaction() | 120 | transactionContext.RollbackTransaction() |
110 | }() | 121 | }() |
122 | + | ||
111 | var notificationRepository domain.NotificationRepository | 123 | var notificationRepository domain.NotificationRepository |
112 | if value, err := factory.CreateNotificationRepository(map[string]interface{}{ | 124 | if value, err := factory.CreateNotificationRepository(map[string]interface{}{ |
113 | "transactionContext": transactionContext, | 125 | "transactionContext": transactionContext, |
@@ -116,6 +128,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime | @@ -116,6 +128,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime | ||
116 | } else { | 128 | } else { |
117 | notificationRepository = value | 129 | notificationRepository = value |
118 | } | 130 | } |
131 | + | ||
119 | var sentNotificationRepository domain.SentNotificationRepository | 132 | var sentNotificationRepository domain.SentNotificationRepository |
120 | if value, err := factory.CreateSentNotificationRepository(map[string]interface{}{ | 133 | if value, err := factory.CreateSentNotificationRepository(map[string]interface{}{ |
121 | "transactionContext": transactionContext, | 134 | "transactionContext": transactionContext, |
@@ -124,6 +137,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime | @@ -124,6 +137,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime | ||
124 | } else { | 137 | } else { |
125 | sentNotificationRepository = value | 138 | sentNotificationRepository = value |
126 | } | 139 | } |
140 | + | ||
127 | var taskDao *dao.TaskDao | 141 | var taskDao *dao.TaskDao |
128 | if value, err := factory.CreateTaskDao(map[string]interface{}{ | 142 | if value, err := factory.CreateTaskDao(map[string]interface{}{ |
129 | "transactionContext": transactionContext, | 143 | "transactionContext": transactionContext, |
@@ -132,6 +146,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime | @@ -132,6 +146,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime | ||
132 | } else { | 146 | } else { |
133 | taskDao = value | 147 | taskDao = value |
134 | } | 148 | } |
149 | + | ||
135 | if tasks, err := taskDao.ListNearBidEndTimeTask(); err != nil { | 150 | if tasks, err := taskDao.ListNearBidEndTimeTask(); err != nil { |
136 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 151 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
137 | } else { | 152 | } else { |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | + "time" | ||
7 | +) | ||
8 | + | ||
9 | +type EmployeesContributionsStatisticsCommand struct { | ||
10 | + CompanyId int `json:"companyId" valid:"Required"` // 公司id | ||
11 | + StartTime time.Time `json:"startTime"` // 年榜开始时间 | ||
12 | + EndTime time.Time `json:"endTime"` // 年榜结束时间 | ||
13 | +} | ||
14 | + | ||
15 | +func (employeesContributionsStatisticsCommand *EmployeesContributionsStatisticsCommand) ValidateCommand() error { | ||
16 | + valid := validation.Validation{} | ||
17 | + b, err := valid.Valid(employeesContributionsStatisticsCommand) | ||
18 | + if err != nil { | ||
19 | + return err | ||
20 | + } | ||
21 | + if !b { | ||
22 | + for _, validErr := range valid.Errors { | ||
23 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
24 | + } | ||
25 | + } | ||
26 | + return nil | ||
27 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "time" | ||
6 | + | ||
7 | + "github.com/astaxie/beego/validation" | ||
8 | +) | ||
9 | + | ||
10 | +type EmployeesSuMoneyStatisticsCommand struct { | ||
11 | + CompanyId int `json:"companyId" valid:"Required"` // 公司id | ||
12 | + StartTime time.Time `json:"startTime"` // 年榜开始时间 | ||
13 | + EndTime time.Time `json:"endTime"` // 年榜结束时间 | ||
14 | +} | ||
15 | + | ||
16 | +func (employeesSuMoneyStatisticsCommand *EmployeesSuMoneyStatisticsCommand) ValidateCommand() error { | ||
17 | + valid := validation.Validation{} | ||
18 | + b, err := valid.Valid(employeesSuMoneyStatisticsCommand) | ||
19 | + if err != nil { | ||
20 | + return err | ||
21 | + } | ||
22 | + if !b { | ||
23 | + for _, validErr := range valid.Errors { | ||
24 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
25 | + } | ||
26 | + } | ||
27 | + return nil | ||
28 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | + "time" | ||
7 | +) | ||
8 | + | ||
9 | +type EmployeesRankingListStatisticsCommand struct { | ||
10 | + CompanyId int `json:"companyId" valid:"Required"` // 公司id | ||
11 | + StartTime time.Time `json:"startTime"` // 年榜开始时间 | ||
12 | + EndTime time.Time `json:"endTime"` // 年榜结束时间 | ||
13 | + Offset int `json:"offset,omitempty"` // 查询偏离量 | ||
14 | + Limit int `json:"limit,omitempty"` // 查询限制 | ||
15 | +} | ||
16 | + | ||
17 | +func (employeesRankingListStatisticsCommand *EmployeesRankingListStatisticsCommand) ValidateCommand() error { | ||
18 | + valid := validation.Validation{} | ||
19 | + b, err := valid.Valid(employeesRankingListStatisticsCommand) | ||
20 | + if err != nil { | ||
21 | + return err | ||
22 | + } | ||
23 | + if !b { | ||
24 | + for _, validErr := range valid.Errors { | ||
25 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
26 | + } | ||
27 | + } | ||
28 | + return nil | ||
29 | +} | ||
30 | + |
@@ -9,6 +9,7 @@ import ( | @@ -9,6 +9,7 @@ import ( | ||
9 | type PersonTaskStatisticsCommand struct { | 9 | type PersonTaskStatisticsCommand struct { |
10 | // 统一用户UID | 10 | // 统一用户UID |
11 | Uid int64 `json:"uid" valid:"Required"` | 11 | Uid int64 `json:"uid" valid:"Required"` |
12 | + CompanyId int `json:"companyId" valid:"Required"` | ||
12 | } | 13 | } |
13 | 14 | ||
14 | func (personTaskStatisticsCommand *PersonTaskStatisticsCommand) ValidateCommand() error { | 15 | func (personTaskStatisticsCommand *PersonTaskStatisticsCommand) ValidateCommand() error { |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + | ||
6 | + "github.com/astaxie/beego/validation" | ||
7 | +) | ||
8 | + | ||
9 | +// 获取系统现金值 | ||
10 | +type SystemCashStatisticsCommand struct { | ||
11 | + CompanyId int64 `json:"companyId" valid:"Required"` // 公司ID | ||
12 | +} | ||
13 | + | ||
14 | +func (systemCashStatisticsCommand *SystemCashStatisticsCommand) ValidateCommand() error { | ||
15 | + valid := validation.Validation{} | ||
16 | + b, err := valid.Valid(systemCashStatisticsCommand) | ||
17 | + if err != nil { | ||
18 | + return err | ||
19 | + } | ||
20 | + if !b { | ||
21 | + for _, validErr := range valid.Errors { | ||
22 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
23 | + } | ||
24 | + } | ||
25 | + return nil | ||
26 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +// 获取系统素币值 | ||
9 | +type SystemSuMoneyStatisticsCommand struct { | ||
10 | + CompanyId int64 `json:"companyId" valid:"Required"` // 公司ID | ||
11 | +} | ||
12 | + | ||
13 | +func (systemSuMoneyStatisticsCommand *SystemSuMoneyStatisticsCommand) ValidateCommand() error { | ||
14 | + valid := validation.Validation{} | ||
15 | + b, err := valid.Valid(systemSuMoneyStatisticsCommand) | ||
16 | + if err != nil { | ||
17 | + return err | ||
18 | + } | ||
19 | + if !b { | ||
20 | + for _, validErr := range valid.Errors { | ||
21 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
22 | + } | ||
23 | + } | ||
24 | + return nil | ||
25 | +} | ||
26 | + |
@@ -2,10 +2,13 @@ package service | @@ -2,10 +2,13 @@ package service | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "github.com/linmadan/egglib-go/core/application" | 4 | "github.com/linmadan/egglib-go/core/application" |
5 | + "github.com/linmadan/egglib-go/utils/tool_funs" | ||
5 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" | 6 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory" |
6 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/statistics/command" | 7 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/statistics/command" |
8 | + "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query" | ||
7 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | 9 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" |
8 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" | 10 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" |
11 | + "time" | ||
9 | ) | 12 | ) |
10 | 13 | ||
11 | // 数据统计服务 | 14 | // 数据统计服务 |
@@ -27,6 +30,7 @@ func (statisticsService *StatisticsService) PersonNotificationStatistics(personN | @@ -27,6 +30,7 @@ func (statisticsService *StatisticsService) PersonNotificationStatistics(personN | ||
27 | defer func() { | 30 | defer func() { |
28 | transactionContext.RollbackTransaction() | 31 | transactionContext.RollbackTransaction() |
29 | }() | 32 | }() |
33 | + | ||
30 | var employeeDao *dao.EmployeeDao | 34 | var employeeDao *dao.EmployeeDao |
31 | if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | 35 | if value, err := factory.CreateEmployeeDao(map[string]interface{}{ |
32 | "transactionContext": transactionContext, | 36 | "transactionContext": transactionContext, |
@@ -35,6 +39,7 @@ func (statisticsService *StatisticsService) PersonNotificationStatistics(personN | @@ -35,6 +39,7 @@ func (statisticsService *StatisticsService) PersonNotificationStatistics(personN | ||
35 | } else { | 39 | } else { |
36 | employeeDao = value | 40 | employeeDao = value |
37 | } | 41 | } |
42 | + | ||
38 | var employeeRepository domain.EmployeeRepository | 43 | var employeeRepository domain.EmployeeRepository |
39 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ | 44 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ |
40 | "transactionContext": transactionContext, | 45 | "transactionContext": transactionContext, |
@@ -43,6 +48,7 @@ func (statisticsService *StatisticsService) PersonNotificationStatistics(personN | @@ -43,6 +48,7 @@ func (statisticsService *StatisticsService) PersonNotificationStatistics(personN | ||
43 | } else { | 48 | } else { |
44 | employeeRepository = value | 49 | employeeRepository = value |
45 | } | 50 | } |
51 | + | ||
46 | employee, err := employeeRepository.FindOne(map[string]interface{}{ | 52 | employee, err := employeeRepository.FindOne(map[string]interface{}{ |
47 | "uid": personNotificationStatisticsCommand.Uid, | 53 | "uid": personNotificationStatisticsCommand.Uid, |
48 | }) | 54 | }) |
@@ -52,6 +58,7 @@ func (statisticsService *StatisticsService) PersonNotificationStatistics(personN | @@ -52,6 +58,7 @@ func (statisticsService *StatisticsService) PersonNotificationStatistics(personN | ||
52 | if employee == nil { | 58 | if employee == nil { |
53 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业员工") | 59 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业员工") |
54 | } | 60 | } |
61 | + | ||
55 | if personNotificationStatistics, err := employeeDao.CalculatePersonUnReadNotification(personNotificationStatisticsCommand.Uid); err != nil { | 62 | if personNotificationStatistics, err := employeeDao.CalculatePersonUnReadNotification(personNotificationStatisticsCommand.Uid); err != nil { |
56 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 63 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
57 | } else { | 64 | } else { |
@@ -77,6 +84,7 @@ func (statisticsService *StatisticsService) SystemTaskStatistics(systemTaskStati | @@ -77,6 +84,7 @@ func (statisticsService *StatisticsService) SystemTaskStatistics(systemTaskStati | ||
77 | defer func() { | 84 | defer func() { |
78 | transactionContext.RollbackTransaction() | 85 | transactionContext.RollbackTransaction() |
79 | }() | 86 | }() |
87 | + | ||
80 | var taskDao *dao.TaskDao | 88 | var taskDao *dao.TaskDao |
81 | if value, err := factory.CreateTaskDao(map[string]interface{}{ | 89 | if value, err := factory.CreateTaskDao(map[string]interface{}{ |
82 | "transactionContext": transactionContext, | 90 | "transactionContext": transactionContext, |
@@ -85,6 +93,7 @@ func (statisticsService *StatisticsService) SystemTaskStatistics(systemTaskStati | @@ -85,6 +93,7 @@ func (statisticsService *StatisticsService) SystemTaskStatistics(systemTaskStati | ||
85 | } else { | 93 | } else { |
86 | taskDao = value | 94 | taskDao = value |
87 | } | 95 | } |
96 | + | ||
88 | if systemTaskStatistics, err := taskDao.CalculateSystemTask(systemTaskStatisticsCommand.CompanyId); err != nil { | 97 | if systemTaskStatistics, err := taskDao.CalculateSystemTask(systemTaskStatisticsCommand.CompanyId); err != nil { |
89 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 98 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
90 | } else { | 99 | } else { |
@@ -110,6 +119,7 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati | @@ -110,6 +119,7 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati | ||
110 | defer func() { | 119 | defer func() { |
111 | transactionContext.RollbackTransaction() | 120 | transactionContext.RollbackTransaction() |
112 | }() | 121 | }() |
122 | + | ||
113 | var taskDao *dao.TaskDao | 123 | var taskDao *dao.TaskDao |
114 | if value, err := factory.CreateTaskDao(map[string]interface{}{ | 124 | if value, err := factory.CreateTaskDao(map[string]interface{}{ |
115 | "transactionContext": transactionContext, | 125 | "transactionContext": transactionContext, |
@@ -118,6 +128,7 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati | @@ -118,6 +128,7 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati | ||
118 | } else { | 128 | } else { |
119 | taskDao = value | 129 | taskDao = value |
120 | } | 130 | } |
131 | + | ||
121 | var employeeRepository domain.EmployeeRepository | 132 | var employeeRepository domain.EmployeeRepository |
122 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ | 133 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ |
123 | "transactionContext": transactionContext, | 134 | "transactionContext": transactionContext, |
@@ -126,6 +137,7 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati | @@ -126,6 +137,7 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati | ||
126 | } else { | 137 | } else { |
127 | employeeRepository = value | 138 | employeeRepository = value |
128 | } | 139 | } |
140 | + | ||
129 | employee, err := employeeRepository.FindOne(map[string]interface{}{ | 141 | employee, err := employeeRepository.FindOne(map[string]interface{}{ |
130 | "uid": personTaskStatisticsCommand.Uid, | 142 | "uid": personTaskStatisticsCommand.Uid, |
131 | }) | 143 | }) |
@@ -135,7 +147,8 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati | @@ -135,7 +147,8 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati | ||
135 | if employee == nil { | 147 | if employee == nil { |
136 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业员工") | 148 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业员工") |
137 | } | 149 | } |
138 | - if personTaskStatistics, err := taskDao.CalculatePersonTask(personTaskStatisticsCommand.Uid); err != nil { | 150 | + |
151 | + if personTaskStatistics, err := taskDao.CalculatePersonTask(personTaskStatisticsCommand.Uid, personTaskStatisticsCommand.CompanyId); err != nil { | ||
139 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 152 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
140 | } else { | 153 | } else { |
141 | if err := transactionContext.CommitTransaction(); err != nil { | 154 | if err := transactionContext.CommitTransaction(); err != nil { |
@@ -160,6 +173,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone | @@ -160,6 +173,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone | ||
160 | defer func() { | 173 | defer func() { |
161 | transactionContext.RollbackTransaction() | 174 | transactionContext.RollbackTransaction() |
162 | }() | 175 | }() |
176 | + | ||
163 | var employeeDao *dao.EmployeeDao | 177 | var employeeDao *dao.EmployeeDao |
164 | if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | 178 | if value, err := factory.CreateEmployeeDao(map[string]interface{}{ |
165 | "transactionContext": transactionContext, | 179 | "transactionContext": transactionContext, |
@@ -168,6 +182,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone | @@ -168,6 +182,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone | ||
168 | } else { | 182 | } else { |
169 | employeeDao = value | 183 | employeeDao = value |
170 | } | 184 | } |
185 | + | ||
171 | var employeeRepository domain.EmployeeRepository | 186 | var employeeRepository domain.EmployeeRepository |
172 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ | 187 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ |
173 | "transactionContext": transactionContext, | 188 | "transactionContext": transactionContext, |
@@ -176,6 +191,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone | @@ -176,6 +191,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone | ||
176 | } else { | 191 | } else { |
177 | employeeRepository = value | 192 | employeeRepository = value |
178 | } | 193 | } |
194 | + | ||
179 | employee, err := employeeRepository.FindOne(map[string]interface{}{ | 195 | employee, err := employeeRepository.FindOne(map[string]interface{}{ |
180 | "uid": personSuMoneyStatisticsCommand.Uid, | 196 | "uid": personSuMoneyStatisticsCommand.Uid, |
181 | }) | 197 | }) |
@@ -185,6 +201,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone | @@ -185,6 +201,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone | ||
185 | if employee == nil { | 201 | if employee == nil { |
186 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业员工") | 202 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业员工") |
187 | } | 203 | } |
204 | + | ||
188 | if personSuMoneyStatistics, err := employeeDao.CalculatePersonSuMoney(personSuMoneyStatisticsCommand.Uid); err != nil { | 205 | if personSuMoneyStatistics, err := employeeDao.CalculatePersonSuMoney(personSuMoneyStatisticsCommand.Uid); err != nil { |
189 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 206 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
190 | } else { | 207 | } else { |
@@ -196,6 +213,327 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone | @@ -196,6 +213,327 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone | ||
196 | } | 213 | } |
197 | } | 214 | } |
198 | 215 | ||
216 | +// 获取系统素币统计 | ||
217 | +func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMoneyStatisticsCommand *command.SystemSuMoneyStatisticsCommand) (interface{}, error) { | ||
218 | + if err := systemSuMoneyStatisticsCommand.ValidateCommand(); err != nil { | ||
219 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
220 | + } | ||
221 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
222 | + if err != nil { | ||
223 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
224 | + } | ||
225 | + if err := transactionContext.StartTransaction(); err != nil { | ||
226 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
227 | + } | ||
228 | + defer func() { | ||
229 | + transactionContext.RollbackTransaction() | ||
230 | + }() | ||
231 | + | ||
232 | + var employeeDao *dao.EmployeeDao | ||
233 | + if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | ||
234 | + "transactionContext": transactionContext, | ||
235 | + }); err != nil { | ||
236 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
237 | + } else { | ||
238 | + employeeDao = value | ||
239 | + } | ||
240 | + | ||
241 | + if systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(systemSuMoneyStatisticsCommand.CompanyId); err != nil { | ||
242 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
243 | + } else { | ||
244 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
245 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
246 | + } | ||
247 | + return systemSuMoneyStatistics, nil | ||
248 | + } | ||
249 | +} | ||
250 | + | ||
251 | +// 获取系统现金统计 | ||
252 | +func (statisticsService *StatisticsService) SystemCashStatistics(systemCashStatisticsCommand *command.SystemCashStatisticsCommand) (interface{}, error) { | ||
253 | + if err := systemCashStatisticsCommand.ValidateCommand(); err != nil { | ||
254 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
255 | + } | ||
256 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
257 | + if err != nil { | ||
258 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
259 | + } | ||
260 | + if err := transactionContext.StartTransaction(); err != nil { | ||
261 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
262 | + } | ||
263 | + defer func() { | ||
264 | + transactionContext.RollbackTransaction() | ||
265 | + }() | ||
266 | + | ||
267 | + var employeeDao *dao.EmployeeDao | ||
268 | + if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | ||
269 | + "transactionContext": transactionContext, | ||
270 | + }); err != nil { | ||
271 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
272 | + } else { | ||
273 | + employeeDao = value | ||
274 | + } | ||
275 | + | ||
276 | + // 判断现金池是否存在 | ||
277 | + var cashPoolRepository domain.CashPoolRepository | ||
278 | + if value, err := factory.CreateCashPoolRepository(map[string] interface{} { | ||
279 | + "transactionContext": transactionContext, | ||
280 | + }); err != nil { | ||
281 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
282 | + } else { | ||
283 | + cashPoolRepository = value | ||
284 | + } | ||
285 | + | ||
286 | + countCashPools, _, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(systemCashStatisticsCommand)) | ||
287 | + if err != nil { | ||
288 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
289 | + } | ||
290 | + if countCashPools == 0 { // 现金池为空时处理 | ||
291 | + return map[string]interface{} { | ||
292 | + "systemExchangedCash" : 0, | ||
293 | + "systemUnExchangeCash": 0, | ||
294 | + }, nil | ||
295 | + } | ||
296 | + | ||
297 | + if systemCashStatistics, err := employeeDao.CalculateSystemCash(systemCashStatisticsCommand.CompanyId); err != nil { | ||
298 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
299 | + } else { | ||
300 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
301 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
302 | + } | ||
303 | + return systemCashStatistics, nil | ||
304 | + } | ||
305 | +} | ||
306 | + | ||
307 | +// 获取公司员工财富值分组统计 | ||
308 | +func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employeesSuMoneyStatisticsCommand *command.EmployeesSuMoneyStatisticsCommand) (interface{}, error) { | ||
309 | + if err := employeesSuMoneyStatisticsCommand.ValidateCommand(); err != nil { | ||
310 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
311 | + } | ||
312 | + | ||
313 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
314 | + if err != nil { | ||
315 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
316 | + } | ||
317 | + if err := transactionContext.StartTransaction(); err != nil { | ||
318 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
319 | + } | ||
320 | + defer func() { | ||
321 | + transactionContext.RollbackTransaction() | ||
322 | + }() | ||
323 | + | ||
324 | + var employeeDao *dao.EmployeeDao | ||
325 | + if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | ||
326 | + "transactionContext": transactionContext, | ||
327 | + }); err != nil { | ||
328 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
329 | + } else { | ||
330 | + employeeDao = value | ||
331 | + } | ||
332 | + | ||
333 | + if employeesSuMoneyStatisticsCommand.StartTime.IsZero() && employeesSuMoneyStatisticsCommand.EndTime.IsZero() { | ||
334 | + employeesSuMoneyStatisticsCommand.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location()) | ||
335 | + employeesSuMoneyStatisticsCommand.EndTime = time.Now().Local() | ||
336 | + } | ||
337 | + | ||
338 | + if employeesSuMoneyStatistics, err := employeeDao.CalculateEmployeesSuMoney(employeesSuMoneyStatisticsCommand.CompanyId, employeesSuMoneyStatisticsCommand.StartTime, employeesSuMoneyStatisticsCommand.EndTime); err != nil { | ||
339 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
340 | + } else { | ||
341 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
342 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
343 | + } | ||
344 | + return employeesSuMoneyStatistics, nil | ||
345 | + } | ||
346 | +} | ||
347 | + | ||
348 | +// 获取公司员工贡献值分组统计 | ||
349 | +func (statisticsService *StatisticsService) EmployeesContributionsStatistics(employeesContributionsStatisticsCommand *command.EmployeesContributionsStatisticsCommand) (interface{}, error) { | ||
350 | + if err := employeesContributionsStatisticsCommand.ValidateCommand(); err != nil { | ||
351 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
352 | + } | ||
353 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
354 | + if err != nil { | ||
355 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
356 | + } | ||
357 | + if err := transactionContext.StartTransaction(); err != nil { | ||
358 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
359 | + } | ||
360 | + defer func() { | ||
361 | + transactionContext.RollbackTransaction() | ||
362 | + }() | ||
363 | + | ||
364 | + var employeeDao *dao.EmployeeDao | ||
365 | + if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | ||
366 | + "transactionContext": transactionContext, | ||
367 | + }); err != nil { | ||
368 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
369 | + } else { | ||
370 | + employeeDao = value | ||
371 | + } | ||
372 | + | ||
373 | + if employeesContributionsStatisticsCommand.StartTime.IsZero() && employeesContributionsStatisticsCommand.EndTime.IsZero() { | ||
374 | + employeesContributionsStatisticsCommand.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location()) | ||
375 | + employeesContributionsStatisticsCommand.EndTime = time.Now().Local() | ||
376 | + } | ||
377 | + | ||
378 | + if employeesContributionsStatistics, err := employeeDao.CalculateEmployeesContributions(employeesContributionsStatisticsCommand.CompanyId, employeesContributionsStatisticsCommand.StartTime, employeesContributionsStatisticsCommand.EndTime); err != nil { | ||
379 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
380 | + } else { | ||
381 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
382 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
383 | + } | ||
384 | + return employeesContributionsStatistics, nil | ||
385 | + } | ||
386 | +} | ||
387 | + | ||
388 | +// 贡献值、财富值榜单 | ||
389 | +func (statisticsService *StatisticsService) ContributionsWealthRanking(contributionsWealthRankingQuery *query.ContributionsWealthRankingQuery) (interface{}, error) { | ||
390 | + if err := contributionsWealthRankingQuery.ValidateQuery(); err != nil { | ||
391 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
392 | + } | ||
393 | + | ||
394 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
395 | + if err != nil { | ||
396 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
397 | + } | ||
398 | + if err := transactionContext.StartTransaction(); err != nil { | ||
399 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
400 | + } | ||
401 | + defer func() { | ||
402 | + transactionContext.RollbackTransaction() | ||
403 | + }() | ||
404 | + | ||
405 | + // 员工仓储初始化 | ||
406 | + var employeeRepository domain.EmployeeRepository | ||
407 | + if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ | ||
408 | + "transactionContext": transactionContext, | ||
409 | + }); err != nil { | ||
410 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
411 | + } else { | ||
412 | + employeeRepository = value | ||
413 | + } | ||
414 | + | ||
415 | + // 员工DAO初始化 | ||
416 | + var employeeDao *dao.EmployeeDao | ||
417 | + if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | ||
418 | + "transactionContext": transactionContext, | ||
419 | + }); err != nil { | ||
420 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
421 | + } else { | ||
422 | + employeeDao = value | ||
423 | + } | ||
424 | + | ||
425 | + if contributionsWealthRankingQuery.RankingType == 1 { // 返回总榜 | ||
426 | + contributionsWealthRankingQuery.StartTime = time.Date(0001, 01, 01, 0, 0, 0, 0, time.UTC) | ||
427 | + contributionsWealthRankingQuery.EndTime = time.Date(0001, 01, 01, 0, 0, 0, 0, time.UTC) | ||
428 | + } else if contributionsWealthRankingQuery.RankingType == 2 { // 返回年榜 | ||
429 | + // 获取公司最新年榜 | ||
430 | + var listIntervalRepository domain.ListIntervalRepository | ||
431 | + if value, err := factory.CreateListIntervalRepository(map[string]interface{}{ | ||
432 | + "transactionContext": transactionContext, | ||
433 | + }); err != nil { | ||
434 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
435 | + } else { | ||
436 | + listIntervalRepository = value | ||
437 | + } | ||
438 | + | ||
439 | + listListIntervalQuery := map[string]interface{} { | ||
440 | + "companyId": contributionsWealthRankingQuery.CompanyId, | ||
441 | + } | ||
442 | + | ||
443 | + if _, listIntervals, err := listIntervalRepository.FindAll(listListIntervalQuery); err != nil { | ||
444 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
445 | + } else { | ||
446 | + if len(listIntervals) == 0 { // 未配置年榜 | ||
447 | + contributionsWealthRankingQuery.StartTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local) | ||
448 | + contributionsWealthRankingQuery.EndTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local) | ||
449 | + } else if len(listIntervals) == 1 { // 只配置了一个年榜 | ||
450 | + currentTime := time.Now().Unix() | ||
451 | + if currentTime >= listIntervals[0].IntervalStartTime.Unix() && currentTime <= listIntervals[0].IntervalEndTime.Unix() { | ||
452 | + contributionsWealthRankingQuery.StartTime = listIntervals[0].IntervalStartTime | ||
453 | + contributionsWealthRankingQuery.EndTime = listIntervals[0].IntervalEndTime | ||
454 | + } else { // 当前时间处于空档期 | ||
455 | + contributionsWealthRankingQuery.StartTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local) | ||
456 | + contributionsWealthRankingQuery.EndTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local) | ||
457 | + } | ||
458 | + } else if len(listIntervals) > 1 { // 配置了多个年榜,判断当前时间是否在榜单里 | ||
459 | + currentTime := time.Now().Unix() | ||
460 | + for _, listInterval := range listIntervals { | ||
461 | + if currentTime >= listInterval.IntervalStartTime.Unix() && currentTime <= listInterval.IntervalEndTime.Unix() { | ||
462 | + contributionsWealthRankingQuery.StartTime = listInterval.IntervalStartTime | ||
463 | + contributionsWealthRankingQuery.EndTime = listInterval.IntervalEndTime | ||
464 | + break | ||
465 | + } else { // 当前时间处于空档期 | ||
466 | + contributionsWealthRankingQuery.StartTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local) | ||
467 | + contributionsWealthRankingQuery.EndTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local) | ||
468 | + continue | ||
469 | + } | ||
470 | + } | ||
471 | + } else { | ||
472 | + contributionsWealthRankingQuery.StartTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local) | ||
473 | + contributionsWealthRankingQuery.EndTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local) | ||
474 | + } | ||
475 | + } | ||
476 | + } | ||
477 | + | ||
478 | + // 默认返回总榜 | ||
479 | + if contributionsWealthRankingStatistics, err := employeeDao.ContributionsWealthRanking(tool_funs.SimpleStructToMap(contributionsWealthRankingQuery)); err != nil { | ||
480 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
481 | + } else { | ||
482 | + uidName := map[int64]interface{}{} | ||
483 | + if _, employees, err := employeeRepository.FindAll(map[string]interface{}{ | ||
484 | + "companyId": contributionsWealthRankingQuery.CompanyId, | ||
485 | + }); err != nil { | ||
486 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
487 | + } else { | ||
488 | + for _, employee := range employees { | ||
489 | + uidName[employee.EmployeeInfo.Uid] = employee.EmployeeInfo.EmployeeName | ||
490 | + } | ||
491 | + } | ||
492 | + | ||
493 | + // 财富值排行榜 | ||
494 | + for i, _ := range contributionsWealthRankingStatistics.(map[string]interface{})["employeesWealth"].([]struct{Uid int64;EmployeeName string;EmployeeSuMoney float64;Ranking int}) { | ||
495 | + uid := contributionsWealthRankingStatistics.(map[string]interface{})["employeesWealth"].([]struct{Uid int64;EmployeeName string;EmployeeSuMoney float64;Ranking int})[i].Uid | ||
496 | + if uidName[uid] != nil { | ||
497 | + contributionsWealthRankingStatistics.(map[string]interface{})["employeesWealth"].([]struct{Uid int64;EmployeeName string;EmployeeSuMoney float64;Ranking int})[i].EmployeeName = uidName[uid].(string) | ||
498 | + } | ||
499 | + } | ||
500 | + | ||
501 | + // 个人财富值 | ||
502 | + if contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeWealth"] != nil { | ||
503 | + currentEmployeeWealth := contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeWealth"].(struct{Uid int64;EmployeeName string;EmployeeSuMoney float64;Ranking int}) | ||
504 | + uidWealth := contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeWealth"].(struct{Uid int64;EmployeeName string;EmployeeSuMoney float64;Ranking int}).Uid | ||
505 | + if uidName[uidWealth] != nil { | ||
506 | + currentEmployeeWealth.EmployeeName = uidName[uidWealth].(string) | ||
507 | + } | ||
508 | + contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeWealth"] = currentEmployeeWealth | ||
509 | + } | ||
510 | + | ||
511 | + // 贡献值排行版 | ||
512 | + for i, _ := range contributionsWealthRankingStatistics.(map[string]interface{})["employeesContributions"].([]struct { Uid int64; EmployeeName string; EmployeesContributions float64; Ranking int }) { | ||
513 | + uid := contributionsWealthRankingStatistics.(map[string]interface{})["employeesContributions"].([]struct{Uid int64;EmployeeName string;EmployeesContributions float64;Ranking int})[i].Uid | ||
514 | + if uidName[uid] != nil { | ||
515 | + contributionsWealthRankingStatistics.(map[string]interface{})["employeesContributions"].([]struct{Uid int64;EmployeeName string;EmployeesContributions float64;Ranking int})[i].EmployeeName = uidName[uid].(string) | ||
516 | + } | ||
517 | + } | ||
518 | + | ||
519 | + // 个人贡献值 | ||
520 | + if contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeContributions"] != nil { | ||
521 | + currentEmployeeContributions := contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeContributions"].(struct{Uid int64;EmployeeName string;EmployeesContributions float64;Ranking int}) | ||
522 | + uidContributions := contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeContributions"].(struct{Uid int64;EmployeeName string;EmployeesContributions float64;Ranking int}).Uid | ||
523 | + if uidName[uidContributions] != nil { | ||
524 | + currentEmployeeContributions.EmployeeName = uidName[uidContributions].(string) | ||
525 | + } | ||
526 | + contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeContributions"] = currentEmployeeContributions | ||
527 | + } | ||
528 | + | ||
529 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
530 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
531 | + } | ||
532 | + | ||
533 | + return contributionsWealthRankingStatistics, nil | ||
534 | + } | ||
535 | +} | ||
536 | + | ||
199 | func NewStatisticsService(options map[string]interface{}) *StatisticsService { | 537 | func NewStatisticsService(options map[string]interface{}) *StatisticsService { |
200 | newStatisticsService := &StatisticsService{} | 538 | newStatisticsService := &StatisticsService{} |
201 | return newStatisticsService | 539 | return newStatisticsService |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | + "time" | ||
7 | +) | ||
8 | + | ||
9 | +type ContributionsTransactionRecordStatisticsCommand struct { | ||
10 | + // 统一用户UID | ||
11 | + Uid int64 `json:"uid" valid:"Required"` | ||
12 | + // 事务时间区间-开始时间 | ||
13 | + TransactionStartTime time.Time `json:"transactionStartTime,omitempty"` | ||
14 | + // 事务时间区间-截止时间 | ||
15 | + TransactionEndTime time.Time `json:"transactionEndTime,omitempty"` | ||
16 | +} | ||
17 | + | ||
18 | +func (contributionsTransactionRecordStatisticsCommand *ContributionsTransactionRecordStatisticsCommand) ValidateCommand() error { | ||
19 | + valid := validation.Validation{} | ||
20 | + b, err := valid.Valid(contributionsTransactionRecordStatisticsCommand) | ||
21 | + if err != nil { | ||
22 | + return err | ||
23 | + } | ||
24 | + if !b { | ||
25 | + for _, validErr := range valid.Errors { | ||
26 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
27 | + } | ||
28 | + } | ||
29 | + return nil | ||
30 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + | ||
6 | + "github.com/astaxie/beego/validation" | ||
7 | +) | ||
8 | + | ||
9 | +// 创建现金池 | ||
10 | +type CreateCashPoolCommand struct { | ||
11 | + CompanyId int64 `json:"companyId" valid:"Required"` // 公司ID | ||
12 | + Cash float64 `json:"cash" valid:"Required"` // 投入的现金值 | ||
13 | +} | ||
14 | + | ||
15 | +func (createCashPoolCommand *CreateCashPoolCommand) ValidateCommand() error { | ||
16 | + valid := validation.Validation{} | ||
17 | + rt, err := valid.Valid(createCashPoolCommand) | ||
18 | + if err != nil { | ||
19 | + return err | ||
20 | + } | ||
21 | + if !rt { | ||
22 | + for _, validErr := range valid.Errors { | ||
23 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
24 | + } | ||
25 | + } | ||
26 | + return nil | ||
27 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | + "time" | ||
7 | +) | ||
8 | + | ||
9 | +// 创建现金兑换活动 | ||
10 | +type CreateExchangeCashActivityCommand struct { | ||
11 | + CompanyId int64 `json:"companyId" valid:"Required"` // 公司id | ||
12 | + ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称 | ||
13 | + Deadline time.Time `json:"deadline"` // 活动截止时间 | ||
14 | + ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率 | ||
15 | + CreateTime time.Time `json:"createTime"` // 创建时间 | ||
16 | +} | ||
17 | + | ||
18 | +func (createExchangeActivityCommand *CreateExchangeCashActivityCommand) ValidateCommand() error { | ||
19 | + valid := validation.Validation{} | ||
20 | + b, err := valid.Valid(createExchangeActivityCommand) | ||
21 | + if err != nil { | ||
22 | + return err | ||
23 | + } | ||
24 | + if !b { | ||
25 | + for _, validErr := range valid.Errors { | ||
26 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
27 | + } | ||
28 | + } | ||
29 | + return nil | ||
30 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type CreateExchangeCashPersonCommand struct { | ||
9 | + Uid int64 `json:"uid"` // 统一用户id | ||
10 | + PersonName string `json:"personName,omitempty"` // 兑换现金人员名称 | ||
11 | + Operator int64 `json:"operator"` // 操作人 | ||
12 | + PersonAccount string `json:"personAccount,omitempty"` // 手机账号 | ||
13 | + ExchangeCashActivityId int64 `json:"exchangeCashActivityId" valid:"Required"` // 参与的兑换活动id | ||
14 | + ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币值 | ||
15 | +} | ||
16 | + | ||
17 | +func (createExchangeCashPersonCommand *CreateExchangeCashPersonCommand) ValidateCommand() error { | ||
18 | + valid := validation.Validation{} | ||
19 | + b, err := valid.Valid(createExchangeCashPersonCommand) | ||
20 | + if err != nil { | ||
21 | + return err | ||
22 | + } | ||
23 | + if !b { | ||
24 | + for _, validErr := range valid.Errors { | ||
25 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
26 | + } | ||
27 | + } | ||
28 | + return nil | ||
29 | +} |
@@ -7,14 +7,10 @@ import ( | @@ -7,14 +7,10 @@ import ( | ||
7 | ) | 7 | ) |
8 | 8 | ||
9 | type ExchangeSuMoneyCommand struct { | 9 | type ExchangeSuMoneyCommand struct { |
10 | - // 兑换人UID | ||
11 | - Uid int64 `json:"uid" valid:"Required"` | ||
12 | - // 素币值 | ||
13 | - SuMoney float64 `json:"suMoney" valid:"Required"` | ||
14 | - // 操作人UID | ||
15 | - Operator int64 `json:"operator,omitempty"` | ||
16 | - // 兑换描述 | ||
17 | - ExchangeDescription string `json:"exchangeDescription" valid:"Required"` | 10 | + Uid int64 `json:"uid" valid:"Required"` // 兑换人UID |
11 | + SuMoney float64 `json:"suMoney" valid:"Required"` // 素币值 | ||
12 | + Operator int64 `json:"operator,omitempty"` // 操作人UID | ||
13 | + ExchangeDescription string `json:"exchangeDescription" valid:"Required"` // 兑换描述 | ||
18 | } | 14 | } |
19 | 15 | ||
20 | func (exchangeSuMoneyCommand *ExchangeSuMoneyCommand) ValidateCommand() error { | 16 | func (exchangeSuMoneyCommand *ExchangeSuMoneyCommand) ValidateCommand() error { |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type ExportExchangeCashListCommand struct { | ||
9 | + Ids []int `json:"ids"` | ||
10 | + Where map[string]interface{} `json:"where"` | ||
11 | +} | ||
12 | + | ||
13 | +func (exportExchangeCashListCommand *ExportExchangeCashListCommand) ValidateCommand() error { | ||
14 | + valid := validation.Validation{} | ||
15 | + b, err := valid.Valid(exportExchangeCashListCommand) | ||
16 | + if err != nil { | ||
17 | + return err | ||
18 | + } | ||
19 | + if !b { | ||
20 | + for _, validErr := range valid.Errors { | ||
21 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
22 | + } | ||
23 | + } | ||
24 | + return nil | ||
25 | +} | ||
26 | + |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type ExportSuMoneyCommand struct { | ||
9 | + Ids []int `json:"ids"` // 员工uid | ||
10 | + Where map[string]interface{} `json:"where"` | ||
11 | +} | ||
12 | + | ||
13 | +func (exportSuMoneyCommand *ExportSuMoneyCommand) ValidateCommand() error { | ||
14 | + valid := validation.Validation{} | ||
15 | + b, err := valid.Valid(exportSuMoneyCommand) | ||
16 | + if err != nil { | ||
17 | + return err | ||
18 | + } | ||
19 | + if !b { | ||
20 | + for _, validErr := range valid.Errors { | ||
21 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
22 | + } | ||
23 | + } | ||
24 | + return nil | ||
25 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type ExportTransactionRecordCommand struct { | ||
9 | + Ids []int `json:"ids"` | ||
10 | + Where map[string]interface{} `json:"where"` | ||
11 | +} | ||
12 | + | ||
13 | +func (exportTransactionRecordCommand *ExportTransactionRecordCommand) ValidateCommand() error { | ||
14 | + valid := validation.Validation{} | ||
15 | + b, err := valid.Valid(exportTransactionRecordCommand) | ||
16 | + if err != nil { | ||
17 | + return err | ||
18 | + } | ||
19 | + if !b { | ||
20 | + for _, validErr := range valid.Errors { | ||
21 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
22 | + } | ||
23 | + } | ||
24 | + return nil | ||
25 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type ImportExchangeCashListCommand struct { | ||
9 | + Where map[string]interface{} `json:"where"` | ||
10 | +} | ||
11 | + | ||
12 | +func (importExchangeCashListCommand *ImportExchangeCashListCommand) ValidateCommand() error { | ||
13 | + valid := validation.Validation{} | ||
14 | + b, err := valid.Valid(importExchangeCashListCommand) | ||
15 | + if err != nil { | ||
16 | + return err | ||
17 | + } | ||
18 | + if !b { | ||
19 | + for _, validErr := range valid.Errors { | ||
20 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
21 | + } | ||
22 | + } | ||
23 | + return nil | ||
24 | +} |
@@ -7,16 +7,11 @@ import ( | @@ -7,16 +7,11 @@ import ( | ||
7 | ) | 7 | ) |
8 | 8 | ||
9 | type OperationSuMoneyCommand struct { | 9 | type OperationSuMoneyCommand struct { |
10 | - // 素币拥有者UID | ||
11 | - Uid int64 `json:"uid" valid:"Required"` | ||
12 | - // 操作类型(1增加,2扣除) | ||
13 | - OperationType int `json:"operationType" valid:"Required"` | ||
14 | - // 素币值 | ||
15 | - SuMoney float64 `json:"suMoney" valid:"Required"` | ||
16 | - // 操作人UID | ||
17 | - Operator int64 `json:"operator,omitempty"` | ||
18 | - // 理由描述 | ||
19 | - OperationDescription string `json:"operationDescription" valid:"Required"` | 10 | + Uid int64 `json:"uid" valid:"Required"` // 素币拥有者UID |
11 | + OperationType int `json:"operationType" valid:"Required"` // 操作类型(1增加,2扣除, 3兑换物资, 4兑换现金) | ||
12 | + SuMoney float64 `json:"suMoney" valid:"Required"` // 素币值 | ||
13 | + Operator int64 `json:"operator,omitempty"` // 操作人UID | ||
14 | + OperationDescription string `json:"operationDescription" valid:"Required"` // 理由描述 | ||
20 | } | 15 | } |
21 | 16 | ||
22 | func (operationSuMoneyCommand *OperationSuMoneyCommand) ValidateCommand() error { | 17 | func (operationSuMoneyCommand *OperationSuMoneyCommand) ValidateCommand() error { |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + | ||
6 | + "github.com/astaxie/beego/validation" | ||
7 | +) | ||
8 | + | ||
9 | +// 删除兑换现金活动 | ||
10 | +type RemoveExchangeCashActivityCommand struct { | ||
11 | + ActivityId int64 `json:"activityId" valid:"Required"` | ||
12 | +} | ||
13 | + | ||
14 | +func (removeExchangeCashActivityCommand *RemoveExchangeCashActivityCommand) ValidateCommand() error { | ||
15 | + valid := validation.Validation{} | ||
16 | + b, err := valid.Valid(removeExchangeCashActivityCommand) | ||
17 | + if err != nil { | ||
18 | + return err | ||
19 | + } | ||
20 | + if !b { | ||
21 | + for _, validErr := range valid.Errors { | ||
22 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
23 | + } | ||
24 | + } | ||
25 | + return nil | ||
26 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +// 移除兑换现金人员 | ||
9 | +type RemoveExchangeCashPersonCommand struct { | ||
10 | + ListId int64 `json:"listId" valid:"Required"` // 兑换现金人员编号 | ||
11 | + Operator int64 `json:"operator,omitempty"` // 操作人 | ||
12 | +} | ||
13 | + | ||
14 | +func (removeExchangeCashPersonCommand *RemoveExchangeCashPersonCommand) ValidateCommand() error { | ||
15 | + valid := validation.Validation{} | ||
16 | + b, err := valid.Valid(removeExchangeCashPersonCommand) | ||
17 | + if err != nil { | ||
18 | + return err | ||
19 | + } | ||
20 | + if !b { | ||
21 | + for _, validErr := range valid.Errors { | ||
22 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
23 | + } | ||
24 | + } | ||
25 | + return nil | ||
26 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type SearchExchangeCashActivityCommand struct { | ||
9 | + ActivityNameMatch string `json:"activityNameMatch"` // 兑换现金活动名称 | ||
10 | + CompanyId int64 `json:"companyId"` // 公司id | ||
11 | + Deadline string `json:"deadline,omitempty"` // 截止时间筛选 | ||
12 | + Offset int `json:"offset,omitempty"` // 查询偏移量 | ||
13 | + Limit int `json:"limit,omitempty"` // 查询限制条目 | ||
14 | +} | ||
15 | + | ||
16 | +func (searchExchangeCashActivityCommand *SearchExchangeCashActivityCommand) ValidateCommand() error { | ||
17 | + valid := validation.Validation{} | ||
18 | + b, err := valid.Valid(searchExchangeCashActivityCommand) | ||
19 | + if err != nil { | ||
20 | + return err | ||
21 | + } | ||
22 | + if !b { | ||
23 | + for _, validErr := range valid.Errors { | ||
24 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
25 | + } | ||
26 | + } | ||
27 | + return nil | ||
28 | +} | ||
29 | + |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type SearchExchangeCashPersonCommand struct { | ||
9 | + ListName string `json:"listName"` // 兑换素币人员名称 | ||
10 | +} | ||
11 | + | ||
12 | +func (searchExchangeCashPersonCommand *SearchExchangeCashPersonCommand) ValidateCommand() error { | ||
13 | + valid := validation.Validation{} | ||
14 | + b, err := valid.Valid(searchExchangeCashPersonCommand) | ||
15 | + if err != nil { | ||
16 | + return err | ||
17 | + } | ||
18 | + if !b { | ||
19 | + for _, validErr := range valid.Errors { | ||
20 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
21 | + } | ||
22 | + } | ||
23 | + return nil | ||
24 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type SearchSuMoneyTransactionCommand struct { | ||
9 | + EmployeeName string `json:"employeeName"` // 员工姓名 | ||
10 | +} | ||
11 | + | ||
12 | +func (searchSuMoneyTransactionCommand *SearchSuMoneyTransactionCommand) ValidateCommand() error { | ||
13 | + valid := validation.Validation{} | ||
14 | + b, err := valid.Valid(searchSuMoneyTransactionCommand) | ||
15 | + if err != nil { | ||
16 | + return err | ||
17 | + } | ||
18 | + if !b { | ||
19 | + for _, validErr := range valid.Errors { | ||
20 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
21 | + } | ||
22 | + } | ||
23 | + return nil | ||
24 | +} |
@@ -9,17 +9,20 @@ import ( | @@ -9,17 +9,20 @@ import ( | ||
9 | 9 | ||
10 | type SearchSuMoneyTransactionRecordCommand struct { | 10 | type SearchSuMoneyTransactionRecordCommand struct { |
11 | // 统一用户UID | 11 | // 统一用户UID |
12 | - Uid int64 `json:"uid" valid:"Required"` | 12 | + //Uid int64 `json:"uid" valid:"Required"` |
13 | + Uid int64 `json:"uid"` | ||
13 | // 记录类型(1兑换,2任务奖励,3增加,4扣除) | 14 | // 记录类型(1兑换,2任务奖励,3增加,4扣除) |
14 | RecordType int `json:"recordType,omitempty"` | 15 | RecordType int `json:"recordType,omitempty"` |
15 | // 记录类型列表(1兑换,2任务奖励,3增加,4扣除) | 16 | // 记录类型列表(1兑换,2任务奖励,3增加,4扣除) |
16 | RecordTypes []int `json:"recordTypes,omitempty"` | 17 | RecordTypes []int `json:"recordTypes,omitempty"` |
17 | - // 操作人UID | ||
18 | // 事务时间区间-开始时间 | 18 | // 事务时间区间-开始时间 |
19 | TransactionStartTime time.Time `json:"transactionStartTime,omitempty"` | 19 | TransactionStartTime time.Time `json:"transactionStartTime,omitempty"` |
20 | // 事务时间区间-截止时间 | 20 | // 事务时间区间-截止时间 |
21 | TransactionEndTime time.Time `json:"transactionEndTime,omitempty"` | 21 | TransactionEndTime time.Time `json:"transactionEndTime,omitempty"` |
22 | + // 操作人UID | ||
22 | Operator int64 `json:"operator,omitempty"` | 23 | Operator int64 `json:"operator,omitempty"` |
24 | + // 关联人员姓名 | ||
25 | + EmployeeMatchName string `json:"employeeMatchName"` | ||
23 | // 查询偏离量 | 26 | // 查询偏离量 |
24 | Offset int `json:"offset,omitempty"` | 27 | Offset int `json:"offset,omitempty"` |
25 | // 查询限制 | 28 | // 查询限制 |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type UpdateCashPoolCommand struct { | ||
9 | + CashPoolId int64 `json:"cashPoolId"` // 现金池编号 | ||
10 | + ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金 | ||
11 | + ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币 | ||
12 | + UnExchangeCash float64 `json:"unExchangeCash"` // 未兑换现金 | ||
13 | + UnExchangeSuMoney float64 `json:"unExchangeSuMoney"` // 未兑换素币 | ||
14 | + Rate float64 `json:"rate"` // 平均兑换汇率 | ||
15 | + Cash float64 `json:"cash"` | ||
16 | + //CompanyId int64 `json:"companyId"` | ||
17 | + LastRate float64 `json:"lastRate"` | ||
18 | + //CreateTime time.Time `json:"createTime"` | ||
19 | +} | ||
20 | + | ||
21 | +func (updateCashPoolCommand *UpdateCashPoolCommand) ValidateCommand() error { | ||
22 | + valid := validation.Validation{} | ||
23 | + b, err := valid.Valid(updateCashPoolCommand) | ||
24 | + if err != nil { | ||
25 | + return err | ||
26 | + } | ||
27 | + if !b { | ||
28 | + for _, validErr := range valid.Errors { | ||
29 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
30 | + } | ||
31 | + } | ||
32 | + return nil | ||
33 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | + "time" | ||
7 | +) | ||
8 | + | ||
9 | +type UpdateExchangeCashActivityCommand struct { | ||
10 | + ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id | ||
11 | + ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称 | ||
12 | + Deadline time.Time `json:"deadline"` // 活动截止时间 | ||
13 | + CountDown int64 `json:"countDown"` // 活动倒计时 | ||
14 | + ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币 | ||
15 | + ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金 | ||
16 | + ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率 | ||
17 | +} | ||
18 | + | ||
19 | +func (updateExchangeCashActivity *UpdateExchangeCashActivityCommand) ValidateCommand() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(updateExchangeCashActivity) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + for _, validErr := range valid.Errors { | ||
27 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
28 | + } | ||
29 | + } | ||
30 | + return nil | ||
31 | +} |
1 | +package command | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type UpdateExchangeCashPersonCommand struct { | ||
9 | + ListId int64 `json:"listId" valid:"Required"` // 兑换现金人员编号 | ||
10 | + ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币(需要和当前的已兑换素币进行比较,少于当前已兑换素币则生成一条扣除素币记录,大于当前已兑换素币则生成一条增加素币记录) | ||
11 | + ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金 | ||
12 | + Operator int64 `json:"operator,omitempty"` // 操作人 | ||
13 | +} | ||
14 | + | ||
15 | +func (updateExchangeCashPersonCommand *UpdateExchangeCashPersonCommand) ValidateCommand() error { | ||
16 | + valid := validation.Validation{} | ||
17 | + b, err := valid.Valid(updateExchangeCashPersonCommand) | ||
18 | + if err != nil { | ||
19 | + return err | ||
20 | + } | ||
21 | + if !b { | ||
22 | + for _, validErr := range valid.Errors { | ||
23 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
24 | + } | ||
25 | + } | ||
26 | + return nil | ||
27 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | + "time" | ||
7 | +) | ||
8 | + | ||
9 | +type ContributionsWealthRankingQuery struct { | ||
10 | + CompanyId int64 `json:"companyId" valid:"Required"` // 公司ID | ||
11 | + RankingType int `json:"rankingType" valid:"Required"` // 榜单类型,区分总榜和年榜 1:总榜,2:年榜 | ||
12 | + Offset int `json:"offset,omitempty"` // 查询偏离量 | ||
13 | + Limit int `json:"limit,omitempty"` // 查询限制 | ||
14 | + Uid int64 `json:"uid" valid:"Required"` // 统一用户id | ||
15 | + StartTime time.Time `json:"startTime"` // 榜单开始时间,由后台根据榜单类型后去 | ||
16 | + EndTime time.Time `json:"endTime"` // 榜单结束更新,由后台根据榜单类型获取 | ||
17 | +} | ||
18 | + | ||
19 | +func (contributionsWealthRankingQuery *ContributionsWealthRankingQuery) ValidateQuery() error { | ||
20 | + valid := validation.Validation{} | ||
21 | + b, err := valid.Valid(contributionsWealthRankingQuery) | ||
22 | + if err != nil { | ||
23 | + return err | ||
24 | + } | ||
25 | + if !b { | ||
26 | + for _, validErr := range valid.Errors { | ||
27 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
28 | + } | ||
29 | + } | ||
30 | + return nil | ||
31 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type ExchangeListRankingQuery struct { | ||
9 | + ActivityId int64 `json:"activityId"` | ||
10 | + CompanyId int64 `json:"companyId"` // 公司ID | ||
11 | + Offset int `json:"offset,omitempty"` // 查询偏离量 | ||
12 | + Limit int `json:"limit,omitempty"` // 查询限制 | ||
13 | + Uid int64 `json:"uid"` // 统一用户id | ||
14 | +} | ||
15 | + | ||
16 | +func (exchangeListRankingQuery *ExchangeListRankingQuery) ValidateCommand() error { | ||
17 | + valid := validation.Validation{} | ||
18 | + b, err := valid.Valid(exchangeListRankingQuery) | ||
19 | + if err != nil { | ||
20 | + return err | ||
21 | + } | ||
22 | + if !b { | ||
23 | + for _, validErr := range valid.Errors { | ||
24 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
25 | + } | ||
26 | + } | ||
27 | + return nil | ||
28 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +// 获取现金池 | ||
9 | +type GetCashPoolQuery struct { | ||
10 | + CompanyId int64 `json:"companyId" valid:"Required"` // 公司id | ||
11 | +} | ||
12 | + | ||
13 | +func (getCashPoolQuery *GetCashPoolQuery) ValidateQuery() error { | ||
14 | + valid := validation.Validation{} | ||
15 | + b, err := valid.Valid(getCashPoolQuery) | ||
16 | + if err != nil { | ||
17 | + return err | ||
18 | + } | ||
19 | + if !b { | ||
20 | + for _, validErr := range valid.Errors { | ||
21 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
22 | + } | ||
23 | + } | ||
24 | + return nil | ||
25 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +// 获取兑换现金活动 | ||
9 | +type GetExchangeCashActivityQuery struct { | ||
10 | + ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id | ||
11 | +} | ||
12 | + | ||
13 | +func (getExchangeCashActivityQuery *GetExchangeCashActivityQuery) ValidateQuery() error { | ||
14 | + valid := validation.Validation{} | ||
15 | + b, err := valid.Valid(getExchangeCashActivityQuery) | ||
16 | + if err != nil { | ||
17 | + return err | ||
18 | + } | ||
19 | + if !b { | ||
20 | + for _, validErr := range valid.Errors { | ||
21 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
22 | + } | ||
23 | + } | ||
24 | + return nil | ||
25 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + | ||
6 | + "github.com/astaxie/beego/validation" | ||
7 | +) | ||
8 | + | ||
9 | +type GetExchangeCashPersonQuery struct { | ||
10 | + ExchangeCashPersonId int64 `json:"exchangeCashPersonId"` // 参与兑换现金活动人员id | ||
11 | +} | ||
12 | + | ||
13 | +func (getExchangeCashPersonQuery *GetExchangeCashPersonQuery) ValidateQuery() error { | ||
14 | + valid := validation.Validation{} | ||
15 | + b, err := valid.Valid(getExchangeCashPersonQuery) | ||
16 | + if err != nil { | ||
17 | + return err | ||
18 | + } | ||
19 | + if !b { | ||
20 | + for _, validErr := range valid.Errors { | ||
21 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
22 | + } | ||
23 | + } | ||
24 | + return nil | ||
25 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +// 获取兑换现金活动列表 | ||
9 | +type ListExchangeCashActivityQuery struct { | ||
10 | + CompanyId int64 `json:"companyId"` // 公司id | ||
11 | + ActivityNameMatch string `json:"activityNameMatch,omitempty"` // 活动名称匹配 | ||
12 | + //Deadline time.Time `json:"deadline,omitempty"` // 截止时间筛选 | ||
13 | + IsEnd bool `json:"isEnd"` // 已结束活动和未结束活动筛选 true: 已结束活动 false: 未结束活动 | ||
14 | + Offset int `json:"offset,omitempty"` // 查询偏移量 | ||
15 | + Limit int `json:"limit,omitempty"` // 查询限制条目 | ||
16 | +} | ||
17 | + | ||
18 | +func (listExchangeCashActivityQuery *ListExchangeCashActivityQuery) ValidateQuery() error { | ||
19 | + valid := validation.Validation{} | ||
20 | + b, err := valid.Valid(listExchangeCashActivityQuery) | ||
21 | + if err != nil { | ||
22 | + return err | ||
23 | + } | ||
24 | + if !b { | ||
25 | + for _, validErr := range valid.Errors { | ||
26 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
27 | + } | ||
28 | + } | ||
29 | + return nil | ||
30 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +type ListExchangeCashActivityDeadlineQuery struct { | ||
9 | + CompanyId int64 `json:"companyId"` // 公司id | ||
10 | +} | ||
11 | + | ||
12 | +func (listExchangeCashActivityDeadlineQuery *ListExchangeCashActivityDeadlineQuery) ValidateQuery() error { | ||
13 | + valid := validation.Validation{} | ||
14 | + b, err := valid.Valid(listExchangeCashActivityDeadlineQuery) | ||
15 | + if err != nil { | ||
16 | + return err | ||
17 | + } | ||
18 | + if !b { | ||
19 | + for _, validErr := range valid.Errors { | ||
20 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
21 | + } | ||
22 | + } | ||
23 | + return nil | ||
24 | +} |
1 | +package query | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "github.com/astaxie/beego/validation" | ||
6 | +) | ||
7 | + | ||
8 | +// 获取兑换活动兑换清单 | ||
9 | +type ListExchangeCashPersonQuery struct { | ||
10 | + CompanyId int64 `json:"companyId"` // 公司id | ||
11 | + ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id | ||
12 | + ExchangeCashPersonNameMatch string `json:"exchangeCashPersonNameMatch,omitempty"` // 兑换活动名称匹配 | ||
13 | + Offset int `json:"offset,omitempty"` // 查询偏离量 | ||
14 | + Limit int `json:"limit,omitempty"` // 查询限制 | ||
15 | +} | ||
16 | + | ||
17 | +func (listExchangeCashPersonQuery *ListExchangeCashPersonQuery) ValidateQuery() error { | ||
18 | + valid := validation.Validation{} | ||
19 | + b, err := valid.Valid(listExchangeCashPersonQuery) | ||
20 | + if err != nil { | ||
21 | + return err | ||
22 | + } | ||
23 | + if !b { | ||
24 | + for _, validErr := range valid.Errors { | ||
25 | + return fmt.Errorf("%s %s", validErr.Key, validErr.Message) | ||
26 | + } | ||
27 | + } | ||
28 | + return nil | ||
29 | +} |
pkg/application/suMoney/service/cash_pool.go
0 → 100644
此 diff 太大无法显示。
@@ -30,6 +30,18 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand * | @@ -30,6 +30,18 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand * | ||
30 | defer func() { | 30 | defer func() { |
31 | transactionContext.RollbackTransaction() | 31 | transactionContext.RollbackTransaction() |
32 | }() | 32 | }() |
33 | + | ||
34 | + // 员工仓储初始化 | ||
35 | + var employeeRepository domain.EmployeeRepository | ||
36 | + if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ | ||
37 | + "transactionContext": transactionContext, | ||
38 | + }); err != nil { | ||
39 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
40 | + } else { | ||
41 | + employeeRepository = value | ||
42 | + } | ||
43 | + | ||
44 | + // 操作素币服务初始化 | ||
33 | var operationSuMoneyService service.OperationSuMoneyService | 45 | var operationSuMoneyService service.OperationSuMoneyService |
34 | if value, err := factory.CreateOperationSuMoneyService(map[string]interface{}{ | 46 | if value, err := factory.CreateOperationSuMoneyService(map[string]interface{}{ |
35 | "transactionContext": transactionContext, | 47 | "transactionContext": transactionContext, |
@@ -38,6 +50,20 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand * | @@ -38,6 +50,20 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand * | ||
38 | } else { | 50 | } else { |
39 | operationSuMoneyService = value | 51 | operationSuMoneyService = value |
40 | } | 52 | } |
53 | + | ||
54 | + // 判断当前员工是否有效 | ||
55 | + getEmployee := map[string]interface{}{ | ||
56 | + "uid": operationSuMoneyCommand.Uid, | ||
57 | + "status": 1, | ||
58 | + } | ||
59 | + employeeFound, err := employeeRepository.FindOne(getEmployee) | ||
60 | + if err != nil { | ||
61 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
62 | + } | ||
63 | + if employeeFound == nil { | ||
64 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的员工") | ||
65 | + } | ||
66 | + | ||
41 | if task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription); err != nil { | 67 | if task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription); err != nil { |
42 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 68 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
43 | } else { | 69 | } else { |
@@ -63,6 +89,7 @@ func (suMoneyService *SuMoneyService) GetSuMoneyTransactionRecord(getSuMoneyTran | @@ -63,6 +89,7 @@ func (suMoneyService *SuMoneyService) GetSuMoneyTransactionRecord(getSuMoneyTran | ||
63 | defer func() { | 89 | defer func() { |
64 | transactionContext.RollbackTransaction() | 90 | transactionContext.RollbackTransaction() |
65 | }() | 91 | }() |
92 | + | ||
66 | var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository | 93 | var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository |
67 | if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{ | 94 | if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{ |
68 | "transactionContext": transactionContext, | 95 | "transactionContext": transactionContext, |
@@ -71,6 +98,7 @@ func (suMoneyService *SuMoneyService) GetSuMoneyTransactionRecord(getSuMoneyTran | @@ -71,6 +98,7 @@ func (suMoneyService *SuMoneyService) GetSuMoneyTransactionRecord(getSuMoneyTran | ||
71 | } else { | 98 | } else { |
72 | suMoneyTransactionRecordRepository = value | 99 | suMoneyTransactionRecordRepository = value |
73 | } | 100 | } |
101 | + | ||
74 | if suMoneyTransactionRecord, err := suMoneyTransactionRecordRepository.FindOne(map[string]interface{}{"suMoneyTransactionRecordId": getSuMoneyTransactionRecordQuery.SuMoneyTransactionRecordId}); err != nil { | 102 | if suMoneyTransactionRecord, err := suMoneyTransactionRecordRepository.FindOne(map[string]interface{}{"suMoneyTransactionRecordId": getSuMoneyTransactionRecordQuery.SuMoneyTransactionRecordId}); err != nil { |
75 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 103 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
76 | } else { | 104 | } else { |
@@ -96,6 +124,7 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co | @@ -96,6 +124,7 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co | ||
96 | defer func() { | 124 | defer func() { |
97 | transactionContext.RollbackTransaction() | 125 | transactionContext.RollbackTransaction() |
98 | }() | 126 | }() |
127 | + | ||
99 | var exchangeSuMoneyService service.ExchangeSuMoneyService | 128 | var exchangeSuMoneyService service.ExchangeSuMoneyService |
100 | if value, err := factory.CreateExchangeSuMoneyService(map[string]interface{}{ | 129 | if value, err := factory.CreateExchangeSuMoneyService(map[string]interface{}{ |
101 | "transactionContext": transactionContext, | 130 | "transactionContext": transactionContext, |
@@ -104,6 +133,7 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co | @@ -104,6 +133,7 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co | ||
104 | } else { | 133 | } else { |
105 | exchangeSuMoneyService = value | 134 | exchangeSuMoneyService = value |
106 | } | 135 | } |
136 | + | ||
107 | if task, err := exchangeSuMoneyService.Exchange(exchangeSuMoneyCommand.Uid, exchangeSuMoneyCommand.Operator, exchangeSuMoneyCommand.SuMoney, exchangeSuMoneyCommand.ExchangeDescription); err != nil { | 137 | if task, err := exchangeSuMoneyService.Exchange(exchangeSuMoneyCommand.Uid, exchangeSuMoneyCommand.Operator, exchangeSuMoneyCommand.SuMoney, exchangeSuMoneyCommand.ExchangeDescription); err != nil { |
108 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 138 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
109 | } else { | 139 | } else { |
@@ -129,6 +159,8 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon | @@ -129,6 +159,8 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon | ||
129 | defer func() { | 159 | defer func() { |
130 | transactionContext.RollbackTransaction() | 160 | transactionContext.RollbackTransaction() |
131 | }() | 161 | }() |
162 | + | ||
163 | + // 素币事务记录仓储初始化 | ||
132 | var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository | 164 | var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository |
133 | if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{ | 165 | if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{ |
134 | "transactionContext": transactionContext, | 166 | "transactionContext": transactionContext, |
@@ -137,20 +169,57 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon | @@ -137,20 +169,57 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon | ||
137 | } else { | 169 | } else { |
138 | suMoneyTransactionRecordRepository = value | 170 | suMoneyTransactionRecordRepository = value |
139 | } | 171 | } |
172 | + | ||
173 | + // 获取素币兑换事务记录 | ||
140 | if count, suMoneyTransactionRecords, err := suMoneyTransactionRecordRepository.Find(tool_funs.SimpleStructToMap(searchSuMoneyTransactionRecordCommand)); err != nil { | 174 | if count, suMoneyTransactionRecords, err := suMoneyTransactionRecordRepository.Find(tool_funs.SimpleStructToMap(searchSuMoneyTransactionRecordCommand)); err != nil { |
141 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 175 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
142 | } else { | 176 | } else { |
143 | if err := transactionContext.CommitTransaction(); err != nil { | 177 | if err := transactionContext.CommitTransaction(); err != nil { |
144 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 178 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
145 | } | 179 | } |
180 | + var suMoneyTransactionRecordsFormat []interface{} | ||
181 | + for _, suMoneyTransactionRecord := range suMoneyTransactionRecords { | ||
182 | + suMoneyTransactionRecordFormat := map[string]interface{} { | ||
183 | + "suMoneyTransactionRecordId": suMoneyTransactionRecord.SuMoneyTransactionRecordId, | ||
184 | + "recordType": suMoneyTransactionRecord.RecordType, | ||
185 | + "employee": map[string]interface{} { | ||
186 | + "uid": suMoneyTransactionRecord.Employee.Uid, | ||
187 | + "employeeName": suMoneyTransactionRecord.Employee.EmployeeName, | ||
188 | + "employeeAccount": suMoneyTransactionRecord.Employee.EmployeeAccount, | ||
189 | + "employeeAvatarUrl": suMoneyTransactionRecord.Employee.EmployeeAvatarUrl, | ||
190 | + "isPrincipal": suMoneyTransactionRecord.Employee.IsPrincipal, | ||
191 | + }, | ||
192 | + "suMoneyBeforeTransaction": suMoneyTransactionRecord.SuMoneyBeforeTransaction, | ||
193 | + "currentSuMoney": suMoneyTransactionRecord.CurrentSuMoney, | ||
194 | + "suMoney": suMoneyTransactionRecord.SuMoney, | ||
195 | + "cashBeforeTransaction": suMoneyTransactionRecord.CashBeforeTransaction, | ||
196 | + "currentCash": suMoneyTransactionRecord.CurrentCash, | ||
197 | + "cash": suMoneyTransactionRecord.Cash, | ||
198 | + "operator": map[string]interface{} { | ||
199 | + "uid": suMoneyTransactionRecord.Operator.Uid, | ||
200 | + "employeeName": suMoneyTransactionRecord.Operator.EmployeeName, | ||
201 | + "employeeAccount": suMoneyTransactionRecord.Operator.EmployeeAccount, | ||
202 | + "employeeAvatarUrl": suMoneyTransactionRecord.Operator.EmployeeAvatarUrl, | ||
203 | + "isPrincipal": suMoneyTransactionRecord.Operator.IsPrincipal, | ||
204 | + }, | ||
205 | + "recordDescription": suMoneyTransactionRecord.RecordDescription, | ||
206 | + "createTime": suMoneyTransactionRecord.CreateTime.Local(), | ||
207 | + } | ||
208 | + suMoneyTransactionRecordsFormat = append(suMoneyTransactionRecordsFormat, suMoneyTransactionRecordFormat) | ||
209 | + } | ||
210 | + | ||
211 | + if len(suMoneyTransactionRecordsFormat) == 0 { | ||
212 | + suMoneyTransactionRecordsFormat = []interface{}{} | ||
213 | + } | ||
214 | + | ||
146 | return map[string]interface{}{ | 215 | return map[string]interface{}{ |
147 | "count": count, | 216 | "count": count, |
148 | - "suMoneyTransactionRecords": suMoneyTransactionRecords, | 217 | + "suMoneyTransactionRecords": suMoneyTransactionRecordsFormat, |
149 | }, nil | 218 | }, nil |
150 | } | 219 | } |
151 | } | 220 | } |
152 | 221 | ||
153 | -// 素币事务记录统计 | 222 | +// 素币事务记录统计(个人素币) |
154 | func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoneyTransactionRecordStatisticsCommand *command.SuMoneyTransactionRecordStatisticsCommand) (interface{}, error) { | 223 | func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoneyTransactionRecordStatisticsCommand *command.SuMoneyTransactionRecordStatisticsCommand) (interface{}, error) { |
155 | if err := suMoneyTransactionRecordStatisticsCommand.ValidateCommand(); err != nil { | 224 | if err := suMoneyTransactionRecordStatisticsCommand.ValidateCommand(); err != nil { |
156 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 225 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
@@ -165,6 +234,8 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney | @@ -165,6 +234,8 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney | ||
165 | defer func() { | 234 | defer func() { |
166 | transactionContext.RollbackTransaction() | 235 | transactionContext.RollbackTransaction() |
167 | }() | 236 | }() |
237 | + | ||
238 | + // 员工DAO初始化 | ||
168 | var employeeDao *dao.EmployeeDao | 239 | var employeeDao *dao.EmployeeDao |
169 | if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | 240 | if value, err := factory.CreateEmployeeDao(map[string]interface{}{ |
170 | "transactionContext": transactionContext, | 241 | "transactionContext": transactionContext, |
@@ -173,6 +244,7 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney | @@ -173,6 +244,7 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney | ||
173 | } else { | 244 | } else { |
174 | employeeDao = value | 245 | employeeDao = value |
175 | } | 246 | } |
247 | + | ||
176 | if calculateResult, err := employeeDao.CalculateSuMoneyTransactionRecord(suMoneyTransactionRecordStatisticsCommand.Uid, suMoneyTransactionRecordStatisticsCommand.TransactionStartTime, suMoneyTransactionRecordStatisticsCommand.TransactionEndTime); err != nil { | 248 | if calculateResult, err := employeeDao.CalculateSuMoneyTransactionRecord(suMoneyTransactionRecordStatisticsCommand.Uid, suMoneyTransactionRecordStatisticsCommand.TransactionStartTime, suMoneyTransactionRecordStatisticsCommand.TransactionEndTime); err != nil { |
177 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 249 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
178 | } else { | 250 | } else { |
@@ -183,6 +255,123 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney | @@ -183,6 +255,123 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney | ||
183 | } | 255 | } |
184 | } | 256 | } |
185 | 257 | ||
258 | +// 贡献值事务记录统计(个人贡献值) | ||
259 | +func (suMoneyService *SuMoneyService) ContributionsTransactionRecordStatistics(contributionsTransactionRecordStatisticsCommand *command.ContributionsTransactionRecordStatisticsCommand) (interface{}, error) { | ||
260 | + if err := contributionsTransactionRecordStatisticsCommand.ValidateCommand(); err != nil { | ||
261 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
262 | + } | ||
263 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
264 | + if err != nil { | ||
265 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
266 | + } | ||
267 | + if err := transactionContext.StartTransaction(); err != nil { | ||
268 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
269 | + } | ||
270 | + defer func() { | ||
271 | + transactionContext.RollbackTransaction() | ||
272 | + }() | ||
273 | + | ||
274 | + var employeeDao *dao.EmployeeDao | ||
275 | + if value, err := factory.CreateEmployeeDao(map[string]interface{}{ | ||
276 | + "transactionContext": transactionContext, | ||
277 | + }); err != nil { | ||
278 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
279 | + } else { | ||
280 | + employeeDao = value | ||
281 | + } | ||
282 | + | ||
283 | + if calculateResult, err := employeeDao.CalculateContributionsTransactionRecord(contributionsTransactionRecordStatisticsCommand.Uid, contributionsTransactionRecordStatisticsCommand.TransactionStartTime, contributionsTransactionRecordStatisticsCommand.TransactionEndTime); err != nil { | ||
284 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
285 | + } else { | ||
286 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
287 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
288 | + } | ||
289 | + return calculateResult, nil | ||
290 | + } | ||
291 | +} | ||
292 | + | ||
293 | +// 根据uid获取员工素币(导出素币流水) | ||
294 | +func (suMoneyService *SuMoneyService) ListSuMoneyById(exportSuMoneyCommand *command.ExportSuMoneyCommand) ([]*domain.Employee, error) { | ||
295 | + if err := exportSuMoneyCommand.ValidateCommand(); err != nil { | ||
296 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
297 | + } | ||
298 | + | ||
299 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
300 | + if err != nil { | ||
301 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
302 | + } | ||
303 | + if err := transactionContext.StartTransaction(); err != nil { | ||
304 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
305 | + } | ||
306 | + defer func() { | ||
307 | + transactionContext.RollbackTransaction() | ||
308 | + }() | ||
309 | + | ||
310 | + if len(exportSuMoneyCommand.Ids) == 0 && exportSuMoneyCommand.Where == nil { | ||
311 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据") | ||
312 | + } | ||
313 | + | ||
314 | + // 员工仓储初始化 | ||
315 | + var employeeRepository domain.EmployeeRepository | ||
316 | + if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ | ||
317 | + "transactionContext": transactionContext, | ||
318 | + }); err != nil { | ||
319 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
320 | + } else { | ||
321 | + employeeRepository = value | ||
322 | + } | ||
323 | + | ||
324 | + if _, employees, err := employeeRepository.FindByIds(tool_funs.SimpleStructToMap(exportSuMoneyCommand)); err != nil { | ||
325 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
326 | + } else { | ||
327 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
328 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
329 | + } | ||
330 | + return employees, nil | ||
331 | + } | ||
332 | +} | ||
333 | + | ||
334 | +// 根据id获取事务记录(导出素币流水记录) | ||
335 | +func (suMoneyService *SuMoneyService) ListSuMoneyTransactionRecordById(exportSuMoneyTransactionRecordCommand *command.ExportTransactionRecordCommand) ([]*domain.SuMoneyTransactionRecord, error) { | ||
336 | + if err := exportSuMoneyTransactionRecordCommand.ValidateCommand(); err != nil { | ||
337 | + return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | ||
338 | + } | ||
339 | + | ||
340 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
341 | + if err != nil { | ||
342 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
343 | + } | ||
344 | + if err := transactionContext.StartTransaction(); err != nil { | ||
345 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
346 | + } | ||
347 | + defer func() { | ||
348 | + transactionContext.RollbackTransaction() | ||
349 | + }() | ||
350 | + | ||
351 | + if len(exportSuMoneyTransactionRecordCommand.Ids) == 0 && exportSuMoneyTransactionRecordCommand.Where == nil { | ||
352 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据") | ||
353 | + } | ||
354 | + | ||
355 | + var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository | ||
356 | + if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{ | ||
357 | + "transactionContext": transactionContext, | ||
358 | + }); err != nil { | ||
359 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
360 | + } else { | ||
361 | + suMoneyTransactionRecordRepository = value | ||
362 | + } | ||
363 | + | ||
364 | + if _, suMoneyTransactionRecords, err := suMoneyTransactionRecordRepository.FindById(tool_funs.SimpleStructToMap(exportSuMoneyTransactionRecordCommand)); err != nil { | ||
365 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
366 | + } else { | ||
367 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
368 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
369 | + } | ||
370 | + return suMoneyTransactionRecords, nil | ||
371 | + } | ||
372 | +} | ||
373 | + | ||
374 | + | ||
186 | func NewSuMoneyService(options map[string]interface{}) *SuMoneyService { | 375 | func NewSuMoneyService(options map[string]interface{}) *SuMoneyService { |
187 | newSuMoneyService := &SuMoneyService{} | 376 | newSuMoneyService := &SuMoneyService{} |
188 | return newSuMoneyService | 377 | return newSuMoneyService |
@@ -15,6 +15,8 @@ type AcceptanceTaskCommand struct { | @@ -15,6 +15,8 @@ type AcceptanceTaskCommand struct { | ||
15 | Operator int64 `json:"operator" valid:"Required"` | 15 | Operator int64 `json:"operator" valid:"Required"` |
16 | // 任务参与者UID列表 | 16 | // 任务参与者UID列表 |
17 | Participators []int64 `json:"participators,omitempty"` | 17 | Participators []int64 `json:"participators,omitempty"` |
18 | + // 实际奖励素币值 | ||
19 | + SuMoney float64 `jsons:"suMoney"` | ||
18 | // 任务贡献占比 | 20 | // 任务贡献占比 |
19 | TaskPercentage []*domain.TaskPercentageItem `json:"taskPercentage"` | 21 | TaskPercentage []*domain.TaskPercentageItem `json:"taskPercentage"` |
20 | // 引用资源解决分 | 22 | // 引用资源解决分 |
@@ -29,6 +29,10 @@ type CreateTaskCommand struct { | @@ -29,6 +29,10 @@ type CreateTaskCommand struct { | ||
29 | TaskNature int `json:"taskNature,omitempty"` | 29 | TaskNature int `json:"taskNature,omitempty"` |
30 | // 奖励素币 | 30 | // 奖励素币 |
31 | SuMoney float64 `json:"suMoney,omitempty"` | 31 | SuMoney float64 `json:"suMoney,omitempty"` |
32 | + // 最小奖励素币 | ||
33 | + MinSuMoney float64 `json:"minSuMoney"` | ||
34 | + // 最大奖励素币 | ||
35 | + MaxSuMoney float64 `json:"maxSuMoney"` | ||
32 | // 验收标准 | 36 | // 验收标准 |
33 | AcceptanceStandard string `json:"acceptanceStandard,omitempty"` | 37 | AcceptanceStandard string `json:"acceptanceStandard,omitempty"` |
34 | // 任务描述 | 38 | // 任务描述 |
@@ -13,12 +13,18 @@ type SearchTaskCommand struct { | @@ -13,12 +13,18 @@ type SearchTaskCommand struct { | ||
13 | Sponsor int64 `json:"sponsor,omitempty"` | 13 | Sponsor int64 `json:"sponsor,omitempty"` |
14 | // 任务内容匹配 | 14 | // 任务内容匹配 |
15 | TaskContentMatch string `json:"taskContentMatch,omitempty"` | 15 | TaskContentMatch string `json:"taskContentMatch,omitempty"` |
16 | + // 任务名称匹配 | ||
17 | + TaskNameMatch string `json:"taskNameMatch,omitempty"` | ||
16 | // 任务类型 | 18 | // 任务类型 |
17 | TaskType int `json:"taskType,omitempty"` | 19 | TaskType int `json:"taskType,omitempty"` |
18 | // 任务类型ID列表 | 20 | // 任务类型ID列表 |
19 | TaskTypes []int `json:"taskTypes,omitempty"` | 21 | TaskTypes []int `json:"taskTypes,omitempty"` |
20 | // 任务状态 | 22 | // 任务状态 |
21 | TaskStatus int `json:"taskStatus,omitempty"` | 23 | TaskStatus int `json:"taskStatus,omitempty"` |
24 | + // 任务状态ID列表 | ||
25 | + TaskStates []int `json:"taskStates,omitempty"` | ||
26 | + // 任务状态ID列表 | ||
27 | + TaskStatuss []int `json:"taskStatuss,omitempty"` | ||
22 | // 项目归属 | 28 | // 项目归属 |
23 | ProjectBelongs []int `json:"projectBelongs,omitempty"` | 29 | ProjectBelongs []int `json:"projectBelongs,omitempty"` |
24 | // 客户价值 | 30 | // 客户价值 |
@@ -23,8 +23,12 @@ type UpdateTaskCommand struct { | @@ -23,8 +23,12 @@ type UpdateTaskCommand struct { | ||
23 | CustomerValues []int `json:"customerValues,omitempty"` | 23 | CustomerValues []int `json:"customerValues,omitempty"` |
24 | // 任务性质 | 24 | // 任务性质 |
25 | TaskNature int `json:"taskNature,omitempty"` | 25 | TaskNature int `json:"taskNature,omitempty"` |
26 | - // 奖励素币 | 26 | + // 实际奖励素币 |
27 | SuMoney float64 `json:"suMoney,omitempty"` | 27 | SuMoney float64 `json:"suMoney,omitempty"` |
28 | + // 最小奖励素币 | ||
29 | + MinSuMoney float64 `json:"minSuMoney,omitempty"` | ||
30 | + // 最大奖励素币 | ||
31 | + MaxSuMoney float64 `json:"maxSuMoney,omitempty"` | ||
28 | // 验收标准 | 32 | // 验收标准 |
29 | AcceptanceStandard string `json:"acceptanceStandard,omitempty"` | 33 | AcceptanceStandard string `json:"acceptanceStandard,omitempty"` |
30 | // 任务描述 | 34 | // 任务描述 |
@@ -29,6 +29,10 @@ type TaskDto struct { | @@ -29,6 +29,10 @@ type TaskDto struct { | ||
29 | TaskNature *domain.TaskNature `json:"taskNature"` | 29 | TaskNature *domain.TaskNature `json:"taskNature"` |
30 | // 奖励素币 | 30 | // 奖励素币 |
31 | SuMoney float64 `json:"suMoney"` | 31 | SuMoney float64 `json:"suMoney"` |
32 | + // 最小奖励素币 | ||
33 | + MinSuMoney float64 `json:"minSuMoney"` | ||
34 | + // 最大奖励素币 | ||
35 | + MaxSuMoney float64 `json:"maxSuMoney"` | ||
32 | // 验收标准 | 36 | // 验收标准 |
33 | AcceptanceStandard string `json:"acceptanceStandard"` | 37 | AcceptanceStandard string `json:"acceptanceStandard"` |
34 | // 任务描述 | 38 | // 任务描述 |
@@ -99,6 +103,8 @@ func (dto *TaskDto) LoadDto(task *domain.Task, projectBelongMap map[int]*domain. | @@ -99,6 +103,8 @@ func (dto *TaskDto) LoadDto(task *domain.Task, projectBelongMap map[int]*domain. | ||
99 | } | 103 | } |
100 | } | 104 | } |
101 | dto.SuMoney = task.SuMoney | 105 | dto.SuMoney = task.SuMoney |
106 | + dto.MinSuMoney = task.MinSuMoney | ||
107 | + dto.MaxSuMoney = task.MaxSuMoney | ||
102 | dto.AcceptanceStandard = task.AcceptanceStandard | 108 | dto.AcceptanceStandard = task.AcceptanceStandard |
103 | dto.TaskDescription = task.TaskDescription | 109 | dto.TaskDescription = task.TaskDescription |
104 | dto.TaskPictureUrls = task.TaskPictureUrls | 110 | dto.TaskPictureUrls = task.TaskPictureUrls |
@@ -2,6 +2,8 @@ package service | @@ -2,6 +2,8 @@ package service | ||
2 | 2 | ||
3 | import ( | 3 | import ( |
4 | "fmt" | 4 | "fmt" |
5 | + "time" | ||
6 | + | ||
5 | "github.com/linmadan/egglib-go/core/application" | 7 | "github.com/linmadan/egglib-go/core/application" |
6 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" | 8 | pgTransaction "github.com/linmadan/egglib-go/transaction/pg" |
7 | "github.com/linmadan/egglib-go/utils/tool_funs" | 9 | "github.com/linmadan/egglib-go/utils/tool_funs" |
@@ -13,7 +15,6 @@ import ( | @@ -13,7 +15,6 @@ import ( | ||
13 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | 15 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" |
14 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service" | 16 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service" |
15 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" | 17 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" |
16 | - "time" | ||
17 | ) | 18 | ) |
18 | 19 | ||
19 | // 任务服务 | 20 | // 任务服务 |
@@ -25,6 +26,7 @@ func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.Co | @@ -25,6 +26,7 @@ func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.Co | ||
25 | if err := confirmRobTaskCommand.ValidateCommand(); err != nil { | 26 | if err := confirmRobTaskCommand.ValidateCommand(); err != nil { |
26 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 27 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
27 | } | 28 | } |
29 | + | ||
28 | transactionContext, err := factory.CreateTransactionContext(nil) | 30 | transactionContext, err := factory.CreateTransactionContext(nil) |
29 | if err != nil { | 31 | if err != nil { |
30 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 32 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -35,6 +37,7 @@ func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.Co | @@ -35,6 +37,7 @@ func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.Co | ||
35 | defer func() { | 37 | defer func() { |
36 | transactionContext.RollbackTransaction() | 38 | transactionContext.RollbackTransaction() |
37 | }() | 39 | }() |
40 | + | ||
38 | var confirmRobTaskService service.ConfirmRobTaskService | 41 | var confirmRobTaskService service.ConfirmRobTaskService |
39 | if value, err := factory.CreateConfirmRobTaskService(map[string]interface{}{ | 42 | if value, err := factory.CreateConfirmRobTaskService(map[string]interface{}{ |
40 | "transactionContext": transactionContext, | 43 | "transactionContext": transactionContext, |
@@ -46,6 +49,7 @@ func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.Co | @@ -46,6 +49,7 @@ func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.Co | ||
46 | TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | 49 | TransactionContext: transactionContext.(*pgTransaction.TransactionContext), |
47 | }) | 50 | }) |
48 | } | 51 | } |
52 | + | ||
49 | if task, err := confirmRobTaskService.Confirm(confirmRobTaskCommand.TaskId, confirmRobTaskCommand.Operator, confirmRobTaskCommand.PlannedCompletionTime); err != nil { | 53 | if task, err := confirmRobTaskService.Confirm(confirmRobTaskCommand.TaskId, confirmRobTaskCommand.Operator, confirmRobTaskCommand.PlannedCompletionTime); err != nil { |
50 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 54 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
51 | } else { | 55 | } else { |
@@ -61,6 +65,7 @@ func (taskService *TaskService) RejectTaskReceiver(rejectTaskReceiverCommand *co | @@ -61,6 +65,7 @@ func (taskService *TaskService) RejectTaskReceiver(rejectTaskReceiverCommand *co | ||
61 | if err := rejectTaskReceiverCommand.ValidateCommand(); err != nil { | 65 | if err := rejectTaskReceiverCommand.ValidateCommand(); err != nil { |
62 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 66 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
63 | } | 67 | } |
68 | + | ||
64 | transactionContext, err := factory.CreateTransactionContext(nil) | 69 | transactionContext, err := factory.CreateTransactionContext(nil) |
65 | if err != nil { | 70 | if err != nil { |
66 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 71 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -71,6 +76,7 @@ func (taskService *TaskService) RejectTaskReceiver(rejectTaskReceiverCommand *co | @@ -71,6 +76,7 @@ func (taskService *TaskService) RejectTaskReceiver(rejectTaskReceiverCommand *co | ||
71 | defer func() { | 76 | defer func() { |
72 | transactionContext.RollbackTransaction() | 77 | transactionContext.RollbackTransaction() |
73 | }() | 78 | }() |
79 | + | ||
74 | var rejectTaskReceiverService service.RejectTaskReceiverService | 80 | var rejectTaskReceiverService service.RejectTaskReceiverService |
75 | if value, err := factory.CreateRejectTaskReceiverService(map[string]interface{}{ | 81 | if value, err := factory.CreateRejectTaskReceiverService(map[string]interface{}{ |
76 | "transactionContext": transactionContext, | 82 | "transactionContext": transactionContext, |
@@ -82,6 +88,7 @@ func (taskService *TaskService) RejectTaskReceiver(rejectTaskReceiverCommand *co | @@ -82,6 +88,7 @@ func (taskService *TaskService) RejectTaskReceiver(rejectTaskReceiverCommand *co | ||
82 | TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | 88 | TransactionContext: transactionContext.(*pgTransaction.TransactionContext), |
83 | }) | 89 | }) |
84 | } | 90 | } |
91 | + | ||
85 | if task, err := rejectTaskReceiverService.Reject(rejectTaskReceiverCommand.TaskId, rejectTaskReceiverCommand.Operator, rejectTaskReceiverCommand.RejectReason); err != nil { | 92 | if task, err := rejectTaskReceiverService.Reject(rejectTaskReceiverCommand.TaskId, rejectTaskReceiverCommand.Operator, rejectTaskReceiverCommand.RejectReason); err != nil { |
86 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 93 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
87 | } else { | 94 | } else { |
@@ -97,6 +104,7 @@ func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand) | @@ -97,6 +104,7 @@ func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand) | ||
97 | if err := robTaskCommand.ValidateCommand(); err != nil { | 104 | if err := robTaskCommand.ValidateCommand(); err != nil { |
98 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 105 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
99 | } | 106 | } |
107 | + | ||
100 | transactionContext, err := factory.CreateTransactionContext(nil) | 108 | transactionContext, err := factory.CreateTransactionContext(nil) |
101 | if err != nil { | 109 | if err != nil { |
102 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 110 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -107,6 +115,7 @@ func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand) | @@ -107,6 +115,7 @@ func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand) | ||
107 | defer func() { | 115 | defer func() { |
108 | transactionContext.RollbackTransaction() | 116 | transactionContext.RollbackTransaction() |
109 | }() | 117 | }() |
118 | + | ||
110 | var robTaskService service.RobTaskService | 119 | var robTaskService service.RobTaskService |
111 | if value, err := factory.CreateRobTaskService(map[string]interface{}{ | 120 | if value, err := factory.CreateRobTaskService(map[string]interface{}{ |
112 | "transactionContext": transactionContext, | 121 | "transactionContext": transactionContext, |
@@ -119,6 +128,7 @@ func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand) | @@ -119,6 +128,7 @@ func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand) | ||
119 | TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | 128 | TransactionContext: transactionContext.(*pgTransaction.TransactionContext), |
120 | }) | 129 | }) |
121 | } | 130 | } |
131 | + | ||
122 | if task, err := robTaskService.Rob(robTaskCommand.TaskId, robTaskCommand.Receiver); err != nil { | 132 | if task, err := robTaskService.Rob(robTaskCommand.TaskId, robTaskCommand.Receiver); err != nil { |
123 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 133 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
124 | } else { | 134 | } else { |
@@ -134,6 +144,7 @@ func (taskService *TaskService) BidTask(bidTaskCommand *command.BidTaskCommand) | @@ -134,6 +144,7 @@ func (taskService *TaskService) BidTask(bidTaskCommand *command.BidTaskCommand) | ||
134 | if err := bidTaskCommand.ValidateCommand(); err != nil { | 144 | if err := bidTaskCommand.ValidateCommand(); err != nil { |
135 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 145 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
136 | } | 146 | } |
147 | + | ||
137 | transactionContext, err := factory.CreateTransactionContext(nil) | 148 | transactionContext, err := factory.CreateTransactionContext(nil) |
138 | if err != nil { | 149 | if err != nil { |
139 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 150 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -144,6 +155,7 @@ func (taskService *TaskService) BidTask(bidTaskCommand *command.BidTaskCommand) | @@ -144,6 +155,7 @@ func (taskService *TaskService) BidTask(bidTaskCommand *command.BidTaskCommand) | ||
144 | defer func() { | 155 | defer func() { |
145 | transactionContext.RollbackTransaction() | 156 | transactionContext.RollbackTransaction() |
146 | }() | 157 | }() |
158 | + | ||
147 | var bidTaskService service.BidTaskService | 159 | var bidTaskService service.BidTaskService |
148 | if value, err := factory.CreateBidTaskService(map[string]interface{}{ | 160 | if value, err := factory.CreateBidTaskService(map[string]interface{}{ |
149 | "transactionContext": transactionContext, | 161 | "transactionContext": transactionContext, |
@@ -152,6 +164,7 @@ func (taskService *TaskService) BidTask(bidTaskCommand *command.BidTaskCommand) | @@ -152,6 +164,7 @@ func (taskService *TaskService) BidTask(bidTaskCommand *command.BidTaskCommand) | ||
152 | } else { | 164 | } else { |
153 | bidTaskService = value | 165 | bidTaskService = value |
154 | } | 166 | } |
167 | + | ||
155 | if task, err := bidTaskService.Bid(bidTaskCommand.TaskId, bidTaskCommand.Bidder); err != nil { | 168 | if task, err := bidTaskService.Bid(bidTaskCommand.TaskId, bidTaskCommand.Bidder); err != nil { |
156 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 169 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
157 | } else { | 170 | } else { |
@@ -167,6 +180,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom | @@ -167,6 +180,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom | ||
167 | if err := chooseSuccessfulBidderCommand.ValidateCommand(); err != nil { | 180 | if err := chooseSuccessfulBidderCommand.ValidateCommand(); err != nil { |
168 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 181 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
169 | } | 182 | } |
183 | + | ||
170 | transactionContext, err := factory.CreateTransactionContext(nil) | 184 | transactionContext, err := factory.CreateTransactionContext(nil) |
171 | if err != nil { | 185 | if err != nil { |
172 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 186 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -177,6 +191,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom | @@ -177,6 +191,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom | ||
177 | defer func() { | 191 | defer func() { |
178 | transactionContext.RollbackTransaction() | 192 | transactionContext.RollbackTransaction() |
179 | }() | 193 | }() |
194 | + | ||
180 | var chooseSuccessfulBidderService service.ChooseSuccessfulBidderService | 195 | var chooseSuccessfulBidderService service.ChooseSuccessfulBidderService |
181 | if value, err := factory.CreateChooseSuccessfulBidderService(map[string]interface{}{ | 196 | if value, err := factory.CreateChooseSuccessfulBidderService(map[string]interface{}{ |
182 | "transactionContext": transactionContext, | 197 | "transactionContext": transactionContext, |
@@ -186,6 +201,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom | @@ -186,6 +201,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom | ||
186 | chooseSuccessfulBidderService = value | 201 | chooseSuccessfulBidderService = value |
187 | chooseSuccessfulBidderService.Subscribe(&subscriber.AbilityServiceSubscriber{}) | 202 | chooseSuccessfulBidderService.Subscribe(&subscriber.AbilityServiceSubscriber{}) |
188 | } | 203 | } |
204 | + | ||
189 | if task, err := chooseSuccessfulBidderService.Choose(chooseSuccessfulBidderCommand.TaskId, chooseSuccessfulBidderCommand.SuccessfulBidder, chooseSuccessfulBidderCommand.Operator, chooseSuccessfulBidderCommand.PlannedCompletionTime); err != nil { | 205 | if task, err := chooseSuccessfulBidderService.Choose(chooseSuccessfulBidderCommand.TaskId, chooseSuccessfulBidderCommand.SuccessfulBidder, chooseSuccessfulBidderCommand.Operator, chooseSuccessfulBidderCommand.PlannedCompletionTime); err != nil { |
190 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 206 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
191 | } else { | 207 | } else { |
@@ -201,6 +217,7 @@ func (taskService *TaskService) ApplyCompleteTask(applyCompleteTaskCommand *comm | @@ -201,6 +217,7 @@ func (taskService *TaskService) ApplyCompleteTask(applyCompleteTaskCommand *comm | ||
201 | if err := applyCompleteTaskCommand.ValidateCommand(); err != nil { | 217 | if err := applyCompleteTaskCommand.ValidateCommand(); err != nil { |
202 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 218 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
203 | } | 219 | } |
220 | + | ||
204 | transactionContext, err := factory.CreateTransactionContext(nil) | 221 | transactionContext, err := factory.CreateTransactionContext(nil) |
205 | if err != nil { | 222 | if err != nil { |
206 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 223 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -211,6 +228,7 @@ func (taskService *TaskService) ApplyCompleteTask(applyCompleteTaskCommand *comm | @@ -211,6 +228,7 @@ func (taskService *TaskService) ApplyCompleteTask(applyCompleteTaskCommand *comm | ||
211 | defer func() { | 228 | defer func() { |
212 | transactionContext.RollbackTransaction() | 229 | transactionContext.RollbackTransaction() |
213 | }() | 230 | }() |
231 | + | ||
214 | var applyCompleteTaskService service.ApplyCompleteTaskService | 232 | var applyCompleteTaskService service.ApplyCompleteTaskService |
215 | if value, err := factory.CreateApplyCompleteTaskService(map[string]interface{}{ | 233 | if value, err := factory.CreateApplyCompleteTaskService(map[string]interface{}{ |
216 | "transactionContext": transactionContext, | 234 | "transactionContext": transactionContext, |
@@ -219,6 +237,7 @@ func (taskService *TaskService) ApplyCompleteTask(applyCompleteTaskCommand *comm | @@ -219,6 +237,7 @@ func (taskService *TaskService) ApplyCompleteTask(applyCompleteTaskCommand *comm | ||
219 | } else { | 237 | } else { |
220 | applyCompleteTaskService = value | 238 | applyCompleteTaskService = value |
221 | } | 239 | } |
240 | + | ||
222 | if task, err := applyCompleteTaskService.ApplyComplete(applyCompleteTaskCommand.TaskId, applyCompleteTaskCommand.Receiver); err != nil { | 241 | if task, err := applyCompleteTaskService.ApplyComplete(applyCompleteTaskCommand.TaskId, applyCompleteTaskCommand.Receiver); err != nil { |
223 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 242 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
224 | } else { | 243 | } else { |
@@ -234,6 +253,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT | @@ -234,6 +253,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT | ||
234 | if err := releaseTaskCommand.ValidateCommand(); err != nil { | 253 | if err := releaseTaskCommand.ValidateCommand(); err != nil { |
235 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 254 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
236 | } | 255 | } |
256 | + | ||
237 | transactionContext, err := factory.CreateTransactionContext(nil) | 257 | transactionContext, err := factory.CreateTransactionContext(nil) |
238 | if err != nil { | 258 | if err != nil { |
239 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 259 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -244,6 +264,8 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT | @@ -244,6 +264,8 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT | ||
244 | defer func() { | 264 | defer func() { |
245 | transactionContext.RollbackTransaction() | 265 | transactionContext.RollbackTransaction() |
246 | }() | 266 | }() |
267 | + | ||
268 | + // 发布任务服务初始化 | ||
247 | var releaseTaskService service.ReleaseTaskService | 269 | var releaseTaskService service.ReleaseTaskService |
248 | if value, err := factory.CreateReleaseTaskService(map[string]interface{}{ | 270 | if value, err := factory.CreateReleaseTaskService(map[string]interface{}{ |
249 | "transactionContext": transactionContext, | 271 | "transactionContext": transactionContext, |
@@ -256,6 +278,8 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT | @@ -256,6 +278,8 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT | ||
256 | TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | 278 | TransactionContext: transactionContext.(*pgTransaction.TransactionContext), |
257 | }) | 279 | }) |
258 | } | 280 | } |
281 | + | ||
282 | + // 关闭任务 | ||
259 | if task, err := releaseTaskService.Release(releaseTaskCommand.TaskId, releaseTaskCommand.Operator); err != nil { | 283 | if task, err := releaseTaskService.Release(releaseTaskCommand.TaskId, releaseTaskCommand.Operator); err != nil { |
260 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 284 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
261 | } else { | 285 | } else { |
@@ -271,6 +295,7 @@ func (taskService *TaskService) OffTask(offTaskCommand *command.OffTaskCommand) | @@ -271,6 +295,7 @@ func (taskService *TaskService) OffTask(offTaskCommand *command.OffTaskCommand) | ||
271 | if err := offTaskCommand.ValidateCommand(); err != nil { | 295 | if err := offTaskCommand.ValidateCommand(); err != nil { |
272 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 296 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
273 | } | 297 | } |
298 | + | ||
274 | transactionContext, err := factory.CreateTransactionContext(nil) | 299 | transactionContext, err := factory.CreateTransactionContext(nil) |
275 | if err != nil { | 300 | if err != nil { |
276 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 301 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -281,6 +306,8 @@ func (taskService *TaskService) OffTask(offTaskCommand *command.OffTaskCommand) | @@ -281,6 +306,8 @@ func (taskService *TaskService) OffTask(offTaskCommand *command.OffTaskCommand) | ||
281 | defer func() { | 306 | defer func() { |
282 | transactionContext.RollbackTransaction() | 307 | transactionContext.RollbackTransaction() |
283 | }() | 308 | }() |
309 | + | ||
310 | + // 关闭任务服务初始化 | ||
284 | var offTaskService service.OffTaskService | 311 | var offTaskService service.OffTaskService |
285 | if value, err := factory.CreateOffTaskService(map[string]interface{}{ | 312 | if value, err := factory.CreateOffTaskService(map[string]interface{}{ |
286 | "transactionContext": transactionContext, | 313 | "transactionContext": transactionContext, |
@@ -290,6 +317,8 @@ func (taskService *TaskService) OffTask(offTaskCommand *command.OffTaskCommand) | @@ -290,6 +317,8 @@ func (taskService *TaskService) OffTask(offTaskCommand *command.OffTaskCommand) | ||
290 | offTaskService = value | 317 | offTaskService = value |
291 | offTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{}) | 318 | offTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{}) |
292 | } | 319 | } |
320 | + | ||
321 | + // 关闭任务 | ||
293 | if task, err := offTaskService.Off(offTaskCommand.TaskId, offTaskCommand.Operator, offTaskCommand.OffReason); err != nil { | 322 | if task, err := offTaskService.Off(offTaskCommand.TaskId, offTaskCommand.Operator, offTaskCommand.OffReason); err != nil { |
294 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 323 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
295 | } else { | 324 | } else { |
@@ -305,6 +334,7 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac | @@ -305,6 +334,7 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac | ||
305 | if err := acceptanceTaskCommand.ValidateCommand(); err != nil { | 334 | if err := acceptanceTaskCommand.ValidateCommand(); err != nil { |
306 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 335 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
307 | } | 336 | } |
337 | + | ||
308 | transactionContext, err := factory.CreateTransactionContext(nil) | 338 | transactionContext, err := factory.CreateTransactionContext(nil) |
309 | if err != nil { | 339 | if err != nil { |
310 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 340 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -315,6 +345,8 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac | @@ -315,6 +345,8 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac | ||
315 | defer func() { | 345 | defer func() { |
316 | transactionContext.RollbackTransaction() | 346 | transactionContext.RollbackTransaction() |
317 | }() | 347 | }() |
348 | + | ||
349 | + // 验收服务初始化 | ||
318 | var acceptanceTaskService service.AcceptanceTaskService | 350 | var acceptanceTaskService service.AcceptanceTaskService |
319 | if value, err := factory.CreateAcceptanceTaskService(map[string]interface{}{ | 351 | if value, err := factory.CreateAcceptanceTaskService(map[string]interface{}{ |
320 | "transactionContext": transactionContext, | 352 | "transactionContext": transactionContext, |
@@ -324,7 +356,50 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac | @@ -324,7 +356,50 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac | ||
324 | acceptanceTaskService = value | 356 | acceptanceTaskService = value |
325 | acceptanceTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{}) | 357 | acceptanceTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{}) |
326 | } | 358 | } |
327 | - if task, err := acceptanceTaskService.Acceptance(acceptanceTaskCommand.TaskId, acceptanceTaskCommand.Operator, acceptanceTaskCommand.Participators, acceptanceTaskCommand.TaskPercentage, acceptanceTaskCommand.ReferenceResourceScore, acceptanceTaskCommand.SolveReport, acceptanceTaskCommand.SolvePictureUrls, acceptanceTaskCommand.ActualCompletionTime); err != nil { | 359 | + |
360 | + // 员工仓储初始化 | ||
361 | + var employeeRepository domain.EmployeeRepository | ||
362 | + if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ | ||
363 | + "transactionContext": transactionContext, | ||
364 | + }); err != nil { | ||
365 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
366 | + } else { | ||
367 | + employeeRepository = value | ||
368 | + } | ||
369 | + | ||
370 | + // 填充百分比员工信息 | ||
371 | + for i, taskPercentage := range acceptanceTaskCommand.TaskPercentage { | ||
372 | + getEmployee := map[string]interface{}{ | ||
373 | + "uid": taskPercentage.Contributor.Uid, | ||
374 | + } | ||
375 | + employeeFound, err := employeeRepository.FindOne(getEmployee) | ||
376 | + if err != nil { | ||
377 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
378 | + } | ||
379 | + if employeeFound == nil { | ||
380 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的员工") | ||
381 | + } | ||
382 | + acceptanceTaskCommand.TaskPercentage[i].Contributor = employeeFound.EmployeeInfo | ||
383 | + } | ||
384 | + | ||
385 | + // 填充评分员工信息 | ||
386 | + for i, referenceResourceScore := range acceptanceTaskCommand.ReferenceResourceScore { | ||
387 | + for j, solveScore := range referenceResourceScore.SolveScore { | ||
388 | + getEmployee := map[string]interface{}{ | ||
389 | + "uid": solveScore.Contributor.Uid, | ||
390 | + } | ||
391 | + employeeFound, err := employeeRepository.FindOne(getEmployee) | ||
392 | + if err != nil { | ||
393 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
394 | + } | ||
395 | + if employeeFound == nil { | ||
396 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的员工") | ||
397 | + } | ||
398 | + acceptanceTaskCommand.ReferenceResourceScore[i].SolveScore[j].Contributor = employeeFound.EmployeeInfo | ||
399 | + } | ||
400 | + } | ||
401 | + | ||
402 | + if task, err := acceptanceTaskService.Acceptance(acceptanceTaskCommand.TaskId, acceptanceTaskCommand.Operator, acceptanceTaskCommand.Participators, acceptanceTaskCommand.SuMoney, acceptanceTaskCommand.TaskPercentage, acceptanceTaskCommand.ReferenceResourceScore, acceptanceTaskCommand.SolveReport, acceptanceTaskCommand.SolvePictureUrls, acceptanceTaskCommand.ActualCompletionTime); err != nil { | ||
328 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 403 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
329 | } else { | 404 | } else { |
330 | if err := transactionContext.CommitTransaction(); err != nil { | 405 | if err := transactionContext.CommitTransaction(); err != nil { |
@@ -336,10 +411,11 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac | @@ -336,10 +411,11 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac | ||
336 | 411 | ||
337 | // 搜索任务 | 412 | // 搜索任务 |
338 | func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTaskCommand) (interface{}, error) { | 413 | func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTaskCommand) (interface{}, error) { |
339 | - if err := searchTaskCommand.ValidateCommand(); err != nil { | 414 | + if err := searchTaskCommand.ValidateCommand(); err != nil { // 校验搜索命令 |
340 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 415 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
341 | } | 416 | } |
342 | - transactionContext, err := factory.CreateTransactionContext(nil) | 417 | + |
418 | + transactionContext, err := factory.CreateTransactionContext(nil) // 工厂类创建事务上下文 | ||
343 | if err != nil { | 419 | if err != nil { |
344 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 420 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
345 | } | 421 | } |
@@ -349,6 +425,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | @@ -349,6 +425,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | ||
349 | defer func() { | 425 | defer func() { |
350 | transactionContext.RollbackTransaction() | 426 | transactionContext.RollbackTransaction() |
351 | }() | 427 | }() |
428 | + | ||
352 | var taskRepository domain.TaskRepository | 429 | var taskRepository domain.TaskRepository |
353 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ | 430 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ |
354 | "transactionContext": transactionContext, | 431 | "transactionContext": transactionContext, |
@@ -357,6 +434,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | @@ -357,6 +434,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | ||
357 | } else { | 434 | } else { |
358 | taskRepository = value | 435 | taskRepository = value |
359 | } | 436 | } |
437 | + | ||
360 | var projectBelongRepository domain.ProjectBelongRepository | 438 | var projectBelongRepository domain.ProjectBelongRepository |
361 | if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{ | 439 | if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{ |
362 | "transactionContext": transactionContext, | 440 | "transactionContext": transactionContext, |
@@ -365,6 +443,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | @@ -365,6 +443,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | ||
365 | } else { | 443 | } else { |
366 | projectBelongRepository = value | 444 | projectBelongRepository = value |
367 | } | 445 | } |
446 | + | ||
368 | projectBelongMap := make(map[int]*domain.ProjectBelong) | 447 | projectBelongMap := make(map[int]*domain.ProjectBelong) |
369 | if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{ | 448 | if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{ |
370 | "companyId": searchTaskCommand.CompanyId, | 449 | "companyId": searchTaskCommand.CompanyId, |
@@ -375,6 +454,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | @@ -375,6 +454,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | ||
375 | projectBelongMap[projectBelong.ProjectBelongId] = projectBelong | 454 | projectBelongMap[projectBelong.ProjectBelongId] = projectBelong |
376 | } | 455 | } |
377 | } | 456 | } |
457 | + | ||
378 | var customerValueRepository domain.CustomerValueRepository | 458 | var customerValueRepository domain.CustomerValueRepository |
379 | if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{ | 459 | if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{ |
380 | "transactionContext": transactionContext, | 460 | "transactionContext": transactionContext, |
@@ -383,6 +463,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | @@ -383,6 +463,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | ||
383 | } else { | 463 | } else { |
384 | customerValueRepository = value | 464 | customerValueRepository = value |
385 | } | 465 | } |
466 | + | ||
386 | customerValueMap := make(map[int]*domain.CustomerValue) | 467 | customerValueMap := make(map[int]*domain.CustomerValue) |
387 | if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{ | 468 | if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{ |
388 | "companyId": searchTaskCommand.CompanyId, | 469 | "companyId": searchTaskCommand.CompanyId, |
@@ -393,6 +474,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | @@ -393,6 +474,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | ||
393 | customerValueMap[customerValue.CustomerValueId] = customerValue | 474 | customerValueMap[customerValue.CustomerValueId] = customerValue |
394 | } | 475 | } |
395 | } | 476 | } |
477 | + | ||
396 | var taskNatureRepository domain.TaskNatureRepository | 478 | var taskNatureRepository domain.TaskNatureRepository |
397 | if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{ | 479 | if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{ |
398 | "transactionContext": transactionContext, | 480 | "transactionContext": transactionContext, |
@@ -401,6 +483,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | @@ -401,6 +483,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | ||
401 | } else { | 483 | } else { |
402 | taskNatureRepository = value | 484 | taskNatureRepository = value |
403 | } | 485 | } |
486 | + | ||
404 | taskNatureMap := make(map[int]*domain.TaskNature) | 487 | taskNatureMap := make(map[int]*domain.TaskNature) |
405 | if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{ | 488 | if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{ |
406 | "companyId": searchTaskCommand.CompanyId, | 489 | "companyId": searchTaskCommand.CompanyId, |
@@ -411,6 +494,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | @@ -411,6 +494,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask | ||
411 | taskNatureMap[taskNature.TaskNatureId] = taskNature | 494 | taskNatureMap[taskNature.TaskNatureId] = taskNature |
412 | } | 495 | } |
413 | } | 496 | } |
497 | + | ||
414 | if count, tasks, err := taskRepository.Find(tool_funs.SimpleStructToMap(searchTaskCommand)); err != nil { | 498 | if count, tasks, err := taskRepository.Find(tool_funs.SimpleStructToMap(searchTaskCommand)); err != nil { |
415 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 499 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
416 | } else { | 500 | } else { |
@@ -437,6 +521,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | @@ -437,6 +521,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | ||
437 | if err := searchOffTaskRecordCommand.ValidateCommand(); err != nil { | 521 | if err := searchOffTaskRecordCommand.ValidateCommand(); err != nil { |
438 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 522 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
439 | } | 523 | } |
524 | + | ||
440 | transactionContext, err := factory.CreateTransactionContext(nil) | 525 | transactionContext, err := factory.CreateTransactionContext(nil) |
441 | if err != nil { | 526 | if err != nil { |
442 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 527 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -447,6 +532,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | @@ -447,6 +532,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | ||
447 | defer func() { | 532 | defer func() { |
448 | transactionContext.RollbackTransaction() | 533 | transactionContext.RollbackTransaction() |
449 | }() | 534 | }() |
535 | + | ||
450 | var projectBelongRepository domain.ProjectBelongRepository | 536 | var projectBelongRepository domain.ProjectBelongRepository |
451 | if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{ | 537 | if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{ |
452 | "transactionContext": transactionContext, | 538 | "transactionContext": transactionContext, |
@@ -455,6 +541,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | @@ -455,6 +541,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | ||
455 | } else { | 541 | } else { |
456 | projectBelongRepository = value | 542 | projectBelongRepository = value |
457 | } | 543 | } |
544 | + | ||
458 | projectBelongMap := make(map[int]*domain.ProjectBelong) | 545 | projectBelongMap := make(map[int]*domain.ProjectBelong) |
459 | if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{ | 546 | if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{ |
460 | "companyId": searchOffTaskRecordCommand.CompanyId, | 547 | "companyId": searchOffTaskRecordCommand.CompanyId, |
@@ -465,6 +552,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | @@ -465,6 +552,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | ||
465 | projectBelongMap[projectBelong.ProjectBelongId] = projectBelong | 552 | projectBelongMap[projectBelong.ProjectBelongId] = projectBelong |
466 | } | 553 | } |
467 | } | 554 | } |
555 | + | ||
468 | var customerValueRepository domain.CustomerValueRepository | 556 | var customerValueRepository domain.CustomerValueRepository |
469 | if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{ | 557 | if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{ |
470 | "transactionContext": transactionContext, | 558 | "transactionContext": transactionContext, |
@@ -473,6 +561,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | @@ -473,6 +561,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | ||
473 | } else { | 561 | } else { |
474 | customerValueRepository = value | 562 | customerValueRepository = value |
475 | } | 563 | } |
564 | + | ||
476 | customerValueMap := make(map[int]*domain.CustomerValue) | 565 | customerValueMap := make(map[int]*domain.CustomerValue) |
477 | if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{ | 566 | if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{ |
478 | "companyId": searchOffTaskRecordCommand.CompanyId, | 567 | "companyId": searchOffTaskRecordCommand.CompanyId, |
@@ -483,6 +572,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | @@ -483,6 +572,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | ||
483 | customerValueMap[customerValue.CustomerValueId] = customerValue | 572 | customerValueMap[customerValue.CustomerValueId] = customerValue |
484 | } | 573 | } |
485 | } | 574 | } |
575 | + | ||
486 | var taskNatureRepository domain.TaskNatureRepository | 576 | var taskNatureRepository domain.TaskNatureRepository |
487 | if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{ | 577 | if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{ |
488 | "transactionContext": transactionContext, | 578 | "transactionContext": transactionContext, |
@@ -491,6 +581,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | @@ -491,6 +581,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | ||
491 | } else { | 581 | } else { |
492 | taskNatureRepository = value | 582 | taskNatureRepository = value |
493 | } | 583 | } |
584 | + | ||
494 | taskNatureMap := make(map[int]*domain.TaskNature) | 585 | taskNatureMap := make(map[int]*domain.TaskNature) |
495 | if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{ | 586 | if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{ |
496 | "companyId": searchOffTaskRecordCommand.CompanyId, | 587 | "companyId": searchOffTaskRecordCommand.CompanyId, |
@@ -501,6 +592,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | @@ -501,6 +592,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | ||
501 | taskNatureMap[taskNature.TaskNatureId] = taskNature | 592 | taskNatureMap[taskNature.TaskNatureId] = taskNature |
502 | } | 593 | } |
503 | } | 594 | } |
595 | + | ||
504 | var taskRepository domain.TaskRepository | 596 | var taskRepository domain.TaskRepository |
505 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ | 597 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ |
506 | "transactionContext": transactionContext, | 598 | "transactionContext": transactionContext, |
@@ -509,6 +601,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | @@ -509,6 +601,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | ||
509 | } else { | 601 | } else { |
510 | taskRepository = value | 602 | taskRepository = value |
511 | } | 603 | } |
604 | + | ||
512 | var offTaskRecordRepository domain.OffTaskRecordRepository | 605 | var offTaskRecordRepository domain.OffTaskRecordRepository |
513 | if value, err := factory.CreateOffTaskRecordRepository(map[string]interface{}{ | 606 | if value, err := factory.CreateOffTaskRecordRepository(map[string]interface{}{ |
514 | "transactionContext": transactionContext, | 607 | "transactionContext": transactionContext, |
@@ -517,6 +610,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | @@ -517,6 +610,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand * | ||
517 | } else { | 610 | } else { |
518 | offTaskRecordRepository = value | 611 | offTaskRecordRepository = value |
519 | } | 612 | } |
613 | + | ||
520 | _, tasks, err := taskRepository.Find(map[string]interface{}{ | 614 | _, tasks, err := taskRepository.Find(map[string]interface{}{ |
521 | "companyId": searchOffTaskRecordCommand.CompanyId, | 615 | "companyId": searchOffTaskRecordCommand.CompanyId, |
522 | "taskStatus": domain.TASK_STATUS_CLOSED, | 616 | "taskStatus": domain.TASK_STATUS_CLOSED, |
@@ -570,6 +664,7 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge | @@ -570,6 +664,7 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge | ||
570 | if err := getOffTaskRecordQuery.ValidateQuery(); err != nil { | 664 | if err := getOffTaskRecordQuery.ValidateQuery(); err != nil { |
571 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 665 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
572 | } | 666 | } |
667 | + | ||
573 | transactionContext, err := factory.CreateTransactionContext(nil) | 668 | transactionContext, err := factory.CreateTransactionContext(nil) |
574 | if err != nil { | 669 | if err != nil { |
575 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 670 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -580,6 +675,7 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge | @@ -580,6 +675,7 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge | ||
580 | defer func() { | 675 | defer func() { |
581 | transactionContext.RollbackTransaction() | 676 | transactionContext.RollbackTransaction() |
582 | }() | 677 | }() |
678 | + | ||
583 | var offTaskRecordRepository domain.OffTaskRecordRepository | 679 | var offTaskRecordRepository domain.OffTaskRecordRepository |
584 | if value, err := factory.CreateOffTaskRecordRepository(map[string]interface{}{ | 680 | if value, err := factory.CreateOffTaskRecordRepository(map[string]interface{}{ |
585 | "transactionContext": transactionContext, | 681 | "transactionContext": transactionContext, |
@@ -588,6 +684,7 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge | @@ -588,6 +684,7 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge | ||
588 | } else { | 684 | } else { |
589 | offTaskRecordRepository = value | 685 | offTaskRecordRepository = value |
590 | } | 686 | } |
687 | + | ||
591 | offTaskRecord, err := offTaskRecordRepository.FindOne(map[string]interface{}{"offTaskRecordId": getOffTaskRecordQuery.OffTaskRecordId}) | 688 | offTaskRecord, err := offTaskRecordRepository.FindOne(map[string]interface{}{"offTaskRecordId": getOffTaskRecordQuery.OffTaskRecordId}) |
592 | if err != nil { | 689 | if err != nil { |
593 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 690 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -607,6 +704,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | @@ -607,6 +704,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | ||
607 | if err := searchRejectTaskRecordCommand.ValidateCommand(); err != nil { | 704 | if err := searchRejectTaskRecordCommand.ValidateCommand(); err != nil { |
608 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 705 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
609 | } | 706 | } |
707 | + | ||
610 | transactionContext, err := factory.CreateTransactionContext(nil) | 708 | transactionContext, err := factory.CreateTransactionContext(nil) |
611 | if err != nil { | 709 | if err != nil { |
612 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 710 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -617,6 +715,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | @@ -617,6 +715,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | ||
617 | defer func() { | 715 | defer func() { |
618 | transactionContext.RollbackTransaction() | 716 | transactionContext.RollbackTransaction() |
619 | }() | 717 | }() |
718 | + | ||
620 | var projectBelongRepository domain.ProjectBelongRepository | 719 | var projectBelongRepository domain.ProjectBelongRepository |
621 | if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{ | 720 | if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{ |
622 | "transactionContext": transactionContext, | 721 | "transactionContext": transactionContext, |
@@ -625,6 +724,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | @@ -625,6 +724,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | ||
625 | } else { | 724 | } else { |
626 | projectBelongRepository = value | 725 | projectBelongRepository = value |
627 | } | 726 | } |
727 | + | ||
628 | projectBelongMap := make(map[int]*domain.ProjectBelong) | 728 | projectBelongMap := make(map[int]*domain.ProjectBelong) |
629 | if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{ | 729 | if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{ |
630 | "companyId": searchRejectTaskRecordCommand.CompanyId, | 730 | "companyId": searchRejectTaskRecordCommand.CompanyId, |
@@ -635,6 +735,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | @@ -635,6 +735,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | ||
635 | projectBelongMap[projectBelong.ProjectBelongId] = projectBelong | 735 | projectBelongMap[projectBelong.ProjectBelongId] = projectBelong |
636 | } | 736 | } |
637 | } | 737 | } |
738 | + | ||
638 | var customerValueRepository domain.CustomerValueRepository | 739 | var customerValueRepository domain.CustomerValueRepository |
639 | if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{ | 740 | if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{ |
640 | "transactionContext": transactionContext, | 741 | "transactionContext": transactionContext, |
@@ -643,6 +744,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | @@ -643,6 +744,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | ||
643 | } else { | 744 | } else { |
644 | customerValueRepository = value | 745 | customerValueRepository = value |
645 | } | 746 | } |
747 | + | ||
646 | customerValueMap := make(map[int]*domain.CustomerValue) | 748 | customerValueMap := make(map[int]*domain.CustomerValue) |
647 | if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{ | 749 | if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{ |
648 | "companyId": searchRejectTaskRecordCommand.CompanyId, | 750 | "companyId": searchRejectTaskRecordCommand.CompanyId, |
@@ -653,6 +755,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | @@ -653,6 +755,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | ||
653 | customerValueMap[customerValue.CustomerValueId] = customerValue | 755 | customerValueMap[customerValue.CustomerValueId] = customerValue |
654 | } | 756 | } |
655 | } | 757 | } |
758 | + | ||
656 | var taskNatureRepository domain.TaskNatureRepository | 759 | var taskNatureRepository domain.TaskNatureRepository |
657 | if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{ | 760 | if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{ |
658 | "transactionContext": transactionContext, | 761 | "transactionContext": transactionContext, |
@@ -661,6 +764,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | @@ -661,6 +764,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | ||
661 | } else { | 764 | } else { |
662 | taskNatureRepository = value | 765 | taskNatureRepository = value |
663 | } | 766 | } |
767 | + | ||
664 | taskNatureMap := make(map[int]*domain.TaskNature) | 768 | taskNatureMap := make(map[int]*domain.TaskNature) |
665 | if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{ | 769 | if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{ |
666 | "companyId": searchRejectTaskRecordCommand.CompanyId, | 770 | "companyId": searchRejectTaskRecordCommand.CompanyId, |
@@ -671,6 +775,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | @@ -671,6 +775,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | ||
671 | taskNatureMap[taskNature.TaskNatureId] = taskNature | 775 | taskNatureMap[taskNature.TaskNatureId] = taskNature |
672 | } | 776 | } |
673 | } | 777 | } |
778 | + | ||
674 | var taskRepository domain.TaskRepository | 779 | var taskRepository domain.TaskRepository |
675 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ | 780 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ |
676 | "transactionContext": transactionContext, | 781 | "transactionContext": transactionContext, |
@@ -679,6 +784,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | @@ -679,6 +784,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | ||
679 | } else { | 784 | } else { |
680 | taskRepository = value | 785 | taskRepository = value |
681 | } | 786 | } |
787 | + | ||
682 | var rejectTaskRecordRepository domain.RejectTaskRecordRepository | 788 | var rejectTaskRecordRepository domain.RejectTaskRecordRepository |
683 | if value, err := factory.CreateRejectTaskRecordRepository(map[string]interface{}{ | 789 | if value, err := factory.CreateRejectTaskRecordRepository(map[string]interface{}{ |
684 | "transactionContext": transactionContext, | 790 | "transactionContext": transactionContext, |
@@ -687,6 +793,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | @@ -687,6 +793,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | ||
687 | } else { | 793 | } else { |
688 | rejectTaskRecordRepository = value | 794 | rejectTaskRecordRepository = value |
689 | } | 795 | } |
796 | + | ||
690 | _, tasks, err := taskRepository.Find(map[string]interface{}{ | 797 | _, tasks, err := taskRepository.Find(map[string]interface{}{ |
691 | "companyId": searchRejectTaskRecordCommand.CompanyId, | 798 | "companyId": searchRejectTaskRecordCommand.CompanyId, |
692 | "taskContentMatch": searchRejectTaskRecordCommand.TaskContentMatch, | 799 | "taskContentMatch": searchRejectTaskRecordCommand.TaskContentMatch, |
@@ -702,6 +809,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | @@ -702,6 +809,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom | ||
702 | for _, task := range tasks { | 809 | for _, task := range tasks { |
703 | taskIds = append(taskIds, task.TaskId) | 810 | taskIds = append(taskIds, task.TaskId) |
704 | } | 811 | } |
812 | + | ||
705 | if count, rejectTaskRecords, err := rejectTaskRecordRepository.Find(map[string]interface{}{ | 813 | if count, rejectTaskRecords, err := rejectTaskRecordRepository.Find(map[string]interface{}{ |
706 | "taskIds": taskIds, | 814 | "taskIds": taskIds, |
707 | "rejectStartTime": searchRejectTaskRecordCommand.RejectStartTime, | 815 | "rejectStartTime": searchRejectTaskRecordCommand.RejectStartTime, |
@@ -739,6 +847,7 @@ func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *qu | @@ -739,6 +847,7 @@ func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *qu | ||
739 | if err := getRejectTaskRecordQuery.ValidateQuery(); err != nil { | 847 | if err := getRejectTaskRecordQuery.ValidateQuery(); err != nil { |
740 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 848 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
741 | } | 849 | } |
850 | + | ||
742 | transactionContext, err := factory.CreateTransactionContext(nil) | 851 | transactionContext, err := factory.CreateTransactionContext(nil) |
743 | if err != nil { | 852 | if err != nil { |
744 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 853 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -749,6 +858,7 @@ func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *qu | @@ -749,6 +858,7 @@ func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *qu | ||
749 | defer func() { | 858 | defer func() { |
750 | transactionContext.RollbackTransaction() | 859 | transactionContext.RollbackTransaction() |
751 | }() | 860 | }() |
861 | + | ||
752 | var rejectTaskRecordRepository domain.RejectTaskRecordRepository | 862 | var rejectTaskRecordRepository domain.RejectTaskRecordRepository |
753 | if value, err := factory.CreateRejectTaskRecordRepository(map[string]interface{}{ | 863 | if value, err := factory.CreateRejectTaskRecordRepository(map[string]interface{}{ |
754 | "transactionContext": transactionContext, | 864 | "transactionContext": transactionContext, |
@@ -757,6 +867,7 @@ func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *qu | @@ -757,6 +867,7 @@ func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *qu | ||
757 | } else { | 867 | } else { |
758 | rejectTaskRecordRepository = value | 868 | rejectTaskRecordRepository = value |
759 | } | 869 | } |
870 | + | ||
760 | rejectTaskRecord, err := rejectTaskRecordRepository.FindOne(map[string]interface{}{"rejectTaskRecordId": getRejectTaskRecordQuery.RejectTaskRecordId}) | 871 | rejectTaskRecord, err := rejectTaskRecordRepository.FindOne(map[string]interface{}{"rejectTaskRecordId": getRejectTaskRecordQuery.RejectTaskRecordId}) |
761 | if err != nil { | 872 | if err != nil { |
762 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 873 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -776,6 +887,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -776,6 +887,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
776 | if err := createTaskCommand.ValidateCommand(); err != nil { | 887 | if err := createTaskCommand.ValidateCommand(); err != nil { |
777 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 888 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
778 | } | 889 | } |
890 | + | ||
779 | transactionContext, err := factory.CreateTransactionContext(nil) | 891 | transactionContext, err := factory.CreateTransactionContext(nil) |
780 | if err != nil { | 892 | if err != nil { |
781 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 893 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -786,6 +898,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -786,6 +898,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
786 | defer func() { | 898 | defer func() { |
787 | transactionContext.RollbackTransaction() | 899 | transactionContext.RollbackTransaction() |
788 | }() | 900 | }() |
901 | + | ||
789 | var taskDao *dao.TaskDao | 902 | var taskDao *dao.TaskDao |
790 | if value, err := factory.CreateTaskDao(map[string]interface{}{ | 903 | if value, err := factory.CreateTaskDao(map[string]interface{}{ |
791 | "transactionContext": transactionContext, | 904 | "transactionContext": transactionContext, |
@@ -794,6 +907,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -794,6 +907,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
794 | } else { | 907 | } else { |
795 | taskDao = value | 908 | taskDao = value |
796 | } | 909 | } |
910 | + | ||
797 | var employeeRepository domain.EmployeeRepository | 911 | var employeeRepository domain.EmployeeRepository |
798 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ | 912 | if value, err := factory.CreateEmployeeRepository(map[string]interface{}{ |
799 | "transactionContext": transactionContext, | 913 | "transactionContext": transactionContext, |
@@ -802,28 +916,54 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -802,28 +916,54 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
802 | } else { | 916 | } else { |
803 | employeeRepository = value | 917 | employeeRepository = value |
804 | } | 918 | } |
919 | + | ||
805 | sponsor, err := employeeRepository.FindOne(map[string]interface{}{ | 920 | sponsor, err := employeeRepository.FindOne(map[string]interface{}{ |
806 | "uid": createTaskCommand.Sponsor, | 921 | "uid": createTaskCommand.Sponsor, |
922 | + "status": 1, | ||
807 | }) | 923 | }) |
808 | if err != nil { | 924 | if err != nil { |
809 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 925 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
810 | } | 926 | } |
811 | if sponsor == nil { | 927 | if sponsor == nil { |
928 | + // 获取无效的发布人员信息 | ||
929 | + sponsorInvalid, err := employeeRepository.FindOne(map[string]interface{}{ | ||
930 | + "uid": createTaskCommand.AssignedPerson, | ||
931 | + }) | ||
932 | + if err != nil { | ||
933 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
934 | + } | ||
935 | + if sponsorInvalid == nil { | ||
812 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者") | 936 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者") |
813 | } | 937 | } |
938 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者:"+ sponsorInvalid.EmployeeInfo.EmployeeName) | ||
939 | + } | ||
940 | + | ||
941 | + // 获取任务指派人 | ||
814 | var assignedPerson *domain.EmployeeInfo | 942 | var assignedPerson *domain.EmployeeInfo |
815 | if createTaskCommand.AssignedPerson != 0 { | 943 | if createTaskCommand.AssignedPerson != 0 { |
816 | employee, err := employeeRepository.FindOne(map[string]interface{}{ | 944 | employee, err := employeeRepository.FindOne(map[string]interface{}{ |
817 | "uid": createTaskCommand.AssignedPerson, | 945 | "uid": createTaskCommand.AssignedPerson, |
946 | + "status": 1, | ||
818 | }) | 947 | }) |
819 | if err != nil { | 948 | if err != nil { |
820 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 949 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
821 | } | 950 | } |
822 | if employee == nil { | 951 | if employee == nil { |
952 | + // 获取无效的指派人员信息 | ||
953 | + employeeInvalid, err := employeeRepository.FindOne(map[string]interface{}{ | ||
954 | + "uid": createTaskCommand.AssignedPerson, | ||
955 | + }) | ||
956 | + if err != nil { | ||
957 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
958 | + } | ||
959 | + if employeeInvalid == nil { | ||
823 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员") | 960 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员") |
824 | } | 961 | } |
962 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:" + employeeInvalid.EmployeeInfo.EmployeeName) | ||
963 | + } | ||
825 | assignedPerson = employee.EmployeeInfo | 964 | assignedPerson = employee.EmployeeInfo |
826 | } | 965 | } |
966 | + | ||
827 | newTask := &domain.Task{ | 967 | newTask := &domain.Task{ |
828 | TaskStatus: domain.TASK_STATUS_UNRELEASED, | 968 | TaskStatus: domain.TASK_STATUS_UNRELEASED, |
829 | CompanyId: createTaskCommand.CompanyId, | 969 | CompanyId: createTaskCommand.CompanyId, |
@@ -838,6 +978,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -838,6 +978,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
838 | CustomerValues: createTaskCommand.CustomerValues, | 978 | CustomerValues: createTaskCommand.CustomerValues, |
839 | TaskNature: createTaskCommand.TaskNature, | 979 | TaskNature: createTaskCommand.TaskNature, |
840 | SuMoney: createTaskCommand.SuMoney, | 980 | SuMoney: createTaskCommand.SuMoney, |
981 | + MinSuMoney: createTaskCommand.MinSuMoney, | ||
982 | + MaxSuMoney: createTaskCommand.MaxSuMoney, | ||
841 | AcceptanceStandard: createTaskCommand.AcceptanceStandard, | 983 | AcceptanceStandard: createTaskCommand.AcceptanceStandard, |
842 | TaskDescription: createTaskCommand.TaskDescription, | 984 | TaskDescription: createTaskCommand.TaskDescription, |
843 | TaskPictureUrls: createTaskCommand.TaskPictureUrls, | 985 | TaskPictureUrls: createTaskCommand.TaskPictureUrls, |
@@ -846,6 +988,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -846,6 +988,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
846 | PlannedCompletionTime: createTaskCommand.PlannedCompletionTime, | 988 | PlannedCompletionTime: createTaskCommand.PlannedCompletionTime, |
847 | CreateTime: time.Now(), | 989 | CreateTime: time.Now(), |
848 | } | 990 | } |
991 | + | ||
849 | var taskRepository domain.TaskRepository | 992 | var taskRepository domain.TaskRepository |
850 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ | 993 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ |
851 | "transactionContext": transactionContext, | 994 | "transactionContext": transactionContext, |
@@ -854,6 +997,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -854,6 +997,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
854 | } else { | 997 | } else { |
855 | taskRepository = value | 998 | taskRepository = value |
856 | } | 999 | } |
1000 | + | ||
857 | if createTaskCommand.ReferenceResourceItems != nil && len(createTaskCommand.ReferenceResourceItems) > 0 { | 1001 | if createTaskCommand.ReferenceResourceItems != nil && len(createTaskCommand.ReferenceResourceItems) > 0 { |
858 | var referenceResourceIds []int64 | 1002 | var referenceResourceIds []int64 |
859 | for _, referenceResourceItem := range createTaskCommand.ReferenceResourceItems { | 1003 | for _, referenceResourceItem := range createTaskCommand.ReferenceResourceItems { |
@@ -871,6 +1015,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | @@ -871,6 +1015,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask | ||
871 | } | 1015 | } |
872 | } | 1016 | } |
873 | } | 1017 | } |
1018 | + | ||
874 | if task, err := taskRepository.Save(newTask); err != nil { | 1019 | if task, err := taskRepository.Save(newTask); err != nil { |
875 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1020 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
876 | } else { | 1021 | } else { |
@@ -908,6 +1053,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | @@ -908,6 +1053,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | ||
908 | if err := getTaskQuery.ValidateQuery(); err != nil { | 1053 | if err := getTaskQuery.ValidateQuery(); err != nil { |
909 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 1054 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
910 | } | 1055 | } |
1056 | + | ||
911 | transactionContext, err := factory.CreateTransactionContext(nil) | 1057 | transactionContext, err := factory.CreateTransactionContext(nil) |
912 | if err != nil { | 1058 | if err != nil { |
913 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1059 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -918,6 +1064,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | @@ -918,6 +1064,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | ||
918 | defer func() { | 1064 | defer func() { |
919 | transactionContext.RollbackTransaction() | 1065 | transactionContext.RollbackTransaction() |
920 | }() | 1066 | }() |
1067 | + | ||
921 | var taskRepository domain.TaskRepository | 1068 | var taskRepository domain.TaskRepository |
922 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ | 1069 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ |
923 | "transactionContext": transactionContext, | 1070 | "transactionContext": transactionContext, |
@@ -926,6 +1073,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | @@ -926,6 +1073,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | ||
926 | } else { | 1073 | } else { |
927 | taskRepository = value | 1074 | taskRepository = value |
928 | } | 1075 | } |
1076 | + | ||
929 | task, err := taskRepository.FindOne(map[string]interface{}{"taskId": getTaskQuery.TaskId}) | 1077 | task, err := taskRepository.FindOne(map[string]interface{}{"taskId": getTaskQuery.TaskId}) |
930 | if err != nil { | 1078 | if err != nil { |
931 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1079 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -941,6 +1089,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | @@ -941,6 +1089,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | ||
941 | } else { | 1089 | } else { |
942 | projectBelongRepository = value | 1090 | projectBelongRepository = value |
943 | } | 1091 | } |
1092 | + | ||
944 | projectBelongMap := make(map[int]*domain.ProjectBelong) | 1093 | projectBelongMap := make(map[int]*domain.ProjectBelong) |
945 | if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{ | 1094 | if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{ |
946 | "companyId": task.CompanyId, | 1095 | "companyId": task.CompanyId, |
@@ -951,6 +1100,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | @@ -951,6 +1100,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | ||
951 | projectBelongMap[projectBelong.ProjectBelongId] = projectBelong | 1100 | projectBelongMap[projectBelong.ProjectBelongId] = projectBelong |
952 | } | 1101 | } |
953 | } | 1102 | } |
1103 | + | ||
954 | var customerValueRepository domain.CustomerValueRepository | 1104 | var customerValueRepository domain.CustomerValueRepository |
955 | if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{ | 1105 | if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{ |
956 | "transactionContext": transactionContext, | 1106 | "transactionContext": transactionContext, |
@@ -959,6 +1109,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | @@ -959,6 +1109,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | ||
959 | } else { | 1109 | } else { |
960 | customerValueRepository = value | 1110 | customerValueRepository = value |
961 | } | 1111 | } |
1112 | + | ||
962 | customerValueMap := make(map[int]*domain.CustomerValue) | 1113 | customerValueMap := make(map[int]*domain.CustomerValue) |
963 | if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{ | 1114 | if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{ |
964 | "companyId": task.CompanyId, | 1115 | "companyId": task.CompanyId, |
@@ -969,6 +1120,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | @@ -969,6 +1120,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | ||
969 | customerValueMap[customerValue.CustomerValueId] = customerValue | 1120 | customerValueMap[customerValue.CustomerValueId] = customerValue |
970 | } | 1121 | } |
971 | } | 1122 | } |
1123 | + | ||
972 | var taskNatureRepository domain.TaskNatureRepository | 1124 | var taskNatureRepository domain.TaskNatureRepository |
973 | if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{ | 1125 | if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{ |
974 | "transactionContext": transactionContext, | 1126 | "transactionContext": transactionContext, |
@@ -977,6 +1129,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | @@ -977,6 +1129,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | ||
977 | } else { | 1129 | } else { |
978 | taskNatureRepository = value | 1130 | taskNatureRepository = value |
979 | } | 1131 | } |
1132 | + | ||
980 | taskNatureMap := make(map[int]*domain.TaskNature) | 1133 | taskNatureMap := make(map[int]*domain.TaskNature) |
981 | if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{ | 1134 | if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{ |
982 | "companyId": task.CompanyId, | 1135 | "companyId": task.CompanyId, |
@@ -987,6 +1140,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | @@ -987,6 +1140,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | ||
987 | taskNatureMap[taskNature.TaskNatureId] = taskNature | 1140 | taskNatureMap[taskNature.TaskNatureId] = taskNature |
988 | } | 1141 | } |
989 | } | 1142 | } |
1143 | + | ||
990 | taskDto := &dto.TaskDto{} | 1144 | taskDto := &dto.TaskDto{} |
991 | if err := taskDto.LoadDto(task, projectBelongMap, customerValueMap, taskNatureMap); err != nil { | 1145 | if err := taskDto.LoadDto(task, projectBelongMap, customerValueMap, taskNatureMap); err != nil { |
992 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1146 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -994,15 +1148,55 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | @@ -994,15 +1148,55 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter | ||
994 | if err := transactionContext.CommitTransaction(); err != nil { | 1148 | if err := transactionContext.CommitTransaction(); err != nil { |
995 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1149 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
996 | } | 1150 | } |
1151 | + | ||
1152 | + // 返回任务素币奖励范围 | ||
1153 | + if taskDto.TaskStatus != 5 && task.MinSuMoney == 0 && task.MaxSuMoney == 0 { | ||
1154 | + taskDto.MinSuMoney = 0 | ||
1155 | + taskDto.MaxSuMoney = task.SuMoney | ||
1156 | + } | ||
1157 | + | ||
997 | return taskDto, nil | 1158 | return taskDto, nil |
998 | } | 1159 | } |
999 | } | 1160 | } |
1000 | 1161 | ||
1162 | +// 更新过期任务状态 | ||
1163 | +func (taskService *TaskService) UpdateTaskStatus() (interface{}, error) { | ||
1164 | + transactionContext, err := factory.CreateTransactionContext(nil) | ||
1165 | + if err != nil { | ||
1166 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1167 | + } | ||
1168 | + if err := transactionContext.StartTransaction(); err != nil { | ||
1169 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1170 | + } | ||
1171 | + defer func() { | ||
1172 | + transactionContext.RollbackTransaction() | ||
1173 | + }() | ||
1174 | + | ||
1175 | + var taskDao *dao.TaskDao | ||
1176 | + if value, err := factory.CreateTaskDao(map[string]interface{}{ | ||
1177 | + "transactionContext": transactionContext, | ||
1178 | + }); err != nil { | ||
1179 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1180 | + } else { | ||
1181 | + taskDao = value | ||
1182 | + } | ||
1183 | + | ||
1184 | + if err := taskDao.UpdateExpiredPlannedCompletionTimeBidTask(); err != nil { | ||
1185 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1186 | + } | ||
1187 | + | ||
1188 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
1189 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
1190 | + } | ||
1191 | + return nil, nil | ||
1192 | +} | ||
1193 | + | ||
1001 | // 更新任务 | 1194 | // 更新任务 |
1002 | func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTaskCommand) (interface{}, error) { | 1195 | func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTaskCommand) (interface{}, error) { |
1003 | if err := updateTaskCommand.ValidateCommand(); err != nil { | 1196 | if err := updateTaskCommand.ValidateCommand(); err != nil { |
1004 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 1197 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
1005 | } | 1198 | } |
1199 | + | ||
1006 | transactionContext, err := factory.CreateTransactionContext(nil) | 1200 | transactionContext, err := factory.CreateTransactionContext(nil) |
1007 | if err != nil { | 1201 | if err != nil { |
1008 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1202 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -1013,6 +1207,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | @@ -1013,6 +1207,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | ||
1013 | defer func() { | 1207 | defer func() { |
1014 | transactionContext.RollbackTransaction() | 1208 | transactionContext.RollbackTransaction() |
1015 | }() | 1209 | }() |
1210 | + | ||
1016 | var taskRepository domain.TaskRepository | 1211 | var taskRepository domain.TaskRepository |
1017 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ | 1212 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ |
1018 | "transactionContext": transactionContext, | 1213 | "transactionContext": transactionContext, |
@@ -1021,6 +1216,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | @@ -1021,6 +1216,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | ||
1021 | } else { | 1216 | } else { |
1022 | taskRepository = value | 1217 | taskRepository = value |
1023 | } | 1218 | } |
1219 | + | ||
1024 | var taskDao *dao.TaskDao | 1220 | var taskDao *dao.TaskDao |
1025 | if value, err := factory.CreateTaskDao(map[string]interface{}{ | 1221 | if value, err := factory.CreateTaskDao(map[string]interface{}{ |
1026 | "transactionContext": transactionContext, | 1222 | "transactionContext": transactionContext, |
@@ -1029,13 +1225,34 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | @@ -1029,13 +1225,34 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | ||
1029 | } else { | 1225 | } else { |
1030 | taskDao = value | 1226 | taskDao = value |
1031 | } | 1227 | } |
1228 | + | ||
1229 | + var releaseTaskService service.ReleaseTaskService | ||
1230 | + if value, err := factory.CreateReleaseTaskService(map[string]interface{}{ | ||
1231 | + "transactionContext": transactionContext, | ||
1232 | + }); err != nil { | ||
1233 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1234 | + } else { | ||
1235 | + releaseTaskService = value | ||
1236 | + releaseTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{}) | ||
1237 | + releaseTaskService.Subscribe(&subscriber.MmmOpenApiServiceServiceSubscriber{ | ||
1238 | + TransactionContext: transactionContext.(*pgTransaction.TransactionContext), | ||
1239 | + }) | ||
1240 | + } | ||
1241 | + | ||
1242 | + var taskBidEndTime time.Time | ||
1243 | + // 找到当前任务 | ||
1032 | task, err := taskRepository.FindOne(map[string]interface{}{"taskId": updateTaskCommand.TaskId}) | 1244 | task, err := taskRepository.FindOne(map[string]interface{}{"taskId": updateTaskCommand.TaskId}) |
1033 | if err != nil { | 1245 | if err != nil { |
1034 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1246 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1035 | } | 1247 | } |
1036 | if task == nil { | 1248 | if task == nil { |
1037 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateTaskCommand.TaskId))) | 1249 | return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateTaskCommand.TaskId))) |
1250 | + } else { | ||
1251 | + if task.TaskStatus == domain.TASK_STATUS_EXPIRED { | ||
1252 | + taskBidEndTime = task.BidInfo.BidEndTime | ||
1253 | + } | ||
1038 | } | 1254 | } |
1255 | + | ||
1039 | if updateTaskCommand.ReferenceResourceItems != nil && len(updateTaskCommand.ReferenceResourceItems) > 0 { | 1256 | if updateTaskCommand.ReferenceResourceItems != nil && len(updateTaskCommand.ReferenceResourceItems) > 0 { |
1040 | var referenceResourceIds []int64 | 1257 | var referenceResourceIds []int64 |
1041 | for _, referenceResourceItem := range updateTaskCommand.ReferenceResourceItems { | 1258 | for _, referenceResourceItem := range updateTaskCommand.ReferenceResourceItems { |
@@ -1058,8 +1275,11 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | @@ -1058,8 +1275,11 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | ||
1058 | } | 1275 | } |
1059 | } | 1276 | } |
1060 | } | 1277 | } |
1278 | + | ||
1061 | updateData := tool_funs.SimpleStructToMap(updateTaskCommand) | 1279 | updateData := tool_funs.SimpleStructToMap(updateTaskCommand) |
1280 | + | ||
1062 | fmt.Println(updateTaskCommand.AssignedPerson != int64(0)) | 1281 | fmt.Println(updateTaskCommand.AssignedPerson != int64(0)) |
1282 | + | ||
1063 | if task.TaskType == domain.TASK_TYPE_DESIGNATE { | 1283 | if task.TaskType == domain.TASK_TYPE_DESIGNATE { |
1064 | if updateTaskCommand.AssignedPerson != int64(0) { | 1284 | if updateTaskCommand.AssignedPerson != int64(0) { |
1065 | var employeeRepository domain.EmployeeRepository | 1285 | var employeeRepository domain.EmployeeRepository |
@@ -1072,18 +1292,30 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | @@ -1072,18 +1292,30 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | ||
1072 | } | 1292 | } |
1073 | employee, err := employeeRepository.FindOne(map[string]interface{}{ | 1293 | employee, err := employeeRepository.FindOne(map[string]interface{}{ |
1074 | "uid": updateTaskCommand.AssignedPerson, | 1294 | "uid": updateTaskCommand.AssignedPerson, |
1295 | + "status": 1, | ||
1075 | }) | 1296 | }) |
1076 | if err != nil { | 1297 | if err != nil { |
1077 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1298 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1078 | } | 1299 | } |
1079 | if employee == nil { | 1300 | if employee == nil { |
1301 | + // 获取无效的发布人员信息 | ||
1302 | + employeeInvalid, err := employeeRepository.FindOne(map[string]interface{}{ | ||
1303 | + "uid": updateTaskCommand.AssignedPerson, | ||
1304 | + }) | ||
1305 | + if err != nil { | ||
1306 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1307 | + } | ||
1308 | + if employeeInvalid == nil { | ||
1080 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员") | 1309 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员") |
1081 | } | 1310 | } |
1311 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:" + employeeInvalid.EmployeeInfo.EmployeeName) | ||
1312 | + } | ||
1082 | updateData["assignedPerson"] = employee.EmployeeInfo | 1313 | updateData["assignedPerson"] = employee.EmployeeInfo |
1083 | } else { | 1314 | } else { |
1084 | updateData["assignedPerson"] = &domain.EmployeeInfo{} | 1315 | updateData["assignedPerson"] = &domain.EmployeeInfo{} |
1085 | } | 1316 | } |
1086 | } | 1317 | } |
1318 | + | ||
1087 | if err := task.Update(updateData); err != nil { | 1319 | if err := task.Update(updateData); err != nil { |
1088 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) | 1320 | return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) |
1089 | } | 1321 | } |
@@ -1095,6 +1327,18 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | @@ -1095,6 +1327,18 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask | ||
1095 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1327 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1096 | } | 1328 | } |
1097 | } | 1329 | } |
1330 | + | ||
1331 | + if task.TaskStatus == domain.TASK_STATUS_EXPIRED { | ||
1332 | + // 未修改时间或者修改的时间小于当前时间 | ||
1333 | + if updateTaskCommand.BidEndTime.Local().Equal(taskBidEndTime.Local()) || updateTaskCommand.BidEndTime.Local().Before(time.Date(time.Now().Local().Year(), time.Now().Local().Month(), time.Now().Local().Day(), 23, 59, 59, 0, time.Local)) { | ||
1334 | + return nil, application.ThrowError(application.BUSINESS_ERROR, "请重新修改竞标时间") | ||
1335 | + } else { | ||
1336 | + if _, err := releaseTaskService.Release(task.TaskId, task.Sponsor.Uid); err != nil { | ||
1337 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
1338 | + } | ||
1339 | + } | ||
1340 | + } | ||
1341 | + | ||
1098 | if err := transactionContext.CommitTransaction(); err != nil { | 1342 | if err := transactionContext.CommitTransaction(); err != nil { |
1099 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1343 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
1100 | } | 1344 | } |
@@ -1124,6 +1368,7 @@ func (taskService *TaskService) RemoveTask(removeTaskCommand *command.RemoveTask | @@ -1124,6 +1368,7 @@ func (taskService *TaskService) RemoveTask(removeTaskCommand *command.RemoveTask | ||
1124 | if err := removeTaskCommand.ValidateCommand(); err != nil { | 1368 | if err := removeTaskCommand.ValidateCommand(); err != nil { |
1125 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 1369 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
1126 | } | 1370 | } |
1371 | + | ||
1127 | transactionContext, err := factory.CreateTransactionContext(nil) | 1372 | transactionContext, err := factory.CreateTransactionContext(nil) |
1128 | if err != nil { | 1373 | if err != nil { |
1129 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1374 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -1134,6 +1379,7 @@ func (taskService *TaskService) RemoveTask(removeTaskCommand *command.RemoveTask | @@ -1134,6 +1379,7 @@ func (taskService *TaskService) RemoveTask(removeTaskCommand *command.RemoveTask | ||
1134 | defer func() { | 1379 | defer func() { |
1135 | transactionContext.RollbackTransaction() | 1380 | transactionContext.RollbackTransaction() |
1136 | }() | 1381 | }() |
1382 | + | ||
1137 | var taskRepository domain.TaskRepository | 1383 | var taskRepository domain.TaskRepository |
1138 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ | 1384 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ |
1139 | "transactionContext": transactionContext, | 1385 | "transactionContext": transactionContext, |
@@ -1142,6 +1388,7 @@ func (taskService *TaskService) RemoveTask(removeTaskCommand *command.RemoveTask | @@ -1142,6 +1388,7 @@ func (taskService *TaskService) RemoveTask(removeTaskCommand *command.RemoveTask | ||
1142 | } else { | 1388 | } else { |
1143 | taskRepository = value | 1389 | taskRepository = value |
1144 | } | 1390 | } |
1391 | + | ||
1145 | task, err := taskRepository.FindOne(map[string]interface{}{"taskId": removeTaskCommand.TaskId}) | 1392 | task, err := taskRepository.FindOne(map[string]interface{}{"taskId": removeTaskCommand.TaskId}) |
1146 | if err != nil { | 1393 | if err != nil { |
1147 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1394 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -1181,6 +1428,7 @@ func (taskService *TaskService) ListTask(listTaskQuery *query.ListTaskQuery) (in | @@ -1181,6 +1428,7 @@ func (taskService *TaskService) ListTask(listTaskQuery *query.ListTaskQuery) (in | ||
1181 | if err := listTaskQuery.ValidateQuery(); err != nil { | 1428 | if err := listTaskQuery.ValidateQuery(); err != nil { |
1182 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 1429 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
1183 | } | 1430 | } |
1431 | + | ||
1184 | transactionContext, err := factory.CreateTransactionContext(nil) | 1432 | transactionContext, err := factory.CreateTransactionContext(nil) |
1185 | if err != nil { | 1433 | if err != nil { |
1186 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1434 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
@@ -1191,6 +1439,7 @@ func (taskService *TaskService) ListTask(listTaskQuery *query.ListTaskQuery) (in | @@ -1191,6 +1439,7 @@ func (taskService *TaskService) ListTask(listTaskQuery *query.ListTaskQuery) (in | ||
1191 | defer func() { | 1439 | defer func() { |
1192 | transactionContext.RollbackTransaction() | 1440 | transactionContext.RollbackTransaction() |
1193 | }() | 1441 | }() |
1442 | + | ||
1194 | var taskRepository domain.TaskRepository | 1443 | var taskRepository domain.TaskRepository |
1195 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ | 1444 | if value, err := factory.CreateTaskRepository(map[string]interface{}{ |
1196 | "transactionContext": transactionContext, | 1445 | "transactionContext": transactionContext, |
@@ -1199,15 +1448,24 @@ func (taskService *TaskService) ListTask(listTaskQuery *query.ListTaskQuery) (in | @@ -1199,15 +1448,24 @@ func (taskService *TaskService) ListTask(listTaskQuery *query.ListTaskQuery) (in | ||
1199 | } else { | 1448 | } else { |
1200 | taskRepository = value | 1449 | taskRepository = value |
1201 | } | 1450 | } |
1451 | + | ||
1202 | if count, tasks, err := taskRepository.Find(tool_funs.SimpleStructToMap(listTaskQuery)); err != nil { | 1452 | if count, tasks, err := taskRepository.Find(tool_funs.SimpleStructToMap(listTaskQuery)); err != nil { |
1203 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 1453 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
1204 | } else { | 1454 | } else { |
1205 | if err := transactionContext.CommitTransaction(); err != nil { | 1455 | if err := transactionContext.CommitTransaction(); err != nil { |
1206 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 1456 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
1207 | } | 1457 | } |
1458 | + var retTasks []*domain.Task | ||
1459 | + for _, task := range tasks { | ||
1460 | + if task.TaskStatus != 5 && task.MinSuMoney == 0 && task.MaxSuMoney == 0 { | ||
1461 | + task.MinSuMoney = 0 | ||
1462 | + task.MaxSuMoney = task.SuMoney | ||
1463 | + } | ||
1464 | + retTasks = append(retTasks, task) | ||
1465 | + } | ||
1208 | return map[string]interface{}{ | 1466 | return map[string]interface{}{ |
1209 | "count": count, | 1467 | "count": count, |
1210 | - "tasks": tasks, | 1468 | + "tasks": retTasks, |
1211 | }, nil | 1469 | }, nil |
1212 | } | 1470 | } |
1213 | } | 1471 | } |
@@ -7,6 +7,7 @@ import ( | @@ -7,6 +7,7 @@ import ( | ||
7 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/unifiedUserCenter/command" | 7 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/unifiedUserCenter/command" |
8 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" | 8 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain" |
9 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" | 9 | "gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao" |
10 | + "time" | ||
10 | ) | 11 | ) |
11 | 12 | ||
12 | // 统一用户中心适配服务 | 13 | // 统一用户中心适配服务 |
@@ -88,12 +89,12 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s | @@ -88,12 +89,12 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s | ||
88 | uids = append(uids, int64(uid.(float64))) | 89 | uids = append(uids, int64(uid.(float64))) |
89 | } | 90 | } |
90 | } | 91 | } |
91 | - if value, ok := data["add"]; ok { | 92 | + if value, ok := data["add"]; ok { // 添加员工 |
92 | for _, addEmployee := range value.([]interface{}) { | 93 | for _, addEmployee := range value.([]interface{}) { |
93 | addEmployees = append(addEmployees, addEmployee.(map[string]interface{})) | 94 | addEmployees = append(addEmployees, addEmployee.(map[string]interface{})) |
94 | } | 95 | } |
95 | } | 96 | } |
96 | - if value, ok := data["edit"]; ok { | 97 | + if value, ok := data["edit"]; ok { // 编辑员工 |
97 | for _, editEmployee := range value.([]interface{}) { | 98 | for _, editEmployee := range value.([]interface{}) { |
98 | editEmployees = append(editEmployees, editEmployee.(map[string]interface{})) | 99 | editEmployees = append(editEmployees, editEmployee.(map[string]interface{})) |
99 | } | 100 | } |
@@ -145,7 +146,9 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s | @@ -145,7 +146,9 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s | ||
145 | }, | 146 | }, |
146 | Status: status, | 147 | Status: status, |
147 | SuMoney: 0, | 148 | SuMoney: 0, |
149 | + CreateTime: time.Now(), | ||
148 | } | 150 | } |
151 | + | ||
149 | if _, err := employeeRepository.Save(employee); err != nil { | 152 | if _, err := employeeRepository.Save(employee); err != nil { |
150 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 153 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
151 | } | 154 | } |
@@ -205,6 +208,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s | @@ -205,6 +208,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s | ||
205 | }, | 208 | }, |
206 | Status: status, | 209 | Status: status, |
207 | SuMoney: 0, | 210 | SuMoney: 0, |
211 | + CreateTime: time.Now(), | ||
208 | } | 212 | } |
209 | if _, err := employeeRepository.Save(employee); err != nil { | 213 | if _, err := employeeRepository.Save(employee); err != nil { |
210 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | 214 | return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) |
@@ -8,6 +8,9 @@ var LOG_LEVEL = "debug" | @@ -8,6 +8,9 @@ var LOG_LEVEL = "debug" | ||
8 | var ABILITY_SERVICE_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" | 8 | var ABILITY_SERVICE_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com" |
9 | var MMM_OPEN_API_SERVICE_HOST = "http://mmm-open-api-dev.fjmaimaimai.com" | 9 | var MMM_OPEN_API_SERVICE_HOST = "http://mmm-open-api-dev.fjmaimaimai.com" |
10 | 10 | ||
11 | +//var LOG_LEVEL = "debug" | ||
12 | +var LOG_File = "logs/app.log" | ||
13 | + | ||
11 | func init() { | 14 | func init() { |
12 | if os.Getenv("LOG_LEVEL") != "" { | 15 | if os.Getenv("LOG_LEVEL") != "" { |
13 | LOG_LEVEL = os.Getenv("LOG_LEVEL") | 16 | LOG_LEVEL = os.Getenv("LOG_LEVEL") |
@@ -2,11 +2,11 @@ package constant | @@ -2,11 +2,11 @@ package constant | ||
2 | 2 | ||
3 | import "os" | 3 | import "os" |
4 | 4 | ||
5 | -var POSTGRESQL_DB_NAME = "mmm-worth" | 5 | +var POSTGRESQL_DB_NAME = "mmm-worth-test" |
6 | var POSTGRESQL_USER = "postgres" | 6 | var POSTGRESQL_USER = "postgres" |
7 | -var POSTGRESQL_PASSWORD = "abc123456" | 7 | +var POSTGRESQL_PASSWORD = "1993618jack" |
8 | var POSTGRESQL_HOST = "127.0.0.1" | 8 | var POSTGRESQL_HOST = "127.0.0.1" |
9 | -var POSTGRESQL_PORT = "32432" | 9 | +var POSTGRESQL_PORT = "5432" |
10 | var DISABLE_CREATE_TABLE = false | 10 | var DISABLE_CREATE_TABLE = false |
11 | var DISABLE_SQL_GENERATE_PRINT = false | 11 | var DISABLE_SQL_GENERATE_PRINT = false |
12 | 12 |
pkg/domain/cash_pool.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import ( | ||
4 | + "time" | ||
5 | +) | ||
6 | + | ||
7 | +// 现金池 | ||
8 | +type CashPool struct { | ||
9 | + CashPoolId int64 `json:"cashPoolId"` // 现金池id | ||
10 | + Cash float64 `json:"cash"` // 投入现金池的现金 | ||
11 | + CompanyId int64 `json:"companyId"` // 公司id | ||
12 | + ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金 | ||
13 | + UnExchangeCash float64 `json:"unExchangeCash"` // 未兑换的现金 | ||
14 | + ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币 | ||
15 | + UnExchangeSuMoney float64 `json:"unExchangeSuMoney"` // 未兑换的素币 | ||
16 | + Rate float64 `json:"rate"` // 平均兑换汇率 | ||
17 | + LastRate float64 `json:"lastRate"` // 上期活动兑换汇率 | ||
18 | + CreateTime time.Time `json:"createTime"` // 现金投入现金池时间 | ||
19 | +} | ||
20 | + | ||
21 | +type CashPoolRepository interface { | ||
22 | + Save(cashPool *CashPool) (*CashPool, error) | ||
23 | + FindOne(queryOptions map[string]interface{}) (*CashPool, error) | ||
24 | + Find(queryOptions map[string]interface{}) (int64, []*CashPool, error) | ||
25 | +} | ||
26 | + | ||
27 | +func (cashPool *CashPool) Update(data map[string]interface{}) error { | ||
28 | + if cash, ok := data["cash"]; ok { | ||
29 | + cashPool.Cash = cash.(float64) | ||
30 | + } | ||
31 | + if exchangedCash, ok := data["exchangedCash"]; ok { | ||
32 | + cashPool.ExchangedCash = exchangedCash.(float64) | ||
33 | + } | ||
34 | + if unExchangeCash, ok := data["unExchangeCash"]; ok { | ||
35 | + cashPool.UnExchangeCash = unExchangeCash.(float64) | ||
36 | + } | ||
37 | + if exchangedSuMoney, ok := data["exchangedSuMoney"]; ok { | ||
38 | + cashPool.ExchangedSuMoney = exchangedSuMoney.(float64) | ||
39 | + } | ||
40 | + if unExchangeSuMoney, ok := data["unExchangeSuMoney"]; ok { | ||
41 | + cashPool.UnExchangeSuMoney = unExchangeSuMoney.(float64) | ||
42 | + } | ||
43 | + if rate, ok := data["rate"]; ok { | ||
44 | + cashPool.Rate = rate.(float64) | ||
45 | + } | ||
46 | + return nil | ||
47 | +} | ||
48 | + | ||
49 | +func (cashPool *CashPool) Identity() interface{} { | ||
50 | + if cashPool.CashPoolId == 0 { | ||
51 | + return nil | ||
52 | + } | ||
53 | + return cashPool.CashPoolId | ||
54 | +} | ||
55 | + |
1 | package domain | 1 | package domain |
2 | 2 | ||
3 | +import "time" | ||
4 | + | ||
3 | // 员工 | 5 | // 员工 |
4 | type Employee struct { | 6 | type Employee struct { |
5 | // 员工ID | 7 | // 员工ID |
@@ -14,6 +16,8 @@ type Employee struct { | @@ -14,6 +16,8 @@ type Employee struct { | ||
14 | Status int `json:"status"` | 16 | Status int `json:"status"` |
15 | // 员工权限集合 | 17 | // 员工权限集合 |
16 | Permissions []int `json:"permissions"` | 18 | Permissions []int `json:"permissions"` |
19 | + // 创建时间 | ||
20 | + CreateTime time.Time `json:"createTime"` | ||
17 | } | 21 | } |
18 | 22 | ||
19 | type EmployeeRepository interface { | 23 | type EmployeeRepository interface { |
@@ -21,6 +25,8 @@ type EmployeeRepository interface { | @@ -21,6 +25,8 @@ type EmployeeRepository interface { | ||
21 | Remove(employee *Employee) (*Employee, error) | 25 | Remove(employee *Employee) (*Employee, error) |
22 | FindOne(queryOptions map[string]interface{}) (*Employee, error) | 26 | FindOne(queryOptions map[string]interface{}) (*Employee, error) |
23 | Find(queryOptions map[string]interface{}) (int64, []*Employee, error) | 27 | Find(queryOptions map[string]interface{}) (int64, []*Employee, error) |
28 | + FindByIds(queryOptions map[string]interface{}) (int64, []*Employee, error) | ||
29 | + FindAll(queryOptions map[string]interface{}) (int64, []*Employee, error) | ||
24 | } | 30 | } |
25 | 31 | ||
26 | func (employee *Employee) Identify() interface{} { | 32 | func (employee *Employee) Identify() interface{} { |
@@ -49,6 +55,9 @@ func (employee *Employee) Update(data map[string]interface{}) error { | @@ -49,6 +55,9 @@ func (employee *Employee) Update(data map[string]interface{}) error { | ||
49 | if permissions, ok := data["permissions"]; ok { | 55 | if permissions, ok := data["permissions"]; ok { |
50 | employee.Permissions = permissions.([]int) | 56 | employee.Permissions = permissions.([]int) |
51 | } | 57 | } |
58 | + if createTime, ok := data["createTime"]; ok && !createTime.(time.Time).IsZero() { | ||
59 | + employee.CreateTime = createTime.(time.Time) | ||
60 | + } | ||
52 | return nil | 61 | return nil |
53 | } | 62 | } |
54 | 63 |
pkg/domain/exchange_cash_activity.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import ( | ||
4 | + "time" | ||
5 | +) | ||
6 | + | ||
7 | +// 兑换现金活动 | ||
8 | +type ExchangeCashActivity struct { | ||
9 | + ActivityId int64 `json:"activityId"` // 兑换现金活动id | ||
10 | + ExchangeActivityName string `json:"exchangeActivityName"` // 兑换现金活动名称 | ||
11 | + CompanyId int64 `json:"companyId"` // 公司ID | ||
12 | + ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金 | ||
13 | + ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币 | ||
14 | + Deadline time.Time `json:"deadline"` // 兑换现金活动截止时间 | ||
15 | + CountDown int64 `json:"countDown"` // 兑换现金活动结束倒计时 | ||
16 | + Rate float64 `json:"rate"` // 兑换汇率 | ||
17 | + CreateTime time.Time `json:"createTime"` // 创建兑换现金活动时间 | ||
18 | +} | ||
19 | + | ||
20 | +type ExchangeActivityRepository interface { | ||
21 | + Save(exchangeCashActivity *ExchangeCashActivity) (*ExchangeCashActivity, error) | ||
22 | + Remove(exchangeCashActivity *ExchangeCashActivity) (*ExchangeCashActivity, error) | ||
23 | + FindOne(queryOptions map[string]interface{}) (*ExchangeCashActivity, error) | ||
24 | + Find(queryOptions map[string]interface{}) (int64, []*ExchangeCashActivity, error) | ||
25 | + FindAll(queryOptions map[string]interface{}) (int64, []*ExchangeCashActivity, error) | ||
26 | +} | ||
27 | + | ||
28 | +func (exchangeCashActivity *ExchangeCashActivity) Identity() interface{} { | ||
29 | + if exchangeCashActivity.ActivityId == 0 { | ||
30 | + return nil | ||
31 | + } | ||
32 | + return exchangeCashActivity.ActivityId | ||
33 | +} | ||
34 | + | ||
35 | +func (exchangeCashActivity *ExchangeCashActivity) Update(data map[string]interface{}) error { | ||
36 | + if exchangeActivityName, ok := data["exchangeActivityName"]; ok && exchangeActivityName != "" { | ||
37 | + exchangeCashActivity.ExchangeActivityName = exchangeActivityName.(string) | ||
38 | + } | ||
39 | + if deadline, ok := data["deadline"]; ok && deadline != "" { | ||
40 | + exchangeCashActivity.Deadline = deadline.(time.Time) | ||
41 | + } | ||
42 | + if countDown, ok := data["countDown"]; ok && countDown != 0 { | ||
43 | + exchangeCashActivity.CountDown = countDown.(int64) | ||
44 | + } | ||
45 | + if exchangedSuMoney, ok := data["exchangedSuMoney"]; ok && exchangedSuMoney != 0 { | ||
46 | + exchangeCashActivity.ExchangedSuMoney = exchangedSuMoney.(float64) | ||
47 | + } | ||
48 | + if exchangedCash, ok := data["exchangedCash"]; ok && exchangedCash != 0 { | ||
49 | + exchangeCashActivity.ExchangedCash = exchangedCash.(float64) | ||
50 | + } | ||
51 | + if exchangeRate, ok := data["exchangeRate"]; ok && exchangeRate != 0 { | ||
52 | + exchangeCashActivity.Rate = exchangeRate.(float64) | ||
53 | + } | ||
54 | + if createTime, ok := data["createTime"]; ok && createTime.(time.Time).IsZero() { | ||
55 | + exchangeCashActivity.CreateTime = createTime.(time.Time) | ||
56 | + } | ||
57 | + exchangeCashActivity.CreateTime = time.Now() | ||
58 | + return nil | ||
59 | +} | ||
60 | + | ||
61 | +func (exchangeCashActivity *ExchangeCashActivity) TransferSuMoney(rate float64) error { | ||
62 | + exchangeCashActivity.ExchangedSuMoney = exchangeCashActivity.ExchangedCash * rate | ||
63 | + return nil | ||
64 | +} | ||
65 | + | ||
66 | +func (exchangeCashActivity *ExchangeCashActivity) TransferCountDown() error { | ||
67 | + exchangeCashActivity.CountDown = int64(time.Until(exchangeCashActivity.Deadline)) | ||
68 | + return nil | ||
69 | +} |
pkg/domain/exchange_cash_person_list.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import ( | ||
4 | + "fmt" | ||
5 | + "strconv" | ||
6 | +) | ||
7 | + | ||
8 | +// 参与兑换现金人员 | ||
9 | +type ExchangeCashPersonList struct { | ||
10 | + ListId int64 `json:"listId"` // 清单id | ||
11 | + EmployeeInfo *EmployeeInfo `json:"employeeInfo"` // 兑换人信息 | ||
12 | + ExchangeCashActivityId int64 `json:"exchangeActivityId"` // 参与的兑换活动id | ||
13 | + ExchangedSuMoney float64 `json:"suMoney"` // 已兑换的素币 | ||
14 | + ExchangedCash float64 `json:"cash"` // 已兑换的现金 | ||
15 | +} | ||
16 | + | ||
17 | +type ExchangeCashPersonListRepository interface { | ||
18 | + Save(exchangeCashPersonList *ExchangeCashPersonList) (*ExchangeCashPersonList, error) | ||
19 | + Remove(exchangeCashPersonList *ExchangeCashPersonList) (*ExchangeCashPersonList, error) | ||
20 | + FindOne(queryOptions map[string]interface{}) (*ExchangeCashPersonList, error) | ||
21 | + Find(queryOptions map[string]interface{}) (int64, []*ExchangeCashPersonList, error) | ||
22 | + FindAll(queryOptions map[string]interface{}) (int64, []*ExchangeCashPersonList, error) | ||
23 | + FindById(queryOptions map[string]interface{}) (int64, []*ExchangeCashPersonList, error) | ||
24 | +} | ||
25 | + | ||
26 | +func (exchangeCashPersonList *ExchangeCashPersonList) Identity() interface{} { | ||
27 | + if exchangeCashPersonList.ListId == 0 { | ||
28 | + return nil | ||
29 | + } | ||
30 | + return exchangeCashPersonList.ListId | ||
31 | +} | ||
32 | + | ||
33 | +func (exchangeCashPersonList *ExchangeCashPersonList) Update(data map[string]interface{}) error { | ||
34 | + if exchangedSuMoney, ok := data["exchangedSuMoney"]; ok && exchangedSuMoney != 0 { | ||
35 | + exchangeCashPersonList.ExchangedSuMoney = exchangedSuMoney.(float64) | ||
36 | + } | ||
37 | + if exchangedCash, ok := data["exchangedCash"]; ok && exchangedCash != 0 { | ||
38 | + exchangeCashPersonList.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2F", exchangedCash.(float64)), 64) | ||
39 | + } | ||
40 | + return nil | ||
41 | +} |
pkg/domain/list_interval.go
0 → 100644
1 | +package domain | ||
2 | + | ||
3 | +import ( | ||
4 | + "time" | ||
5 | +) | ||
6 | + | ||
7 | +// 排行榜时间 | ||
8 | +type ListInterval struct { | ||
9 | + ListIntervalId int `json:"listIntervalId"` // 排行榜时间id | ||
10 | + CompanyId int `json:"companyId"` // 公司id | ||
11 | + IntervalStartTime time.Time `json:"intervalStartTime"` // 排行榜开始时间 | ||
12 | + IntervalEndTime time.Time `json:"intervalEndTime"` // 排行榜结束时间 | ||
13 | +} | ||
14 | + | ||
15 | +type ListIntervalRepository interface { | ||
16 | + Save(listInterval *ListInterval) (*ListInterval, error) | ||
17 | + Remove(listInterval *ListInterval) (*ListInterval, error) | ||
18 | + FindOne(queryOptions map[string]interface{}) (*ListInterval, error) | ||
19 | + Find(queryOptions map[string]interface{}) (int64, []*ListInterval, error) | ||
20 | + FindAll(queryOptions map[string]interface{}) (int64, []*ListInterval, error) | ||
21 | +} | ||
22 | + | ||
23 | +func (listInterval *ListInterval) Identify() interface{} { | ||
24 | + if listInterval.ListIntervalId == 0 { | ||
25 | + return nil | ||
26 | + } | ||
27 | + return listInterval.ListIntervalId | ||
28 | +} | ||
29 | + | ||
30 | +func (listInterval *ListInterval) Update(data map[string]interface{}) error { | ||
31 | + if listIntervalStartTime, ok := data["listIntervalStartTime"]; ok { | ||
32 | + listInterval.IntervalStartTime = listIntervalStartTime.(time.Time) | ||
33 | + } | ||
34 | + if listIntervalEndTime, ok := data["listIntervalEndTime"]; ok { | ||
35 | + listInterval.IntervalEndTime = listIntervalEndTime.(time.Time) | ||
36 | + } | ||
37 | + return nil | ||
38 | +} |
@@ -8,5 +8,5 @@ import ( | @@ -8,5 +8,5 @@ import ( | ||
8 | 8 | ||
9 | type AcceptanceTaskService interface { | 9 | type AcceptanceTaskService interface { |
10 | coreDomain.DomainEventPublisher | 10 | coreDomain.DomainEventPublisher |
11 | - Acceptance(taskId int64, operatorUid int64, participators []int64, taskPercentage []*domain.TaskPercentageItem, referenceResourceScore []*domain.ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) (*domain.Task, error) | 11 | + Acceptance(taskId int64, operatorUid int64, participators []int64, suMoney float64, taskPercentage []*domain.TaskPercentageItem, referenceResourceScore []*domain.ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) (*domain.Task, error) |
12 | } | 12 | } |
@@ -3,32 +3,28 @@ package domain | @@ -3,32 +3,28 @@ package domain | ||
3 | import "time" | 3 | import "time" |
4 | 4 | ||
5 | const ( | 5 | const ( |
6 | - SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE = iota + 1 //兑换 | 6 | + SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE = iota + 1 //兑换物资 |
7 | SU_MONEY_TRANSACTION_RECORD_TYPE_AWARD //任务奖励 | 7 | SU_MONEY_TRANSACTION_RECORD_TYPE_AWARD //任务奖励 |
8 | SU_MONEY_TRANSACTION_RECORD_TYPE_INCREASE //增加 | 8 | SU_MONEY_TRANSACTION_RECORD_TYPE_INCREASE //增加 |
9 | SU_MONEY_TRANSACTION_RECORD_TYPE_DEDUCT //扣除 | 9 | SU_MONEY_TRANSACTION_RECORD_TYPE_DEDUCT //扣除 |
10 | + SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE_CASH //兑换现金 | ||
11 | + SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE_CASH_RESTORE // 兑换现金撤销 | ||
10 | ) | 12 | ) |
11 | 13 | ||
12 | // 素币事务记录 | 14 | // 素币事务记录 |
13 | type SuMoneyTransactionRecord struct { | 15 | type SuMoneyTransactionRecord struct { |
14 | - // 素币事务记录ID | ||
15 | - SuMoneyTransactionRecordId int64 `json:"suMoneyTransactionRecordId"` | ||
16 | - // 记录类型 | ||
17 | - RecordType int `json:"recordType"` | ||
18 | - // 记录关联员工 | ||
19 | - Employee *EmployeeInfo `json:"employee"` | ||
20 | - // 事务处理前素币值 | ||
21 | - SuMoneyBeforeTransaction float64 `json:"suMoneyBeforeTransaction"` | ||
22 | - // 当前素币值 | ||
23 | - CurrentSuMoney float64 `json:"currentSuMoney"` | ||
24 | - // 事务素币值 | ||
25 | - SuMoney float64 `json:"suMoney"` | ||
26 | - // 操作人 | ||
27 | - Operator *EmployeeInfo `json:"operator"` | ||
28 | - // 素币事务记录描述 | ||
29 | - RecordDescription string `json:"recordDescription"` | ||
30 | - // 创建时间 | ||
31 | - CreateTime time.Time `json:"createTime"` | 16 | + SuMoneyTransactionRecordId int64 `json:"suMoneyTransactionRecordId"` // 素币事务记录ID |
17 | + RecordType int `json:"recordType"` // 记录类型 | ||
18 | + Employee *EmployeeInfo `json:"employee"` // 记录关联员工 | ||
19 | + SuMoneyBeforeTransaction float64 `json:"suMoneyBeforeTransaction"` // 事务处理前素币值 | ||
20 | + CurrentSuMoney float64 `json:"currentSuMoney"` // 当前素币值 | ||
21 | + SuMoney float64 `json:"suMoney"` // 事务素币值 | ||
22 | + CashBeforeTransaction float64 `json:"cashBeforeTransaction"` // 事务处理前现金值 | ||
23 | + CurrentCash float64 `json:"currentCash"` // 当前现金值 | ||
24 | + Cash float64 `json:"cash"` // 事务现金值 | ||
25 | + Operator *EmployeeInfo `json:"operator"` // 操作人 | ||
26 | + RecordDescription string `json:"recordDescription"` // 素币事务记录描述 | ||
27 | + CreateTime time.Time `json:"createTime"` // 创建时间 | ||
32 | } | 28 | } |
33 | 29 | ||
34 | type SuMoneyTransactionRecordRepository interface { | 30 | type SuMoneyTransactionRecordRepository interface { |
@@ -36,6 +32,7 @@ type SuMoneyTransactionRecordRepository interface { | @@ -36,6 +32,7 @@ type SuMoneyTransactionRecordRepository interface { | ||
36 | Remove(suMoneyTransactionRecord *SuMoneyTransactionRecord) (*SuMoneyTransactionRecord, error) | 32 | Remove(suMoneyTransactionRecord *SuMoneyTransactionRecord) (*SuMoneyTransactionRecord, error) |
37 | FindOne(queryOptions map[string]interface{}) (*SuMoneyTransactionRecord, error) | 33 | FindOne(queryOptions map[string]interface{}) (*SuMoneyTransactionRecord, error) |
38 | Find(queryOptions map[string]interface{}) (int64, []*SuMoneyTransactionRecord, error) | 34 | Find(queryOptions map[string]interface{}) (int64, []*SuMoneyTransactionRecord, error) |
35 | + FindById(queryOptions map[string]interface{}) (int64, []*SuMoneyTransactionRecord, error) | ||
39 | } | 36 | } |
40 | 37 | ||
41 | func (suMoneyTransactionRecord *SuMoneyTransactionRecord) Identify() interface{} { | 38 | func (suMoneyTransactionRecord *SuMoneyTransactionRecord) Identify() interface{} { |
@@ -24,6 +24,7 @@ const ( | @@ -24,6 +24,7 @@ const ( | ||
24 | TASK_STATUS_COMPLETED //已完成 | 24 | TASK_STATUS_COMPLETED //已完成 |
25 | TASK_STATUS_CLOSED //关闭 | 25 | TASK_STATUS_CLOSED //关闭 |
26 | TASK_STATUS_UNCONFIRMED //待确认 | 26 | TASK_STATUS_UNCONFIRMED //待确认 |
27 | + TASK_STATUS_EXPIRED //已过期 | ||
27 | ) | 28 | ) |
28 | 29 | ||
29 | // 任务 | 30 | // 任务 |
@@ -50,6 +51,10 @@ type Task struct { | @@ -50,6 +51,10 @@ type Task struct { | ||
50 | TaskNature int `json:"taskNature"` | 51 | TaskNature int `json:"taskNature"` |
51 | // 奖励素币 | 52 | // 奖励素币 |
52 | SuMoney float64 `json:"suMoney"` | 53 | SuMoney float64 `json:"suMoney"` |
54 | + // 最小奖励素币 | ||
55 | + MinSuMoney float64 `json:"minSuMoney"` | ||
56 | + // 最大奖励素币 | ||
57 | + MaxSuMoney float64 `json:"maxSuMoney"` | ||
53 | // 验收标准 | 58 | // 验收标准 |
54 | AcceptanceStandard string `json:"acceptanceStandard"` | 59 | AcceptanceStandard string `json:"acceptanceStandard"` |
55 | // 任务描述 | 60 | // 任务描述 |
@@ -98,11 +103,12 @@ type TaskStatus interface { | @@ -98,11 +103,12 @@ type TaskStatus interface { | ||
98 | ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error | 103 | ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error |
99 | ApplyComplete(task *Task) error | 104 | ApplyComplete(task *Task) error |
100 | Off(task *Task) error | 105 | Off(task *Task) error |
101 | - Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error | 106 | + Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error |
102 | ConfirmTask(task *Task, plannedCompletionTime time.Time) error | 107 | ConfirmTask(task *Task, plannedCompletionTime time.Time) error |
103 | RejectReceiver(task *Task) error | 108 | RejectReceiver(task *Task) error |
104 | } | 109 | } |
105 | 110 | ||
111 | +// 待发布的任务 | ||
106 | type UnReleasedStatus struct{} | 112 | type UnReleasedStatus struct{} |
107 | 113 | ||
108 | func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) error { | 114 | func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) error { |
@@ -127,6 +133,12 @@ func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) | @@ -127,6 +133,12 @@ func (status *UnReleasedStatus) Update(task *Task, data map[string]interface{}) | ||
127 | if suMoney, ok := data["suMoney"]; ok { | 133 | if suMoney, ok := data["suMoney"]; ok { |
128 | task.SuMoney = suMoney.(float64) | 134 | task.SuMoney = suMoney.(float64) |
129 | } | 135 | } |
136 | + if minSuMoney, ok := data["minSuMoney"]; ok { | ||
137 | + task.MinSuMoney = minSuMoney.(float64) | ||
138 | + } | ||
139 | + if maxSuMoney, ok := data["maxSuMoney"]; ok { | ||
140 | + task.MaxSuMoney = maxSuMoney.(float64) | ||
141 | + } | ||
130 | if task.TaskType == TASK_TYPE_BID { | 142 | if task.TaskType == TASK_TYPE_BID { |
131 | if bidStartTime, ok := data["bidStartTime"]; ok { | 143 | if bidStartTime, ok := data["bidStartTime"]; ok { |
132 | task.BidInfo.BidStartTime = bidStartTime.(time.Time) | 144 | task.BidInfo.BidStartTime = bidStartTime.(time.Time) |
@@ -198,7 +210,7 @@ func (status *UnReleasedStatus) Off(task *Task) error { | @@ -198,7 +210,7 @@ func (status *UnReleasedStatus) Off(task *Task) error { | ||
198 | return fmt.Errorf("待发布的任务不允许关闭") | 210 | return fmt.Errorf("待发布的任务不允许关闭") |
199 | } | 211 | } |
200 | 212 | ||
201 | -func (status *UnReleasedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { | 213 | +func (status *UnReleasedStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { |
202 | return fmt.Errorf("待发布的任务不允许验收") | 214 | return fmt.Errorf("待发布的任务不允许验收") |
203 | } | 215 | } |
204 | 216 | ||
@@ -213,7 +225,68 @@ func (status *UnReleasedStatus) RejectReceiver(task *Task) error { | @@ -213,7 +225,68 @@ func (status *UnReleasedStatus) RejectReceiver(task *Task) error { | ||
213 | type UnClaimedStatus struct{} | 225 | type UnClaimedStatus struct{} |
214 | 226 | ||
215 | func (status *UnClaimedStatus) Update(task *Task, data map[string]interface{}) error { | 227 | func (status *UnClaimedStatus) Update(task *Task, data map[string]interface{}) error { |
216 | - return fmt.Errorf("待领取的任务不允许编辑") | 228 | + if taskName, ok := data["taskName"]; ok { |
229 | + task.TaskName = taskName.(string) | ||
230 | + } | ||
231 | + if referenceResourceType, ok := data["referenceResourceType"]; ok { | ||
232 | + task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int) | ||
233 | + } | ||
234 | + if referenceResourceItems, ok := data["referenceResourceItems"]; ok { | ||
235 | + task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem) | ||
236 | + } | ||
237 | + if projectBelong, ok := data["projectBelong"]; ok { | ||
238 | + task.ProjectBelong = projectBelong.(int) | ||
239 | + } | ||
240 | + if customerValues, ok := data["customerValues"]; ok { | ||
241 | + task.CustomerValues = customerValues.([]int) | ||
242 | + } | ||
243 | + if taskNature, ok := data["taskNature"]; ok { | ||
244 | + task.TaskNature = taskNature.(int) | ||
245 | + } | ||
246 | + if suMoney, ok := data["suMoney"]; ok { | ||
247 | + task.SuMoney = suMoney.(float64) | ||
248 | + } | ||
249 | + if minSuMoney, ok := data["minSuMoney"]; ok { | ||
250 | + task.MinSuMoney = minSuMoney.(float64) | ||
251 | + } | ||
252 | + if maxSuMoney, ok := data["maxSuMoney"]; ok { | ||
253 | + task.MaxSuMoney = maxSuMoney.(float64) | ||
254 | + } | ||
255 | + if task.TaskType == TASK_TYPE_BID { | ||
256 | + if bidStartTime, ok := data["bidStartTime"]; ok { | ||
257 | + task.BidInfo.BidStartTime = bidStartTime.(time.Time) | ||
258 | + } | ||
259 | + if bidEndTime, ok := data["bidEndTime"]; ok { | ||
260 | + task.BidInfo.BidEndTime = bidEndTime.(time.Time) | ||
261 | + } | ||
262 | + if isRemind, ok := data["isRemind"]; ok { | ||
263 | + task.BidInfo.IsRemind = isRemind.(bool) | ||
264 | + } | ||
265 | + } | ||
266 | + if acceptanceStandard, ok := data["acceptanceStandard"]; ok { | ||
267 | + task.AcceptanceStandard = acceptanceStandard.(string) | ||
268 | + } | ||
269 | + if taskDescription, ok := data["taskDescription"]; ok { | ||
270 | + task.TaskDescription = taskDescription.(string) | ||
271 | + } | ||
272 | + if taskPictureUrls, ok := data["taskPictureUrls"]; ok { | ||
273 | + task.TaskPictureUrls = taskPictureUrls.([]string) | ||
274 | + } | ||
275 | + if isRewardTake, ok := data["isRewardTake"]; ok { | ||
276 | + task.IsRewardTake = isRewardTake.(bool) | ||
277 | + } | ||
278 | + if task.TaskType == TASK_TYPE_DESIGNATE { | ||
279 | + if plannedCompletionTime, ok := data["plannedCompletionTime"]; ok { | ||
280 | + task.PlannedCompletionTime = plannedCompletionTime.(time.Time) | ||
281 | + } | ||
282 | + if assignedPerson, ok := data["assignedPerson"]; ok { | ||
283 | + task.AssignedPerson = assignedPerson.(*EmployeeInfo) | ||
284 | + if task.AssignedPerson.Uid == 0 { | ||
285 | + task.AssignedPerson = nil | ||
286 | + } | ||
287 | + } | ||
288 | + } | ||
289 | + return nil | ||
217 | } | 290 | } |
218 | 291 | ||
219 | func (status *UnClaimedStatus) Release(task *Task) error { | 292 | func (status *UnClaimedStatus) Release(task *Task) error { |
@@ -286,7 +359,7 @@ func (status *UnClaimedStatus) Off(task *Task) error { | @@ -286,7 +359,7 @@ func (status *UnClaimedStatus) Off(task *Task) error { | ||
286 | return nil | 359 | return nil |
287 | } | 360 | } |
288 | 361 | ||
289 | -func (status *UnClaimedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { | 362 | +func (status *UnClaimedStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { |
290 | return fmt.Errorf("待领取的任务不允许验收") | 363 | return fmt.Errorf("待领取的任务不允许验收") |
291 | } | 364 | } |
292 | 365 | ||
@@ -333,7 +406,7 @@ func (status *UnderwayStatus) Off(task *Task) error { | @@ -333,7 +406,7 @@ func (status *UnderwayStatus) Off(task *Task) error { | ||
333 | return nil | 406 | return nil |
334 | } | 407 | } |
335 | 408 | ||
336 | -func (status *UnderwayStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { | 409 | +func (status *UnderwayStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { |
337 | return fmt.Errorf("进行中的任务不允许验收") | 410 | return fmt.Errorf("进行中的任务不允许验收") |
338 | } | 411 | } |
339 | 412 | ||
@@ -359,6 +432,7 @@ func (status *UnderwayStatus) RejectReceiver(task *Task) error { | @@ -359,6 +432,7 @@ func (status *UnderwayStatus) RejectReceiver(task *Task) error { | ||
359 | return nil | 432 | return nil |
360 | } | 433 | } |
361 | 434 | ||
435 | +// 代验收的任务 | ||
362 | type UnAcceptanceStatus struct{} | 436 | type UnAcceptanceStatus struct{} |
363 | 437 | ||
364 | func (status *UnAcceptanceStatus) Update(task *Task, data map[string]interface{}) error { | 438 | func (status *UnAcceptanceStatus) Update(task *Task, data map[string]interface{}) error { |
@@ -391,8 +465,9 @@ func (status *UnAcceptanceStatus) Off(task *Task) error { | @@ -391,8 +465,9 @@ func (status *UnAcceptanceStatus) Off(task *Task) error { | ||
391 | return nil | 465 | return nil |
392 | } | 466 | } |
393 | 467 | ||
394 | -func (status *UnAcceptanceStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { | 468 | +func (status *UnAcceptanceStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { |
395 | task.Participators = participators | 469 | task.Participators = participators |
470 | + task.SuMoney = suMoney | ||
396 | task.TaskPercentage = taskPercentage | 471 | task.TaskPercentage = taskPercentage |
397 | task.SolveReport = solveReport | 472 | task.SolveReport = solveReport |
398 | task.SolvePictureUrls = solvePictureUrls | 473 | task.SolvePictureUrls = solvePictureUrls |
@@ -451,7 +526,7 @@ func (status *CompletedStatus) Off(task *Task) error { | @@ -451,7 +526,7 @@ func (status *CompletedStatus) Off(task *Task) error { | ||
451 | return fmt.Errorf("已完成的任务不允许申请完成任务") | 526 | return fmt.Errorf("已完成的任务不允许申请完成任务") |
452 | } | 527 | } |
453 | 528 | ||
454 | -func (status *CompletedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { | 529 | +func (status *CompletedStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { |
455 | return fmt.Errorf("已完成的任务不允许验收") | 530 | return fmt.Errorf("已完成的任务不允许验收") |
456 | } | 531 | } |
457 | 532 | ||
@@ -493,7 +568,7 @@ func (status *ClosedStatus) Off(task *Task) error { | @@ -493,7 +568,7 @@ func (status *ClosedStatus) Off(task *Task) error { | ||
493 | return fmt.Errorf("已关闭的任务不允许关闭") | 568 | return fmt.Errorf("已关闭的任务不允许关闭") |
494 | } | 569 | } |
495 | 570 | ||
496 | -func (status *ClosedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { | 571 | +func (status *ClosedStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { |
497 | return fmt.Errorf("已关闭的任务不允许验收") | 572 | return fmt.Errorf("已关闭的任务不允许验收") |
498 | } | 573 | } |
499 | 574 | ||
@@ -505,6 +580,7 @@ func (status *ClosedStatus) RejectReceiver(task *Task) error { | @@ -505,6 +580,7 @@ func (status *ClosedStatus) RejectReceiver(task *Task) error { | ||
505 | return fmt.Errorf("已关闭的任务不允许驳回任务领取人") | 580 | return fmt.Errorf("已关闭的任务不允许驳回任务领取人") |
506 | } | 581 | } |
507 | 582 | ||
583 | +// 待确认任务 | ||
508 | type UnConfirmedStatus struct{} | 584 | type UnConfirmedStatus struct{} |
509 | 585 | ||
510 | func (status *UnConfirmedStatus) Update(task *Task, data map[string]interface{}) error { | 586 | func (status *UnConfirmedStatus) Update(task *Task, data map[string]interface{}) error { |
@@ -537,7 +613,7 @@ func (status *UnConfirmedStatus) Off(task *Task) error { | @@ -537,7 +613,7 @@ func (status *UnConfirmedStatus) Off(task *Task) error { | ||
537 | return nil | 613 | return nil |
538 | } | 614 | } |
539 | 615 | ||
540 | -func (status *UnConfirmedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { | 616 | +func (status *UnConfirmedStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { |
541 | return fmt.Errorf("待确认的任务不允许验收") | 617 | return fmt.Errorf("待确认的任务不允许验收") |
542 | } | 618 | } |
543 | 619 | ||
@@ -560,6 +636,113 @@ func (status *UnConfirmedStatus) RejectReceiver(task *Task) error { | @@ -560,6 +636,113 @@ func (status *UnConfirmedStatus) RejectReceiver(task *Task) error { | ||
560 | return nil | 636 | return nil |
561 | } | 637 | } |
562 | 638 | ||
639 | +type ExpiredStatus struct{} | ||
640 | + | ||
641 | +func (status ExpiredStatus) Update(task *Task, data map[string]interface{}) error { | ||
642 | + if taskName, ok := data["taskName"]; ok { | ||
643 | + task.TaskName = taskName.(string) | ||
644 | + } | ||
645 | + if referenceResourceType, ok := data["referenceResourceType"]; ok { | ||
646 | + task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int) | ||
647 | + } | ||
648 | + if referenceResourceItems, ok := data["referenceResourceItems"]; ok { | ||
649 | + task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem) | ||
650 | + } | ||
651 | + if projectBelong, ok := data["projectBelong"]; ok { | ||
652 | + task.ProjectBelong = projectBelong.(int) | ||
653 | + } | ||
654 | + if customerValues, ok := data["customerValues"]; ok { | ||
655 | + task.CustomerValues = customerValues.([]int) | ||
656 | + } | ||
657 | + if taskNature, ok := data["taskNature"]; ok { | ||
658 | + task.TaskNature = taskNature.(int) | ||
659 | + } | ||
660 | + if suMoney, ok := data["suMoney"]; ok { | ||
661 | + task.SuMoney = suMoney.(float64) | ||
662 | + } | ||
663 | + if minSuMoney, ok := data["minSuMoney"]; ok { | ||
664 | + task.MinSuMoney = minSuMoney.(float64) | ||
665 | + } | ||
666 | + if maxSuMoney, ok := data["maxSuMoney"]; ok { | ||
667 | + task.MaxSuMoney = maxSuMoney.(float64) | ||
668 | + } | ||
669 | + if task.TaskType == TASK_TYPE_BID { | ||
670 | + if bidStartTime, ok := data["bidStartTime"]; ok { | ||
671 | + task.BidInfo.BidStartTime = bidStartTime.(time.Time) | ||
672 | + } | ||
673 | + if bidEndTime, ok := data["bidEndTime"]; ok { | ||
674 | + task.BidInfo.BidEndTime = bidEndTime.(time.Time) | ||
675 | + } | ||
676 | + if isRemind, ok := data["isRemind"]; ok { | ||
677 | + task.BidInfo.IsRemind = isRemind.(bool) | ||
678 | + } | ||
679 | + } | ||
680 | + if acceptanceStandard, ok := data["acceptanceStandard"]; ok { | ||
681 | + task.AcceptanceStandard = acceptanceStandard.(string) | ||
682 | + } | ||
683 | + if taskDescription, ok := data["taskDescription"]; ok { | ||
684 | + task.TaskDescription = taskDescription.(string) | ||
685 | + } | ||
686 | + if taskPictureUrls, ok := data["taskPictureUrls"]; ok { | ||
687 | + task.TaskPictureUrls = taskPictureUrls.([]string) | ||
688 | + } | ||
689 | + if isRewardTake, ok := data["isRewardTake"]; ok { | ||
690 | + task.IsRewardTake = isRewardTake.(bool) | ||
691 | + } | ||
692 | + if task.TaskType == TASK_TYPE_DESIGNATE { | ||
693 | + if plannedCompletionTime, ok := data["plannedCompletionTime"]; ok { | ||
694 | + task.PlannedCompletionTime = plannedCompletionTime.(time.Time) | ||
695 | + } | ||
696 | + if assignedPerson, ok := data["assignedPerson"]; ok { | ||
697 | + task.AssignedPerson = assignedPerson.(*EmployeeInfo) | ||
698 | + if task.AssignedPerson.Uid == 0 { | ||
699 | + task.AssignedPerson = nil | ||
700 | + } | ||
701 | + } | ||
702 | + } | ||
703 | + return nil | ||
704 | +} | ||
705 | + | ||
706 | +func (status ExpiredStatus) Release(task *Task) error { | ||
707 | + currentTime := time.Now() | ||
708 | + task.ReleaseTime = currentTime | ||
709 | + task.TaskStatus = TASK_STATUS_UNCLAIMED | ||
710 | + task.CurrentStatus = &UnClaimedStatus{} | ||
711 | + return nil | ||
712 | +} | ||
713 | + | ||
714 | +func (status ExpiredStatus) Rob(task *Task, receiver *EmployeeInfo) error { | ||
715 | + return fmt.Errorf("已过期的任务不允许抢单") | ||
716 | +} | ||
717 | + | ||
718 | +func (status ExpiredStatus) Bib(task *Task, bidder *EmployeeInfo) error { | ||
719 | + return fmt.Errorf("已过期的任务不允许竞标") | ||
720 | +} | ||
721 | + | ||
722 | +func (status ExpiredStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error { | ||
723 | + return fmt.Errorf("已过期的任务不允许选择竞标任务的中标人") | ||
724 | +} | ||
725 | + | ||
726 | +func (status ExpiredStatus) ApplyComplete(task *Task) error { | ||
727 | + return fmt.Errorf("已过期的任务不允许申请完成任务") | ||
728 | +} | ||
729 | + | ||
730 | +func (status ExpiredStatus) Off(task *Task) error { | ||
731 | + return fmt.Errorf("已过期的任务不允许关闭") | ||
732 | +} | ||
733 | + | ||
734 | +func (status ExpiredStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { | ||
735 | + return fmt.Errorf("已过期的任务不允许验收") | ||
736 | +} | ||
737 | + | ||
738 | +func (status ExpiredStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error { | ||
739 | + return fmt.Errorf("已过期的任务不允许确认任务领取人") | ||
740 | +} | ||
741 | + | ||
742 | +func (status ExpiredStatus) RejectReceiver(task *Task) error { | ||
743 | + return fmt.Errorf("已过期的任务不允许驳回任务领取人") | ||
744 | +} | ||
745 | + | ||
563 | type TaskRepository interface { | 746 | type TaskRepository interface { |
564 | Save(task *Task) (*Task, error) | 747 | Save(task *Task) (*Task, error) |
565 | Remove(task *Task) (*Task, error) | 748 | Remove(task *Task) (*Task, error) |
@@ -602,8 +785,8 @@ func (task *Task) Off() error { | @@ -602,8 +785,8 @@ func (task *Task) Off() error { | ||
602 | return task.CurrentStatus.Off(task) | 785 | return task.CurrentStatus.Off(task) |
603 | } | 786 | } |
604 | 787 | ||
605 | -func (task *Task) Acceptance(participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { | ||
606 | - return task.CurrentStatus.Acceptance(task, participators, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls, actualCompletionTime) | 788 | +func (task *Task) Acceptance(participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error { |
789 | + return task.CurrentStatus.Acceptance(task, participators, suMoney, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls, actualCompletionTime) | ||
607 | } | 790 | } |
608 | 791 | ||
609 | func (task *Task) ConfirmTask(plannedCompletionTime time.Time) error { | 792 | func (task *Task) ConfirmTask(plannedCompletionTime time.Time) error { |
pkg/infrastructure/dao/pg_cash_pool_dao.go
0 → 100644
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) CalculateActivityExchangedSuMoney(activityId int64) (map[string]interface{}, error) { | ||
15 | + var activityExchangedSuMoney float64 | ||
16 | + var activityExchangedCash float64 | ||
17 | + tx := dao.transactionContext.PgTx | ||
18 | + exchangeCashPersonListModels := new(models.ExchangeCashPersonList) | ||
19 | + if err := tx.Model(exchangeCashPersonListModels). | ||
20 | + ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS activity_exchanged_su_money"). | ||
21 | + Where("exchange_cash_person_list.activity_id = ?", activityId). | ||
22 | + Select(&activityExchangedSuMoney); err !=nil { | ||
23 | + return nil, err | ||
24 | + } | ||
25 | + if err := tx.Model(exchangeCashPersonListModels). | ||
26 | + ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS activity_exchanged_cash"). | ||
27 | + Where("exchange_cash_person_list.activity_id = ?", activityId). | ||
28 | + Select(&activityExchangedCash); err !=nil { | ||
29 | + return nil, err | ||
30 | + } | ||
31 | + return map[string]interface{}{ | ||
32 | + "activityExchangedSuMoney": activityExchangedSuMoney, | ||
33 | + "activityExchangedCash": activityExchangedCash, | ||
34 | + }, nil | ||
35 | +} | ||
36 | + | ||
37 | +// 返回兑换活动清单榜单 | ||
38 | +func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) { | ||
39 | + var retPeople []struct { | ||
40 | + Uid int64 | ||
41 | + EmployeeName string | ||
42 | + SuMoney float64 | ||
43 | + Cash float64 | ||
44 | + Ranking int | ||
45 | + } | ||
46 | + | ||
47 | + var retEmployee []struct { | ||
48 | + Uid int64 | ||
49 | + EmployeeName string | ||
50 | + SuMoney float64 | ||
51 | + Cash float64 | ||
52 | + Ranking int | ||
53 | + } | ||
54 | + | ||
55 | + tx := dao.transactionContext.PgTx | ||
56 | + exchangeCashPersonListModels := new(models.ExchangeCashPersonList) | ||
57 | + | ||
58 | + // 清单人员排名 | ||
59 | + queryPeople := tx.Model(exchangeCashPersonListModels) | ||
60 | + queryPeople = queryPeople.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid") | ||
61 | + queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.uid AS uid") | ||
62 | + //queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name") | ||
63 | + queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash") | ||
64 | + queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money") | ||
65 | + queryPeople = queryPeople.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC, e.create_time ASC) AS ranking") | ||
66 | + //queryPeople = queryPeople.Where("e.status = ?", 1) | ||
67 | + if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { | ||
68 | + queryPeople = queryPeople.Where("e.company_id = ?", companyId) | ||
69 | + } | ||
70 | + if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){ | ||
71 | + queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId) | ||
72 | + } | ||
73 | + queryPeople = queryPeople.Group("exchange_cash_person_list.uid") | ||
74 | + queryPeople = queryPeople.Group("e.create_time") | ||
75 | + //queryPeople = queryPeople.Group("exchange_cash_person_list.employee_name") | ||
76 | + if offset, ok := queryOptions["offset"]; ok { | ||
77 | + offset := offset.(int) | ||
78 | + if offset > -1 { | ||
79 | + queryPeople = queryPeople.Offset(offset) | ||
80 | + } | ||
81 | + } else { | ||
82 | + queryPeople = queryPeople.Offset(0) | ||
83 | + } | ||
84 | + if limit, ok := queryOptions["limit"]; ok { | ||
85 | + limit := limit.(int) | ||
86 | + if limit > -1 { | ||
87 | + queryPeople = queryPeople.Limit(limit) | ||
88 | + } | ||
89 | + } else { | ||
90 | + queryPeople = queryPeople.Limit(20) | ||
91 | + } | ||
92 | + if err := queryPeople.Order("ranking ASC").Select(&retPeople); err != nil { | ||
93 | + return nil, err | ||
94 | + } | ||
95 | + | ||
96 | + // 个人清单排名 | ||
97 | + queryPeopleAll := tx.Model(exchangeCashPersonListModels) | ||
98 | + queryPeopleAll = queryPeopleAll.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid") | ||
99 | + queryPeopleAll = queryPeopleAll.ColumnExpr("exchange_cash_person_list.uid AS uid") | ||
100 | + //queryPeopleAll = queryPeopleAll.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name") | ||
101 | + queryPeopleAll = queryPeopleAll.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash") | ||
102 | + queryPeopleAll = queryPeopleAll.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money") | ||
103 | + queryPeopleAll = queryPeopleAll.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC, e.create_time ASC) AS ranking") | ||
104 | + if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { | ||
105 | + queryPeopleAll = queryPeopleAll.Where("e.company_id = ?", companyId) | ||
106 | + } | ||
107 | + if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){ | ||
108 | + queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId) | ||
109 | + } | ||
110 | + queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid") | ||
111 | + queryPeopleAll = queryPeopleAll.Group("e.create_time") | ||
112 | + //queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.employee_name") | ||
113 | + queryPeopleAllWith := queryPeopleAll.Order("su_money DESC") | ||
114 | + queryEmployee := tx.Model() | ||
115 | + queryEmployee = queryEmployee.With("t", queryPeopleAllWith) | ||
116 | + queryEmployee = queryEmployee.Table("t") | ||
117 | + queryEmployee = queryEmployee.ColumnExpr("t.uid AS uid") | ||
118 | + //queryEmployee = queryEmployee.ColumnExpr("t.employee_name AS employee_name") | ||
119 | + queryEmployee = queryEmployee.ColumnExpr("t.cash AS cash") | ||
120 | + queryEmployee = queryEmployee.ColumnExpr("t.su_money AS su_money") | ||
121 | + queryEmployee = queryEmployee.ColumnExpr("t.ranking AS ranking") | ||
122 | + if uid, ok := queryOptions["uid"]; ok { | ||
123 | + queryEmployee = queryEmployee.Where("t.uid::bigint = ?", uid) | ||
124 | + } | ||
125 | + | ||
126 | + if err := queryEmployee.Select(&retEmployee); err != nil { | ||
127 | + return nil, err | ||
128 | + } | ||
129 | + var currentEmployee interface{} | ||
130 | + if len(retEmployee) == 0 { | ||
131 | + currentEmployee = nil | ||
132 | + } else { | ||
133 | + currentEmployee = retEmployee[0] | ||
134 | + } | ||
135 | + | ||
136 | + // 清单已兑换素币 | ||
137 | + var activityExchangedSuMoney float64 | ||
138 | + queryListSuMoney := tx.Model(exchangeCashPersonListModels) | ||
139 | + queryListSuMoney = queryListSuMoney.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid") | ||
140 | + queryListSuMoney = queryListSuMoney.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS activity_exchanged_su_money") | ||
141 | + //queryListSuMoney = queryListSuMoney.Where("e.status = ?", 1) | ||
142 | + if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { | ||
143 | + queryListSuMoney = queryListSuMoney.Where("e.company_id = ?", companyId) | ||
144 | + } | ||
145 | + if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0) { | ||
146 | + queryListSuMoney = queryListSuMoney.Where("exchange_cash_person_list.activity_id = ?", activityId) | ||
147 | + } | ||
148 | + if err := queryListSuMoney.Select(&activityExchangedSuMoney); err != nil { | ||
149 | + return nil, err | ||
150 | + } | ||
151 | + | ||
152 | + // 清单已兑换现金 | ||
153 | + var activityExchangedCash float64 | ||
154 | + queryListCash := tx.Model(exchangeCashPersonListModels) | ||
155 | + queryListCash = queryListCash.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid") | ||
156 | + queryListCash = queryListCash.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS activity_exchanged_cash") | ||
157 | + //queryListCash = queryListCash.Where("e.status = ?", 1) | ||
158 | + if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) { | ||
159 | + queryListCash = queryListCash.Where("e.company_id = ?", companyId) | ||
160 | + } | ||
161 | + if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0) { | ||
162 | + queryListCash = queryListCash.Where("exchange_cash_person_list.activity_id = ?", activityId) | ||
163 | + } | ||
164 | + if err := queryListCash.Select(&activityExchangedCash); err != nil { | ||
165 | + return nil, err | ||
166 | + } | ||
167 | + | ||
168 | + // 清单计数 | ||
169 | + queryCount := tx.Model(exchangeCashPersonListModels) | ||
170 | + count, err := queryCount.Count() | ||
171 | + if err != nil { | ||
172 | + return nil, err | ||
173 | + } | ||
174 | + | ||
175 | + return map[string]interface{} { | ||
176 | + "people": retPeople, // 员工排行榜 | ||
177 | + "count": count, // 计数 | ||
178 | + "currentEmployee": currentEmployee, // 当前员工排名 | ||
179 | + "exchangedSuMoney": activityExchangedSuMoney, // 清单已兑换素币 | ||
180 | + "exchangedCash": activityExchangedCash, // 清单已兑换现金 | ||
181 | + }, nil | ||
182 | +} | ||
183 | + | ||
184 | +func NewCashPoolDao(transactionContext *pgTransaction.TransactionContext) (*CashPoolDao, error) { | ||
185 | + if transactionContext == nil { | ||
186 | + return nil, fmt.Errorf("transactionContext参数不能为nil") | ||
187 | + } else { | ||
188 | + return &CashPoolDao{ | ||
189 | + transactionContext: transactionContext, | ||
190 | + }, nil | ||
191 | + } | ||
192 | +} |
-
请 注册 或 登录 后发表评论