作者 Administrator

合并分支 'dev' 到 'master'

Dev



查看合并请求 !4
正在显示 79 个修改的文件 包含 2807 行增加85 行删除

要显示太多修改。

为保证性能只显示 79 of 79+ 个文件。

... ... @@ -6,6 +6,8 @@
# Folders
_obj
_test
public/file
logs
# Architecture specific extensions/prefixes
*.[568vq]
... ... @@ -23,3 +25,4 @@ _testmain.go
*.test
.log
.idea
... ...
FROM golang:latest
MAINTAINER linmadan <772181827@qq.com>
FROM 192.168.0.243:5000/mmm/mmm-worth:20201122
#FROM golang:latest
#MAINTAINER linmadan <772181827@qq.com>
ENV APP_DIR $GOPATH/src/mmm-worth
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR/
... ... @@ -10,6 +11,6 @@ COPY ./main.go main.go
RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
ENV GO111MODULE on
ENV GOPROXY https://goproxy.io
RUN ["go","mod","tidy"]
#RUN ["go","mod","tidy"]
RUN ["go","build"]
ENTRYPOINT ["./mmm-worth"]
\ No newline at end of file
... ...
... ... @@ -39,9 +39,6 @@ spec:
operator: In
values:
- cn-hangzhou.i-bp1djh1xn7taumbue1ze
- cn-hangzhou.i-bp1djh1xn7taumbue1zd
- cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
- cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
containers:
- name: mmm-worth
image: 192.168.0.243:5000/mmm/mmm-worth:dev
... ... @@ -57,11 +54,11 @@ spec:
- name: POSTGRESQL_USER
value: "postgres"
- name: POSTGRESQL_PASSWORD
value: "postgres_15432"
value: "eagle1010"
- name: POSTGRESQL_HOST
value: "101.37.68.23"
value: "114.55.200.59"
- name: POSTGRESQL_PORT
value: "15432"
value: "31543"
- name: LOG_LEVEL
value: "debug"
- name: ERROR_BASE_CODE
... ...
... ... @@ -39,9 +39,6 @@ spec:
operator: In
values:
- cn-hangzhou.i-bp1djh1xn7taumbue1ze
- cn-hangzhou.i-bp1djh1xn7taumbue1zd
- cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
- cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
containers:
- name: mmm-worth
image: 192.168.0.243:5000/mmm/mmm-worth:test
... ... @@ -57,11 +54,11 @@ spec:
- name: POSTGRESQL_USER
value: "postgres"
- name: POSTGRESQL_PASSWORD
value: "postgres_15432"
value: "eagle1010"
- name: POSTGRESQL_HOST
value: "101.37.68.23"
value: "114.55.200.59"
- name: POSTGRESQL_PORT
value: "15432"
value: "31543"
- name: LOG_LEVEL
value: "debug"
- name: ERROR_BASE_CODE
... ...
... ... @@ -3,6 +3,7 @@ module gitlab.fjmaimaimai.com/linmadan/mmm-worth
go 1.14
require (
github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.1
github.com/ajg/form v1.5.1 // indirect
github.com/astaxie/beego v1.12.1
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
... ... @@ -13,13 +14,14 @@ require (
github.com/gorilla/websocket v1.4.2 // indirect
github.com/imkira/go-interpol v1.1.0 // indirect
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9
github.com/linmadan/egglib-go v0.0.0-20201125083542-25358a549edb
github.com/mattn/go-colorable v0.1.6 // indirect
github.com/moul/http2curl v1.0.0 // indirect
github.com/onsi/ginkgo v1.10.3
github.com/onsi/gomega v1.7.1
github.com/sergi/go-diff v1.1.0 // indirect
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 // indirect
github.com/shopspring/decimal v1.2.0
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/valyala/fasthttp v1.9.0 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
... ... @@ -27,6 +29,7 @@ require (
github.com/yudai/gojsondiff v1.0.0 // indirect
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
github.com/yudai/pp v2.0.1+incompatible // indirect
golang.org/x/tools v0.0.0-20200117065230-39095c1d176c
)
replace gitlab.fjmaimaimai.com/linmadan/mmm-worth => ../mmm-worth
... ...
github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.1 h1:j56fC19WoD3z+u+ZHxm2XwRGyS1XmdSMk7058BLhdsM=
github.com/360EntSecGroup-Skylar/excelize/v2 v2.3.1/go.mod h1:gXEhMjm1VadSGjAzyDlBxmdYglP8eJpYWxpwJnmXRWw=
github.com/DataDog/zstd v1.3.6-0.20190409195224-796139022798/go.mod h1:1jcaCB/ufaK+sKp1NBhlGmpz41jOoPQ35bpF36t7BBo=
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
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=
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 h1:zJZsqJ1wFMYb2yrja5S3OZ+oASx4irRksZ8+emFs56M=
github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9/go.mod h1:S1zYn9bb6h+Qzu1aOO8raFhHniewOBaif3YvA9qA6lk=
github.com/linmadan/egglib-go v0.0.0-20201125083542-25358a549edb h1:Ocxw5BWyRrRkTHSsTmQx0UnGsAYZDOwa3K9oGlXF8Jo=
github.com/linmadan/egglib-go v0.0.0-20201125083542-25358a549edb/go.mod h1:S1zYn9bb6h+Qzu1aOO8raFhHniewOBaif3YvA9qA6lk=
github.com/mattn/go-colorable v0.1.6 h1:6Su7aK7lXmJ/U79bYtBjLNaha4Fs1Rg9plHpcH+vvnE=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mattn/go-sqlite3 v1.10.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 h1:RWengNIwukTxcDr9M+97sNutRR1RKhG96O6jWumTTnw=
github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826/go.mod h1:TaXosZuwdSHYgviHp1DAtfrULt5eUgsSMsZf+YrPgl8=
github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs=
github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ=
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
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4=
github.com/richardlehane/mscfb v1.0.3 h1:rD8TBkYWkObWO0oLDFCbwMeZ4KoalxQy+QgniCj3nKI=
github.com/richardlehane/mscfb v1.0.3/go.mod h1:YzVpcZg9czvAuhk9T+a3avCpcFPMUWm7gK3DypaEsUk=
github.com/richardlehane/msoleps v1.0.1 h1:RfrALnSNXzmXLbGct/P2b4xkFz4e8Gmj/0Vj9M9xC1o=
github.com/richardlehane/msoleps v1.0.1/go.mod h1:BWev5JBpU9Ko2WAgmZEuiz4/u3ZYTKbjLycmwiWUfWg=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644 h1:X+yvsM2yrEktyI+b2qND5gpH8YhURn0k8OCaeRnkINo=
github.com/shiena/ansicolor v0.0.0-20151119151921-a422bbe96644/go.mod h1:nkxAfR/5quYxwPZhyDxgasBMnRtBZd0FCEpawpjMUFg=
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
github.com/siddontang/go v0.0.0-20180604090527-bdc77568d726/go.mod h1:3yhqj7WBBfRhbBlzyOC3gUxftwsU0u8gqevxwIHQpMw=
github.com/siddontang/ledisdb v0.0.0-20181029004158-becf5f38d373/go.mod h1:mF1DpOSOUiJRMR+FDqaqu3EBqrybQtrDDszLUZ6oxPg=
github.com/siddontang/rdb v0.0.0-20150307021120-fc89ed2e418d/go.mod h1:AMEsy7v5z92TR1JKMkLLoaOQk++LVnOKL3ScbJ8GNGA=
... ... @@ -119,6 +131,8 @@ github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/syndtr/goleveldb v0.0.0-20181127023241-353a9fca669c/go.mod h1:Z4AUp2Km+PwemOoO/VB5AOx9XSsIItzFjoJlOSiYmn0=
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
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
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
github.com/xuri/efp v0.0.0-20200605144744-ba689101faaf h1:spotWVWg9DP470pPFQ7LaYtUqDpWEOS/BUrSmwFZE4k=
github.com/xuri/efp v0.0.0-20200605144744-ba689101faaf/go.mod h1:uBiSUepVYMhGTfDeBKKasV4GpgBlzJ46gXUBAqV8qLk=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY=
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
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
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf h1:fnPsqIDRbCSgumaMCRpoIoF2s4qxv0xSSS0BVZUE/ss=
golang.org/x/crypto v0.0.0-20191029031824-8986dd9e96cf/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a h1:vclmkQCjlDX5OydZ9wv8rBCcS0QyQY66Mpf/7BZbInM=
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/image v0.0.0-20200922025426-e59bae62ef32 h1:E+SEVulmY8U4+i6vSB88YSc2OKAFfvbHPU/uDTdQu7M=
golang.org/x/image v0.0.0-20200922025426-e59bae62ef32/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
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
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478 h1:l5EDrHhldLYb3ZRHDUhXF7Om7MvYXnkV9/iQNo1lX6g=
golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA=
golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
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
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepxRw6jWvR5iDRdvjHgy8=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd h1:xhmwyvizuTgC2qz7ZlMluP20uW+C3Rm0FD/WLDX8884=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
golang.org/x/tools v0.0.0-20200117065230-39095c1d176c h1:FodBYPZKH5tAN2O60HlglMwXGAeV/4k+NKbli79M/2c=
golang.org/x/tools v0.0.0-20200117065230-39095c1d176c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
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=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4 h1:/eiJrUcujPVeJ3xlSWaiNi3uSVmDGBK1pDHUHAnao1I=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
mellium.im/sasl v0.2.1 h1:nspKSRg7/SyO0cRGY71OkfHab8tf9kCts6a6oTDut0w=
mellium.im/sasl v0.2.1/go.mod h1:ROaEDLQNuf9vjKqE1SrAfnsobm2YKXT1gnN1uDp1PjQ=
... ...
... ... @@ -35,5 +35,10 @@ func main() {
}
}
}()
// excel文件路径映射
beego.SetStaticPath("/download", "download")
beego.SetStaticPath("/logs", "log")
beego.Run()
}
... ...
... ... @@ -21,6 +21,7 @@ func (configService *ConfigService) ListTaskStatus(listTaskStatusQuery *query.Li
4: "待验收",
5: "已完成",
7: "待确认",
8: "已过期",
}
var list []map[string]interface{}
for key, value := range taskStatusMap {
... ... @@ -165,7 +166,7 @@ func (configService *ConfigService) ListBidTimeMatch(listBidTimeMatchQuery *quer
}, nil
}
// 返回员工权限字典列表(1任务管理,2素币管理,3成员管理)
// 返回员工权限字典列表(1任务管理,2素币管理,3成员管理,4标签管理,5排行榜管理
func (configService *ConfigService) ListEmployeePermission(listEmployeePermissionQuery *query.ListEmployeePermissionQuery) (interface{}, error) {
if err := listEmployeePermissionQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -175,6 +176,7 @@ func (configService *ConfigService) ListEmployeePermission(listEmployeePermissio
2: "素币管理",
3: "成员管理",
4: "标签管理",
5: "排行榜管理",
}
var list []map[string]interface{}
for key, value := range employeePermissionMap {
... ...
... ... @@ -2,7 +2,6 @@ package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"time"
"github.com/astaxie/beego/validation"
)
... ... @@ -15,6 +16,8 @@ type CreateEmployeeCommand struct {
EmployeeAccount string `json:"employeeAccount,omitempty"`
// 员工头像URL
EmployeeAvatarUrl string `json:"employeeAvatarUrl,omitempty"`
// 创建时间
CreateTime time.Time `json:"createTime"`
}
func (createEmployeeCommand *CreateEmployeeCommand) ValidateCommand() error {
... ...
... ... @@ -2,7 +2,6 @@ package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
... ...
... ... @@ -2,6 +2,7 @@ package command
import (
"fmt"
"time"
"github.com/astaxie/beego/validation"
)
... ... @@ -17,6 +18,8 @@ type UpdateEmployeeCommand struct {
EmployeeAvatarUrl string `json:"employeeAvatarUrl,omitempty"`
// 员工权限集合
Permissions []int `json:"permissions,omitempty"`
// 创建时间
CreateTime time.Time `json:"createTime"`
}
func (updateEmployeeCommand *UpdateEmployeeCommand) ValidateCommand() error {
... ...
... ... @@ -13,6 +13,8 @@ type ListEmployeeQuery struct {
EmployeeNameMatch string `json:"employeeNameMatch,omitempty"`
// 查询偏离量
Offset int `json:"offset,omitempty"`
// 员工状态(启用或者禁用)
Status int `json:"status"`
// 查询限制
Limit int `json:"limit,omitempty"`
}
... ...
... ... @@ -8,6 +8,7 @@ import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/employee/query"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"time"
)
// 员工服务
... ... @@ -36,6 +37,7 @@ func (employeeService *EmployeeService) CreateEmployee(createEmployeeCommand *co
EmployeeAccount: createEmployeeCommand.EmployeeAccount,
},
SuMoney: 0,
CreateTime: time.Now(),
}
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
... ... @@ -122,6 +124,7 @@ func (employeeService *EmployeeService) UpdateEmployee(updateEmployeeCommand *co
if employee == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateEmployeeCommand.Uid)))
}
updateEmployeeCommand.CreateTime = time.Now()
if err := employee.Update(tool_funs.SimpleStructToMap(updateEmployeeCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
... ... @@ -180,6 +183,7 @@ func (employeeService *EmployeeService) ListEmployee(listEmployeeQuery *query.Li
if err := listEmployeeQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -190,6 +194,7 @@ func (employeeService *EmployeeService) ListEmployee(listEmployeeQuery *query.Li
defer func() {
transactionContext.RollbackTransaction()
}()
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -198,7 +203,13 @@ func (employeeService *EmployeeService) ListEmployee(listEmployeeQuery *query.Li
} else {
employeeRepository = value
}
if count, employees, err := employeeRepository.Find(tool_funs.SimpleStructToMap(listEmployeeQuery)); err != nil {
if count, employees, err := employeeRepository.Find(map[string]interface{}{
"companyId": listEmployeeQuery.CompanyId,
"employeeNameMatch": listEmployeeQuery.EmployeeNameMatch,
"offset": listEmployeeQuery.Offset,
"limit": listEmployeeQuery.Limit,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ...
... ... @@ -28,3 +28,19 @@ func CreateNotificationDao(options map[string]interface{}) (*dao.NotificationDao
}
return dao.NewNotificationDao(transactionContext)
}
func CreateCashPoolDao(options map[string]interface{}) (*dao.CashPoolDao, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return dao.NewCashPoolDao(transactionContext)
}
func CreateListIntervalDao(options map[string]interface{}) (*dao.ListIntervalDao, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return dao.NewListIntervalDao(transactionContext)
}
\ No newline at end of file
... ...
... ... @@ -109,3 +109,6 @@ func CreateExchangeSuMoneyService(options map[string]interface{}) (service.Excha
}
return domainService.NewExchangeSuMoneyService(transactionContext)
}
... ...
... ... @@ -85,3 +85,35 @@ func CreateSentNotificationRepository(options map[string]interface{}) (domain.Se
}
return repository.NewSentNotificationRepository(transactionContext)
}
func CreateCashPoolRepository(options map[string]interface{}) (domain.CashPoolRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewCashPoolRepository(transactionContext)
}
func CreateExchangeCashActivityRepository(options map[string]interface{}) (domain.ExchangeActivityRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewExchangeCashActivityRepository(transactionContext)
}
func CreateExchangeCashPersonListRepository(options map[string]interface{}) (domain.ExchangeCashPersonListRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewExchangeCashPersonListRepository(transactionContext)
}
func CreateListIntervalRepository(options map[string]interface{}) (domain.ListIntervalRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewListIntervalRepository(transactionContext)
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
"time"
)
type CreateListIntervalCommand struct {
CompanyId int `json:"companyId" valid:"Required"` // 公司id
ListIntervalStartTime time.Time `json:"listIntervalStartTime"` // 排行榜开始时间
ListIntervalEndTime time.Time `json:"listIntervalEndTime"` // 排行榜结束时间
}
func (createListIntervalCommand *CreateListIntervalCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createListIntervalCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type RemoveListIntervalCommand struct {
ListIntervalId int `json:"listIntervalId" valid:"Required"` // 排行榜Id
}
func (removeListIntervalCommand *RemoveListIntervalCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeListIntervalCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
"time"
)
type UpdateListIntervalCommand struct {
ListIntervalId int `json:"listIntervalId" valid:"Required"` // 排行榜id
ListIntervalStartTime time.Time `json:"listIntervalStartTime"` // 排行榜开始时间
ListIntervalEndTime time.Time `json:"listIntervalEndTime"` // 排行榜结束时间
}
func (updateListIntervalCommand *UpdateListIntervalCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateListIntervalCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type GetListIntervalQuery struct {
ListIntervalId int `json:"listIntervalId"` // 排行榜id
}
func (getListIntervalQuery *GetListIntervalQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(getListIntervalQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ListListIntervalQuery struct {
CompanyId int `json:"companyId"` // 公司id
Offset int `json:"offset,omitempty"` // 查询偏离量
Limit int `json:"limit,omitempty"` // 查询限制
}
func (listListIntervalQuery *ListListIntervalQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listListIntervalQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/listInterval/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/listInterval/query"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
"time"
)
type ListIntervalService struct {
}
// 创建排行榜时间
func (listIntervalService *ListIntervalService) CreateListInterval(createListIntervalCommand *command.CreateListIntervalCommand) (interface{}, error) {
if err := createListIntervalCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
// 排行榜时间仓储初始化
var listIntervalRepository domain.ListIntervalRepository
if value, err := factory.CreateListIntervalRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
listIntervalRepository = value
}
// 排行榜管理DAO初始化
var listIntervalDao *dao.ListIntervalDao
if value, err := factory.CreateListIntervalDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
listIntervalDao = value
}
// 获取当前最新排行榜时间
listListIntervalQuery := &query.ListListIntervalQuery {
CompanyId: createListIntervalCommand.CompanyId,
Offset: 0,
Limit: 1,
}
// 获取上个年榜时间
_, listIntervals, err := listIntervalRepository.Find(tool_funs.SimpleStructToMap(listListIntervalQuery))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
startTime := time.Date(createListIntervalCommand.ListIntervalStartTime.Local().Year(), createListIntervalCommand.ListIntervalStartTime.Local().Month(), createListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local)
endTime := time.Date(createListIntervalCommand.ListIntervalEndTime.Local().Year(), createListIntervalCommand.ListIntervalEndTime.Local().Month(), createListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local)
// 判断年榜时间是否重叠
if len(listIntervals) > 0 {
ok := listIntervalDao.RankPeriodCheckTime(startTime.Local().Unix(), endTime.Local().Unix(), 0, listIntervals[0].CompanyId)
if !ok {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠")
}
}
// 创建排行榜时间
newListInterval := &domain.ListInterval {
CompanyId: createListIntervalCommand.CompanyId,
IntervalStartTime: startTime,
IntervalEndTime: endTime,
}
listInterval, err := listIntervalRepository.Save(newListInterval)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return listInterval, nil
}
// 返回排行榜时间列表
func (listIntervalService *ListIntervalService) ListListInterval(listListIntervalQuery *query.ListListIntervalQuery) (interface{}, error) {
if err := listListIntervalQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var listIntervalRepository domain.ListIntervalRepository
if value, err := factory.CreateListIntervalRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
listIntervalRepository = value
}
if count, listIntervals, err := listIntervalRepository.Find(tool_funs.SimpleStructToMap(listListIntervalQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"count": count,
"listIntervals": listIntervals,
}, nil
}
}
// 返回排行榜时间
func (listIntervalService *ListIntervalService) GetListInterval(getListIntervalQuery *query.GetListIntervalQuery) (interface{}, error) {
if err := getListIntervalQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var listIntervalRepository domain.ListIntervalRepository
if value, err := factory.CreateListIntervalRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
listIntervalRepository = value
}
listInterval, err := listIntervalRepository.FindOne(map[string]interface{}{"listId": getListIntervalQuery.ListIntervalId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if listInterval == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getListIntervalQuery.ListIntervalId)))
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return listInterval, nil
}
}
// 更新排行榜时间
func (listIntervalService *ListIntervalService) UpdateListInterval(updateListIntervalCommand *command.UpdateListIntervalCommand) (interface{}, error) {
if err := updateListIntervalCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
// 排行榜管理仓储初始化
var listIntervalRepository domain.ListIntervalRepository
if value, err := factory.CreateListIntervalRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
listIntervalRepository = value
}
// 排行榜管理DAO初始化
var listIntervalDao *dao.ListIntervalDao
if value, err := factory.CreateListIntervalDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
listIntervalDao = value
}
// 获取当前年榜
listIntervalFound, err := listIntervalRepository.FindOne(map[string]interface{}{"listId": updateListIntervalCommand.ListIntervalId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if listIntervalFound == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateListIntervalCommand.ListIntervalId)))
}
// 当前更新的开始结束时间
startTime := time.Date(updateListIntervalCommand.ListIntervalStartTime.Local().Year(), updateListIntervalCommand.ListIntervalStartTime.Local().Month(), updateListIntervalCommand.ListIntervalStartTime.Local().Day(), 0, 0, 0, 0, time.Local)
endTime := time.Date(updateListIntervalCommand.ListIntervalEndTime.Local().Year(), updateListIntervalCommand.ListIntervalEndTime.Local().Month(), updateListIntervalCommand.ListIntervalEndTime.Local().Day(), 23, 59, 59, 0, time.Local)
updateListIntervalCommand.ListIntervalStartTime = startTime
updateListIntervalCommand.ListIntervalEndTime = endTime
// 判断年榜时间是否重叠
ok := listIntervalDao.RankPeriodCheckTime(startTime.Unix(), endTime.Unix(), listIntervalFound.ListIntervalId, listIntervalFound.CompanyId)
if !ok {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "年榜时间不能重叠")
}
// 更新年榜
if err := listIntervalFound.Update(tool_funs.SimpleStructToMap(updateListIntervalCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if listIntervalUpdated, err := listIntervalRepository.Save(listIntervalFound); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return listIntervalUpdated, nil
}
}
// 移除排行榜时间
func (listIntervalService *ListIntervalService) RemoveListInterval(removeListIntervalCommand *command.RemoveListIntervalCommand) (interface{}, error) {
if err := removeListIntervalCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var listIntervalRepository domain.ListIntervalRepository
if value, err := factory.CreateListIntervalRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
listIntervalRepository = value
}
listInterval, err := listIntervalRepository.FindOne(map[string]interface{}{"listId": removeListIntervalCommand.ListIntervalId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if listInterval == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeListIntervalCommand.ListIntervalId)))
}
if listInterval, err := listIntervalRepository.Remove(listInterval); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return listInterval, nil
}
}
func NewListIntervalService(options map[string] interface{}) *ListIntervalService {
newListIntervalService := &ListIntervalService{}
return newListIntervalService
}
\ No newline at end of file
... ...
... ... @@ -28,6 +28,7 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned
defer func() {
transactionContext.RollbackTransaction()
}()
var notificationRepository domain.NotificationRepository
if value, err := factory.CreateNotificationRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -36,6 +37,7 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned
} else {
notificationRepository = value
}
var sentNotificationRepository domain.SentNotificationRepository
if value, err := factory.CreateSentNotificationRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -44,6 +46,7 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned
} else {
sentNotificationRepository = value
}
var taskDao *dao.TaskDao
if value, err := factory.CreateTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -52,6 +55,13 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned
} else {
taskDao = value
}
// 更新已过期竞标任务状态
if err := taskDao.UpdateExpiredPlannedCompletionTimeBidTask(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 返回快过期任务并发送消息
if tasks, err := taskDao.ListNearThePlannedCompletionTimeTask(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -88,6 +98,7 @@ func (notificationService *NotificationService) SystemNotificationNearThePlanned
}
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
... ... @@ -108,6 +119,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime
defer func() {
transactionContext.RollbackTransaction()
}()
var notificationRepository domain.NotificationRepository
if value, err := factory.CreateNotificationRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -116,6 +128,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime
} else {
notificationRepository = value
}
var sentNotificationRepository domain.SentNotificationRepository
if value, err := factory.CreateSentNotificationRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -124,6 +137,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime
} else {
sentNotificationRepository = value
}
var taskDao *dao.TaskDao
if value, err := factory.CreateTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -132,6 +146,7 @@ func (notificationService *NotificationService) SystemNotificationNearBidEndTime
} else {
taskDao = value
}
if tasks, err := taskDao.ListNearBidEndTimeTask(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
"time"
)
type EmployeesContributionsStatisticsCommand struct {
CompanyId int `json:"companyId" valid:"Required"` // 公司id
StartTime time.Time `json:"startTime"` // 年榜开始时间
EndTime time.Time `json:"endTime"` // 年榜结束时间
}
func (employeesContributionsStatisticsCommand *EmployeesContributionsStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(employeesContributionsStatisticsCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package command
import (
"fmt"
"time"
"github.com/astaxie/beego/validation"
)
type EmployeesSuMoneyStatisticsCommand struct {
CompanyId int `json:"companyId" valid:"Required"` // 公司id
StartTime time.Time `json:"startTime"` // 年榜开始时间
EndTime time.Time `json:"endTime"` // 年榜结束时间
}
func (employeesSuMoneyStatisticsCommand *EmployeesSuMoneyStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(employeesSuMoneyStatisticsCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
"time"
)
type EmployeesRankingListStatisticsCommand struct {
CompanyId int `json:"companyId" valid:"Required"` // 公司id
StartTime time.Time `json:"startTime"` // 年榜开始时间
EndTime time.Time `json:"endTime"` // 年榜结束时间
Offset int `json:"offset,omitempty"` // 查询偏离量
Limit int `json:"limit,omitempty"` // 查询限制
}
func (employeesRankingListStatisticsCommand *EmployeesRankingListStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(employeesRankingListStatisticsCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -9,6 +9,7 @@ import (
type PersonTaskStatisticsCommand struct {
// 统一用户UID
Uid int64 `json:"uid" valid:"Required"`
CompanyId int `json:"companyId" valid:"Required"`
}
func (personTaskStatisticsCommand *PersonTaskStatisticsCommand) ValidateCommand() error {
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
// 获取系统现金值
type SystemCashStatisticsCommand struct {
CompanyId int64 `json:"companyId" valid:"Required"` // 公司ID
}
func (systemCashStatisticsCommand *SystemCashStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(systemCashStatisticsCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
// 获取系统素币值
type SystemSuMoneyStatisticsCommand struct {
CompanyId int64 `json:"companyId" valid:"Required"` // 公司ID
}
func (systemSuMoneyStatisticsCommand *SystemSuMoneyStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(systemSuMoneyStatisticsCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -2,10 +2,13 @@ package service
import (
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/factory"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/statistics/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/suMoney/query"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
"time"
)
// 数据统计服务
... ... @@ -27,6 +30,7 @@ func (statisticsService *StatisticsService) PersonNotificationStatistics(personN
defer func() {
transactionContext.RollbackTransaction()
}()
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -35,6 +39,7 @@ func (statisticsService *StatisticsService) PersonNotificationStatistics(personN
} else {
employeeDao = value
}
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -43,6 +48,7 @@ func (statisticsService *StatisticsService) PersonNotificationStatistics(personN
} else {
employeeRepository = value
}
employee, err := employeeRepository.FindOne(map[string]interface{}{
"uid": personNotificationStatisticsCommand.Uid,
})
... ... @@ -52,6 +58,7 @@ func (statisticsService *StatisticsService) PersonNotificationStatistics(personN
if employee == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业员工")
}
if personNotificationStatistics, err := employeeDao.CalculatePersonUnReadNotification(personNotificationStatisticsCommand.Uid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -77,6 +84,7 @@ func (statisticsService *StatisticsService) SystemTaskStatistics(systemTaskStati
defer func() {
transactionContext.RollbackTransaction()
}()
var taskDao *dao.TaskDao
if value, err := factory.CreateTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -85,6 +93,7 @@ func (statisticsService *StatisticsService) SystemTaskStatistics(systemTaskStati
} else {
taskDao = value
}
if systemTaskStatistics, err := taskDao.CalculateSystemTask(systemTaskStatisticsCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -110,6 +119,7 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati
defer func() {
transactionContext.RollbackTransaction()
}()
var taskDao *dao.TaskDao
if value, err := factory.CreateTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -118,6 +128,7 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati
} else {
taskDao = value
}
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -126,6 +137,7 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati
} else {
employeeRepository = value
}
employee, err := employeeRepository.FindOne(map[string]interface{}{
"uid": personTaskStatisticsCommand.Uid,
})
... ... @@ -135,7 +147,8 @@ func (statisticsService *StatisticsService) PersonTaskStatistics(personTaskStati
if employee == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业员工")
}
if personTaskStatistics, err := taskDao.CalculatePersonTask(personTaskStatisticsCommand.Uid); err != nil {
if personTaskStatistics, err := taskDao.CalculatePersonTask(personTaskStatisticsCommand.Uid, personTaskStatisticsCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -160,6 +173,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone
defer func() {
transactionContext.RollbackTransaction()
}()
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -168,6 +182,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone
} else {
employeeDao = value
}
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -176,6 +191,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone
} else {
employeeRepository = value
}
employee, err := employeeRepository.FindOne(map[string]interface{}{
"uid": personSuMoneyStatisticsCommand.Uid,
})
... ... @@ -185,6 +201,7 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone
if employee == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的企业员工")
}
if personSuMoneyStatistics, err := employeeDao.CalculatePersonSuMoney(personSuMoneyStatisticsCommand.Uid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -196,6 +213,327 @@ func (statisticsService *StatisticsService) PersonSuMoneyStatistics(personSuMone
}
}
// 获取系统素币统计
func (statisticsService *StatisticsService) SystemSuMoneyStatistics(systemSuMoneyStatisticsCommand *command.SystemSuMoneyStatisticsCommand) (interface{}, error) {
if err := systemSuMoneyStatisticsCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
employeeDao = value
}
if systemSuMoneyStatistics, err := employeeDao.CalculateSystemSuMoney(systemSuMoneyStatisticsCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return systemSuMoneyStatistics, nil
}
}
// 获取系统现金统计
func (statisticsService *StatisticsService) SystemCashStatistics(systemCashStatisticsCommand *command.SystemCashStatisticsCommand) (interface{}, error) {
if err := systemCashStatisticsCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
employeeDao = value
}
// 判断现金池是否存在
var cashPoolRepository domain.CashPoolRepository
if value, err := factory.CreateCashPoolRepository(map[string] interface{} {
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cashPoolRepository = value
}
countCashPools, _, err := cashPoolRepository.Find(tool_funs.SimpleStructToMap(systemCashStatisticsCommand))
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if countCashPools == 0 { // 现金池为空时处理
return map[string]interface{} {
"systemExchangedCash" : 0,
"systemUnExchangeCash": 0,
}, nil
}
if systemCashStatistics, err := employeeDao.CalculateSystemCash(systemCashStatisticsCommand.CompanyId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return systemCashStatistics, nil
}
}
// 获取公司员工财富值分组统计
func (statisticsService *StatisticsService) EmployeesSuMoneyStatistics(employeesSuMoneyStatisticsCommand *command.EmployeesSuMoneyStatisticsCommand) (interface{}, error) {
if err := employeesSuMoneyStatisticsCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
employeeDao = value
}
if employeesSuMoneyStatisticsCommand.StartTime.IsZero() && employeesSuMoneyStatisticsCommand.EndTime.IsZero() {
employeesSuMoneyStatisticsCommand.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
employeesSuMoneyStatisticsCommand.EndTime = time.Now().Local()
}
if employeesSuMoneyStatistics, err := employeeDao.CalculateEmployeesSuMoney(employeesSuMoneyStatisticsCommand.CompanyId, employeesSuMoneyStatisticsCommand.StartTime, employeesSuMoneyStatisticsCommand.EndTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return employeesSuMoneyStatistics, nil
}
}
// 获取公司员工贡献值分组统计
func (statisticsService *StatisticsService) EmployeesContributionsStatistics(employeesContributionsStatisticsCommand *command.EmployeesContributionsStatisticsCommand) (interface{}, error) {
if err := employeesContributionsStatisticsCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
employeeDao = value
}
if employeesContributionsStatisticsCommand.StartTime.IsZero() && employeesContributionsStatisticsCommand.EndTime.IsZero() {
employeesContributionsStatisticsCommand.StartTime = time.Date(1971, time.Month(1), 1, 0, 0, 0, 0, time.Now().Location())
employeesContributionsStatisticsCommand.EndTime = time.Now().Local()
}
if employeesContributionsStatistics, err := employeeDao.CalculateEmployeesContributions(employeesContributionsStatisticsCommand.CompanyId, employeesContributionsStatisticsCommand.StartTime, employeesContributionsStatisticsCommand.EndTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return employeesContributionsStatistics, nil
}
}
// 贡献值、财富值榜单
func (statisticsService *StatisticsService) ContributionsWealthRanking(contributionsWealthRankingQuery *query.ContributionsWealthRankingQuery) (interface{}, error) {
if err := contributionsWealthRankingQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
// 员工仓储初始化
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
employeeRepository = value
}
// 员工DAO初始化
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
employeeDao = value
}
if contributionsWealthRankingQuery.RankingType == 1 { // 返回总榜
contributionsWealthRankingQuery.StartTime = time.Date(0001, 01, 01, 0, 0, 0, 0, time.UTC)
contributionsWealthRankingQuery.EndTime = time.Date(0001, 01, 01, 0, 0, 0, 0, time.UTC)
} else if contributionsWealthRankingQuery.RankingType == 2 { // 返回年榜
// 获取公司最新年榜
var listIntervalRepository domain.ListIntervalRepository
if value, err := factory.CreateListIntervalRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
listIntervalRepository = value
}
listListIntervalQuery := map[string]interface{} {
"companyId": contributionsWealthRankingQuery.CompanyId,
}
if _, listIntervals, err := listIntervalRepository.FindAll(listListIntervalQuery); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if len(listIntervals) == 0 { // 未配置年榜
contributionsWealthRankingQuery.StartTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local)
contributionsWealthRankingQuery.EndTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local)
} else if len(listIntervals) == 1 { // 只配置了一个年榜
currentTime := time.Now().Unix()
if currentTime >= listIntervals[0].IntervalStartTime.Unix() && currentTime <= listIntervals[0].IntervalEndTime.Unix() {
contributionsWealthRankingQuery.StartTime = listIntervals[0].IntervalStartTime
contributionsWealthRankingQuery.EndTime = listIntervals[0].IntervalEndTime
} else { // 当前时间处于空档期
contributionsWealthRankingQuery.StartTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local)
contributionsWealthRankingQuery.EndTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local)
}
} else if len(listIntervals) > 1 { // 配置了多个年榜,判断当前时间是否在榜单里
currentTime := time.Now().Unix()
for _, listInterval := range listIntervals {
if currentTime >= listInterval.IntervalStartTime.Unix() && currentTime <= listInterval.IntervalEndTime.Unix() {
contributionsWealthRankingQuery.StartTime = listInterval.IntervalStartTime
contributionsWealthRankingQuery.EndTime = listInterval.IntervalEndTime
break
} else { // 当前时间处于空档期
contributionsWealthRankingQuery.StartTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local)
contributionsWealthRankingQuery.EndTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local)
continue
}
}
} else {
contributionsWealthRankingQuery.StartTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local)
contributionsWealthRankingQuery.EndTime = time.Date(0001, 01, 02, 0, 0, 0, 0, time.Local)
}
}
}
// 默认返回总榜
if contributionsWealthRankingStatistics, err := employeeDao.ContributionsWealthRanking(tool_funs.SimpleStructToMap(contributionsWealthRankingQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
uidName := map[int64]interface{}{}
if _, employees, err := employeeRepository.FindAll(map[string]interface{}{
"companyId": contributionsWealthRankingQuery.CompanyId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, employee := range employees {
uidName[employee.EmployeeInfo.Uid] = employee.EmployeeInfo.EmployeeName
}
}
// 财富值排行榜
for i, _ := range contributionsWealthRankingStatistics.(map[string]interface{})["employeesWealth"].([]struct{Uid int64;EmployeeName string;EmployeeSuMoney float64;Ranking int}) {
uid := contributionsWealthRankingStatistics.(map[string]interface{})["employeesWealth"].([]struct{Uid int64;EmployeeName string;EmployeeSuMoney float64;Ranking int})[i].Uid
if uidName[uid] != nil {
contributionsWealthRankingStatistics.(map[string]interface{})["employeesWealth"].([]struct{Uid int64;EmployeeName string;EmployeeSuMoney float64;Ranking int})[i].EmployeeName = uidName[uid].(string)
}
}
// 个人财富值
if contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeWealth"] != nil {
currentEmployeeWealth := contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeWealth"].(struct{Uid int64;EmployeeName string;EmployeeSuMoney float64;Ranking int})
uidWealth := contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeWealth"].(struct{Uid int64;EmployeeName string;EmployeeSuMoney float64;Ranking int}).Uid
if uidName[uidWealth] != nil {
currentEmployeeWealth.EmployeeName = uidName[uidWealth].(string)
}
contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeWealth"] = currentEmployeeWealth
}
// 贡献值排行版
for i, _ := range contributionsWealthRankingStatistics.(map[string]interface{})["employeesContributions"].([]struct { Uid int64; EmployeeName string; EmployeesContributions float64; Ranking int }) {
uid := contributionsWealthRankingStatistics.(map[string]interface{})["employeesContributions"].([]struct{Uid int64;EmployeeName string;EmployeesContributions float64;Ranking int})[i].Uid
if uidName[uid] != nil {
contributionsWealthRankingStatistics.(map[string]interface{})["employeesContributions"].([]struct{Uid int64;EmployeeName string;EmployeesContributions float64;Ranking int})[i].EmployeeName = uidName[uid].(string)
}
}
// 个人贡献值
if contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeContributions"] != nil {
currentEmployeeContributions := contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeContributions"].(struct{Uid int64;EmployeeName string;EmployeesContributions float64;Ranking int})
uidContributions := contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeContributions"].(struct{Uid int64;EmployeeName string;EmployeesContributions float64;Ranking int}).Uid
if uidName[uidContributions] != nil {
currentEmployeeContributions.EmployeeName = uidName[uidContributions].(string)
}
contributionsWealthRankingStatistics.(map[string]interface{})["currentEmployeeContributions"] = currentEmployeeContributions
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return contributionsWealthRankingStatistics, nil
}
}
func NewStatisticsService(options map[string]interface{}) *StatisticsService {
newStatisticsService := &StatisticsService{}
return newStatisticsService
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
"time"
)
type ContributionsTransactionRecordStatisticsCommand struct {
// 统一用户UID
Uid int64 `json:"uid" valid:"Required"`
// 事务时间区间-开始时间
TransactionStartTime time.Time `json:"transactionStartTime,omitempty"`
// 事务时间区间-截止时间
TransactionEndTime time.Time `json:"transactionEndTime,omitempty"`
}
func (contributionsTransactionRecordStatisticsCommand *ContributionsTransactionRecordStatisticsCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(contributionsTransactionRecordStatisticsCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
// 创建现金池
type CreateCashPoolCommand struct {
CompanyId int64 `json:"companyId" valid:"Required"` // 公司ID
Cash float64 `json:"cash" valid:"Required"` // 投入的现金值
}
func (createCashPoolCommand *CreateCashPoolCommand) ValidateCommand() error {
valid := validation.Validation{}
rt, err := valid.Valid(createCashPoolCommand)
if err != nil {
return err
}
if !rt {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
"time"
)
// 创建现金兑换活动
type CreateExchangeCashActivityCommand struct {
CompanyId int64 `json:"companyId" valid:"Required"` // 公司id
ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称
Deadline time.Time `json:"deadline"` // 活动截止时间
ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率
CreateTime time.Time `json:"createTime"` // 创建时间
}
func (createExchangeActivityCommand *CreateExchangeCashActivityCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createExchangeActivityCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type CreateExchangeCashPersonCommand struct {
Uid int64 `json:"uid"` // 统一用户id
PersonName string `json:"personName,omitempty"` // 兑换现金人员名称
Operator int64 `json:"operator"` // 操作人
PersonAccount string `json:"personAccount,omitempty"` // 手机账号
ExchangeCashActivityId int64 `json:"exchangeCashActivityId" valid:"Required"` // 参与的兑换活动id
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币值
}
func (createExchangeCashPersonCommand *CreateExchangeCashPersonCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createExchangeCashPersonCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
... ... @@ -7,14 +7,10 @@ import (
)
type ExchangeSuMoneyCommand struct {
// 兑换人UID
Uid int64 `json:"uid" valid:"Required"`
// 素币值
SuMoney float64 `json:"suMoney" valid:"Required"`
// 操作人UID
Operator int64 `json:"operator,omitempty"`
// 兑换描述
ExchangeDescription string `json:"exchangeDescription" valid:"Required"`
Uid int64 `json:"uid" valid:"Required"` // 兑换人UID
SuMoney float64 `json:"suMoney" valid:"Required"` // 素币值
Operator int64 `json:"operator,omitempty"` // 操作人UID
ExchangeDescription string `json:"exchangeDescription" valid:"Required"` // 兑换描述
}
func (exchangeSuMoneyCommand *ExchangeSuMoneyCommand) ValidateCommand() error {
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ExportExchangeCashListCommand struct {
Ids []int `json:"ids"`
Where map[string]interface{} `json:"where"`
}
func (exportExchangeCashListCommand *ExportExchangeCashListCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(exportExchangeCashListCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ExportSuMoneyCommand struct {
Ids []int `json:"ids"` // 员工uid
Where map[string]interface{} `json:"where"`
}
func (exportSuMoneyCommand *ExportSuMoneyCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(exportSuMoneyCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ExportTransactionRecordCommand struct {
Ids []int `json:"ids"`
Where map[string]interface{} `json:"where"`
}
func (exportTransactionRecordCommand *ExportTransactionRecordCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(exportTransactionRecordCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ImportExchangeCashListCommand struct {
Where map[string]interface{} `json:"where"`
}
func (importExchangeCashListCommand *ImportExchangeCashListCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(importExchangeCashListCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
... ... @@ -7,16 +7,11 @@ import (
)
type OperationSuMoneyCommand struct {
// 素币拥有者UID
Uid int64 `json:"uid" valid:"Required"`
// 操作类型(1增加,2扣除)
OperationType int `json:"operationType" valid:"Required"`
// 素币值
SuMoney float64 `json:"suMoney" valid:"Required"`
// 操作人UID
Operator int64 `json:"operator,omitempty"`
// 理由描述
OperationDescription string `json:"operationDescription" valid:"Required"`
Uid int64 `json:"uid" valid:"Required"` // 素币拥有者UID
OperationType int `json:"operationType" valid:"Required"` // 操作类型(1增加,2扣除, 3兑换物资, 4兑换现金)
SuMoney float64 `json:"suMoney" valid:"Required"` // 素币值
Operator int64 `json:"operator,omitempty"` // 操作人UID
OperationDescription string `json:"operationDescription" valid:"Required"` // 理由描述
}
func (operationSuMoneyCommand *OperationSuMoneyCommand) ValidateCommand() error {
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
// 删除兑换现金活动
type RemoveExchangeCashActivityCommand struct {
ActivityId int64 `json:"activityId" valid:"Required"`
}
func (removeExchangeCashActivityCommand *RemoveExchangeCashActivityCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeExchangeCashActivityCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
// 移除兑换现金人员
type RemoveExchangeCashPersonCommand struct {
ListId int64 `json:"listId" valid:"Required"` // 兑换现金人员编号
Operator int64 `json:"operator,omitempty"` // 操作人
}
func (removeExchangeCashPersonCommand *RemoveExchangeCashPersonCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeExchangeCashPersonCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type SearchExchangeCashActivityCommand struct {
ActivityNameMatch string `json:"activityNameMatch"` // 兑换现金活动名称
CompanyId int64 `json:"companyId"` // 公司id
Deadline string `json:"deadline,omitempty"` // 截止时间筛选
Offset int `json:"offset,omitempty"` // 查询偏移量
Limit int `json:"limit,omitempty"` // 查询限制条目
}
func (searchExchangeCashActivityCommand *SearchExchangeCashActivityCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(searchExchangeCashActivityCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type SearchExchangeCashPersonCommand struct {
ListName string `json:"listName"` // 兑换素币人员名称
}
func (searchExchangeCashPersonCommand *SearchExchangeCashPersonCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(searchExchangeCashPersonCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type SearchSuMoneyTransactionCommand struct {
EmployeeName string `json:"employeeName"` // 员工姓名
}
func (searchSuMoneyTransactionCommand *SearchSuMoneyTransactionCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(searchSuMoneyTransactionCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
... ... @@ -9,17 +9,20 @@ import (
type SearchSuMoneyTransactionRecordCommand struct {
// 统一用户UID
Uid int64 `json:"uid" valid:"Required"`
//Uid int64 `json:"uid" valid:"Required"`
Uid int64 `json:"uid"`
// 记录类型(1兑换,2任务奖励,3增加,4扣除)
RecordType int `json:"recordType,omitempty"`
// 记录类型列表(1兑换,2任务奖励,3增加,4扣除)
RecordTypes []int `json:"recordTypes,omitempty"`
// 操作人UID
// 事务时间区间-开始时间
TransactionStartTime time.Time `json:"transactionStartTime,omitempty"`
// 事务时间区间-截止时间
TransactionEndTime time.Time `json:"transactionEndTime,omitempty"`
// 操作人UID
Operator int64 `json:"operator,omitempty"`
// 关联人员姓名
EmployeeMatchName string `json:"employeeMatchName"`
// 查询偏离量
Offset int `json:"offset,omitempty"`
// 查询限制
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type UpdateCashPoolCommand struct {
CashPoolId int64 `json:"cashPoolId"` // 现金池编号
ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币
UnExchangeCash float64 `json:"unExchangeCash"` // 未兑换现金
UnExchangeSuMoney float64 `json:"unExchangeSuMoney"` // 未兑换素币
Rate float64 `json:"rate"` // 平均兑换汇率
Cash float64 `json:"cash"`
//CompanyId int64 `json:"companyId"`
LastRate float64 `json:"lastRate"`
//CreateTime time.Time `json:"createTime"`
}
func (updateCashPoolCommand *UpdateCashPoolCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateCashPoolCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
"time"
)
type UpdateExchangeCashActivityCommand struct {
ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id
ExchangeActivityName string `json:"exchangeActivityName"` // 活动名称
Deadline time.Time `json:"deadline"` // 活动截止时间
CountDown int64 `json:"countDown"` // 活动倒计时
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换素币
ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金
ExchangeRate float64 `json:"exchangeRate"` // 兑换汇率
}
func (updateExchangeCashActivity *UpdateExchangeCashActivityCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateExchangeCashActivity)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package command
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type UpdateExchangeCashPersonCommand struct {
ListId int64 `json:"listId" valid:"Required"` // 兑换现金人员编号
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币(需要和当前的已兑换素币进行比较,少于当前已兑换素币则生成一条扣除素币记录,大于当前已兑换素币则生成一条增加素币记录)
ExchangedCash float64 `json:"exchangedCash"` // 已兑换现金
Operator int64 `json:"operator,omitempty"` // 操作人
}
func (updateExchangeCashPersonCommand *UpdateExchangeCashPersonCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateExchangeCashPersonCommand)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
"time"
)
type ContributionsWealthRankingQuery struct {
CompanyId int64 `json:"companyId" valid:"Required"` // 公司ID
RankingType int `json:"rankingType" valid:"Required"` // 榜单类型,区分总榜和年榜 1:总榜,2:年榜
Offset int `json:"offset,omitempty"` // 查询偏离量
Limit int `json:"limit,omitempty"` // 查询限制
Uid int64 `json:"uid" valid:"Required"` // 统一用户id
StartTime time.Time `json:"startTime"` // 榜单开始时间,由后台根据榜单类型后去
EndTime time.Time `json:"endTime"` // 榜单结束更新,由后台根据榜单类型获取
}
func (contributionsWealthRankingQuery *ContributionsWealthRankingQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(contributionsWealthRankingQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ExchangeListRankingQuery struct {
ActivityId int64 `json:"activityId"`
CompanyId int64 `json:"companyId"` // 公司ID
Offset int `json:"offset,omitempty"` // 查询偏离量
Limit int `json:"limit,omitempty"` // 查询限制
Uid int64 `json:"uid"` // 统一用户id
}
func (exchangeListRankingQuery *ExchangeListRankingQuery) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(exchangeListRankingQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
// 获取现金池
type GetCashPoolQuery struct {
CompanyId int64 `json:"companyId" valid:"Required"` // 公司id
}
func (getCashPoolQuery *GetCashPoolQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(getCashPoolQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
// 获取兑换现金活动
type GetExchangeCashActivityQuery struct {
ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id
}
func (getExchangeCashActivityQuery *GetExchangeCashActivityQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(getExchangeCashActivityQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type GetExchangeCashPersonQuery struct {
ExchangeCashPersonId int64 `json:"exchangeCashPersonId"` // 参与兑换现金活动人员id
}
func (getExchangeCashPersonQuery *GetExchangeCashPersonQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(getExchangeCashPersonQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
// 获取兑换现金活动列表
type ListExchangeCashActivityQuery struct {
CompanyId int64 `json:"companyId"` // 公司id
ActivityNameMatch string `json:"activityNameMatch,omitempty"` // 活动名称匹配
//Deadline time.Time `json:"deadline,omitempty"` // 截止时间筛选
IsEnd bool `json:"isEnd"` // 已结束活动和未结束活动筛选 true: 已结束活动 false: 未结束活动
Offset int `json:"offset,omitempty"` // 查询偏移量
Limit int `json:"limit,omitempty"` // 查询限制条目
}
func (listExchangeCashActivityQuery *ListExchangeCashActivityQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listExchangeCashActivityQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
type ListExchangeCashActivityDeadlineQuery struct {
CompanyId int64 `json:"companyId"` // 公司id
}
func (listExchangeCashActivityDeadlineQuery *ListExchangeCashActivityDeadlineQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listExchangeCashActivityDeadlineQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
package query
import (
"fmt"
"github.com/astaxie/beego/validation"
)
// 获取兑换活动兑换清单
type ListExchangeCashPersonQuery struct {
CompanyId int64 `json:"companyId"` // 公司id
ExchangeCashActivityId int64 `json:"exchangeCashActivityId"` // 兑换现金活动id
ExchangeCashPersonNameMatch string `json:"exchangeCashPersonNameMatch,omitempty"` // 兑换活动名称匹配
Offset int `json:"offset,omitempty"` // 查询偏离量
Limit int `json:"limit,omitempty"` // 查询限制
}
func (listExchangeCashPersonQuery *ListExchangeCashPersonQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listExchangeCashPersonQuery)
if err != nil {
return err
}
if !b {
for _, validErr := range valid.Errors {
return fmt.Errorf("%s %s", validErr.Key, validErr.Message)
}
}
return nil
}
\ No newline at end of file
... ...
... ... @@ -30,6 +30,18 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand *
defer func() {
transactionContext.RollbackTransaction()
}()
// 员工仓储初始化
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
employeeRepository = value
}
// 操作素币服务初始化
var operationSuMoneyService service.OperationSuMoneyService
if value, err := factory.CreateOperationSuMoneyService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -38,6 +50,20 @@ func (suMoneyService *SuMoneyService) OperationSuMoney(operationSuMoneyCommand *
} else {
operationSuMoneyService = value
}
// 判断当前员工是否有效
getEmployee := map[string]interface{}{
"uid": operationSuMoneyCommand.Uid,
"status": 1,
}
employeeFound, err := employeeRepository.FindOne(getEmployee)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if employeeFound == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的员工")
}
if task, err := operationSuMoneyService.Operation(operationSuMoneyCommand.Uid, operationSuMoneyCommand.Operator, operationSuMoneyCommand.SuMoney, operationSuMoneyCommand.OperationType, operationSuMoneyCommand.OperationDescription); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -63,6 +89,7 @@ func (suMoneyService *SuMoneyService) GetSuMoneyTransactionRecord(getSuMoneyTran
defer func() {
transactionContext.RollbackTransaction()
}()
var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -71,6 +98,7 @@ func (suMoneyService *SuMoneyService) GetSuMoneyTransactionRecord(getSuMoneyTran
} else {
suMoneyTransactionRecordRepository = value
}
if suMoneyTransactionRecord, err := suMoneyTransactionRecordRepository.FindOne(map[string]interface{}{"suMoneyTransactionRecordId": getSuMoneyTransactionRecordQuery.SuMoneyTransactionRecordId}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -96,6 +124,7 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co
defer func() {
transactionContext.RollbackTransaction()
}()
var exchangeSuMoneyService service.ExchangeSuMoneyService
if value, err := factory.CreateExchangeSuMoneyService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -104,6 +133,7 @@ func (suMoneyService *SuMoneyService) ExchangeSuMoney(exchangeSuMoneyCommand *co
} else {
exchangeSuMoneyService = value
}
if task, err := exchangeSuMoneyService.Exchange(exchangeSuMoneyCommand.Uid, exchangeSuMoneyCommand.Operator, exchangeSuMoneyCommand.SuMoney, exchangeSuMoneyCommand.ExchangeDescription); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -129,6 +159,8 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon
defer func() {
transactionContext.RollbackTransaction()
}()
// 素币事务记录仓储初始化
var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -137,20 +169,57 @@ func (suMoneyService *SuMoneyService) SearchSuMoneyTransactionRecord(searchSuMon
} else {
suMoneyTransactionRecordRepository = value
}
// 获取素币兑换事务记录
if count, suMoneyTransactionRecords, err := suMoneyTransactionRecordRepository.Find(tool_funs.SimpleStructToMap(searchSuMoneyTransactionRecordCommand)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var suMoneyTransactionRecordsFormat []interface{}
for _, suMoneyTransactionRecord := range suMoneyTransactionRecords {
suMoneyTransactionRecordFormat := map[string]interface{} {
"suMoneyTransactionRecordId": suMoneyTransactionRecord.SuMoneyTransactionRecordId,
"recordType": suMoneyTransactionRecord.RecordType,
"employee": map[string]interface{} {
"uid": suMoneyTransactionRecord.Employee.Uid,
"employeeName": suMoneyTransactionRecord.Employee.EmployeeName,
"employeeAccount": suMoneyTransactionRecord.Employee.EmployeeAccount,
"employeeAvatarUrl": suMoneyTransactionRecord.Employee.EmployeeAvatarUrl,
"isPrincipal": suMoneyTransactionRecord.Employee.IsPrincipal,
},
"suMoneyBeforeTransaction": suMoneyTransactionRecord.SuMoneyBeforeTransaction,
"currentSuMoney": suMoneyTransactionRecord.CurrentSuMoney,
"suMoney": suMoneyTransactionRecord.SuMoney,
"cashBeforeTransaction": suMoneyTransactionRecord.CashBeforeTransaction,
"currentCash": suMoneyTransactionRecord.CurrentCash,
"cash": suMoneyTransactionRecord.Cash,
"operator": map[string]interface{} {
"uid": suMoneyTransactionRecord.Operator.Uid,
"employeeName": suMoneyTransactionRecord.Operator.EmployeeName,
"employeeAccount": suMoneyTransactionRecord.Operator.EmployeeAccount,
"employeeAvatarUrl": suMoneyTransactionRecord.Operator.EmployeeAvatarUrl,
"isPrincipal": suMoneyTransactionRecord.Operator.IsPrincipal,
},
"recordDescription": suMoneyTransactionRecord.RecordDescription,
"createTime": suMoneyTransactionRecord.CreateTime.Local(),
}
suMoneyTransactionRecordsFormat = append(suMoneyTransactionRecordsFormat, suMoneyTransactionRecordFormat)
}
if len(suMoneyTransactionRecordsFormat) == 0 {
suMoneyTransactionRecordsFormat = []interface{}{}
}
return map[string]interface{}{
"count": count,
"suMoneyTransactionRecords": suMoneyTransactionRecords,
"suMoneyTransactionRecords": suMoneyTransactionRecordsFormat,
}, nil
}
}
// 素币事务记录统计
// 素币事务记录统计(个人素币)
func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoneyTransactionRecordStatisticsCommand *command.SuMoneyTransactionRecordStatisticsCommand) (interface{}, error) {
if err := suMoneyTransactionRecordStatisticsCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
... ... @@ -165,6 +234,8 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney
defer func() {
transactionContext.RollbackTransaction()
}()
// 员工DAO初始化
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -173,6 +244,7 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney
} else {
employeeDao = value
}
if calculateResult, err := employeeDao.CalculateSuMoneyTransactionRecord(suMoneyTransactionRecordStatisticsCommand.Uid, suMoneyTransactionRecordStatisticsCommand.TransactionStartTime, suMoneyTransactionRecordStatisticsCommand.TransactionEndTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -183,6 +255,123 @@ func (suMoneyService *SuMoneyService) SuMoneyTransactionRecordStatistics(suMoney
}
}
// 贡献值事务记录统计(个人贡献值)
func (suMoneyService *SuMoneyService) ContributionsTransactionRecordStatistics(contributionsTransactionRecordStatisticsCommand *command.ContributionsTransactionRecordStatisticsCommand) (interface{}, error) {
if err := contributionsTransactionRecordStatisticsCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var employeeDao *dao.EmployeeDao
if value, err := factory.CreateEmployeeDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
employeeDao = value
}
if calculateResult, err := employeeDao.CalculateContributionsTransactionRecord(contributionsTransactionRecordStatisticsCommand.Uid, contributionsTransactionRecordStatisticsCommand.TransactionStartTime, contributionsTransactionRecordStatisticsCommand.TransactionEndTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return calculateResult, nil
}
}
// 根据uid获取员工素币(导出素币流水)
func (suMoneyService *SuMoneyService) ListSuMoneyById(exportSuMoneyCommand *command.ExportSuMoneyCommand) ([]*domain.Employee, error) {
if err := exportSuMoneyCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
if len(exportSuMoneyCommand.Ids) == 0 && exportSuMoneyCommand.Where == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据")
}
// 员工仓储初始化
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
employeeRepository = value
}
if _, employees, err := employeeRepository.FindByIds(tool_funs.SimpleStructToMap(exportSuMoneyCommand)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return employees, nil
}
}
// 根据id获取事务记录(导出素币流水记录)
func (suMoneyService *SuMoneyService) ListSuMoneyTransactionRecordById(exportSuMoneyTransactionRecordCommand *command.ExportTransactionRecordCommand) ([]*domain.SuMoneyTransactionRecord, error) {
if err := exportSuMoneyTransactionRecordCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
if len(exportSuMoneyTransactionRecordCommand.Ids) == 0 && exportSuMoneyTransactionRecordCommand.Where == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "未勾选需要导出的数据")
}
var suMoneyTransactionRecordRepository domain.SuMoneyTransactionRecordRepository
if value, err := factory.CreateSuMoneyTransactionRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
suMoneyTransactionRecordRepository = value
}
if _, suMoneyTransactionRecords, err := suMoneyTransactionRecordRepository.FindById(tool_funs.SimpleStructToMap(exportSuMoneyTransactionRecordCommand)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return suMoneyTransactionRecords, nil
}
}
func NewSuMoneyService(options map[string]interface{}) *SuMoneyService {
newSuMoneyService := &SuMoneyService{}
return newSuMoneyService
... ...
... ... @@ -15,6 +15,8 @@ type AcceptanceTaskCommand struct {
Operator int64 `json:"operator" valid:"Required"`
// 任务参与者UID列表
Participators []int64 `json:"participators,omitempty"`
// 实际奖励素币值
SuMoney float64 `jsons:"suMoney"`
// 任务贡献占比
TaskPercentage []*domain.TaskPercentageItem `json:"taskPercentage"`
// 引用资源解决分
... ...
... ... @@ -29,6 +29,10 @@ type CreateTaskCommand struct {
TaskNature int `json:"taskNature,omitempty"`
// 奖励素币
SuMoney float64 `json:"suMoney,omitempty"`
// 最小奖励素币
MinSuMoney float64 `json:"minSuMoney"`
// 最大奖励素币
MaxSuMoney float64 `json:"maxSuMoney"`
// 验收标准
AcceptanceStandard string `json:"acceptanceStandard,omitempty"`
// 任务描述
... ...
... ... @@ -13,12 +13,18 @@ type SearchTaskCommand struct {
Sponsor int64 `json:"sponsor,omitempty"`
// 任务内容匹配
TaskContentMatch string `json:"taskContentMatch,omitempty"`
// 任务名称匹配
TaskNameMatch string `json:"taskNameMatch,omitempty"`
// 任务类型
TaskType int `json:"taskType,omitempty"`
// 任务类型ID列表
TaskTypes []int `json:"taskTypes,omitempty"`
// 任务状态
TaskStatus int `json:"taskStatus,omitempty"`
// 任务状态ID列表
TaskStates []int `json:"taskStates,omitempty"`
// 任务状态ID列表
TaskStatuss []int `json:"taskStatuss,omitempty"`
// 项目归属
ProjectBelongs []int `json:"projectBelongs,omitempty"`
// 客户价值
... ...
... ... @@ -23,8 +23,12 @@ type UpdateTaskCommand struct {
CustomerValues []int `json:"customerValues,omitempty"`
// 任务性质
TaskNature int `json:"taskNature,omitempty"`
// 奖励素币
// 实际奖励素币
SuMoney float64 `json:"suMoney,omitempty"`
// 最小奖励素币
MinSuMoney float64 `json:"minSuMoney,omitempty"`
// 最大奖励素币
MaxSuMoney float64 `json:"maxSuMoney,omitempty"`
// 验收标准
AcceptanceStandard string `json:"acceptanceStandard,omitempty"`
// 任务描述
... ...
... ... @@ -29,6 +29,10 @@ type TaskDto struct {
TaskNature *domain.TaskNature `json:"taskNature"`
// 奖励素币
SuMoney float64 `json:"suMoney"`
// 最小奖励素币
MinSuMoney float64 `json:"minSuMoney"`
// 最大奖励素币
MaxSuMoney float64 `json:"maxSuMoney"`
// 验收标准
AcceptanceStandard string `json:"acceptanceStandard"`
// 任务描述
... ... @@ -99,6 +103,8 @@ func (dto *TaskDto) LoadDto(task *domain.Task, projectBelongMap map[int]*domain.
}
}
dto.SuMoney = task.SuMoney
dto.MinSuMoney = task.MinSuMoney
dto.MaxSuMoney = task.MaxSuMoney
dto.AcceptanceStandard = task.AcceptanceStandard
dto.TaskDescription = task.TaskDescription
dto.TaskPictureUrls = task.TaskPictureUrls
... ...
... ... @@ -2,6 +2,8 @@ package service
import (
"fmt"
"time"
"github.com/linmadan/egglib-go/core/application"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"github.com/linmadan/egglib-go/utils/tool_funs"
... ... @@ -13,7 +15,6 @@ import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain/service"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
"time"
)
// 任务服务
... ... @@ -25,6 +26,7 @@ func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.Co
if err := confirmRobTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -35,6 +37,7 @@ func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.Co
defer func() {
transactionContext.RollbackTransaction()
}()
var confirmRobTaskService service.ConfirmRobTaskService
if value, err := factory.CreateConfirmRobTaskService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -46,6 +49,7 @@ func (taskService *TaskService) ConfirmRobTask(confirmRobTaskCommand *command.Co
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
if task, err := confirmRobTaskService.Confirm(confirmRobTaskCommand.TaskId, confirmRobTaskCommand.Operator, confirmRobTaskCommand.PlannedCompletionTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -61,6 +65,7 @@ func (taskService *TaskService) RejectTaskReceiver(rejectTaskReceiverCommand *co
if err := rejectTaskReceiverCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -71,6 +76,7 @@ func (taskService *TaskService) RejectTaskReceiver(rejectTaskReceiverCommand *co
defer func() {
transactionContext.RollbackTransaction()
}()
var rejectTaskReceiverService service.RejectTaskReceiverService
if value, err := factory.CreateRejectTaskReceiverService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -82,6 +88,7 @@ func (taskService *TaskService) RejectTaskReceiver(rejectTaskReceiverCommand *co
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
if task, err := rejectTaskReceiverService.Reject(rejectTaskReceiverCommand.TaskId, rejectTaskReceiverCommand.Operator, rejectTaskReceiverCommand.RejectReason); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -97,6 +104,7 @@ func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand)
if err := robTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -107,6 +115,7 @@ func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand)
defer func() {
transactionContext.RollbackTransaction()
}()
var robTaskService service.RobTaskService
if value, err := factory.CreateRobTaskService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -119,6 +128,7 @@ func (taskService *TaskService) RobTask(robTaskCommand *command.RobTaskCommand)
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
if task, err := robTaskService.Rob(robTaskCommand.TaskId, robTaskCommand.Receiver); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -134,6 +144,7 @@ func (taskService *TaskService) BidTask(bidTaskCommand *command.BidTaskCommand)
if err := bidTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -144,6 +155,7 @@ func (taskService *TaskService) BidTask(bidTaskCommand *command.BidTaskCommand)
defer func() {
transactionContext.RollbackTransaction()
}()
var bidTaskService service.BidTaskService
if value, err := factory.CreateBidTaskService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -152,6 +164,7 @@ func (taskService *TaskService) BidTask(bidTaskCommand *command.BidTaskCommand)
} else {
bidTaskService = value
}
if task, err := bidTaskService.Bid(bidTaskCommand.TaskId, bidTaskCommand.Bidder); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -167,6 +180,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom
if err := chooseSuccessfulBidderCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -177,6 +191,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom
defer func() {
transactionContext.RollbackTransaction()
}()
var chooseSuccessfulBidderService service.ChooseSuccessfulBidderService
if value, err := factory.CreateChooseSuccessfulBidderService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -186,6 +201,7 @@ func (taskService *TaskService) ChooseSuccessfulBidder(chooseSuccessfulBidderCom
chooseSuccessfulBidderService = value
chooseSuccessfulBidderService.Subscribe(&subscriber.AbilityServiceSubscriber{})
}
if task, err := chooseSuccessfulBidderService.Choose(chooseSuccessfulBidderCommand.TaskId, chooseSuccessfulBidderCommand.SuccessfulBidder, chooseSuccessfulBidderCommand.Operator, chooseSuccessfulBidderCommand.PlannedCompletionTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -201,6 +217,7 @@ func (taskService *TaskService) ApplyCompleteTask(applyCompleteTaskCommand *comm
if err := applyCompleteTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -211,6 +228,7 @@ func (taskService *TaskService) ApplyCompleteTask(applyCompleteTaskCommand *comm
defer func() {
transactionContext.RollbackTransaction()
}()
var applyCompleteTaskService service.ApplyCompleteTaskService
if value, err := factory.CreateApplyCompleteTaskService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -219,6 +237,7 @@ func (taskService *TaskService) ApplyCompleteTask(applyCompleteTaskCommand *comm
} else {
applyCompleteTaskService = value
}
if task, err := applyCompleteTaskService.ApplyComplete(applyCompleteTaskCommand.TaskId, applyCompleteTaskCommand.Receiver); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -234,6 +253,7 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT
if err := releaseTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -244,6 +264,8 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT
defer func() {
transactionContext.RollbackTransaction()
}()
// 发布任务服务初始化
var releaseTaskService service.ReleaseTaskService
if value, err := factory.CreateReleaseTaskService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -256,6 +278,8 @@ func (taskService *TaskService) ReleaseTask(releaseTaskCommand *command.ReleaseT
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
// 关闭任务
if task, err := releaseTaskService.Release(releaseTaskCommand.TaskId, releaseTaskCommand.Operator); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -271,6 +295,7 @@ func (taskService *TaskService) OffTask(offTaskCommand *command.OffTaskCommand)
if err := offTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -281,6 +306,8 @@ func (taskService *TaskService) OffTask(offTaskCommand *command.OffTaskCommand)
defer func() {
transactionContext.RollbackTransaction()
}()
// 关闭任务服务初始化
var offTaskService service.OffTaskService
if value, err := factory.CreateOffTaskService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -290,6 +317,8 @@ func (taskService *TaskService) OffTask(offTaskCommand *command.OffTaskCommand)
offTaskService = value
offTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
}
// 关闭任务
if task, err := offTaskService.Off(offTaskCommand.TaskId, offTaskCommand.Operator, offTaskCommand.OffReason); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -305,6 +334,7 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac
if err := acceptanceTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -315,6 +345,8 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac
defer func() {
transactionContext.RollbackTransaction()
}()
// 验收服务初始化
var acceptanceTaskService service.AcceptanceTaskService
if value, err := factory.CreateAcceptanceTaskService(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -324,7 +356,50 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac
acceptanceTaskService = value
acceptanceTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
}
if task, err := acceptanceTaskService.Acceptance(acceptanceTaskCommand.TaskId, acceptanceTaskCommand.Operator, acceptanceTaskCommand.Participators, acceptanceTaskCommand.TaskPercentage, acceptanceTaskCommand.ReferenceResourceScore, acceptanceTaskCommand.SolveReport, acceptanceTaskCommand.SolvePictureUrls, acceptanceTaskCommand.ActualCompletionTime); err != nil {
// 员工仓储初始化
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
employeeRepository = value
}
// 填充百分比员工信息
for i, taskPercentage := range acceptanceTaskCommand.TaskPercentage {
getEmployee := map[string]interface{}{
"uid": taskPercentage.Contributor.Uid,
}
employeeFound, err := employeeRepository.FindOne(getEmployee)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if employeeFound == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的员工")
}
acceptanceTaskCommand.TaskPercentage[i].Contributor = employeeFound.EmployeeInfo
}
// 填充评分员工信息
for i, referenceResourceScore := range acceptanceTaskCommand.ReferenceResourceScore {
for j, solveScore := range referenceResourceScore.SolveScore {
getEmployee := map[string]interface{}{
"uid": solveScore.Contributor.Uid,
}
employeeFound, err := employeeRepository.FindOne(getEmployee)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if employeeFound == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的员工")
}
acceptanceTaskCommand.ReferenceResourceScore[i].SolveScore[j].Contributor = employeeFound.EmployeeInfo
}
}
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 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
... ... @@ -336,10 +411,11 @@ func (taskService *TaskService) AcceptanceTask(acceptanceTaskCommand *command.Ac
// 搜索任务
func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTaskCommand) (interface{}, error) {
if err := searchTaskCommand.ValidateCommand(); err != nil {
if err := searchTaskCommand.ValidateCommand(); err != nil { // 校验搜索命令
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
transactionContext, err := factory.CreateTransactionContext(nil) // 工厂类创建事务上下文
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -349,6 +425,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
defer func() {
transactionContext.RollbackTransaction()
}()
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -357,6 +434,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
} else {
taskRepository = value
}
var projectBelongRepository domain.ProjectBelongRepository
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -365,6 +443,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
} else {
projectBelongRepository = value
}
projectBelongMap := make(map[int]*domain.ProjectBelong)
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
"companyId": searchTaskCommand.CompanyId,
... ... @@ -375,6 +454,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
}
}
var customerValueRepository domain.CustomerValueRepository
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -383,6 +463,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
} else {
customerValueRepository = value
}
customerValueMap := make(map[int]*domain.CustomerValue)
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
"companyId": searchTaskCommand.CompanyId,
... ... @@ -393,6 +474,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
customerValueMap[customerValue.CustomerValueId] = customerValue
}
}
var taskNatureRepository domain.TaskNatureRepository
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -401,6 +483,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
} else {
taskNatureRepository = value
}
taskNatureMap := make(map[int]*domain.TaskNature)
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
"companyId": searchTaskCommand.CompanyId,
... ... @@ -411,6 +494,7 @@ func (taskService *TaskService) SearchTask(searchTaskCommand *command.SearchTask
taskNatureMap[taskNature.TaskNatureId] = taskNature
}
}
if count, tasks, err := taskRepository.Find(tool_funs.SimpleStructToMap(searchTaskCommand)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -437,6 +521,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
if err := searchOffTaskRecordCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -447,6 +532,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
defer func() {
transactionContext.RollbackTransaction()
}()
var projectBelongRepository domain.ProjectBelongRepository
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -455,6 +541,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
} else {
projectBelongRepository = value
}
projectBelongMap := make(map[int]*domain.ProjectBelong)
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
"companyId": searchOffTaskRecordCommand.CompanyId,
... ... @@ -465,6 +552,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
}
}
var customerValueRepository domain.CustomerValueRepository
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -473,6 +561,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
} else {
customerValueRepository = value
}
customerValueMap := make(map[int]*domain.CustomerValue)
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
"companyId": searchOffTaskRecordCommand.CompanyId,
... ... @@ -483,6 +572,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
customerValueMap[customerValue.CustomerValueId] = customerValue
}
}
var taskNatureRepository domain.TaskNatureRepository
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -491,6 +581,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
} else {
taskNatureRepository = value
}
taskNatureMap := make(map[int]*domain.TaskNature)
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
"companyId": searchOffTaskRecordCommand.CompanyId,
... ... @@ -501,6 +592,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
taskNatureMap[taskNature.TaskNatureId] = taskNature
}
}
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -509,6 +601,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
} else {
taskRepository = value
}
var offTaskRecordRepository domain.OffTaskRecordRepository
if value, err := factory.CreateOffTaskRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -517,6 +610,7 @@ func (taskService *TaskService) SearchOffTaskRecord(searchOffTaskRecordCommand *
} else {
offTaskRecordRepository = value
}
_, tasks, err := taskRepository.Find(map[string]interface{}{
"companyId": searchOffTaskRecordCommand.CompanyId,
"taskStatus": domain.TASK_STATUS_CLOSED,
... ... @@ -570,6 +664,7 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge
if err := getOffTaskRecordQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -580,6 +675,7 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge
defer func() {
transactionContext.RollbackTransaction()
}()
var offTaskRecordRepository domain.OffTaskRecordRepository
if value, err := factory.CreateOffTaskRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -588,6 +684,7 @@ func (taskService *TaskService) GetOffTaskRecord(getOffTaskRecordQuery *query.Ge
} else {
offTaskRecordRepository = value
}
offTaskRecord, err := offTaskRecordRepository.FindOne(map[string]interface{}{"offTaskRecordId": getOffTaskRecordQuery.OffTaskRecordId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -607,6 +704,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom
if err := searchRejectTaskRecordCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -617,6 +715,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom
defer func() {
transactionContext.RollbackTransaction()
}()
var projectBelongRepository domain.ProjectBelongRepository
if value, err := factory.CreateProjectBelongRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -625,6 +724,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom
} else {
projectBelongRepository = value
}
projectBelongMap := make(map[int]*domain.ProjectBelong)
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
"companyId": searchRejectTaskRecordCommand.CompanyId,
... ... @@ -635,6 +735,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
}
}
var customerValueRepository domain.CustomerValueRepository
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -643,6 +744,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom
} else {
customerValueRepository = value
}
customerValueMap := make(map[int]*domain.CustomerValue)
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
"companyId": searchRejectTaskRecordCommand.CompanyId,
... ... @@ -653,6 +755,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom
customerValueMap[customerValue.CustomerValueId] = customerValue
}
}
var taskNatureRepository domain.TaskNatureRepository
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -661,6 +764,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom
} else {
taskNatureRepository = value
}
taskNatureMap := make(map[int]*domain.TaskNature)
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
"companyId": searchRejectTaskRecordCommand.CompanyId,
... ... @@ -671,6 +775,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom
taskNatureMap[taskNature.TaskNatureId] = taskNature
}
}
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -679,6 +784,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom
} else {
taskRepository = value
}
var rejectTaskRecordRepository domain.RejectTaskRecordRepository
if value, err := factory.CreateRejectTaskRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -687,6 +793,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom
} else {
rejectTaskRecordRepository = value
}
_, tasks, err := taskRepository.Find(map[string]interface{}{
"companyId": searchRejectTaskRecordCommand.CompanyId,
"taskContentMatch": searchRejectTaskRecordCommand.TaskContentMatch,
... ... @@ -702,6 +809,7 @@ func (taskService *TaskService) SearchRejectTaskRecord(searchRejectTaskRecordCom
for _, task := range tasks {
taskIds = append(taskIds, task.TaskId)
}
if count, rejectTaskRecords, err := rejectTaskRecordRepository.Find(map[string]interface{}{
"taskIds": taskIds,
"rejectStartTime": searchRejectTaskRecordCommand.RejectStartTime,
... ... @@ -739,6 +847,7 @@ func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *qu
if err := getRejectTaskRecordQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -749,6 +858,7 @@ func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *qu
defer func() {
transactionContext.RollbackTransaction()
}()
var rejectTaskRecordRepository domain.RejectTaskRecordRepository
if value, err := factory.CreateRejectTaskRecordRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -757,6 +867,7 @@ func (taskService *TaskService) GetRejectTaskRecord(getRejectTaskRecordQuery *qu
} else {
rejectTaskRecordRepository = value
}
rejectTaskRecord, err := rejectTaskRecordRepository.FindOne(map[string]interface{}{"rejectTaskRecordId": getRejectTaskRecordQuery.RejectTaskRecordId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -776,6 +887,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
if err := createTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -786,6 +898,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
defer func() {
transactionContext.RollbackTransaction()
}()
var taskDao *dao.TaskDao
if value, err := factory.CreateTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -794,6 +907,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
} else {
taskDao = value
}
var employeeRepository domain.EmployeeRepository
if value, err := factory.CreateEmployeeRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -802,28 +916,54 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
} else {
employeeRepository = value
}
sponsor, err := employeeRepository.FindOne(map[string]interface{}{
"uid": createTaskCommand.Sponsor,
"status": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if sponsor == nil {
// 获取无效的发布人员信息
sponsorInvalid, err := employeeRepository.FindOne(map[string]interface{}{
"uid": createTaskCommand.AssignedPerson,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if sponsorInvalid == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者")
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的发布者:"+ sponsorInvalid.EmployeeInfo.EmployeeName)
}
// 获取任务指派人
var assignedPerson *domain.EmployeeInfo
if createTaskCommand.AssignedPerson != 0 {
employee, err := employeeRepository.FindOne(map[string]interface{}{
"uid": createTaskCommand.AssignedPerson,
"status": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if employee == nil {
// 获取无效的指派人员信息
employeeInvalid, err := employeeRepository.FindOne(map[string]interface{}{
"uid": createTaskCommand.AssignedPerson,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if employeeInvalid == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:" + employeeInvalid.EmployeeInfo.EmployeeName)
}
assignedPerson = employee.EmployeeInfo
}
newTask := &domain.Task{
TaskStatus: domain.TASK_STATUS_UNRELEASED,
CompanyId: createTaskCommand.CompanyId,
... ... @@ -838,6 +978,8 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
CustomerValues: createTaskCommand.CustomerValues,
TaskNature: createTaskCommand.TaskNature,
SuMoney: createTaskCommand.SuMoney,
MinSuMoney: createTaskCommand.MinSuMoney,
MaxSuMoney: createTaskCommand.MaxSuMoney,
AcceptanceStandard: createTaskCommand.AcceptanceStandard,
TaskDescription: createTaskCommand.TaskDescription,
TaskPictureUrls: createTaskCommand.TaskPictureUrls,
... ... @@ -846,6 +988,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
PlannedCompletionTime: createTaskCommand.PlannedCompletionTime,
CreateTime: time.Now(),
}
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -854,6 +997,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
} else {
taskRepository = value
}
if createTaskCommand.ReferenceResourceItems != nil && len(createTaskCommand.ReferenceResourceItems) > 0 {
var referenceResourceIds []int64
for _, referenceResourceItem := range createTaskCommand.ReferenceResourceItems {
... ... @@ -871,6 +1015,7 @@ func (taskService *TaskService) CreateTask(createTaskCommand *command.CreateTask
}
}
}
if task, err := taskRepository.Save(newTask); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -908,6 +1053,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
if err := getTaskQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -918,6 +1064,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
defer func() {
transactionContext.RollbackTransaction()
}()
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -926,6 +1073,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
} else {
taskRepository = value
}
task, err := taskRepository.FindOne(map[string]interface{}{"taskId": getTaskQuery.TaskId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -941,6 +1089,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
} else {
projectBelongRepository = value
}
projectBelongMap := make(map[int]*domain.ProjectBelong)
if _, projectBelongs, err := projectBelongRepository.Find(map[string]interface{}{
"companyId": task.CompanyId,
... ... @@ -951,6 +1100,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
projectBelongMap[projectBelong.ProjectBelongId] = projectBelong
}
}
var customerValueRepository domain.CustomerValueRepository
if value, err := factory.CreateCustomerValueRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -959,6 +1109,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
} else {
customerValueRepository = value
}
customerValueMap := make(map[int]*domain.CustomerValue)
if _, customerValues, err := customerValueRepository.Find(map[string]interface{}{
"companyId": task.CompanyId,
... ... @@ -969,6 +1120,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
customerValueMap[customerValue.CustomerValueId] = customerValue
}
}
var taskNatureRepository domain.TaskNatureRepository
if value, err := factory.CreateTaskNatureRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -977,6 +1129,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
} else {
taskNatureRepository = value
}
taskNatureMap := make(map[int]*domain.TaskNature)
if _, taskNatures, err := taskNatureRepository.Find(map[string]interface{}{
"companyId": task.CompanyId,
... ... @@ -987,6 +1140,7 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
taskNatureMap[taskNature.TaskNatureId] = taskNature
}
}
taskDto := &dto.TaskDto{}
if err := taskDto.LoadDto(task, projectBelongMap, customerValueMap, taskNatureMap); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -994,15 +1148,55 @@ func (taskService *TaskService) GetTask(getTaskQuery *query.GetTaskQuery) (inter
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// 返回任务素币奖励范围
if taskDto.TaskStatus != 5 && task.MinSuMoney == 0 && task.MaxSuMoney == 0 {
taskDto.MinSuMoney = 0
taskDto.MaxSuMoney = task.SuMoney
}
return taskDto, nil
}
}
// 更新过期任务状态
func (taskService *TaskService) UpdateTaskStatus() (interface{}, error) {
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var taskDao *dao.TaskDao
if value, err := factory.CreateTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
taskDao = value
}
if err := taskDao.UpdateExpiredPlannedCompletionTimeBidTask(); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
}
// 更新任务
func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTaskCommand) (interface{}, error) {
if err := updateTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -1013,6 +1207,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
defer func() {
transactionContext.RollbackTransaction()
}()
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -1021,6 +1216,7 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
} else {
taskRepository = value
}
var taskDao *dao.TaskDao
if value, err := factory.CreateTaskDao(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -1029,13 +1225,34 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
} else {
taskDao = value
}
var releaseTaskService service.ReleaseTaskService
if value, err := factory.CreateReleaseTaskService(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
releaseTaskService = value
releaseTaskService.Subscribe(&subscriber.AbilityServiceSubscriber{})
releaseTaskService.Subscribe(&subscriber.MmmOpenApiServiceServiceSubscriber{
TransactionContext: transactionContext.(*pgTransaction.TransactionContext),
})
}
var taskBidEndTime time.Time
// 找到当前任务
task, err := taskRepository.FindOne(map[string]interface{}{"taskId": updateTaskCommand.TaskId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if task == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateTaskCommand.TaskId)))
} else {
if task.TaskStatus == domain.TASK_STATUS_EXPIRED {
taskBidEndTime = task.BidInfo.BidEndTime
}
}
if updateTaskCommand.ReferenceResourceItems != nil && len(updateTaskCommand.ReferenceResourceItems) > 0 {
var referenceResourceIds []int64
for _, referenceResourceItem := range updateTaskCommand.ReferenceResourceItems {
... ... @@ -1058,8 +1275,11 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
}
}
}
updateData := tool_funs.SimpleStructToMap(updateTaskCommand)
fmt.Println(updateTaskCommand.AssignedPerson != int64(0))
if task.TaskType == domain.TASK_TYPE_DESIGNATE {
if updateTaskCommand.AssignedPerson != int64(0) {
var employeeRepository domain.EmployeeRepository
... ... @@ -1072,18 +1292,30 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
}
employee, err := employeeRepository.FindOne(map[string]interface{}{
"uid": updateTaskCommand.AssignedPerson,
"status": 1,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if employee == nil {
// 获取无效的发布人员信息
employeeInvalid, err := employeeRepository.FindOne(map[string]interface{}{
"uid": updateTaskCommand.AssignedPerson,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if employeeInvalid == nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员")
}
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "无效的指派人员:" + employeeInvalid.EmployeeInfo.EmployeeName)
}
updateData["assignedPerson"] = employee.EmployeeInfo
} else {
updateData["assignedPerson"] = &domain.EmployeeInfo{}
}
}
if err := task.Update(updateData); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
... ... @@ -1095,6 +1327,18 @@ func (taskService *TaskService) UpdateTask(updateTaskCommand *command.UpdateTask
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
if task.TaskStatus == domain.TASK_STATUS_EXPIRED {
// 未修改时间或者修改的时间小于当前时间
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)) {
return nil, application.ThrowError(application.BUSINESS_ERROR, "请重新修改竞标时间")
} else {
if _, err := releaseTaskService.Release(task.TaskId, task.Sponsor.Uid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
}
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -1124,6 +1368,7 @@ func (taskService *TaskService) RemoveTask(removeTaskCommand *command.RemoveTask
if err := removeTaskCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -1134,6 +1379,7 @@ func (taskService *TaskService) RemoveTask(removeTaskCommand *command.RemoveTask
defer func() {
transactionContext.RollbackTransaction()
}()
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -1142,6 +1388,7 @@ func (taskService *TaskService) RemoveTask(removeTaskCommand *command.RemoveTask
} else {
taskRepository = value
}
task, err := taskRepository.FindOne(map[string]interface{}{"taskId": removeTaskCommand.TaskId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -1181,6 +1428,7 @@ func (taskService *TaskService) ListTask(listTaskQuery *query.ListTaskQuery) (in
if err := listTaskQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
... ... @@ -1191,6 +1439,7 @@ func (taskService *TaskService) ListTask(listTaskQuery *query.ListTaskQuery) (in
defer func() {
transactionContext.RollbackTransaction()
}()
var taskRepository domain.TaskRepository
if value, err := factory.CreateTaskRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -1199,15 +1448,24 @@ func (taskService *TaskService) ListTask(listTaskQuery *query.ListTaskQuery) (in
} else {
taskRepository = value
}
if count, tasks, err := taskRepository.Find(tool_funs.SimpleStructToMap(listTaskQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var retTasks []*domain.Task
for _, task := range tasks {
if task.TaskStatus != 5 && task.MinSuMoney == 0 && task.MaxSuMoney == 0 {
task.MinSuMoney = 0
task.MaxSuMoney = task.SuMoney
}
retTasks = append(retTasks, task)
}
return map[string]interface{}{
"count": count,
"tasks": tasks,
"tasks": retTasks,
}, nil
}
}
... ...
... ... @@ -7,6 +7,7 @@ import (
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/application/unifiedUserCenter/command"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/domain"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/dao"
"time"
)
// 统一用户中心适配服务
... ... @@ -88,12 +89,12 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
uids = append(uids, int64(uid.(float64)))
}
}
if value, ok := data["add"]; ok {
if value, ok := data["add"]; ok { // 添加员工
for _, addEmployee := range value.([]interface{}) {
addEmployees = append(addEmployees, addEmployee.(map[string]interface{}))
}
}
if value, ok := data["edit"]; ok {
if value, ok := data["edit"]; ok { // 编辑员工
for _, editEmployee := range value.([]interface{}) {
editEmployees = append(editEmployees, editEmployee.(map[string]interface{}))
}
... ... @@ -145,7 +146,9 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
},
Status: status,
SuMoney: 0,
CreateTime: time.Now(),
}
if _, err := employeeRepository.Save(employee); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -205,6 +208,7 @@ func (unifiedUserCenterService *UnifiedUserCenterService) SyncEmployeeCallback(s
},
Status: status,
SuMoney: 0,
CreateTime: time.Now(),
}
if _, err := employeeRepository.Save(employee); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ...
... ... @@ -8,6 +8,9 @@ var LOG_LEVEL = "debug"
var ABILITY_SERVICE_HOST = "https://suplus-worth-app-gateway-dev.fjmaimaimai.com"
var MMM_OPEN_API_SERVICE_HOST = "http://mmm-open-api-dev.fjmaimaimai.com"
//var LOG_LEVEL = "debug"
var LOG_File = "logs/app.log"
func init() {
if os.Getenv("LOG_LEVEL") != "" {
LOG_LEVEL = os.Getenv("LOG_LEVEL")
... ...
... ... @@ -2,11 +2,11 @@ package constant
import "os"
var POSTGRESQL_DB_NAME = "mmm-worth"
var POSTGRESQL_DB_NAME = "mmm-worth-test"
var POSTGRESQL_USER = "postgres"
var POSTGRESQL_PASSWORD = "abc123456"
var POSTGRESQL_PASSWORD = "1993618jack"
var POSTGRESQL_HOST = "127.0.0.1"
var POSTGRESQL_PORT = "32432"
var POSTGRESQL_PORT = "5432"
var DISABLE_CREATE_TABLE = false
var DISABLE_SQL_GENERATE_PRINT = false
... ...
package domain
import (
"time"
)
// 现金池
type CashPool struct {
CashPoolId int64 `json:"cashPoolId"` // 现金池id
Cash float64 `json:"cash"` // 投入现金池的现金
CompanyId int64 `json:"companyId"` // 公司id
ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
UnExchangeCash float64 `json:"unExchangeCash"` // 未兑换的现金
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币
UnExchangeSuMoney float64 `json:"unExchangeSuMoney"` // 未兑换的素币
Rate float64 `json:"rate"` // 平均兑换汇率
LastRate float64 `json:"lastRate"` // 上期活动兑换汇率
CreateTime time.Time `json:"createTime"` // 现金投入现金池时间
}
type CashPoolRepository interface {
Save(cashPool *CashPool) (*CashPool, error)
FindOne(queryOptions map[string]interface{}) (*CashPool, error)
Find(queryOptions map[string]interface{}) (int64, []*CashPool, error)
}
func (cashPool *CashPool) Update(data map[string]interface{}) error {
if cash, ok := data["cash"]; ok {
cashPool.Cash = cash.(float64)
}
if exchangedCash, ok := data["exchangedCash"]; ok {
cashPool.ExchangedCash = exchangedCash.(float64)
}
if unExchangeCash, ok := data["unExchangeCash"]; ok {
cashPool.UnExchangeCash = unExchangeCash.(float64)
}
if exchangedSuMoney, ok := data["exchangedSuMoney"]; ok {
cashPool.ExchangedSuMoney = exchangedSuMoney.(float64)
}
if unExchangeSuMoney, ok := data["unExchangeSuMoney"]; ok {
cashPool.UnExchangeSuMoney = unExchangeSuMoney.(float64)
}
if rate, ok := data["rate"]; ok {
cashPool.Rate = rate.(float64)
}
return nil
}
func (cashPool *CashPool) Identity() interface{} {
if cashPool.CashPoolId == 0 {
return nil
}
return cashPool.CashPoolId
}
... ...
package domain
import "time"
// 员工
type Employee struct {
// 员工ID
... ... @@ -14,6 +16,8 @@ type Employee struct {
Status int `json:"status"`
// 员工权限集合
Permissions []int `json:"permissions"`
// 创建时间
CreateTime time.Time `json:"createTime"`
}
type EmployeeRepository interface {
... ... @@ -21,6 +25,8 @@ type EmployeeRepository interface {
Remove(employee *Employee) (*Employee, error)
FindOne(queryOptions map[string]interface{}) (*Employee, error)
Find(queryOptions map[string]interface{}) (int64, []*Employee, error)
FindByIds(queryOptions map[string]interface{}) (int64, []*Employee, error)
FindAll(queryOptions map[string]interface{}) (int64, []*Employee, error)
}
func (employee *Employee) Identify() interface{} {
... ... @@ -49,6 +55,9 @@ func (employee *Employee) Update(data map[string]interface{}) error {
if permissions, ok := data["permissions"]; ok {
employee.Permissions = permissions.([]int)
}
if createTime, ok := data["createTime"]; ok && !createTime.(time.Time).IsZero() {
employee.CreateTime = createTime.(time.Time)
}
return nil
}
... ...
package domain
import (
"time"
)
// 兑换现金活动
type ExchangeCashActivity struct {
ActivityId int64 `json:"activityId"` // 兑换现金活动id
ExchangeActivityName string `json:"exchangeActivityName"` // 兑换现金活动名称
CompanyId int64 `json:"companyId"` // 公司ID
ExchangedCash float64 `json:"exchangedCash"` // 已兑换的现金
ExchangedSuMoney float64 `json:"exchangedSuMoney"` // 已兑换的素币
Deadline time.Time `json:"deadline"` // 兑换现金活动截止时间
CountDown int64 `json:"countDown"` // 兑换现金活动结束倒计时
Rate float64 `json:"rate"` // 兑换汇率
CreateTime time.Time `json:"createTime"` // 创建兑换现金活动时间
}
type ExchangeActivityRepository interface {
Save(exchangeCashActivity *ExchangeCashActivity) (*ExchangeCashActivity, error)
Remove(exchangeCashActivity *ExchangeCashActivity) (*ExchangeCashActivity, error)
FindOne(queryOptions map[string]interface{}) (*ExchangeCashActivity, error)
Find(queryOptions map[string]interface{}) (int64, []*ExchangeCashActivity, error)
FindAll(queryOptions map[string]interface{}) (int64, []*ExchangeCashActivity, error)
}
func (exchangeCashActivity *ExchangeCashActivity) Identity() interface{} {
if exchangeCashActivity.ActivityId == 0 {
return nil
}
return exchangeCashActivity.ActivityId
}
func (exchangeCashActivity *ExchangeCashActivity) Update(data map[string]interface{}) error {
if exchangeActivityName, ok := data["exchangeActivityName"]; ok && exchangeActivityName != "" {
exchangeCashActivity.ExchangeActivityName = exchangeActivityName.(string)
}
if deadline, ok := data["deadline"]; ok && deadline != "" {
exchangeCashActivity.Deadline = deadline.(time.Time)
}
if countDown, ok := data["countDown"]; ok && countDown != 0 {
exchangeCashActivity.CountDown = countDown.(int64)
}
if exchangedSuMoney, ok := data["exchangedSuMoney"]; ok && exchangedSuMoney != 0 {
exchangeCashActivity.ExchangedSuMoney = exchangedSuMoney.(float64)
}
if exchangedCash, ok := data["exchangedCash"]; ok && exchangedCash != 0 {
exchangeCashActivity.ExchangedCash = exchangedCash.(float64)
}
if exchangeRate, ok := data["exchangeRate"]; ok && exchangeRate != 0 {
exchangeCashActivity.Rate = exchangeRate.(float64)
}
if createTime, ok := data["createTime"]; ok && createTime.(time.Time).IsZero() {
exchangeCashActivity.CreateTime = createTime.(time.Time)
}
exchangeCashActivity.CreateTime = time.Now()
return nil
}
func (exchangeCashActivity *ExchangeCashActivity) TransferSuMoney(rate float64) error {
exchangeCashActivity.ExchangedSuMoney = exchangeCashActivity.ExchangedCash * rate
return nil
}
func (exchangeCashActivity *ExchangeCashActivity) TransferCountDown() error {
exchangeCashActivity.CountDown = int64(time.Until(exchangeCashActivity.Deadline))
return nil
}
... ...
package domain
import (
"fmt"
"strconv"
)
// 参与兑换现金人员
type ExchangeCashPersonList struct {
ListId int64 `json:"listId"` // 清单id
EmployeeInfo *EmployeeInfo `json:"employeeInfo"` // 兑换人信息
ExchangeCashActivityId int64 `json:"exchangeActivityId"` // 参与的兑换活动id
ExchangedSuMoney float64 `json:"suMoney"` // 已兑换的素币
ExchangedCash float64 `json:"cash"` // 已兑换的现金
}
type ExchangeCashPersonListRepository interface {
Save(exchangeCashPersonList *ExchangeCashPersonList) (*ExchangeCashPersonList, error)
Remove(exchangeCashPersonList *ExchangeCashPersonList) (*ExchangeCashPersonList, error)
FindOne(queryOptions map[string]interface{}) (*ExchangeCashPersonList, error)
Find(queryOptions map[string]interface{}) (int64, []*ExchangeCashPersonList, error)
FindAll(queryOptions map[string]interface{}) (int64, []*ExchangeCashPersonList, error)
FindById(queryOptions map[string]interface{}) (int64, []*ExchangeCashPersonList, error)
}
func (exchangeCashPersonList *ExchangeCashPersonList) Identity() interface{} {
if exchangeCashPersonList.ListId == 0 {
return nil
}
return exchangeCashPersonList.ListId
}
func (exchangeCashPersonList *ExchangeCashPersonList) Update(data map[string]interface{}) error {
if exchangedSuMoney, ok := data["exchangedSuMoney"]; ok && exchangedSuMoney != 0 {
exchangeCashPersonList.ExchangedSuMoney = exchangedSuMoney.(float64)
}
if exchangedCash, ok := data["exchangedCash"]; ok && exchangedCash != 0 {
exchangeCashPersonList.ExchangedCash, _ = strconv.ParseFloat(fmt.Sprintf("%.2F", exchangedCash.(float64)), 64)
}
return nil
}
\ No newline at end of file
... ...
package domain
import (
"time"
)
// 排行榜时间
type ListInterval struct {
ListIntervalId int `json:"listIntervalId"` // 排行榜时间id
CompanyId int `json:"companyId"` // 公司id
IntervalStartTime time.Time `json:"intervalStartTime"` // 排行榜开始时间
IntervalEndTime time.Time `json:"intervalEndTime"` // 排行榜结束时间
}
type ListIntervalRepository interface {
Save(listInterval *ListInterval) (*ListInterval, error)
Remove(listInterval *ListInterval) (*ListInterval, error)
FindOne(queryOptions map[string]interface{}) (*ListInterval, error)
Find(queryOptions map[string]interface{}) (int64, []*ListInterval, error)
FindAll(queryOptions map[string]interface{}) (int64, []*ListInterval, error)
}
func (listInterval *ListInterval) Identify() interface{} {
if listInterval.ListIntervalId == 0 {
return nil
}
return listInterval.ListIntervalId
}
func (listInterval *ListInterval) Update(data map[string]interface{}) error {
if listIntervalStartTime, ok := data["listIntervalStartTime"]; ok {
listInterval.IntervalStartTime = listIntervalStartTime.(time.Time)
}
if listIntervalEndTime, ok := data["listIntervalEndTime"]; ok {
listInterval.IntervalEndTime = listIntervalEndTime.(time.Time)
}
return nil
}
\ No newline at end of file
... ...
... ... @@ -8,5 +8,5 @@ import (
type AcceptanceTaskService interface {
coreDomain.DomainEventPublisher
Acceptance(taskId int64, operatorUid int64, participators []int64, taskPercentage []*domain.TaskPercentageItem, referenceResourceScore []*domain.ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) (*domain.Task, error)
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)
}
... ...
... ... @@ -3,32 +3,28 @@ package domain
import "time"
const (
SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE = iota + 1 //兑换
SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE = iota + 1 //兑换物资
SU_MONEY_TRANSACTION_RECORD_TYPE_AWARD //任务奖励
SU_MONEY_TRANSACTION_RECORD_TYPE_INCREASE //增加
SU_MONEY_TRANSACTION_RECORD_TYPE_DEDUCT //扣除
SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE_CASH //兑换现金
SU_MONEY_TRANSACTION_RECORD_TYPE_EXCHANGE_CASH_RESTORE // 兑换现金撤销
)
// 素币事务记录
type SuMoneyTransactionRecord struct {
// 素币事务记录ID
SuMoneyTransactionRecordId int64 `json:"suMoneyTransactionRecordId"`
// 记录类型
RecordType int `json:"recordType"`
// 记录关联员工
Employee *EmployeeInfo `json:"employee"`
// 事务处理前素币值
SuMoneyBeforeTransaction float64 `json:"suMoneyBeforeTransaction"`
// 当前素币值
CurrentSuMoney float64 `json:"currentSuMoney"`
// 事务素币值
SuMoney float64 `json:"suMoney"`
// 操作人
Operator *EmployeeInfo `json:"operator"`
// 素币事务记录描述
RecordDescription string `json:"recordDescription"`
// 创建时间
CreateTime time.Time `json:"createTime"`
SuMoneyTransactionRecordId int64 `json:"suMoneyTransactionRecordId"` // 素币事务记录ID
RecordType int `json:"recordType"` // 记录类型
Employee *EmployeeInfo `json:"employee"` // 记录关联员工
SuMoneyBeforeTransaction float64 `json:"suMoneyBeforeTransaction"` // 事务处理前素币值
CurrentSuMoney float64 `json:"currentSuMoney"` // 当前素币值
SuMoney float64 `json:"suMoney"` // 事务素币值
CashBeforeTransaction float64 `json:"cashBeforeTransaction"` // 事务处理前现金值
CurrentCash float64 `json:"currentCash"` // 当前现金值
Cash float64 `json:"cash"` // 事务现金值
Operator *EmployeeInfo `json:"operator"` // 操作人
RecordDescription string `json:"recordDescription"` // 素币事务记录描述
CreateTime time.Time `json:"createTime"` // 创建时间
}
type SuMoneyTransactionRecordRepository interface {
... ... @@ -36,6 +32,7 @@ type SuMoneyTransactionRecordRepository interface {
Remove(suMoneyTransactionRecord *SuMoneyTransactionRecord) (*SuMoneyTransactionRecord, error)
FindOne(queryOptions map[string]interface{}) (*SuMoneyTransactionRecord, error)
Find(queryOptions map[string]interface{}) (int64, []*SuMoneyTransactionRecord, error)
FindById(queryOptions map[string]interface{}) (int64, []*SuMoneyTransactionRecord, error)
}
func (suMoneyTransactionRecord *SuMoneyTransactionRecord) Identify() interface{} {
... ...
... ... @@ -24,6 +24,7 @@ const (
TASK_STATUS_COMPLETED //已完成
TASK_STATUS_CLOSED //关闭
TASK_STATUS_UNCONFIRMED //待确认
TASK_STATUS_EXPIRED //已过期
)
// 任务
... ... @@ -50,6 +51,10 @@ type Task struct {
TaskNature int `json:"taskNature"`
// 奖励素币
SuMoney float64 `json:"suMoney"`
// 最小奖励素币
MinSuMoney float64 `json:"minSuMoney"`
// 最大奖励素币
MaxSuMoney float64 `json:"maxSuMoney"`
// 验收标准
AcceptanceStandard string `json:"acceptanceStandard"`
// 任务描述
... ... @@ -98,11 +103,12 @@ type TaskStatus interface {
ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error
ApplyComplete(task *Task) error
Off(task *Task) error
Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error
Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error
ConfirmTask(task *Task, plannedCompletionTime time.Time) error
RejectReceiver(task *Task) error
}
// 待发布的任务
type UnReleasedStatus struct{}
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{})
if suMoney, ok := data["suMoney"]; ok {
task.SuMoney = suMoney.(float64)
}
if minSuMoney, ok := data["minSuMoney"]; ok {
task.MinSuMoney = minSuMoney.(float64)
}
if maxSuMoney, ok := data["maxSuMoney"]; ok {
task.MaxSuMoney = maxSuMoney.(float64)
}
if task.TaskType == TASK_TYPE_BID {
if bidStartTime, ok := data["bidStartTime"]; ok {
task.BidInfo.BidStartTime = bidStartTime.(time.Time)
... ... @@ -198,7 +210,7 @@ func (status *UnReleasedStatus) Off(task *Task) error {
return fmt.Errorf("待发布的任务不允许关闭")
}
func (status *UnReleasedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
func (status *UnReleasedStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("待发布的任务不允许验收")
}
... ... @@ -213,7 +225,68 @@ func (status *UnReleasedStatus) RejectReceiver(task *Task) error {
type UnClaimedStatus struct{}
func (status *UnClaimedStatus) Update(task *Task, data map[string]interface{}) error {
return fmt.Errorf("待领取的任务不允许编辑")
if taskName, ok := data["taskName"]; ok {
task.TaskName = taskName.(string)
}
if referenceResourceType, ok := data["referenceResourceType"]; ok {
task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int)
}
if referenceResourceItems, ok := data["referenceResourceItems"]; ok {
task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem)
}
if projectBelong, ok := data["projectBelong"]; ok {
task.ProjectBelong = projectBelong.(int)
}
if customerValues, ok := data["customerValues"]; ok {
task.CustomerValues = customerValues.([]int)
}
if taskNature, ok := data["taskNature"]; ok {
task.TaskNature = taskNature.(int)
}
if suMoney, ok := data["suMoney"]; ok {
task.SuMoney = suMoney.(float64)
}
if minSuMoney, ok := data["minSuMoney"]; ok {
task.MinSuMoney = minSuMoney.(float64)
}
if maxSuMoney, ok := data["maxSuMoney"]; ok {
task.MaxSuMoney = maxSuMoney.(float64)
}
if task.TaskType == TASK_TYPE_BID {
if bidStartTime, ok := data["bidStartTime"]; ok {
task.BidInfo.BidStartTime = bidStartTime.(time.Time)
}
if bidEndTime, ok := data["bidEndTime"]; ok {
task.BidInfo.BidEndTime = bidEndTime.(time.Time)
}
if isRemind, ok := data["isRemind"]; ok {
task.BidInfo.IsRemind = isRemind.(bool)
}
}
if acceptanceStandard, ok := data["acceptanceStandard"]; ok {
task.AcceptanceStandard = acceptanceStandard.(string)
}
if taskDescription, ok := data["taskDescription"]; ok {
task.TaskDescription = taskDescription.(string)
}
if taskPictureUrls, ok := data["taskPictureUrls"]; ok {
task.TaskPictureUrls = taskPictureUrls.([]string)
}
if isRewardTake, ok := data["isRewardTake"]; ok {
task.IsRewardTake = isRewardTake.(bool)
}
if task.TaskType == TASK_TYPE_DESIGNATE {
if plannedCompletionTime, ok := data["plannedCompletionTime"]; ok {
task.PlannedCompletionTime = plannedCompletionTime.(time.Time)
}
if assignedPerson, ok := data["assignedPerson"]; ok {
task.AssignedPerson = assignedPerson.(*EmployeeInfo)
if task.AssignedPerson.Uid == 0 {
task.AssignedPerson = nil
}
}
}
return nil
}
func (status *UnClaimedStatus) Release(task *Task) error {
... ... @@ -286,7 +359,7 @@ func (status *UnClaimedStatus) Off(task *Task) error {
return nil
}
func (status *UnClaimedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
func (status *UnClaimedStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("待领取的任务不允许验收")
}
... ... @@ -333,7 +406,7 @@ func (status *UnderwayStatus) Off(task *Task) error {
return nil
}
func (status *UnderwayStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
func (status *UnderwayStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("进行中的任务不允许验收")
}
... ... @@ -359,6 +432,7 @@ func (status *UnderwayStatus) RejectReceiver(task *Task) error {
return nil
}
// 代验收的任务
type UnAcceptanceStatus struct{}
func (status *UnAcceptanceStatus) Update(task *Task, data map[string]interface{}) error {
... ... @@ -391,8 +465,9 @@ func (status *UnAcceptanceStatus) Off(task *Task) error {
return nil
}
func (status *UnAcceptanceStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
func (status *UnAcceptanceStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
task.Participators = participators
task.SuMoney = suMoney
task.TaskPercentage = taskPercentage
task.SolveReport = solveReport
task.SolvePictureUrls = solvePictureUrls
... ... @@ -451,7 +526,7 @@ func (status *CompletedStatus) Off(task *Task) error {
return fmt.Errorf("已完成的任务不允许申请完成任务")
}
func (status *CompletedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
func (status *CompletedStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("已完成的任务不允许验收")
}
... ... @@ -493,7 +568,7 @@ func (status *ClosedStatus) Off(task *Task) error {
return fmt.Errorf("已关闭的任务不允许关闭")
}
func (status *ClosedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
func (status *ClosedStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("已关闭的任务不允许验收")
}
... ... @@ -505,6 +580,7 @@ func (status *ClosedStatus) RejectReceiver(task *Task) error {
return fmt.Errorf("已关闭的任务不允许驳回任务领取人")
}
// 待确认任务
type UnConfirmedStatus struct{}
func (status *UnConfirmedStatus) Update(task *Task, data map[string]interface{}) error {
... ... @@ -537,7 +613,7 @@ func (status *UnConfirmedStatus) Off(task *Task) error {
return nil
}
func (status *UnConfirmedStatus) Acceptance(task *Task, participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
func (status *UnConfirmedStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("待确认的任务不允许验收")
}
... ... @@ -560,6 +636,113 @@ func (status *UnConfirmedStatus) RejectReceiver(task *Task) error {
return nil
}
type ExpiredStatus struct{}
func (status ExpiredStatus) Update(task *Task, data map[string]interface{}) error {
if taskName, ok := data["taskName"]; ok {
task.TaskName = taskName.(string)
}
if referenceResourceType, ok := data["referenceResourceType"]; ok {
task.ReferenceResource.ReferenceResourceType = referenceResourceType.(int)
}
if referenceResourceItems, ok := data["referenceResourceItems"]; ok {
task.ReferenceResource.ReferenceResourceItems = referenceResourceItems.([]*ReferenceResourceItem)
}
if projectBelong, ok := data["projectBelong"]; ok {
task.ProjectBelong = projectBelong.(int)
}
if customerValues, ok := data["customerValues"]; ok {
task.CustomerValues = customerValues.([]int)
}
if taskNature, ok := data["taskNature"]; ok {
task.TaskNature = taskNature.(int)
}
if suMoney, ok := data["suMoney"]; ok {
task.SuMoney = suMoney.(float64)
}
if minSuMoney, ok := data["minSuMoney"]; ok {
task.MinSuMoney = minSuMoney.(float64)
}
if maxSuMoney, ok := data["maxSuMoney"]; ok {
task.MaxSuMoney = maxSuMoney.(float64)
}
if task.TaskType == TASK_TYPE_BID {
if bidStartTime, ok := data["bidStartTime"]; ok {
task.BidInfo.BidStartTime = bidStartTime.(time.Time)
}
if bidEndTime, ok := data["bidEndTime"]; ok {
task.BidInfo.BidEndTime = bidEndTime.(time.Time)
}
if isRemind, ok := data["isRemind"]; ok {
task.BidInfo.IsRemind = isRemind.(bool)
}
}
if acceptanceStandard, ok := data["acceptanceStandard"]; ok {
task.AcceptanceStandard = acceptanceStandard.(string)
}
if taskDescription, ok := data["taskDescription"]; ok {
task.TaskDescription = taskDescription.(string)
}
if taskPictureUrls, ok := data["taskPictureUrls"]; ok {
task.TaskPictureUrls = taskPictureUrls.([]string)
}
if isRewardTake, ok := data["isRewardTake"]; ok {
task.IsRewardTake = isRewardTake.(bool)
}
if task.TaskType == TASK_TYPE_DESIGNATE {
if plannedCompletionTime, ok := data["plannedCompletionTime"]; ok {
task.PlannedCompletionTime = plannedCompletionTime.(time.Time)
}
if assignedPerson, ok := data["assignedPerson"]; ok {
task.AssignedPerson = assignedPerson.(*EmployeeInfo)
if task.AssignedPerson.Uid == 0 {
task.AssignedPerson = nil
}
}
}
return nil
}
func (status ExpiredStatus) Release(task *Task) error {
currentTime := time.Now()
task.ReleaseTime = currentTime
task.TaskStatus = TASK_STATUS_UNCLAIMED
task.CurrentStatus = &UnClaimedStatus{}
return nil
}
func (status ExpiredStatus) Rob(task *Task, receiver *EmployeeInfo) error {
return fmt.Errorf("已过期的任务不允许抢单")
}
func (status ExpiredStatus) Bib(task *Task, bidder *EmployeeInfo) error {
return fmt.Errorf("已过期的任务不允许竞标")
}
func (status ExpiredStatus) ChooseSuccessfulBidder(task *Task, successfulBidder *EmployeeInfo, plannedCompletionTime time.Time) error {
return fmt.Errorf("已过期的任务不允许选择竞标任务的中标人")
}
func (status ExpiredStatus) ApplyComplete(task *Task) error {
return fmt.Errorf("已过期的任务不允许申请完成任务")
}
func (status ExpiredStatus) Off(task *Task) error {
return fmt.Errorf("已过期的任务不允许关闭")
}
func (status ExpiredStatus) Acceptance(task *Task, participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return fmt.Errorf("已过期的任务不允许验收")
}
func (status ExpiredStatus) ConfirmTask(task *Task, plannedCompletionTime time.Time) error {
return fmt.Errorf("已过期的任务不允许确认任务领取人")
}
func (status ExpiredStatus) RejectReceiver(task *Task) error {
return fmt.Errorf("已过期的任务不允许驳回任务领取人")
}
type TaskRepository interface {
Save(task *Task) (*Task, error)
Remove(task *Task) (*Task, error)
... ... @@ -602,8 +785,8 @@ func (task *Task) Off() error {
return task.CurrentStatus.Off(task)
}
func (task *Task) Acceptance(participators []*EmployeeInfo, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return task.CurrentStatus.Acceptance(task, participators, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls, actualCompletionTime)
func (task *Task) Acceptance(participators []*EmployeeInfo, suMoney float64, taskPercentage []*TaskPercentageItem, referenceResourceScore []*ReferenceResourceItem, solveReport string, solvePictureUrls []string, actualCompletionTime time.Time) error {
return task.CurrentStatus.Acceptance(task, participators, suMoney, taskPercentage, referenceResourceScore, solveReport, solvePictureUrls, actualCompletionTime)
}
func (task *Task) ConfirmTask(plannedCompletionTime time.Time) error {
... ...
package dao
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/linmadan/mmm-worth/pkg/infrastructure/pg/models"
)
type CashPoolDao struct {
transactionContext *pgTransaction.TransactionContext
}
// 兑换活动兑换清单已兑换素币、已兑换现金
func (dao *CashPoolDao) CalculateActivityExchangedSuMoney(activityId int64) (map[string]interface{}, error) {
var activityExchangedSuMoney float64
var activityExchangedCash float64
tx := dao.transactionContext.PgTx
exchangeCashPersonListModels := new(models.ExchangeCashPersonList)
if err := tx.Model(exchangeCashPersonListModels).
ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS activity_exchanged_su_money").
Where("exchange_cash_person_list.activity_id = ?", activityId).
Select(&activityExchangedSuMoney); err !=nil {
return nil, err
}
if err := tx.Model(exchangeCashPersonListModels).
ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS activity_exchanged_cash").
Where("exchange_cash_person_list.activity_id = ?", activityId).
Select(&activityExchangedCash); err !=nil {
return nil, err
}
return map[string]interface{}{
"activityExchangedSuMoney": activityExchangedSuMoney,
"activityExchangedCash": activityExchangedCash,
}, nil
}
// 返回兑换活动清单榜单
func (dao *CashPoolDao) ExchangeCashListRanking(queryOptions map[string]interface{}) (map[string]interface{}, error) {
var retPeople []struct {
Uid int64
EmployeeName string
SuMoney float64
Cash float64
Ranking int
}
var retEmployee []struct {
Uid int64
EmployeeName string
SuMoney float64
Cash float64
Ranking int
}
tx := dao.transactionContext.PgTx
exchangeCashPersonListModels := new(models.ExchangeCashPersonList)
// 清单人员排名
queryPeople := tx.Model(exchangeCashPersonListModels)
queryPeople = queryPeople.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid")
queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.uid AS uid")
//queryPeople = queryPeople.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name")
queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash")
queryPeople = queryPeople.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money")
queryPeople = queryPeople.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC, e.create_time ASC) AS ranking")
//queryPeople = queryPeople.Where("e.status = ?", 1)
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryPeople = queryPeople.Where("e.company_id = ?", companyId)
}
if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){
queryPeople = queryPeople.Where("exchange_cash_person_list.activity_id = ?", activityId)
}
queryPeople = queryPeople.Group("exchange_cash_person_list.uid")
queryPeople = queryPeople.Group("e.create_time")
//queryPeople = queryPeople.Group("exchange_cash_person_list.employee_name")
if offset, ok := queryOptions["offset"]; ok {
offset := offset.(int)
if offset > -1 {
queryPeople = queryPeople.Offset(offset)
}
} else {
queryPeople = queryPeople.Offset(0)
}
if limit, ok := queryOptions["limit"]; ok {
limit := limit.(int)
if limit > -1 {
queryPeople = queryPeople.Limit(limit)
}
} else {
queryPeople = queryPeople.Limit(20)
}
if err := queryPeople.Order("ranking ASC").Select(&retPeople); err != nil {
return nil, err
}
// 个人清单排名
queryPeopleAll := tx.Model(exchangeCashPersonListModels)
queryPeopleAll = queryPeopleAll.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid")
queryPeopleAll = queryPeopleAll.ColumnExpr("exchange_cash_person_list.uid AS uid")
//queryPeopleAll = queryPeopleAll.ColumnExpr("exchange_cash_person_list.employee_name AS employee_name")
queryPeopleAll = queryPeopleAll.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS cash")
queryPeopleAll = queryPeopleAll.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS su_money")
queryPeopleAll = queryPeopleAll.ColumnExpr("ROW_NUMBER() OVER (ORDER BY sum(exchange_cash_person_list.exchanged_su_money) DESC, e.create_time ASC) AS ranking")
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryPeopleAll = queryPeopleAll.Where("e.company_id = ?", companyId)
}
if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0){
queryPeopleAll = queryPeopleAll.Where("exchange_cash_person_list.activity_id = ?", activityId)
}
queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.uid")
queryPeopleAll = queryPeopleAll.Group("e.create_time")
//queryPeopleAll = queryPeopleAll.Group("exchange_cash_person_list.employee_name")
queryPeopleAllWith := queryPeopleAll.Order("su_money DESC")
queryEmployee := tx.Model()
queryEmployee = queryEmployee.With("t", queryPeopleAllWith)
queryEmployee = queryEmployee.Table("t")
queryEmployee = queryEmployee.ColumnExpr("t.uid AS uid")
//queryEmployee = queryEmployee.ColumnExpr("t.employee_name AS employee_name")
queryEmployee = queryEmployee.ColumnExpr("t.cash AS cash")
queryEmployee = queryEmployee.ColumnExpr("t.su_money AS su_money")
queryEmployee = queryEmployee.ColumnExpr("t.ranking AS ranking")
if uid, ok := queryOptions["uid"]; ok {
queryEmployee = queryEmployee.Where("t.uid::bigint = ?", uid)
}
if err := queryEmployee.Select(&retEmployee); err != nil {
return nil, err
}
var currentEmployee interface{}
if len(retEmployee) == 0 {
currentEmployee = nil
} else {
currentEmployee = retEmployee[0]
}
// 清单已兑换素币
var activityExchangedSuMoney float64
queryListSuMoney := tx.Model(exchangeCashPersonListModels)
queryListSuMoney = queryListSuMoney.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid")
queryListSuMoney = queryListSuMoney.ColumnExpr("sum(exchange_cash_person_list.exchanged_su_money) AS activity_exchanged_su_money")
//queryListSuMoney = queryListSuMoney.Where("e.status = ?", 1)
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryListSuMoney = queryListSuMoney.Where("e.company_id = ?", companyId)
}
if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0) {
queryListSuMoney = queryListSuMoney.Where("exchange_cash_person_list.activity_id = ?", activityId)
}
if err := queryListSuMoney.Select(&activityExchangedSuMoney); err != nil {
return nil, err
}
// 清单已兑换现金
var activityExchangedCash float64
queryListCash := tx.Model(exchangeCashPersonListModels)
queryListCash = queryListCash.Join("JOIN employees AS e ON e.uid = exchange_cash_person_list.uid")
queryListCash = queryListCash.ColumnExpr("sum(exchange_cash_person_list.exchanged_cash) AS activity_exchanged_cash")
//queryListCash = queryListCash.Where("e.status = ?", 1)
if companyId, ok := queryOptions["companyId"]; ok && (companyId.(int64) != 0) {
queryListCash = queryListCash.Where("e.company_id = ?", companyId)
}
if activityId, ok := queryOptions["activityId"]; ok && (activityId.(int64) != 0) {
queryListCash = queryListCash.Where("exchange_cash_person_list.activity_id = ?", activityId)
}
if err := queryListCash.Select(&activityExchangedCash); err != nil {
return nil, err
}
// 清单计数
queryCount := tx.Model(exchangeCashPersonListModels)
count, err := queryCount.Count()
if err != nil {
return nil, err
}
return map[string]interface{} {
"people": retPeople, // 员工排行榜
"count": count, // 计数
"currentEmployee": currentEmployee, // 当前员工排名
"exchangedSuMoney": activityExchangedSuMoney, // 清单已兑换素币
"exchangedCash": activityExchangedCash, // 清单已兑换现金
}, nil
}
func NewCashPoolDao(transactionContext *pgTransaction.TransactionContext) (*CashPoolDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &CashPoolDao{
transactionContext: transactionContext,
}, nil
}
}
\ No newline at end of file
... ...