作者 tangxuhui

Merge branch 'dev' into test

# Conflicts:
#	deploy/k8s/test/allied-creation-cooperation.yaml
正在显示 71 个修改的文件 包含 2011 行增加438 行删除

要显示太多修改。

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

不能预览此文件类型
... ... @@ -4,7 +4,7 @@ ENV APP_DIR $GOPATH/src/allied-creation-cooperation
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR/
COPY ./pkg pkg
# COPY ./conf conf
COPY ./config config
COPY ./go.mod go.mod
COPY ./go.sum go.sum
COPY ./main.go main.go
... ...
-----BEGIN RSA PRIVATE KEY-----
MIIEpQIBAAKCAQEAy0OxRf+NheQG9epxbrudwnrzqVgqK5zCuRAkLUgaSMATVXEA
iDzJN39om+Q49MmtEk4pXGzKUyzkFJG96PA8tJq0E+bSDtSK3n+2mjZb6pChmgHw
KEX7T8ZVLqJBSrfrI4Z2BJDNEC+3wvVW3zpog1RlfKgft6NYUzNLUqE5Mxzq7lpD
eRsq+FhzM1sOeEb2dAmUlDDs+7HcR3Kj0ttKeg+hKqIottQ/H6Tq4c8deEQGnO0+
RN3CygyETbYmLuWttI/sUltulWJALIuU81Yr6uCOq5MSt2WsU8CTuhRwGXSvcQCO
FLYppYktoMDOGIBQffmJc/DdT1d35fvdpKbm+QIDAQABAoIBAQC8X7+qX2uI6gqJ
XPxC4x0RX2DxUAPE50KOv6bHUEsLoPZJ+K/Fko/oHuuTja47Lax3inhKb4gSDUhS
x754YivgNH8u8ns5wz/vc+yGflowyFj7oVAwAqslA2luDnD0Df6crcAx+wAQQCjN
RRF9T2QMUeq73BOI3Ji+gosLyN55vms2KadrwpPQwYN7qhdrerE7vPqCZeswzs1/
A5M9PVGBG+simNea5kv+tVJUdLi6ckGAB5KabyhpG779ckwzV/aZy3wIj4SvUvCd
bewH0xPHx5TqnMOXtzHgktClmL7hIYxy9sL14Dn0KVHbyolQ7IqmJtjXYqG84Fmx
AfyDfeABAoGBAPP820tKElrfTuZ+Z19kJBTp6I5iax2Ph10glUHLlLqJ82clI/Gl
CbMtnGmD72HfnJei82xqoVLsUkN9Sp+TSNJALh4N8rHkAtwq5kWToiAWZydwxVsp
x5OWEN3+QFIdjVW6fhg6jZSK5HHIqMdZOVvbfKP+Cv9fWWzlS7/WVTlJAoGBANVF
kol+KojM4DEASrw0s1mfPr0XvUFvKJ2TgVGR3HxAk4r0e0WwJdSfwGiB/ePcc6g5
D5dxBe8W5g3+V0DaC0f1DDNXg2MjYWoByWrurbm14FRnpMnx/UfZLo7rq8T9YrUT
Bd/y0/JasndN27bIfd60n233IYMqhV2+wBwqD3AxAoGAE2/wdHYJMk4Z9gjZ6WKL
8VKVIUq759X4XbXrzhsO1TGKP4xY6bZRKIIYtNs65dwvmHD13Yw9H+MNxqyjlkTg
h0dvpRtNW1ij1bBhOefCAbZnL2AviMyyRpKs81J/A0uxZ8P8qad4gf3ypxHqSD9W
b3fz3QivDZsl/6Pgvf6wOWkCgYEA1Cv9x5lj2WrxEu62axyG3P9nHBm055cdsf5g
JfVVg6t+3TuyM7c1O52efpnsKrdTvKTf1QrVG3INdxh0V4lUtcac16sVhBhbvml+
p0pCPMIrJe1ibKG5F7SB9B+TaEuo2nnNW2mp367JY5VqoyI8zsWk4nJ8vZAc1BGD
78EMUNECgYEAtV0pta3GuHKOLX1HMRsUsYuWjLqAbahnciF6MnjNWSonEK3VjMhI
g+krP/9sWoC3cFOG+4s96ubjDTWImvQvCrPaENdvlNwgp035bn51eFRv00QchM2H
VCS9Nhoqj5BIHl1G7Q13+tYTzjUWtteG902nWDVhgSlNLJf1rbTn34g=
-----END RSA PRIVATE KEY-----
... ...
-----BEGIN CERTIFICATE-----
MIIGazCCBVOgAwIBAgIQZBwijHoFToh2kjGwQ1E6bjANBgkqhkiG9w0BAQsFADBc
MQswCQYDVQQGEwJDTjEaMBgGA1UEChMRV29UcnVzIENBIExpbWl0ZWQxMTAvBgNV
BAMMKFdvVHJ1cyBPViBTZXJ2ZXIgQ0EgIFtSdW4gYnkgdGhlIElzc3Vlcl0wHhcN
MjEwMjA0MDAwMDAwWhcNMjIwMzA2MjM1OTU5WjCB0TELMAkGA1UEBhMCQ04xDzAN
BgNVBBETBjM1MDAxNTESMBAGA1UEBwwJ56aP5bee5biCMU8wTQYDVQQJDEbpqazl
sL7ljLrmuZbph4zot68yN+WPtzEj5qW85LqU5qW8NTEw44CBNTEx5a6k77yI6Ieq
6LS46K+V6aqM5Yy65YaF77yJMTAwLgYDVQQKDCfnpo/lu7rkubDkubDkubDkv6Hm
ga/np5HmioDmnInpmZDlhazlj7gxGjAYBgNVBAMMESouZmptYWltYWltYWkuY29t
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy0OxRf+NheQG9epxbrud
wnrzqVgqK5zCuRAkLUgaSMATVXEAiDzJN39om+Q49MmtEk4pXGzKUyzkFJG96PA8
tJq0E+bSDtSK3n+2mjZb6pChmgHwKEX7T8ZVLqJBSrfrI4Z2BJDNEC+3wvVW3zpo
g1RlfKgft6NYUzNLUqE5Mxzq7lpDeRsq+FhzM1sOeEb2dAmUlDDs+7HcR3Kj0ttK
eg+hKqIottQ/H6Tq4c8deEQGnO0+RN3CygyETbYmLuWttI/sUltulWJALIuU81Yr
6uCOq5MSt2WsU8CTuhRwGXSvcQCOFLYppYktoMDOGIBQffmJc/DdT1d35fvdpKbm
+QIDAQABo4ICsTCCAq0wHwYDVR0jBBgwFoAUDUmPFTN7wE+2+zo4Cfw0Fdpg3RQw
HQYDVR0OBBYEFMGZEgzwtp+UhpTAS9nmSxlo9tIlMA4GA1UdDwEB/wQEAwIFoDAM
BgNVHRMBAf8EAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBJBgNV
HSAEQjBAMDQGCysGAQQBsjEBAgIWMCUwIwYIKwYBBQUHAgEWF2h0dHBzOi8vc2Vj
dGlnby5jb20vQ1BTMAgGBmeBDAECAjA9BgNVHR8ENjA0MDKgMKAuhixodHRwOi8v
Y3JsLmNybG9jc3AuY24vV29UcnVzT1ZTZXJ2ZXJDQV8yLmNybDBsBggrBgEFBQcB
AQRgMF4wOAYIKwYBBQUHMAKGLGh0dHA6Ly9haWEuY3Jsb2NzcC5jbi9Xb1RydXNP
VlNlcnZlckNBXzIuY3J0MCIGCCsGAQUFBzABhhZodHRwOi8vb2NzcC5jcmxvY3Nw
LmNuMIIBBQYKKwYBBAHWeQIEAgSB9gSB8wDxAHcARqVV63X6kSAwtaKJafTzfREs
QXS+/Um4havy/HD+bUcAAAF3brV9qAAABAMASDBGAiEAjrXS+1JJW9jag/XfW+kY
oL4sGGDNvcZgV35E0EcGQVACIQCjQh8k5oSFtqo7Qrbx2k3OISjfPSYRXNNsG4Ba
MyDmRwB2AN+lXqtogk8fbK3uuF9OPlrqzaISpGpejjsSwCBEXCpzAAABd261fdAA
AAQDAEcwRQIgcPQQJ3rkCFaQPKwT3rtfQkr0taPzw0KW7yqu+MtmBH0CIQChKeMk
v7Xs0z7J47lM6HTPOU+xXL2riC69LC1KCOS6GTAtBgNVHREEJjAkghEqLmZqbWFp
bWFpbWFpLmNvbYIPZmptYWltYWltYWkuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQBn
+jDy7sZS0gZzwMR4hnZHWqFYcJR3wnk77xr+5Yu2ifhlxaLHE3rEY3xTR9LsPwfW
pdg2McinPCI6vs009NYIpeTiHzVDPzKu2BaUfKj+EHLwZQGfXkNhp3cpqZMiTkr/
YNqf25GXsBa+spwzyHh9MBXXCfWRfdHX7JlH5zyoLNztTp8unxaRYldjghHDA3Q7
8Fyz6OncY3I4U4KKBSq2/TTxveDW6NxTTuJTPOg3/qSIkwdOBLuIzuhxmF4D9wpl
LMHmne2CilVeg73/GAzQt/w7FzmdvaHPAOVYWzdaTNALiXJxbi7EyO8q/uNK0GqY
hljMsnA1hApG+/2sOP/P
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIF4TCCA8mgAwIBAgIQHQgpVDhMv3SvabmRFpvwLTANBgkqhkiG9w0BAQwFADCB
iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl
cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV
BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMjAw
MTA4MDAwMDAwWhcNMzAwMTA3MjM1OTU5WjBcMQswCQYDVQQGEwJDTjEaMBgGA1UE
ChMRV29UcnVzIENBIExpbWl0ZWQxMTAvBgNVBAMMKFdvVHJ1cyBPViBTZXJ2ZXIg
Q0EgIFtSdW4gYnkgdGhlIElzc3Vlcl0wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
ggEKAoIBAQCARFLq6kqQRZ4SdFMPdd3XJTcOdVVT5bvZZx0VVDrkw3TmSAloQVFf
RhqDOSXg4CsIaa64qFSrC3a5sc8LgRhx7AUdvoUdfvdxIY1uoyxRWpoWO8oTUkSn
EXjEPf+zrcU5cWTOi32xWL9vklYds7iOQwgsKAHDzt4an8MLGvcLxAHciyiKcDEh
HZOGUHO5bKaCq+kP2rJCfVSlNvdyl1B8q+aGWXoi0gXGVL7WX4pcWj+DGuITbLB2
MzMytse4MjLJ84zaXh0UD4STlyD8tu/fakdxIwQ7K3/pP3RoGj1R9CvMWXUU+fZm
KNLW5565hd9Bh3Wkz8b4ApgMD9o3RUjTAgMBAAGjggFwMIIBbDAfBgNVHSMEGDAW
gBRTeb9aqitKz1SA4dibwJ3ysgNmyzAdBgNVHQ4EFgQUDUmPFTN7wE+2+zo4Cfw0
Fdpg3RQwDgYDVR0PAQH/BAQDAgGGMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0l
BBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMCIGA1UdIAQbMBkwDQYLKwYBBAGyMQEC
AhYwCAYGZ4EMAQICMFAGA1UdHwRJMEcwRaBDoEGGP2h0dHA6Ly9jcmwudXNlcnRy
dXN0LmNvbS9VU0VSVHJ1c3RSU0FDZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDBx
BggrBgEFBQcBAQRlMGMwOgYIKwYBBQUHMAKGLmh0dHA6Ly9jcnQudXNlcnRydXN0
LmNvbS9VU0VSVHJ1c3RSU0FBQUFDQS5jcnQwJQYIKwYBBQUHMAGGGWh0dHA6Ly9v
Y3NwLnVzZXJ0cnVzdC5jb20wDQYJKoZIhvcNAQEMBQADggIBAA5G7XA+fNKyj7Fy
uotoII38/32eZ4UrC1vGFPEtDyd0yzOrr7SvQUoO2GLxFzIQ0SsgMNXJ4UAhMkTD
yz1OA0tx0g0GjOQXBGA/yfRR7SgitRJAdbqkPfppMn+dtKXCHHx35ohTL0PklRdb
mXacvR7rXUIiJMdsvZZqYwc+DpGJ+Zv0sRJZEL7pm1oZv6EV+UzjAlOnLe6yrnyD
c99Kk1H/RFPUzduUWjiVR2aMDT1oMiwYeB2Zq60Sb201jqZPNQj5E+TkDD5BPFVc
kLeRi3LyXBUuBvXPsdLtBNlr+LExtCDd66kjeUe2/YbTHF4ai5PZPraQxgbOJJyc
gizGl/JOgrIQPUOLSQvXlxpKEqS+0z6KqV52bco2PNrC0f8ILKuw0nsfhgcGy46d
Su8fmU9+FT6e61i2nteKvt8qkkSkAJKQxRUWYduN24mG/OOIkoeOPdYHi+qEfbyI
qxiiqcH9cZgLK9AVuJoKtt7vg21OyrWi7S5T/WbTfTz9XL7QGe8ZODZZx6d50uo/
lDOmXm3p/kdGApvUF1UrL+og22jBLi0Ns6xzCfzrI3SpC9abvU8E9EnxQABuu/gM
/B63dbaZzSsMVFxeECD9nMWv7IH+/rqyGmjqEJzgKdPGvXhqpebQ1HhWrV+j+ipc
jplXB1j3GCozDFsninXG102N6wC8
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIFgTCCBGmgAwIBAgIQOXJEOvkit1HX02wQ3TE1lTANBgkqhkiG9w0BAQwFADB7
MQswCQYDVQQGEwJHQjEbMBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYD
VQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UE
AwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTE5MDMxMjAwMDAwMFoXDTI4
MTIzMTIzNTk1OVowgYgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpOZXcgSmVyc2V5
MRQwEgYDVQQHEwtKZXJzZXkgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBO
ZXR3b3JrMS4wLAYDVQQDEyVVU0VSVHJ1c3QgUlNBIENlcnRpZmljYXRpb24gQXV0
aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAgBJlFzYOw9sI
s9CsVw127c0n00ytUINh4qogTQktZAnczomfzD2p7PbPwdzx07HWezcoEStH2jnG
vDoZtF+mvX2do2NCtnbyqTsrkfjib9DsFiCQCT7i6HTJGLSR1GJk23+jBvGIGGqQ
Ijy8/hPwhxR79uQfjtTkUcYRZ0YIUcuGFFQ/vDP+fmyc/xadGL1RjjWmp2bIcmfb
IWax1Jt4A8BQOujM8Ny8nkz+rwWWNR9XWrf/zvk9tyy29lTdyOcSOk2uTIq3XJq0
tyA9yn8iNK5+O2hmAUTnAU5GU5szYPeUvlM3kHND8zLDU+/bqv50TmnHa4xgk97E
xwzf4TKuzJM7UXiVZ4vuPVb+DNBpDxsP8yUmazNt925H+nND5X4OpWaxKXwyhGNV
icQNwZNUMBkTrNN9N6frXTpsNVzbQdcS2qlJC9/YgIoJk2KOtWbPJYjNhLixP6Q5
D9kCnusSTJV882sFqV4Wg8y4Z+LoE53MW4LTTLPtW//e5XOsIzstAL81VXQJSdhJ
WBp/kjbmUZIO8yZ9HE0XvMnsQybQv0FfQKlERPSZ51eHnlAfV1SoPv10Yy+xUGUJ
5lhCLkMaTLTwJUdZ+gQek9QmRkpQgbLevni3/GcV4clXhB4PY9bpYrrWX1Uu6lzG
KAgEJTm4Diup8kyXHAc/DVL17e8vgg8CAwEAAaOB8jCB7zAfBgNVHSMEGDAWgBSg
EQojPpbxB+zirynvgqV/0DCktDAdBgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rID
ZsswDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0gBAowCDAG
BgRVHSAAMEMGA1UdHwQ8MDowOKA2oDSGMmh0dHA6Ly9jcmwuY29tb2RvY2EuY29t
L0FBQUNlcnRpZmljYXRlU2VydmljZXMuY3JsMDQGCCsGAQUFBwEBBCgwJjAkBggr
BgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29tMA0GCSqGSIb3DQEBDAUA
A4IBAQAYh1HcdCE9nIrgJ7cz0C7M7PDmy14R3iJvm3WOnnL+5Nb+qh+cli3vA0p+
rvSNb3I8QzvAP+u431yqqcau8vzY7qN7Q/aGNnwU4M309z/+3ri0ivCRlv79Q2R+
/czSAaF9ffgZGclCKxO/WIu6pKJmBHaIkU4MiRTOok3JMrO66BQavHHxW/BBC5gA
CiIDEOUMsfnNkjcZ7Tvx5Dq2+UUTJnWvu6rvP3t3O9LEApE9GQDTF1w52z97GA1F
zZOFli9d31kWTz9RvdVFGD/tSo7oBmF0Ixa1DVBzJ0RHfxBdiSprhTEUxOipakyA
vGp4z7h/jnZymQyd/teRCBaho1+V
-----END CERTIFICATE-----
... ...
... ... @@ -54,10 +54,16 @@ spec:
env:
- name: LOG_LEVEL
value: "debug"
- name: LOG_FRAMEWORK
value: "beego"
- name: LOG_TYPE
value: "file"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
value: "1000"
- name: ENABLE_KAFKA_LOG
value: "false"
- name: USER_MODULE_HOST
value: "http://allied-creation-user-dev.fjmaimaimai.com"
- name: REDIS_HOST
... ...
... ... @@ -61,8 +61,7 @@ spec:
- name: LOG_FRAMEWORK
value: "beego"
- name: LOG_TYPE
value: "file"
- name: ERROR_BASE_CODE
value: "file" - name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
value: "1000"
... ...
... ... @@ -13,15 +13,15 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
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-20210527091316-06b0732fb5f6
github.com/mattn/go-colorable v0.1.8 // indirect
github.com/moul/http2curl v1.0.0 // indirect
github.com/olivere/elastic/v7 v7.0.28
github.com/onsi/ginkgo v1.14.2
github.com/onsi/gomega v1.10.3
github.com/sergi/go-diff v1.2.0 // indirect
github.com/shopspring/decimal v1.2.0
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/sirupsen/logrus v1.8.1
github.com/smartystreets/goconvey v1.6.4 // indirect
github.com/valyala/fasthttp v1.28.0 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
... ... @@ -29,4 +29,5 @@ 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
gopkg.in/sohlich/elogrus.v7 v7.0.0
)
... ...
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/sarama v1.25.0 h1:ch1ywjRLjfJtU+EaiJ+l0rWffQ6TRpyYmW4DX7Cb2SU=
github.com/Shopify/sarama v1.25.0/go.mod h1:y/CFFTO9eaMTNriwu/Q+W4eioLqiDMGkA1W+gmdfj8w=
github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc=
... ... @@ -15,6 +17,9 @@ github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGn
github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
github.com/andybalholm/brotli v1.0.2 h1:JKnhI/XQ75uFBTiuzXpzFrUriDPiZjlOSzh6wXogP0E=
github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
github.com/aws/aws-sdk-go v1.19.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
github.com/aws/aws-sdk-go v1.40.32/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q=
github.com/beego/beego/v2 v2.0.1 h1:07a7Z0Ok5vbqyqh+q53sDPl9LdhKh0ZDy3gbyGrhFnE=
github.com/beego/beego/v2 v2.0.1/go.mod h1:8zyHi1FnWO1mZLwTn62aKRIZF/aIKvkCBB2JYs+eqQI=
github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ=
... ... @@ -30,6 +35,7 @@ github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
github.com/coreos/etcd v3.3.25+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
... ... @@ -49,10 +55,13 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1
github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
github.com/elastic/go-elasticsearch/v6 v6.8.5 h1:U2HtkBseC1FNBmDr0TR2tKltL6FxoY+niDAlj5M8TK8=
github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 h1:DddqAaWDpywytcG8w/qoQ5sAN8X12d3Z3koB0C3Rxsc=
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
... ... @@ -82,9 +91,12 @@ github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gG
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
... ... @@ -109,21 +121,27 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M=
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
... ... @@ -133,13 +151,16 @@ github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03 h1:FUwcHNlEqkqLjL
github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM=
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
... ... @@ -158,6 +179,10 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
github.com/linmadan/egglib-go v0.0.0-20210527091316-06b0732fb5f6 h1:nyhVnOIXsESuhZ95Ak6VRSF+0fHeKlYWq0EvHByt5RU=
github.com/linmadan/egglib-go v0.0.0-20210527091316-06b0732fb5f6/go.mod h1:ZZuSWicGxpgN0OulARhuKwFJuJ9we0otaPVAJtz10yk=
github.com/magefile/mage v1.10.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
... ... @@ -179,21 +204,29 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/olivere/elastic/v7 v7.0.4/go.mod h1:l4YWa59iTCcOJQXI5ZtxVjcd3p5U8GCxVgvzHZqGn3o=
github.com/olivere/elastic/v7 v7.0.28 h1:KAP4EuaEcvPJknRNkAAso1xeu0C1+/CeDQsxj9Cw9Fg=
github.com/olivere/elastic/v7 v7.0.28/go.mod h1:DzHQoqd6YqSuvF1lk/fR4cW4FNUNzSD5/F5MBm3GRMo=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M=
github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA=
github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pierrec/lz4 v2.2.6+incompatible h1:6aCX4/YZ9v8q69hTyiR7dNLnTA3fgtKHVVW5BCd5Znw=
github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
... ... @@ -203,18 +236,22 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
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/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U=
github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU=
... ... @@ -235,10 +272,13 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
github.com/sirupsen/logrus v1.8.0/go.mod h1:4GuYW9TZmE769R5STWrRakJc4UqQ3+QQ95fyz7ENv1A=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v1.1.1 h1:T/YLemO5Yp7KPzS+lVtu+WsHn8yoSwTfItdAd1r3cck=
github.com/smartystreets/assertions v1.1.1/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/smartystreets/gunit v1.4.2/go.mod h1:ZjM1ozSIMJlAz/ay4SG8PeKF00ckUp+zMHZXV9/bvak=
github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
... ... @@ -287,6 +327,8 @@ github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZ
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
go.etcd.io/etcd v3.3.25+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
go.opentelemetry.io/otel v0.17.0 h1:6MKOu8WY4hmfpQ4oQn34u6rYhnf2sWf1LXYO/UFm71U=
go.opentelemetry.io/otel v0.17.0/go.mod h1:Oqtdxmf7UtEvL037ohlgnaYa1h7GtMh0NcSd9eqkC9s=
go.opentelemetry.io/otel/metric v0.17.0 h1:t+5EioN8YFXQ2EH+1j6FHCKMUj+57zIDSnSGr/mWuug=
... ... @@ -312,6 +354,7 @@ golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
... ... @@ -323,6 +366,8 @@ golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73r
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
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=
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
... ... @@ -334,12 +379,15 @@ golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210510120150-4163338589ed h1:p9UgmWI9wKpfYmgaV/IZKGdXc5qEK45tDwwwDyjS26I=
golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
... ... @@ -347,6 +395,7 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
... ... @@ -375,11 +424,13 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
... ... @@ -395,15 +446,20 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
... ... @@ -433,6 +489,8 @@ gopkg.in/jcmturner/gokrb5.v7 v7.2.3/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuv
gopkg.in/jcmturner/rpc.v1 v1.1.0 h1:QHIUxTX1ISuAv9dD2wJ9HWQVuWDX/Zc0PfeC2tjc4rU=
gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8=
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
gopkg.in/sohlich/elogrus.v7 v7.0.0 h1:w4pw1DTXK/bqliKbcJk7hSXKrMM/jPdvpaROC9WSK+8=
gopkg.in/sohlich/elogrus.v7 v7.0.0/go.mod h1:nGmb0kLyAPGwIHLpHNlMlz0l0OfSaFatKgfpuO/+fnY=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
... ... @@ -444,6 +502,7 @@ gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
gopkg.in/yaml.v2 v2.3.0/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=
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
... ...
package main
import (
"fmt"
"github.com/beego/beego/v2/server/web"
"github.com/linmadan/egglib-go/log/logrus"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
_ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego"
)
func main() {
// web主服务
if constant.ENABLE_KAFKA_LOG {
w, err := logrus.NewKafkaWriter(constant.KAFKA_HOSTS, constant.TOPIC_LOG_STASH, false)
if err != nil {
log.Logger.Error(err.Error())
}
log.Logger.AddHook(w)
}
fmt.Printf("Server running at:%d\n", web.BConfig.Listen.HTTPPort)
web.Run()
}
... ...
不能预览此文件类型
... ... @@ -10,15 +10,15 @@ import (
type ApplyForCooperationCommand struct {
// 共创申请描述附件
CooperationApplicationAttachment []*domain.Attachment `cname:"共创申请描述附件" json:"cooperationApplicationAttachment" valid:"Required"`
CooperationApplicationAttachment []*domain.Attachment `cname:"共创申请描述附件" json:"cooperationApplicationAttachment"`
// 共创申请描述
CooperationApplicationDescription string `cname:"共创申请描述" json:"cooperationApplicationDescription,omitempty"`
// 申请人ID
UserId int64 `cname:"申请人ID" json:"userId" valid:"Required"`
UserId int64 `cname:"申请人ID" json:"userId"`
// 用户基本id
UserBaseId int64 `cname:"用户基本数据ID" json:"userBaseId" valid:"Required"`
UserBaseId int64 `cname:"用户基本数据ID" json:"userBaseId"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId" valid:"Required"`
OrgId int64 `cname:"组织机构ID" json:"orgId"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId"`
// 共创项目ID
... ... @@ -26,7 +26,6 @@ type ApplyForCooperationCommand struct {
}
func (applyForCooperationCommand *ApplyForCooperationCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (applyForCooperationCommand *ApplyForCooperationCommand) ValidateCommand() error {
... ...
... ... @@ -98,7 +98,11 @@ func (data *CooperationApplicationDto) LoadDto(a *domain.CooperationApplication)
data.CooperationApplyTime = a.CooperationApplyTime.Unix() * 1000
data.CooperationProject = data.LoadCooperationProject(a.CooperationProject)
data.Org = data.LoadOrg(a.Org)
data.IsCanceled = a.IsCanceled
if a.IsCanceled == 1 {
data.IsCanceled = false
} else {
data.IsCanceled = true
}
data.Company = data.LoadCompany(a.Company)
}
... ...
... ... @@ -17,6 +17,8 @@ type SearchCooperationApplicationQuery struct {
ApplicantName string `cname:"申请人姓名" json:"applicantName,omitempty"`
// 共创申请审核状态,1待审核,2已同意,3已拒绝
CooperationApplicationStatus int32 `cname:"共创申请审核状态" json:"cooperationApplicationStatus,omitempty"`
// 是否被取消标记 1正常,2取消,3所有
IsCanceled int32 `cname:"取消状态" json:"isCanceled,omitempty"`
// 页面大小
PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
// 页面大小
... ...
... ... @@ -10,6 +10,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"strconv"
"time"
... ... @@ -45,6 +46,50 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
cooperationProjectRepository = value
}
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyService = value
}
// 组织机构REST服务初始化
var organizationService service.OrgService
if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organizationService = value
}
// 共创申请仓储初始化
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationApplicationRepository = value
}
// 共创申请DAO初始化
var cooperationApplicationDao *dao.CooperationApplicationDao
if value, err := factory.CreateCooperationApplicationDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
cooperationApplicationDao = value
}
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": applyForCooperationCommand.CooperationProjectId})
if err != nil {
... ... @@ -54,14 +99,53 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(applyForCooperationCommand.CooperationProjectId, 10)))
}
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
var newCooperationApplication *domain.CooperationApplication
if applyForCooperationCommand.CompanyId == 0 && applyForCooperationCommand.OrgId == 0 && applyForCooperationCommand.UserId == 0 && applyForCooperationCommand.UserBaseId != 0 { // 游客操作
// 获取申请人信息
var applicant *domain.User
if data, err := userService.VisitorFrom(applyForCooperationCommand.CompanyId, applyForCooperationCommand.OrgId, applyForCooperationCommand.UserBaseId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取申请人失败")
} else {
userService = value
applicant = data
}
// 校验:同一个用户,不能多次申请同一个项目
applicationExist, _ := cooperationApplicationDao.CheckApplicationExist(map[string]interface{}{
"visitorUserBaseId": applicant.UserBaseId,
"companyId": cooperationProject.Company.CompanyId,
"orgId": cooperationProject.Org.OrgId,
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
})
if applicationExist {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "抱歉,您已经申请过该项目")
}
// 校验:判断用户类型是否属于承接对象
if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 4) { // 非公开类型校验
if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
}
}
newCooperationApplication = &domain.CooperationApplication{
CooperationApplicationApplicant: applicant,
CooperationApplicationAttachment: applyForCooperationCommand.CooperationApplicationAttachment,
CooperationApplicationDescription: applyForCooperationCommand.CooperationApplicationDescription,
CooperationApplicationStatus: 1,
CooperationApplicationVerifier: nil,
CooperationApplicationVerifyDescription: "",
CooperationApplicationVerifyTime: time.Time{},
CooperationApplyTime: time.Now(),
CooperationProject: cooperationProject,
Org: cooperationProject.Org,
IsCanceled: 1,
Company: cooperationProject.Company,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
}
} else {
// 获取申请人
var applicant *domain.User
if data, err := userService.UserFrom(applyForCooperationCommand.CompanyId, applyForCooperationCommand.OrgId, applyForCooperationCommand.UserId); err != nil {
... ... @@ -70,14 +154,6 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
applicant = data
}
// 公司REST服务初始化
var companyService service.CompanyService
if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
companyService = value
}
// 获取公司信息
var company *domain.Company
if data, err := companyService.CompanyFrom(applyForCooperationCommand.CompanyId); err != nil {
... ... @@ -86,14 +162,6 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
company = data
}
// 组织机构REST服务初始化
var organizationService service.OrgService
if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
organizationService = value
}
// 获取组织机构信息
var organization *domain.Org
if data, err := organizationService.OrgFrom(applyForCooperationCommand.CompanyId, applyForCooperationCommand.OrgId); err != nil {
... ... @@ -102,7 +170,23 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
organization = data
}
newCooperationApplication := &domain.CooperationApplication{
// 校验:同一个用户,不能多次申请同一个项目
applicationExist, _ := cooperationApplicationDao.CheckApplicationExist(map[string]interface{}{
"companyId": applyForCooperationCommand.CompanyId,
"orgId": applyForCooperationCommand.OrgId,
"applicantId": applicant.UserId,
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
})
if applicationExist {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "抱歉,您已经申请过该项目")
}
// 校验:判断用户类型是否属于承接对象
if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
}
newCooperationApplication = &domain.CooperationApplication{
CooperationApplicationApplicant: applicant,
CooperationApplicationAttachment: applyForCooperationCommand.CooperationApplicationAttachment,
CooperationApplicationDescription: applyForCooperationCommand.CooperationApplicationDescription,
... ... @@ -113,24 +197,23 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
CooperationApplyTime: time.Now(),
CooperationProject: cooperationProject,
Org: organization,
IsCanceled: false,
IsCanceled: 1,
Company: company,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
}
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationApplicationRepository = value
}
// 保存共创申请
if cooperationApplication, err := cooperationApplicationRepository.Save(newCooperationApplication); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
// 更新共创项目申请人计数
cooperationProject.ApplicantCount = cooperationProject.ApplicantCount + 1
if _, err := cooperationProjectRepository.Save(cooperationProject); 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())
}
... ... @@ -195,6 +278,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApprovalCoop
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10)))
}
// 校验共创申请是否已经审核过
if cooperationApplication.CooperationApplicationStatus != 1 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "改申请已经审核过")
}
if approvalCooperationApplicationCommand.Action == 1 {
cooperationApplication.CooperationApplicationStatus = 2
} else if approvalCooperationApplicationCommand.Action == 2 {
... ... @@ -272,7 +360,12 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 0 {
for i, _ := range cooperationApplications {
for i, cooperationApplication := range cooperationApplications {
// 校验共创申请是否已经审核过
if cooperationApplication.CooperationApplicationStatus != 1 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "改申请已经审核过")
}
// 更新共创申请数据
cooperationApplications[i].CooperationApplicationVerifyDescription = batchApprovalCooperationApplicationCommand.CooperationApplicationVerifyDescription
if batchApprovalCooperationApplicationCommand.Action == 1 { // 同意
cooperationApplications[i].CooperationApplicationStatus = 2
... ... @@ -281,6 +374,7 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova
}
cooperationApplications[i].CooperationApplicationVerifier = verifier
cooperationApplications[i].CooperationApplicationVerifyTime = time.Now()
cooperationApplications[i].IsCanceled = 1
}
cooperationApplicationsApproved, err := cooperationApplicationRepository.UpdateMany(cooperationApplications)
if err != nil {
... ... @@ -346,7 +440,12 @@ func (cooperationApplicationService *CooperationApplicationService) OneClickAppr
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 0 {
for i, _ := range cooperationApplications {
for i, cooperationApplication := range cooperationApplications {
// 校验共创申请是否已经审核过
if cooperationApplication.CooperationApplicationStatus != 1 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "改申请已经审核过")
}
// 更新共创申请
if oneClickApprovalCooperationApplicationCommand.Action == 1 {
cooperationApplications[i].CooperationApplicationStatus = 2
} else if oneClickApprovalCooperationApplicationCommand.Action == 2 {
... ... @@ -463,7 +562,7 @@ func (cooperationApplicationService *CooperationApplicationService) CreateCooper
CooperationApplyTime: time.Now(),
CooperationProject: cooperationProject,
Org: organization,
IsCanceled: false,
IsCanceled: 1,
Company: company,
CreatedAt: time.Now(),
DeletedAt: time.Time{},
... ... @@ -551,6 +650,7 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat
} else {
cooperationApplicationRepository = value
}
// 获取共创申请
if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(listCooperationApplicationQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -709,8 +809,19 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper
defer func() {
_ = transactionContext.RollbackTransaction()
}()
//TODO 校验用户菜单模块权限
// 共创项目仓储初始化
var cooperationProjectRepository domain.CooperationProjectRepository
if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationProjectRepository = value
}
// 共创申请仓储初始化
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
... ... @@ -732,17 +843,30 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10)))
}
if err := cooperationApplication.Update(map[string]interface{}{
"isCanceled": true,
"isCanceled": int32(2),
}); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if cooperationApplication, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
if cooperationApplicationSaved, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": cooperationApplicationSaved.CooperationProject.CooperationProjectId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目不存在")
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s不存在", strconv.FormatInt(cooperationApplicationSaved.CooperationProject.CooperationProjectId, 10)))
}
// 更新共创项目申请统计
cooperationProject.ApplicantCount = cooperationProject.ApplicantCount - 1
if _, err := cooperationProjectRepository.Save(cooperationProject); 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 cooperationApplication, nil
return cooperationApplicationSaved, nil
}
}
... ...
... ... @@ -18,6 +18,10 @@ type CooperationContractByUndertakerDto struct {
CooperationContractNumber string `json:"cooperationContractNumber"`
// 项目合约名称
CooperationContractName string `json:"cooperationContractName"`
// 项目合约状态
CooperationContractStatus int32 `json:"cooperationContractStatus"`
// 共创描述
CooperationContractDescription string `json:"cooperationContractDescription"`
// 合同附件
Attachment []*domain.Attachment `json:"attachment"`
// 发起人姓名
... ... @@ -37,6 +41,8 @@ func (dto *CooperationContractByUndertakerDto) LoadDto(contractByUndertaker *mod
dto.UndertakerPhone = contractByUndertaker.UndertakerPhone
dto.CooperationContractNumber = contractByUndertaker.CooperationContractNumber
dto.CooperationContractName = contractByUndertaker.CooperationContractName
dto.CooperationContractStatus = contractByUndertaker.ContractStatus
dto.CooperationContractDescription = contractByUndertaker.CooperationContractDescription
dto.Attachment = contractByUndertaker.ContractAttachment
dto.SponsorName = contractByUndertaker.CooperationContractSponsor.UserName
if contractByUndertaker.Department != nil {
... ...
... ... @@ -17,6 +17,8 @@ type SearchCooperationContractQuery struct {
CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber,omitempty"`
// 发起人姓名
SponsorName string `cname:"发起人姓名" json:"sponsorName,omitempty"`
// 激励类型
IncentivesType int32 `cname:"激励类型" json:"incentivesType,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId"`
// 组织机构ID
... ... @@ -30,7 +32,6 @@ type SearchCooperationContractQuery struct {
}
func (searchCooperationContractQuery *SearchCooperationContractQuery) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (searchCooperationContractQuery *SearchCooperationContractQuery) ValidateQuery() error {
... ...
... ... @@ -2,6 +2,9 @@ package service
import (
"fmt"
"strconv"
"time"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command"
... ... @@ -13,8 +16,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
"strconv"
"time"
)
// CooperationContractService 共创合约服务
... ... @@ -125,7 +126,9 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
}
// 生成共创合约编号
contractNumber, err2 := cooperationContractDao.GenerateContractNumber()
contractNumber, err2 := cooperationContractDao.GenerateContractNumber(map[string]interface{}{
"companyId": createCooperationContractCommand.CompanyId,
})
if err2 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error())
}
... ... @@ -133,16 +136,16 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
// 校验共创合约编号是否唯一
numberAvailable, _ := cooperationContractDao.CheckContractNumberAvailable(map[string]interface{}{
"companyId": createCooperationContractCommand.CompanyId,
"orgId": createCooperationContractCommand.OrgId,
"cooperationContractNumber": contractNumber,
})
if !numberAvailable {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创合约异常")
}
// 获取承接人
// 承接人
var undertakers []*domain.Undertaker
for _, undertaker := range createCooperationContractCommand.Undertakers {
// 获取承接人
var undertakerDomain *domain.Undertaker
undertakerUid, err := strconv.ParseInt(undertaker.UserId, 10, 64)
if err != nil {
... ... @@ -155,6 +158,13 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
undertakerDomain = data
}
// 校验承接人是否属于承接对象,1员工,2共创用户,4公开
if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, 4) {
if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, undertakerDomain.UserType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象")
}
}
// 获取推荐人
var referrerDomain *domain.Referrer
referrerUid, _ := strconv.ParseInt(undertaker.ReferrerId, 10, 64)
... ... @@ -195,11 +205,13 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
UserId: undertakerDomain.UserId,
CooperationContractNumber: contractNumber,
UserBaseId: undertakerDomain.UserBaseId,
Org: undertakerDomain.Org,
Org: organization,
Orgs: undertakerDomain.Orgs,
Department: undertakerDomain.Department,
Roles: undertakerDomain.Roles,
UserInfo: undertakerDomain.UserInfo,
UserName: undertakerDomain.UserName,
UserPhone: undertakerDomain.UserPhone,
UserType: undertakerDomain.UserType,
Referrer: referrerDomain,
Salesman: salesmanDomain,
... ... @@ -225,14 +237,14 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
CooperationContractNumber: contractNumber,
UserId: relevantDomain.UserId,
UserBaseId: relevantDomain.UserBaseId,
Org: relevantDomain.Org,
Org: organization,
Orgs: relevantDomain.Orgs,
Department: relevantDomain.Department,
Roles: relevantDomain.Roles,
UserInfo: relevantDomain.UserInfo,
UserType: relevantDomain.UserType,
Status: relevantDomain.Status,
Company: relevantDomain.Company,
Company: company,
})
}
... ... @@ -267,7 +279,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
MoneyIncentivesStage: moneyIncentivesRule.MoneyIncentivesStage,
MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd,
MoneyIncentivesStageStart: moneyIncentivesRule.MoneyIncentivesStageStart,
MoneyIncentivesTime: time.Now(),
MoneyIncentivesTime: moneyIncentivesRule.MoneyIncentivesTime,
ReferrerPercentage: moneyIncentivesRule.ReferrerPercentage,
SalesmanPercentage: moneyIncentivesRule.SalesmanPercentage,
Org: organization,
... ... @@ -444,6 +456,7 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon
defer func() {
_ = transactionContext.RollbackTransaction()
}()
// 合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -452,6 +465,7 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon
} else {
cooperationContractRepository = value
}
// 查找合约
if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listCooperationContractQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
... ... @@ -824,7 +838,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC
if count, cooperationContractByUndertakers, err := cooperationContractDao.SearchCooperationContractByUndertaker(tool_funs.SimpleStructToMap(searchCooperationContractByUndertakerQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
var cooperationContractByUndertakerDtos []*dto.CooperationContractByUndertakerDto
cooperationContractByUndertakerDtos := make([]*dto.CooperationContractByUndertakerDto, 0)
for _, cooperationContractByUndertaker := range cooperationContractByUndertakers {
cooperationContractByUndertakerDto := &dto.CooperationContractByUndertakerDto{}
if err := cooperationContractByUndertakerDto.LoadDto(cooperationContractByUndertaker); err != nil {
... ... @@ -1005,6 +1019,13 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
undertakerDomain = data
}
// 校验:判断用户类型是否属于承接对象
if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, 4) { // 非公开类型校验
if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, undertakerDomain.UserType) {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
}
}
// 获取推荐人
var referrerDomain *domain.Referrer
if undertaker.ReferrerId != "" {
... ... @@ -1043,6 +1064,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err16.Error())
}
var contractAttachments []*domain.Attachment
for _, attachment := range undertaker.ContractAttachment {
contractAttachments = append(contractAttachments, &domain.Attachment{
FileType: attachment.FileType,
Name: attachment.Name,
Url: attachment.Url,
FileSize: attachment.FileSize,
})
}
undertakers = append(undertakers, &domain.Undertaker{
UndertakerId: undertakerId,
UserId: undertakerDomain.UserId,
... ... @@ -1058,7 +1089,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
Salesman: salesmanDomain,
Status: undertakerDomain.Status,
Company: undertakerDomain.Company,
ContractAttachment: nil,
ContractAttachment: contractAttachments,
})
}
// 更新承接人
... ... @@ -1106,7 +1137,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
MoneyIncentivesStage: moneyIncentivesRule.MoneyIncentivesStage,
MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd,
MoneyIncentivesStageStart: moneyIncentivesRule.MoneyIncentivesStageStart,
MoneyIncentivesTime: time.Now(),
MoneyIncentivesTime: moneyIncentivesRule.MoneyIncentivesTime,
ReferrerPercentage: moneyIncentivesRule.ReferrerPercentage,
SalesmanPercentage: moneyIncentivesRule.SalesmanPercentage,
Org: organization,
... ... @@ -1301,7 +1332,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
UserPhone: "",
}
}
undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
}
undertakerChangeTmp1 := "【" + undertakersOriginal + "】"
... ... @@ -1338,7 +1369,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
UserPhone: "",
}
}
undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
}
undertakerChangeTemp2 := "【" + undertakersChanged + "】"
// 拼接承接人变更记录
... ...
... ... @@ -29,6 +29,8 @@ type SearchCooperationModeQuery struct {
UserId int64 `cname:"用户ID" json:"userId"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
// 共创模式状态,1启用,2禁用
Status int32 `json:"status"`
}
func (searchCooperationModeQuery *SearchCooperationModeQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -17,6 +17,8 @@ type SearchCooperationProjectQuery struct {
CooperationProjectName string `cname:"共创项目名称" json:"cooperationProjectName,omitempty"`
// 共创项目编号
CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber,omitempty"`
// 共创项目承接对象,1员工,2共创用户,4公开,可以多选
CooperationProjectUndertakerType int32 `json:"cooperationProjectUndertakerType"`
// 部门名称
DepartmentName string `cname:"部门名称" json:"departmentName,omitempty"`
// 关键字搜索
... ...
... ... @@ -163,9 +163,11 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
cooperationProjectDao = value
}
// 生成共创项目编号
projectNumber, err2 := cooperationProjectDao.GenerateProjectNumber()
projectNumber, err2 := cooperationProjectDao.GenerateProjectNumber(map[string]interface{}{
"companyId": createCooperationProjectCommand.CompanyId,
})
if err2 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error())
}
// 校验共创项目编号是否唯一
numberAvailable, _ := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{
... ... @@ -457,29 +459,123 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
cooperationProjectRepository = value
}
// 共创申请仓储初始化
var cooperationApplicationRepository domain.CooperationApplicationRepository
if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationApplicationRepository = value
}
// 用户REST服务初始化
var userService service.UserService
if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
userService = value
}
// 获取操作人
var operator *domain.User
if data, err := userService.OperatorFrom(updateCooperationProjectCommand.CompanyId, updateCooperationProjectCommand.OrgId, updateCooperationProjectCommand.UserId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取操作人失败")
} else {
operator = data
}
// 获取发起人
var sponsor *domain.User
// sponsorUid类型转换
sponsorUid, err := strconv.ParseInt(updateCooperationProjectCommand.SponsorUid, 10, 64)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if data, err := userService.UserFrom(updateCooperationProjectCommand.CompanyId, updateCooperationProjectCommand.OrgId, sponsorUid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取发起人失败")
} else {
sponsor = data
}
// 共创项目ID类型转换
cooperationProjectId, err := strconv.ParseInt(updateCooperationProjectCommand.CooperationProjectId, 10, 64)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目编号类型错误")
}
// 查找共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": cooperationProjectId})
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
"cooperationProjectId": cooperationProjectId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationProject == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationProjectCommand.CooperationProjectId)))
}
applicantTypes := make(map[int32]interface{})
// 获取所有申请人
if count, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{
"cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
"offsetLimit": false,
"companyId": updateCooperationProjectCommand.CompanyId,
"cooperationApplicationStatus": int32(2), // 共创申请审核状态,1待审核,2已同意,3已拒绝
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 0 {
for _, cooperationApplication := range cooperationApplications {
applicantTypes[cooperationApplication.CooperationApplicationApplicant.UserType] = cooperationApplication.CooperationApplicationApplicant.UserType
}
}
}
var undertakerTypes []int32
var k1, k2 int32
if len(applicantTypes) > 0 {
for k, _ := range applicantTypes {
if k == 1 {
k1 = k
} else if k == 2 {
k2 = k
}
undertakerTypes = append(undertakerTypes, k)
}
}
if k1 != 0 && k2 != 0 {
undertakerTypes = append(undertakerTypes, 4)
}
// 校验可以修改的承接人(申请人)类型
for _, t := range undertakerTypes {
if !utils.IsContain(updateCooperationProjectCommand.CooperationProjectUndertakerTypes, t) {
switch t {
case 1:
return nil, application.ThrowError(application.BUSINESS_ERROR, "承接对象'员工'存在业务数据,不可取消勾选")
case 2:
return nil, application.ThrowError(application.BUSINESS_ERROR, "承接对象'共创用户'存在业务数据,不可取消勾选")
case 4:
return nil, application.ThrowError(application.BUSINESS_ERROR, "承接对象'公开'存在业务数据,不可取消勾选")
}
}
}
// 更新共创项目
cooperationProject.Operator = operator
cooperationProject.CooperationProjectSponsor = sponsor
if err := cooperationProject.Update(tool_funs.SimpleStructToMap(updateCooperationProjectCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if cooperationProject, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
if cooperationProjectSaved, err := cooperationProjectRepository.Save(cooperationProject); 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 cooperationProject, nil
return cooperationProjectSaved, nil
}
}
... ...
... ... @@ -63,6 +63,8 @@ func (svr *CooperationStatisticsService) CooperationContractStatistics(contractS
res, err = statisticsService.PersonCompanyPaymentHistoryStatistics(contractStatisticsQuery.QueryOptions)
case domain_service.CreditAccountStatistics:
res, err = statisticsService.CreditAccountStatistics(contractStatisticsQuery.QueryOptions)
case domain_service.RelevantCooperationContractNumbers:
res, err = statisticsService.RelevantCooperationContractNumbers(contractStatisticsQuery.QueryOptions)
}
if err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
... ...
... ... @@ -16,9 +16,9 @@ type PayCreditAccountCommand struct {
// 账期结算实付金额
ActuallyPaidAmount float64 `cname:"账期结算实付金额" json:"actuallyPaidAmount" valid:"Required"`
// 备注
Remarks string `cname:"备注" json:"remarks" valid:"Required"`
Remarks string `cname:"备注" json:"remarks"`
// 支付凭证附件
PaymentDocumentAttachments []*domain.Attachment `cname:"支付凭证附件" json:"paymentDocumentAttachment" valid:"Required"`
PaymentDocumentAttachments []*domain.Attachment `cname:"支付凭证附件" json:"paymentDocumentAttachment"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
// 组织机构ID
... ... @@ -30,7 +30,6 @@ type PayCreditAccountCommand struct {
}
func (payCreditAccountCommand *PayCreditAccountCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (payCreditAccountCommand *PayCreditAccountCommand) ValidateCommand() error {
... ...
... ... @@ -32,6 +32,12 @@ type SearchCreditAccountQuery struct {
UserId int64 `cname:"用户ID" json:"userId"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
// 账期创建-开始时间
BeginTime time.Time `json:"beginTime"`
// 账期创建-结束时间
EndTime time.Time `json:"endTime"`
// 合约编号列表
CooperationContractNumbers []string `json:"cooperationContractNumbers"`
}
func (searchCreditAccountQuery *SearchCreditAccountQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -145,7 +145,6 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
}
// 预算明细
var creditAccounts []*domain.CreditAccount
var accountDetail []*domain.AccountDetail
var settlementAmount float64
for _, dividendsEstimate := range dividendsEstimates {
... ... @@ -158,7 +157,9 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
}
// 生成账期结算单号
creditAccountNumber, err12 := creditAccountDao.GenerateCreditAccountNumber()
creditAccountNumber, err12 := creditAccountDao.GenerateCreditAccountNumber(map[string]interface{}{
"companyId": createCreditAccountCommand.CompanyId,
})
if err12 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "生成账期结算单号错误")
}
... ... @@ -179,7 +180,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
Department: dividendsEstimates[0].DividendsUser.Department,
Roles: dividendsEstimates[0].DividendsUser.Roles,
UserInfo: dividendsEstimates[0].DividendsUser.UserInfo,
UserName: dividendsEstimates[0].DividendsUser.UserName,
UserName: dividendsEstimates[0].DividendsUser.UserInfo.UserName,
UserPhone: dividendsEstimates[0].DividendsUser.UserPhone,
UserType: dividendsEstimates[0].DividendsUser.UserType,
Status: dividendsEstimates[0].DividendsUser.Status,
... ... @@ -199,13 +200,19 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
if creditAccount, err13 := creditAccountRepository.Save(newCreditAccount); err13 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err13.Error())
} else {
creditAccounts = append(creditAccounts, creditAccount)
// 变更分红预算单结算状态
for i, _ := range dividendsEstimates {
dividendsEstimates[i].DividendsAccountStatus = 2
}
_, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimates)
if err3 != nil {
return nil, err3
}
if err14 := transactionContext.CommitTransaction(); err14 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err14.Error())
}
return creditAccounts, nil
return creditAccount, nil
}
}
}
... ... @@ -353,6 +360,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
if creditAccountSaved, err4 := creditAccountRepository.Save(creditAccount); err4 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
} else {
// TODO 更新分红预算单结算状态(已支付)
if err3 := transactionContext.CommitTransaction(); err3 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
}
... ...
... ... @@ -28,10 +28,11 @@ type MoneyIncentivesEstimateDto struct {
// 创建合约时间
CreatedAt time.Time `json:"createdAt"`
// 阶段和承接人
StageAndUndertaker *StageAndUndertaker `json:"stageAndUndertaker"`
StageAndUndertaker []*StageAndUndertaker `json:"stageAndUndertaker"`
}
func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract) error {
// TODO 阶段承接人数据聚合
dto.CooperationContractId = contract.CooperationContractId
dto.CooperationContractNumber = contract.CooperationContractNumber
dto.CooperationContractName = contract.CooperationContractName
... ... @@ -39,9 +40,9 @@ func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContr
dto.Department = contract.Department
dto.CooperationContractSponsorName = contract.CooperationContractSponsor.UserName
dto.CreatedAt = contract.CreatedAt
dto.StageAndUndertaker = &StageAndUndertaker{
dto.StageAndUndertaker = append(dto.StageAndUndertaker, &StageAndUndertaker{
Stage: 0,
Undertakers: []*domain.Undertaker{},
}
Undertakers: nil,
})
return nil
}
... ...
... ... @@ -27,7 +27,6 @@ type ListDividendsIncentivesEstimateQuery struct {
}
func (listDividendsIncentivesEstimateQuery *ListDividendsIncentivesEstimateQuery) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
}
func (listDividendsIncentivesEstimateQuery *ListDividendsIncentivesEstimateQuery) ValidateQuery() error {
... ...
... ... @@ -75,24 +75,32 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
for _, orderGood := range orderGoods {
dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber})
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{
"dividendsOrderNumber": orderGood.DividendsOrderNumber,
"companyId": orderGood.CompanyId,
"orgId": orderGood.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红订单%s不存在", orderGood.DividendsOrderNumber))
}
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsOrder.DividendsOrderNumber, dividendsOrder.DividendsOriginalOrderNum, dividendsOrder.CustomerName, dividendsOrder.Region.RegionName, dividendsOrder.OrderTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
} else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber})
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
"companyId": orderGood.CompanyId,
"orgId": orderGood.OrgId,
"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsReturnedOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红退货单%s不存在", orderGood.DividendsReturnedOrderNumber))
}
if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsReturnedOrder.DividendsReturnedOrderNumber, dividendsReturnedOrder.OriginalOrderNum, dividendsReturnedOrder.DividendsReturnedCustomerName, dividendsReturnedOrder.Region.RegionName, dividendsReturnedOrder.OrderTime); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
... ... @@ -223,6 +231,11 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cancelDividendsEstimateCommand.DividendsEstimateId, 10)))
}
// 校验重复取消
if dividendsEstimate.IsCanceled {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已取消的分红单不能重复取消")
}
// 校验是否能够取消
if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红、退货冲销
if count, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum}); err2 != nil {
... ... @@ -328,6 +341,11 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
if count > 0 {
// 校验分红预算是否可以取消,已有相关分红预算单已结算,无法取消
for _, dividendsEstimate := range dividendsEstimates {
// 校验重复取消
if dividendsEstimate.IsCanceled {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已取消的分红单不能重复取消")
}
// 校验是否能够取消
if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红、退货冲销
if count, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum}); err2 != nil {
... ... @@ -542,25 +560,25 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
operator = data
}
// 分红订单仓储初始化
var dividendsOrderRepository domain.DividendsOrderRepository
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsOrderRepository = value
}
//// 分红订单仓储初始化
//var dividendsOrderRepository domain.DividendsOrderRepository
//if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
// "transactionContext": transactionContext,
//}); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//} else {
// dividendsOrderRepository = value
//}
// 分红退货单仓储初始化
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
dividendsReturnedOrderRepository = value
}
//var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
//if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
// "transactionContext": transactionContext,
//}); err != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
//} else {
// dividendsReturnedOrderRepository = value
//}
// 订单产品仓储初始化
var orderGoodRepository domain.OrderGoodRepository
... ... @@ -605,33 +623,59 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
})
}
// 统计成功预算的分红订单
estimateSuccessfullyDividendsOrders := make(map[string]string)
// 统计预算失败的分红订单
estimateFailedDividendsOrders := make(map[string]string)
// 获取订单产品
if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{
"orderGoodIds": orderGoodIds,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
var dividendsEstimates []*domain.DividendsEstimate
dividendsEstimates := make([]*domain.DividendsEstimate, 0)
// 统计当前分红预算单数
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
"companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
var countDividendsEstimate int64
for _, orderGood := range orderGoods {
dividendsEstimate := &domain.DividendsEstimate{}
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
dividendsOrder, err3 := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber})
if err3 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
}
//dividendsOrder, err3 := dividendsOrderRepository.FindOne(map[string]interface{}{
// "dividendsOrderNumber": orderGood.DividendsOrderNumber,
// "companyId": orderGood.CompanyId,
// "orgId": orderGood.OrgId,
//})
//if err3 != nil {
// return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
//}
//if dividendsOrder == nil {
// return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红订单%s不存在", orderGood.DividendsOrderNumber))
//}
// 分红订单产品预算
if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoods); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, dividendsEstimateDetail := range dividendsEstimateDetails {
if dividendsEstimateDetail.IsSuccessfully {
// 生成分红预算单号
dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber()
dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// 记录成功的订单号
estimateSuccessfullyDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.OrderOrReturnedOrderNumber
// 统计分红预算单数目
countDividendsEstimate = countDividendsEstimate + 1
dividendsEstimate = &domain.DividendsEstimate{
DividendsEstimateId: 0,
DividendsAccountStatus: domain.TO_BE_ACCOUNT,
... ... @@ -656,27 +700,33 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
OrderGoodId: orderGood.OrderGoodId,
OrderGoodAmount: orderGood.OrderGoodAmount,
}
dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
} else {
// 记录失败的订单号和原因s
estimateFailedDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.Reason
}
}
} else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsReturnedOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
}
} else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
// 分红退货单产品预算
if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoods); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
if dividendsReturnedEstimateDetail.IsSuccessfully {
// 生成分红预算单号
dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber()
dividendsEstimateOrderNumber, err := dividendsReturnedEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// 记录成功的退货单号
estimateSuccessfullyDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber
// 统计生成的预算单数量
countDividendsEstimate = countDividendsEstimate + 1
dividendsEstimate = &domain.DividendsEstimate{
DividendsEstimateId: 0,
DividendsAccountStatus: domain.TO_BE_ACCOUNT,
... ... @@ -701,7 +751,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
OrderGoodId: orderGood.OrderGoodId,
OrderGoodAmount: orderGood.OrderGoodAmount,
}
dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
} else {
// 记录失败的退货单号和原因
estimateFailedDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.Reason
}
}
}
}
... ... @@ -709,26 +764,29 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
log.Logger.Info("新增的分红预算单", map[string]interface{}{
"dividendsEstimates": dividendsEstimates,
})
// 创建成功的分红预算单
var dividendsEstimatesSavedSuccessfully []*domain.DividendsEstimate
// 创建失败的分红预算单
var dividendsEstimateSaveFailed []*domain.DividendsEstimate
for _, dividendsEstimate := range dividendsEstimates {
if dividendsEstimateSaved, err := dividendsEstimateRepository.Save(dividendsEstimate); err != nil {
dividendsEstimateSaveFailed = append(dividendsEstimateSaveFailed, dividendsEstimate)
if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else if dividendsEstimateSaved != nil {
dividendsEstimatesSavedSuccessfully = append(dividendsEstimatesSavedSuccessfully, dividendsEstimate)
}
}
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// TODO 分析成功和失败原因
return dividendsEstimatesSavedSuccessfully, nil
// 分析成功和失败原因
successfullyCount := len(dividendsEstimatesSaved)
// 错误原因收集,返回第一个可能的原因
failedReason := make([]string, 0)
for _, v := range estimateFailedDividendsOrders {
failedReason = append(failedReason, v)
}
var failedReasonStr string
if len(failedReason) > 0 {
failedReasonStr = failedReason[0]
} else {
failedReasonStr = "无"
}
return map[string]interface{}{
"report": fmt.Sprintf("已完成%d笔单订单分红预算,生成%d笔单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
}, nil
}
}
}
... ... @@ -823,11 +881,20 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
dividendsEstimateRepository = value
}
cooperationContractId, _ := strconv.ParseInt(confirmMoneyIncentivesEstimateCommand.CooperationContractId, 10, 64)
undertakerUIDs, _ := utils.SliceAtoi(confirmMoneyIncentivesEstimateCommand.UndertakerUids)
cooperationContractId, err := strconv.ParseInt(confirmMoneyIncentivesEstimateCommand.CooperationContractId, 10, 64)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "合约编号类型错误:"+err.Error())
}
undertakerUIDs, err := utils.SliceAtoi(confirmMoneyIncentivesEstimateCommand.UndertakerUids)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人UID类型错误:"+err.Error())
}
// 获取共创合约
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": cooperationContractId})
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{
"cooperationContractId": cooperationContractId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -837,16 +904,28 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
var dividendsEstimates []*domain.DividendsEstimate
// 统计当前分红预算单数
count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
"companyId": confirmMoneyIncentivesEstimateCommand.CompanyId,
})
// 分红预算单统计
var countDividendsEstimate int64
// 共创合约预算
if dividendsEstimateDetails, err2 := confirmMoneyIncentivesEstimateService.Confirm(cooperationContract, confirmMoneyIncentivesEstimateCommand.DividendsIncentivesStage, undertakerUIDs); err2 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
} else {
for _, dividendsEstimateDetail := range dividendsEstimateDetails {
// 生成分红预算单号
dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber()
dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// 统计生成的预算单数目
countDividendsEstimate = countDividendsEstimate + 1
dividendsEstimate := &domain.DividendsEstimate{
DividendsEstimateId: 0,
DividendsAccountStatus: domain.TO_BE_ACCOUNT,
... ... @@ -869,15 +948,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
}
dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
}
dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if confirmMoneyIncentivesEstimateCommand.Action == 1 { // 只预算,不入库
return dividendsEstimatesSaved, nil
} else if confirmMoneyIncentivesEstimateCommand.Action == 2 { // 确定预算
... ... @@ -1098,7 +1175,11 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti
for _, orderGood := range orderGoods {
dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
if orderGood.DividendsOrderNumber != "" { // 查询分红订单
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber})
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{
"dividendsOrderNumber": orderGood.DividendsOrderNumber,
"companyId": orderGood.CompanyId,
"orgId": orderGood.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ... @@ -1110,7 +1191,11 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti
}
dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
} else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber})
dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
"companyId": orderGood.CompanyId,
"orgId": orderGood.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
... ...
... ... @@ -5,6 +5,7 @@ import (
"github.com/beego/beego/v2/core/validation"
"reflect"
"strings"
"time"
)
type OrderGoods struct {
... ... @@ -17,7 +18,7 @@ type OrderGoods struct {
// 订单产品单价
OrderGoodPrice float64 `json:"orderGoodPrice"`
// 订单产品数量
OrderGoodQuantity int64 `json:"orderGoodQuantity"`
OrderGoodQuantity float64 `json:"orderGoodQuantity"`
// 关联分红订单号
DividendsOrderNumber string `json:"dividendsOrderNumber"`
// 关联的共创合约编号
... ... @@ -55,6 +56,28 @@ type CreateDividendsOrderCommand struct {
LineNumbers []int `cname:"记录行号" json:"lineNumbers"`
}
// GenerateSpecificDividendsOrderNumber 生成自定义分红订单
func (createDividendsOrderCommand *CreateDividendsOrderCommand) GenerateSpecificDividendsOrderNumber(count int64, orderTime time.Time, index int64) (string, error) {
currentTime := time.Now()
if count+index < 1000 {
countStr := fmt.Sprintf("%03d", count+index+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
timeString := timeNow.Format("20060102")
timeString = timeString[2:len(timeString)]
dividendsOrderNumber := "SL" + timeString + "#" + countStr
return dividendsOrderNumber, nil
} else {
countStr := fmt.Sprintf("%d", count+index+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
timeString := timeNow.Format("20060102")
timeString = timeString[2:len(timeString)]
dividendsOrderNumber := "SL" + timeString + "#" + countStr
return dividendsOrderNumber, nil
}
}
func (createDividendsOrderCommand *CreateDividendsOrderCommand) Valid(validation *validation.Validation) {
}
... ...
... ... @@ -10,7 +10,7 @@ import (
type RemoveDividendsOrderCommand struct {
// 分红订单ID
DividendsOrderId string `cname:"分红订单ID" json:"dividendsOrderId" valid:"Required"`
DividendsOrderId int64 `cname:"分红订单ID" json:"dividendsOrderId" valid:"Required"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
// 组织机构ID
... ...
... ... @@ -40,7 +40,7 @@ type UpdateDividendsOrderCommand struct {
func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) Valid(validation *validation.Validation) {
if len(updateDividendsOrderCommand.OrderGoods) <= 0 {
validation.Error("激励规则不能为空")
validation.Error("订单产品不能为空")
} else {
for i, _ := range updateDividendsOrderCommand.OrderGoods {
if updateDividendsOrderCommand.OrderGoods[i].OrderGoodId == "" {
... ...
... ... @@ -10,7 +10,7 @@ import (
type GetDividendsOrderQuery struct {
// 分红订单ID
DividendsOrderId int64 `cname:"分红订单ID" json:"dividendsOrderId" valid:"Required"`
DividendsOrderId int64 `cname:"分红订单ID" json:"dividendsOrderId,omitempty"`
// 分红订单编号
DividendsOrderNumber string `cname:"分红订单编号" json:"dividendsOrderNumber,omitempty"`
// 公司ID,通过集成REST上下文获取
... ... @@ -20,7 +20,7 @@ type GetDividendsOrderQuery struct {
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID" json:"userId" valid:"Required"`
// 用户基础数据id
UserBaseId int64 `canme:"用户基础数据ID" json:"userBaseId" valid:"Required"`
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"`
}
func (getDividendsOrderQuery *GetDividendsOrderQuery) Valid(validation *validation.Validation) {
... ...
... ... @@ -6,6 +6,7 @@ import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"github.com/shopspring/decimal"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
... ... @@ -99,7 +100,9 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
}
// 生成分红订单号
dividendsOrderNumber, err := dividendsOrderDao.GenerateDividendsOrderNumber()
dividendsOrderNumber, err := dividendsOrderDao.GenerateDividendsOrderNumber(map[string]interface{}{
"companyId": createDividendsOrderCommand.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -107,7 +110,6 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
// 校验分红订单编号是否唯一
numberAvailable, err := dividendsOrderDao.CheckDividendsOrderNumberAvailable(map[string]interface{}{
"companyId": createDividendsOrderCommand.CompanyId,
"orgId": createDividendsOrderCommand.OrgId,
"dividendsOrderNumber": dividendsOrderNumber,
})
if err != nil {
... ... @@ -117,13 +119,70 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
}
// 合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
// 查找合约
cooperationContractsMap := make(map[string]*domain.CooperationContract)
if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
"offsetLimit": false,
"companyId": createDividendsOrderCommand.CompanyId,
"orgId": createDividendsOrderCommand.OrgId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 0 {
for _, cooperationContract := range cooperationContracts {
cooperationContractsMap[cooperationContract.CooperationContractNumber] = cooperationContract
}
}
}
// 订单时间转换
orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间错误")
}
orderTime := utils.TransformTimestampToTime(orderTimeInt)
// 新增订单产品
var orderGoods []*domain.OrderGood
var dividendsOrderAmount float64
for _, orderGood := range createDividendsOrderCommand.OrderGoods {
// 计算订单产品金额
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense)).Float64()
// 校验合约
ruleMatchedFlag := false
if orderGood.CooperationContractNumber != "" {
// 校验共创合约激励类型是否正确
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单产品不能关联金额激励规则")
}
// 校验产品关联合约的激励规则是否匹配订单时间
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
ruleMatchedFlag = true
break
}
}
}
if !ruleMatchedFlag {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
}
}
orderGoods = append(orderGoods, &domain.OrderGood{
OrderGoodId: 0,
OrderGoodAmount: orderGood.OrderGoodAmount,
OrderGoodAmount: orderGoodAmount,
OrderGoodName: orderGood.OrderGoodName,
OrderGoodPrice: orderGood.OrderGoodPrice,
OrderGoodQuantity: orderGood.OrderGoodQuantity,
... ... @@ -139,19 +198,11 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
UpdatedAt: time.Time{},
})
// 计算分红订单金额
dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount
}
// 订单时间转换
orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间错误")
dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense))).Float64()
}
orderTime := utils.TransformTimestampToTime(orderTimeInt)
// 新增分红订单
newDividendsOrder := &domain.DividendsOrder{
DividendsOrderId: 0,
DividendsOrderNumber: dividendsOrderNumber,
DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum,
DividendsOrderAmount: dividendsOrderAmount,
... ... @@ -257,6 +308,33 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
operator = data
}
// 合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
// 查找合约
cooperationContractsMap := make(map[string]*domain.CooperationContract)
countContracts, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
"offsetLimit": false,
"companyId": importDividendsOrderCommand.CompanyId,
"orgId": importDividendsOrderCommand.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if countContracts > 0 {
for _, cooperationContract := range cooperationContracts {
cooperationContractsMap[cooperationContract.CooperationContractNumber] = cooperationContract
}
}
}
// 分红订单DAO初始化
var dividendsOrderDao *dao.DividendsOrderDao
if value, err := factory.CreateDividendsOrderDao(map[string]interface{}{
... ... @@ -297,7 +375,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
}
// 必填项校验
nullCellError := make([]interface{}, 0)
nullCellError := make([]*domain.FailInfo, 0)
// 数据行计数
rowCnt := 0
... ... @@ -308,7 +386,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData {
rowCnt++
nullCell := make([]interface{}, 0)
//var myRow []string
t := reflect.TypeOf(dividendsOrder)
v := reflect.ValueOf(dividendsOrder)
for k := 0; k < t.NumField(); k++ {
... ... @@ -323,7 +400,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
}
if nullFlag {
myRow := &domain.FailInfo{
FailReason: "订单日期格式错误,请输入正确的订单日期",
FailReason: "必填项为空",
}
myRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[i]
nullCellError = append(nullCellError, myRow)
... ... @@ -459,7 +536,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
// 订单日期时间格式转换
timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
if err != nil {
//s := strconv.Itoa(i + 1)
tmpRow := &domain.FailInfo{
FailReason: "无效的订单日期",
}
... ... @@ -469,7 +545,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
}
// 产品相关:产品名称,产品数量、产品价格、费用
quantity, err := strconv.ParseInt(dividendsOrder.OrderGoodQuantity, 10, 64)
quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ... @@ -477,9 +553,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
expense, err := strconv.ParseFloat(dividendsOrder.Expense, 64)
if err != nil {
var expense float64
if dividendsOrder.Expense != "" {
if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
} else {
expense = expenseParse
}
}
// 初始化新建分红订单命令集
... ... @@ -510,7 +590,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
}
} else { // 聚合同一笔订单产品
// 产品相关:产品名称,产品数量、产品价格、费用
quantity, err := strconv.ParseInt(dividendsOrder.OrderGoodQuantity, 10, 64)
quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ... @@ -518,9 +598,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
expense, err := strconv.ParseFloat(dividendsOrder.Expense, 64)
if err != nil {
var expense float64
if dividendsOrder.Expense != "" {
if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
} else {
expense = expenseParse
}
}
dividendsOrderCommands[hashString].OrderGoods = append(dividendsOrderCommands[hashString].OrderGoods, command.OrderGoods{
... ... @@ -586,7 +670,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
for _, errorData := range errorDataList {
if len(errorData.GoodLine) == 0 { // 订单错误
for _, line := range errorData.LineNumbers {
//s := strconv.Itoa(line + 1)
tmpRow := &domain.FailInfo{
FailReason: "数据校验错误:" + errorData.Error.Error(),
}
... ... @@ -595,7 +678,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
}
} else if len(errorData.GoodLine) > 0 { // 订单产品错误
for line := range errorData.GoodLine {
//s := strconv.Itoa(line + 1)
tmpRow := &domain.FailInfo{
FailReason: "订单产品信息错误:" + errorData.Error.Error(),
}
... ... @@ -613,36 +695,35 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
}, nil
}
// 批量导入创建分红订单
for _, dividendsOrder := range createDividendsOrderCommands {
// 生成分红订单号
dividendsOrderNumber, err := dividendsOrderDao.GenerateDividendsOrderNumber()
// 创建分红订单领域模型
var creatDividendsOrder []*domain.DividendsOrder
// 统计当前分红订单数
count, err := dividendsOrderDao.CountDividendsOrder(map[string]interface{}{})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// 校验分红订单编号是否唯一
numberAvailable, err3 := dividendsOrderDao.CheckDividendsOrderNumberAvailable(map[string]interface{}{
"companyId": importDividendsOrderCommand.CompanyId,
"orgId": importDividendsOrderCommand.OrgId,
"dividendsOrderNumber": dividendsOrderNumber,
})
if err3 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
}
if !numberAvailable {
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
// 批量创建分红订单
for i, dividendsOrder := range createDividendsOrderCommands {
// 生成分红订单号
dividendsOrderNumber, err := dividendsOrder.GenerateSpecificDividendsOrderNumber(int64(count), time.Time{}, int64(i))
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
// 共创合约DAO初始化
var cooperationContractDao *dao.CooperationContractDao
if value, err := factory.CreateCooperationContractDao(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
} else {
cooperationContractDao = value
// 订单时间转换
orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64)
if err != nil {
row := &domain.ImportInfo{
Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("订单日期转换错误:%s", err)),
LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行
GoodLine: map[int]interface{}{},
}
errorDataList = append(errorDataList, row)
continue
}
orderTime := utils.TransformTimestampToTime(orderTimeInt)
// 新增订单产品
var orderGoods []*domain.OrderGood
... ... @@ -650,20 +731,43 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
orderGoodErrMap := make(map[int]interface{}, 0)
for i, orderGood := range dividendsOrder.OrderGoods {
// 校验共创合约是否合法
if orderGood.CooperationContractNumber != "" {
contractNumberExist, _ := cooperationContractDao.CheckContractNumberExist(map[string]interface{}{
"companyId": importDividendsOrderCommand.CompanyId,
"orgId": importDividendsOrderCommand.OrgId,
"cooperationContractNumber": orderGood.CooperationContractNumber,
})
contractNumberExist := false
for _, cooperationContract := range cooperationContracts {
if orderGood.CooperationContractNumber == cooperationContract.CooperationContractNumber {
contractNumberExist = true
break
}
}
if !contractNumberExist {
orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("共创合约编号不存在:%s", err))
}
// 计算产品金额
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense)).Float64()
// 校验共创合约激励类型是否正确
ruleMatchedFlag := false
if orderGood.CooperationContractNumber != "" {
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
}
// 校验产品关联合约的激励规则是否匹配订单时间
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
ruleMatchedFlag = true
break
}
}
}
if !ruleMatchedFlag {
orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
}
}
orderGoods = append(orderGoods, &domain.OrderGood{
OrderGoodId: 0,
OrderGoodAmount: orderGood.OrderGoodAmount,
OrderGoodAmount: orderGoodAmount,
OrderGoodName: orderGood.OrderGoodName,
OrderGoodPrice: orderGood.OrderGoodPrice,
OrderGoodQuantity: orderGood.OrderGoodQuantity,
... ... @@ -679,7 +783,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
})
// 计算分红订单金额
dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount
dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense)))).Float64()
}
if len(orderGoodErrMap) > 0 {
row := &domain.ImportInfo{
... ... @@ -691,19 +795,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
continue
}
// 订单时间转换
orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64)
if err != nil {
row := &domain.ImportInfo{
Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("订单日期转换错误:%s", err)),
LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行
GoodLine: map[int]interface{}{},
}
errorDataList = append(errorDataList, row)
continue
}
orderTime := utils.TransformTimestampToTime(orderTimeInt)
// 新增分红订单
newDividendsOrder := &domain.DividendsOrder{
DividendsOrderId: 0,
... ... @@ -728,19 +819,14 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
Operator: operator,
}
if _, err2 := dividendsOrderRepository.Save(newDividendsOrder); err2 != nil {
row := &domain.ImportInfo{
Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单数据失败:%s", err)),
LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行
GoodLine: map[int]interface{}{},
}
errorDataList = append(errorDataList, row)
continue
}
creatDividendsOrder = append(creatDividendsOrder, newDividendsOrder)
}
// 错误报告处理
if len(errorDataList) <= 0 { // 成功返回
if _, err2 := dividendsOrderRepository.SaveMany(creatDividendsOrder); err2 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
}
if err3 := transactionContext.CommitTransaction(); err3 != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
}
... ... @@ -757,7 +843,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
for _, errorData := range errorDataList {
if len(errorData.GoodLine) == 0 { // 订单错误
for _, line := range errorData.LineNumbers {
//s := strconv.Itoa(line + 1)
tmpRow := &domain.FailInfo{
FailReason: "订单数据新增错误:" + errorData.Error.Error(),
}
... ... @@ -766,7 +851,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
}
} else if len(errorData.GoodLine) > 0 { // 订单产品错误
for line := range errorData.GoodLine {
//s := strconv.Itoa(line + 1)
tmpRow := &domain.FailInfo{
FailReason: "订单数据新增错误:" + errorData.Error.Error(),
}
... ... @@ -888,15 +972,15 @@ func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeD
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeDividendsOrderCommand.DividendsOrderId)))
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeDividendsOrderCommand.DividendsOrderId, 10)))
}
if dividendsOrder, err := dividendsOrderRepository.Remove(dividendsOrder); err != nil {
if dividendsOrderRemoved, err := dividendsOrderRepository.Remove(dividendsOrder); 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 dividendsOrder, nil
return dividendsOrderRemoved, nil
}
}
... ... @@ -924,7 +1008,10 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
dividendsOrderRepository = value
}
dividendsOrderIds, _ := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds)
dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单ID类型错误")
}
if count, dividendsOrders, err := dividendsOrderRepository.Find(map[string]interface{}{
"dividendsOrderIds": dividendsOrderIds,
}); err != nil {
... ... @@ -1055,8 +1142,14 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD
}
orderTime := utils.TransformTimestampToTime(orderTimeInt)
// 分红订单ID类型转换
dividendsOrderId, err := strconv.ParseInt(updateDividendsOrderCommand.DividendsOrderId, 10, 64)
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
// 获取分红订单
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderId": updateDividendsOrderCommand.DividendsOrderId})
dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderId": dividendsOrderId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
}
... ... @@ -1064,18 +1157,68 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateDividendsOrderCommand.DividendsOrderId)))
}
// 合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
// 查找合约
cooperationContractsMap := make(map[string]*domain.CooperationContract)
if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
"offsetLimit": false,
"companyId": updateDividendsOrderCommand.CompanyId,
"orgId": updateDividendsOrderCommand.OrgId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 0 {
for _, cooperationContract := range cooperationContracts {
cooperationContractsMap[cooperationContract.CooperationContractNumber] = cooperationContract
}
}
}
// 获取订单产品
var orderGoods []*domain.OrderGood
var dividendsOrderAmount float64
for _, orderGood := range updateDividendsOrderCommand.OrderGoods {
// 计算订单产品金额
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense)).Float64()
// 产品ID类型转换
orderGoodId, err3 := strconv.ParseInt(orderGood.OrderGoodId, 10, 64)
if err3 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
}
ruleMatchedFlag := false
if orderGood.CooperationContractNumber != "" {
// 校验共创合约激励类型是否正确
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单产品不能关联金额激励规则")
}
// 校验产品关联合约的激励规则是否匹配订单时间
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
ruleMatchedFlag = true
break
}
}
}
if !ruleMatchedFlag {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
}
}
orderGoods = append(orderGoods, &domain.OrderGood{
OrderGoodId: orderGoodId,
OrderGoodAmount: orderGood.OrderGoodAmount,
OrderGoodAmount: orderGoodAmount,
OrderGoodName: orderGood.OrderGoodName,
OrderGoodPrice: orderGood.OrderGoodPrice,
OrderGoodQuantity: orderGood.OrderGoodQuantity,
... ... @@ -1083,13 +1226,14 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD
DividendsReturnedOrderNumber: "",
CooperationContractNumber: orderGood.CooperationContractNumber,
OrderGoodExpense: orderGood.OrderGoodExpense,
OrderGoodDividendsStatus: 0,
OrgId: updateDividendsOrderCommand.OrgId,
CompanyId: updateDividendsOrderCommand.CompanyId,
CreatedAt: time.Time{},
UpdatedAt: time.Now(),
})
// 计算分红订单金额
dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount
dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense))).Float64()
}
if err := dividendsOrder.Update(tool_funs.SimpleStructToMap(updateDividendsOrderCommand)); err != nil {
... ...
... ... @@ -17,13 +17,15 @@ type OrderGoods struct {
// 订单产品单价
OrderGoodPrice float64 `cname:"订单产品单价" json:"orderGoodPrice"`
// 订单产品数量
OrderGoodQuantity int64 `cname:"订单产品数量" json:"orderGoodQuantity"`
OrderGoodQuantity float64 `cname:"订单产品数量" json:"orderGoodQuantity"`
// 关联分红订单号
DividendsOrderNumber string `cname:"关联分红订单号" json:"dividendsOrderNumber"`
// 关联的共创合约编号
CooperationContractNumber string `cname:"关联的共创合约编号" json:"cooperationContractNumber"`
// 订单产品费用
OrderGoodExpense float64 `cname:"订单产品费用" json:"orderGoodExpense"`
//行号-错误信息返回
LineNumber int `json:"lineNumber"`
}
type CreateDividendsReturnedOrderCommand struct {
... ... @@ -34,9 +36,9 @@ type CreateDividendsReturnedOrderCommand struct {
// 来源单号,源单号,订单号
OriginalOrderNum string `cname:"来源单号" json:"originalOrderNum" valid:"Required"`
// 分红单号
DividendsOrderNumber string `cname:"订单号" json:"dividendsOrderNumber" valid:"Required"`
DividendsOrderNumber string `cname:"订单号" json:"dividendsOrderNumber"`
// 备注
Remarks string `cname:"备注" json:"remarks" valid:"Required"`
Remarks string `cname:"备注" json:"remarks,omitempty"`
// 退货日期
DividendsReturnedDate string `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"`
// 订单日期
... ...
... ... @@ -10,14 +10,14 @@ import (
type UpdateDividendsReturnedOrderCommand struct {
// 分红退货单记录ID
DividendsReturnedOrderId string `cname:"分红退货单记录ID" json:"dividendsReturnedOrderId" valid:"Required"`
// 退货金额
DividendsReturnedOrderRefund float64 `cname:"退货金额" json:"dividendsReturnedOrderRefund" valid:"Required"`
// 退货客户名称
DividendsReturnedCustomerName string `cname:"退货客户名称" json:"dividendsReturnedCustomerName" valid:"Required"`
// 来源单号,源单号,订单号
OriginalOrderNum string `cname:"来源单号" json:"originalOrderNum" valid:"Required"`
// 分红单号
DividendsOrderNumber string `cname:"订单号" json:"dividendsOrderNumber"`
// 备注
Remarks string `cname:"备注" json:"remarks" valid:"Required"`
Remarks string `cname:"备注" json:"remarks"`
// 退货日期
DividendsReturnedDate string `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"`
// 退货区域
... ... @@ -37,7 +37,15 @@ type UpdateDividendsReturnedOrderCommand struct {
}
func (updateDividendsReturnedOrderCommand *UpdateDividendsReturnedOrderCommand) Valid(validation *validation.Validation) {
//validation.SetError("CustomValid", "未实现的自定义认证")
if len(updateDividendsReturnedOrderCommand.OrderGoods) <= 0 {
validation.Error("退货单产品不能为空")
} else {
for i, _ := range updateDividendsReturnedOrderCommand.OrderGoods {
if updateDividendsReturnedOrderCommand.OrderGoods[i].OrderGoodId == "" {
updateDividendsReturnedOrderCommand.OrderGoods[i].OrderGoodId = "0"
}
}
}
}
func (updateDividendsReturnedOrderCommand *UpdateDividendsReturnedOrderCommand) ValidateCommand() error {
... ...
... ... @@ -6,6 +6,7 @@ import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"github.com/shopspring/decimal"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/command"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
... ... @@ -16,7 +17,6 @@ import (
"reflect"
"regexp"
"strconv"
"strings"
"time"
)
... ... @@ -99,7 +99,9 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
}
// 生成分红订单号
dividendsReturnedOrderNumber, err := dividendsReturnedOrderDao.GenerateDividendsReturnedOrderNumber()
dividendsReturnedOrderNumber, err := dividendsReturnedOrderDao.GenerateDividendsReturnedOrderNumber(map[string]interface{}{
"companyId": createDividendsReturnedOrderCommand.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -121,7 +123,6 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
// 校验分红退货单编号是否唯一
numberAvailable, err := dividendsReturnedOrderDao.CheckDividendsReturnedOrderNumberAvailable(map[string]interface{}{
"companyId": createDividendsReturnedOrderCommand.CompanyId,
"orgId": createDividendsReturnedOrderCommand.OrgId,
"dividendsReturnedOrderNumber": dividendsReturnedOrderNumber,
})
if err != nil {
... ... @@ -131,12 +132,64 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红退货单号已存在")
}
// 获取分红退货单产品
// 合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
// 查找合约
cooperationContractsMap := make(map[string]*domain.CooperationContract)
if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
"offsetLimit": false,
"companyId": createDividendsReturnedOrderCommand.CompanyId,
"orgId": createDividendsReturnedOrderCommand.OrgId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 0 {
for _, cooperationContract := range cooperationContracts {
cooperationContractsMap[cooperationContract.CooperationContractNumber] = cooperationContract
}
}
}
// 退货金额
var dividendsReturnedOrderRefund float64
// 新增分红退货单产品
var orderGoods []*domain.OrderGood
for _, orderGood := range createDividendsReturnedOrderCommand.OrderGoods {
// 退货产品金额计算
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
// 校验合约激励类型是否正确
ruleMatchedFlag := false
if orderGood.CooperationContractNumber != "" {
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
}
// 校验产品关联合约的激励规则是否匹配订单时间
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
ruleMatchedFlag = true
break
}
}
}
if !ruleMatchedFlag {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
}
}
orderGoods = append(orderGoods, &domain.OrderGood{
OrderGoodId: 0,
OrderGoodAmount: orderGood.OrderGoodAmount,
OrderGoodAmount: orderGoodAmount,
OrderGoodName: orderGood.OrderGoodName,
OrderGoodPrice: orderGood.OrderGoodPrice,
OrderGoodQuantity: orderGood.OrderGoodQuantity,
... ... @@ -151,11 +204,13 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
DeletedAt: time.Time{},
UpdatedAt: time.Time{},
})
// 计算退货订单金额
dividendsReturnedOrderRefund, _ = decimal.NewFromFloat(dividendsReturnedOrderRefund).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity))).Float64()
}
newDividendsReturnedOrder := &domain.DividendsReturnedOrder{
DividendsReturnedOrderNumber: dividendsReturnedOrderNumber,
DividendsReturnedOrderRefund: createDividendsReturnedOrderCommand.DividendsReturnedOrderRefund,
DividendsReturnedOrderRefund: dividendsReturnedOrderRefund,
OriginalOrderNum: createDividendsReturnedOrderCommand.OriginalOrderNum,
DividendsOrderNumber: createDividendsReturnedOrderCommand.DividendsOrderNumber,
DividendsReturnedCustomerName: createDividendsReturnedOrderCommand.DividendsReturnedCustomerName,
... ... @@ -316,6 +371,33 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
dividendsReturnedOrderRepository = value
}
// 合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
// 查找合约
cooperationContractsMap := make(map[string]*domain.CooperationContract)
countContracts, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
"offsetLimit": false,
"companyId": importDividendsReturnedOrderCommand.CompanyId,
"orgId": importDividendsReturnedOrderCommand.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if countContracts > 0 {
for _, cooperationContract := range cooperationContracts {
cooperationContractsMap[cooperationContract.CooperationContractNumber] = cooperationContract
}
}
}
// 返回信息表头定义
var tableHeader = map[string]interface{}{
"failReason": "错误详情",
... ... @@ -347,7 +429,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
rowCnt++
nullCell := make([]interface{}, 0)
var myRow []string
var myRow *domain.FailReturnedInfo
t := reflect.TypeOf(dividendsReturnedOrder)
v := reflect.ValueOf(dividendsReturnedOrder)
for k := 0; k < t.NumField(); k++ {
... ... @@ -361,11 +443,12 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
}
}
if nullFlag {
s := strconv.Itoa(i + 1)
b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1)
myRow = append(myRow, "第"+s+"行的第"+b+"列必填项为空") // 错误信息
myRow = append(myRow, s) // 行号
myRow = append(myRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
//s := strconv.Itoa(i + 1)
//b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1)
myRow = &domain.FailReturnedInfo{
FailReason: "必填项为空",
ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
}
nullCellError = append(nullCellError, myRow)
nullFlag = false
}
... ... @@ -384,24 +467,22 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
// 单元格类型校验
typeError := make([]interface{}, 0)
for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { // 行
var myRow []string
for _, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { // 行
var myRow *domain.FailReturnedInfo
t := reflect.TypeOf(dividendsReturnedOrder)
v := reflect.ValueOf(dividendsReturnedOrder)
for k := 0; k < t.NumField(); k++ { // 列
r := strconv.Itoa(i + 1)
col := strconv.Itoa(k + 1)
switch k {
case 3: // 退货日期校验
{
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
if !ok {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货日期格式错误,请输入正确的退货日期") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
var tmpRow *domain.FailReturnedInfo
tmpRow = &domain.FailReturnedInfo{
FailReason: "退货日期格式错误,请输入正确的退货日期",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
myRow = tmpRow
}
}
... ... @@ -410,10 +491,11 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
regexpStr := `(\d{4})/(\d{2})/(\d{2})`
ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
if !ok {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列订单日期格式错误,请输入正确的订单日期") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
var tmpRow *domain.FailReturnedInfo
tmpRow = &domain.FailReturnedInfo{
FailReason: "订单日期格式错误,请输入正确的订单日期",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
myRow = tmpRow
}
}
... ... @@ -422,18 +504,20 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
//参数类型转换
orderGoodQuantity, err := strconv.ParseInt(fmt.Sprintf("%v", v.Field(k).Interface()), 10, 64)
if err != nil {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货数量格式错误,退货数量必须整数") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
var tmpRow *domain.FailReturnedInfo
tmpRow = &domain.FailReturnedInfo{
FailReason: "退货数量格式错误,退货数量必须整数",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
myRow = tmpRow
}
// 正负判断
if orderGoodQuantity < 0 {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货数量必须大于0,请重新填写") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
var tmpRow *domain.FailReturnedInfo
tmpRow = &domain.FailReturnedInfo{
FailReason: "退货数量必须大于0,请重新填写",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
myRow = tmpRow
}
}
... ... @@ -442,19 +526,21 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
// 参数类型转换
univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64)
if typeErr != nil {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货价格格式错误,退货价格必须为数字类型") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
var tmpRow *domain.FailReturnedInfo
tmpRow = &domain.FailReturnedInfo{
FailReason: "退货价格格式错误,退货价格必须为数字类型",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
myRow = tmpRow
}
// 长度校验
if univalent >= 1e16 {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货价格超过最大限制,退货价格小数点前面不能超过十六位数字,并保留两位小数") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据
var tmpRow *domain.FailReturnedInfo
tmpRow = &domain.FailReturnedInfo{
FailReason: "退货价格超过最大限制,退货价格小数点前面不能超过十六位数字,并保留两位小数",
ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
}
myRow = tmpRow
}
}
... ... @@ -515,7 +601,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
}
// 产品相关:产品名称,退货数量、退货价格
quantity, err := strconv.ParseInt(dividendsReturnedOrder.OrderGoodQuantity, 10, 64)
quantity, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodQuantity, 64)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ... @@ -553,7 +639,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
}
} else { // 聚合同一笔订单产品
// 产品相关:产品名称,退货数量、退货价格
quantity, err := strconv.ParseInt(dividendsReturnedOrder.OrderGoodQuantity, 10, 64)
quantity, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodQuantity, 64)
if err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
... ... @@ -655,7 +741,9 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
// 批量导入创建退货单
for _, dividendsReturnedOrder := range createDividendsReturnedOrderCommands {
// 生成退货订单号
dividendsReturnedOrderNumber, err := dividendsReturnedOrderDao.GenerateDividendsReturnedOrderNumber()
dividendsReturnedOrderNumber, err := dividendsReturnedOrderDao.GenerateDividendsReturnedOrderNumber(map[string]interface{}{
"companyId": importDividendsReturnedOrderCommand.CompanyId,
})
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
... ... @@ -663,7 +751,6 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
// 校验退货订单编号是否唯一
numberAvailable, err3 := dividendsReturnedOrderDao.CheckDividendsReturnedOrderNumberAvailable(map[string]interface{}{
"companyId": importDividendsReturnedOrderCommand.CompanyId,
"orgId": importDividendsReturnedOrderCommand.OrgId,
"dividendsReturnedOrderNumber": dividendsReturnedOrderNumber,
})
if err3 != nil {
... ... @@ -676,10 +763,32 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
// 新增订单产品
var orderGoods []*domain.OrderGood
var dividendsReturnedOrderAmount float64
for _, orderGood := range dividendsReturnedOrder.OrderGoods {
orderGoodErrMap := make(map[int]interface{}, 0)
for i, orderGood := range dividendsReturnedOrder.OrderGoods {
// 校验共创合约是否合法
contractNumberExist := false
for _, cooperationContract := range cooperationContracts {
if orderGood.CooperationContractNumber == cooperationContract.CooperationContractNumber {
contractNumberExist = true
break
}
}
if !contractNumberExist {
orderGoodErrMap[dividendsReturnedOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("共创合约编号不存在:%s", err))
}
// 计算产品金额
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
// 校验合约激励类型是否正确
if orderGood.CooperationContractNumber != "" {
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
orderGoodErrMap[dividendsReturnedOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
}
}
orderGoods = append(orderGoods, &domain.OrderGood{
OrderGoodId: 0,
OrderGoodAmount: orderGood.OrderGoodAmount,
OrderGoodAmount: orderGoodAmount,
OrderGoodName: orderGood.OrderGoodName,
OrderGoodPrice: orderGood.OrderGoodPrice,
OrderGoodQuantity: orderGood.OrderGoodQuantity,
... ... @@ -1011,6 +1120,32 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateDividendsReturnedOrderCommand.DividendsReturnedOrderId)))
}
// 合约仓储初始化
var cooperationContractRepository domain.CooperationContractRepository
if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
cooperationContractRepository = value
}
// 查找合约
cooperationContractsMap := make(map[string]*domain.CooperationContract)
if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
"offsetLimit": false,
"companyId": updateDividendsReturnedOrderCommand.CompanyId,
"orgId": updateDividendsReturnedOrderCommand.OrgId,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if count > 0 {
for _, cooperationContract := range cooperationContracts {
cooperationContractsMap[cooperationContract.CooperationContractNumber] = cooperationContract
}
}
}
// 获取订单产品
var orderGoods []*domain.OrderGood
var dividendsReturnedOrderAmount float64
... ... @@ -1020,9 +1155,33 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
if err3 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
}
// 退货产品金额计算
orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
// 校验合约激励类型是否正确
ruleMatchedFlag := false
if orderGood.CooperationContractNumber != "" {
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
}
// 校验产品关联合约的激励规则是否匹配订单时间
if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
ruleMatchedFlag = true
break
}
}
}
if !ruleMatchedFlag {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
}
}
orderGoods = append(orderGoods, &domain.OrderGood{
OrderGoodId: orderGoodId,
OrderGoodAmount: orderGood.OrderGoodAmount,
OrderGoodAmount: orderGoodAmount,
OrderGoodName: orderGood.OrderGoodName,
OrderGoodPrice: orderGood.OrderGoodPrice,
OrderGoodQuantity: orderGood.OrderGoodQuantity,
... ... @@ -1036,7 +1195,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
UpdatedAt: time.Now(),
})
// 计算分红退货单金额
dividendsReturnedOrderAmount = dividendsReturnedOrderAmount + orderGood.OrderGoodAmount
dividendsReturnedOrderAmount, _ = decimal.NewFromFloat(dividendsReturnedOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodAmount)).Float64()
}
if err := dividendsReturnedOrder.Update(tool_funs.SimpleStructToMap(updateDividendsReturnedOrderCommand)); err != nil {
... ...
... ... @@ -60,3 +60,11 @@ func CreateDividendsEstimateDao(options map[string]interface{}) (*dao.DividendsE
}
return dao.NewDividendsEstimateDao(transactionContext)
}
func CreateCooperationApplicationDao(options map[string]interface{}) (*dao.CooperationApplicationDao, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return dao.NewCooperationApplicationDao(transactionContext)
}
... ...
... ... @@ -4,7 +4,9 @@ import "os"
const SERVICE_NAME = "allied-creation-cooperation"
// LOG_LEVEL 日志相关设置
// LOG_TYPE 日志相关设置
var LOG_TYPE = "terminal" // file, terminal, es
var LOG_FRAMEWORK = "beego" // beego logrus
var LOG_LEVEL = "debug"
var LOG_FILE = "app.log"
var LOG_PREFIX = "[allied-creation-cooperation]"
... ... @@ -16,9 +18,15 @@ var USER_MODULE_HOST = "http://127.0.0.1:8081"
var BASIC_MODULE_HOST = "http://127.0.0.1:8080"
func init() {
if os.Getenv("LOG_TYPE") != "" {
LOG_TYPE = os.Getenv("LOG_TYPE")
}
if os.Getenv("LOG_LEVEL") != "" {
LOG_LEVEL = os.Getenv("LOG_LEVEL")
}
if os.Getenv("LOG_FRAMEWORK") != "" {
LOG_FRAMEWORK = os.Getenv("LOG_FRAMEWORK")
}
if os.Getenv("LOG_FILE") != "" {
LOG_FILE = os.Getenv("LOG_FILE")
}
... ... @@ -28,4 +36,7 @@ func init() {
if os.Getenv("USER_MODULE_HOST") != "" {
USER_MODULE_HOST = os.Getenv("USER_MODULE_HOST")
}
if os.Getenv("BASIC_MODULE_HOST") != "" {
BASIC_MODULE_HOST = os.Getenv("BASIC_MODULE_HOST")
}
}
... ...
... ... @@ -2,13 +2,13 @@ package constant
import "os"
// kafka 地址
var KAFKA_HOSTS = ""
// KAFKA_HOSTS kafka 地址
var KAFKA_HOSTS = "192.168.0.250:9092,192.168.0.251:9092,192.168.0.252:9092"
// kafka topic log stash
// TOPIC_LOG_STASH kafka topic log stash
var TOPIC_LOG_STASH = "go_stash_dev"
// 是否启用日志收集 (本地不启用)
// ENABLE_KAFKA_LOG 是否启用日志收集 (本地不启用)
var ENABLE_KAFKA_LOG = false
func init() {
... ... @@ -19,6 +19,10 @@ func init() {
POSTGRESQL_PORT = os.Getenv("TOPIC_LOG_STASH")
}
if os.Getenv("ENABLE_KAFKA_LOG") != "" {
DISABLE_CREATE_TABLE = true
if os.Getenv("ENABLE_KAFKA_LOG") == "true" {
ENABLE_KAFKA_LOG = true
} else if os.Getenv("ENABLE_KAFKA_LOG") == "false" {
ENABLE_KAFKA_LOG = false
}
}
}
... ...
... ... @@ -26,8 +26,8 @@ type CooperationApplication struct {
CooperationProject *CooperationProject `json:"cooperationProject"`
// 数据所属组织机构
Org *Org `json:"org"`
// 是否被取消标志位
IsCanceled bool `json:"isCanceled"`
// 是否被取消标志位 1未取消,2取消
IsCanceled int32 `json:"isCanceled"`
// 公司
Company *Company `json:"company"`
// 创建时间
... ... @@ -55,7 +55,7 @@ func (cooperationApplication *CooperationApplication) Identify() interface{} {
func (cooperationApplication *CooperationApplication) Update(data map[string]interface{}) error {
if isCanceled, ok := data["isCanceled"]; ok {
cooperationApplication.IsCanceled = isCanceled.(bool)
cooperationApplication.IsCanceled = isCanceled.(int32)
}
if cooperationApplicationAttachment, ok := data["cooperationApplicationAttachment"]; ok {
cooperationApplication.CooperationApplicationAttachment = cooperationApplicationAttachment.([]*Attachment)
... ...
... ... @@ -22,7 +22,7 @@ type CooperationProject struct {
CooperationMode *CooperationMode `json:"cooperationMode"`
// 共创项目发起部门
Department *Department `json:"department"`
// 共创项目承接对象,1员工,2共创用户,3公开,可以多选
// 共创项目承接对象,1员工,2共创用户,4公开,可以多选
CooperationProjectUndertakerTypes []int32 `json:"cooperationProjectUndertakerTypes"`
// 数据所属组织机构
Org *Org `json:"org"`
... ...
... ... @@ -61,20 +61,12 @@ type ImportInfo struct {
// FailInfo 返回的失败信息
type FailInfo struct {
FailReason string `json:"failReason"`
//OriginalOrderNum string `json:"originalOrderNum"`
//DividendsCustomerName string `json:"dividendsCustomerName"`
//OrderGoodName string `json:"orderGoodName"`
//OrderTime string `json:"orderTime"`
//RegionName string `json:"regionName"`
//OrderGoodQuantity string `json:"orderGoodQuantity"`
//OrderGoodPrice string `json:"orderGoodPrice"`
//Expense string `json:"expense"`
//CooperationContractNumber string `json:"cooperationContractNumber"`
*command.ImportDividendsOrderData
}
type DividendsOrderRepository interface {
Save(dividendsOrder *DividendsOrder) (*DividendsOrder, error)
SaveMany(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error)
UpdateMany(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error)
Remove(dividendsOrder *DividendsOrder) (*DividendsOrder, error)
BatchRemove(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error)
... ...
package domain
import "time"
import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/command"
"time"
)
// DividendsReturnedOrder 分红退货单实体
type DividendsReturnedOrder struct {
... ... @@ -46,8 +49,15 @@ type DividendsReturnedOrder struct {
OperateTime time.Time `json:"operateTime"`
}
// FailReturnedInfo 返回的失败信息
type FailReturnedInfo struct {
FailReason string `json:"failReason"`
*command.ImportDividendsReturnedOrderData
}
type DividendsReturnedOrderRepository interface {
Save(dividendsReturnedOrder *DividendsReturnedOrder) (*DividendsReturnedOrder, error)
SaveMany(dividendsReturnedOrders []*DividendsReturnedOrder) ([]*DividendsReturnedOrder, error)
UpdateMany(dividendsReturnedOrder []*DividendsReturnedOrder) ([]*DividendsReturnedOrder, error)
Remove(dividendsReturnedOrder *DividendsReturnedOrder) (*DividendsReturnedOrder, error)
BatchRemove(dividendsReturnedOrders []*DividendsReturnedOrder) ([]*DividendsReturnedOrder, error)
... ...
... ... @@ -18,7 +18,7 @@ type OrderGood struct {
// 订单产品单价
OrderGoodPrice float64 `json:"orderGoodPrice"`
// 订单产品数量
OrderGoodQuantity int64 `json:"orderGoodQuantity,string"`
OrderGoodQuantity float64 `json:"orderGoodQuantity,string"`
// 关联分红订单号
DividendsOrderNumber string `json:"dividendsOrderNumber"`
// 关联的分红退货单号
... ... @@ -66,7 +66,7 @@ func (orderGood *OrderGood) Update(data map[string]interface{}) error {
orderGood.OrderGoodPrice = orderGoodPrice.(float64)
}
if orderGoodQuantity, ok := data["orderGoodQuantity"]; ok {
orderGood.OrderGoodQuantity = orderGoodQuantity.(int64)
orderGood.OrderGoodQuantity = orderGoodQuantity.(float64)
}
if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
orderGood.CooperationContractNumber = cooperationContractNumber.(string)
... ...
... ... @@ -31,3 +31,10 @@ type Relevant struct {
// 公司
Company *Company `json:"company"`
}
func (relevant *Relevant) Identify() interface{} {
if relevant.RelevantId == 0 {
return nil
}
return relevant.RelevantId
}
... ...
package service
import (
"fmt"
coreDomain "github.com/linmadan/egglib-go/core/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"time"
)
type DividendsEstimateDetail struct {
... ... @@ -10,6 +12,31 @@ type DividendsEstimateDetail struct {
DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型
DividendsStage int32 `json:"dividendsStage"` // 分红阶段
DividendsAmount float64 `json:"dividendsAmount"` // 分红金额
OrderOrReturnedOrderNumber string `json:"orderOrReturnedOrderNumber"` // 分红订单号或退货单号
IsSuccessfully bool `json:"isSuccessfully"` // 是否预算成功
Reason string `json:"reason"` // 错误原因
}
// GenerateSpecificDividendsEstimateNumber 批量生成自定义分红预算单号
func (DividendsEstimateDetail *DividendsEstimateDetail) GenerateSpecificDividendsEstimateNumber(count int64, index int64) (string, error) {
currentTime := time.Now()
if count+index < 1000 {
countStr := fmt.Sprintf("%03d", count+index+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
timeString := timeNow.Format("20060102")
timeString = timeString[2:len(timeString)]
dividendsEstimateNumber := "FH" + timeString + "#" + countStr
return dividendsEstimateNumber, nil
} else {
countStr := fmt.Sprintf("%d", count+index+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
timeString := timeNow.Format("20060102")
timeString = timeString[2:len(timeString)]
dividendsEstimateNumber := "FH" + timeString + "#" + countStr
return dividendsEstimateNumber, nil
}
}
type ConfirmDividendsIncentivesEstimateService interface {
... ...
... ... @@ -9,4 +9,5 @@ type UserService interface {
RelevantFrom(companyId int64, orgId int64, userId int64) (*domain.Relevant, error) // 获取相关人
SalesmanFrom(companyId int64, orgId int64, userId int64) (*domain.Salesman, error) // 获取业务员
OperatorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) // 获取操作人
VisitorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) // 获取游客
}
... ...
... ... @@ -37,3 +37,10 @@ type Undertaker struct {
// 合同附件
ContractAttachment []*Attachment `json:"contractAttachment"`
}
func (undertaker *Undertaker) Identify() interface{} {
if undertaker.UndertakerId == 0 {
return nil
}
return undertaker.UndertakerId
}
... ...
package dao
import (
"fmt"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
)
type CooperationApplicationDao struct {
transactionContext *pgTransaction.TransactionContext
}
// CheckApplicationExist 判断该申请人是否提交过申请
func (dao *CooperationApplicationDao) CheckApplicationExist(queryOptions map[string]interface{}) (bool, error) {
tx := dao.transactionContext.PgTx
var cooperationApplicationModels []*models.CooperationApplication
query := tx.Model(&cooperationApplicationModels)
if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
query = query.Where("cooperation_project_number = ?", cooperationProjectNumber)
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query = query.Where(`cooperation_application.company @> '{"companyId":"?"}'`, companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query = query.Where(`cooperation_application.org @> '{"orgId":"?"}'`, orgId)
}
if applicantId, ok := queryOptions["applicantId"]; ok && applicantId.(int64) != 0 {
query = query.Where(`cooperation_application.cooperation_application_applicant @>'{"userId":"?"}'`, applicantId)
}
if visitorUserBaseId, ok := queryOptions["visitorUserBaseId"]; ok && visitorUserBaseId.(int64) != 0 {
query = query.Where(`cooperation_application.cooperation_application_applicant @>'{"userBaseId":"?"}'`, visitorUserBaseId)
}
if applicantBaseId, ok := queryOptions["applicantBaseId"]; ok && applicantBaseId.(int64) != 0 {
query = query.Where(`cooperation_application.cooperation_application_applicant @>'{"userBaseId":"?"}'`, applicantBaseId)
}
ok, err := query.Exists()
return ok, err
}
func NewCooperationApplicationDao(transactionContext *pgTransaction.TransactionContext) (*CooperationApplicationDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
return &CooperationApplicationDao{
transactionContext: transactionContext,
}, nil
}
}
... ...
... ... @@ -2,8 +2,12 @@ package dao
import (
"fmt"
"github.com/go-pg/pg/v10"
"github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/transform"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"time"
)
... ... @@ -13,7 +17,7 @@ type CooperationContractDao struct {
}
// GenerateContractNumber 生成共创合约编号
func (dao *CooperationContractDao) GenerateContractNumber() (string, error) {
func (dao *CooperationContractDao) GenerateContractNumber(queryOptions map[string]interface{}) (string, error) {
tx := dao.transactionContext.PgTx
var cooperationContractModels []*models.CooperationContract
query := tx.Model(&cooperationContractModels)
... ... @@ -22,9 +26,13 @@ func (dao *CooperationContractDao) GenerateContractNumber() (string, error) {
nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
query.Where("cooperation_contract.created_at >= ?", todayZeroTime)
query.Where("cooperation_contract.created_at < ?", nextDayZeroTime)
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query = query.Where(`cooperation_contract.company @> '{"companyId":"?"}'`, companyId)
}
if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
return "", err
} else {
if count < 1000 {
countStr := fmt.Sprintf("%03d", count+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
... ... @@ -32,6 +40,16 @@ func (dao *CooperationContractDao) GenerateContractNumber() (string, error) {
timeString = timeString[2:len(timeString)]
contractNumber := "HY" + timeString + "#" + countStr
return contractNumber, nil
} else {
countStr := fmt.Sprintf("%d", count+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
timeString := timeNow.Format("20060102")
timeString = timeString[2:len(timeString)]
dividendsOrderNumber := "HY" + timeString + "#" + countStr
return dividendsOrderNumber, nil
}
}
}
... ... @@ -146,6 +164,76 @@ func (dao *CooperationContractDao) SearchCooperationContractByUndertaker(queryOp
}
}
func (dao *CooperationContractDao) Find(queryOptions map[string]interface{}) (int64, []*domain.CooperationContract, error) {
tx := dao.transactionContext.PgTx
var cooperationContractModels []*models.CooperationContract
cooperationContracts := make([]*domain.CooperationContract, 0)
query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractModels), queryOptions)
if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
query.Where("cooperation_contract_number ilike ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
}
if cooperationContractName, ok := queryOptions["cooperationContactName"]; ok && cooperationContractName != "" {
query.Where("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", cooperationContractName))
}
if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
query.Where(`(cooperation_contract.department->>'departmentName')::test LIKE ?`, fmt.Sprintf("%%%s%%", departmentName))
}
if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
}
if cooperationContractIds, ok := queryOptions["cooperationContractIds"]; ok && len(cooperationContractIds.([]int64)) != 0 {
query.Where("cooperation_contract_id in (?)", pg.In(cooperationContractIds))
}
if cooperationContractNumbers, ok := queryOptions["cooperationContractNumbers"]; ok && len(cooperationContractNumbers.([]string)) != 0 {
query.Where("cooperation_contract_number in (?)", pg.In(cooperationContractNumbers))
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query.Where("org->>'orgId' = '?'", orgId)
}
if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
newOrgIds := utils.SliceItoa(orgIds.([]int64))
query.Where("org->>'orgId' in (?)", pg.In(newOrgIds))
}
if incentivesType, ok := queryOptions["incentivesType"]; ok && incentivesType.(int32) != 0 {
query.Where("incentives_type = ?", incentivesType)
}
offsetLimitFlag := true
if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
offsetLimitFlag = offsetLimit.(bool)
}
if offsetLimitFlag {
query.SetOffsetAndLimit(20)
}
query.SetOrderDirect("cooperation_contract_id", "DESC")
var count int
var err error
if count, err = query.SelectAndCount(); err != nil {
return 0, cooperationContracts, err
}
for _, cooperationContractModel := range cooperationContractModels {
// 获取分红激励规则列表
var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
var cooperationContractRelevantModels []*models.CooperationContractRelevant
if cooperationContract, err := transform.TransformToCooperationContractDomainModelFromPgModels(
cooperationContractModel,
&models.CooperationMode{},
dividendsIncentivesRuleModels,
moneyIncentivesRuleModels,
cooperationContractRelevantModels,
cooperationContractUndertakerModels); err != nil {
return 0, cooperationContracts, err
} else {
cooperationContracts = append(cooperationContracts, cooperationContract)
}
}
return int64(count), cooperationContracts, nil
}
func NewCooperationContractDao(transactionContext *pgTransaction.TransactionContext) (*CooperationContractDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
... ...
... ... @@ -13,7 +13,7 @@ type CooperationProjectDao struct {
}
// GenerateProjectNumber 生成共创项目编码
func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) {
func (dao *CooperationProjectDao) GenerateProjectNumber(queryOptions map[string]interface{}) (string, error) {
tx := dao.transactionContext.PgTx
var cooperationProjectModels []*models.CooperationProject
query := tx.Model(&cooperationProjectModels)
... ... @@ -22,9 +22,13 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) {
nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
query.Where("cooperation_project.created_at >= ?", todayZeroTime)
query.Where("cooperation_project.created_at < ?", nextDayZeroTime)
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query = query.Where(`cooperation_project.company @> '{"companyId":"?"}'`, companyId)
}
if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
return "", err
} else {
if count < 1000 {
countStr := fmt.Sprintf("%03d", count+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
... ... @@ -32,6 +36,15 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) {
timeString = timeString[2:len(timeString)]
contractNumber := "XM" + timeString + "#" + countStr
return contractNumber, nil
} else {
countStr := fmt.Sprintf("%d", count+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
timeString := timeNow.Format("20060102")
timeString = timeString[2:len(timeString)]
contractNumber := "XM" + timeString + "#" + countStr
return contractNumber, nil
}
}
}
... ...
... ... @@ -2,6 +2,7 @@ package dao
import (
"fmt"
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
... ... @@ -13,7 +14,7 @@ type CreditAccountDao struct {
}
// GenerateCreditAccountNumber 生成账期结算单号
func (dao *CreditAccountDao) GenerateCreditAccountNumber() (string, error) {
func (dao *CreditAccountDao) GenerateCreditAccountNumber(queryOptions map[string]interface{}) (string, error) {
tx := dao.transactionContext.PgTx
var creditAccountModels []*models.CreditAccount
query := tx.Model(&creditAccountModels)
... ... @@ -22,9 +23,13 @@ func (dao *CreditAccountDao) GenerateCreditAccountNumber() (string, error) {
nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
query.Where("credit_account.created_at >= ?", todayZeroTime)
query.Where("credit_account.created_at < ?", nextDayZeroTime)
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query = query.Where(`credit_account.company @> '{"companyId":"?"}'`, companyId)
}
if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
return "", err
} else {
if count < 1000 {
countStr := fmt.Sprintf("%03d", count+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
... ... @@ -32,6 +37,15 @@ func (dao *CreditAccountDao) GenerateCreditAccountNumber() (string, error) {
timeString = timeString[2:len(timeString)]
creditAccountNumber := "JS" + timeString + "#" + countStr
return creditAccountNumber, nil
} else {
countStr := fmt.Sprintf("%d", count+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
timeString := timeNow.Format("20060102")
timeString = timeString[2:len(timeString)]
creditAccountNumber := "JS" + timeString + "#" + countStr
return creditAccountNumber, nil
}
}
}
... ... @@ -58,7 +72,8 @@ func (dao *CreditAccountDao) DividendsStatistics(queryOptions map[string]interfa
creditAccount := new(models.CreditAccount)
query := dao.transactionContext.PgTx.Model(creditAccount)
query.ColumnExpr(`sum(settlement_amount) total`)
query.ColumnExpr(`sum((case when payment_status = 1 then actually_paid_amount else 0 end)) paid`)
query.ColumnExpr(`sum((case when payment_status = 2 then actually_paid_amount else 0 end)) paid`)
query.ColumnExpr(`sum((case when payment_status = 1 then settlement_amount else 0 end)) unpaid`)
query.ColumnExpr(`sum((case when settlement_time is not null then settlement_amount else 0 end)) accounted `)
if v, ok := queryOptions["beginTime"]; ok && !(v.(time.Time).IsZero()) {
query.Where(`created_at>? `, queryOptions["beginTime"])
... ... @@ -70,6 +85,10 @@ func (dao *CreditAccountDao) DividendsStatistics(queryOptions map[string]interfa
if v, ok := queryOptions["orgId"]; ok && v.(int64) > 0 {
query.Where(fmt.Sprintf(` org->>'orgId'= '%v'`, v))
}
if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
query.Where("cooperation_contract_number in (?)", pg.In(v))
}
query.Where("deleted_at is null")
err := query.Select(v)
return err
}
... ... @@ -84,7 +103,7 @@ func (dao *CreditAccountDao) CooperationUsersDividendsStatistics(queryOptions ma
query.ColumnExpr(`sum((case when payment_status = 1 then actually_paid_amount else 0 end)) actually_paid_amount`)
query.ColumnExpr(`max(participator->>'userId') user_id`)
query.ColumnExpr(`max(participator#>>'{userInfo,userName}') user_name`)
if _, ok := queryOptions["beginTime"]; ok {
if _, ok := queryOptions["beginTime"]; ok && !queryOptions["beginTime"].(time.Time).IsZero() {
query.Where(`created_at>? `, queryOptions["beginTime"])
query.Where(`created_at<? `, queryOptions["endTime"])
}
... ... @@ -103,6 +122,9 @@ func (dao *CreditAccountDao) CooperationUsersDividendsStatistics(queryOptions ma
if v, ok := queryOptions["endTime"]; ok && !v.(time.Time).IsZero() {
query.Where("created_at < ?", v)
}
if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
query.Where("cooperation_contract_number in (?)", pg.In(v))
}
query.Where("deleted_at is null")
if v, ok := queryOptions["sortByActuallyPaidAmount"]; ok {
vInt := v.(int)
... ...
... ... @@ -13,7 +13,7 @@ type DividendsEstimateDao struct {
}
// GenerateDividendsEstimateNumber 生成分红预算单号
func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber() (string, error) {
func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber(queryOptions map[string]interface{}) (string, error) {
tx := dao.transactionContext.PgTx
var dividendsEstimateModels []*models.DividendsEstimate
query := tx.Model(&dividendsEstimateModels)
... ... @@ -22,9 +22,13 @@ func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber() (string, erro
nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
query.Where("dividends_estimate.created_at >= ?", todayZeroTime)
query.Where("dividends_estimate.created_at < ?", nextDayZeroTime)
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId)
}
if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
return "", err
} else {
if count < 1000 {
countStr := fmt.Sprintf("%03d", count+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
... ... @@ -32,6 +36,16 @@ func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber() (string, erro
timeString = timeString[2:len(timeString)]
dividendsOrderNumber := "FH" + timeString + "#" + countStr
return dividendsOrderNumber, nil
} else {
countStr := fmt.Sprintf("%d", count+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
timeString := timeNow.Format("20060102")
timeString = timeString[2:len(timeString)]
dividendsOrderNumber := "FH" + timeString + "#" + countStr
return dividendsOrderNumber, nil
}
}
}
... ... @@ -75,6 +89,24 @@ func (dao *DividendsEstimateDao) UserEstimated(queryOptions map[string]interface
return ok, err
}
// CountDividendsEstimate 统计当前分红预算单总数
func (dao *DividendsEstimateDao) CountDividendsEstimate(queryOptions map[string]interface{}) (int, error) {
tx := dao.transactionContext.PgTx
var dividendsEstimateModels []*models.DividendsEstimate
query := tx.Model(&dividendsEstimateModels)
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId)
}
if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
query = query.Where(`dividends_estimate.org @> '{"orgId":"?"}'`, orgId)
}
if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
return 0, err
} else {
return count, nil
}
}
func NewDividendsEstimateDao(transactionContext *pgTransaction.TransactionContext) (*DividendsEstimateDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为空")
... ...
... ... @@ -13,7 +13,7 @@ type DividendsOrderDao struct {
}
// GenerateDividendsOrderNumber 生成分红订单号
func (dao *DividendsOrderDao) GenerateDividendsOrderNumber() (string, error) {
func (dao *DividendsOrderDao) GenerateDividendsOrderNumber(queryOptions map[string]interface{}) (string, error) {
tx := dao.transactionContext.PgTx
var dividendsOrderModels []*models.DividendsOrder
query := tx.Model(&dividendsOrderModels)
... ... @@ -22,9 +22,13 @@ func (dao *DividendsOrderDao) GenerateDividendsOrderNumber() (string, error) {
nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
query.Where("dividends_order.created_at >= ?", todayZeroTime)
query.Where("dividends_order.created_at < ?", nextDayZeroTime)
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query = query.Where(`dividends_order.company @> '{"companyId":"?"}'`, companyId)
}
if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
return "", err
} else {
if count < 1000 {
countStr := fmt.Sprintf("%03d", count+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
... ... @@ -32,6 +36,15 @@ func (dao *DividendsOrderDao) GenerateDividendsOrderNumber() (string, error) {
timeString = timeString[2:len(timeString)]
dividendsOrderNumber := "SL" + timeString + "#" + countStr
return dividendsOrderNumber, nil
} else {
countStr := fmt.Sprintf("%d", count+1)
timestamp := currentTime.Unix()
timeNow := time.Unix(timestamp, 0)
timeString := timeNow.Format("20060102")
timeString = timeString[2:len(timeString)]
dividendsOrderNumber := "SL" + timeString + "#" + countStr
return dividendsOrderNumber, nil
}
}
}
... ... @@ -78,6 +91,23 @@ func (dao *DividendsOrderDao) CalculateDividendsOrderAmount(queryOptions map[str
return dividendsOrderModel.DividendsOrderAmount, nil
}
// CountDividendsOrder 统计当前订单总数
func (dao *DividendsOrderDao) CountDividendsOrder(queryOptions map[string]interface{}) (int, error) {
tx := dao.transactionContext.PgTx
var dividendsOrderModels []*models.DividendsOrder
query := tx.Model(&dividendsOrderModels)
currentTime := time.Now()
todayZeroTime := utils.GetZeroTime(currentTime)
nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
query.Where("dividends_order.created_at >= ?", todayZeroTime)
query.Where("dividends_order.created_at < ?", nextDayZeroTime)
if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
return 0, err
} else {
return count, nil
}
}
func NewDividendsOrderDao(transactionContext *pgTransaction.TransactionContext) (*DividendsOrderDao, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为空")
... ...
... ... @@ -13,7 +13,7 @@ type DividendsReturnedOrderDao struct {
}
// GenerateDividendsReturnedOrderNumber 生成分红退货单号
func (dao *DividendsReturnedOrderDao) GenerateDividendsReturnedOrderNumber() (string, error) {
func (dao *DividendsReturnedOrderDao) GenerateDividendsReturnedOrderNumber(queryOptions map[string]interface{}) (string, error) {
tx := dao.transactionContext.PgTx
var dividendsReturnedOrderModels []*models.DividendsReturnedOrder
query := tx.Model(&dividendsReturnedOrderModels)
... ... @@ -22,6 +22,9 @@ func (dao *DividendsReturnedOrderDao) GenerateDividendsReturnedOrderNumber() (st
nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
query.Where("dividends_returned_order.created_at >= ?", todayZeroTime)
query.Where("dividends_returned_order.created_at < ?", nextDayZeroTime)
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query = query.Where(`dividends_returned_order.company @> '{"companyId":"?"}'`, companyId)
}
if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
return "", err
} else {
... ...
... ... @@ -30,7 +30,7 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte
queryLimit = fmt.Sprintf("limit %v", queryOptions["limit"])
}
sql := fmt.Sprintf(`select order_good_name good_name,sum(order_good_amount) good_amount from order_goods
where company_id=? and org_id = ? %v
where company_id=? and org_id = ? and deleted_at is null %v
GROUP BY order_good_name
order by good_amount desc
%v
... ... @@ -49,7 +49,7 @@ func (dao *OrderGoodDao) CooperationCompanyModeStatistics(queryOptions map[strin
var goods []*domain.CooperationModeStatisticsDto
sql := fmt.Sprintf(`select count(0) cooperation_people,sum(a.actually_paid_amount) dividends_estimate,b.cooperation_mode_number,sum(good_amount_count) order_amount
from credit_accounts a inner join cooperation_contracts b on a.cooperation_contract_number = b.cooperation_contract_number
where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and b.status = 1
where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and a.deleted_at is null and b.status = 1
group by b.cooperation_mode_number
`)
_, err := tx.Query(&goods, sql, queryOptions["companyId"], queryOptions["orgId"])
... ...
... ... @@ -50,6 +50,8 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
for _, dividendsEstimate := range dividendsEstimates {
// 根据当前分红预算单的分红订单号或退货单号获取分红预算单
if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
"companyId": dividendsEstimate.Company.CompanyId,
"orgId": dividendsEstimate.Org.OrgId,
"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
}); err2 != nil {
return nil, err2
... ... @@ -86,6 +88,8 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
// 获取分红订单
if countDividendsOrder, orders, err4 := dividendsOrderRepository.Find(map[string]interface{}{
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
"dividendsOrderNumbers": orderNums,
}); err4 != nil {
return nil, err4
... ... @@ -103,6 +107,8 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
// 获取分红退货单
if countDividendsReturnedOrder, returnedOrders, err5 := dividendsReturnedOrderRepository.Find(map[string]interface{}{
"companyId": dividendsEstimates[0].Company.CompanyId,
"orgId": dividendsEstimates[0].Org.OrgId,
"dividendsReturnedOrderNumbers": returnedOrderNums,
}); err5 != nil {
return nil, err5
... ...
... ... @@ -2,9 +2,9 @@ package domain_service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"github.com/shopspring/decimal"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
... ... @@ -18,48 +18,157 @@ type ConfirmDividendsIncentivesEstimateService struct {
// Confirm 确认业绩分红预算
func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood) ([]*service.DividendsEstimateDetail, error) {
var cooperationContractRepository domain.CooperationContractRepository // 共创合约仓储
var cooperationProjectRepository domain.CooperationProjectRepository // 共创项目仓储
var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
// 共创合约仓储初始化
if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil {
return nil, err
} else {
cooperationContractRepository = repo
}
// 共创项目仓储初始化
if repo, err := repository.NewCooperationProjectRepository(domainService.transactionContext); err != nil {
return nil, err
} else {
cooperationProjectRepository = repo
}
// 分红订单仓储初始化
if repo, err := repository.NewDividendsOrderRepository(domainService.transactionContext); err != nil {
return nil, err
} else {
dividendsOrderRepository = repo
}
// 分红退货单仓储初始化
if repo, err := repository.NewDividendsReturnedOrderRepository(domainService.transactionContext); err != nil {
return nil, err
} else {
dividendsReturnedOrderRepository = repo
}
// 确认业绩分红预算
var dividendsEstimateDetails []*service.DividendsEstimateDetail
for _, orderGood := range orderGoods {
// 获取合约
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractNumber": orderGood.CooperationContractNumber})
cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{
"cooperationContractNumber": orderGood.CooperationContractNumber,
"companyId": orderGood.CompanyId,
"orgId": orderGood.OrgId,
})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在")
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
IsSuccessfully: false,
Reason: "共创合约错误",
})
continue
//return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if cooperationContract == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.CooperationContractNumber))
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
IsSuccessfully: false,
Reason: "共创合约" + orderGood.CooperationContractNumber + "不存在",
})
continue
//return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创合约%s不存在", orderGood.CooperationContractNumber))
}
// 获取共创项目
cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
"cooperationProjectNumber": cooperationContract.CooperationProjectNumber,
"companyId": cooperationContract.Company.CompanyId,
"orgId": cooperationContract.Org.OrgId,
"notPause": true,
})
if err != nil {
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
IsSuccessfully: false,
Reason: "共创项目" + orderGood.CooperationContractNumber + "查询错误",
})
continue
//return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if orderGood.DividendsOrderNumber != "" {
if cooperationProject == nil {
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
IsSuccessfully: false,
Reason: "共创项目" + orderGood.CooperationContractNumber + "已结束或不存在",
})
continue
//return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s不存在", cooperationContract.CooperationProjectNumber))
}
// 校验合约关联的项目是否已结束
//if cooperationProject.Status == 2 {
// dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
// DividendsUser: nil,
// DividendsParticipateType: 0,
// DividendsStage: 0,
// DividendsAmount: 0,
// OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
// IsSuccessfully: false,
// Reason: "共创项目" + orderGood.CooperationContractNumber + "已结束",
// })
// continue
// //return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s已结束", cooperationContract.CooperationProjectNumber))
//}
if orderGood.DividendsOrderNumber != "" { // 获取分红订单
// 获取分红订单
dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{
"dividendsOrderNumber": orderGood.DividendsOrderNumber,
"companyId": orderGood.CompanyId,
"orgId": orderGood.OrgId,
})
if err2 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
IsSuccessfully: false,
Reason: "分红订单" + orderGood.DividendsOrderNumber + "查询错误",
})
continue
//return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
}
if dividendsOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
IsSuccessfully: false,
Reason: "分红订单" + orderGood.DividendsOrderNumber + "不存在",
})
continue
//return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红订单%s不存在", orderGood.DividendsOrderNumber))
}
// 匹配分红规则
var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
... ... @@ -69,14 +178,24 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
}
}
if dividendsIncentivesRuleMatched == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, "未匹配到分红规则")
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
IsSuccessfully: false,
Reason: "未匹配到分红规则",
})
continue
//return nil, application.ThrowError(application.RES_NO_FIND_ERROR, "未匹配到分红规则")
}
// 计算分红
if dividendsIncentivesRuleMatched != nil {
for _, undertaker := range cooperationContract.Undertakers {
// 添加承接人分红预算信息详情
undertakerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage
undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.UserId,
... ... @@ -87,7 +206,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
Roles: undertaker.Roles,
UserInfo: undertaker.UserInfo,
UserType: undertaker.UserType,
UserName: undertaker.UserName,
UserName: undertaker.UserInfo.UserName,
UserPhone: undertaker.UserPhone,
Status: undertaker.Status,
Company: undertaker.Company,
... ... @@ -95,10 +214,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
DividendsParticipateType: domain.UNDERTAKER,
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
DividendsAmount: undertakerDividendsAmount,
OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
IsSuccessfully: true,
})
// 添加推荐人分红预算信息详情
if undertaker.Referrer != nil {
referrerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.ReferrerPercentage
referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Referrer.UserId,
... ... @@ -116,11 +237,13 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
DividendsParticipateType: domain.REFERRER,
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
DividendsAmount: referrerDividendsAmount,
OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
IsSuccessfully: true,
})
}
// 添加关联业务员分红预算信息详情
if undertaker.Salesman != nil {
salesmanDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.SalesmanPercentage
salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Salesman.UserId,
... ... @@ -131,26 +254,50 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
Roles: undertaker.Salesman.Roles,
UserInfo: undertaker.Salesman.UserInfo,
UserType: undertaker.Salesman.UserType,
UserName: undertaker.Salesman.UserName,
UserName: undertaker.Salesman.UserInfo.UserName,
UserPhone: undertaker.Salesman.UserPhone,
Company: undertaker.Salesman.Company,
},
DividendsParticipateType: domain.SALESMAN,
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
DividendsAmount: salesmanDividendsAmount,
OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
IsSuccessfully: true,
})
}
}
}
} else if orderGood.DividendsReturnedOrderNumber != "" { // 获取分红退货单
} else if orderGood.DividendsReturnedOrderNumber != "" { // 获取退货单
dividendsReturnedOrder, err3 := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
"companyId": orderGood.CompanyId,
"orgId": orderGood.OrgId,
})
if err3 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红退货单不存在")
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
IsSuccessfully: false,
Reason: "退货单" + orderGood.DividendsReturnedOrderNumber + "不存在",
})
continue
//return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红退货单不存在")
}
if dividendsReturnedOrder == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: nil,
DividendsParticipateType: 0,
DividendsStage: 0,
DividendsAmount: 0,
OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
IsSuccessfully: false,
Reason: "退货单" + orderGood.DividendsReturnedOrderNumber + "不存在",
})
continue
//return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
}
// 匹配分红规则
var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
... ... @@ -163,7 +310,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
// 计算分红
for _, undertaker := range cooperationContract.Undertakers {
// 添加承接人分红退货预算信息详情
undertakerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage
undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.UserId,
... ... @@ -174,18 +321,20 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
Roles: undertaker.Roles,
UserInfo: undertaker.UserInfo,
UserType: undertaker.UserType,
UserName: undertaker.UserName,
UserName: undertaker.UserInfo.UserName,
UserPhone: undertaker.UserPhone,
Status: undertaker.Status,
Company: undertaker.Company,
},
DividendsParticipateType: domain.UNDERTAKER,
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
DividendsAmount: undertakerDividendsAmount,
DividendsAmount: -undertakerDividendsAmount,
OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsOrderNumber,
IsSuccessfully: true,
})
// 添加推荐人分红退货预算信息详情
if undertaker.Referrer != nil {
referrerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.ReferrerPercentage
referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Referrer.UserId,
... ... @@ -196,18 +345,20 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
Roles: undertaker.Referrer.Roles,
UserInfo: undertaker.Referrer.UserInfo,
UserType: undertaker.Referrer.UserType,
UserName: undertaker.Referrer.UserName,
UserName: undertaker.Referrer.UserInfo.UserName,
UserPhone: undertaker.Referrer.UserPhone,
Company: undertaker.Referrer.Company,
},
DividendsParticipateType: domain.REFERRER,
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
DividendsAmount: referrerDividendsAmount,
DividendsAmount: -referrerDividendsAmount,
OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsOrderNumber,
IsSuccessfully: true,
})
}
// 添加关联业务员分红退货预算信息详情
if undertaker.Salesman != nil {
salesmanDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.SalesmanPercentage
salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Salesman.UserId,
... ... @@ -218,13 +369,15 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
Roles: undertaker.Salesman.Roles,
UserInfo: undertaker.Salesman.UserInfo,
UserType: undertaker.Salesman.UserType,
UserName: undertaker.Salesman.UserName,
UserName: undertaker.Salesman.UserInfo.UserName,
UserPhone: undertaker.Salesman.UserPhone,
Company: undertaker.Salesman.Company,
},
DividendsParticipateType: domain.SALESMAN,
DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
DividendsAmount: salesmanDividendsAmount,
DividendsAmount: -salesmanDividendsAmount,
OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsOrderNumber,
IsSuccessfully: true,
})
}
}
... ...
... ... @@ -4,6 +4,7 @@ import (
"fmt"
coreDomain "github.com/linmadan/egglib-go/core/domain"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
"github.com/shopspring/decimal"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
... ... @@ -16,16 +17,8 @@ type ConfirmMoneyIncentivesEstimateService struct {
}
func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *domain.CooperationContract, stage int32, undertakerUIDs []int64) ([]*service.DividendsEstimateDetail, error) {
//var dividendsEstimateRepository domain.DividendsEstimateRepository // 分红预算单仓储
var dividendsEstimateDao *dao.DividendsEstimateDao // 分红预算DAO
// 分红预算单仓储初始化
//if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil {
// return nil, err
//} else {
// dividendsEstimateRepository = repo
//}
// 分红预算DAO初始化
if estimateDao, err := dao.NewDividendsEstimateDao(domainService.transactionContext); err != nil {
return nil, err
... ... @@ -68,7 +61,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
if undertakerEstimated {
return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红")
} else {
undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (1 - (moneyIncentivesRuleMatched.SalesmanPercentage+moneyIncentivesRuleMatched.ReferrerPercentage)/100)
undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage))).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.UserId,
... ... @@ -91,7 +84,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
}
// 判断业务员在当前阶段是否已经分红
if undertaker.Salesman.UserId != 0 {
if undertaker.Salesman != nil {
salesmanEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
"undertakerUid": undertaker.Salesman.UserId,
"companyId": contract.Company.CompanyId,
... ... @@ -103,7 +96,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
if salesmanEstimated {
return nil, fmt.Errorf("业务员 " + undertaker.Salesman.UserName + " 已分红")
} else {
undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.SalesmanPercentage / 100)
undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Salesman.UserId,
... ... @@ -127,7 +120,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
}
// 判断关联业务员在当前阶段是否已经分红
if undertaker.Referrer.UserId != 0 {
if undertaker.Referrer != nil {
referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
"undertakerUid": undertaker.Referrer.UserId,
"companyId": contract.Company.CompanyId,
... ... @@ -139,7 +132,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
if referrerEstimated {
return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红")
} else {
undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.ReferrerPercentage / 100)
undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
DividendsUser: &domain.User{
UserId: undertaker.Referrer.UserId,
... ...
... ... @@ -317,6 +317,7 @@ func (ptr *CooperationStatisticsService) CompanyPaymentHistoryStatistics(queryOp
Limit int `json:"limit" valid:"Required"`
Offset int `json:"offset"`
OrgId int64 `json:"orgId" valid:"Required"`
UserId int64 `json:"userId" valid:"Required"`
SortByActuallyPaidAmount int `json:"sortByActuallyPaidAmount" valid:"Required"`
BeginTime time.Time `json:"beginTime"`
EndTime time.Time `json:"endTime"`
... ... @@ -326,13 +327,23 @@ func (ptr *CooperationStatisticsService) CompanyPaymentHistoryStatistics(queryOp
}
queryOptions = tool_funs.SimpleStructToMap(&request)
// 按关联相关人过滤
var retMap = make([]interface{}, 0)
contractNumbers, err := ptr.getRelevantContracts(map[string]interface{}{"userId": request.UserId})
if len(contractNumbers) == 0 {
return retMap, nil
}
if err != nil {
return retMap, err
}
queryOptions["cooperationContractNumbers"] = contractNumbers
var responses []usersStatisticsResponse
creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
if err := creditAccountDao.CooperationUsersDividendsStatistics(queryOptions, &responses); err != nil {
return nil, err
}
var retMap = make([]interface{}, 0)
for i := range responses {
retMap = append(retMap, map[string]interface{}{
"paymentAmount": responses[i].ActuallyPaidAmount,
... ... @@ -354,21 +365,75 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query
var request = struct {
OrgId int64 `json:"orgId"`
UserId int64 `json:"userId"`
UserBaseId int64 `json:"userBaseId"`
BeginTime time.Time `json:"beginTime"`
EndTime time.Time `json:"endTime"`
}{}
if err := LoadQueryObject(queryOptions, &request); err != nil {
return nil, err
}
queryOptions = tool_funs.SimpleStructToMap(&request)
// 按关联相关人过滤
var contractNumbers []string
var err error
if request.UserId > 0 {
var retMap = make([]interface{}, 0)
contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"userId": request.UserId})
if len(contractNumbers) == 0 {
return retMap, nil
}
if err != nil {
return retMap, err
}
queryOptions["cooperationContractNumbers"] = contractNumbers
}
var dividends = &CreditAccountStatisticsResponse{}
var xAxisData []string
var values []float64
var queryItems []queryItem
if !request.BeginTime.IsZero() && request.BeginTime.AddDate(0, 3, 0).Before(request.EndTime) {
queryItems, xAxisData = histogramStatisticsByYear()
} else {
queryItems, xAxisData = histogramStatisticsByMonth()
}
for i := range queryItems {
item := queryItems[i]
if len(contractNumbers) == 0 && request.UserId > 0 { //没有相关的合约 查看分红预算单为空
continue
}
queryOptions["beginTime"] = item.BeginTime
queryOptions["endTime"] = item.EndTime
if err := creditAccountDao.DividendsStatistics(queryOptions, dividends); err != nil {
return nil, err
}
values = append(values, dividends.Paid)
}
return map[string]interface{}{
"xAxis": map[string]interface{}{
"data": xAxisData,
},
"source": map[string]interface{}{
"value": values,
},
}, nil
}
type queryItem struct {
BeginTime time.Time
EndTime time.Time
}
func histogramStatisticsByMonth() ([]queryItem, []string) {
ret := make([]queryItem, 0)
year, month := time.Now().Year(), time.Now().Month()
var beginTime = time.Date(year, month, 1, 0, 0, 0, 0, time.Local)
var endTime time.Time
var increaseDay = 5
var monthEnd = time.Date(year, month+1, 1, 0, 0, 0, 0, time.Local).Add(-time.Second)
var xAxisData []string
var values []float64
for {
if beginTime.AddDate(0, 0, increaseDay).After(monthEnd) {
endTime = monthEnd
... ... @@ -376,25 +441,30 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query
} else {
endTime = beginTime.AddDate(0, 0, increaseDay).Add(-time.Second)
}
xAxisData = append(xAxisData, endTime.Format("01-02"))
queryOptions["beginTime"] = beginTime
queryOptions["endTime"] = beginTime.AddDate(0, 0, increaseDay)
if err := creditAccountDao.DividendsStatistics(queryOptions, dividends); err != nil {
return nil, err
item := queryItem{
BeginTime: beginTime,
EndTime: beginTime.AddDate(0, 0, increaseDay).Add(-time.Second),
}
dividends.Accounting = dividends.Total - dividends.Accounted
values = append(values, dividends.Paid)
xAxisData = append(xAxisData, item.EndTime.Format("01-02"))
beginTime = endTime
if endTime == monthEnd {
break
}
ret = append(ret, item)
}
return map[string]interface{}{
"xAxis": map[string]interface{}{
"data": xAxisData,
},
"source": map[string]interface{}{
"value": values,
},
}, nil
return ret, xAxisData
}
func histogramStatisticsByYear() ([]queryItem, []string) {
ret := make([]queryItem, 0)
var xAxisData = []string{"3月", "6月", "9月", "12月"}
year, _ := time.Now().Year(), time.Now().Month()
var increase = 3
for i := 0; i < 4; i++ {
ret = append(ret, queryItem{
BeginTime: time.Date(year, time.Month(1+i*increase), 1, 0, 0, 0, 0, time.Local),
EndTime: time.Date(year, time.Month(1+(i+1)*increase), 1, 0, 0, 0, 0, time.Local),
})
}
return ret, xAxisData
}
... ...
... ... @@ -52,21 +52,15 @@ func (ptr *CooperationStatisticsService) cooperationCompanyStatistics(userBaseId
// 2.相关合约统计
cooperationContractRelevantRepository, _ := repository.NewCooperationContractRelevantRepository(ptr.transactionContext)
cooperationContractCount, _, err := cooperationContractRelevantRepository.Find(map[string]interface{}{"userBaseId": userBaseId,
cooperationContractCount, _, err := cooperationContractRelevantRepository.Find(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId,
"limit": 1})
if err != nil {
return nil, err
}
// 3.个人分红统计
type response struct {
Total float64 `json:"total"`
Accounting float64 `json:"accounting"`
Accounted float64 `json:"accounted"`
Paid float64 `json:"paid"`
}
creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
var allDividends = &response{}
var allDividends = &CreditAccountStatisticsResponse{}
if err := creditAccountDao.DividendsStatistics(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId}, allDividends); err != nil {
return nil, err
}
... ... @@ -76,7 +70,7 @@ func (ptr *CooperationStatisticsService) cooperationCompanyStatistics(userBaseId
OrgId: orgId,
CooperationProjectCount: cooperationProjectCount,
CooperationContractCount: cooperationContractCount,
DividendsIncome: utils.Round(allDividends.Total, 2),
DividendsIncome: utils.Round(allDividends.Accounted, 2),
}
return ret, nil
}
... ... @@ -105,7 +99,7 @@ func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(que
}
queryOptions = tool_funs.SimpleStructToMap(&request)
cooperationContractUndertaker, _ := repository.NewCooperationContractUndertakerRepository(ptr.transactionContext)
cooperationContractUndertaker, _ := repository.NewCooperationContractRelevantRepository(ptr.transactionContext)
_, contractUndertakers, err := cooperationContractUndertaker.Find(queryOptions)
if err != nil {
return nil, nil
... ...
package domain_service
import (
"encoding/json"
"fmt"
"github.com/go-pg/pg/v10"
pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
... ... @@ -48,6 +47,8 @@ const (
CreditAccountStatistics = "CreditAccountStatistics"
// 公司/个人 - 支付历史统计直方图
PaymentHistoryHistogramStatistics = "PaymentHistoryHistogramStatistics"
// 用户相关的项目合约编号列表查询
RelevantCooperationContractNumbers = "RelevantCooperationContractNumbers"
)
// CooperationStatisticsService 共创统计服务
... ... @@ -77,6 +78,7 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma
//企业
CompanyId int64 `json:"companyId"`
OrgId int64 `json:"orgId"`
UserId int64 `json:"userId"`
//个人
UserBaseId int64 `json:"userBaseId"`
Offset int `json:"offset"`
... ... @@ -90,11 +92,11 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma
// 1.根据个人、企业查询合约列表
var contracts []*domain.CooperationContract
var err error
if _, ok := queryOptions["userBaseId"]; ok {
contracts, err = ptr.getUserContracts(queryOptions)
} else if v, ok := queryOptions["orgId"]; ok {
queryOptions["orgId"], _ = (v.(json.Number)).Int64()
contracts, err = ptr.getCompanyContracts(queryOptions)
if request.UserBaseId > 0 {
contracts, err = ptr.getUserContracts(request.UserBaseId, queryOptions)
} else if request.OrgId > 0 {
queryOptions["orgId"] = request.OrgId
contracts, err = ptr.getCompanyContracts(request.UserId, queryOptions)
}
if err != nil {
return nil, err
... ... @@ -131,32 +133,59 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma
// getUserContracts 获取用户的合约列表
//
// p1 p1_desc
func (ptr *CooperationStatisticsService) getUserContracts(queryOptions map[string]interface{}) ([]*domain.CooperationContract, error) {
undertakerRepository, _ := repository.NewCooperationContractUndertakerRepository(ptr.transactionContext)
_, undertakers, err := undertakerRepository.Find(queryOptions)
var numbers []string
for i := range undertakers {
numbers = append(numbers, undertakers[i].CooperationContractNumber)
func (ptr *CooperationStatisticsService) getUserContracts(userBaseId int64, queryOptions map[string]interface{}) ([]*domain.CooperationContract, error) {
var contracts = make([]*domain.CooperationContract, 0)
if userBaseId == 0 {
return contracts, nil
}
if len(numbers) == 0 {
return []*domain.CooperationContract{}, nil
contractNumbers, err := ptr.getRelevantContracts(map[string]interface{}{"userBaseId": userBaseId})
if len(contractNumbers) == 0 {
return contracts, nil
}
queryOptions["inCooperationContractNumber"] = numbers
contractRepository, _ := repository.NewCooperationContractRepository(ptr.transactionContext)
_, contracts, err := contractRepository.Find(queryOptions)
if err != nil {
return contracts, err
}
queryOptions["cooperationContractNumbers"] = contractNumbers
contractRepository, _ := dao.NewCooperationContractDao(ptr.transactionContext)
_, contracts, err = contractRepository.Find(queryOptions)
return contracts, err
}
// getCompanyContracts 获取组织合约列表
//
// p1 p1_desc
func (ptr *CooperationStatisticsService) getCompanyContracts(queryOptions map[string]interface{}) ([]*domain.CooperationContract, error) {
contractRepository, _ := repository.NewCooperationContractRepository(ptr.transactionContext)
// TODO: 参数查询条件
_, contracts, err := contractRepository.Find(queryOptions)
func (ptr *CooperationStatisticsService) getCompanyContracts(userId int64, queryOptions map[string]interface{}) ([]*domain.CooperationContract, error) {
var contracts = make([]*domain.CooperationContract, 0)
if userId == 0 {
return contracts, nil
}
contractNumbers, err := ptr.getRelevantContracts(map[string]interface{}{"userId": userId})
if len(contractNumbers) == 0 {
return contracts, nil
}
if err != nil {
return contracts, err
}
queryOptions["cooperationContractNumbers"] = contractNumbers
contractRepository, _ := dao.NewCooperationContractDao(ptr.transactionContext)
_, contracts, err = contractRepository.Find(queryOptions)
return contracts, err
}
//getRelevantContracts 获取相关人的合约
func (ptr *CooperationStatisticsService) getRelevantContracts(queryOptions map[string]interface{}) ([]string, error) {
undertakerRepository, _ := repository.NewCooperationContractRelevantRepository(ptr.transactionContext)
_, undertakers, err := undertakerRepository.Find(queryOptions)
var numbers []string
for i := range undertakers {
numbers = append(numbers, undertakers[i].CooperationContractNumber)
}
if len(numbers) == 0 {
return []string{}, nil
}
return numbers, err
}
// getContractsDividendsEstimate 合约分红预算
func (ptr *CooperationStatisticsService) getContractsDividendsEstimate(numbers []string) (map[string]*domain.DividendsEstimate, error) {
var estimates []*domain.DividendsEstimate
... ... @@ -320,6 +349,7 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st
//企业
CompanyId int64 `json:"companyId"`
OrgId int64 `json:"orgId"`
UserId int64 `json:"userId"`
//个人
UserBaseId int64 `json:"userBaseId"`
}{}
... ... @@ -335,14 +365,32 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st
Paid float64 `json:"paid"`
}
creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
var contractNumbers []string
var err error
if request.OrgId > 0 && request.UserId > 0 {
contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"orgId": request.OrgId, "userId": request.UserId})
if err != nil {
return struct{}{}, err
}
} else if request.UserBaseId > 0 {
contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"orgId": request.OrgId, "userBaseId": request.UserBaseId})
if err != nil {
return struct{}{}, err
}
}
var allDividends = &response{}
queryOptions["cooperationContractNumbers"] = contractNumbers
var allDividends = &CreditAccountStatisticsResponse{}
var annualDividends = &CreditAccountStatisticsResponse{}
var quarterDividends = &CreditAccountStatisticsResponse{}
if len(contractNumbers) > 0 {
if err := creditAccountDao.DividendsStatistics(queryOptions, allDividends); err != nil {
return nil, err
}
allDividends.Accounting = allDividends.Total - allDividends.Accounted
var annualDividends = &response{}
queryOptions["beginTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local)
queryOptions["endTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local).AddDate(1, 0, 0)
if err := creditAccountDao.DividendsStatistics(queryOptions, annualDividends); err != nil {
... ... @@ -350,12 +398,12 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st
}
annualDividends.Accounting = annualDividends.Total - annualDividends.Accounted
var quarterDividends = &response{}
queryOptions["beginTime"], queryOptions["endTime"] = quarterBeginEnd()
if err := creditAccountDao.DividendsStatistics(queryOptions, quarterDividends); err != nil {
return nil, err
}
quarterDividends.Accounting = quarterDividends.Total - quarterDividends.Accounted
}
ret := map[string]interface{}{
"allDividends": allDividends,
... ... @@ -395,6 +443,8 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m
var request = struct {
CompanyId int64 `json:"companyId"`
OrgId int64 `json:"orgId"`
UserId int64 `json:"userId"`
UserBaseId int64 `json:"userBaseId"`
DividendsAccountStatus int32 `json:"dividendsAccountStatus"` // 分红结算状态
Offset int64 `json:"offset"`
... ... @@ -405,10 +455,18 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m
}
queryOptions = tool_funs.SimpleStructToMap(&request)
dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
_, estimates, err := dividendsEstimateRepository.Find(queryOptions)
var contractNumbers []string
var err error
if request.OrgId > 0 && request.UserId > 0 {
contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"orgId": request.OrgId, "userId": request.UserId})
if err != nil {
return nil, err
return struct{}{}, err
}
} else if request.UserBaseId > 0 {
contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"orgId": request.OrgId, "userBaseId": request.UserBaseId})
if err != nil {
return struct{}{}, err
}
}
type response struct {
// 承接人分红预算记录ID
... ... @@ -429,6 +487,18 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m
CustomerName string `json:"customerName"`
}
var results = make([]response, 0)
if len(contractNumbers) == 0 {
return results, nil
}
queryOptions["cooperationContractNumbers"] = contractNumbers
dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
_, estimates, err := dividendsEstimateRepository.Find(queryOptions)
if err != nil {
return nil, err
}
dividendsOrderRepository, _ := repository.NewDividendsOrderRepository(ptr.transactionContext)
dividendsReturnedOrderRepository, _ := repository.NewDividendsReturnedOrderRepository(ptr.transactionContext)
for i := range estimates {
... ... @@ -441,8 +511,11 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m
DividendsType: item.DividendsType,
DividendsUser: item.DividendsUser,
}
// TODO:优化查询 统一查询到map里面
if item.DividendsType == 1 {
order, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": item.OrderOrReturnedOrderNum})
order, err := dividendsOrderRepository.FindOne(map[string]interface{}{
"dividendsOrderNumber": item.OrderOrReturnedOrderNum,
})
if err != nil {
return nil, err
}
... ... @@ -469,6 +542,8 @@ func (ptr *CooperationStatisticsService) CreditAccountStatistics(queryOptions ma
UserBaseId int64 `json:"userBaseId"`
BeginTime time.Time `json:"beginTime"`
EndTime time.Time `json:"endTime"`
// 合约编号列表
CooperationContractNumbers []string `json:"cooperationContractNumbers"`
}{}
if err := LoadQueryObject(queryOptions, &request); err != nil {
return nil, err
... ... @@ -490,4 +565,26 @@ type CreditAccountStatisticsResponse struct {
Accounting float64 `json:"accounting"`
Accounted float64 `json:"accounted"`
Paid float64 `json:"paid"`
Unpaid float64 `json:"unpaid"`
}
//getRelevantContracts 获取相关人的合约
func (ptr *CooperationStatisticsService) RelevantCooperationContractNumbers(queryOptions map[string]interface{}) (interface{}, error) {
var request = struct {
//企业
CompanyId int64 `json:"companyId" valid:"Required"`
OrgId int64 `json:"orgId" valid:"Required"`
UserId int64 `json:"userId" valid:"Required"`
//个人
//UserBaseId int64 `json:"userBaseId"`
//Offset int `json:"offset"`
//Limit int `json:"limit"`
}{}
if err := LoadQueryObject(queryOptions, &request); err != nil {
return nil, err
}
queryOptions = tool_funs.SimpleStructToMap(&request)
contractNumbers, err := ptr.getRelevantContracts(queryOptions)
return contractNumbers, err
}
... ...
... ... @@ -172,6 +172,33 @@ func (service *UserService) OperatorFrom(companyId int64, orgId int64, userId in
}
}
// VisitorFrom 获取游客
func (service *UserService) VisitorFrom(companyId int64, orgId int64, userBaseId int64) (*domain.User, error) {
var returnData *domain.User
if userAdaptor, err := adaptor.NewUserAdaptor(); err != nil {
return nil, err
} else {
if visitor, err := userAdaptor.ToParticipator(companyId, orgId, userBaseId, "Visitor"); err != nil {
return nil, err
} else {
if visitor != nil {
log.Logger.Debug("游客", map[string]interface{}{
"visitor interface": visitor,
})
visitorJson, err1 := json.Marshal(visitor)
if err1 != nil {
return nil, err
}
err2 := json.Unmarshal(visitorJson, &returnData)
if err2 != nil {
return nil, err2
}
}
return returnData, nil
}
}
}
func NewUserService() (*UserService, error) {
return &UserService{}, nil
}
... ...
... ... @@ -17,6 +17,8 @@ type ContractUndertakerFeedback struct {
CooperationContractNumber string `comment:"共创合约编号"`
// 项目合约名称
CooperationContractName string `comment:"项目合约名称"`
// 模式名称
CooperationModeName string `comment:"模式名称"`
// 共创合约承接人
ContractUndertaker *domain.Undertaker `comment:"共创合约承接人"`
// 数据所属组织机构
... ...
... ... @@ -29,8 +29,8 @@ type CooperationApplication struct {
CooperationProjectNumber string `comment:"共创项目编号"`
// 数据所属组织机构
Org *domain.Org `comment:"数据所属组织机构"`
// 是否被取消标志位
IsCanceled bool `comment:"是否被取消标志位"`
// 是否被取消标志位 1正常,2取消
IsCanceled int32 `comment:"是否被取消标志位" pg:",default:1"`
// 公司
Company *domain.Company `comment:"公司"`
// 创建时间
... ...
... ... @@ -25,7 +25,7 @@ type CooperationContractByUndertaker struct {
Department *domain.Department `comment:"共创合约发起部门"`
// 组织机构
Org *domain.Org `comment:"组织机构"`
// 共创合约状态
// 共创合约状态 1正常,2关闭
ContractStatus int32 `comment:"共创合约状态"`
// 共创模式名称
CooperationModeName string `comment:"共创合约名称"`
... ...
... ... @@ -10,7 +10,7 @@ type DividendsOrder struct {
// 分红订单ID
DividendsOrderId int64 `comment:"分红订单ID" pg:",pk"`
// 分红订单号
DividendsOrderNumber string `comment:"分红订单号"`
DividendsOrderNumber string `comment:"分红订单号" pg:",unique"`
// 分红订单原单号
DividendsOriginalOrderNum string `comment:"分红订单原单号"`
// 分红订单金额
... ...
... ... @@ -13,7 +13,7 @@ type OrderGood struct {
// 订单产品单价
OrderGoodPrice float64 `comment:"订单产品单价"`
// 订单产品数量
OrderGoodQuantity int64 `comment:"订单产品数量"`
OrderGoodQuantity float64 `comment:"订单产品数量"`
// 关联分红订单号
DividendsOrderNumber string `comment:"关联分红订单号"`
// 关联的分红退货单号
... ...
... ... @@ -13,6 +13,7 @@ func TransformToContractUndertakerFeedbackDomainModelFromPgModels(
FeedbackContent: contractUndertakerFeedbackModel.FeedbackContent,
CooperationContractNumber: contractUndertakerFeedbackModel.CooperationContractNumber,
CooperationContractName: contractUndertakerFeedbackModel.CooperationContractName,
CooperationModeName: contractUndertakerFeedbackModel.CooperationModeName,
ContractUndertaker: contractUndertakerFeedbackModel.ContractUndertaker,
Org: contractUndertakerFeedbackModel.Org,
Company: contractUndertakerFeedbackModel.Company,
... ...
package transform
import (
"github.com/shopspring/decimal"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
)
... ... @@ -8,9 +9,10 @@ import (
func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *models.DividendsOrder, goods []*models.OrderGood) (*domain.DividendsOrder, error) {
var orderGoods []*domain.OrderGood
for _, good := range goods {
orderGoodAmount, _ := decimal.NewFromFloatWithExponent(good.OrderGoodAmount, -2).Float64()
orderGoods = append(orderGoods, &domain.OrderGood{
OrderGoodId: good.OrderGoodId,
OrderGoodAmount: good.OrderGoodAmount,
OrderGoodAmount: orderGoodAmount,
OrderGoodName: good.OrderGoodName,
OrderGoodPrice: good.OrderGoodPrice,
OrderGoodQuantity: good.OrderGoodQuantity,
... ... @@ -24,11 +26,12 @@ func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *model
UpdatedAt: good.UpdatedAt,
})
}
dividendsOrderAmount, _ := decimal.NewFromFloatWithExponent(dividendsOrderModel.DividendsOrderAmount, -2).Float64()
return &domain.DividendsOrder{
DividendsOrderId: dividendsOrderModel.DividendsOrderId,
DividendsOrderNumber: dividendsOrderModel.DividendsOrderNumber,
DividendsOriginalOrderNum: dividendsOrderModel.DividendsOriginalOrderNum,
DividendsOrderAmount: dividendsOrderModel.DividendsOrderAmount,
DividendsOrderAmount: dividendsOrderAmount,
OrderTime: dividendsOrderModel.OrderTime,
DividendTime: dividendsOrderModel.DividendTime,
DividendStatus: dividendsOrderModel.DividendStatus,
... ...
package transform
import (
"github.com/shopspring/decimal"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
)
... ... @@ -10,9 +11,10 @@ func TransformToDividendsReturnedOrderDomainModelFromPgModels(
goods []*models.OrderGood) (*domain.DividendsReturnedOrder, error) {
var orderGoods []*domain.OrderGood
for _, good := range goods {
orderGoodAmount, _ := decimal.NewFromFloatWithExponent(good.OrderGoodAmount, -2).Float64()
orderGoods = append(orderGoods, &domain.OrderGood{
OrderGoodId: good.OrderGoodId,
OrderGoodAmount: good.OrderGoodAmount,
OrderGoodAmount: orderGoodAmount,
OrderGoodName: good.OrderGoodName,
OrderGoodPrice: good.OrderGoodPrice,
OrderGoodQuantity: good.OrderGoodQuantity,
... ... @@ -26,10 +28,11 @@ func TransformToDividendsReturnedOrderDomainModelFromPgModels(
UpdatedAt: good.UpdatedAt,
})
}
dividendsReturnedOrderRefund, _ := decimal.NewFromFloatWithExponent(dividendsReturnedOrderModel.DividendsReturnedOrderRefund, -2).Float64()
return &domain.DividendsReturnedOrder{
DividendsReturnedOrderId: dividendsReturnedOrderModel.DividendsReturnedOrderId,
DividendsReturnedOrderNumber: dividendsReturnedOrderModel.DividendsReturnedOrderNumber,
DividendsReturnedOrderRefund: dividendsReturnedOrderModel.DividendsReturnedOrderRefund,
DividendsReturnedOrderRefund: dividendsReturnedOrderRefund,
OriginalOrderNum: dividendsReturnedOrderModel.OriginalOrderNum,
DividendsOrderNumber: dividendsReturnedOrderModel.DividendsOrderNumber,
DividendsReturnedCustomerName: dividendsReturnedOrderModel.DividendsReturnedCustomerName,
... ...
... ... @@ -15,14 +15,11 @@ import (
type ContractUndertakerFeedbackRepository struct {
transactionContext *pgTransaction.TransactionContext
IdWorker *snowflake.IdWorker
}
func (repository *ContractUndertakerFeedbackRepository) nextIdentify() (int64, error) {
IdWorker, err := snowflake.NewIdWorker(1)
if err != nil {
return 0, err
}
id, err := IdWorker.NextId()
id, err := repository.IdWorker.NextId()
return id, err
}
... ... @@ -33,6 +30,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
"feedback_content",
"cooperation_contract_number",
"cooperation_contract_name",
"cooperation_mode_name",
"contract_undertaker",
"org",
"company",
... ... @@ -60,6 +58,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
&contractUndertakerFeedback.FeedbackContent,
&contractUndertakerFeedback.CooperationContractNumber,
&contractUndertakerFeedback.CooperationContractName,
&contractUndertakerFeedback.CooperationModeName,
&contractUndertakerFeedback.ContractUndertaker,
&contractUndertakerFeedback.Org,
&contractUndertakerFeedback.Company,
... ... @@ -73,6 +72,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
contractUndertakerFeedback.FeedbackContent,
contractUndertakerFeedback.CooperationContractNumber,
contractUndertakerFeedback.CooperationContractName,
contractUndertakerFeedback.CooperationModeName,
contractUndertakerFeedback.ContractUndertaker,
contractUndertakerFeedback.Org,
contractUndertakerFeedback.Company,
... ... @@ -90,6 +90,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
&contractUndertakerFeedback.FeedbackContent,
&contractUndertakerFeedback.CooperationContractNumber,
&contractUndertakerFeedback.CooperationContractName,
&contractUndertakerFeedback.CooperationModeName,
&contractUndertakerFeedback.ContractUndertaker,
&contractUndertakerFeedback.Org,
&contractUndertakerFeedback.Company,
... ... @@ -103,6 +104,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
contractUndertakerFeedback.FeedbackContent,
contractUndertakerFeedback.CooperationContractNumber,
contractUndertakerFeedback.CooperationContractName,
contractUndertakerFeedback.CooperationModeName,
contractUndertakerFeedback.ContractUndertaker,
contractUndertakerFeedback.Org,
contractUndertakerFeedback.Company,
... ... @@ -134,7 +136,7 @@ func (repository *ContractUndertakerFeedbackRepository) FindOne(queryOptions map
query.SetWhereByQueryOption("contract_undertaker_feedback.feedback_id = ?", "contractUndertakerFeedbackId")
if err := query.First(); err != nil {
if err.Error() == "pg: no rows in result set" {
return nil, fmt.Errorf("没有此资源")
return nil, fmt.Errorf("承接人反馈信息不存在")
} else {
return nil, err
}
... ... @@ -202,8 +204,13 @@ func NewContractUndertakerFeedbackRepository(transactionContext *pgTransaction.T
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
} else {
idWorker, err := snowflake.NewIdWorker(1)
if err != nil {
return nil, err
}
return &ContractUndertakerFeedbackRepository{
transactionContext: transactionContext,
IdWorker: idWorker,
}, nil
}
}
... ...