作者 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 @@ -4,7 +4,7 @@ ENV APP_DIR $GOPATH/src/allied-creation-cooperation
4 RUN mkdir -p $APP_DIR 4 RUN mkdir -p $APP_DIR
5 WORKDIR $APP_DIR/ 5 WORKDIR $APP_DIR/
6 COPY ./pkg pkg 6 COPY ./pkg pkg
7 -# COPY ./conf conf 7 +COPY ./config config
8 COPY ./go.mod go.mod 8 COPY ./go.mod go.mod
9 COPY ./go.sum go.sum 9 COPY ./go.sum go.sum
10 COPY ./main.go main.go 10 COPY ./main.go main.go
  1 +-----BEGIN RSA PRIVATE KEY-----
  2 +MIIEpQIBAAKCAQEAy0OxRf+NheQG9epxbrudwnrzqVgqK5zCuRAkLUgaSMATVXEA
  3 +iDzJN39om+Q49MmtEk4pXGzKUyzkFJG96PA8tJq0E+bSDtSK3n+2mjZb6pChmgHw
  4 +KEX7T8ZVLqJBSrfrI4Z2BJDNEC+3wvVW3zpog1RlfKgft6NYUzNLUqE5Mxzq7lpD
  5 +eRsq+FhzM1sOeEb2dAmUlDDs+7HcR3Kj0ttKeg+hKqIottQ/H6Tq4c8deEQGnO0+
  6 +RN3CygyETbYmLuWttI/sUltulWJALIuU81Yr6uCOq5MSt2WsU8CTuhRwGXSvcQCO
  7 +FLYppYktoMDOGIBQffmJc/DdT1d35fvdpKbm+QIDAQABAoIBAQC8X7+qX2uI6gqJ
  8 +XPxC4x0RX2DxUAPE50KOv6bHUEsLoPZJ+K/Fko/oHuuTja47Lax3inhKb4gSDUhS
  9 +x754YivgNH8u8ns5wz/vc+yGflowyFj7oVAwAqslA2luDnD0Df6crcAx+wAQQCjN
  10 +RRF9T2QMUeq73BOI3Ji+gosLyN55vms2KadrwpPQwYN7qhdrerE7vPqCZeswzs1/
  11 +A5M9PVGBG+simNea5kv+tVJUdLi6ckGAB5KabyhpG779ckwzV/aZy3wIj4SvUvCd
  12 +bewH0xPHx5TqnMOXtzHgktClmL7hIYxy9sL14Dn0KVHbyolQ7IqmJtjXYqG84Fmx
  13 +AfyDfeABAoGBAPP820tKElrfTuZ+Z19kJBTp6I5iax2Ph10glUHLlLqJ82clI/Gl
  14 +CbMtnGmD72HfnJei82xqoVLsUkN9Sp+TSNJALh4N8rHkAtwq5kWToiAWZydwxVsp
  15 +x5OWEN3+QFIdjVW6fhg6jZSK5HHIqMdZOVvbfKP+Cv9fWWzlS7/WVTlJAoGBANVF
  16 +kol+KojM4DEASrw0s1mfPr0XvUFvKJ2TgVGR3HxAk4r0e0WwJdSfwGiB/ePcc6g5
  17 +D5dxBe8W5g3+V0DaC0f1DDNXg2MjYWoByWrurbm14FRnpMnx/UfZLo7rq8T9YrUT
  18 +Bd/y0/JasndN27bIfd60n233IYMqhV2+wBwqD3AxAoGAE2/wdHYJMk4Z9gjZ6WKL
  19 +8VKVIUq759X4XbXrzhsO1TGKP4xY6bZRKIIYtNs65dwvmHD13Yw9H+MNxqyjlkTg
  20 +h0dvpRtNW1ij1bBhOefCAbZnL2AviMyyRpKs81J/A0uxZ8P8qad4gf3ypxHqSD9W
  21 +b3fz3QivDZsl/6Pgvf6wOWkCgYEA1Cv9x5lj2WrxEu62axyG3P9nHBm055cdsf5g
  22 +JfVVg6t+3TuyM7c1O52efpnsKrdTvKTf1QrVG3INdxh0V4lUtcac16sVhBhbvml+
  23 +p0pCPMIrJe1ibKG5F7SB9B+TaEuo2nnNW2mp367JY5VqoyI8zsWk4nJ8vZAc1BGD
  24 +78EMUNECgYEAtV0pta3GuHKOLX1HMRsUsYuWjLqAbahnciF6MnjNWSonEK3VjMhI
  25 +g+krP/9sWoC3cFOG+4s96ubjDTWImvQvCrPaENdvlNwgp035bn51eFRv00QchM2H
  26 +VCS9Nhoqj5BIHl1G7Q13+tYTzjUWtteG902nWDVhgSlNLJf1rbTn34g=
  27 +-----END RSA PRIVATE KEY-----
  1 +-----BEGIN CERTIFICATE-----
  2 +MIIGazCCBVOgAwIBAgIQZBwijHoFToh2kjGwQ1E6bjANBgkqhkiG9w0BAQsFADBc
  3 +MQswCQYDVQQGEwJDTjEaMBgGA1UEChMRV29UcnVzIENBIExpbWl0ZWQxMTAvBgNV
  4 +BAMMKFdvVHJ1cyBPViBTZXJ2ZXIgQ0EgIFtSdW4gYnkgdGhlIElzc3Vlcl0wHhcN
  5 +MjEwMjA0MDAwMDAwWhcNMjIwMzA2MjM1OTU5WjCB0TELMAkGA1UEBhMCQ04xDzAN
  6 +BgNVBBETBjM1MDAxNTESMBAGA1UEBwwJ56aP5bee5biCMU8wTQYDVQQJDEbpqazl
  7 +sL7ljLrmuZbph4zot68yN+WPtzEj5qW85LqU5qW8NTEw44CBNTEx5a6k77yI6Ieq
  8 +6LS46K+V6aqM5Yy65YaF77yJMTAwLgYDVQQKDCfnpo/lu7rkubDkubDkubDkv6Hm
  9 +ga/np5HmioDmnInpmZDlhazlj7gxGjAYBgNVBAMMESouZmptYWltYWltYWkuY29t
  10 +MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAy0OxRf+NheQG9epxbrud
  11 +wnrzqVgqK5zCuRAkLUgaSMATVXEAiDzJN39om+Q49MmtEk4pXGzKUyzkFJG96PA8
  12 +tJq0E+bSDtSK3n+2mjZb6pChmgHwKEX7T8ZVLqJBSrfrI4Z2BJDNEC+3wvVW3zpo
  13 +g1RlfKgft6NYUzNLUqE5Mxzq7lpDeRsq+FhzM1sOeEb2dAmUlDDs+7HcR3Kj0ttK
  14 +eg+hKqIottQ/H6Tq4c8deEQGnO0+RN3CygyETbYmLuWttI/sUltulWJALIuU81Yr
  15 +6uCOq5MSt2WsU8CTuhRwGXSvcQCOFLYppYktoMDOGIBQffmJc/DdT1d35fvdpKbm
  16 ++QIDAQABo4ICsTCCAq0wHwYDVR0jBBgwFoAUDUmPFTN7wE+2+zo4Cfw0Fdpg3RQw
  17 +HQYDVR0OBBYEFMGZEgzwtp+UhpTAS9nmSxlo9tIlMA4GA1UdDwEB/wQEAwIFoDAM
  18 +BgNVHRMBAf8EAjAAMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcDAjBJBgNV
  19 +HSAEQjBAMDQGCysGAQQBsjEBAgIWMCUwIwYIKwYBBQUHAgEWF2h0dHBzOi8vc2Vj
  20 +dGlnby5jb20vQ1BTMAgGBmeBDAECAjA9BgNVHR8ENjA0MDKgMKAuhixodHRwOi8v
  21 +Y3JsLmNybG9jc3AuY24vV29UcnVzT1ZTZXJ2ZXJDQV8yLmNybDBsBggrBgEFBQcB
  22 +AQRgMF4wOAYIKwYBBQUHMAKGLGh0dHA6Ly9haWEuY3Jsb2NzcC5jbi9Xb1RydXNP
  23 +VlNlcnZlckNBXzIuY3J0MCIGCCsGAQUFBzABhhZodHRwOi8vb2NzcC5jcmxvY3Nw
  24 +LmNuMIIBBQYKKwYBBAHWeQIEAgSB9gSB8wDxAHcARqVV63X6kSAwtaKJafTzfREs
  25 +QXS+/Um4havy/HD+bUcAAAF3brV9qAAABAMASDBGAiEAjrXS+1JJW9jag/XfW+kY
  26 +oL4sGGDNvcZgV35E0EcGQVACIQCjQh8k5oSFtqo7Qrbx2k3OISjfPSYRXNNsG4Ba
  27 +MyDmRwB2AN+lXqtogk8fbK3uuF9OPlrqzaISpGpejjsSwCBEXCpzAAABd261fdAA
  28 +AAQDAEcwRQIgcPQQJ3rkCFaQPKwT3rtfQkr0taPzw0KW7yqu+MtmBH0CIQChKeMk
  29 +v7Xs0z7J47lM6HTPOU+xXL2riC69LC1KCOS6GTAtBgNVHREEJjAkghEqLmZqbWFp
  30 +bWFpbWFpLmNvbYIPZmptYWltYWltYWkuY29tMA0GCSqGSIb3DQEBCwUAA4IBAQBn
  31 ++jDy7sZS0gZzwMR4hnZHWqFYcJR3wnk77xr+5Yu2ifhlxaLHE3rEY3xTR9LsPwfW
  32 +pdg2McinPCI6vs009NYIpeTiHzVDPzKu2BaUfKj+EHLwZQGfXkNhp3cpqZMiTkr/
  33 +YNqf25GXsBa+spwzyHh9MBXXCfWRfdHX7JlH5zyoLNztTp8unxaRYldjghHDA3Q7
  34 +8Fyz6OncY3I4U4KKBSq2/TTxveDW6NxTTuJTPOg3/qSIkwdOBLuIzuhxmF4D9wpl
  35 +LMHmne2CilVeg73/GAzQt/w7FzmdvaHPAOVYWzdaTNALiXJxbi7EyO8q/uNK0GqY
  36 +hljMsnA1hApG+/2sOP/P
  37 +-----END CERTIFICATE-----
  38 +-----BEGIN CERTIFICATE-----
  39 +MIIF4TCCA8mgAwIBAgIQHQgpVDhMv3SvabmRFpvwLTANBgkqhkiG9w0BAQwFADCB
  40 +iDELMAkGA1UEBhMCVVMxEzARBgNVBAgTCk5ldyBKZXJzZXkxFDASBgNVBAcTC0pl
  41 +cnNleSBDaXR5MR4wHAYDVQQKExVUaGUgVVNFUlRSVVNUIE5ldHdvcmsxLjAsBgNV
  42 +BAMTJVVTRVJUcnVzdCBSU0EgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkwHhcNMjAw
  43 +MTA4MDAwMDAwWhcNMzAwMTA3MjM1OTU5WjBcMQswCQYDVQQGEwJDTjEaMBgGA1UE
  44 +ChMRV29UcnVzIENBIExpbWl0ZWQxMTAvBgNVBAMMKFdvVHJ1cyBPViBTZXJ2ZXIg
  45 +Q0EgIFtSdW4gYnkgdGhlIElzc3Vlcl0wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAw
  46 +ggEKAoIBAQCARFLq6kqQRZ4SdFMPdd3XJTcOdVVT5bvZZx0VVDrkw3TmSAloQVFf
  47 +RhqDOSXg4CsIaa64qFSrC3a5sc8LgRhx7AUdvoUdfvdxIY1uoyxRWpoWO8oTUkSn
  48 +EXjEPf+zrcU5cWTOi32xWL9vklYds7iOQwgsKAHDzt4an8MLGvcLxAHciyiKcDEh
  49 +HZOGUHO5bKaCq+kP2rJCfVSlNvdyl1B8q+aGWXoi0gXGVL7WX4pcWj+DGuITbLB2
  50 +MzMytse4MjLJ84zaXh0UD4STlyD8tu/fakdxIwQ7K3/pP3RoGj1R9CvMWXUU+fZm
  51 +KNLW5565hd9Bh3Wkz8b4ApgMD9o3RUjTAgMBAAGjggFwMIIBbDAfBgNVHSMEGDAW
  52 +gBRTeb9aqitKz1SA4dibwJ3ysgNmyzAdBgNVHQ4EFgQUDUmPFTN7wE+2+zo4Cfw0
  53 +Fdpg3RQwDgYDVR0PAQH/BAQDAgGGMBIGA1UdEwEB/wQIMAYBAf8CAQAwHQYDVR0l
  54 +BBYwFAYIKwYBBQUHAwEGCCsGAQUFBwMCMCIGA1UdIAQbMBkwDQYLKwYBBAGyMQEC
  55 +AhYwCAYGZ4EMAQICMFAGA1UdHwRJMEcwRaBDoEGGP2h0dHA6Ly9jcmwudXNlcnRy
  56 +dXN0LmNvbS9VU0VSVHJ1c3RSU0FDZXJ0aWZpY2F0aW9uQXV0aG9yaXR5LmNybDBx
  57 +BggrBgEFBQcBAQRlMGMwOgYIKwYBBQUHMAKGLmh0dHA6Ly9jcnQudXNlcnRydXN0
  58 +LmNvbS9VU0VSVHJ1c3RSU0FBQUFDQS5jcnQwJQYIKwYBBQUHMAGGGWh0dHA6Ly9v
  59 +Y3NwLnVzZXJ0cnVzdC5jb20wDQYJKoZIhvcNAQEMBQADggIBAA5G7XA+fNKyj7Fy
  60 +uotoII38/32eZ4UrC1vGFPEtDyd0yzOrr7SvQUoO2GLxFzIQ0SsgMNXJ4UAhMkTD
  61 +yz1OA0tx0g0GjOQXBGA/yfRR7SgitRJAdbqkPfppMn+dtKXCHHx35ohTL0PklRdb
  62 +mXacvR7rXUIiJMdsvZZqYwc+DpGJ+Zv0sRJZEL7pm1oZv6EV+UzjAlOnLe6yrnyD
  63 +c99Kk1H/RFPUzduUWjiVR2aMDT1oMiwYeB2Zq60Sb201jqZPNQj5E+TkDD5BPFVc
  64 +kLeRi3LyXBUuBvXPsdLtBNlr+LExtCDd66kjeUe2/YbTHF4ai5PZPraQxgbOJJyc
  65 +gizGl/JOgrIQPUOLSQvXlxpKEqS+0z6KqV52bco2PNrC0f8ILKuw0nsfhgcGy46d
  66 +Su8fmU9+FT6e61i2nteKvt8qkkSkAJKQxRUWYduN24mG/OOIkoeOPdYHi+qEfbyI
  67 +qxiiqcH9cZgLK9AVuJoKtt7vg21OyrWi7S5T/WbTfTz9XL7QGe8ZODZZx6d50uo/
  68 +lDOmXm3p/kdGApvUF1UrL+og22jBLi0Ns6xzCfzrI3SpC9abvU8E9EnxQABuu/gM
  69 +/B63dbaZzSsMVFxeECD9nMWv7IH+/rqyGmjqEJzgKdPGvXhqpebQ1HhWrV+j+ipc
  70 +jplXB1j3GCozDFsninXG102N6wC8
  71 +-----END CERTIFICATE-----
  72 +-----BEGIN CERTIFICATE-----
  73 +MIIFgTCCBGmgAwIBAgIQOXJEOvkit1HX02wQ3TE1lTANBgkqhkiG9w0BAQwFADB7
  74 +MQswCQYDVQQGEwJHQjEbMBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVyMRAwDgYD
  75 +VQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEhMB8GA1UE
  76 +AwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTE5MDMxMjAwMDAwMFoXDTI4
  77 +MTIzMTIzNTk1OVowgYgxCzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpOZXcgSmVyc2V5
  78 +MRQwEgYDVQQHEwtKZXJzZXkgQ2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBO
  79 +ZXR3b3JrMS4wLAYDVQQDEyVVU0VSVHJ1c3QgUlNBIENlcnRpZmljYXRpb24gQXV0
  80 +aG9yaXR5MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAgBJlFzYOw9sI
  81 +s9CsVw127c0n00ytUINh4qogTQktZAnczomfzD2p7PbPwdzx07HWezcoEStH2jnG
  82 +vDoZtF+mvX2do2NCtnbyqTsrkfjib9DsFiCQCT7i6HTJGLSR1GJk23+jBvGIGGqQ
  83 +Ijy8/hPwhxR79uQfjtTkUcYRZ0YIUcuGFFQ/vDP+fmyc/xadGL1RjjWmp2bIcmfb
  84 +IWax1Jt4A8BQOujM8Ny8nkz+rwWWNR9XWrf/zvk9tyy29lTdyOcSOk2uTIq3XJq0
  85 +tyA9yn8iNK5+O2hmAUTnAU5GU5szYPeUvlM3kHND8zLDU+/bqv50TmnHa4xgk97E
  86 +xwzf4TKuzJM7UXiVZ4vuPVb+DNBpDxsP8yUmazNt925H+nND5X4OpWaxKXwyhGNV
  87 +icQNwZNUMBkTrNN9N6frXTpsNVzbQdcS2qlJC9/YgIoJk2KOtWbPJYjNhLixP6Q5
  88 +D9kCnusSTJV882sFqV4Wg8y4Z+LoE53MW4LTTLPtW//e5XOsIzstAL81VXQJSdhJ
  89 +WBp/kjbmUZIO8yZ9HE0XvMnsQybQv0FfQKlERPSZ51eHnlAfV1SoPv10Yy+xUGUJ
  90 +5lhCLkMaTLTwJUdZ+gQek9QmRkpQgbLevni3/GcV4clXhB4PY9bpYrrWX1Uu6lzG
  91 +KAgEJTm4Diup8kyXHAc/DVL17e8vgg8CAwEAAaOB8jCB7zAfBgNVHSMEGDAWgBSg
  92 +EQojPpbxB+zirynvgqV/0DCktDAdBgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rID
  93 +ZsswDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0gBAowCDAG
  94 +BgRVHSAAMEMGA1UdHwQ8MDowOKA2oDSGMmh0dHA6Ly9jcmwuY29tb2RvY2EuY29t
  95 +L0FBQUNlcnRpZmljYXRlU2VydmljZXMuY3JsMDQGCCsGAQUFBwEBBCgwJjAkBggr
  96 +BgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29tMA0GCSqGSIb3DQEBDAUA
  97 +A4IBAQAYh1HcdCE9nIrgJ7cz0C7M7PDmy14R3iJvm3WOnnL+5Nb+qh+cli3vA0p+
  98 +rvSNb3I8QzvAP+u431yqqcau8vzY7qN7Q/aGNnwU4M309z/+3ri0ivCRlv79Q2R+
  99 +/czSAaF9ffgZGclCKxO/WIu6pKJmBHaIkU4MiRTOok3JMrO66BQavHHxW/BBC5gA
  100 +CiIDEOUMsfnNkjcZ7Tvx5Dq2+UUTJnWvu6rvP3t3O9LEApE9GQDTF1w52z97GA1F
  101 +zZOFli9d31kWTz9RvdVFGD/tSo7oBmF0Ixa1DVBzJ0RHfxBdiSprhTEUxOipakyA
  102 +vGp4z7h/jnZymQyd/teRCBaho1+V
  103 +-----END CERTIFICATE-----
@@ -54,10 +54,16 @@ spec: @@ -54,10 +54,16 @@ spec:
54 env: 54 env:
55 - name: LOG_LEVEL 55 - name: LOG_LEVEL
56 value: "debug" 56 value: "debug"
  57 + - name: LOG_FRAMEWORK
  58 + value: "beego"
  59 + - name: LOG_TYPE
  60 + value: "file"
57 - name: ERROR_BASE_CODE 61 - name: ERROR_BASE_CODE
58 value: "1" 62 value: "1"
59 - name: ERROR_BASE_CODE_MULTIPLE 63 - name: ERROR_BASE_CODE_MULTIPLE
60 value: "1000" 64 value: "1000"
  65 + - name: ENABLE_KAFKA_LOG
  66 + value: "false"
61 - name: USER_MODULE_HOST 67 - name: USER_MODULE_HOST
62 value: "http://allied-creation-user-dev.fjmaimaimai.com" 68 value: "http://allied-creation-user-dev.fjmaimaimai.com"
63 - name: REDIS_HOST 69 - name: REDIS_HOST
@@ -61,8 +61,7 @@ spec: @@ -61,8 +61,7 @@ spec:
61 - name: LOG_FRAMEWORK 61 - name: LOG_FRAMEWORK
62 value: "beego" 62 value: "beego"
63 - name: LOG_TYPE 63 - name: LOG_TYPE
64 - value: "file"  
65 - - name: ERROR_BASE_CODE 64 + value: "file" - name: ERROR_BASE_CODE
66 value: "1" 65 value: "1"
67 - name: ERROR_BASE_CODE_MULTIPLE 66 - name: ERROR_BASE_CODE_MULTIPLE
68 value: "1000" 67 value: "1000"
@@ -13,15 +13,15 @@ require ( @@ -13,15 +13,15 @@ require (
13 github.com/google/go-querystring v1.1.0 // indirect 13 github.com/google/go-querystring v1.1.0 // indirect
14 github.com/gorilla/websocket v1.4.2 // indirect 14 github.com/gorilla/websocket v1.4.2 // indirect
15 github.com/imkira/go-interpol v1.1.0 // indirect 15 github.com/imkira/go-interpol v1.1.0 // indirect
16 - github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect  
17 github.com/linmadan/egglib-go v0.0.0-20210527091316-06b0732fb5f6 16 github.com/linmadan/egglib-go v0.0.0-20210527091316-06b0732fb5f6
18 github.com/mattn/go-colorable v0.1.8 // indirect 17 github.com/mattn/go-colorable v0.1.8 // indirect
19 github.com/moul/http2curl v1.0.0 // indirect 18 github.com/moul/http2curl v1.0.0 // indirect
  19 + github.com/olivere/elastic/v7 v7.0.28
20 github.com/onsi/ginkgo v1.14.2 20 github.com/onsi/ginkgo v1.14.2
21 github.com/onsi/gomega v1.10.3 21 github.com/onsi/gomega v1.10.3
22 github.com/sergi/go-diff v1.2.0 // indirect 22 github.com/sergi/go-diff v1.2.0 // indirect
23 github.com/shopspring/decimal v1.2.0 23 github.com/shopspring/decimal v1.2.0
24 - github.com/sirupsen/logrus v1.8.1 // indirect 24 + github.com/sirupsen/logrus v1.8.1
25 github.com/smartystreets/goconvey v1.6.4 // indirect 25 github.com/smartystreets/goconvey v1.6.4 // indirect
26 github.com/valyala/fasthttp v1.28.0 // indirect 26 github.com/valyala/fasthttp v1.28.0 // indirect
27 github.com/xeipuuv/gojsonschema v1.2.0 // indirect 27 github.com/xeipuuv/gojsonschema v1.2.0 // indirect
@@ -29,4 +29,5 @@ require ( @@ -29,4 +29,5 @@ require (
29 github.com/yudai/gojsondiff v1.0.0 // indirect 29 github.com/yudai/gojsondiff v1.0.0 // indirect
30 github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect 30 github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
31 github.com/yudai/pp v2.0.1+incompatible // indirect 31 github.com/yudai/pp v2.0.1+incompatible // indirect
  32 + gopkg.in/sohlich/elogrus.v7 v7.0.0
32 ) 33 )
1 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= 1 cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
  2 +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
2 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= 3 github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
3 github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0= 4 github.com/Knetic/govaluate v3.0.0+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
  5 +github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
4 github.com/Shopify/sarama v1.25.0 h1:ch1ywjRLjfJtU+EaiJ+l0rWffQ6TRpyYmW4DX7Cb2SU= 6 github.com/Shopify/sarama v1.25.0 h1:ch1ywjRLjfJtU+EaiJ+l0rWffQ6TRpyYmW4DX7Cb2SU=
5 github.com/Shopify/sarama v1.25.0/go.mod h1:y/CFFTO9eaMTNriwu/Q+W4eioLqiDMGkA1W+gmdfj8w= 7 github.com/Shopify/sarama v1.25.0/go.mod h1:y/CFFTO9eaMTNriwu/Q+W4eioLqiDMGkA1W+gmdfj8w=
6 github.com/Shopify/toxiproxy v2.1.4+incompatible h1:TKdv8HiTLgE5wdJuEML90aBgNWsokNbMijUGhmcoBJc= 8 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 @@ -15,6 +17,9 @@ github.com/alicebob/gopher-json v0.0.0-20180125190556-5a6b3ba71ee6/go.mod h1:SGn
15 github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk= 17 github.com/alicebob/miniredis v2.5.0+incompatible/go.mod h1:8HZjEj4yU0dwhYHky+DxYx+6BMjkBbe5ONFIF1MXffk=
16 github.com/andybalholm/brotli v1.0.2 h1:JKnhI/XQ75uFBTiuzXpzFrUriDPiZjlOSzh6wXogP0E= 18 github.com/andybalholm/brotli v1.0.2 h1:JKnhI/XQ75uFBTiuzXpzFrUriDPiZjlOSzh6wXogP0E=
17 github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= 19 github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y=
  20 +github.com/apache/thrift v0.12.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ=
  21 +github.com/aws/aws-sdk-go v1.19.6/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo=
  22 +github.com/aws/aws-sdk-go v1.40.32/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q=
18 github.com/beego/beego/v2 v2.0.1 h1:07a7Z0Ok5vbqyqh+q53sDPl9LdhKh0ZDy3gbyGrhFnE= 23 github.com/beego/beego/v2 v2.0.1 h1:07a7Z0Ok5vbqyqh+q53sDPl9LdhKh0ZDy3gbyGrhFnE=
19 github.com/beego/beego/v2 v2.0.1/go.mod h1:8zyHi1FnWO1mZLwTn62aKRIZF/aIKvkCBB2JYs+eqQI= 24 github.com/beego/beego/v2 v2.0.1/go.mod h1:8zyHi1FnWO1mZLwTn62aKRIZF/aIKvkCBB2JYs+eqQI=
20 github.com/beego/goyaml2 v0.0.0-20130207012346-5545475820dd/go.mod h1:1b+Y/CofkYwXMUU0OhQqGvsY2Bvgr4j6jfT699wyZKQ= 25 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+ @@ -30,6 +35,7 @@ github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+
30 github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= 35 github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
31 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= 36 github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
32 github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= 37 github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
  38 +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
33 github.com/coreos/etcd v3.3.25+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= 39 github.com/coreos/etcd v3.3.25+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
34 github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= 40 github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
35 github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= 41 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 @@ -49,10 +55,13 @@ github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1
49 github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc= 55 github.com/eapache/queue v1.1.0 h1:YOEu7KNc61ntiQlcEeUIoDTJ2o8mQznoNvUhiigpIqc=
50 github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= 56 github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I=
51 github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M= 57 github.com/edsrzf/mmap-go v0.0.0-20170320065105-0bce6a688712/go.mod h1:YO35OhQPt3KJa3ryjFM5Bs14WD66h8eGKpfaBNrHW5M=
  58 +github.com/elastic/go-elasticsearch/v6 v6.8.5 h1:U2HtkBseC1FNBmDr0TR2tKltL6FxoY+niDAlj5M8TK8=
52 github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI= 59 github.com/elastic/go-elasticsearch/v6 v6.8.5/go.mod h1:UwaDJsD3rWLM5rKNFzv9hgox93HoX8utj1kxD9aFUcI=
53 github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk= 60 github.com/elazarl/go-bindata-assetfs v1.0.0 h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=
54 github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4= 61 github.com/elazarl/go-bindata-assetfs v1.0.0/go.mod h1:v+YaWX3bdea5J/mo8dSETolEo7R71Vk1u8bnjau5yw4=
  62 +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
55 github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= 63 github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
  64 +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
56 github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= 65 github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
57 github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 h1:DddqAaWDpywytcG8w/qoQ5sAN8X12d3Z3koB0C3Rxsc= 66 github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 h1:DddqAaWDpywytcG8w/qoQ5sAN8X12d3Z3koB0C3Rxsc=
58 github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8= 67 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 @@ -82,9 +91,12 @@ github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gG
82 github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg= 91 github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
83 github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= 92 github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
84 github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= 93 github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
  94 +github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
85 github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= 95 github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o=
86 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= 96 github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
  97 +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
87 github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= 98 github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
  99 +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
88 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 100 github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
89 github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 101 github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
90 github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= 102 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 @@ -109,21 +121,27 @@ github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMyw
109 github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 121 github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
110 github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 122 github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
111 github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 123 github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
112 -github.com/google/go-cmp v0.5.4 h1:L8R9j+yAqZuZjsqh/z+F1NCffTKKLShY6zXTItVIZ8M= 124 +github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
113 github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= 125 github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
  126 +github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
  127 +github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
114 github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= 128 github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
115 github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= 129 github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
116 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= 130 github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
117 github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= 131 github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
118 -github.com/google/uuid v1.1.1 h1:Gkbcsh/GbpXz7lPftLA3P6TYMwjCLYm83jiFQZF/3gY=  
119 github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= 132 github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
  133 +github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y=
  134 +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
120 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= 135 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=
121 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= 136 github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
  137 +github.com/gorilla/context v1.1.1/go.mod h1:kBGZzfjB9CEq2AlWe17Uuf7NDRt0dE0s8S51q0aT7Yg=
  138 +github.com/gorilla/mux v1.6.2/go.mod h1:1lud6UwP+6orDFRuTfBEV8e9/aOM/c4fVVCaMa2zaAs=
122 github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= 139 github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
123 github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= 140 github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
124 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= 141 github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk=
125 github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE= 142 github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1BE=
126 github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= 143 github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro=
  144 +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
127 github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= 145 github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
128 github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= 146 github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
129 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= 147 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 @@ -133,13 +151,16 @@ github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03 h1:FUwcHNlEqkqLjL
133 github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o= 151 github.com/jcmturner/gofork v0.0.0-20190328161633-dc7c13fece03/go.mod h1:MK8+TM0La+2rjBD4jE12Kj1pCCxK7d2LK/UM3ncEo0o=
134 github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= 152 github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
135 github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= 153 github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
  154 +github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
  155 +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
  156 +github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
  157 +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
  158 +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
136 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= 159 github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
137 github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= 160 github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
138 github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= 161 github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
139 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= 162 github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
140 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= 163 github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w=
141 -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 h1:uC1QfSlInpQF+M0ao65imhwqKnz3Q2z/d8PWZRMQvDM=  
142 -github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=  
143 github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= 164 github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
144 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= 165 github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
145 github.com/klauspost/compress v1.9.7/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A= 166 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= @@ -158,6 +179,10 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
158 github.com/linmadan/egglib-go v0.0.0-20210527091316-06b0732fb5f6 h1:nyhVnOIXsESuhZ95Ak6VRSF+0fHeKlYWq0EvHByt5RU= 179 github.com/linmadan/egglib-go v0.0.0-20210527091316-06b0732fb5f6 h1:nyhVnOIXsESuhZ95Ak6VRSF+0fHeKlYWq0EvHByt5RU=
159 github.com/linmadan/egglib-go v0.0.0-20210527091316-06b0732fb5f6/go.mod h1:ZZuSWicGxpgN0OulARhuKwFJuJ9we0otaPVAJtz10yk= 180 github.com/linmadan/egglib-go v0.0.0-20210527091316-06b0732fb5f6/go.mod h1:ZZuSWicGxpgN0OulARhuKwFJuJ9we0otaPVAJtz10yk=
160 github.com/magefile/mage v1.10.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= 181 github.com/magefile/mage v1.10.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A=
  182 +github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
  183 +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
  184 +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
  185 +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
161 github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8= 186 github.com/mattn/go-colorable v0.1.8 h1:c1ghPdyEDarC70ftn0y+A/Ee++9zz8ljHG1b13eJ0s8=
162 github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= 187 github.com/mattn/go-colorable v0.1.8/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
163 github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY= 188 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 @@ -179,21 +204,29 @@ github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWb
179 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= 204 github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
180 github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78= 205 github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
181 github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A= 206 github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
  207 +github.com/olivere/elastic/v7 v7.0.4/go.mod h1:l4YWa59iTCcOJQXI5ZtxVjcd3p5U8GCxVgvzHZqGn3o=
  208 +github.com/olivere/elastic/v7 v7.0.28 h1:KAP4EuaEcvPJknRNkAAso1xeu0C1+/CeDQsxj9Cw9Fg=
  209 +github.com/olivere/elastic/v7 v7.0.28/go.mod h1:DzHQoqd6YqSuvF1lk/fR4cW4FNUNzSD5/F5MBm3GRMo=
182 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 210 github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
  211 +github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
183 github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= 212 github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
184 github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg= 213 github.com/onsi/ginkgo v1.12.0/go.mod h1:oUhWkIvk5aDxtKvDDuw8gItl8pKl42LzjC9KZE0HfGg=
185 github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk= 214 github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
186 github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M= 215 github.com/onsi/ginkgo v1.14.2 h1:8mVmC9kjFFmA8H4pKMUhcblgifdkOIXPvbhN1T36q1M=
187 github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY= 216 github.com/onsi/ginkgo v1.14.2/go.mod h1:iSB4RoI2tjJc9BBv4NKIKWKya62Rps+oPG/Lv9klQyY=
  217 +github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
188 github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= 218 github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
189 github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY= 219 github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
190 github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo= 220 github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
191 github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA= 221 github.com/onsi/gomega v1.10.3 h1:gph6h/qe9GSUw1NhH1gp+qb+h8rXD8Cy60Z32Qw3ELA=
192 github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc= 222 github.com/onsi/gomega v1.10.3/go.mod h1:V9xEwhxec5O8UDM77eCW8vLymOMltsqPVYWrpDsH8xc=
  223 +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
193 github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= 224 github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc=
  225 +github.com/openzipkin/zipkin-go v0.1.6/go.mod h1:QgAqvLzwWbR/WpD4A3cGpPtJrZXNIiJc5AZX7/PBEpw=
194 github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= 226 github.com/pelletier/go-toml v1.0.1/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
195 github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc= 227 github.com/pelletier/go-toml v1.8.1/go.mod h1:T2/BmBdy8dvIRq1a/8aqjN41wvWlN4lrapLU/GW4pbc=
196 github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc= 228 github.com/peterh/liner v1.0.1-0.20171122030339-3681c2a91233/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
  229 +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
197 github.com/pierrec/lz4 v2.2.6+incompatible h1:6aCX4/YZ9v8q69hTyiR7dNLnTA3fgtKHVVW5BCd5Znw= 230 github.com/pierrec/lz4 v2.2.6+incompatible h1:6aCX4/YZ9v8q69hTyiR7dNLnTA3fgtKHVVW5BCd5Znw=
198 github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= 231 github.com/pierrec/lz4 v2.2.6+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
199 github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= 232 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 @@ -203,18 +236,22 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
203 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= 236 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
204 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= 237 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
205 github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= 238 github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
  239 +github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829/go.mod h1:p2iRAGwDERtqlqzRXnrOVns+ignqQo//hLXqYxZYVNs=
206 github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= 240 github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
207 github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U= 241 github.com/prometheus/client_golang v1.7.0 h1:wCi7urQOGBsYcQROHqpUUX4ct84xp40t9R9JX0FuA/U=
208 github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= 242 github.com/prometheus/client_golang v1.7.0/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M=
209 github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= 243 github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
  244 +github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
210 github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 245 github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
211 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 246 github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
212 github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= 247 github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M=
213 github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= 248 github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
  249 +github.com/prometheus/common v0.2.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
214 github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= 250 github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4=
215 github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc= 251 github.com/prometheus/common v0.10.0 h1:RyRA7RzGXQZiW+tGMr7sxa85G1z0yOpM1qq5c8lNawc=
216 github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= 252 github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo=
217 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= 253 github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
  254 +github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
218 github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= 255 github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA=
219 github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8= 256 github.com/prometheus/procfs v0.1.3 h1:F0+tqvhOksq22sc6iCHF5WGlWjdwj92p0udFh1VFBS8=
220 github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= 257 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 @@ -235,10 +272,13 @@ github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6Mwd
235 github.com/sirupsen/logrus v1.8.0/go.mod h1:4GuYW9TZmE769R5STWrRakJc4UqQ3+QQ95fyz7ENv1A= 272 github.com/sirupsen/logrus v1.8.0/go.mod h1:4GuYW9TZmE769R5STWrRakJc4UqQ3+QQ95fyz7ENv1A=
236 github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= 273 github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
237 github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= 274 github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
238 -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykElWQ6/NYmHa3jpm/yHnI4xSofP+UP6SpjHcSeM=  
239 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= 275 github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
  276 +github.com/smartystreets/assertions v1.1.1 h1:T/YLemO5Yp7KPzS+lVtu+WsHn8yoSwTfItdAd1r3cck=
  277 +github.com/smartystreets/assertions v1.1.1/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo=
  278 +github.com/smartystreets/go-aws-auth v0.0.0-20180515143844-0c1422d1fdb9/go.mod h1:SnhjPscd9TpLiy1LpzGSKh3bXCfxxXuqd9xmQJy3slM=
240 github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s= 279 github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
241 github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= 280 github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
  281 +github.com/smartystreets/gunit v1.4.2/go.mod h1:ZjM1ozSIMJlAz/ay4SG8PeKF00ckUp+zMHZXV9/bvak=
242 github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE= 282 github.com/ssdb/gossdb v0.0.0-20180723034631-88f6b59b84ec/go.mod h1:QBvMkMya+gXctz3kmljlUCu/yB3GZ6oee+dUozsezQE=
243 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 283 github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
244 github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= 284 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 @@ -287,6 +327,8 @@ github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZ
287 github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= 327 github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
288 github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU= 328 github.com/yuin/gopher-lua v0.0.0-20171031051903-609c9cd26973/go.mod h1:aEV29XrmTYFr3CiRxZeGHpkvbwq+prZduBqMaascyCU=
289 go.etcd.io/etcd v3.3.25+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI= 329 go.etcd.io/etcd v3.3.25+incompatible/go.mod h1:yaeTdrJi5lOmYerz05bd8+V7KubZs8YSFZfzsF9A6aI=
  330 +go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
  331 +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E=
290 go.opentelemetry.io/otel v0.17.0 h1:6MKOu8WY4hmfpQ4oQn34u6rYhnf2sWf1LXYO/UFm71U= 332 go.opentelemetry.io/otel v0.17.0 h1:6MKOu8WY4hmfpQ4oQn34u6rYhnf2sWf1LXYO/UFm71U=
291 go.opentelemetry.io/otel v0.17.0/go.mod h1:Oqtdxmf7UtEvL037ohlgnaYa1h7GtMh0NcSd9eqkC9s= 333 go.opentelemetry.io/otel v0.17.0/go.mod h1:Oqtdxmf7UtEvL037ohlgnaYa1h7GtMh0NcSd9eqkC9s=
292 go.opentelemetry.io/otel/metric v0.17.0 h1:t+5EioN8YFXQ2EH+1j6FHCKMUj+57zIDSnSGr/mWuug= 334 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 @@ -312,6 +354,7 @@ golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5
312 golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= 354 golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
313 golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= 355 golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
314 golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= 356 golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
  357 +golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
315 golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 358 golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
316 golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= 359 golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
317 golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= 360 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 @@ -323,6 +366,8 @@ golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73r
323 golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 366 golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
324 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 367 golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
325 golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 368 golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
  369 +golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
  370 +golang.org/x/net v0.0.0-20190125091013-d26f9f9a57f3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
326 golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= 371 golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
327 golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 372 golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
328 golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= 373 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 @@ -334,12 +379,15 @@ golang.org/x/net v0.0.0-20201006153459-a7d1128ccaa0/go.mod h1:sp8m0HH+o8qH0wwXwY
334 golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 379 golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
335 golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= 380 golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
336 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= 381 golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
337 -golang.org/x/net v0.0.0-20210510120150-4163338589ed h1:p9UgmWI9wKpfYmgaV/IZKGdXc5qEK45tDwwwDyjS26I=  
338 golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= 382 golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
  383 +golang.org/x/net v0.0.0-20210614182718-04defd469f4e h1:XpT3nA5TvE525Ne3hInMh6+GETgn27Zfm9dxsThnX2Q=
  384 +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
339 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= 385 golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
  386 +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
340 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 387 golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
341 golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 388 golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
342 golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 389 golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
  390 +golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
343 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 391 golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
344 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 392 golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
345 golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= 393 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 @@ -347,6 +395,7 @@ golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5h
347 golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 395 golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
348 golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 396 golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
349 golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 397 golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
  398 +golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
350 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= 399 golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
351 golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 400 golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
352 golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= 401 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= @@ -375,11 +424,13 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
375 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 424 golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
376 golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M= 425 golang.org/x/text v0.3.6 h1:aRYxNxv6iGQlyVaZmk6ZgYEDa+Jg18DxebPSrd6bg1M=
377 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= 426 golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
  427 +golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
378 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 428 golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
379 golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 429 golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
380 golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= 430 golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
381 golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= 431 golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
382 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 432 golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
  433 +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
383 golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= 434 golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
384 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= 435 golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
385 golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= 436 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 @@ -395,15 +446,20 @@ golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8T
395 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 446 golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
396 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE= 447 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
397 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= 448 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
  449 +google.golang.org/api v0.3.1/go.mod h1:6wY9I6uQWHQ8EM57III9mq/AjF+i8G65rmVagqKMtkk=
398 google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= 450 google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
399 google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= 451 google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
400 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= 452 google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
  453 +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
401 google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= 454 google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
402 google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= 455 google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
  456 +google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
403 google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= 457 google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
404 google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= 458 google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
  459 +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
405 google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 460 google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
406 google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= 461 google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
  462 +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
407 google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= 463 google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
408 google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= 464 google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
409 google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= 465 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 @@ -433,6 +489,8 @@ gopkg.in/jcmturner/gokrb5.v7 v7.2.3/go.mod h1:l8VISx+WGYp+Fp7KRbsiUuXTTOnxIc3Tuv
433 gopkg.in/jcmturner/rpc.v1 v1.1.0 h1:QHIUxTX1ISuAv9dD2wJ9HWQVuWDX/Zc0PfeC2tjc4rU= 489 gopkg.in/jcmturner/rpc.v1 v1.1.0 h1:QHIUxTX1ISuAv9dD2wJ9HWQVuWDX/Zc0PfeC2tjc4rU=
434 gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8= 490 gopkg.in/jcmturner/rpc.v1 v1.1.0/go.mod h1:YIdkC4XfD6GXbzje11McwsDuOlZQSb9W4vfLvuNnlv8=
435 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA= 491 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22/go.mod h1:yeKp02qBN3iKW1OzL3MGk2IdtZzaj7SFntXj72NppTA=
  492 +gopkg.in/sohlich/elogrus.v7 v7.0.0 h1:w4pw1DTXK/bqliKbcJk7hSXKrMM/jPdvpaROC9WSK+8=
  493 +gopkg.in/sohlich/elogrus.v7 v7.0.0/go.mod h1:nGmb0kLyAPGwIHLpHNlMlz0l0OfSaFatKgfpuO/+fnY=
436 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= 494 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
437 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= 495 gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
438 gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 496 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= @@ -444,6 +502,7 @@ gopkg.in/yaml.v2 v2.3.0 h1:clyUAQHOM3G0M3f5vQj7LuJrETvjVot3Z5el9nffUtU=
444 gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= 502 gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
445 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= 503 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
446 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= 504 gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
  505 +honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
447 honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 506 honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
448 honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= 507 honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
449 honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= 508 honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
1 package main 1 package main
2 2
3 import ( 3 import (
  4 + "fmt"
4 "github.com/beego/beego/v2/server/web" 5 "github.com/beego/beego/v2/server/web"
  6 + "github.com/linmadan/egglib-go/log/logrus"
  7 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant"
  8 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/constant"
5 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg" 9 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
  11 + _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
6 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego" 12 _ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/port/beego"
7 ) 13 )
8 14
9 func main() { 15 func main() {
10 // web主服务 16 // web主服务
  17 + if constant.ENABLE_KAFKA_LOG {
  18 + w, err := logrus.NewKafkaWriter(constant.KAFKA_HOSTS, constant.TOPIC_LOG_STASH, false)
  19 + if err != nil {
  20 + log.Logger.Error(err.Error())
  21 + }
  22 + log.Logger.AddHook(w)
  23 + }
  24 +
  25 + fmt.Printf("Server running at:%d\n", web.BConfig.Listen.HTTPPort)
  26 +
11 web.Run() 27 web.Run()
12 } 28 }
不能预览此文件类型
@@ -10,15 +10,15 @@ import ( @@ -10,15 +10,15 @@ import (
10 10
11 type ApplyForCooperationCommand struct { 11 type ApplyForCooperationCommand struct {
12 // 共创申请描述附件 12 // 共创申请描述附件
13 - CooperationApplicationAttachment []*domain.Attachment `cname:"共创申请描述附件" json:"cooperationApplicationAttachment" valid:"Required"` 13 + CooperationApplicationAttachment []*domain.Attachment `cname:"共创申请描述附件" json:"cooperationApplicationAttachment"`
14 // 共创申请描述 14 // 共创申请描述
15 CooperationApplicationDescription string `cname:"共创申请描述" json:"cooperationApplicationDescription,omitempty"` 15 CooperationApplicationDescription string `cname:"共创申请描述" json:"cooperationApplicationDescription,omitempty"`
16 // 申请人ID 16 // 申请人ID
17 - UserId int64 `cname:"申请人ID" json:"userId" valid:"Required"` 17 + UserId int64 `cname:"申请人ID" json:"userId"`
18 // 用户基本id 18 // 用户基本id
19 - UserBaseId int64 `cname:"用户基本数据ID" json:"userBaseId" valid:"Required"` 19 + UserBaseId int64 `cname:"用户基本数据ID" json:"userBaseId"`
20 // 组织机构ID 20 // 组织机构ID
21 - OrgId int64 `cname:"组织机构ID" json:"orgId" valid:"Required"` 21 + OrgId int64 `cname:"组织机构ID" json:"orgId"`
22 // 公司ID,通过集成REST上下文获取 22 // 公司ID,通过集成REST上下文获取
23 CompanyId int64 `cname:"公司ID" json:"companyId"` 23 CompanyId int64 `cname:"公司ID" json:"companyId"`
24 // 共创项目ID 24 // 共创项目ID
@@ -26,7 +26,6 @@ type ApplyForCooperationCommand struct { @@ -26,7 +26,6 @@ type ApplyForCooperationCommand struct {
26 } 26 }
27 27
28 func (applyForCooperationCommand *ApplyForCooperationCommand) Valid(validation *validation.Validation) { 28 func (applyForCooperationCommand *ApplyForCooperationCommand) Valid(validation *validation.Validation) {
29 - //validation.SetError("CustomValid", "未实现的自定义认证")  
30 } 29 }
31 30
32 func (applyForCooperationCommand *ApplyForCooperationCommand) ValidateCommand() error { 31 func (applyForCooperationCommand *ApplyForCooperationCommand) ValidateCommand() error {
@@ -98,7 +98,11 @@ func (data *CooperationApplicationDto) LoadDto(a *domain.CooperationApplication) @@ -98,7 +98,11 @@ func (data *CooperationApplicationDto) LoadDto(a *domain.CooperationApplication)
98 data.CooperationApplyTime = a.CooperationApplyTime.Unix() * 1000 98 data.CooperationApplyTime = a.CooperationApplyTime.Unix() * 1000
99 data.CooperationProject = data.LoadCooperationProject(a.CooperationProject) 99 data.CooperationProject = data.LoadCooperationProject(a.CooperationProject)
100 data.Org = data.LoadOrg(a.Org) 100 data.Org = data.LoadOrg(a.Org)
101 - data.IsCanceled = a.IsCanceled 101 + if a.IsCanceled == 1 {
  102 + data.IsCanceled = false
  103 + } else {
  104 + data.IsCanceled = true
  105 + }
102 data.Company = data.LoadCompany(a.Company) 106 data.Company = data.LoadCompany(a.Company)
103 } 107 }
104 108
@@ -17,6 +17,8 @@ type SearchCooperationApplicationQuery struct { @@ -17,6 +17,8 @@ type SearchCooperationApplicationQuery struct {
17 ApplicantName string `cname:"申请人姓名" json:"applicantName,omitempty"` 17 ApplicantName string `cname:"申请人姓名" json:"applicantName,omitempty"`
18 // 共创申请审核状态,1待审核,2已同意,3已拒绝 18 // 共创申请审核状态,1待审核,2已同意,3已拒绝
19 CooperationApplicationStatus int32 `cname:"共创申请审核状态" json:"cooperationApplicationStatus,omitempty"` 19 CooperationApplicationStatus int32 `cname:"共创申请审核状态" json:"cooperationApplicationStatus,omitempty"`
  20 + // 是否被取消标记 1正常,2取消,3所有
  21 + IsCanceled int32 `cname:"取消状态" json:"isCanceled,omitempty"`
20 // 页面大小 22 // 页面大小
21 PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"` 23 PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
22 // 页面大小 24 // 页面大小
@@ -10,6 +10,7 @@ import ( @@ -10,6 +10,7 @@ import (
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" 12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
  13 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" 14 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
14 "strconv" 15 "strconv"
15 "time" 16 "time"
@@ -45,6 +46,50 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -45,6 +46,50 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
45 cooperationProjectRepository = value 46 cooperationProjectRepository = value
46 } 47 }
47 48
  49 + // 用户REST服务初始化
  50 + var userService service.UserService
  51 + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
  52 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  53 + } else {
  54 + userService = value
  55 + }
  56 +
  57 + // 公司REST服务初始化
  58 + var companyService service.CompanyService
  59 + if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {
  60 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  61 + } else {
  62 + companyService = value
  63 + }
  64 +
  65 + // 组织机构REST服务初始化
  66 + var organizationService service.OrgService
  67 + if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {
  68 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  69 + } else {
  70 + organizationService = value
  71 + }
  72 +
  73 + // 共创申请仓储初始化
  74 + var cooperationApplicationRepository domain.CooperationApplicationRepository
  75 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  76 + "transactionContext": transactionContext,
  77 + }); err != nil {
  78 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  79 + } else {
  80 + cooperationApplicationRepository = value
  81 + }
  82 +
  83 + // 共创申请DAO初始化
  84 + var cooperationApplicationDao *dao.CooperationApplicationDao
  85 + if value, err := factory.CreateCooperationApplicationDao(map[string]interface{}{
  86 + "transactionContext": transactionContext,
  87 + }); err != nil {
  88 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  89 + } else {
  90 + cooperationApplicationDao = value
  91 + }
  92 +
48 // 获取共创项目 93 // 获取共创项目
49 cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": applyForCooperationCommand.CooperationProjectId}) 94 cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": applyForCooperationCommand.CooperationProjectId})
50 if err != nil { 95 if err != nil {
@@ -54,14 +99,53 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -54,14 +99,53 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
54 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(applyForCooperationCommand.CooperationProjectId, 10))) 99 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(applyForCooperationCommand.CooperationProjectId, 10)))
55 } 100 }
56 101
57 - // 用户REST服务初始化  
58 - var userService service.UserService  
59 - if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {  
60 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 102 + var newCooperationApplication *domain.CooperationApplication
  103 +
  104 + if applyForCooperationCommand.CompanyId == 0 && applyForCooperationCommand.OrgId == 0 && applyForCooperationCommand.UserId == 0 && applyForCooperationCommand.UserBaseId != 0 { // 游客操作
  105 + // 获取申请人信息
  106 + var applicant *domain.User
  107 + if data, err := userService.VisitorFrom(applyForCooperationCommand.CompanyId, applyForCooperationCommand.OrgId, applyForCooperationCommand.UserBaseId); err != nil {
  108 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取申请人失败")
61 } else { 109 } else {
62 - userService = value 110 + applicant = data
  111 + }
  112 +
  113 + // 校验:同一个用户,不能多次申请同一个项目
  114 + applicationExist, _ := cooperationApplicationDao.CheckApplicationExist(map[string]interface{}{
  115 + "visitorUserBaseId": applicant.UserBaseId,
  116 + "companyId": cooperationProject.Company.CompanyId,
  117 + "orgId": cooperationProject.Org.OrgId,
  118 + "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
  119 + })
  120 + if applicationExist {
  121 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "抱歉,您已经申请过该项目")
  122 + }
  123 +
  124 + // 校验:判断用户类型是否属于承接对象
  125 + if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, 4) { // 非公开类型校验
  126 + if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType) {
  127 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
  128 + }
63 } 129 }
64 130
  131 + newCooperationApplication = &domain.CooperationApplication{
  132 + CooperationApplicationApplicant: applicant,
  133 + CooperationApplicationAttachment: applyForCooperationCommand.CooperationApplicationAttachment,
  134 + CooperationApplicationDescription: applyForCooperationCommand.CooperationApplicationDescription,
  135 + CooperationApplicationStatus: 1,
  136 + CooperationApplicationVerifier: nil,
  137 + CooperationApplicationVerifyDescription: "",
  138 + CooperationApplicationVerifyTime: time.Time{},
  139 + CooperationApplyTime: time.Now(),
  140 + CooperationProject: cooperationProject,
  141 + Org: cooperationProject.Org,
  142 + IsCanceled: 1,
  143 + Company: cooperationProject.Company,
  144 + CreatedAt: time.Now(),
  145 + DeletedAt: time.Time{},
  146 + UpdatedAt: time.Time{},
  147 + }
  148 + } else {
65 // 获取申请人 149 // 获取申请人
66 var applicant *domain.User 150 var applicant *domain.User
67 if data, err := userService.UserFrom(applyForCooperationCommand.CompanyId, applyForCooperationCommand.OrgId, applyForCooperationCommand.UserId); err != nil { 151 if data, err := userService.UserFrom(applyForCooperationCommand.CompanyId, applyForCooperationCommand.OrgId, applyForCooperationCommand.UserId); err != nil {
@@ -70,14 +154,6 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -70,14 +154,6 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
70 applicant = data 154 applicant = data
71 } 155 }
72 156
73 - // 公司REST服务初始化  
74 - var companyService service.CompanyService  
75 - if value, err := factory.CreateCompanyService(map[string]interface{}{}); err != nil {  
76 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
77 - } else {  
78 - companyService = value  
79 - }  
80 -  
81 // 获取公司信息 157 // 获取公司信息
82 var company *domain.Company 158 var company *domain.Company
83 if data, err := companyService.CompanyFrom(applyForCooperationCommand.CompanyId); err != nil { 159 if data, err := companyService.CompanyFrom(applyForCooperationCommand.CompanyId); err != nil {
@@ -86,14 +162,6 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -86,14 +162,6 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
86 company = data 162 company = data
87 } 163 }
88 164
89 - // 组织机构REST服务初始化  
90 - var organizationService service.OrgService  
91 - if value, err := factory.CreateOrganizationService(map[string]interface{}{}); err != nil {  
92 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
93 - } else {  
94 - organizationService = value  
95 - }  
96 -  
97 // 获取组织机构信息 165 // 获取组织机构信息
98 var organization *domain.Org 166 var organization *domain.Org
99 if data, err := organizationService.OrgFrom(applyForCooperationCommand.CompanyId, applyForCooperationCommand.OrgId); err != nil { 167 if data, err := organizationService.OrgFrom(applyForCooperationCommand.CompanyId, applyForCooperationCommand.OrgId); err != nil {
@@ -102,7 +170,23 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -102,7 +170,23 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
102 organization = data 170 organization = data
103 } 171 }
104 172
105 - newCooperationApplication := &domain.CooperationApplication{ 173 + // 校验:同一个用户,不能多次申请同一个项目
  174 + applicationExist, _ := cooperationApplicationDao.CheckApplicationExist(map[string]interface{}{
  175 + "companyId": applyForCooperationCommand.CompanyId,
  176 + "orgId": applyForCooperationCommand.OrgId,
  177 + "applicantId": applicant.UserId,
  178 + "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
  179 + })
  180 + if applicationExist {
  181 + return nil, application.ThrowError(application.TRANSACTION_ERROR, "抱歉,您已经申请过该项目")
  182 + }
  183 +
  184 + // 校验:判断用户类型是否属于承接对象
  185 + if !utils.IsContain(cooperationProject.CooperationProjectUndertakerTypes, applicant.UserType) {
  186 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
  187 + }
  188 +
  189 + newCooperationApplication = &domain.CooperationApplication{
106 CooperationApplicationApplicant: applicant, 190 CooperationApplicationApplicant: applicant,
107 CooperationApplicationAttachment: applyForCooperationCommand.CooperationApplicationAttachment, 191 CooperationApplicationAttachment: applyForCooperationCommand.CooperationApplicationAttachment,
108 CooperationApplicationDescription: applyForCooperationCommand.CooperationApplicationDescription, 192 CooperationApplicationDescription: applyForCooperationCommand.CooperationApplicationDescription,
@@ -113,24 +197,23 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -113,24 +197,23 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
113 CooperationApplyTime: time.Now(), 197 CooperationApplyTime: time.Now(),
114 CooperationProject: cooperationProject, 198 CooperationProject: cooperationProject,
115 Org: organization, 199 Org: organization,
116 - IsCanceled: false, 200 + IsCanceled: 1,
117 Company: company, 201 Company: company,
118 CreatedAt: time.Now(), 202 CreatedAt: time.Now(),
119 DeletedAt: time.Time{}, 203 DeletedAt: time.Time{},
120 UpdatedAt: time.Time{}, 204 UpdatedAt: time.Time{},
121 } 205 }
122 -  
123 - var cooperationApplicationRepository domain.CooperationApplicationRepository  
124 - if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{  
125 - "transactionContext": transactionContext,  
126 - }); err != nil {  
127 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
128 - } else {  
129 - cooperationApplicationRepository = value  
130 } 206 }
  207 +
  208 + // 保存共创申请
131 if cooperationApplication, err := cooperationApplicationRepository.Save(newCooperationApplication); err != nil { 209 if cooperationApplication, err := cooperationApplicationRepository.Save(newCooperationApplication); err != nil {
132 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 210 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
133 } else { 211 } else {
  212 + // 更新共创项目申请人计数
  213 + cooperationProject.ApplicantCount = cooperationProject.ApplicantCount + 1
  214 + if _, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
  215 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  216 + }
134 if err := transactionContext.CommitTransaction(); err != nil { 217 if err := transactionContext.CommitTransaction(); err != nil {
135 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 218 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
136 } 219 }
@@ -195,6 +278,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApprovalCoop @@ -195,6 +278,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApprovalCoop
195 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10))) 278 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10)))
196 } 279 }
197 280
  281 + // 校验共创申请是否已经审核过
  282 + if cooperationApplication.CooperationApplicationStatus != 1 {
  283 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "改申请已经审核过")
  284 + }
  285 +
198 if approvalCooperationApplicationCommand.Action == 1 { 286 if approvalCooperationApplicationCommand.Action == 1 {
199 cooperationApplication.CooperationApplicationStatus = 2 287 cooperationApplication.CooperationApplicationStatus = 2
200 } else if approvalCooperationApplicationCommand.Action == 2 { 288 } else if approvalCooperationApplicationCommand.Action == 2 {
@@ -272,7 +360,12 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova @@ -272,7 +360,12 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova
272 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 360 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
273 } else { 361 } else {
274 if count > 0 { 362 if count > 0 {
275 - for i, _ := range cooperationApplications { 363 + for i, cooperationApplication := range cooperationApplications {
  364 + // 校验共创申请是否已经审核过
  365 + if cooperationApplication.CooperationApplicationStatus != 1 {
  366 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "改申请已经审核过")
  367 + }
  368 + // 更新共创申请数据
276 cooperationApplications[i].CooperationApplicationVerifyDescription = batchApprovalCooperationApplicationCommand.CooperationApplicationVerifyDescription 369 cooperationApplications[i].CooperationApplicationVerifyDescription = batchApprovalCooperationApplicationCommand.CooperationApplicationVerifyDescription
277 if batchApprovalCooperationApplicationCommand.Action == 1 { // 同意 370 if batchApprovalCooperationApplicationCommand.Action == 1 { // 同意
278 cooperationApplications[i].CooperationApplicationStatus = 2 371 cooperationApplications[i].CooperationApplicationStatus = 2
@@ -281,6 +374,7 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova @@ -281,6 +374,7 @@ func (cooperationApplicationService *CooperationApplicationService) BatchApprova
281 } 374 }
282 cooperationApplications[i].CooperationApplicationVerifier = verifier 375 cooperationApplications[i].CooperationApplicationVerifier = verifier
283 cooperationApplications[i].CooperationApplicationVerifyTime = time.Now() 376 cooperationApplications[i].CooperationApplicationVerifyTime = time.Now()
  377 + cooperationApplications[i].IsCanceled = 1
284 } 378 }
285 cooperationApplicationsApproved, err := cooperationApplicationRepository.UpdateMany(cooperationApplications) 379 cooperationApplicationsApproved, err := cooperationApplicationRepository.UpdateMany(cooperationApplications)
286 if err != nil { 380 if err != nil {
@@ -346,7 +440,12 @@ func (cooperationApplicationService *CooperationApplicationService) OneClickAppr @@ -346,7 +440,12 @@ func (cooperationApplicationService *CooperationApplicationService) OneClickAppr
346 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 440 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
347 } else { 441 } else {
348 if count > 0 { 442 if count > 0 {
349 - for i, _ := range cooperationApplications { 443 + for i, cooperationApplication := range cooperationApplications {
  444 + // 校验共创申请是否已经审核过
  445 + if cooperationApplication.CooperationApplicationStatus != 1 {
  446 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "改申请已经审核过")
  447 + }
  448 + // 更新共创申请
350 if oneClickApprovalCooperationApplicationCommand.Action == 1 { 449 if oneClickApprovalCooperationApplicationCommand.Action == 1 {
351 cooperationApplications[i].CooperationApplicationStatus = 2 450 cooperationApplications[i].CooperationApplicationStatus = 2
352 } else if oneClickApprovalCooperationApplicationCommand.Action == 2 { 451 } else if oneClickApprovalCooperationApplicationCommand.Action == 2 {
@@ -463,7 +562,7 @@ func (cooperationApplicationService *CooperationApplicationService) CreateCooper @@ -463,7 +562,7 @@ func (cooperationApplicationService *CooperationApplicationService) CreateCooper
463 CooperationApplyTime: time.Now(), 562 CooperationApplyTime: time.Now(),
464 CooperationProject: cooperationProject, 563 CooperationProject: cooperationProject,
465 Org: organization, 564 Org: organization,
466 - IsCanceled: false, 565 + IsCanceled: 1,
467 Company: company, 566 Company: company,
468 CreatedAt: time.Now(), 567 CreatedAt: time.Now(),
469 DeletedAt: time.Time{}, 568 DeletedAt: time.Time{},
@@ -551,6 +650,7 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat @@ -551,6 +650,7 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat
551 } else { 650 } else {
552 cooperationApplicationRepository = value 651 cooperationApplicationRepository = value
553 } 652 }
  653 + // 获取共创申请
554 if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(listCooperationApplicationQuery)); err != nil { 654 if count, cooperationApplications, err := cooperationApplicationRepository.Find(tool_funs.SimpleStructToMap(listCooperationApplicationQuery)); err != nil {
555 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 655 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
556 } else { 656 } else {
@@ -709,8 +809,19 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper @@ -709,8 +809,19 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper
709 defer func() { 809 defer func() {
710 _ = transactionContext.RollbackTransaction() 810 _ = transactionContext.RollbackTransaction()
711 }() 811 }()
  812 +
712 //TODO 校验用户菜单模块权限 813 //TODO 校验用户菜单模块权限
713 814
  815 + // 共创项目仓储初始化
  816 + var cooperationProjectRepository domain.CooperationProjectRepository
  817 + if value, err := factory.CreateCooperationProjectRepository(map[string]interface{}{
  818 + "transactionContext": transactionContext,
  819 + }); err != nil {
  820 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  821 + } else {
  822 + cooperationProjectRepository = value
  823 + }
  824 +
714 // 共创申请仓储初始化 825 // 共创申请仓储初始化
715 var cooperationApplicationRepository domain.CooperationApplicationRepository 826 var cooperationApplicationRepository domain.CooperationApplicationRepository
716 if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{ 827 if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
@@ -732,17 +843,30 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper @@ -732,17 +843,30 @@ func (cooperationApplicationService *CooperationApplicationService) CancelCooper
732 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10))) 843 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10)))
733 } 844 }
734 if err := cooperationApplication.Update(map[string]interface{}{ 845 if err := cooperationApplication.Update(map[string]interface{}{
735 - "isCanceled": true, 846 + "isCanceled": int32(2),
736 }); err != nil { 847 }); err != nil {
737 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 848 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
738 } 849 }
739 - if cooperationApplication, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil { 850 + if cooperationApplicationSaved, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
740 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 851 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
741 } else { 852 } else {
  853 + // 获取共创项目
  854 + cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": cooperationApplicationSaved.CooperationProject.CooperationProjectId})
  855 + if err != nil {
  856 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目不存在")
  857 + }
  858 + if cooperationProject == nil {
  859 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s不存在", strconv.FormatInt(cooperationApplicationSaved.CooperationProject.CooperationProjectId, 10)))
  860 + }
  861 + // 更新共创项目申请统计
  862 + cooperationProject.ApplicantCount = cooperationProject.ApplicantCount - 1
  863 + if _, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
  864 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  865 + }
742 if err := transactionContext.CommitTransaction(); err != nil { 866 if err := transactionContext.CommitTransaction(); err != nil {
743 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 867 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
744 } 868 }
745 - return cooperationApplication, nil 869 + return cooperationApplicationSaved, nil
746 } 870 }
747 } 871 }
748 872
@@ -18,6 +18,10 @@ type CooperationContractByUndertakerDto struct { @@ -18,6 +18,10 @@ type CooperationContractByUndertakerDto struct {
18 CooperationContractNumber string `json:"cooperationContractNumber"` 18 CooperationContractNumber string `json:"cooperationContractNumber"`
19 // 项目合约名称 19 // 项目合约名称
20 CooperationContractName string `json:"cooperationContractName"` 20 CooperationContractName string `json:"cooperationContractName"`
  21 + // 项目合约状态
  22 + CooperationContractStatus int32 `json:"cooperationContractStatus"`
  23 + // 共创描述
  24 + CooperationContractDescription string `json:"cooperationContractDescription"`
21 // 合同附件 25 // 合同附件
22 Attachment []*domain.Attachment `json:"attachment"` 26 Attachment []*domain.Attachment `json:"attachment"`
23 // 发起人姓名 27 // 发起人姓名
@@ -37,6 +41,8 @@ func (dto *CooperationContractByUndertakerDto) LoadDto(contractByUndertaker *mod @@ -37,6 +41,8 @@ func (dto *CooperationContractByUndertakerDto) LoadDto(contractByUndertaker *mod
37 dto.UndertakerPhone = contractByUndertaker.UndertakerPhone 41 dto.UndertakerPhone = contractByUndertaker.UndertakerPhone
38 dto.CooperationContractNumber = contractByUndertaker.CooperationContractNumber 42 dto.CooperationContractNumber = contractByUndertaker.CooperationContractNumber
39 dto.CooperationContractName = contractByUndertaker.CooperationContractName 43 dto.CooperationContractName = contractByUndertaker.CooperationContractName
  44 + dto.CooperationContractStatus = contractByUndertaker.ContractStatus
  45 + dto.CooperationContractDescription = contractByUndertaker.CooperationContractDescription
40 dto.Attachment = contractByUndertaker.ContractAttachment 46 dto.Attachment = contractByUndertaker.ContractAttachment
41 dto.SponsorName = contractByUndertaker.CooperationContractSponsor.UserName 47 dto.SponsorName = contractByUndertaker.CooperationContractSponsor.UserName
42 if contractByUndertaker.Department != nil { 48 if contractByUndertaker.Department != nil {
@@ -17,6 +17,8 @@ type SearchCooperationContractQuery struct { @@ -17,6 +17,8 @@ type SearchCooperationContractQuery struct {
17 CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber,omitempty"` 17 CooperationContractNumber string `cname:"共创合约编号" json:"cooperationContractNumber,omitempty"`
18 // 发起人姓名 18 // 发起人姓名
19 SponsorName string `cname:"发起人姓名" json:"sponsorName,omitempty"` 19 SponsorName string `cname:"发起人姓名" json:"sponsorName,omitempty"`
  20 + // 激励类型
  21 + IncentivesType int32 `cname:"激励类型" json:"incentivesType,omitempty"`
20 // 公司ID,通过集成REST上下文获取 22 // 公司ID,通过集成REST上下文获取
21 CompanyId int64 `cname:"公司ID" json:"companyId"` 23 CompanyId int64 `cname:"公司ID" json:"companyId"`
22 // 组织机构ID 24 // 组织机构ID
@@ -30,7 +32,6 @@ type SearchCooperationContractQuery struct { @@ -30,7 +32,6 @@ type SearchCooperationContractQuery struct {
30 } 32 }
31 33
32 func (searchCooperationContractQuery *SearchCooperationContractQuery) Valid(validation *validation.Validation) { 34 func (searchCooperationContractQuery *SearchCooperationContractQuery) Valid(validation *validation.Validation) {
33 - //validation.SetError("CustomValid", "未实现的自定义认证")  
34 } 35 }
35 36
36 func (searchCooperationContractQuery *SearchCooperationContractQuery) ValidateQuery() error { 37 func (searchCooperationContractQuery *SearchCooperationContractQuery) ValidateQuery() error {
@@ -2,6 +2,9 @@ package service @@ -2,6 +2,9 @@ package service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "strconv"
  6 + "time"
  7 +
5 "github.com/linmadan/egglib-go/core/application" 8 "github.com/linmadan/egglib-go/core/application"
6 "github.com/linmadan/egglib-go/utils/tool_funs" 9 "github.com/linmadan/egglib-go/utils/tool_funs"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationContract/command"
@@ -13,8 +16,6 @@ import ( @@ -13,8 +16,6 @@ import (
13 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" 16 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
14 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" 17 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
15 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log" 18 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
16 - "strconv"  
17 - "time"  
18 ) 19 )
19 20
20 // CooperationContractService 共创合约服务 21 // CooperationContractService 共创合约服务
@@ -125,7 +126,9 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -125,7 +126,9 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
125 } 126 }
126 127
127 // 生成共创合约编号 128 // 生成共创合约编号
128 - contractNumber, err2 := cooperationContractDao.GenerateContractNumber() 129 + contractNumber, err2 := cooperationContractDao.GenerateContractNumber(map[string]interface{}{
  130 + "companyId": createCooperationContractCommand.CompanyId,
  131 + })
129 if err2 != nil { 132 if err2 != nil {
130 return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error()) 133 return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error())
131 } 134 }
@@ -133,16 +136,16 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -133,16 +136,16 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
133 // 校验共创合约编号是否唯一 136 // 校验共创合约编号是否唯一
134 numberAvailable, _ := cooperationContractDao.CheckContractNumberAvailable(map[string]interface{}{ 137 numberAvailable, _ := cooperationContractDao.CheckContractNumberAvailable(map[string]interface{}{
135 "companyId": createCooperationContractCommand.CompanyId, 138 "companyId": createCooperationContractCommand.CompanyId,
136 - "orgId": createCooperationContractCommand.OrgId,  
137 "cooperationContractNumber": contractNumber, 139 "cooperationContractNumber": contractNumber,
138 }) 140 })
139 if !numberAvailable { 141 if !numberAvailable {
140 return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创合约异常") 142 return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增共创合约异常")
141 } 143 }
142 144
143 - // 获取承接人 145 + // 承接人
144 var undertakers []*domain.Undertaker 146 var undertakers []*domain.Undertaker
145 for _, undertaker := range createCooperationContractCommand.Undertakers { 147 for _, undertaker := range createCooperationContractCommand.Undertakers {
  148 + // 获取承接人
146 var undertakerDomain *domain.Undertaker 149 var undertakerDomain *domain.Undertaker
147 undertakerUid, err := strconv.ParseInt(undertaker.UserId, 10, 64) 150 undertakerUid, err := strconv.ParseInt(undertaker.UserId, 10, 64)
148 if err != nil { 151 if err != nil {
@@ -155,6 +158,13 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -155,6 +158,13 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
155 undertakerDomain = data 158 undertakerDomain = data
156 } 159 }
157 160
  161 + // 校验承接人是否属于承接对象,1员工,2共创用户,4公开
  162 + if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, 4) {
  163 + if !utils.IsContain(createCooperationContractCommand.CooperationContractUndertakerTypes, undertakerDomain.UserType) {
  164 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人"+undertakerDomain.UserName+"不属于承接对象")
  165 + }
  166 + }
  167 +
158 // 获取推荐人 168 // 获取推荐人
159 var referrerDomain *domain.Referrer 169 var referrerDomain *domain.Referrer
160 referrerUid, _ := strconv.ParseInt(undertaker.ReferrerId, 10, 64) 170 referrerUid, _ := strconv.ParseInt(undertaker.ReferrerId, 10, 64)
@@ -195,11 +205,13 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -195,11 +205,13 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
195 UserId: undertakerDomain.UserId, 205 UserId: undertakerDomain.UserId,
196 CooperationContractNumber: contractNumber, 206 CooperationContractNumber: contractNumber,
197 UserBaseId: undertakerDomain.UserBaseId, 207 UserBaseId: undertakerDomain.UserBaseId,
198 - Org: undertakerDomain.Org, 208 + Org: organization,
199 Orgs: undertakerDomain.Orgs, 209 Orgs: undertakerDomain.Orgs,
200 Department: undertakerDomain.Department, 210 Department: undertakerDomain.Department,
201 Roles: undertakerDomain.Roles, 211 Roles: undertakerDomain.Roles,
202 UserInfo: undertakerDomain.UserInfo, 212 UserInfo: undertakerDomain.UserInfo,
  213 + UserName: undertakerDomain.UserName,
  214 + UserPhone: undertakerDomain.UserPhone,
203 UserType: undertakerDomain.UserType, 215 UserType: undertakerDomain.UserType,
204 Referrer: referrerDomain, 216 Referrer: referrerDomain,
205 Salesman: salesmanDomain, 217 Salesman: salesmanDomain,
@@ -225,14 +237,14 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -225,14 +237,14 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
225 CooperationContractNumber: contractNumber, 237 CooperationContractNumber: contractNumber,
226 UserId: relevantDomain.UserId, 238 UserId: relevantDomain.UserId,
227 UserBaseId: relevantDomain.UserBaseId, 239 UserBaseId: relevantDomain.UserBaseId,
228 - Org: relevantDomain.Org, 240 + Org: organization,
229 Orgs: relevantDomain.Orgs, 241 Orgs: relevantDomain.Orgs,
230 Department: relevantDomain.Department, 242 Department: relevantDomain.Department,
231 Roles: relevantDomain.Roles, 243 Roles: relevantDomain.Roles,
232 UserInfo: relevantDomain.UserInfo, 244 UserInfo: relevantDomain.UserInfo,
233 UserType: relevantDomain.UserType, 245 UserType: relevantDomain.UserType,
234 Status: relevantDomain.Status, 246 Status: relevantDomain.Status,
235 - Company: relevantDomain.Company, 247 + Company: company,
236 }) 248 })
237 } 249 }
238 250
@@ -267,7 +279,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC @@ -267,7 +279,7 @@ func (cooperationContractService *CooperationContractService) CreateCooperationC
267 MoneyIncentivesStage: moneyIncentivesRule.MoneyIncentivesStage, 279 MoneyIncentivesStage: moneyIncentivesRule.MoneyIncentivesStage,
268 MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd, 280 MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd,
269 MoneyIncentivesStageStart: moneyIncentivesRule.MoneyIncentivesStageStart, 281 MoneyIncentivesStageStart: moneyIncentivesRule.MoneyIncentivesStageStart,
270 - MoneyIncentivesTime: time.Now(), 282 + MoneyIncentivesTime: moneyIncentivesRule.MoneyIncentivesTime,
271 ReferrerPercentage: moneyIncentivesRule.ReferrerPercentage, 283 ReferrerPercentage: moneyIncentivesRule.ReferrerPercentage,
272 SalesmanPercentage: moneyIncentivesRule.SalesmanPercentage, 284 SalesmanPercentage: moneyIncentivesRule.SalesmanPercentage,
273 Org: organization, 285 Org: organization,
@@ -444,6 +456,7 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon @@ -444,6 +456,7 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon
444 defer func() { 456 defer func() {
445 _ = transactionContext.RollbackTransaction() 457 _ = transactionContext.RollbackTransaction()
446 }() 458 }()
  459 + // 合约仓储初始化
447 var cooperationContractRepository domain.CooperationContractRepository 460 var cooperationContractRepository domain.CooperationContractRepository
448 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{ 461 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
449 "transactionContext": transactionContext, 462 "transactionContext": transactionContext,
@@ -452,6 +465,7 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon @@ -452,6 +465,7 @@ func (cooperationContractService *CooperationContractService) ListCooperationCon
452 } else { 465 } else {
453 cooperationContractRepository = value 466 cooperationContractRepository = value
454 } 467 }
  468 + // 查找合约
455 if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listCooperationContractQuery)); err != nil { 469 if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listCooperationContractQuery)); err != nil {
456 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 470 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
457 } else { 471 } else {
@@ -824,7 +838,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC @@ -824,7 +838,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC
824 if count, cooperationContractByUndertakers, err := cooperationContractDao.SearchCooperationContractByUndertaker(tool_funs.SimpleStructToMap(searchCooperationContractByUndertakerQuery)); err != nil { 838 if count, cooperationContractByUndertakers, err := cooperationContractDao.SearchCooperationContractByUndertaker(tool_funs.SimpleStructToMap(searchCooperationContractByUndertakerQuery)); err != nil {
825 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 839 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
826 } else { 840 } else {
827 - var cooperationContractByUndertakerDtos []*dto.CooperationContractByUndertakerDto 841 + cooperationContractByUndertakerDtos := make([]*dto.CooperationContractByUndertakerDto, 0)
828 for _, cooperationContractByUndertaker := range cooperationContractByUndertakers { 842 for _, cooperationContractByUndertaker := range cooperationContractByUndertakers {
829 cooperationContractByUndertakerDto := &dto.CooperationContractByUndertakerDto{} 843 cooperationContractByUndertakerDto := &dto.CooperationContractByUndertakerDto{}
830 if err := cooperationContractByUndertakerDto.LoadDto(cooperationContractByUndertaker); err != nil { 844 if err := cooperationContractByUndertakerDto.LoadDto(cooperationContractByUndertaker); err != nil {
@@ -1005,6 +1019,13 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1005,6 +1019,13 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1005 undertakerDomain = data 1019 undertakerDomain = data
1006 } 1020 }
1007 1021
  1022 + // 校验:判断用户类型是否属于承接对象
  1023 + if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, 4) { // 非公开类型校验
  1024 + if !utils.IsContain(cooperationContract.CooperationContractUndertakerTypes, undertakerDomain.UserType) {
  1025 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "抱歉,您不属于当前项目的承接对象")
  1026 + }
  1027 + }
  1028 +
1008 // 获取推荐人 1029 // 获取推荐人
1009 var referrerDomain *domain.Referrer 1030 var referrerDomain *domain.Referrer
1010 if undertaker.ReferrerId != "" { 1031 if undertaker.ReferrerId != "" {
@@ -1043,6 +1064,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1043,6 +1064,16 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1043 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err16.Error()) 1064 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err16.Error())
1044 } 1065 }
1045 1066
  1067 + var contractAttachments []*domain.Attachment
  1068 + for _, attachment := range undertaker.ContractAttachment {
  1069 + contractAttachments = append(contractAttachments, &domain.Attachment{
  1070 + FileType: attachment.FileType,
  1071 + Name: attachment.Name,
  1072 + Url: attachment.Url,
  1073 + FileSize: attachment.FileSize,
  1074 + })
  1075 + }
  1076 +
1046 undertakers = append(undertakers, &domain.Undertaker{ 1077 undertakers = append(undertakers, &domain.Undertaker{
1047 UndertakerId: undertakerId, 1078 UndertakerId: undertakerId,
1048 UserId: undertakerDomain.UserId, 1079 UserId: undertakerDomain.UserId,
@@ -1058,7 +1089,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1058,7 +1089,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1058 Salesman: salesmanDomain, 1089 Salesman: salesmanDomain,
1059 Status: undertakerDomain.Status, 1090 Status: undertakerDomain.Status,
1060 Company: undertakerDomain.Company, 1091 Company: undertakerDomain.Company,
1061 - ContractAttachment: nil, 1092 + ContractAttachment: contractAttachments,
1062 }) 1093 })
1063 } 1094 }
1064 // 更新承接人 1095 // 更新承接人
@@ -1106,7 +1137,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1106,7 +1137,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1106 MoneyIncentivesStage: moneyIncentivesRule.MoneyIncentivesStage, 1137 MoneyIncentivesStage: moneyIncentivesRule.MoneyIncentivesStage,
1107 MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd, 1138 MoneyIncentivesStageEnd: moneyIncentivesRule.MoneyIncentivesStageEnd,
1108 MoneyIncentivesStageStart: moneyIncentivesRule.MoneyIncentivesStageStart, 1139 MoneyIncentivesStageStart: moneyIncentivesRule.MoneyIncentivesStageStart,
1109 - MoneyIncentivesTime: time.Now(), 1140 + MoneyIncentivesTime: moneyIncentivesRule.MoneyIncentivesTime,
1110 ReferrerPercentage: moneyIncentivesRule.ReferrerPercentage, 1141 ReferrerPercentage: moneyIncentivesRule.ReferrerPercentage,
1111 SalesmanPercentage: moneyIncentivesRule.SalesmanPercentage, 1142 SalesmanPercentage: moneyIncentivesRule.SalesmanPercentage,
1112 Org: organization, 1143 Org: organization,
@@ -1301,7 +1332,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1301,7 +1332,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1301 UserPhone: "", 1332 UserPhone: "",
1302 } 1333 }
1303 } 1334 }
1304 - undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" 1335 + undertakersOriginal = undertakersOriginal + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
1305 } 1336 }
1306 undertakerChangeTmp1 := "【" + undertakersOriginal + "】" 1337 undertakerChangeTmp1 := "【" + undertakersOriginal + "】"
1307 1338
@@ -1338,7 +1369,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC @@ -1338,7 +1369,7 @@ func (cooperationContractService *CooperationContractService) UpdateCooperationC
1338 UserPhone: "", 1369 UserPhone: "",
1339 } 1370 }
1340 } 1371 }
1341 - undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")" 1372 + undertakersChanged = undertakersChanged + strconv.FormatInt(int64(i+1), 10) + "(" + undertaker.UserName + "," + undertaker.Referrer.UserName + "," + undertaker.Salesman.UserName + ")"
1342 } 1373 }
1343 undertakerChangeTemp2 := "【" + undertakersChanged + "】" 1374 undertakerChangeTemp2 := "【" + undertakersChanged + "】"
1344 // 拼接承接人变更记录 1375 // 拼接承接人变更记录
@@ -29,6 +29,8 @@ type SearchCooperationModeQuery struct { @@ -29,6 +29,8 @@ type SearchCooperationModeQuery struct {
29 UserId int64 `cname:"用户ID" json:"userId"` 29 UserId int64 `cname:"用户ID" json:"userId"`
30 // 用户基础数据id 30 // 用户基础数据id
31 UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"` 31 UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
  32 + // 共创模式状态,1启用,2禁用
  33 + Status int32 `json:"status"`
32 } 34 }
33 35
34 func (searchCooperationModeQuery *SearchCooperationModeQuery) Valid(validation *validation.Validation) { 36 func (searchCooperationModeQuery *SearchCooperationModeQuery) Valid(validation *validation.Validation) {
@@ -17,6 +17,8 @@ type SearchCooperationProjectQuery struct { @@ -17,6 +17,8 @@ type SearchCooperationProjectQuery struct {
17 CooperationProjectName string `cname:"共创项目名称" json:"cooperationProjectName,omitempty"` 17 CooperationProjectName string `cname:"共创项目名称" json:"cooperationProjectName,omitempty"`
18 // 共创项目编号 18 // 共创项目编号
19 CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber,omitempty"` 19 CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber,omitempty"`
  20 + // 共创项目承接对象,1员工,2共创用户,4公开,可以多选
  21 + CooperationProjectUndertakerType int32 `json:"cooperationProjectUndertakerType"`
20 // 部门名称 22 // 部门名称
21 DepartmentName string `cname:"部门名称" json:"departmentName,omitempty"` 23 DepartmentName string `cname:"部门名称" json:"departmentName,omitempty"`
22 // 关键字搜索 24 // 关键字搜索
@@ -163,9 +163,11 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro @@ -163,9 +163,11 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
163 cooperationProjectDao = value 163 cooperationProjectDao = value
164 } 164 }
165 // 生成共创项目编号 165 // 生成共创项目编号
166 - projectNumber, err2 := cooperationProjectDao.GenerateProjectNumber() 166 + projectNumber, err2 := cooperationProjectDao.GenerateProjectNumber(map[string]interface{}{
  167 + "companyId": createCooperationProjectCommand.CompanyId,
  168 + })
167 if err2 != nil { 169 if err2 != nil {
168 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 170 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err2.Error())
169 } 171 }
170 // 校验共创项目编号是否唯一 172 // 校验共创项目编号是否唯一
171 numberAvailable, _ := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{ 173 numberAvailable, _ := cooperationProjectDao.CheckProjectNumberAvailable(map[string]interface{}{
@@ -457,29 +459,123 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro @@ -457,29 +459,123 @@ func (cooperationProjectService *CooperationProjectService) UpdateCooperationPro
457 cooperationProjectRepository = value 459 cooperationProjectRepository = value
458 } 460 }
459 461
  462 + // 共创申请仓储初始化
  463 + var cooperationApplicationRepository domain.CooperationApplicationRepository
  464 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  465 + "transactionContext": transactionContext,
  466 + }); err != nil {
  467 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  468 + } else {
  469 + cooperationApplicationRepository = value
  470 + }
  471 +
  472 + // 用户REST服务初始化
  473 + var userService service.UserService
  474 + if value, err := factory.CreateUserService(map[string]interface{}{}); err != nil {
  475 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  476 + } else {
  477 + userService = value
  478 + }
  479 +
  480 + // 获取操作人
  481 + var operator *domain.User
  482 + if data, err := userService.OperatorFrom(updateCooperationProjectCommand.CompanyId, updateCooperationProjectCommand.OrgId, updateCooperationProjectCommand.UserId); err != nil {
  483 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取操作人失败")
  484 + } else {
  485 + operator = data
  486 + }
  487 +
  488 + // 获取发起人
  489 + var sponsor *domain.User
  490 + // sponsorUid类型转换
  491 + sponsorUid, err := strconv.ParseInt(updateCooperationProjectCommand.SponsorUid, 10, 64)
  492 + if err != nil {
  493 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  494 + }
  495 +
  496 + if data, err := userService.UserFrom(updateCooperationProjectCommand.CompanyId, updateCooperationProjectCommand.OrgId, sponsorUid); err != nil {
  497 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "获取发起人失败")
  498 + } else {
  499 + sponsor = data
  500 + }
  501 +
  502 + // 共创项目ID类型转换
460 cooperationProjectId, err := strconv.ParseInt(updateCooperationProjectCommand.CooperationProjectId, 10, 64) 503 cooperationProjectId, err := strconv.ParseInt(updateCooperationProjectCommand.CooperationProjectId, 10, 64)
461 if err != nil { 504 if err != nil {
462 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目编号类型错误") 505 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创项目编号类型错误")
463 } 506 }
464 507
465 // 查找共创项目 508 // 查找共创项目
466 - cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{"cooperationProjectId": cooperationProjectId}) 509 + cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
  510 + "cooperationProjectId": cooperationProjectId,
  511 + })
467 if err != nil { 512 if err != nil {
468 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 513 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
469 } 514 }
470 if cooperationProject == nil { 515 if cooperationProject == nil {
471 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationProjectCommand.CooperationProjectId))) 516 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateCooperationProjectCommand.CooperationProjectId)))
472 } 517 }
  518 +
  519 + applicantTypes := make(map[int32]interface{})
  520 +
  521 + // 获取所有申请人
  522 + if count, cooperationApplications, err := cooperationApplicationRepository.Find(map[string]interface{}{
  523 + "cooperationProjectNumber": cooperationProject.CooperationProjectNumber,
  524 + "offsetLimit": false,
  525 + "companyId": updateCooperationProjectCommand.CompanyId,
  526 + "cooperationApplicationStatus": int32(2), // 共创申请审核状态,1待审核,2已同意,3已拒绝
  527 + }); err != nil {
  528 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  529 + } else {
  530 + if count > 0 {
  531 + for _, cooperationApplication := range cooperationApplications {
  532 + applicantTypes[cooperationApplication.CooperationApplicationApplicant.UserType] = cooperationApplication.CooperationApplicationApplicant.UserType
  533 + }
  534 + }
  535 + }
  536 + var undertakerTypes []int32
  537 + var k1, k2 int32
  538 + if len(applicantTypes) > 0 {
  539 + for k, _ := range applicantTypes {
  540 + if k == 1 {
  541 + k1 = k
  542 + } else if k == 2 {
  543 + k2 = k
  544 + }
  545 + undertakerTypes = append(undertakerTypes, k)
  546 + }
  547 + }
  548 + if k1 != 0 && k2 != 0 {
  549 + undertakerTypes = append(undertakerTypes, 4)
  550 + }
  551 +
  552 + // 校验可以修改的承接人(申请人)类型
  553 + for _, t := range undertakerTypes {
  554 + if !utils.IsContain(updateCooperationProjectCommand.CooperationProjectUndertakerTypes, t) {
  555 + switch t {
  556 + case 1:
  557 + return nil, application.ThrowError(application.BUSINESS_ERROR, "承接对象'员工'存在业务数据,不可取消勾选")
  558 + case 2:
  559 + return nil, application.ThrowError(application.BUSINESS_ERROR, "承接对象'共创用户'存在业务数据,不可取消勾选")
  560 + case 4:
  561 + return nil, application.ThrowError(application.BUSINESS_ERROR, "承接对象'公开'存在业务数据,不可取消勾选")
  562 + }
  563 + }
  564 + }
  565 +
  566 + // 更新共创项目
  567 + cooperationProject.Operator = operator
  568 + cooperationProject.CooperationProjectSponsor = sponsor
473 if err := cooperationProject.Update(tool_funs.SimpleStructToMap(updateCooperationProjectCommand)); err != nil { 569 if err := cooperationProject.Update(tool_funs.SimpleStructToMap(updateCooperationProjectCommand)); err != nil {
474 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 570 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
475 } 571 }
476 - if cooperationProject, err := cooperationProjectRepository.Save(cooperationProject); err != nil { 572 + if cooperationProjectSaved, err := cooperationProjectRepository.Save(cooperationProject); err != nil {
477 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 573 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
478 } else { 574 } else {
479 if err := transactionContext.CommitTransaction(); err != nil { 575 if err := transactionContext.CommitTransaction(); err != nil {
480 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 576 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
481 } 577 }
482 - return cooperationProject, nil 578 + return cooperationProjectSaved, nil
483 } 579 }
484 } 580 }
485 581
@@ -63,6 +63,8 @@ func (svr *CooperationStatisticsService) CooperationContractStatistics(contractS @@ -63,6 +63,8 @@ func (svr *CooperationStatisticsService) CooperationContractStatistics(contractS
63 res, err = statisticsService.PersonCompanyPaymentHistoryStatistics(contractStatisticsQuery.QueryOptions) 63 res, err = statisticsService.PersonCompanyPaymentHistoryStatistics(contractStatisticsQuery.QueryOptions)
64 case domain_service.CreditAccountStatistics: 64 case domain_service.CreditAccountStatistics:
65 res, err = statisticsService.CreditAccountStatistics(contractStatisticsQuery.QueryOptions) 65 res, err = statisticsService.CreditAccountStatistics(contractStatisticsQuery.QueryOptions)
  66 + case domain_service.RelevantCooperationContractNumbers:
  67 + res, err = statisticsService.RelevantCooperationContractNumbers(contractStatisticsQuery.QueryOptions)
66 } 68 }
67 if err != nil { 69 if err != nil {
68 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 70 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
@@ -16,9 +16,9 @@ type PayCreditAccountCommand struct { @@ -16,9 +16,9 @@ type PayCreditAccountCommand struct {
16 // 账期结算实付金额 16 // 账期结算实付金额
17 ActuallyPaidAmount float64 `cname:"账期结算实付金额" json:"actuallyPaidAmount" valid:"Required"` 17 ActuallyPaidAmount float64 `cname:"账期结算实付金额" json:"actuallyPaidAmount" valid:"Required"`
18 // 备注 18 // 备注
19 - Remarks string `cname:"备注" json:"remarks" valid:"Required"` 19 + Remarks string `cname:"备注" json:"remarks"`
20 // 支付凭证附件 20 // 支付凭证附件
21 - PaymentDocumentAttachments []*domain.Attachment `cname:"支付凭证附件" json:"paymentDocumentAttachment" valid:"Required"` 21 + PaymentDocumentAttachments []*domain.Attachment `cname:"支付凭证附件" json:"paymentDocumentAttachment"`
22 // 公司ID,通过集成REST上下文获取 22 // 公司ID,通过集成REST上下文获取
23 CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"` 23 CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
24 // 组织机构ID 24 // 组织机构ID
@@ -30,7 +30,6 @@ type PayCreditAccountCommand struct { @@ -30,7 +30,6 @@ type PayCreditAccountCommand struct {
30 } 30 }
31 31
32 func (payCreditAccountCommand *PayCreditAccountCommand) Valid(validation *validation.Validation) { 32 func (payCreditAccountCommand *PayCreditAccountCommand) Valid(validation *validation.Validation) {
33 - //validation.SetError("CustomValid", "未实现的自定义认证")  
34 } 33 }
35 34
36 func (payCreditAccountCommand *PayCreditAccountCommand) ValidateCommand() error { 35 func (payCreditAccountCommand *PayCreditAccountCommand) ValidateCommand() error {
@@ -32,6 +32,12 @@ type SearchCreditAccountQuery struct { @@ -32,6 +32,12 @@ type SearchCreditAccountQuery struct {
32 UserId int64 `cname:"用户ID" json:"userId"` 32 UserId int64 `cname:"用户ID" json:"userId"`
33 // 用户基础数据id 33 // 用户基础数据id
34 UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"` 34 UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
  35 + // 账期创建-开始时间
  36 + BeginTime time.Time `json:"beginTime"`
  37 + // 账期创建-结束时间
  38 + EndTime time.Time `json:"endTime"`
  39 + // 合约编号列表
  40 + CooperationContractNumbers []string `json:"cooperationContractNumbers"`
35 } 41 }
36 42
37 func (searchCreditAccountQuery *SearchCreditAccountQuery) Valid(validation *validation.Validation) { 43 func (searchCreditAccountQuery *SearchCreditAccountQuery) Valid(validation *validation.Validation) {
@@ -145,7 +145,6 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred @@ -145,7 +145,6 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
145 } 145 }
146 146
147 // 预算明细 147 // 预算明细
148 - var creditAccounts []*domain.CreditAccount  
149 var accountDetail []*domain.AccountDetail 148 var accountDetail []*domain.AccountDetail
150 var settlementAmount float64 149 var settlementAmount float64
151 for _, dividendsEstimate := range dividendsEstimates { 150 for _, dividendsEstimate := range dividendsEstimates {
@@ -158,7 +157,9 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred @@ -158,7 +157,9 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
158 } 157 }
159 158
160 // 生成账期结算单号 159 // 生成账期结算单号
161 - creditAccountNumber, err12 := creditAccountDao.GenerateCreditAccountNumber() 160 + creditAccountNumber, err12 := creditAccountDao.GenerateCreditAccountNumber(map[string]interface{}{
  161 + "companyId": createCreditAccountCommand.CompanyId,
  162 + })
162 if err12 != nil { 163 if err12 != nil {
163 return nil, application.ThrowError(application.TRANSACTION_ERROR, "生成账期结算单号错误") 164 return nil, application.ThrowError(application.TRANSACTION_ERROR, "生成账期结算单号错误")
164 } 165 }
@@ -179,7 +180,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred @@ -179,7 +180,7 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
179 Department: dividendsEstimates[0].DividendsUser.Department, 180 Department: dividendsEstimates[0].DividendsUser.Department,
180 Roles: dividendsEstimates[0].DividendsUser.Roles, 181 Roles: dividendsEstimates[0].DividendsUser.Roles,
181 UserInfo: dividendsEstimates[0].DividendsUser.UserInfo, 182 UserInfo: dividendsEstimates[0].DividendsUser.UserInfo,
182 - UserName: dividendsEstimates[0].DividendsUser.UserName, 183 + UserName: dividendsEstimates[0].DividendsUser.UserInfo.UserName,
183 UserPhone: dividendsEstimates[0].DividendsUser.UserPhone, 184 UserPhone: dividendsEstimates[0].DividendsUser.UserPhone,
184 UserType: dividendsEstimates[0].DividendsUser.UserType, 185 UserType: dividendsEstimates[0].DividendsUser.UserType,
185 Status: dividendsEstimates[0].DividendsUser.Status, 186 Status: dividendsEstimates[0].DividendsUser.Status,
@@ -199,13 +200,19 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred @@ -199,13 +200,19 @@ func (creditAccountService *CreditAccountService) CreateCreditAccount(createCred
199 if creditAccount, err13 := creditAccountRepository.Save(newCreditAccount); err13 != nil { 200 if creditAccount, err13 := creditAccountRepository.Save(newCreditAccount); err13 != nil {
200 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err13.Error()) 201 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err13.Error())
201 } else { 202 } else {
202 - creditAccounts = append(creditAccounts, creditAccount) 203 + // 变更分红预算单结算状态
  204 + for i, _ := range dividendsEstimates {
  205 + dividendsEstimates[i].DividendsAccountStatus = 2
  206 + }
  207 + _, err3 := dividendsEstimateRepository.UpdateMany(dividendsEstimates)
  208 + if err3 != nil {
  209 + return nil, err3
203 } 210 }
204 -  
205 if err14 := transactionContext.CommitTransaction(); err14 != nil { 211 if err14 := transactionContext.CommitTransaction(); err14 != nil {
206 return nil, application.ThrowError(application.TRANSACTION_ERROR, err14.Error()) 212 return nil, application.ThrowError(application.TRANSACTION_ERROR, err14.Error())
207 } 213 }
208 - return creditAccounts, nil 214 + return creditAccount, nil
  215 + }
209 } 216 }
210 } 217 }
211 218
@@ -353,6 +360,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco @@ -353,6 +360,7 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
353 if creditAccountSaved, err4 := creditAccountRepository.Save(creditAccount); err4 != nil { 360 if creditAccountSaved, err4 := creditAccountRepository.Save(creditAccount); err4 != nil {
354 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error()) 361 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
355 } else { 362 } else {
  363 + // TODO 更新分红预算单结算状态(已支付)
356 if err3 := transactionContext.CommitTransaction(); err3 != nil { 364 if err3 := transactionContext.CommitTransaction(); err3 != nil {
357 return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error()) 365 return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
358 } 366 }
@@ -28,10 +28,11 @@ type MoneyIncentivesEstimateDto struct { @@ -28,10 +28,11 @@ type MoneyIncentivesEstimateDto struct {
28 // 创建合约时间 28 // 创建合约时间
29 CreatedAt time.Time `json:"createdAt"` 29 CreatedAt time.Time `json:"createdAt"`
30 // 阶段和承接人 30 // 阶段和承接人
31 - StageAndUndertaker *StageAndUndertaker `json:"stageAndUndertaker"` 31 + StageAndUndertaker []*StageAndUndertaker `json:"stageAndUndertaker"`
32 } 32 }
33 33
34 func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract) error { 34 func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract) error {
  35 + // TODO 阶段承接人数据聚合
35 dto.CooperationContractId = contract.CooperationContractId 36 dto.CooperationContractId = contract.CooperationContractId
36 dto.CooperationContractNumber = contract.CooperationContractNumber 37 dto.CooperationContractNumber = contract.CooperationContractNumber
37 dto.CooperationContractName = contract.CooperationContractName 38 dto.CooperationContractName = contract.CooperationContractName
@@ -39,9 +40,9 @@ func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContr @@ -39,9 +40,9 @@ func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContr
39 dto.Department = contract.Department 40 dto.Department = contract.Department
40 dto.CooperationContractSponsorName = contract.CooperationContractSponsor.UserName 41 dto.CooperationContractSponsorName = contract.CooperationContractSponsor.UserName
41 dto.CreatedAt = contract.CreatedAt 42 dto.CreatedAt = contract.CreatedAt
42 - dto.StageAndUndertaker = &StageAndUndertaker{ 43 + dto.StageAndUndertaker = append(dto.StageAndUndertaker, &StageAndUndertaker{
43 Stage: 0, 44 Stage: 0,
44 - Undertakers: []*domain.Undertaker{},  
45 - } 45 + Undertakers: nil,
  46 + })
46 return nil 47 return nil
47 } 48 }
@@ -27,7 +27,6 @@ type ListDividendsIncentivesEstimateQuery struct { @@ -27,7 +27,6 @@ type ListDividendsIncentivesEstimateQuery struct {
27 } 27 }
28 28
29 func (listDividendsIncentivesEstimateQuery *ListDividendsIncentivesEstimateQuery) Valid(validation *validation.Validation) { 29 func (listDividendsIncentivesEstimateQuery *ListDividendsIncentivesEstimateQuery) Valid(validation *validation.Validation) {
30 - //validation.SetError("CustomValid", "未实现的自定义认证")  
31 } 30 }
32 31
33 func (listDividendsIncentivesEstimateQuery *ListDividendsIncentivesEstimateQuery) ValidateQuery() error { 32 func (listDividendsIncentivesEstimateQuery *ListDividendsIncentivesEstimateQuery) ValidateQuery() error {
@@ -75,24 +75,32 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive @@ -75,24 +75,32 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
75 for _, orderGood := range orderGoods { 75 for _, orderGood := range orderGoods {
76 dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{} 76 dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
77 if orderGood.DividendsOrderNumber != "" { // 查询分红订单 77 if orderGood.DividendsOrderNumber != "" { // 查询分红订单
78 - dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber}) 78 + dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{
  79 + "dividendsOrderNumber": orderGood.DividendsOrderNumber,
  80 + "companyId": orderGood.CompanyId,
  81 + "orgId": orderGood.OrgId,
  82 + })
79 if err != nil { 83 if err != nil {
80 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 84 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
81 } 85 }
82 if dividendsOrder == nil { 86 if dividendsOrder == nil {
83 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber)) 87 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红订单%s不存在", orderGood.DividendsOrderNumber))
84 } 88 }
85 if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsOrder.DividendsOrderNumber, dividendsOrder.DividendsOriginalOrderNum, dividendsOrder.CustomerName, dividendsOrder.Region.RegionName, dividendsOrder.OrderTime); err != nil { 89 if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsOrder.DividendsOrderNumber, dividendsOrder.DividendsOriginalOrderNum, dividendsOrder.CustomerName, dividendsOrder.Region.RegionName, dividendsOrder.OrderTime); err != nil {
86 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 90 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
87 } 91 }
88 dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto) 92 dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
89 } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单 93 } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
90 - dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber}) 94 + dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
  95 + "companyId": orderGood.CompanyId,
  96 + "orgId": orderGood.OrgId,
  97 + "dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
  98 + })
91 if err != nil { 99 if err != nil {
92 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 100 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
93 } 101 }
94 if dividendsReturnedOrder == nil { 102 if dividendsReturnedOrder == nil {
95 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber)) 103 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红退货单%s不存在", orderGood.DividendsReturnedOrderNumber))
96 } 104 }
97 if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsReturnedOrder.DividendsReturnedOrderNumber, dividendsReturnedOrder.OriginalOrderNum, dividendsReturnedOrder.DividendsReturnedCustomerName, dividendsReturnedOrder.Region.RegionName, dividendsReturnedOrder.OrderTime); err != nil { 105 if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsReturnedOrder.DividendsReturnedOrderNumber, dividendsReturnedOrder.OriginalOrderNum, dividendsReturnedOrder.DividendsReturnedCustomerName, dividendsReturnedOrder.Region.RegionName, dividendsReturnedOrder.OrderTime); err != nil {
98 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 106 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
@@ -223,6 +231,11 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat @@ -223,6 +231,11 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat
223 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cancelDividendsEstimateCommand.DividendsEstimateId, 10))) 231 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cancelDividendsEstimateCommand.DividendsEstimateId, 10)))
224 } 232 }
225 233
  234 + // 校验重复取消
  235 + if dividendsEstimate.IsCanceled {
  236 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已取消的分红单不能重复取消")
  237 + }
  238 +
226 // 校验是否能够取消 239 // 校验是否能够取消
227 if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红、退货冲销 240 if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红、退货冲销
228 if count, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum}); err2 != nil { 241 if count, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum}); err2 != nil {
@@ -328,6 +341,11 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs @@ -328,6 +341,11 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
328 if count > 0 { 341 if count > 0 {
329 // 校验分红预算是否可以取消,已有相关分红预算单已结算,无法取消 342 // 校验分红预算是否可以取消,已有相关分红预算单已结算,无法取消
330 for _, dividendsEstimate := range dividendsEstimates { 343 for _, dividendsEstimate := range dividendsEstimates {
  344 + // 校验重复取消
  345 + if dividendsEstimate.IsCanceled {
  346 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "已取消的分红单不能重复取消")
  347 + }
  348 +
331 // 校验是否能够取消 349 // 校验是否能够取消
332 if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红、退货冲销 350 if dividendsEstimate.DividendsType == domain.ORDER_DIVIDENDS || dividendsEstimate.DividendsType == domain.RETURN_WRITE_OFF { // 订单分红、退货冲销
333 if count, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum}); err2 != nil { 351 if count, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{"orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum}); err2 != nil {
@@ -542,25 +560,25 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -542,25 +560,25 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
542 operator = data 560 operator = data
543 } 561 }
544 562
545 - // 分红订单仓储初始化  
546 - var dividendsOrderRepository domain.DividendsOrderRepository  
547 - if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{  
548 - "transactionContext": transactionContext,  
549 - }); err != nil {  
550 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
551 - } else {  
552 - dividendsOrderRepository = value  
553 - } 563 + //// 分红订单仓储初始化
  564 + //var dividendsOrderRepository domain.DividendsOrderRepository
  565 + //if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
  566 + // "transactionContext": transactionContext,
  567 + //}); err != nil {
  568 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  569 + //} else {
  570 + // dividendsOrderRepository = value
  571 + //}
554 572
555 // 分红退货单仓储初始化 573 // 分红退货单仓储初始化
556 - var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository  
557 - if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{  
558 - "transactionContext": transactionContext,  
559 - }); err != nil {  
560 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
561 - } else {  
562 - dividendsReturnedOrderRepository = value  
563 - } 574 + //var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
  575 + //if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
  576 + // "transactionContext": transactionContext,
  577 + //}); err != nil {
  578 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  579 + //} else {
  580 + // dividendsReturnedOrderRepository = value
  581 + //}
564 582
565 // 订单产品仓储初始化 583 // 订单产品仓储初始化
566 var orderGoodRepository domain.OrderGoodRepository 584 var orderGoodRepository domain.OrderGoodRepository
@@ -605,33 +623,59 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -605,33 +623,59 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
605 }) 623 })
606 } 624 }
607 625
  626 + // 统计成功预算的分红订单
  627 + estimateSuccessfullyDividendsOrders := make(map[string]string)
  628 +
  629 + // 统计预算失败的分红订单
  630 + estimateFailedDividendsOrders := make(map[string]string)
  631 +
608 // 获取订单产品 632 // 获取订单产品
609 if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{ 633 if _, orderGoods, err := orderGoodRepository.Find(map[string]interface{}{
610 "orderGoodIds": orderGoodIds, 634 "orderGoodIds": orderGoodIds,
611 }); err != nil { 635 }); err != nil {
612 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 636 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
613 } else { 637 } else {
614 - var dividendsEstimates []*domain.DividendsEstimate 638 + dividendsEstimates := make([]*domain.DividendsEstimate, 0)
  639 + // 统计当前分红预算单数
  640 + count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
  641 + "companyId": confirmDividendsIncentivesEstimateCommand.CompanyId,
  642 + })
  643 + if err != nil {
  644 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  645 + }
  646 + var countDividendsEstimate int64
615 for _, orderGood := range orderGoods { 647 for _, orderGood := range orderGoods {
616 dividendsEstimate := &domain.DividendsEstimate{} 648 dividendsEstimate := &domain.DividendsEstimate{}
617 if orderGood.DividendsOrderNumber != "" { // 查询分红订单 649 if orderGood.DividendsOrderNumber != "" { // 查询分红订单
618 - dividendsOrder, err3 := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber})  
619 - if err3 != nil {  
620 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")  
621 - }  
622 - if dividendsOrder == nil {  
623 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))  
624 - } 650 + //dividendsOrder, err3 := dividendsOrderRepository.FindOne(map[string]interface{}{
  651 + // "dividendsOrderNumber": orderGood.DividendsOrderNumber,
  652 + // "companyId": orderGood.CompanyId,
  653 + // "orgId": orderGood.OrgId,
  654 + //})
  655 + //if err3 != nil {
  656 + // return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
  657 + //}
  658 + //if dividendsOrder == nil {
  659 + // return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红订单%s不存在", orderGood.DividendsOrderNumber))
  660 + //}
625 // 分红订单产品预算 661 // 分红订单产品预算
626 if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoods); err != nil { 662 if dividendsEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoods); err != nil {
627 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 663 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
628 } else { 664 } else {
629 for _, dividendsEstimateDetail := range dividendsEstimateDetails { 665 for _, dividendsEstimateDetail := range dividendsEstimateDetails {
  666 + if dividendsEstimateDetail.IsSuccessfully {
630 // 生成分红预算单号 667 // 生成分红预算单号
631 - dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber() 668 + dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
632 if err != nil { 669 if err != nil {
633 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 670 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
634 } 671 }
  672 +
  673 + // 记录成功的订单号
  674 + estimateSuccessfullyDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.OrderOrReturnedOrderNumber
  675 +
  676 + // 统计分红预算单数目
  677 + countDividendsEstimate = countDividendsEstimate + 1
  678 +
635 dividendsEstimate = &domain.DividendsEstimate{ 679 dividendsEstimate = &domain.DividendsEstimate{
636 DividendsEstimateId: 0, 680 DividendsEstimateId: 0,
637 DividendsAccountStatus: domain.TO_BE_ACCOUNT, 681 DividendsAccountStatus: domain.TO_BE_ACCOUNT,
@@ -656,27 +700,33 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -656,27 +700,33 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
656 OrderGoodId: orderGood.OrderGoodId, 700 OrderGoodId: orderGood.OrderGoodId,
657 OrderGoodAmount: orderGood.OrderGoodAmount, 701 OrderGoodAmount: orderGood.OrderGoodAmount,
658 } 702 }
  703 +
659 dividendsEstimates = append(dividendsEstimates, dividendsEstimate) 704 dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
  705 + } else {
  706 + // 记录失败的订单号和原因s
  707 + estimateFailedDividendsOrders[dividendsEstimateDetail.OrderOrReturnedOrderNumber] = dividendsEstimateDetail.Reason
660 } 708 }
661 } 709 }
662 - } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单  
663 - dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber})  
664 - if err != nil {  
665 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
666 - }  
667 - if dividendsReturnedOrder == nil {  
668 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))  
669 } 710 }
  711 + } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
670 // 分红退货单产品预算 712 // 分红退货单产品预算
671 if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoods); err != nil { 713 if dividendsReturnedEstimateDetails, err := confirmDividendsIncentivesEstimateService.Confirm(orderGoods); err != nil {
672 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 714 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
673 } else { 715 } else {
674 for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails { 716 for _, dividendsReturnedEstimateDetail := range dividendsReturnedEstimateDetails {
  717 + if dividendsReturnedEstimateDetail.IsSuccessfully {
675 // 生成分红预算单号 718 // 生成分红预算单号
676 - dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber() 719 + dividendsEstimateOrderNumber, err := dividendsReturnedEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
677 if err != nil { 720 if err != nil {
678 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 721 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
679 } 722 }
  723 +
  724 + // 记录成功的退货单号
  725 + estimateSuccessfullyDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber
  726 +
  727 + // 统计生成的预算单数量
  728 + countDividendsEstimate = countDividendsEstimate + 1
  729 +
680 dividendsEstimate = &domain.DividendsEstimate{ 730 dividendsEstimate = &domain.DividendsEstimate{
681 DividendsEstimateId: 0, 731 DividendsEstimateId: 0,
682 DividendsAccountStatus: domain.TO_BE_ACCOUNT, 732 DividendsAccountStatus: domain.TO_BE_ACCOUNT,
@@ -701,7 +751,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -701,7 +751,12 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
701 OrderGoodId: orderGood.OrderGoodId, 751 OrderGoodId: orderGood.OrderGoodId,
702 OrderGoodAmount: orderGood.OrderGoodAmount, 752 OrderGoodAmount: orderGood.OrderGoodAmount,
703 } 753 }
  754 +
704 dividendsEstimates = append(dividendsEstimates, dividendsEstimate) 755 dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
  756 + } else {
  757 + // 记录失败的退货单号和原因
  758 + estimateFailedDividendsOrders[dividendsReturnedEstimateDetail.OrderOrReturnedOrderNumber] = dividendsReturnedEstimateDetail.Reason
  759 + }
705 } 760 }
706 } 761 }
707 } 762 }
@@ -709,26 +764,29 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent @@ -709,26 +764,29 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmDividendsIncent
709 log.Logger.Info("新增的分红预算单", map[string]interface{}{ 764 log.Logger.Info("新增的分红预算单", map[string]interface{}{
710 "dividendsEstimates": dividendsEstimates, 765 "dividendsEstimates": dividendsEstimates,
711 }) 766 })
712 -  
713 - // 创建成功的分红预算单  
714 - var dividendsEstimatesSavedSuccessfully []*domain.DividendsEstimate  
715 - // 创建失败的分红预算单  
716 - var dividendsEstimateSaveFailed []*domain.DividendsEstimate  
717 - for _, dividendsEstimate := range dividendsEstimates {  
718 - if dividendsEstimateSaved, err := dividendsEstimateRepository.Save(dividendsEstimate); err != nil {  
719 - dividendsEstimateSaveFailed = append(dividendsEstimateSaveFailed, dividendsEstimate) 767 + if dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates); err != nil {
720 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 768 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
721 - } else if dividendsEstimateSaved != nil {  
722 - dividendsEstimatesSavedSuccessfully = append(dividendsEstimatesSavedSuccessfully, dividendsEstimate)  
723 - }  
724 - }  
725 - 769 + } else {
726 if err := transactionContext.CommitTransaction(); err != nil { 770 if err := transactionContext.CommitTransaction(); err != nil {
727 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 771 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
728 } 772 }
729 - // TODO 分析成功和失败原因  
730 -  
731 - return dividendsEstimatesSavedSuccessfully, nil 773 + // 分析成功和失败原因
  774 + successfullyCount := len(dividendsEstimatesSaved)
  775 + // 错误原因收集,返回第一个可能的原因
  776 + failedReason := make([]string, 0)
  777 + for _, v := range estimateFailedDividendsOrders {
  778 + failedReason = append(failedReason, v)
  779 + }
  780 + var failedReasonStr string
  781 + if len(failedReason) > 0 {
  782 + failedReasonStr = failedReason[0]
  783 + } else {
  784 + failedReasonStr = "无"
  785 + }
  786 + return map[string]interface{}{
  787 + "report": fmt.Sprintf("已完成%d笔单订单分红预算,生成%d笔单分红预算,%d笔订单分红预算失败,失败原因:%s", len(estimateSuccessfullyDividendsOrders), successfullyCount, len(estimateFailedDividendsOrders), failedReasonStr),
  788 + }, nil
  789 + }
732 } 790 }
733 } 791 }
734 792
@@ -823,11 +881,20 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives @@ -823,11 +881,20 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
823 dividendsEstimateRepository = value 881 dividendsEstimateRepository = value
824 } 882 }
825 883
826 - cooperationContractId, _ := strconv.ParseInt(confirmMoneyIncentivesEstimateCommand.CooperationContractId, 10, 64)  
827 - undertakerUIDs, _ := utils.SliceAtoi(confirmMoneyIncentivesEstimateCommand.UndertakerUids) 884 + cooperationContractId, err := strconv.ParseInt(confirmMoneyIncentivesEstimateCommand.CooperationContractId, 10, 64)
  885 + if err != nil {
  886 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "合约编号类型错误:"+err.Error())
  887 + }
  888 +
  889 + undertakerUIDs, err := utils.SliceAtoi(confirmMoneyIncentivesEstimateCommand.UndertakerUids)
  890 + if err != nil {
  891 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "承接人UID类型错误:"+err.Error())
  892 + }
828 893
829 // 获取共创合约 894 // 获取共创合约
830 - cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractId": cooperationContractId}) 895 + cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{
  896 + "cooperationContractId": cooperationContractId,
  897 + })
831 if err != nil { 898 if err != nil {
832 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 899 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
833 } 900 }
@@ -837,16 +904,28 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives @@ -837,16 +904,28 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
837 904
838 var dividendsEstimates []*domain.DividendsEstimate 905 var dividendsEstimates []*domain.DividendsEstimate
839 906
  907 + // 统计当前分红预算单数
  908 + count, err := dividendsEstimateDao.CountDividendsEstimate(map[string]interface{}{
  909 + "companyId": confirmMoneyIncentivesEstimateCommand.CompanyId,
  910 + })
  911 +
  912 + // 分红预算单统计
  913 + var countDividendsEstimate int64
  914 +
840 // 共创合约预算 915 // 共创合约预算
841 if dividendsEstimateDetails, err2 := confirmMoneyIncentivesEstimateService.Confirm(cooperationContract, confirmMoneyIncentivesEstimateCommand.DividendsIncentivesStage, undertakerUIDs); err2 != nil { 916 if dividendsEstimateDetails, err2 := confirmMoneyIncentivesEstimateService.Confirm(cooperationContract, confirmMoneyIncentivesEstimateCommand.DividendsIncentivesStage, undertakerUIDs); err2 != nil {
842 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error()) 917 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
843 } else { 918 } else {
844 for _, dividendsEstimateDetail := range dividendsEstimateDetails { 919 for _, dividendsEstimateDetail := range dividendsEstimateDetails {
845 // 生成分红预算单号 920 // 生成分红预算单号
846 - dividendsEstimateOrderNumber, err := dividendsEstimateDao.GenerateDividendsEstimateNumber() 921 + dividendsEstimateOrderNumber, err := dividendsEstimateDetail.GenerateSpecificDividendsEstimateNumber(int64(count), countDividendsEstimate)
847 if err != nil { 922 if err != nil {
848 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 923 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
849 } 924 }
  925 +
  926 + // 统计生成的预算单数目
  927 + countDividendsEstimate = countDividendsEstimate + 1
  928 +
850 dividendsEstimate := &domain.DividendsEstimate{ 929 dividendsEstimate := &domain.DividendsEstimate{
851 DividendsEstimateId: 0, 930 DividendsEstimateId: 0,
852 DividendsAccountStatus: domain.TO_BE_ACCOUNT, 931 DividendsAccountStatus: domain.TO_BE_ACCOUNT,
@@ -869,15 +948,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives @@ -869,15 +948,13 @@ func (dividendsEstimateService *DividendsEstimateService) ConfirmMoneyIncentives
869 DeletedAt: time.Time{}, 948 DeletedAt: time.Time{},
870 UpdatedAt: time.Time{}, 949 UpdatedAt: time.Time{},
871 } 950 }
  951 +
872 dividendsEstimates = append(dividendsEstimates, dividendsEstimate) 952 dividendsEstimates = append(dividendsEstimates, dividendsEstimate)
873 } 953 }
874 dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates) 954 dividendsEstimatesSaved, err := dividendsEstimateRepository.SaveMany(dividendsEstimates)
875 if err != nil { 955 if err != nil {
876 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 956 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
877 } 957 }
878 - if err := transactionContext.CommitTransaction(); err != nil {  
879 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
880 - }  
881 if confirmMoneyIncentivesEstimateCommand.Action == 1 { // 只预算,不入库 958 if confirmMoneyIncentivesEstimateCommand.Action == 1 { // 只预算,不入库
882 return dividendsEstimatesSaved, nil 959 return dividendsEstimatesSaved, nil
883 } else if confirmMoneyIncentivesEstimateCommand.Action == 2 { // 确定预算 960 } else if confirmMoneyIncentivesEstimateCommand.Action == 2 { // 确定预算
@@ -1098,7 +1175,11 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti @@ -1098,7 +1175,11 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti
1098 for _, orderGood := range orderGoods { 1175 for _, orderGood := range orderGoods {
1099 dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{} 1176 dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
1100 if orderGood.DividendsOrderNumber != "" { // 查询分红订单 1177 if orderGood.DividendsOrderNumber != "" { // 查询分红订单
1101 - dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber}) 1178 + dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{
  1179 + "dividendsOrderNumber": orderGood.DividendsOrderNumber,
  1180 + "companyId": orderGood.CompanyId,
  1181 + "orgId": orderGood.OrgId,
  1182 + })
1102 if err != nil { 1183 if err != nil {
1103 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1184 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1104 } 1185 }
@@ -1110,7 +1191,11 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti @@ -1110,7 +1191,11 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti
1110 } 1191 }
1111 dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto) 1192 dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
1112 } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单 1193 } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
1113 - dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber}) 1194 + dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
  1195 + "dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
  1196 + "companyId": orderGood.CompanyId,
  1197 + "orgId": orderGood.OrgId,
  1198 + })
1114 if err != nil { 1199 if err != nil {
1115 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 1200 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
1116 } 1201 }
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "github.com/beego/beego/v2/core/validation" 5 "github.com/beego/beego/v2/core/validation"
6 "reflect" 6 "reflect"
7 "strings" 7 "strings"
  8 + "time"
8 ) 9 )
9 10
10 type OrderGoods struct { 11 type OrderGoods struct {
@@ -17,7 +18,7 @@ type OrderGoods struct { @@ -17,7 +18,7 @@ type OrderGoods struct {
17 // 订单产品单价 18 // 订单产品单价
18 OrderGoodPrice float64 `json:"orderGoodPrice"` 19 OrderGoodPrice float64 `json:"orderGoodPrice"`
19 // 订单产品数量 20 // 订单产品数量
20 - OrderGoodQuantity int64 `json:"orderGoodQuantity"` 21 + OrderGoodQuantity float64 `json:"orderGoodQuantity"`
21 // 关联分红订单号 22 // 关联分红订单号
22 DividendsOrderNumber string `json:"dividendsOrderNumber"` 23 DividendsOrderNumber string `json:"dividendsOrderNumber"`
23 // 关联的共创合约编号 24 // 关联的共创合约编号
@@ -55,6 +56,28 @@ type CreateDividendsOrderCommand struct { @@ -55,6 +56,28 @@ type CreateDividendsOrderCommand struct {
55 LineNumbers []int `cname:"记录行号" json:"lineNumbers"` 56 LineNumbers []int `cname:"记录行号" json:"lineNumbers"`
56 } 57 }
57 58
  59 +// GenerateSpecificDividendsOrderNumber 生成自定义分红订单
  60 +func (createDividendsOrderCommand *CreateDividendsOrderCommand) GenerateSpecificDividendsOrderNumber(count int64, orderTime time.Time, index int64) (string, error) {
  61 + currentTime := time.Now()
  62 + if count+index < 1000 {
  63 + countStr := fmt.Sprintf("%03d", count+index+1)
  64 + timestamp := currentTime.Unix()
  65 + timeNow := time.Unix(timestamp, 0)
  66 + timeString := timeNow.Format("20060102")
  67 + timeString = timeString[2:len(timeString)]
  68 + dividendsOrderNumber := "SL" + timeString + "#" + countStr
  69 + return dividendsOrderNumber, nil
  70 + } else {
  71 + countStr := fmt.Sprintf("%d", count+index+1)
  72 + timestamp := currentTime.Unix()
  73 + timeNow := time.Unix(timestamp, 0)
  74 + timeString := timeNow.Format("20060102")
  75 + timeString = timeString[2:len(timeString)]
  76 + dividendsOrderNumber := "SL" + timeString + "#" + countStr
  77 + return dividendsOrderNumber, nil
  78 + }
  79 +}
  80 +
58 func (createDividendsOrderCommand *CreateDividendsOrderCommand) Valid(validation *validation.Validation) { 81 func (createDividendsOrderCommand *CreateDividendsOrderCommand) Valid(validation *validation.Validation) {
59 } 82 }
60 83
@@ -10,7 +10,7 @@ import ( @@ -10,7 +10,7 @@ import (
10 10
11 type RemoveDividendsOrderCommand struct { 11 type RemoveDividendsOrderCommand struct {
12 // 分红订单ID 12 // 分红订单ID
13 - DividendsOrderId string `cname:"分红订单ID" json:"dividendsOrderId" valid:"Required"` 13 + DividendsOrderId int64 `cname:"分红订单ID" json:"dividendsOrderId" valid:"Required"`
14 // 公司ID,通过集成REST上下文获取 14 // 公司ID,通过集成REST上下文获取
15 CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"` 15 CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
16 // 组织机构ID 16 // 组织机构ID
@@ -40,7 +40,7 @@ type UpdateDividendsOrderCommand struct { @@ -40,7 +40,7 @@ type UpdateDividendsOrderCommand struct {
40 40
41 func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) Valid(validation *validation.Validation) { 41 func (updateDividendsOrderCommand *UpdateDividendsOrderCommand) Valid(validation *validation.Validation) {
42 if len(updateDividendsOrderCommand.OrderGoods) <= 0 { 42 if len(updateDividendsOrderCommand.OrderGoods) <= 0 {
43 - validation.Error("激励规则不能为空") 43 + validation.Error("订单产品不能为空")
44 } else { 44 } else {
45 for i, _ := range updateDividendsOrderCommand.OrderGoods { 45 for i, _ := range updateDividendsOrderCommand.OrderGoods {
46 if updateDividendsOrderCommand.OrderGoods[i].OrderGoodId == "" { 46 if updateDividendsOrderCommand.OrderGoods[i].OrderGoodId == "" {
@@ -10,7 +10,7 @@ import ( @@ -10,7 +10,7 @@ import (
10 10
11 type GetDividendsOrderQuery struct { 11 type GetDividendsOrderQuery struct {
12 // 分红订单ID 12 // 分红订单ID
13 - DividendsOrderId int64 `cname:"分红订单ID" json:"dividendsOrderId" valid:"Required"` 13 + DividendsOrderId int64 `cname:"分红订单ID" json:"dividendsOrderId,omitempty"`
14 // 分红订单编号 14 // 分红订单编号
15 DividendsOrderNumber string `cname:"分红订单编号" json:"dividendsOrderNumber,omitempty"` 15 DividendsOrderNumber string `cname:"分红订单编号" json:"dividendsOrderNumber,omitempty"`
16 // 公司ID,通过集成REST上下文获取 16 // 公司ID,通过集成REST上下文获取
@@ -20,7 +20,7 @@ type GetDividendsOrderQuery struct { @@ -20,7 +20,7 @@ type GetDividendsOrderQuery struct {
20 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 20 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
21 UserId int64 `cname:"用户ID" json:"userId" valid:"Required"` 21 UserId int64 `cname:"用户ID" json:"userId" valid:"Required"`
22 // 用户基础数据id 22 // 用户基础数据id
23 - UserBaseId int64 `canme:"用户基础数据ID" json:"userBaseId" valid:"Required"` 23 + UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"`
24 } 24 }
25 25
26 func (getDividendsOrderQuery *GetDividendsOrderQuery) Valid(validation *validation.Validation) { 26 func (getDividendsOrderQuery *GetDividendsOrderQuery) Valid(validation *validation.Validation) {
@@ -6,6 +6,7 @@ import ( @@ -6,6 +6,7 @@ import (
6 "fmt" 6 "fmt"
7 "github.com/linmadan/egglib-go/core/application" 7 "github.com/linmadan/egglib-go/core/application"
8 "github.com/linmadan/egglib-go/utils/tool_funs" 8 "github.com/linmadan/egglib-go/utils/tool_funs"
  9 + "github.com/shopspring/decimal"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/command" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/command"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/query" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsOrder/query"
11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
@@ -99,7 +100,9 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -99,7 +100,9 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
99 } 100 }
100 101
101 // 生成分红订单号 102 // 生成分红订单号
102 - dividendsOrderNumber, err := dividendsOrderDao.GenerateDividendsOrderNumber() 103 + dividendsOrderNumber, err := dividendsOrderDao.GenerateDividendsOrderNumber(map[string]interface{}{
  104 + "companyId": createDividendsOrderCommand.CompanyId,
  105 + })
103 if err != nil { 106 if err != nil {
104 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 107 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
105 } 108 }
@@ -107,7 +110,6 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -107,7 +110,6 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
107 // 校验分红订单编号是否唯一 110 // 校验分红订单编号是否唯一
108 numberAvailable, err := dividendsOrderDao.CheckDividendsOrderNumberAvailable(map[string]interface{}{ 111 numberAvailable, err := dividendsOrderDao.CheckDividendsOrderNumberAvailable(map[string]interface{}{
109 "companyId": createDividendsOrderCommand.CompanyId, 112 "companyId": createDividendsOrderCommand.CompanyId,
110 - "orgId": createDividendsOrderCommand.OrgId,  
111 "dividendsOrderNumber": dividendsOrderNumber, 113 "dividendsOrderNumber": dividendsOrderNumber,
112 }) 114 })
113 if err != nil { 115 if err != nil {
@@ -117,13 +119,70 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -117,13 +119,70 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
117 return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常") 119 return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
118 } 120 }
119 121
  122 + // 合约仓储初始化
  123 + var cooperationContractRepository domain.CooperationContractRepository
  124 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  125 + "transactionContext": transactionContext,
  126 + }); err != nil {
  127 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  128 + } else {
  129 + cooperationContractRepository = value
  130 + }
  131 +
  132 + // 查找合约
  133 + cooperationContractsMap := make(map[string]*domain.CooperationContract)
  134 + if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
  135 + "offsetLimit": false,
  136 + "companyId": createDividendsOrderCommand.CompanyId,
  137 + "orgId": createDividendsOrderCommand.OrgId,
  138 + }); err != nil {
  139 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  140 + } else {
  141 + if count > 0 {
  142 + for _, cooperationContract := range cooperationContracts {
  143 + cooperationContractsMap[cooperationContract.CooperationContractNumber] = cooperationContract
  144 + }
  145 + }
  146 + }
  147 +
  148 + // 订单时间转换
  149 + orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
  150 + if err != nil {
  151 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间错误")
  152 + }
  153 + orderTime := utils.TransformTimestampToTime(orderTimeInt)
  154 +
120 // 新增订单产品 155 // 新增订单产品
121 var orderGoods []*domain.OrderGood 156 var orderGoods []*domain.OrderGood
122 var dividendsOrderAmount float64 157 var dividendsOrderAmount float64
123 for _, orderGood := range createDividendsOrderCommand.OrderGoods { 158 for _, orderGood := range createDividendsOrderCommand.OrderGoods {
  159 + // 计算订单产品金额
  160 + orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense)).Float64()
  161 +
  162 + // 校验合约
  163 + ruleMatchedFlag := false
  164 + if orderGood.CooperationContractNumber != "" {
  165 + // 校验共创合约激励类型是否正确
  166 + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
  167 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单产品不能关联金额激励规则")
  168 + }
  169 + // 校验产品关联合约的激励规则是否匹配订单时间
  170 + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
  171 + for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
  172 + if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
  173 + ruleMatchedFlag = true
  174 + break
  175 + }
  176 + }
  177 + }
  178 + if !ruleMatchedFlag {
  179 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
  180 + }
  181 + }
  182 +
124 orderGoods = append(orderGoods, &domain.OrderGood{ 183 orderGoods = append(orderGoods, &domain.OrderGood{
125 OrderGoodId: 0, 184 OrderGoodId: 0,
126 - OrderGoodAmount: orderGood.OrderGoodAmount, 185 + OrderGoodAmount: orderGoodAmount,
127 OrderGoodName: orderGood.OrderGoodName, 186 OrderGoodName: orderGood.OrderGoodName,
128 OrderGoodPrice: orderGood.OrderGoodPrice, 187 OrderGoodPrice: orderGood.OrderGoodPrice,
129 OrderGoodQuantity: orderGood.OrderGoodQuantity, 188 OrderGoodQuantity: orderGood.OrderGoodQuantity,
@@ -139,19 +198,11 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -139,19 +198,11 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
139 UpdatedAt: time.Time{}, 198 UpdatedAt: time.Time{},
140 }) 199 })
141 // 计算分红订单金额 200 // 计算分红订单金额
142 - dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount  
143 - }  
144 -  
145 - // 订单时间转换  
146 - orderTimeInt, err := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)  
147 - if err != nil {  
148 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间错误") 201 + dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense))).Float64()
149 } 202 }
150 - orderTime := utils.TransformTimestampToTime(orderTimeInt)  
151 203
152 // 新增分红订单 204 // 新增分红订单
153 newDividendsOrder := &domain.DividendsOrder{ 205 newDividendsOrder := &domain.DividendsOrder{
154 - DividendsOrderId: 0,  
155 DividendsOrderNumber: dividendsOrderNumber, 206 DividendsOrderNumber: dividendsOrderNumber,
156 DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum, 207 DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum,
157 DividendsOrderAmount: dividendsOrderAmount, 208 DividendsOrderAmount: dividendsOrderAmount,
@@ -257,6 +308,33 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -257,6 +308,33 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
257 operator = data 308 operator = data
258 } 309 }
259 310
  311 + // 合约仓储初始化
  312 + var cooperationContractRepository domain.CooperationContractRepository
  313 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  314 + "transactionContext": transactionContext,
  315 + }); err != nil {
  316 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  317 + } else {
  318 + cooperationContractRepository = value
  319 + }
  320 +
  321 + // 查找合约
  322 + cooperationContractsMap := make(map[string]*domain.CooperationContract)
  323 + countContracts, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
  324 + "offsetLimit": false,
  325 + "companyId": importDividendsOrderCommand.CompanyId,
  326 + "orgId": importDividendsOrderCommand.OrgId,
  327 + })
  328 + if err != nil {
  329 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  330 + } else {
  331 + if countContracts > 0 {
  332 + for _, cooperationContract := range cooperationContracts {
  333 + cooperationContractsMap[cooperationContract.CooperationContractNumber] = cooperationContract
  334 + }
  335 + }
  336 + }
  337 +
260 // 分红订单DAO初始化 338 // 分红订单DAO初始化
261 var dividendsOrderDao *dao.DividendsOrderDao 339 var dividendsOrderDao *dao.DividendsOrderDao
262 if value, err := factory.CreateDividendsOrderDao(map[string]interface{}{ 340 if value, err := factory.CreateDividendsOrderDao(map[string]interface{}{
@@ -297,7 +375,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -297,7 +375,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
297 } 375 }
298 376
299 // 必填项校验 377 // 必填项校验
300 - nullCellError := make([]interface{}, 0) 378 + nullCellError := make([]*domain.FailInfo, 0)
301 379
302 // 数据行计数 380 // 数据行计数
303 rowCnt := 0 381 rowCnt := 0
@@ -308,7 +386,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -308,7 +386,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
308 for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData { 386 for i, dividendsOrder := range importDividendsOrderCommand.DividendsOrderData {
309 rowCnt++ 387 rowCnt++
310 nullCell := make([]interface{}, 0) 388 nullCell := make([]interface{}, 0)
311 - //var myRow []string  
312 t := reflect.TypeOf(dividendsOrder) 389 t := reflect.TypeOf(dividendsOrder)
313 v := reflect.ValueOf(dividendsOrder) 390 v := reflect.ValueOf(dividendsOrder)
314 for k := 0; k < t.NumField(); k++ { 391 for k := 0; k < t.NumField(); k++ {
@@ -323,7 +400,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -323,7 +400,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
323 } 400 }
324 if nullFlag { 401 if nullFlag {
325 myRow := &domain.FailInfo{ 402 myRow := &domain.FailInfo{
326 - FailReason: "订单日期格式错误,请输入正确的订单日期", 403 + FailReason: "必填项为空",
327 } 404 }
328 myRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[i] 405 myRow.ImportDividendsOrderData = &importDividendsOrderCommand.DividendsOrderData[i]
329 nullCellError = append(nullCellError, myRow) 406 nullCellError = append(nullCellError, myRow)
@@ -459,7 +536,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -459,7 +536,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
459 // 订单日期时间格式转换 536 // 订单日期时间格式转换
460 timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local) 537 timeValue, err := time.ParseInLocation("2006/01/02", dividendsOrder.OrderTime, time.Local)
461 if err != nil { 538 if err != nil {
462 - //s := strconv.Itoa(i + 1)  
463 tmpRow := &domain.FailInfo{ 539 tmpRow := &domain.FailInfo{
464 FailReason: "无效的订单日期", 540 FailReason: "无效的订单日期",
465 } 541 }
@@ -469,7 +545,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -469,7 +545,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
469 } 545 }
470 546
471 // 产品相关:产品名称,产品数量、产品价格、费用 547 // 产品相关:产品名称,产品数量、产品价格、费用
472 - quantity, err := strconv.ParseInt(dividendsOrder.OrderGoodQuantity, 10, 64) 548 + quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64)
473 if err != nil { 549 if err != nil {
474 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 550 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
475 } 551 }
@@ -477,9 +553,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -477,9 +553,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
477 if err != nil { 553 if err != nil {
478 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 554 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
479 } 555 }
480 - expense, err := strconv.ParseFloat(dividendsOrder.Expense, 64)  
481 - if err != nil { 556 + var expense float64
  557 + if dividendsOrder.Expense != "" {
  558 + if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
482 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 559 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  560 + } else {
  561 + expense = expenseParse
  562 + }
483 } 563 }
484 564
485 // 初始化新建分红订单命令集 565 // 初始化新建分红订单命令集
@@ -510,7 +590,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -510,7 +590,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
510 } 590 }
511 } else { // 聚合同一笔订单产品 591 } else { // 聚合同一笔订单产品
512 // 产品相关:产品名称,产品数量、产品价格、费用 592 // 产品相关:产品名称,产品数量、产品价格、费用
513 - quantity, err := strconv.ParseInt(dividendsOrder.OrderGoodQuantity, 10, 64) 593 + quantity, err := strconv.ParseFloat(dividendsOrder.OrderGoodQuantity, 64)
514 if err != nil { 594 if err != nil {
515 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 595 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
516 } 596 }
@@ -518,9 +598,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -518,9 +598,13 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
518 if err != nil { 598 if err != nil {
519 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 599 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
520 } 600 }
521 - expense, err := strconv.ParseFloat(dividendsOrder.Expense, 64)  
522 - if err != nil { 601 + var expense float64
  602 + if dividendsOrder.Expense != "" {
  603 + if expenseParse, err := strconv.ParseFloat(dividendsOrder.Expense, 64); err != nil {
523 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 604 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  605 + } else {
  606 + expense = expenseParse
  607 + }
524 } 608 }
525 609
526 dividendsOrderCommands[hashString].OrderGoods = append(dividendsOrderCommands[hashString].OrderGoods, command.OrderGoods{ 610 dividendsOrderCommands[hashString].OrderGoods = append(dividendsOrderCommands[hashString].OrderGoods, command.OrderGoods{
@@ -586,7 +670,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -586,7 +670,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
586 for _, errorData := range errorDataList { 670 for _, errorData := range errorDataList {
587 if len(errorData.GoodLine) == 0 { // 订单错误 671 if len(errorData.GoodLine) == 0 { // 订单错误
588 for _, line := range errorData.LineNumbers { 672 for _, line := range errorData.LineNumbers {
589 - //s := strconv.Itoa(line + 1)  
590 tmpRow := &domain.FailInfo{ 673 tmpRow := &domain.FailInfo{
591 FailReason: "数据校验错误:" + errorData.Error.Error(), 674 FailReason: "数据校验错误:" + errorData.Error.Error(),
592 } 675 }
@@ -595,7 +678,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -595,7 +678,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
595 } 678 }
596 } else if len(errorData.GoodLine) > 0 { // 订单产品错误 679 } else if len(errorData.GoodLine) > 0 { // 订单产品错误
597 for line := range errorData.GoodLine { 680 for line := range errorData.GoodLine {
598 - //s := strconv.Itoa(line + 1)  
599 tmpRow := &domain.FailInfo{ 681 tmpRow := &domain.FailInfo{
600 FailReason: "订单产品信息错误:" + errorData.Error.Error(), 682 FailReason: "订单产品信息错误:" + errorData.Error.Error(),
601 } 683 }
@@ -613,36 +695,35 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -613,36 +695,35 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
613 }, nil 695 }, nil
614 } 696 }
615 697
616 - // 批量导入创建分红订单  
617 - for _, dividendsOrder := range createDividendsOrderCommands {  
618 - // 生成分红订单号  
619 - dividendsOrderNumber, err := dividendsOrderDao.GenerateDividendsOrderNumber() 698 + // 创建分红订单领域模型
  699 + var creatDividendsOrder []*domain.DividendsOrder
  700 +
  701 + // 统计当前分红订单数
  702 + count, err := dividendsOrderDao.CountDividendsOrder(map[string]interface{}{})
620 if err != nil { 703 if err != nil {
621 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 704 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
622 } 705 }
623 706
624 - // 校验分红订单编号是否唯一  
625 - numberAvailable, err3 := dividendsOrderDao.CheckDividendsOrderNumberAvailable(map[string]interface{}{  
626 - "companyId": importDividendsOrderCommand.CompanyId,  
627 - "orgId": importDividendsOrderCommand.OrgId,  
628 - "dividendsOrderNumber": dividendsOrderNumber,  
629 - })  
630 - if err3 != nil {  
631 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())  
632 - }  
633 - if !numberAvailable {  
634 - return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常") 707 + // 批量创建分红订单
  708 + for i, dividendsOrder := range createDividendsOrderCommands {
  709 + // 生成分红订单号
  710 + dividendsOrderNumber, err := dividendsOrder.GenerateSpecificDividendsOrderNumber(int64(count), time.Time{}, int64(i))
  711 + if err != nil {
  712 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
635 } 713 }
636 714
637 - // 共创合约DAO初始化  
638 - var cooperationContractDao *dao.CooperationContractDao  
639 - if value, err := factory.CreateCooperationContractDao(map[string]interface{}{  
640 - "transactionContext": transactionContext,  
641 - }); err != nil {  
642 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
643 - } else {  
644 - cooperationContractDao = value 715 + // 订单时间转换
  716 + orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64)
  717 + if err != nil {
  718 + row := &domain.ImportInfo{
  719 + Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("订单日期转换错误:%s", err)),
  720 + LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行
  721 + GoodLine: map[int]interface{}{},
645 } 722 }
  723 + errorDataList = append(errorDataList, row)
  724 + continue
  725 + }
  726 + orderTime := utils.TransformTimestampToTime(orderTimeInt)
646 727
647 // 新增订单产品 728 // 新增订单产品
648 var orderGoods []*domain.OrderGood 729 var orderGoods []*domain.OrderGood
@@ -650,20 +731,43 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -650,20 +731,43 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
650 orderGoodErrMap := make(map[int]interface{}, 0) 731 orderGoodErrMap := make(map[int]interface{}, 0)
651 for i, orderGood := range dividendsOrder.OrderGoods { 732 for i, orderGood := range dividendsOrder.OrderGoods {
652 // 校验共创合约是否合法 733 // 校验共创合约是否合法
653 - if orderGood.CooperationContractNumber != "" {  
654 - contractNumberExist, _ := cooperationContractDao.CheckContractNumberExist(map[string]interface{}{  
655 - "companyId": importDividendsOrderCommand.CompanyId,  
656 - "orgId": importDividendsOrderCommand.OrgId,  
657 - "cooperationContractNumber": orderGood.CooperationContractNumber,  
658 - }) 734 + contractNumberExist := false
  735 + for _, cooperationContract := range cooperationContracts {
  736 + if orderGood.CooperationContractNumber == cooperationContract.CooperationContractNumber {
  737 + contractNumberExist = true
  738 + break
  739 + }
  740 + }
659 if !contractNumberExist { 741 if !contractNumberExist {
660 orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("共创合约编号不存在:%s", err)) 742 orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("共创合约编号不存在:%s", err))
661 } 743 }
  744 +
  745 + // 计算产品金额
  746 + orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense)).Float64()
  747 +
  748 + // 校验共创合约激励类型是否正确
  749 + ruleMatchedFlag := false
  750 + if orderGood.CooperationContractNumber != "" {
  751 + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
  752 + orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
  753 + }
  754 + // 校验产品关联合约的激励规则是否匹配订单时间
  755 + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
  756 + for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
  757 + if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
  758 + ruleMatchedFlag = true
  759 + break
  760 + }
  761 + }
  762 + }
  763 + if !ruleMatchedFlag {
  764 + orderGoodErrMap[dividendsOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
  765 + }
662 } 766 }
663 767
664 orderGoods = append(orderGoods, &domain.OrderGood{ 768 orderGoods = append(orderGoods, &domain.OrderGood{
665 OrderGoodId: 0, 769 OrderGoodId: 0,
666 - OrderGoodAmount: orderGood.OrderGoodAmount, 770 + OrderGoodAmount: orderGoodAmount,
667 OrderGoodName: orderGood.OrderGoodName, 771 OrderGoodName: orderGood.OrderGoodName,
668 OrderGoodPrice: orderGood.OrderGoodPrice, 772 OrderGoodPrice: orderGood.OrderGoodPrice,
669 OrderGoodQuantity: orderGood.OrderGoodQuantity, 773 OrderGoodQuantity: orderGood.OrderGoodQuantity,
@@ -679,7 +783,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -679,7 +783,7 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
679 }) 783 })
680 784
681 // 计算分红订单金额 785 // 计算分红订单金额
682 - dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount 786 + dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense)))).Float64()
683 } 787 }
684 if len(orderGoodErrMap) > 0 { 788 if len(orderGoodErrMap) > 0 {
685 row := &domain.ImportInfo{ 789 row := &domain.ImportInfo{
@@ -691,19 +795,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -691,19 +795,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
691 continue 795 continue
692 } 796 }
693 797
694 - // 订单时间转换  
695 - orderTimeInt, err := strconv.ParseInt(dividendsOrder.OrderTime, 10, 64)  
696 - if err != nil {  
697 - row := &domain.ImportInfo{  
698 - Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("订单日期转换错误:%s", err)),  
699 - LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行  
700 - GoodLine: map[int]interface{}{},  
701 - }  
702 - errorDataList = append(errorDataList, row)  
703 - continue  
704 - }  
705 - orderTime := utils.TransformTimestampToTime(orderTimeInt)  
706 -  
707 // 新增分红订单 798 // 新增分红订单
708 newDividendsOrder := &domain.DividendsOrder{ 799 newDividendsOrder := &domain.DividendsOrder{
709 DividendsOrderId: 0, 800 DividendsOrderId: 0,
@@ -728,19 +819,14 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -728,19 +819,14 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
728 Operator: operator, 819 Operator: operator,
729 } 820 }
730 821
731 - if _, err2 := dividendsOrderRepository.Save(newDividendsOrder); err2 != nil {  
732 - row := &domain.ImportInfo{  
733 - Error: application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单数据失败:%s", err)),  
734 - LineNumbers: dividendsOrder.LineNumbers, // 错误影响的行  
735 - GoodLine: map[int]interface{}{},  
736 - }  
737 - errorDataList = append(errorDataList, row)  
738 - continue  
739 - } 822 + creatDividendsOrder = append(creatDividendsOrder, newDividendsOrder)
740 } 823 }
741 824
742 // 错误报告处理 825 // 错误报告处理
743 if len(errorDataList) <= 0 { // 成功返回 826 if len(errorDataList) <= 0 { // 成功返回
  827 + if _, err2 := dividendsOrderRepository.SaveMany(creatDividendsOrder); err2 != nil {
  828 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err2.Error())
  829 + }
744 if err3 := transactionContext.CommitTransaction(); err3 != nil { 830 if err3 := transactionContext.CommitTransaction(); err3 != nil {
745 return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error()) 831 return nil, application.ThrowError(application.TRANSACTION_ERROR, err3.Error())
746 } 832 }
@@ -757,7 +843,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -757,7 +843,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
757 for _, errorData := range errorDataList { 843 for _, errorData := range errorDataList {
758 if len(errorData.GoodLine) == 0 { // 订单错误 844 if len(errorData.GoodLine) == 0 { // 订单错误
759 for _, line := range errorData.LineNumbers { 845 for _, line := range errorData.LineNumbers {
760 - //s := strconv.Itoa(line + 1)  
761 tmpRow := &domain.FailInfo{ 846 tmpRow := &domain.FailInfo{
762 FailReason: "订单数据新增错误:" + errorData.Error.Error(), 847 FailReason: "订单数据新增错误:" + errorData.Error.Error(),
763 } 848 }
@@ -766,7 +851,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD @@ -766,7 +851,6 @@ func (dividendsOrderService *DividendsOrderService) ImportDividendsOrder(importD
766 } 851 }
767 } else if len(errorData.GoodLine) > 0 { // 订单产品错误 852 } else if len(errorData.GoodLine) > 0 { // 订单产品错误
768 for line := range errorData.GoodLine { 853 for line := range errorData.GoodLine {
769 - //s := strconv.Itoa(line + 1)  
770 tmpRow := &domain.FailInfo{ 854 tmpRow := &domain.FailInfo{
771 FailReason: "订单数据新增错误:" + errorData.Error.Error(), 855 FailReason: "订单数据新增错误:" + errorData.Error.Error(),
772 } 856 }
@@ -888,15 +972,15 @@ func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeD @@ -888,15 +972,15 @@ func (dividendsOrderService *DividendsOrderService) RemoveDividendsOrder(removeD
888 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 972 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
889 } 973 }
890 if dividendsOrder == nil { 974 if dividendsOrder == nil {
891 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeDividendsOrderCommand.DividendsOrderId))) 975 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(removeDividendsOrderCommand.DividendsOrderId, 10)))
892 } 976 }
893 - if dividendsOrder, err := dividendsOrderRepository.Remove(dividendsOrder); err != nil { 977 + if dividendsOrderRemoved, err := dividendsOrderRepository.Remove(dividendsOrder); err != nil {
894 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 978 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
895 } else { 979 } else {
896 if err := transactionContext.CommitTransaction(); err != nil { 980 if err := transactionContext.CommitTransaction(); err != nil {
897 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 981 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
898 } 982 }
899 - return dividendsOrder, nil 983 + return dividendsOrderRemoved, nil
900 } 984 }
901 } 985 }
902 986
@@ -924,7 +1008,10 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba @@ -924,7 +1008,10 @@ func (dividendsOrderService *DividendsOrderService) BatchRemoveDividendsOrder(ba
924 dividendsOrderRepository = value 1008 dividendsOrderRepository = value
925 } 1009 }
926 1010
927 - dividendsOrderIds, _ := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds) 1011 + dividendsOrderIds, err := utils.SliceAtoi(batchRemoveDividendsOrderCommand.DividendsOrderIds)
  1012 + if err != nil {
  1013 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单ID类型错误")
  1014 + }
928 if count, dividendsOrders, err := dividendsOrderRepository.Find(map[string]interface{}{ 1015 if count, dividendsOrders, err := dividendsOrderRepository.Find(map[string]interface{}{
929 "dividendsOrderIds": dividendsOrderIds, 1016 "dividendsOrderIds": dividendsOrderIds,
930 }); err != nil { 1017 }); err != nil {
@@ -1055,8 +1142,14 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD @@ -1055,8 +1142,14 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD
1055 } 1142 }
1056 orderTime := utils.TransformTimestampToTime(orderTimeInt) 1143 orderTime := utils.TransformTimestampToTime(orderTimeInt)
1057 1144
  1145 + // 分红订单ID类型转换
  1146 + dividendsOrderId, err := strconv.ParseInt(updateDividendsOrderCommand.DividendsOrderId, 10, 64)
  1147 + if err != nil {
  1148 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1149 + }
  1150 +
1058 // 获取分红订单 1151 // 获取分红订单
1059 - dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderId": updateDividendsOrderCommand.DividendsOrderId}) 1152 + dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderId": dividendsOrderId})
1060 if err != nil { 1153 if err != nil {
1061 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在") 1154 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
1062 } 1155 }
@@ -1064,18 +1157,68 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD @@ -1064,18 +1157,68 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD
1064 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateDividendsOrderCommand.DividendsOrderId))) 1157 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateDividendsOrderCommand.DividendsOrderId)))
1065 } 1158 }
1066 1159
  1160 + // 合约仓储初始化
  1161 + var cooperationContractRepository domain.CooperationContractRepository
  1162 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  1163 + "transactionContext": transactionContext,
  1164 + }); err != nil {
  1165 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1166 + } else {
  1167 + cooperationContractRepository = value
  1168 + }
  1169 +
  1170 + // 查找合约
  1171 + cooperationContractsMap := make(map[string]*domain.CooperationContract)
  1172 + if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
  1173 + "offsetLimit": false,
  1174 + "companyId": updateDividendsOrderCommand.CompanyId,
  1175 + "orgId": updateDividendsOrderCommand.OrgId,
  1176 + }); err != nil {
  1177 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1178 + } else {
  1179 + if count > 0 {
  1180 + for _, cooperationContract := range cooperationContracts {
  1181 + cooperationContractsMap[cooperationContract.CooperationContractNumber] = cooperationContract
  1182 + }
  1183 + }
  1184 + }
  1185 +
1067 // 获取订单产品 1186 // 获取订单产品
1068 var orderGoods []*domain.OrderGood 1187 var orderGoods []*domain.OrderGood
1069 var dividendsOrderAmount float64 1188 var dividendsOrderAmount float64
1070 for _, orderGood := range updateDividendsOrderCommand.OrderGoods { 1189 for _, orderGood := range updateDividendsOrderCommand.OrderGoods {
  1190 + // 计算订单产品金额
  1191 + orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense)).Float64()
  1192 +
1071 // 产品ID类型转换 1193 // 产品ID类型转换
1072 orderGoodId, err3 := strconv.ParseInt(orderGood.OrderGoodId, 10, 64) 1194 orderGoodId, err3 := strconv.ParseInt(orderGood.OrderGoodId, 10, 64)
1073 if err3 != nil { 1195 if err3 != nil {
1074 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error()) 1196 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
1075 } 1197 }
  1198 +
  1199 + ruleMatchedFlag := false
  1200 + if orderGood.CooperationContractNumber != "" {
  1201 + // 校验共创合约激励类型是否正确
  1202 + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
  1203 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单产品不能关联金额激励规则")
  1204 + }
  1205 + // 校验产品关联合约的激励规则是否匹配订单时间
  1206 + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
  1207 + for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
  1208 + if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
  1209 + ruleMatchedFlag = true
  1210 + break
  1211 + }
  1212 + }
  1213 + }
  1214 + if !ruleMatchedFlag {
  1215 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
  1216 + }
  1217 + }
  1218 +
1076 orderGoods = append(orderGoods, &domain.OrderGood{ 1219 orderGoods = append(orderGoods, &domain.OrderGood{
1077 OrderGoodId: orderGoodId, 1220 OrderGoodId: orderGoodId,
1078 - OrderGoodAmount: orderGood.OrderGoodAmount, 1221 + OrderGoodAmount: orderGoodAmount,
1079 OrderGoodName: orderGood.OrderGoodName, 1222 OrderGoodName: orderGood.OrderGoodName,
1080 OrderGoodPrice: orderGood.OrderGoodPrice, 1223 OrderGoodPrice: orderGood.OrderGoodPrice,
1081 OrderGoodQuantity: orderGood.OrderGoodQuantity, 1224 OrderGoodQuantity: orderGood.OrderGoodQuantity,
@@ -1083,13 +1226,14 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD @@ -1083,13 +1226,14 @@ func (dividendsOrderService *DividendsOrderService) UpdateDividendsOrder(updateD
1083 DividendsReturnedOrderNumber: "", 1226 DividendsReturnedOrderNumber: "",
1084 CooperationContractNumber: orderGood.CooperationContractNumber, 1227 CooperationContractNumber: orderGood.CooperationContractNumber,
1085 OrderGoodExpense: orderGood.OrderGoodExpense, 1228 OrderGoodExpense: orderGood.OrderGoodExpense,
  1229 + OrderGoodDividendsStatus: 0,
1086 OrgId: updateDividendsOrderCommand.OrgId, 1230 OrgId: updateDividendsOrderCommand.OrgId,
1087 CompanyId: updateDividendsOrderCommand.CompanyId, 1231 CompanyId: updateDividendsOrderCommand.CompanyId,
1088 CreatedAt: time.Time{}, 1232 CreatedAt: time.Time{},
1089 UpdatedAt: time.Now(), 1233 UpdatedAt: time.Now(),
1090 }) 1234 })
1091 // 计算分红订单金额 1235 // 计算分红订单金额
1092 - dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount 1236 + dividendsOrderAmount, _ = decimal.NewFromFloat(dividendsOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Sub(decimal.NewFromFloat(orderGood.OrderGoodExpense))).Float64()
1093 } 1237 }
1094 1238
1095 if err := dividendsOrder.Update(tool_funs.SimpleStructToMap(updateDividendsOrderCommand)); err != nil { 1239 if err := dividendsOrder.Update(tool_funs.SimpleStructToMap(updateDividendsOrderCommand)); err != nil {
@@ -17,13 +17,15 @@ type OrderGoods struct { @@ -17,13 +17,15 @@ type OrderGoods struct {
17 // 订单产品单价 17 // 订单产品单价
18 OrderGoodPrice float64 `cname:"订单产品单价" json:"orderGoodPrice"` 18 OrderGoodPrice float64 `cname:"订单产品单价" json:"orderGoodPrice"`
19 // 订单产品数量 19 // 订单产品数量
20 - OrderGoodQuantity int64 `cname:"订单产品数量" json:"orderGoodQuantity"` 20 + OrderGoodQuantity float64 `cname:"订单产品数量" json:"orderGoodQuantity"`
21 // 关联分红订单号 21 // 关联分红订单号
22 DividendsOrderNumber string `cname:"关联分红订单号" json:"dividendsOrderNumber"` 22 DividendsOrderNumber string `cname:"关联分红订单号" json:"dividendsOrderNumber"`
23 // 关联的共创合约编号 23 // 关联的共创合约编号
24 CooperationContractNumber string `cname:"关联的共创合约编号" json:"cooperationContractNumber"` 24 CooperationContractNumber string `cname:"关联的共创合约编号" json:"cooperationContractNumber"`
25 // 订单产品费用 25 // 订单产品费用
26 OrderGoodExpense float64 `cname:"订单产品费用" json:"orderGoodExpense"` 26 OrderGoodExpense float64 `cname:"订单产品费用" json:"orderGoodExpense"`
  27 + //行号-错误信息返回
  28 + LineNumber int `json:"lineNumber"`
27 } 29 }
28 30
29 type CreateDividendsReturnedOrderCommand struct { 31 type CreateDividendsReturnedOrderCommand struct {
@@ -34,9 +36,9 @@ type CreateDividendsReturnedOrderCommand struct { @@ -34,9 +36,9 @@ type CreateDividendsReturnedOrderCommand struct {
34 // 来源单号,源单号,订单号 36 // 来源单号,源单号,订单号
35 OriginalOrderNum string `cname:"来源单号" json:"originalOrderNum" valid:"Required"` 37 OriginalOrderNum string `cname:"来源单号" json:"originalOrderNum" valid:"Required"`
36 // 分红单号 38 // 分红单号
37 - DividendsOrderNumber string `cname:"订单号" json:"dividendsOrderNumber" valid:"Required"` 39 + DividendsOrderNumber string `cname:"订单号" json:"dividendsOrderNumber"`
38 // 备注 40 // 备注
39 - Remarks string `cname:"备注" json:"remarks" valid:"Required"` 41 + Remarks string `cname:"备注" json:"remarks,omitempty"`
40 // 退货日期 42 // 退货日期
41 DividendsReturnedDate string `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"` 43 DividendsReturnedDate string `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"`
42 // 订单日期 44 // 订单日期
@@ -10,14 +10,14 @@ import ( @@ -10,14 +10,14 @@ import (
10 type UpdateDividendsReturnedOrderCommand struct { 10 type UpdateDividendsReturnedOrderCommand struct {
11 // 分红退货单记录ID 11 // 分红退货单记录ID
12 DividendsReturnedOrderId string `cname:"分红退货单记录ID" json:"dividendsReturnedOrderId" valid:"Required"` 12 DividendsReturnedOrderId string `cname:"分红退货单记录ID" json:"dividendsReturnedOrderId" valid:"Required"`
13 - // 退货金额  
14 - DividendsReturnedOrderRefund float64 `cname:"退货金额" json:"dividendsReturnedOrderRefund" valid:"Required"`  
15 // 退货客户名称 13 // 退货客户名称
16 DividendsReturnedCustomerName string `cname:"退货客户名称" json:"dividendsReturnedCustomerName" valid:"Required"` 14 DividendsReturnedCustomerName string `cname:"退货客户名称" json:"dividendsReturnedCustomerName" valid:"Required"`
17 // 来源单号,源单号,订单号 15 // 来源单号,源单号,订单号
18 OriginalOrderNum string `cname:"来源单号" json:"originalOrderNum" valid:"Required"` 16 OriginalOrderNum string `cname:"来源单号" json:"originalOrderNum" valid:"Required"`
  17 + // 分红单号
  18 + DividendsOrderNumber string `cname:"订单号" json:"dividendsOrderNumber"`
19 // 备注 19 // 备注
20 - Remarks string `cname:"备注" json:"remarks" valid:"Required"` 20 + Remarks string `cname:"备注" json:"remarks"`
21 // 退货日期 21 // 退货日期
22 DividendsReturnedDate string `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"` 22 DividendsReturnedDate string `cname:"退货日期" json:"dividendsReturnedDate" valid:"Required"`
23 // 退货区域 23 // 退货区域
@@ -37,7 +37,15 @@ type UpdateDividendsReturnedOrderCommand struct { @@ -37,7 +37,15 @@ type UpdateDividendsReturnedOrderCommand struct {
37 } 37 }
38 38
39 func (updateDividendsReturnedOrderCommand *UpdateDividendsReturnedOrderCommand) Valid(validation *validation.Validation) { 39 func (updateDividendsReturnedOrderCommand *UpdateDividendsReturnedOrderCommand) Valid(validation *validation.Validation) {
40 - //validation.SetError("CustomValid", "未实现的自定义认证") 40 + if len(updateDividendsReturnedOrderCommand.OrderGoods) <= 0 {
  41 + validation.Error("退货单产品不能为空")
  42 + } else {
  43 + for i, _ := range updateDividendsReturnedOrderCommand.OrderGoods {
  44 + if updateDividendsReturnedOrderCommand.OrderGoods[i].OrderGoodId == "" {
  45 + updateDividendsReturnedOrderCommand.OrderGoods[i].OrderGoodId = "0"
  46 + }
  47 + }
  48 + }
41 } 49 }
42 50
43 func (updateDividendsReturnedOrderCommand *UpdateDividendsReturnedOrderCommand) ValidateCommand() error { 51 func (updateDividendsReturnedOrderCommand *UpdateDividendsReturnedOrderCommand) ValidateCommand() error {
@@ -6,6 +6,7 @@ import ( @@ -6,6 +6,7 @@ import (
6 "fmt" 6 "fmt"
7 "github.com/linmadan/egglib-go/core/application" 7 "github.com/linmadan/egglib-go/core/application"
8 "github.com/linmadan/egglib-go/utils/tool_funs" 8 "github.com/linmadan/egglib-go/utils/tool_funs"
  9 + "github.com/shopspring/decimal"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/command" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/command"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/query" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/query"
11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
@@ -16,7 +17,6 @@ import ( @@ -16,7 +17,6 @@ import (
16 "reflect" 17 "reflect"
17 "regexp" 18 "regexp"
18 "strconv" 19 "strconv"
19 - "strings"  
20 "time" 20 "time"
21 ) 21 )
22 22
@@ -99,7 +99,9 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide @@ -99,7 +99,9 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
99 } 99 }
100 100
101 // 生成分红订单号 101 // 生成分红订单号
102 - dividendsReturnedOrderNumber, err := dividendsReturnedOrderDao.GenerateDividendsReturnedOrderNumber() 102 + dividendsReturnedOrderNumber, err := dividendsReturnedOrderDao.GenerateDividendsReturnedOrderNumber(map[string]interface{}{
  103 + "companyId": createDividendsReturnedOrderCommand.CompanyId,
  104 + })
103 if err != nil { 105 if err != nil {
104 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 106 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
105 } 107 }
@@ -121,7 +123,6 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide @@ -121,7 +123,6 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
121 // 校验分红退货单编号是否唯一 123 // 校验分红退货单编号是否唯一
122 numberAvailable, err := dividendsReturnedOrderDao.CheckDividendsReturnedOrderNumberAvailable(map[string]interface{}{ 124 numberAvailable, err := dividendsReturnedOrderDao.CheckDividendsReturnedOrderNumberAvailable(map[string]interface{}{
123 "companyId": createDividendsReturnedOrderCommand.CompanyId, 125 "companyId": createDividendsReturnedOrderCommand.CompanyId,
124 - "orgId": createDividendsReturnedOrderCommand.OrgId,  
125 "dividendsReturnedOrderNumber": dividendsReturnedOrderNumber, 126 "dividendsReturnedOrderNumber": dividendsReturnedOrderNumber,
126 }) 127 })
127 if err != nil { 128 if err != nil {
@@ -131,12 +132,64 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide @@ -131,12 +132,64 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
131 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红退货单号已存在") 132 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红退货单号已存在")
132 } 133 }
133 134
134 - // 获取分红退货单产品 135 + // 合约仓储初始化
  136 + var cooperationContractRepository domain.CooperationContractRepository
  137 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  138 + "transactionContext": transactionContext,
  139 + }); err != nil {
  140 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  141 + } else {
  142 + cooperationContractRepository = value
  143 + }
  144 +
  145 + // 查找合约
  146 + cooperationContractsMap := make(map[string]*domain.CooperationContract)
  147 + if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
  148 + "offsetLimit": false,
  149 + "companyId": createDividendsReturnedOrderCommand.CompanyId,
  150 + "orgId": createDividendsReturnedOrderCommand.OrgId,
  151 + }); err != nil {
  152 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  153 + } else {
  154 + if count > 0 {
  155 + for _, cooperationContract := range cooperationContracts {
  156 + cooperationContractsMap[cooperationContract.CooperationContractNumber] = cooperationContract
  157 + }
  158 + }
  159 + }
  160 +
  161 + // 退货金额
  162 + var dividendsReturnedOrderRefund float64
  163 +
  164 + // 新增分红退货单产品
135 var orderGoods []*domain.OrderGood 165 var orderGoods []*domain.OrderGood
136 for _, orderGood := range createDividendsReturnedOrderCommand.OrderGoods { 166 for _, orderGood := range createDividendsReturnedOrderCommand.OrderGoods {
  167 + // 退货产品金额计算
  168 + orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
  169 +
  170 + // 校验合约激励类型是否正确
  171 + ruleMatchedFlag := false
  172 + if orderGood.CooperationContractNumber != "" {
  173 + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
  174 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
  175 + }
  176 + // 校验产品关联合约的激励规则是否匹配订单时间
  177 + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
  178 + for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
  179 + if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
  180 + ruleMatchedFlag = true
  181 + break
  182 + }
  183 + }
  184 + }
  185 + if !ruleMatchedFlag {
  186 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
  187 + }
  188 + }
  189 +
137 orderGoods = append(orderGoods, &domain.OrderGood{ 190 orderGoods = append(orderGoods, &domain.OrderGood{
138 OrderGoodId: 0, 191 OrderGoodId: 0,
139 - OrderGoodAmount: orderGood.OrderGoodAmount, 192 + OrderGoodAmount: orderGoodAmount,
140 OrderGoodName: orderGood.OrderGoodName, 193 OrderGoodName: orderGood.OrderGoodName,
141 OrderGoodPrice: orderGood.OrderGoodPrice, 194 OrderGoodPrice: orderGood.OrderGoodPrice,
142 OrderGoodQuantity: orderGood.OrderGoodQuantity, 195 OrderGoodQuantity: orderGood.OrderGoodQuantity,
@@ -151,11 +204,13 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide @@ -151,11 +204,13 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) CreateDivide
151 DeletedAt: time.Time{}, 204 DeletedAt: time.Time{},
152 UpdatedAt: time.Time{}, 205 UpdatedAt: time.Time{},
153 }) 206 })
  207 + // 计算退货订单金额
  208 + dividendsReturnedOrderRefund, _ = decimal.NewFromFloat(dividendsReturnedOrderRefund).Add(decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity))).Float64()
154 } 209 }
155 210
156 newDividendsReturnedOrder := &domain.DividendsReturnedOrder{ 211 newDividendsReturnedOrder := &domain.DividendsReturnedOrder{
157 DividendsReturnedOrderNumber: dividendsReturnedOrderNumber, 212 DividendsReturnedOrderNumber: dividendsReturnedOrderNumber,
158 - DividendsReturnedOrderRefund: createDividendsReturnedOrderCommand.DividendsReturnedOrderRefund, 213 + DividendsReturnedOrderRefund: dividendsReturnedOrderRefund,
159 OriginalOrderNum: createDividendsReturnedOrderCommand.OriginalOrderNum, 214 OriginalOrderNum: createDividendsReturnedOrderCommand.OriginalOrderNum,
160 DividendsOrderNumber: createDividendsReturnedOrderCommand.DividendsOrderNumber, 215 DividendsOrderNumber: createDividendsReturnedOrderCommand.DividendsOrderNumber,
161 DividendsReturnedCustomerName: createDividendsReturnedOrderCommand.DividendsReturnedCustomerName, 216 DividendsReturnedCustomerName: createDividendsReturnedOrderCommand.DividendsReturnedCustomerName,
@@ -316,6 +371,33 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -316,6 +371,33 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
316 dividendsReturnedOrderRepository = value 371 dividendsReturnedOrderRepository = value
317 } 372 }
318 373
  374 + // 合约仓储初始化
  375 + var cooperationContractRepository domain.CooperationContractRepository
  376 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  377 + "transactionContext": transactionContext,
  378 + }); err != nil {
  379 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  380 + } else {
  381 + cooperationContractRepository = value
  382 + }
  383 +
  384 + // 查找合约
  385 + cooperationContractsMap := make(map[string]*domain.CooperationContract)
  386 + countContracts, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
  387 + "offsetLimit": false,
  388 + "companyId": importDividendsReturnedOrderCommand.CompanyId,
  389 + "orgId": importDividendsReturnedOrderCommand.OrgId,
  390 + })
  391 + if err != nil {
  392 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  393 + } else {
  394 + if countContracts > 0 {
  395 + for _, cooperationContract := range cooperationContracts {
  396 + cooperationContractsMap[cooperationContract.CooperationContractNumber] = cooperationContract
  397 + }
  398 + }
  399 + }
  400 +
319 // 返回信息表头定义 401 // 返回信息表头定义
320 var tableHeader = map[string]interface{}{ 402 var tableHeader = map[string]interface{}{
321 "failReason": "错误详情", 403 "failReason": "错误详情",
@@ -347,7 +429,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -347,7 +429,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
347 for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { 429 for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData {
348 rowCnt++ 430 rowCnt++
349 nullCell := make([]interface{}, 0) 431 nullCell := make([]interface{}, 0)
350 - var myRow []string 432 + var myRow *domain.FailReturnedInfo
351 t := reflect.TypeOf(dividendsReturnedOrder) 433 t := reflect.TypeOf(dividendsReturnedOrder)
352 v := reflect.ValueOf(dividendsReturnedOrder) 434 v := reflect.ValueOf(dividendsReturnedOrder)
353 for k := 0; k < t.NumField(); k++ { 435 for k := 0; k < t.NumField(); k++ {
@@ -361,11 +443,12 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -361,11 +443,12 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
361 } 443 }
362 } 444 }
363 if nullFlag { 445 if nullFlag {
364 - s := strconv.Itoa(i + 1)  
365 - b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1)  
366 - myRow = append(myRow, "第"+s+"行的第"+b+"列必填项为空") // 错误信息  
367 - myRow = append(myRow, s) // 行号  
368 - myRow = append(myRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据 446 + //s := strconv.Itoa(i + 1)
  447 + //b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1)
  448 + myRow = &domain.FailReturnedInfo{
  449 + FailReason: "必填项为空",
  450 + ImportDividendsReturnedOrderData: &importDividendsReturnedOrderCommand.DividendsReturnedOrderData[i],
  451 + }
369 nullCellError = append(nullCellError, myRow) 452 nullCellError = append(nullCellError, myRow)
370 nullFlag = false 453 nullFlag = false
371 } 454 }
@@ -384,24 +467,22 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -384,24 +467,22 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
384 467
385 // 单元格类型校验 468 // 单元格类型校验
386 typeError := make([]interface{}, 0) 469 typeError := make([]interface{}, 0)
387 - for i, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { // 行  
388 - var myRow []string 470 + for _, dividendsReturnedOrder := range importDividendsReturnedOrderCommand.DividendsReturnedOrderData { // 行
  471 + var myRow *domain.FailReturnedInfo
389 t := reflect.TypeOf(dividendsReturnedOrder) 472 t := reflect.TypeOf(dividendsReturnedOrder)
390 v := reflect.ValueOf(dividendsReturnedOrder) 473 v := reflect.ValueOf(dividendsReturnedOrder)
391 for k := 0; k < t.NumField(); k++ { // 列 474 for k := 0; k < t.NumField(); k++ { // 列
392 - r := strconv.Itoa(i + 1)  
393 - col := strconv.Itoa(k + 1)  
394 -  
395 switch k { 475 switch k {
396 case 3: // 退货日期校验 476 case 3: // 退货日期校验
397 { 477 {
398 regexpStr := `(\d{4})/(\d{2})/(\d{2})` 478 regexpStr := `(\d{4})/(\d{2})/(\d{2})`
399 ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface())) 479 ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
400 if !ok { 480 if !ok {
401 - var tmpRow []string  
402 - tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货日期格式错误,请输入正确的退货日期") // 错误信息  
403 - tmpRow = append(tmpRow, r) // 行号  
404 - tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据 481 + var tmpRow *domain.FailReturnedInfo
  482 + tmpRow = &domain.FailReturnedInfo{
  483 + FailReason: "退货日期格式错误,请输入正确的退货日期",
  484 + ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
  485 + }
405 myRow = tmpRow 486 myRow = tmpRow
406 } 487 }
407 } 488 }
@@ -410,10 +491,11 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -410,10 +491,11 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
410 regexpStr := `(\d{4})/(\d{2})/(\d{2})` 491 regexpStr := `(\d{4})/(\d{2})/(\d{2})`
411 ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface())) 492 ok := regexp.MustCompile(regexpStr).MatchString(fmt.Sprintf("%v", v.Field(k).Interface()))
412 if !ok { 493 if !ok {
413 - var tmpRow []string  
414 - tmpRow = append(tmpRow, "第"+r+"行第"+col+"列订单日期格式错误,请输入正确的订单日期") // 错误信息  
415 - tmpRow = append(tmpRow, r) // 行号  
416 - tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据 494 + var tmpRow *domain.FailReturnedInfo
  495 + tmpRow = &domain.FailReturnedInfo{
  496 + FailReason: "订单日期格式错误,请输入正确的订单日期",
  497 + ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
  498 + }
417 myRow = tmpRow 499 myRow = tmpRow
418 } 500 }
419 } 501 }
@@ -422,18 +504,20 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -422,18 +504,20 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
422 //参数类型转换 504 //参数类型转换
423 orderGoodQuantity, err := strconv.ParseInt(fmt.Sprintf("%v", v.Field(k).Interface()), 10, 64) 505 orderGoodQuantity, err := strconv.ParseInt(fmt.Sprintf("%v", v.Field(k).Interface()), 10, 64)
424 if err != nil { 506 if err != nil {
425 - var tmpRow []string  
426 - tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货数量格式错误,退货数量必须整数") // 错误信息  
427 - tmpRow = append(tmpRow, r) // 行号  
428 - tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据 507 + var tmpRow *domain.FailReturnedInfo
  508 + tmpRow = &domain.FailReturnedInfo{
  509 + FailReason: "退货数量格式错误,退货数量必须整数",
  510 + ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
  511 + }
429 myRow = tmpRow 512 myRow = tmpRow
430 } 513 }
431 // 正负判断 514 // 正负判断
432 if orderGoodQuantity < 0 { 515 if orderGoodQuantity < 0 {
433 - var tmpRow []string  
434 - tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货数量必须大于0,请重新填写") // 错误信息  
435 - tmpRow = append(tmpRow, r) // 行号  
436 - tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据 516 + var tmpRow *domain.FailReturnedInfo
  517 + tmpRow = &domain.FailReturnedInfo{
  518 + FailReason: "退货数量必须大于0,请重新填写",
  519 + ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
  520 + }
437 myRow = tmpRow 521 myRow = tmpRow
438 } 522 }
439 } 523 }
@@ -442,19 +526,21 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -442,19 +526,21 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
442 // 参数类型转换 526 // 参数类型转换
443 univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64) 527 univalent, typeErr := strconv.ParseFloat(fmt.Sprintf("%v", v.Field(k).Interface()), 64)
444 if typeErr != nil { 528 if typeErr != nil {
445 - var tmpRow []string  
446 - tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货价格格式错误,退货价格必须为数字类型") // 错误信息  
447 - tmpRow = append(tmpRow, r) // 行号  
448 - tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据 529 + var tmpRow *domain.FailReturnedInfo
  530 + tmpRow = &domain.FailReturnedInfo{
  531 + FailReason: "退货价格格式错误,退货价格必须为数字类型",
  532 + ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
  533 + }
449 myRow = tmpRow 534 myRow = tmpRow
450 } 535 }
451 536
452 // 长度校验 537 // 长度校验
453 if univalent >= 1e16 { 538 if univalent >= 1e16 {
454 - var tmpRow []string  
455 - tmpRow = append(tmpRow, "第"+r+"行第"+col+"列退货价格超过最大限制,退货价格小数点前面不能超过十六位数字,并保留两位小数") // 错误信息  
456 - tmpRow = append(tmpRow, r) // 行号  
457 - tmpRow = append(tmpRow, fmt.Sprintf("%v", v.Interface())) // 错误行数据 539 + var tmpRow *domain.FailReturnedInfo
  540 + tmpRow = &domain.FailReturnedInfo{
  541 + FailReason: "退货价格超过最大限制,退货价格小数点前面不能超过十六位数字,并保留两位小数",
  542 + ImportDividendsReturnedOrderData: &dividendsReturnedOrder,
  543 + }
458 myRow = tmpRow 544 myRow = tmpRow
459 } 545 }
460 } 546 }
@@ -515,7 +601,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -515,7 +601,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
515 } 601 }
516 602
517 // 产品相关:产品名称,退货数量、退货价格 603 // 产品相关:产品名称,退货数量、退货价格
518 - quantity, err := strconv.ParseInt(dividendsReturnedOrder.OrderGoodQuantity, 10, 64) 604 + quantity, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodQuantity, 64)
519 if err != nil { 605 if err != nil {
520 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 606 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
521 } 607 }
@@ -553,7 +639,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -553,7 +639,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
553 } 639 }
554 } else { // 聚合同一笔订单产品 640 } else { // 聚合同一笔订单产品
555 // 产品相关:产品名称,退货数量、退货价格 641 // 产品相关:产品名称,退货数量、退货价格
556 - quantity, err := strconv.ParseInt(dividendsReturnedOrder.OrderGoodQuantity, 10, 64) 642 + quantity, err := strconv.ParseFloat(dividendsReturnedOrder.OrderGoodQuantity, 64)
557 if err != nil { 643 if err != nil {
558 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 644 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
559 } 645 }
@@ -655,7 +741,9 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -655,7 +741,9 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
655 // 批量导入创建退货单 741 // 批量导入创建退货单
656 for _, dividendsReturnedOrder := range createDividendsReturnedOrderCommands { 742 for _, dividendsReturnedOrder := range createDividendsReturnedOrderCommands {
657 // 生成退货订单号 743 // 生成退货订单号
658 - dividendsReturnedOrderNumber, err := dividendsReturnedOrderDao.GenerateDividendsReturnedOrderNumber() 744 + dividendsReturnedOrderNumber, err := dividendsReturnedOrderDao.GenerateDividendsReturnedOrderNumber(map[string]interface{}{
  745 + "companyId": importDividendsReturnedOrderCommand.CompanyId,
  746 + })
659 if err != nil { 747 if err != nil {
660 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 748 return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
661 } 749 }
@@ -663,7 +751,6 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -663,7 +751,6 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
663 // 校验退货订单编号是否唯一 751 // 校验退货订单编号是否唯一
664 numberAvailable, err3 := dividendsReturnedOrderDao.CheckDividendsReturnedOrderNumberAvailable(map[string]interface{}{ 752 numberAvailable, err3 := dividendsReturnedOrderDao.CheckDividendsReturnedOrderNumberAvailable(map[string]interface{}{
665 "companyId": importDividendsReturnedOrderCommand.CompanyId, 753 "companyId": importDividendsReturnedOrderCommand.CompanyId,
666 - "orgId": importDividendsReturnedOrderCommand.OrgId,  
667 "dividendsReturnedOrderNumber": dividendsReturnedOrderNumber, 754 "dividendsReturnedOrderNumber": dividendsReturnedOrderNumber,
668 }) 755 })
669 if err3 != nil { 756 if err3 != nil {
@@ -676,10 +763,32 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide @@ -676,10 +763,32 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) ImportDivide
676 // 新增订单产品 763 // 新增订单产品
677 var orderGoods []*domain.OrderGood 764 var orderGoods []*domain.OrderGood
678 var dividendsReturnedOrderAmount float64 765 var dividendsReturnedOrderAmount float64
679 - for _, orderGood := range dividendsReturnedOrder.OrderGoods { 766 + orderGoodErrMap := make(map[int]interface{}, 0)
  767 + for i, orderGood := range dividendsReturnedOrder.OrderGoods {
  768 + // 校验共创合约是否合法
  769 + contractNumberExist := false
  770 + for _, cooperationContract := range cooperationContracts {
  771 + if orderGood.CooperationContractNumber == cooperationContract.CooperationContractNumber {
  772 + contractNumberExist = true
  773 + break
  774 + }
  775 + }
  776 + if !contractNumberExist {
  777 + orderGoodErrMap[dividendsReturnedOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, fmt.Sprintf("共创合约编号不存在:%s", err))
  778 + }
  779 +
  780 + // 计算产品金额
  781 + orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
  782 +
  783 + // 校验合约激励类型是否正确
  784 + if orderGood.CooperationContractNumber != "" {
  785 + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
  786 + orderGoodErrMap[dividendsReturnedOrder.OrderGoods[i].LineNumber] = application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
  787 + }
  788 + }
680 orderGoods = append(orderGoods, &domain.OrderGood{ 789 orderGoods = append(orderGoods, &domain.OrderGood{
681 OrderGoodId: 0, 790 OrderGoodId: 0,
682 - OrderGoodAmount: orderGood.OrderGoodAmount, 791 + OrderGoodAmount: orderGoodAmount,
683 OrderGoodName: orderGood.OrderGoodName, 792 OrderGoodName: orderGood.OrderGoodName,
684 OrderGoodPrice: orderGood.OrderGoodPrice, 793 OrderGoodPrice: orderGood.OrderGoodPrice,
685 OrderGoodQuantity: orderGood.OrderGoodQuantity, 794 OrderGoodQuantity: orderGood.OrderGoodQuantity,
@@ -1011,6 +1120,32 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide @@ -1011,6 +1120,32 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
1011 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateDividendsReturnedOrderCommand.DividendsReturnedOrderId))) 1120 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateDividendsReturnedOrderCommand.DividendsReturnedOrderId)))
1012 } 1121 }
1013 1122
  1123 + // 合约仓储初始化
  1124 + var cooperationContractRepository domain.CooperationContractRepository
  1125 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  1126 + "transactionContext": transactionContext,
  1127 + }); err != nil {
  1128 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1129 + } else {
  1130 + cooperationContractRepository = value
  1131 + }
  1132 +
  1133 + // 查找合约
  1134 + cooperationContractsMap := make(map[string]*domain.CooperationContract)
  1135 + if count, cooperationContracts, err := cooperationContractRepository.Find(map[string]interface{}{
  1136 + "offsetLimit": false,
  1137 + "companyId": updateDividendsReturnedOrderCommand.CompanyId,
  1138 + "orgId": updateDividendsReturnedOrderCommand.OrgId,
  1139 + }); err != nil {
  1140 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  1141 + } else {
  1142 + if count > 0 {
  1143 + for _, cooperationContract := range cooperationContracts {
  1144 + cooperationContractsMap[cooperationContract.CooperationContractNumber] = cooperationContract
  1145 + }
  1146 + }
  1147 + }
  1148 +
1014 // 获取订单产品 1149 // 获取订单产品
1015 var orderGoods []*domain.OrderGood 1150 var orderGoods []*domain.OrderGood
1016 var dividendsReturnedOrderAmount float64 1151 var dividendsReturnedOrderAmount float64
@@ -1020,9 +1155,33 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide @@ -1020,9 +1155,33 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
1020 if err3 != nil { 1155 if err3 != nil {
1021 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error()) 1156 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
1022 } 1157 }
  1158 +
  1159 + // 退货产品金额计算
  1160 + orderGoodAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodPrice).Mul(decimal.NewFromFloat(orderGood.OrderGoodQuantity)).Float64()
  1161 +
  1162 + // 校验合约激励类型是否正确
  1163 + ruleMatchedFlag := false
  1164 + if orderGood.CooperationContractNumber != "" {
  1165 + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil && cooperationContractsMap[orderGood.CooperationContractNumber].IncentivesType != 1 {
  1166 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "退货单产品不能关联金额激励规则")
  1167 + }
  1168 + // 校验产品关联合约的激励规则是否匹配订单时间
  1169 + if cooperationContractsMap[orderGood.CooperationContractNumber] != nil {
  1170 + for _, incentivesRule := range cooperationContractsMap[orderGood.CooperationContractNumber].DividendsIncentivesRules {
  1171 + if (orderTime.After(incentivesRule.DividendsIncentivesStageStart) || orderTime.Equal(incentivesRule.DividendsIncentivesStageStart)) && (orderTime.Before(incentivesRule.DividendsIncentivesStageEnd) || orderTime.Equal(incentivesRule.DividendsIncentivesStageEnd)) {
  1172 + ruleMatchedFlag = true
  1173 + break
  1174 + }
  1175 + }
  1176 + }
  1177 + if !ruleMatchedFlag {
  1178 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "订单时间无法匹配分红激励规则,请重新选择")
  1179 + }
  1180 + }
  1181 +
1023 orderGoods = append(orderGoods, &domain.OrderGood{ 1182 orderGoods = append(orderGoods, &domain.OrderGood{
1024 OrderGoodId: orderGoodId, 1183 OrderGoodId: orderGoodId,
1025 - OrderGoodAmount: orderGood.OrderGoodAmount, 1184 + OrderGoodAmount: orderGoodAmount,
1026 OrderGoodName: orderGood.OrderGoodName, 1185 OrderGoodName: orderGood.OrderGoodName,
1027 OrderGoodPrice: orderGood.OrderGoodPrice, 1186 OrderGoodPrice: orderGood.OrderGoodPrice,
1028 OrderGoodQuantity: orderGood.OrderGoodQuantity, 1187 OrderGoodQuantity: orderGood.OrderGoodQuantity,
@@ -1036,7 +1195,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide @@ -1036,7 +1195,7 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
1036 UpdatedAt: time.Now(), 1195 UpdatedAt: time.Now(),
1037 }) 1196 })
1038 // 计算分红退货单金额 1197 // 计算分红退货单金额
1039 - dividendsReturnedOrderAmount = dividendsReturnedOrderAmount + orderGood.OrderGoodAmount 1198 + dividendsReturnedOrderAmount, _ = decimal.NewFromFloat(dividendsReturnedOrderAmount).Add(decimal.NewFromFloat(orderGood.OrderGoodAmount)).Float64()
1040 } 1199 }
1041 1200
1042 if err := dividendsReturnedOrder.Update(tool_funs.SimpleStructToMap(updateDividendsReturnedOrderCommand)); err != nil { 1201 if err := dividendsReturnedOrder.Update(tool_funs.SimpleStructToMap(updateDividendsReturnedOrderCommand)); err != nil {
@@ -60,3 +60,11 @@ func CreateDividendsEstimateDao(options map[string]interface{}) (*dao.DividendsE @@ -60,3 +60,11 @@ func CreateDividendsEstimateDao(options map[string]interface{}) (*dao.DividendsE
60 } 60 }
61 return dao.NewDividendsEstimateDao(transactionContext) 61 return dao.NewDividendsEstimateDao(transactionContext)
62 } 62 }
  63 +
  64 +func CreateCooperationApplicationDao(options map[string]interface{}) (*dao.CooperationApplicationDao, error) {
  65 + var transactionContext *pg.TransactionContext
  66 + if value, ok := options["transactionContext"]; ok {
  67 + transactionContext = value.(*pg.TransactionContext)
  68 + }
  69 + return dao.NewCooperationApplicationDao(transactionContext)
  70 +}
@@ -4,7 +4,9 @@ import "os" @@ -4,7 +4,9 @@ import "os"
4 4
5 const SERVICE_NAME = "allied-creation-cooperation" 5 const SERVICE_NAME = "allied-creation-cooperation"
6 6
7 -// LOG_LEVEL 日志相关设置 7 +// LOG_TYPE 日志相关设置
  8 +var LOG_TYPE = "terminal" // file, terminal, es
  9 +var LOG_FRAMEWORK = "beego" // beego logrus
8 var LOG_LEVEL = "debug" 10 var LOG_LEVEL = "debug"
9 var LOG_FILE = "app.log" 11 var LOG_FILE = "app.log"
10 var LOG_PREFIX = "[allied-creation-cooperation]" 12 var LOG_PREFIX = "[allied-creation-cooperation]"
@@ -16,9 +18,15 @@ var USER_MODULE_HOST = "http://127.0.0.1:8081" @@ -16,9 +18,15 @@ var USER_MODULE_HOST = "http://127.0.0.1:8081"
16 var BASIC_MODULE_HOST = "http://127.0.0.1:8080" 18 var BASIC_MODULE_HOST = "http://127.0.0.1:8080"
17 19
18 func init() { 20 func init() {
  21 + if os.Getenv("LOG_TYPE") != "" {
  22 + LOG_TYPE = os.Getenv("LOG_TYPE")
  23 + }
19 if os.Getenv("LOG_LEVEL") != "" { 24 if os.Getenv("LOG_LEVEL") != "" {
20 LOG_LEVEL = os.Getenv("LOG_LEVEL") 25 LOG_LEVEL = os.Getenv("LOG_LEVEL")
21 } 26 }
  27 + if os.Getenv("LOG_FRAMEWORK") != "" {
  28 + LOG_FRAMEWORK = os.Getenv("LOG_FRAMEWORK")
  29 + }
22 if os.Getenv("LOG_FILE") != "" { 30 if os.Getenv("LOG_FILE") != "" {
23 LOG_FILE = os.Getenv("LOG_FILE") 31 LOG_FILE = os.Getenv("LOG_FILE")
24 } 32 }
@@ -28,4 +36,7 @@ func init() { @@ -28,4 +36,7 @@ func init() {
28 if os.Getenv("USER_MODULE_HOST") != "" { 36 if os.Getenv("USER_MODULE_HOST") != "" {
29 USER_MODULE_HOST = os.Getenv("USER_MODULE_HOST") 37 USER_MODULE_HOST = os.Getenv("USER_MODULE_HOST")
30 } 38 }
  39 + if os.Getenv("BASIC_MODULE_HOST") != "" {
  40 + BASIC_MODULE_HOST = os.Getenv("BASIC_MODULE_HOST")
  41 + }
31 } 42 }
@@ -2,13 +2,13 @@ package constant @@ -2,13 +2,13 @@ package constant
2 2
3 import "os" 3 import "os"
4 4
5 -// kafka 地址  
6 -var KAFKA_HOSTS = "" 5 +// KAFKA_HOSTS kafka 地址
  6 +var KAFKA_HOSTS = "192.168.0.250:9092,192.168.0.251:9092,192.168.0.252:9092"
7 7
8 -// kafka topic log stash 8 +// TOPIC_LOG_STASH kafka topic log stash
9 var TOPIC_LOG_STASH = "go_stash_dev" 9 var TOPIC_LOG_STASH = "go_stash_dev"
10 10
11 -// 是否启用日志收集 (本地不启用) 11 +// ENABLE_KAFKA_LOG 是否启用日志收集 (本地不启用)
12 var ENABLE_KAFKA_LOG = false 12 var ENABLE_KAFKA_LOG = false
13 13
14 func init() { 14 func init() {
@@ -19,6 +19,10 @@ func init() { @@ -19,6 +19,10 @@ func init() {
19 POSTGRESQL_PORT = os.Getenv("TOPIC_LOG_STASH") 19 POSTGRESQL_PORT = os.Getenv("TOPIC_LOG_STASH")
20 } 20 }
21 if os.Getenv("ENABLE_KAFKA_LOG") != "" { 21 if os.Getenv("ENABLE_KAFKA_LOG") != "" {
22 - DISABLE_CREATE_TABLE = true 22 + if os.Getenv("ENABLE_KAFKA_LOG") == "true" {
  23 + ENABLE_KAFKA_LOG = true
  24 + } else if os.Getenv("ENABLE_KAFKA_LOG") == "false" {
  25 + ENABLE_KAFKA_LOG = false
  26 + }
23 } 27 }
24 } 28 }
@@ -26,8 +26,8 @@ type CooperationApplication struct { @@ -26,8 +26,8 @@ type CooperationApplication struct {
26 CooperationProject *CooperationProject `json:"cooperationProject"` 26 CooperationProject *CooperationProject `json:"cooperationProject"`
27 // 数据所属组织机构 27 // 数据所属组织机构
28 Org *Org `json:"org"` 28 Org *Org `json:"org"`
29 - // 是否被取消标志位  
30 - IsCanceled bool `json:"isCanceled"` 29 + // 是否被取消标志位 1未取消,2取消
  30 + IsCanceled int32 `json:"isCanceled"`
31 // 公司 31 // 公司
32 Company *Company `json:"company"` 32 Company *Company `json:"company"`
33 // 创建时间 33 // 创建时间
@@ -55,7 +55,7 @@ func (cooperationApplication *CooperationApplication) Identify() interface{} { @@ -55,7 +55,7 @@ func (cooperationApplication *CooperationApplication) Identify() interface{} {
55 55
56 func (cooperationApplication *CooperationApplication) Update(data map[string]interface{}) error { 56 func (cooperationApplication *CooperationApplication) Update(data map[string]interface{}) error {
57 if isCanceled, ok := data["isCanceled"]; ok { 57 if isCanceled, ok := data["isCanceled"]; ok {
58 - cooperationApplication.IsCanceled = isCanceled.(bool) 58 + cooperationApplication.IsCanceled = isCanceled.(int32)
59 } 59 }
60 if cooperationApplicationAttachment, ok := data["cooperationApplicationAttachment"]; ok { 60 if cooperationApplicationAttachment, ok := data["cooperationApplicationAttachment"]; ok {
61 cooperationApplication.CooperationApplicationAttachment = cooperationApplicationAttachment.([]*Attachment) 61 cooperationApplication.CooperationApplicationAttachment = cooperationApplicationAttachment.([]*Attachment)
@@ -22,7 +22,7 @@ type CooperationProject struct { @@ -22,7 +22,7 @@ type CooperationProject struct {
22 CooperationMode *CooperationMode `json:"cooperationMode"` 22 CooperationMode *CooperationMode `json:"cooperationMode"`
23 // 共创项目发起部门 23 // 共创项目发起部门
24 Department *Department `json:"department"` 24 Department *Department `json:"department"`
25 - // 共创项目承接对象,1员工,2共创用户,3公开,可以多选 25 + // 共创项目承接对象,1员工,2共创用户,4公开,可以多选
26 CooperationProjectUndertakerTypes []int32 `json:"cooperationProjectUndertakerTypes"` 26 CooperationProjectUndertakerTypes []int32 `json:"cooperationProjectUndertakerTypes"`
27 // 数据所属组织机构 27 // 数据所属组织机构
28 Org *Org `json:"org"` 28 Org *Org `json:"org"`
@@ -61,20 +61,12 @@ type ImportInfo struct { @@ -61,20 +61,12 @@ type ImportInfo struct {
61 // FailInfo 返回的失败信息 61 // FailInfo 返回的失败信息
62 type FailInfo struct { 62 type FailInfo struct {
63 FailReason string `json:"failReason"` 63 FailReason string `json:"failReason"`
64 - //OriginalOrderNum string `json:"originalOrderNum"`  
65 - //DividendsCustomerName string `json:"dividendsCustomerName"`  
66 - //OrderGoodName string `json:"orderGoodName"`  
67 - //OrderTime string `json:"orderTime"`  
68 - //RegionName string `json:"regionName"`  
69 - //OrderGoodQuantity string `json:"orderGoodQuantity"`  
70 - //OrderGoodPrice string `json:"orderGoodPrice"`  
71 - //Expense string `json:"expense"`  
72 - //CooperationContractNumber string `json:"cooperationContractNumber"`  
73 *command.ImportDividendsOrderData 64 *command.ImportDividendsOrderData
74 } 65 }
75 66
76 type DividendsOrderRepository interface { 67 type DividendsOrderRepository interface {
77 Save(dividendsOrder *DividendsOrder) (*DividendsOrder, error) 68 Save(dividendsOrder *DividendsOrder) (*DividendsOrder, error)
  69 + SaveMany(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error)
78 UpdateMany(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error) 70 UpdateMany(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error)
79 Remove(dividendsOrder *DividendsOrder) (*DividendsOrder, error) 71 Remove(dividendsOrder *DividendsOrder) (*DividendsOrder, error)
80 BatchRemove(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error) 72 BatchRemove(dividendsOrders []*DividendsOrder) ([]*DividendsOrder, error)
1 package domain 1 package domain
2 2
3 -import "time" 3 +import (
  4 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsReturnedOrder/command"
  5 + "time"
  6 +)
4 7
5 // DividendsReturnedOrder 分红退货单实体 8 // DividendsReturnedOrder 分红退货单实体
6 type DividendsReturnedOrder struct { 9 type DividendsReturnedOrder struct {
@@ -46,8 +49,15 @@ type DividendsReturnedOrder struct { @@ -46,8 +49,15 @@ type DividendsReturnedOrder struct {
46 OperateTime time.Time `json:"operateTime"` 49 OperateTime time.Time `json:"operateTime"`
47 } 50 }
48 51
  52 +// FailReturnedInfo 返回的失败信息
  53 +type FailReturnedInfo struct {
  54 + FailReason string `json:"failReason"`
  55 + *command.ImportDividendsReturnedOrderData
  56 +}
  57 +
49 type DividendsReturnedOrderRepository interface { 58 type DividendsReturnedOrderRepository interface {
50 Save(dividendsReturnedOrder *DividendsReturnedOrder) (*DividendsReturnedOrder, error) 59 Save(dividendsReturnedOrder *DividendsReturnedOrder) (*DividendsReturnedOrder, error)
  60 + SaveMany(dividendsReturnedOrders []*DividendsReturnedOrder) ([]*DividendsReturnedOrder, error)
51 UpdateMany(dividendsReturnedOrder []*DividendsReturnedOrder) ([]*DividendsReturnedOrder, error) 61 UpdateMany(dividendsReturnedOrder []*DividendsReturnedOrder) ([]*DividendsReturnedOrder, error)
52 Remove(dividendsReturnedOrder *DividendsReturnedOrder) (*DividendsReturnedOrder, error) 62 Remove(dividendsReturnedOrder *DividendsReturnedOrder) (*DividendsReturnedOrder, error)
53 BatchRemove(dividendsReturnedOrders []*DividendsReturnedOrder) ([]*DividendsReturnedOrder, error) 63 BatchRemove(dividendsReturnedOrders []*DividendsReturnedOrder) ([]*DividendsReturnedOrder, error)
@@ -18,7 +18,7 @@ type OrderGood struct { @@ -18,7 +18,7 @@ type OrderGood struct {
18 // 订单产品单价 18 // 订单产品单价
19 OrderGoodPrice float64 `json:"orderGoodPrice"` 19 OrderGoodPrice float64 `json:"orderGoodPrice"`
20 // 订单产品数量 20 // 订单产品数量
21 - OrderGoodQuantity int64 `json:"orderGoodQuantity,string"` 21 + OrderGoodQuantity float64 `json:"orderGoodQuantity,string"`
22 // 关联分红订单号 22 // 关联分红订单号
23 DividendsOrderNumber string `json:"dividendsOrderNumber"` 23 DividendsOrderNumber string `json:"dividendsOrderNumber"`
24 // 关联的分红退货单号 24 // 关联的分红退货单号
@@ -66,7 +66,7 @@ func (orderGood *OrderGood) Update(data map[string]interface{}) error { @@ -66,7 +66,7 @@ func (orderGood *OrderGood) Update(data map[string]interface{}) error {
66 orderGood.OrderGoodPrice = orderGoodPrice.(float64) 66 orderGood.OrderGoodPrice = orderGoodPrice.(float64)
67 } 67 }
68 if orderGoodQuantity, ok := data["orderGoodQuantity"]; ok { 68 if orderGoodQuantity, ok := data["orderGoodQuantity"]; ok {
69 - orderGood.OrderGoodQuantity = orderGoodQuantity.(int64) 69 + orderGood.OrderGoodQuantity = orderGoodQuantity.(float64)
70 } 70 }
71 if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok { 71 if cooperationContractNumber, ok := data["cooperationContractNumber"]; ok {
72 orderGood.CooperationContractNumber = cooperationContractNumber.(string) 72 orderGood.CooperationContractNumber = cooperationContractNumber.(string)
@@ -31,3 +31,10 @@ type Relevant struct { @@ -31,3 +31,10 @@ type Relevant struct {
31 // 公司 31 // 公司
32 Company *Company `json:"company"` 32 Company *Company `json:"company"`
33 } 33 }
  34 +
  35 +func (relevant *Relevant) Identify() interface{} {
  36 + if relevant.RelevantId == 0 {
  37 + return nil
  38 + }
  39 + return relevant.RelevantId
  40 +}
1 package service 1 package service
2 2
3 import ( 3 import (
  4 + "fmt"
4 coreDomain "github.com/linmadan/egglib-go/core/domain" 5 coreDomain "github.com/linmadan/egglib-go/core/domain"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
  7 + "time"
6 ) 8 )
7 9
8 type DividendsEstimateDetail struct { 10 type DividendsEstimateDetail struct {
@@ -10,6 +12,31 @@ type DividendsEstimateDetail struct { @@ -10,6 +12,31 @@ type DividendsEstimateDetail struct {
10 DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型 12 DividendsParticipateType int32 `json:"dividendsParticipateType"` // 参与类型
11 DividendsStage int32 `json:"dividendsStage"` // 分红阶段 13 DividendsStage int32 `json:"dividendsStage"` // 分红阶段
12 DividendsAmount float64 `json:"dividendsAmount"` // 分红金额 14 DividendsAmount float64 `json:"dividendsAmount"` // 分红金额
  15 + OrderOrReturnedOrderNumber string `json:"orderOrReturnedOrderNumber"` // 分红订单号或退货单号
  16 + IsSuccessfully bool `json:"isSuccessfully"` // 是否预算成功
  17 + Reason string `json:"reason"` // 错误原因
  18 +}
  19 +
  20 +// GenerateSpecificDividendsEstimateNumber 批量生成自定义分红预算单号
  21 +func (DividendsEstimateDetail *DividendsEstimateDetail) GenerateSpecificDividendsEstimateNumber(count int64, index int64) (string, error) {
  22 + currentTime := time.Now()
  23 + if count+index < 1000 {
  24 + countStr := fmt.Sprintf("%03d", count+index+1)
  25 + timestamp := currentTime.Unix()
  26 + timeNow := time.Unix(timestamp, 0)
  27 + timeString := timeNow.Format("20060102")
  28 + timeString = timeString[2:len(timeString)]
  29 + dividendsEstimateNumber := "FH" + timeString + "#" + countStr
  30 + return dividendsEstimateNumber, nil
  31 + } else {
  32 + countStr := fmt.Sprintf("%d", count+index+1)
  33 + timestamp := currentTime.Unix()
  34 + timeNow := time.Unix(timestamp, 0)
  35 + timeString := timeNow.Format("20060102")
  36 + timeString = timeString[2:len(timeString)]
  37 + dividendsEstimateNumber := "FH" + timeString + "#" + countStr
  38 + return dividendsEstimateNumber, nil
  39 + }
13 } 40 }
14 41
15 type ConfirmDividendsIncentivesEstimateService interface { 42 type ConfirmDividendsIncentivesEstimateService interface {
@@ -9,4 +9,5 @@ type UserService interface { @@ -9,4 +9,5 @@ type UserService interface {
9 RelevantFrom(companyId int64, orgId int64, userId int64) (*domain.Relevant, error) // 获取相关人 9 RelevantFrom(companyId int64, orgId int64, userId int64) (*domain.Relevant, error) // 获取相关人
10 SalesmanFrom(companyId int64, orgId int64, userId int64) (*domain.Salesman, error) // 获取业务员 10 SalesmanFrom(companyId int64, orgId int64, userId int64) (*domain.Salesman, error) // 获取业务员
11 OperatorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) // 获取操作人 11 OperatorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) // 获取操作人
  12 + VisitorFrom(companyId int64, orgId int64, userId int64) (*domain.User, error) // 获取游客
12 } 13 }
@@ -37,3 +37,10 @@ type Undertaker struct { @@ -37,3 +37,10 @@ type Undertaker struct {
37 // 合同附件 37 // 合同附件
38 ContractAttachment []*Attachment `json:"contractAttachment"` 38 ContractAttachment []*Attachment `json:"contractAttachment"`
39 } 39 }
  40 +
  41 +func (undertaker *Undertaker) Identify() interface{} {
  42 + if undertaker.UndertakerId == 0 {
  43 + return nil
  44 + }
  45 + return undertaker.UndertakerId
  46 +}
  1 +package dao
  2 +
  3 +import (
  4 + "fmt"
  5 + pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  6 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
  7 +)
  8 +
  9 +type CooperationApplicationDao struct {
  10 + transactionContext *pgTransaction.TransactionContext
  11 +}
  12 +
  13 +// CheckApplicationExist 判断该申请人是否提交过申请
  14 +func (dao *CooperationApplicationDao) CheckApplicationExist(queryOptions map[string]interface{}) (bool, error) {
  15 + tx := dao.transactionContext.PgTx
  16 + var cooperationApplicationModels []*models.CooperationApplication
  17 + query := tx.Model(&cooperationApplicationModels)
  18 + if cooperationProjectNumber, ok := queryOptions["cooperationProjectNumber"]; ok && cooperationProjectNumber != "" {
  19 + query = query.Where("cooperation_project_number = ?", cooperationProjectNumber)
  20 + }
  21 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  22 + query = query.Where(`cooperation_application.company @> '{"companyId":"?"}'`, companyId)
  23 + }
  24 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  25 + query = query.Where(`cooperation_application.org @> '{"orgId":"?"}'`, orgId)
  26 + }
  27 + if applicantId, ok := queryOptions["applicantId"]; ok && applicantId.(int64) != 0 {
  28 + query = query.Where(`cooperation_application.cooperation_application_applicant @>'{"userId":"?"}'`, applicantId)
  29 + }
  30 + if visitorUserBaseId, ok := queryOptions["visitorUserBaseId"]; ok && visitorUserBaseId.(int64) != 0 {
  31 + query = query.Where(`cooperation_application.cooperation_application_applicant @>'{"userBaseId":"?"}'`, visitorUserBaseId)
  32 + }
  33 + if applicantBaseId, ok := queryOptions["applicantBaseId"]; ok && applicantBaseId.(int64) != 0 {
  34 + query = query.Where(`cooperation_application.cooperation_application_applicant @>'{"userBaseId":"?"}'`, applicantBaseId)
  35 + }
  36 + ok, err := query.Exists()
  37 + return ok, err
  38 +}
  39 +
  40 +func NewCooperationApplicationDao(transactionContext *pgTransaction.TransactionContext) (*CooperationApplicationDao, error) {
  41 + if transactionContext == nil {
  42 + return nil, fmt.Errorf("transactionContext参数不能为nil")
  43 + } else {
  44 + return &CooperationApplicationDao{
  45 + transactionContext: transactionContext,
  46 + }, nil
  47 + }
  48 +}
@@ -2,8 +2,12 @@ package dao @@ -2,8 +2,12 @@ package dao
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "github.com/go-pg/pg/v10"
  6 + "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
5 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
  10 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/transform"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
8 "time" 12 "time"
9 ) 13 )
@@ -13,7 +17,7 @@ type CooperationContractDao struct { @@ -13,7 +17,7 @@ type CooperationContractDao struct {
13 } 17 }
14 18
15 // GenerateContractNumber 生成共创合约编号 19 // GenerateContractNumber 生成共创合约编号
16 -func (dao *CooperationContractDao) GenerateContractNumber() (string, error) { 20 +func (dao *CooperationContractDao) GenerateContractNumber(queryOptions map[string]interface{}) (string, error) {
17 tx := dao.transactionContext.PgTx 21 tx := dao.transactionContext.PgTx
18 var cooperationContractModels []*models.CooperationContract 22 var cooperationContractModels []*models.CooperationContract
19 query := tx.Model(&cooperationContractModels) 23 query := tx.Model(&cooperationContractModels)
@@ -22,9 +26,13 @@ func (dao *CooperationContractDao) GenerateContractNumber() (string, error) { @@ -22,9 +26,13 @@ func (dao *CooperationContractDao) GenerateContractNumber() (string, error) {
22 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) 26 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
23 query.Where("cooperation_contract.created_at >= ?", todayZeroTime) 27 query.Where("cooperation_contract.created_at >= ?", todayZeroTime)
24 query.Where("cooperation_contract.created_at < ?", nextDayZeroTime) 28 query.Where("cooperation_contract.created_at < ?", nextDayZeroTime)
  29 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  30 + query = query.Where(`cooperation_contract.company @> '{"companyId":"?"}'`, companyId)
  31 + }
25 if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { 32 if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
26 return "", err 33 return "", err
27 } else { 34 } else {
  35 + if count < 1000 {
28 countStr := fmt.Sprintf("%03d", count+1) 36 countStr := fmt.Sprintf("%03d", count+1)
29 timestamp := currentTime.Unix() 37 timestamp := currentTime.Unix()
30 timeNow := time.Unix(timestamp, 0) 38 timeNow := time.Unix(timestamp, 0)
@@ -32,6 +40,16 @@ func (dao *CooperationContractDao) GenerateContractNumber() (string, error) { @@ -32,6 +40,16 @@ func (dao *CooperationContractDao) GenerateContractNumber() (string, error) {
32 timeString = timeString[2:len(timeString)] 40 timeString = timeString[2:len(timeString)]
33 contractNumber := "HY" + timeString + "#" + countStr 41 contractNumber := "HY" + timeString + "#" + countStr
34 return contractNumber, nil 42 return contractNumber, nil
  43 + } else {
  44 + countStr := fmt.Sprintf("%d", count+1)
  45 + timestamp := currentTime.Unix()
  46 + timeNow := time.Unix(timestamp, 0)
  47 + timeString := timeNow.Format("20060102")
  48 + timeString = timeString[2:len(timeString)]
  49 + dividendsOrderNumber := "HY" + timeString + "#" + countStr
  50 + return dividendsOrderNumber, nil
  51 + }
  52 +
35 } 53 }
36 } 54 }
37 55
@@ -146,6 +164,76 @@ func (dao *CooperationContractDao) SearchCooperationContractByUndertaker(queryOp @@ -146,6 +164,76 @@ func (dao *CooperationContractDao) SearchCooperationContractByUndertaker(queryOp
146 } 164 }
147 } 165 }
148 166
  167 +func (dao *CooperationContractDao) Find(queryOptions map[string]interface{}) (int64, []*domain.CooperationContract, error) {
  168 + tx := dao.transactionContext.PgTx
  169 + var cooperationContractModels []*models.CooperationContract
  170 + cooperationContracts := make([]*domain.CooperationContract, 0)
  171 + query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractModels), queryOptions)
  172 + if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
  173 + query.Where("cooperation_contract_number ilike ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
  174 + }
  175 + if cooperationContractName, ok := queryOptions["cooperationContactName"]; ok && cooperationContractName != "" {
  176 + query.Where("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", cooperationContractName))
  177 + }
  178 + if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
  179 + query.Where(`(cooperation_contract.department->>'departmentName')::test LIKE ?`, fmt.Sprintf("%%%s%%", departmentName))
  180 + }
  181 + if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
  182 + query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
  183 + }
  184 + if cooperationContractIds, ok := queryOptions["cooperationContractIds"]; ok && len(cooperationContractIds.([]int64)) != 0 {
  185 + query.Where("cooperation_contract_id in (?)", pg.In(cooperationContractIds))
  186 + }
  187 + if cooperationContractNumbers, ok := queryOptions["cooperationContractNumbers"]; ok && len(cooperationContractNumbers.([]string)) != 0 {
  188 + query.Where("cooperation_contract_number in (?)", pg.In(cooperationContractNumbers))
  189 + }
  190 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  191 + query.Where("company->>'companyId' = '?'", companyId)
  192 + }
  193 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  194 + query.Where("org->>'orgId' = '?'", orgId)
  195 + }
  196 + if orgIds, ok := queryOptions["orgIds"]; ok && len(orgIds.([]int64)) > 0 {
  197 + newOrgIds := utils.SliceItoa(orgIds.([]int64))
  198 + query.Where("org->>'orgId' in (?)", pg.In(newOrgIds))
  199 + }
  200 + if incentivesType, ok := queryOptions["incentivesType"]; ok && incentivesType.(int32) != 0 {
  201 + query.Where("incentives_type = ?", incentivesType)
  202 + }
  203 + offsetLimitFlag := true
  204 + if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
  205 + offsetLimitFlag = offsetLimit.(bool)
  206 + }
  207 + if offsetLimitFlag {
  208 + query.SetOffsetAndLimit(20)
  209 + }
  210 + query.SetOrderDirect("cooperation_contract_id", "DESC")
  211 + var count int
  212 + var err error
  213 + if count, err = query.SelectAndCount(); err != nil {
  214 + return 0, cooperationContracts, err
  215 + }
  216 + for _, cooperationContractModel := range cooperationContractModels {
  217 + // 获取分红激励规则列表
  218 + var dividendsIncentivesRuleModels []*models.DividendsIncentivesRule
  219 + var moneyIncentivesRuleModels []*models.MoneyIncentivesRule
  220 + var cooperationContractUndertakerModels []*models.CooperationContractUndertaker
  221 + var cooperationContractRelevantModels []*models.CooperationContractRelevant
  222 + if cooperationContract, err := transform.TransformToCooperationContractDomainModelFromPgModels(
  223 + cooperationContractModel,
  224 + &models.CooperationMode{},
  225 + dividendsIncentivesRuleModels,
  226 + moneyIncentivesRuleModels,
  227 + cooperationContractRelevantModels,
  228 + cooperationContractUndertakerModels); err != nil {
  229 + return 0, cooperationContracts, err
  230 + } else {
  231 + cooperationContracts = append(cooperationContracts, cooperationContract)
  232 + }
  233 + }
  234 + return int64(count), cooperationContracts, nil
  235 +}
  236 +
149 func NewCooperationContractDao(transactionContext *pgTransaction.TransactionContext) (*CooperationContractDao, error) { 237 func NewCooperationContractDao(transactionContext *pgTransaction.TransactionContext) (*CooperationContractDao, error) {
150 if transactionContext == nil { 238 if transactionContext == nil {
151 return nil, fmt.Errorf("transactionContext参数不能为nil") 239 return nil, fmt.Errorf("transactionContext参数不能为nil")
@@ -13,7 +13,7 @@ type CooperationProjectDao struct { @@ -13,7 +13,7 @@ type CooperationProjectDao struct {
13 } 13 }
14 14
15 // GenerateProjectNumber 生成共创项目编码 15 // GenerateProjectNumber 生成共创项目编码
16 -func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) { 16 +func (dao *CooperationProjectDao) GenerateProjectNumber(queryOptions map[string]interface{}) (string, error) {
17 tx := dao.transactionContext.PgTx 17 tx := dao.transactionContext.PgTx
18 var cooperationProjectModels []*models.CooperationProject 18 var cooperationProjectModels []*models.CooperationProject
19 query := tx.Model(&cooperationProjectModels) 19 query := tx.Model(&cooperationProjectModels)
@@ -22,9 +22,13 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) { @@ -22,9 +22,13 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) {
22 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) 22 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
23 query.Where("cooperation_project.created_at >= ?", todayZeroTime) 23 query.Where("cooperation_project.created_at >= ?", todayZeroTime)
24 query.Where("cooperation_project.created_at < ?", nextDayZeroTime) 24 query.Where("cooperation_project.created_at < ?", nextDayZeroTime)
  25 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  26 + query = query.Where(`cooperation_project.company @> '{"companyId":"?"}'`, companyId)
  27 + }
25 if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { 28 if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
26 return "", err 29 return "", err
27 } else { 30 } else {
  31 + if count < 1000 {
28 countStr := fmt.Sprintf("%03d", count+1) 32 countStr := fmt.Sprintf("%03d", count+1)
29 timestamp := currentTime.Unix() 33 timestamp := currentTime.Unix()
30 timeNow := time.Unix(timestamp, 0) 34 timeNow := time.Unix(timestamp, 0)
@@ -32,6 +36,15 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) { @@ -32,6 +36,15 @@ func (dao *CooperationProjectDao) GenerateProjectNumber() (string, error) {
32 timeString = timeString[2:len(timeString)] 36 timeString = timeString[2:len(timeString)]
33 contractNumber := "XM" + timeString + "#" + countStr 37 contractNumber := "XM" + timeString + "#" + countStr
34 return contractNumber, nil 38 return contractNumber, nil
  39 + } else {
  40 + countStr := fmt.Sprintf("%d", count+1)
  41 + timestamp := currentTime.Unix()
  42 + timeNow := time.Unix(timestamp, 0)
  43 + timeString := timeNow.Format("20060102")
  44 + timeString = timeString[2:len(timeString)]
  45 + contractNumber := "XM" + timeString + "#" + countStr
  46 + return contractNumber, nil
  47 + }
35 } 48 }
36 } 49 }
37 50
@@ -2,6 +2,7 @@ package dao @@ -2,6 +2,7 @@ package dao
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "github.com/go-pg/pg/v10"
5 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
@@ -13,7 +14,7 @@ type CreditAccountDao struct { @@ -13,7 +14,7 @@ type CreditAccountDao struct {
13 } 14 }
14 15
15 // GenerateCreditAccountNumber 生成账期结算单号 16 // GenerateCreditAccountNumber 生成账期结算单号
16 -func (dao *CreditAccountDao) GenerateCreditAccountNumber() (string, error) { 17 +func (dao *CreditAccountDao) GenerateCreditAccountNumber(queryOptions map[string]interface{}) (string, error) {
17 tx := dao.transactionContext.PgTx 18 tx := dao.transactionContext.PgTx
18 var creditAccountModels []*models.CreditAccount 19 var creditAccountModels []*models.CreditAccount
19 query := tx.Model(&creditAccountModels) 20 query := tx.Model(&creditAccountModels)
@@ -22,9 +23,13 @@ func (dao *CreditAccountDao) GenerateCreditAccountNumber() (string, error) { @@ -22,9 +23,13 @@ func (dao *CreditAccountDao) GenerateCreditAccountNumber() (string, error) {
22 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) 23 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
23 query.Where("credit_account.created_at >= ?", todayZeroTime) 24 query.Where("credit_account.created_at >= ?", todayZeroTime)
24 query.Where("credit_account.created_at < ?", nextDayZeroTime) 25 query.Where("credit_account.created_at < ?", nextDayZeroTime)
  26 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  27 + query = query.Where(`credit_account.company @> '{"companyId":"?"}'`, companyId)
  28 + }
25 if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { 29 if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
26 return "", err 30 return "", err
27 } else { 31 } else {
  32 + if count < 1000 {
28 countStr := fmt.Sprintf("%03d", count+1) 33 countStr := fmt.Sprintf("%03d", count+1)
29 timestamp := currentTime.Unix() 34 timestamp := currentTime.Unix()
30 timeNow := time.Unix(timestamp, 0) 35 timeNow := time.Unix(timestamp, 0)
@@ -32,6 +37,15 @@ func (dao *CreditAccountDao) GenerateCreditAccountNumber() (string, error) { @@ -32,6 +37,15 @@ func (dao *CreditAccountDao) GenerateCreditAccountNumber() (string, error) {
32 timeString = timeString[2:len(timeString)] 37 timeString = timeString[2:len(timeString)]
33 creditAccountNumber := "JS" + timeString + "#" + countStr 38 creditAccountNumber := "JS" + timeString + "#" + countStr
34 return creditAccountNumber, nil 39 return creditAccountNumber, nil
  40 + } else {
  41 + countStr := fmt.Sprintf("%d", count+1)
  42 + timestamp := currentTime.Unix()
  43 + timeNow := time.Unix(timestamp, 0)
  44 + timeString := timeNow.Format("20060102")
  45 + timeString = timeString[2:len(timeString)]
  46 + creditAccountNumber := "JS" + timeString + "#" + countStr
  47 + return creditAccountNumber, nil
  48 + }
35 } 49 }
36 } 50 }
37 51
@@ -58,7 +72,8 @@ func (dao *CreditAccountDao) DividendsStatistics(queryOptions map[string]interfa @@ -58,7 +72,8 @@ func (dao *CreditAccountDao) DividendsStatistics(queryOptions map[string]interfa
58 creditAccount := new(models.CreditAccount) 72 creditAccount := new(models.CreditAccount)
59 query := dao.transactionContext.PgTx.Model(creditAccount) 73 query := dao.transactionContext.PgTx.Model(creditAccount)
60 query.ColumnExpr(`sum(settlement_amount) total`) 74 query.ColumnExpr(`sum(settlement_amount) total`)
61 - query.ColumnExpr(`sum((case when payment_status = 1 then actually_paid_amount else 0 end)) paid`) 75 + query.ColumnExpr(`sum((case when payment_status = 2 then actually_paid_amount else 0 end)) paid`)
  76 + query.ColumnExpr(`sum((case when payment_status = 1 then settlement_amount else 0 end)) unpaid`)
62 query.ColumnExpr(`sum((case when settlement_time is not null then settlement_amount else 0 end)) accounted `) 77 query.ColumnExpr(`sum((case when settlement_time is not null then settlement_amount else 0 end)) accounted `)
63 if v, ok := queryOptions["beginTime"]; ok && !(v.(time.Time).IsZero()) { 78 if v, ok := queryOptions["beginTime"]; ok && !(v.(time.Time).IsZero()) {
64 query.Where(`created_at>? `, queryOptions["beginTime"]) 79 query.Where(`created_at>? `, queryOptions["beginTime"])
@@ -70,6 +85,10 @@ func (dao *CreditAccountDao) DividendsStatistics(queryOptions map[string]interfa @@ -70,6 +85,10 @@ func (dao *CreditAccountDao) DividendsStatistics(queryOptions map[string]interfa
70 if v, ok := queryOptions["orgId"]; ok && v.(int64) > 0 { 85 if v, ok := queryOptions["orgId"]; ok && v.(int64) > 0 {
71 query.Where(fmt.Sprintf(` org->>'orgId'= '%v'`, v)) 86 query.Where(fmt.Sprintf(` org->>'orgId'= '%v'`, v))
72 } 87 }
  88 + if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
  89 + query.Where("cooperation_contract_number in (?)", pg.In(v))
  90 + }
  91 + query.Where("deleted_at is null")
73 err := query.Select(v) 92 err := query.Select(v)
74 return err 93 return err
75 } 94 }
@@ -84,7 +103,7 @@ func (dao *CreditAccountDao) CooperationUsersDividendsStatistics(queryOptions ma @@ -84,7 +103,7 @@ func (dao *CreditAccountDao) CooperationUsersDividendsStatistics(queryOptions ma
84 query.ColumnExpr(`sum((case when payment_status = 1 then actually_paid_amount else 0 end)) actually_paid_amount`) 103 query.ColumnExpr(`sum((case when payment_status = 1 then actually_paid_amount else 0 end)) actually_paid_amount`)
85 query.ColumnExpr(`max(participator->>'userId') user_id`) 104 query.ColumnExpr(`max(participator->>'userId') user_id`)
86 query.ColumnExpr(`max(participator#>>'{userInfo,userName}') user_name`) 105 query.ColumnExpr(`max(participator#>>'{userInfo,userName}') user_name`)
87 - if _, ok := queryOptions["beginTime"]; ok { 106 + if _, ok := queryOptions["beginTime"]; ok && !queryOptions["beginTime"].(time.Time).IsZero() {
88 query.Where(`created_at>? `, queryOptions["beginTime"]) 107 query.Where(`created_at>? `, queryOptions["beginTime"])
89 query.Where(`created_at<? `, queryOptions["endTime"]) 108 query.Where(`created_at<? `, queryOptions["endTime"])
90 } 109 }
@@ -103,6 +122,9 @@ func (dao *CreditAccountDao) CooperationUsersDividendsStatistics(queryOptions ma @@ -103,6 +122,9 @@ func (dao *CreditAccountDao) CooperationUsersDividendsStatistics(queryOptions ma
103 if v, ok := queryOptions["endTime"]; ok && !v.(time.Time).IsZero() { 122 if v, ok := queryOptions["endTime"]; ok && !v.(time.Time).IsZero() {
104 query.Where("created_at < ?", v) 123 query.Where("created_at < ?", v)
105 } 124 }
  125 + if v, ok := queryOptions["cooperationContractNumbers"]; ok && len(v.([]string)) > 0 {
  126 + query.Where("cooperation_contract_number in (?)", pg.In(v))
  127 + }
106 query.Where("deleted_at is null") 128 query.Where("deleted_at is null")
107 if v, ok := queryOptions["sortByActuallyPaidAmount"]; ok { 129 if v, ok := queryOptions["sortByActuallyPaidAmount"]; ok {
108 vInt := v.(int) 130 vInt := v.(int)
@@ -13,7 +13,7 @@ type DividendsEstimateDao struct { @@ -13,7 +13,7 @@ type DividendsEstimateDao struct {
13 } 13 }
14 14
15 // GenerateDividendsEstimateNumber 生成分红预算单号 15 // GenerateDividendsEstimateNumber 生成分红预算单号
16 -func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber() (string, error) { 16 +func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber(queryOptions map[string]interface{}) (string, error) {
17 tx := dao.transactionContext.PgTx 17 tx := dao.transactionContext.PgTx
18 var dividendsEstimateModels []*models.DividendsEstimate 18 var dividendsEstimateModels []*models.DividendsEstimate
19 query := tx.Model(&dividendsEstimateModels) 19 query := tx.Model(&dividendsEstimateModels)
@@ -22,9 +22,13 @@ func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber() (string, erro @@ -22,9 +22,13 @@ func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber() (string, erro
22 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) 22 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
23 query.Where("dividends_estimate.created_at >= ?", todayZeroTime) 23 query.Where("dividends_estimate.created_at >= ?", todayZeroTime)
24 query.Where("dividends_estimate.created_at < ?", nextDayZeroTime) 24 query.Where("dividends_estimate.created_at < ?", nextDayZeroTime)
  25 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  26 + query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId)
  27 + }
25 if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { 28 if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
26 return "", err 29 return "", err
27 } else { 30 } else {
  31 + if count < 1000 {
28 countStr := fmt.Sprintf("%03d", count+1) 32 countStr := fmt.Sprintf("%03d", count+1)
29 timestamp := currentTime.Unix() 33 timestamp := currentTime.Unix()
30 timeNow := time.Unix(timestamp, 0) 34 timeNow := time.Unix(timestamp, 0)
@@ -32,6 +36,16 @@ func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber() (string, erro @@ -32,6 +36,16 @@ func (dao *DividendsEstimateDao) GenerateDividendsEstimateNumber() (string, erro
32 timeString = timeString[2:len(timeString)] 36 timeString = timeString[2:len(timeString)]
33 dividendsOrderNumber := "FH" + timeString + "#" + countStr 37 dividendsOrderNumber := "FH" + timeString + "#" + countStr
34 return dividendsOrderNumber, nil 38 return dividendsOrderNumber, nil
  39 + } else {
  40 + countStr := fmt.Sprintf("%d", count+1)
  41 + timestamp := currentTime.Unix()
  42 + timeNow := time.Unix(timestamp, 0)
  43 + timeString := timeNow.Format("20060102")
  44 + timeString = timeString[2:len(timeString)]
  45 + dividendsOrderNumber := "FH" + timeString + "#" + countStr
  46 + return dividendsOrderNumber, nil
  47 + }
  48 +
35 } 49 }
36 } 50 }
37 51
@@ -75,6 +89,24 @@ func (dao *DividendsEstimateDao) UserEstimated(queryOptions map[string]interface @@ -75,6 +89,24 @@ func (dao *DividendsEstimateDao) UserEstimated(queryOptions map[string]interface
75 return ok, err 89 return ok, err
76 } 90 }
77 91
  92 +// CountDividendsEstimate 统计当前分红预算单总数
  93 +func (dao *DividendsEstimateDao) CountDividendsEstimate(queryOptions map[string]interface{}) (int, error) {
  94 + tx := dao.transactionContext.PgTx
  95 + var dividendsEstimateModels []*models.DividendsEstimate
  96 + query := tx.Model(&dividendsEstimateModels)
  97 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  98 + query = query.Where(`dividends_estimate.company @> '{"companyId":"?"}'`, companyId)
  99 + }
  100 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  101 + query = query.Where(`dividends_estimate.org @> '{"orgId":"?"}'`, orgId)
  102 + }
  103 + if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
  104 + return 0, err
  105 + } else {
  106 + return count, nil
  107 + }
  108 +}
  109 +
78 func NewDividendsEstimateDao(transactionContext *pgTransaction.TransactionContext) (*DividendsEstimateDao, error) { 110 func NewDividendsEstimateDao(transactionContext *pgTransaction.TransactionContext) (*DividendsEstimateDao, error) {
79 if transactionContext == nil { 111 if transactionContext == nil {
80 return nil, fmt.Errorf("transactionContext参数不能为空") 112 return nil, fmt.Errorf("transactionContext参数不能为空")
@@ -13,7 +13,7 @@ type DividendsOrderDao struct { @@ -13,7 +13,7 @@ type DividendsOrderDao struct {
13 } 13 }
14 14
15 // GenerateDividendsOrderNumber 生成分红订单号 15 // GenerateDividendsOrderNumber 生成分红订单号
16 -func (dao *DividendsOrderDao) GenerateDividendsOrderNumber() (string, error) { 16 +func (dao *DividendsOrderDao) GenerateDividendsOrderNumber(queryOptions map[string]interface{}) (string, error) {
17 tx := dao.transactionContext.PgTx 17 tx := dao.transactionContext.PgTx
18 var dividendsOrderModels []*models.DividendsOrder 18 var dividendsOrderModels []*models.DividendsOrder
19 query := tx.Model(&dividendsOrderModels) 19 query := tx.Model(&dividendsOrderModels)
@@ -22,9 +22,13 @@ func (dao *DividendsOrderDao) GenerateDividendsOrderNumber() (string, error) { @@ -22,9 +22,13 @@ func (dao *DividendsOrderDao) GenerateDividendsOrderNumber() (string, error) {
22 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) 22 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
23 query.Where("dividends_order.created_at >= ?", todayZeroTime) 23 query.Where("dividends_order.created_at >= ?", todayZeroTime)
24 query.Where("dividends_order.created_at < ?", nextDayZeroTime) 24 query.Where("dividends_order.created_at < ?", nextDayZeroTime)
  25 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  26 + query = query.Where(`dividends_order.company @> '{"companyId":"?"}'`, companyId)
  27 + }
25 if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { 28 if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
26 return "", err 29 return "", err
27 } else { 30 } else {
  31 + if count < 1000 {
28 countStr := fmt.Sprintf("%03d", count+1) 32 countStr := fmt.Sprintf("%03d", count+1)
29 timestamp := currentTime.Unix() 33 timestamp := currentTime.Unix()
30 timeNow := time.Unix(timestamp, 0) 34 timeNow := time.Unix(timestamp, 0)
@@ -32,6 +36,15 @@ func (dao *DividendsOrderDao) GenerateDividendsOrderNumber() (string, error) { @@ -32,6 +36,15 @@ func (dao *DividendsOrderDao) GenerateDividendsOrderNumber() (string, error) {
32 timeString = timeString[2:len(timeString)] 36 timeString = timeString[2:len(timeString)]
33 dividendsOrderNumber := "SL" + timeString + "#" + countStr 37 dividendsOrderNumber := "SL" + timeString + "#" + countStr
34 return dividendsOrderNumber, nil 38 return dividendsOrderNumber, nil
  39 + } else {
  40 + countStr := fmt.Sprintf("%d", count+1)
  41 + timestamp := currentTime.Unix()
  42 + timeNow := time.Unix(timestamp, 0)
  43 + timeString := timeNow.Format("20060102")
  44 + timeString = timeString[2:len(timeString)]
  45 + dividendsOrderNumber := "SL" + timeString + "#" + countStr
  46 + return dividendsOrderNumber, nil
  47 + }
35 } 48 }
36 } 49 }
37 50
@@ -78,6 +91,23 @@ func (dao *DividendsOrderDao) CalculateDividendsOrderAmount(queryOptions map[str @@ -78,6 +91,23 @@ func (dao *DividendsOrderDao) CalculateDividendsOrderAmount(queryOptions map[str
78 return dividendsOrderModel.DividendsOrderAmount, nil 91 return dividendsOrderModel.DividendsOrderAmount, nil
79 } 92 }
80 93
  94 +// CountDividendsOrder 统计当前订单总数
  95 +func (dao *DividendsOrderDao) CountDividendsOrder(queryOptions map[string]interface{}) (int, error) {
  96 + tx := dao.transactionContext.PgTx
  97 + var dividendsOrderModels []*models.DividendsOrder
  98 + query := tx.Model(&dividendsOrderModels)
  99 + currentTime := time.Now()
  100 + todayZeroTime := utils.GetZeroTime(currentTime)
  101 + nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
  102 + query.Where("dividends_order.created_at >= ?", todayZeroTime)
  103 + query.Where("dividends_order.created_at < ?", nextDayZeroTime)
  104 + if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
  105 + return 0, err
  106 + } else {
  107 + return count, nil
  108 + }
  109 +}
  110 +
81 func NewDividendsOrderDao(transactionContext *pgTransaction.TransactionContext) (*DividendsOrderDao, error) { 111 func NewDividendsOrderDao(transactionContext *pgTransaction.TransactionContext) (*DividendsOrderDao, error) {
82 if transactionContext == nil { 112 if transactionContext == nil {
83 return nil, fmt.Errorf("transactionContext参数不能为空") 113 return nil, fmt.Errorf("transactionContext参数不能为空")
@@ -13,7 +13,7 @@ type DividendsReturnedOrderDao struct { @@ -13,7 +13,7 @@ type DividendsReturnedOrderDao struct {
13 } 13 }
14 14
15 // GenerateDividendsReturnedOrderNumber 生成分红退货单号 15 // GenerateDividendsReturnedOrderNumber 生成分红退货单号
16 -func (dao *DividendsReturnedOrderDao) GenerateDividendsReturnedOrderNumber() (string, error) { 16 +func (dao *DividendsReturnedOrderDao) GenerateDividendsReturnedOrderNumber(queryOptions map[string]interface{}) (string, error) {
17 tx := dao.transactionContext.PgTx 17 tx := dao.transactionContext.PgTx
18 var dividendsReturnedOrderModels []*models.DividendsReturnedOrder 18 var dividendsReturnedOrderModels []*models.DividendsReturnedOrder
19 query := tx.Model(&dividendsReturnedOrderModels) 19 query := tx.Model(&dividendsReturnedOrderModels)
@@ -22,6 +22,9 @@ func (dao *DividendsReturnedOrderDao) GenerateDividendsReturnedOrderNumber() (st @@ -22,6 +22,9 @@ func (dao *DividendsReturnedOrderDao) GenerateDividendsReturnedOrderNumber() (st
22 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime) 22 nextDayZeroTime := utils.GetNextDayZeroTime(currentTime)
23 query.Where("dividends_returned_order.created_at >= ?", todayZeroTime) 23 query.Where("dividends_returned_order.created_at >= ?", todayZeroTime)
24 query.Where("dividends_returned_order.created_at < ?", nextDayZeroTime) 24 query.Where("dividends_returned_order.created_at < ?", nextDayZeroTime)
  25 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  26 + query = query.Where(`dividends_returned_order.company @> '{"companyId":"?"}'`, companyId)
  27 + }
25 if count, err := query.AllWithDeleted().SelectAndCount(); err != nil { 28 if count, err := query.AllWithDeleted().SelectAndCount(); err != nil {
26 return "", err 29 return "", err
27 } else { 30 } else {
@@ -30,7 +30,7 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte @@ -30,7 +30,7 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte
30 queryLimit = fmt.Sprintf("limit %v", queryOptions["limit"]) 30 queryLimit = fmt.Sprintf("limit %v", queryOptions["limit"])
31 } 31 }
32 sql := fmt.Sprintf(`select order_good_name good_name,sum(order_good_amount) good_amount from order_goods 32 sql := fmt.Sprintf(`select order_good_name good_name,sum(order_good_amount) good_amount from order_goods
33 -where company_id=? and org_id = ? %v 33 +where company_id=? and org_id = ? and deleted_at is null %v
34 GROUP BY order_good_name 34 GROUP BY order_good_name
35 order by good_amount desc 35 order by good_amount desc
36 %v 36 %v
@@ -49,7 +49,7 @@ func (dao *OrderGoodDao) CooperationCompanyModeStatistics(queryOptions map[strin @@ -49,7 +49,7 @@ func (dao *OrderGoodDao) CooperationCompanyModeStatistics(queryOptions map[strin
49 var goods []*domain.CooperationModeStatisticsDto 49 var goods []*domain.CooperationModeStatisticsDto
50 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 50 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
51 from credit_accounts a inner join cooperation_contracts b on a.cooperation_contract_number = b.cooperation_contract_number 51 from credit_accounts a inner join cooperation_contracts b on a.cooperation_contract_number = b.cooperation_contract_number
52 -where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and b.status = 1 52 +where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and a.deleted_at is null and b.status = 1
53 group by b.cooperation_mode_number 53 group by b.cooperation_mode_number
54 `) 54 `)
55 _, err := tx.Query(&goods, sql, queryOptions["companyId"], queryOptions["orgId"]) 55 _, err := tx.Query(&goods, sql, queryOptions["companyId"], queryOptions["orgId"])
@@ -50,6 +50,8 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -50,6 +50,8 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
50 for _, dividendsEstimate := range dividendsEstimates { 50 for _, dividendsEstimate := range dividendsEstimates {
51 // 根据当前分红预算单的分红订单号或退货单号获取分红预算单 51 // 根据当前分红预算单的分红订单号或退货单号获取分红预算单
52 if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{ 52 if countRelative, dividendsEstimatesRelative, err2 := dividendsEstimateRepository.Find(map[string]interface{}{
  53 + "companyId": dividendsEstimate.Company.CompanyId,
  54 + "orgId": dividendsEstimate.Org.OrgId,
53 "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum, 55 "orderOrReturnedOrderNum": dividendsEstimate.OrderOrReturnedOrderNum,
54 }); err2 != nil { 56 }); err2 != nil {
55 return nil, err2 57 return nil, err2
@@ -86,6 +88,8 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -86,6 +88,8 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
86 88
87 // 获取分红订单 89 // 获取分红订单
88 if countDividendsOrder, orders, err4 := dividendsOrderRepository.Find(map[string]interface{}{ 90 if countDividendsOrder, orders, err4 := dividendsOrderRepository.Find(map[string]interface{}{
  91 + "companyId": dividendsEstimates[0].Company.CompanyId,
  92 + "orgId": dividendsEstimates[0].Org.OrgId,
89 "dividendsOrderNumbers": orderNums, 93 "dividendsOrderNumbers": orderNums,
90 }); err4 != nil { 94 }); err4 != nil {
91 return nil, err4 95 return nil, err4
@@ -103,6 +107,8 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst @@ -103,6 +107,8 @@ func (domainService *CancelDividendsEstimateService) CancelEstimate(dividendsEst
103 107
104 // 获取分红退货单 108 // 获取分红退货单
105 if countDividendsReturnedOrder, returnedOrders, err5 := dividendsReturnedOrderRepository.Find(map[string]interface{}{ 109 if countDividendsReturnedOrder, returnedOrders, err5 := dividendsReturnedOrderRepository.Find(map[string]interface{}{
  110 + "companyId": dividendsEstimates[0].Company.CompanyId,
  111 + "orgId": dividendsEstimates[0].Org.OrgId,
106 "dividendsReturnedOrderNumbers": returnedOrderNums, 112 "dividendsReturnedOrderNumbers": returnedOrderNums,
107 }); err5 != nil { 113 }); err5 != nil {
108 return nil, err5 114 return nil, err5
@@ -2,9 +2,9 @@ package domain_service @@ -2,9 +2,9 @@ package domain_service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 - "github.com/linmadan/egglib-go/core/application"  
6 coreDomain "github.com/linmadan/egglib-go/core/domain" 5 coreDomain "github.com/linmadan/egglib-go/core/domain"
7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  7 + "github.com/shopspring/decimal"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/repository"
@@ -18,48 +18,157 @@ type ConfirmDividendsIncentivesEstimateService struct { @@ -18,48 +18,157 @@ type ConfirmDividendsIncentivesEstimateService struct {
18 // Confirm 确认业绩分红预算 18 // Confirm 确认业绩分红预算
19 func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood) ([]*service.DividendsEstimateDetail, error) { 19 func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoods []*domain.OrderGood) ([]*service.DividendsEstimateDetail, error) {
20 var cooperationContractRepository domain.CooperationContractRepository // 共创合约仓储 20 var cooperationContractRepository domain.CooperationContractRepository // 共创合约仓储
  21 + var cooperationProjectRepository domain.CooperationProjectRepository // 共创项目仓储
21 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储 22 var dividendsOrderRepository domain.DividendsOrderRepository // 分红订单仓储
22 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储 23 var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository // 分红退货单仓储
  24 +
23 // 共创合约仓储初始化 25 // 共创合约仓储初始化
24 if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil { 26 if repo, err := repository.NewCooperationContractRepository(domainService.transactionContext); err != nil {
25 return nil, err 27 return nil, err
26 } else { 28 } else {
27 cooperationContractRepository = repo 29 cooperationContractRepository = repo
28 } 30 }
  31 +
  32 + // 共创项目仓储初始化
  33 + if repo, err := repository.NewCooperationProjectRepository(domainService.transactionContext); err != nil {
  34 + return nil, err
  35 + } else {
  36 + cooperationProjectRepository = repo
  37 + }
  38 +
29 // 分红订单仓储初始化 39 // 分红订单仓储初始化
30 if repo, err := repository.NewDividendsOrderRepository(domainService.transactionContext); err != nil { 40 if repo, err := repository.NewDividendsOrderRepository(domainService.transactionContext); err != nil {
31 return nil, err 41 return nil, err
32 } else { 42 } else {
33 dividendsOrderRepository = repo 43 dividendsOrderRepository = repo
34 } 44 }
  45 +
35 // 分红退货单仓储初始化 46 // 分红退货单仓储初始化
36 if repo, err := repository.NewDividendsReturnedOrderRepository(domainService.transactionContext); err != nil { 47 if repo, err := repository.NewDividendsReturnedOrderRepository(domainService.transactionContext); err != nil {
37 return nil, err 48 return nil, err
38 } else { 49 } else {
39 dividendsReturnedOrderRepository = repo 50 dividendsReturnedOrderRepository = repo
40 } 51 }
  52 +
41 // 确认业绩分红预算 53 // 确认业绩分红预算
42 var dividendsEstimateDetails []*service.DividendsEstimateDetail 54 var dividendsEstimateDetails []*service.DividendsEstimateDetail
43 for _, orderGood := range orderGoods { 55 for _, orderGood := range orderGoods {
44 // 获取合约 56 // 获取合约
45 - cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{"cooperationContractNumber": orderGood.CooperationContractNumber}) 57 + cooperationContract, err := cooperationContractRepository.FindOne(map[string]interface{}{
  58 + "cooperationContractNumber": orderGood.CooperationContractNumber,
  59 + "companyId": orderGood.CompanyId,
  60 + "orgId": orderGood.OrgId,
  61 + })
46 if err != nil { 62 if err != nil {
47 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "共创合约不存在") 63 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  64 + DividendsUser: nil,
  65 + DividendsParticipateType: 0,
  66 + DividendsStage: 0,
  67 + DividendsAmount: 0,
  68 + OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
  69 + IsSuccessfully: false,
  70 + Reason: "共创合约错误",
  71 + })
  72 + continue
  73 + //return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
48 } 74 }
49 if cooperationContract == nil { 75 if cooperationContract == nil {
50 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.CooperationContractNumber)) 76 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  77 + DividendsUser: nil,
  78 + DividendsParticipateType: 0,
  79 + DividendsStage: 0,
  80 + DividendsAmount: 0,
  81 + OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
  82 + IsSuccessfully: false,
  83 + Reason: "共创合约" + orderGood.CooperationContractNumber + "不存在",
  84 + })
  85 + continue
  86 + //return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创合约%s不存在", orderGood.CooperationContractNumber))
  87 + }
  88 +
  89 + // 获取共创项目
  90 + cooperationProject, err := cooperationProjectRepository.FindOne(map[string]interface{}{
  91 + "cooperationProjectNumber": cooperationContract.CooperationProjectNumber,
  92 + "companyId": cooperationContract.Company.CompanyId,
  93 + "orgId": cooperationContract.Org.OrgId,
  94 + "notPause": true,
  95 + })
  96 + if err != nil {
  97 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  98 + DividendsUser: nil,
  99 + DividendsParticipateType: 0,
  100 + DividendsStage: 0,
  101 + DividendsAmount: 0,
  102 + OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
  103 + IsSuccessfully: false,
  104 + Reason: "共创项目" + orderGood.CooperationContractNumber + "查询错误",
  105 + })
  106 + continue
  107 + //return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
51 } 108 }
52 - if orderGood.DividendsOrderNumber != "" { 109 + if cooperationProject == nil {
  110 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  111 + DividendsUser: nil,
  112 + DividendsParticipateType: 0,
  113 + DividendsStage: 0,
  114 + DividendsAmount: 0,
  115 + OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
  116 + IsSuccessfully: false,
  117 + Reason: "共创项目" + orderGood.CooperationContractNumber + "已结束或不存在",
  118 + })
  119 + continue
  120 + //return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s不存在", cooperationContract.CooperationProjectNumber))
  121 + }
  122 +
  123 + // 校验合约关联的项目是否已结束
  124 + //if cooperationProject.Status == 2 {
  125 + // dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  126 + // DividendsUser: nil,
  127 + // DividendsParticipateType: 0,
  128 + // DividendsStage: 0,
  129 + // DividendsAmount: 0,
  130 + // OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
  131 + // IsSuccessfully: false,
  132 + // Reason: "共创项目" + orderGood.CooperationContractNumber + "已结束",
  133 + // })
  134 + // continue
  135 + // //return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("共创项目%s已结束", cooperationContract.CooperationProjectNumber))
  136 + //}
  137 +
  138 + if orderGood.DividendsOrderNumber != "" { // 获取分红订单
53 // 获取分红订单 139 // 获取分红订单
54 dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{ 140 dividendsOrder, err2 := dividendsOrderRepository.FindOne(map[string]interface{}{
55 "dividendsOrderNumber": orderGood.DividendsOrderNumber, 141 "dividendsOrderNumber": orderGood.DividendsOrderNumber,
  142 + "companyId": orderGood.CompanyId,
  143 + "orgId": orderGood.OrgId,
56 }) 144 })
57 if err2 != nil { 145 if err2 != nil {
58 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在") 146 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  147 + DividendsUser: nil,
  148 + DividendsParticipateType: 0,
  149 + DividendsStage: 0,
  150 + DividendsAmount: 0,
  151 + OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
  152 + IsSuccessfully: false,
  153 + Reason: "分红订单" + orderGood.DividendsOrderNumber + "查询错误",
  154 + })
  155 + continue
  156 + //return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红订单不存在")
59 } 157 }
60 if dividendsOrder == nil { 158 if dividendsOrder == nil {
61 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber)) 159 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  160 + DividendsUser: nil,
  161 + DividendsParticipateType: 0,
  162 + DividendsStage: 0,
  163 + DividendsAmount: 0,
  164 + OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
  165 + IsSuccessfully: false,
  166 + Reason: "分红订单" + orderGood.DividendsOrderNumber + "不存在",
  167 + })
  168 + continue
  169 + //return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("分红订单%s不存在", orderGood.DividendsOrderNumber))
62 } 170 }
  171 +
63 // 匹配分红规则 172 // 匹配分红规则
64 var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule 173 var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
65 for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules { 174 for _, dividendsIncentivesRule := range cooperationContract.DividendsIncentivesRules {
@@ -69,14 +178,24 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -69,14 +178,24 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
69 } 178 }
70 } 179 }
71 if dividendsIncentivesRuleMatched == nil { 180 if dividendsIncentivesRuleMatched == nil {
72 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, "未匹配到分红规则") 181 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  182 + DividendsUser: nil,
  183 + DividendsParticipateType: 0,
  184 + DividendsStage: 0,
  185 + DividendsAmount: 0,
  186 + OrderOrReturnedOrderNumber: orderGood.DividendsOrderNumber,
  187 + IsSuccessfully: false,
  188 + Reason: "未匹配到分红规则",
  189 + })
  190 + continue
  191 + //return nil, application.ThrowError(application.RES_NO_FIND_ERROR, "未匹配到分红规则")
73 } 192 }
74 193
75 // 计算分红 194 // 计算分红
76 if dividendsIncentivesRuleMatched != nil { 195 if dividendsIncentivesRuleMatched != nil {
77 for _, undertaker := range cooperationContract.Undertakers { 196 for _, undertaker := range cooperationContract.Undertakers {
78 // 添加承接人分红预算信息详情 197 // 添加承接人分红预算信息详情
79 - undertakerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage 198 + undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64()
80 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 199 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
81 DividendsUser: &domain.User{ 200 DividendsUser: &domain.User{
82 UserId: undertaker.UserId, 201 UserId: undertaker.UserId,
@@ -87,7 +206,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -87,7 +206,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
87 Roles: undertaker.Roles, 206 Roles: undertaker.Roles,
88 UserInfo: undertaker.UserInfo, 207 UserInfo: undertaker.UserInfo,
89 UserType: undertaker.UserType, 208 UserType: undertaker.UserType,
90 - UserName: undertaker.UserName, 209 + UserName: undertaker.UserInfo.UserName,
91 UserPhone: undertaker.UserPhone, 210 UserPhone: undertaker.UserPhone,
92 Status: undertaker.Status, 211 Status: undertaker.Status,
93 Company: undertaker.Company, 212 Company: undertaker.Company,
@@ -95,10 +214,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -95,10 +214,12 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
95 DividendsParticipateType: domain.UNDERTAKER, 214 DividendsParticipateType: domain.UNDERTAKER,
96 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, 215 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
97 DividendsAmount: undertakerDividendsAmount, 216 DividendsAmount: undertakerDividendsAmount,
  217 + OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
  218 + IsSuccessfully: true,
98 }) 219 })
99 // 添加推荐人分红预算信息详情 220 // 添加推荐人分红预算信息详情
100 if undertaker.Referrer != nil { 221 if undertaker.Referrer != nil {
101 - referrerDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.ReferrerPercentage 222 + referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
102 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 223 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
103 DividendsUser: &domain.User{ 224 DividendsUser: &domain.User{
104 UserId: undertaker.Referrer.UserId, 225 UserId: undertaker.Referrer.UserId,
@@ -116,11 +237,13 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -116,11 +237,13 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
116 DividendsParticipateType: domain.REFERRER, 237 DividendsParticipateType: domain.REFERRER,
117 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, 238 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
118 DividendsAmount: referrerDividendsAmount, 239 DividendsAmount: referrerDividendsAmount,
  240 + OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
  241 + IsSuccessfully: true,
119 }) 242 })
120 } 243 }
121 // 添加关联业务员分红预算信息详情 244 // 添加关联业务员分红预算信息详情
122 if undertaker.Salesman != nil { 245 if undertaker.Salesman != nil {
123 - salesmanDividendsAmount := (orderGood.OrderGoodAmount - orderGood.OrderGoodExpense) * dividendsIncentivesRuleMatched.SalesmanPercentage 246 + salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
124 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 247 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
125 DividendsUser: &domain.User{ 248 DividendsUser: &domain.User{
126 UserId: undertaker.Salesman.UserId, 249 UserId: undertaker.Salesman.UserId,
@@ -131,26 +254,50 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -131,26 +254,50 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
131 Roles: undertaker.Salesman.Roles, 254 Roles: undertaker.Salesman.Roles,
132 UserInfo: undertaker.Salesman.UserInfo, 255 UserInfo: undertaker.Salesman.UserInfo,
133 UserType: undertaker.Salesman.UserType, 256 UserType: undertaker.Salesman.UserType,
134 - UserName: undertaker.Salesman.UserName, 257 + UserName: undertaker.Salesman.UserInfo.UserName,
135 UserPhone: undertaker.Salesman.UserPhone, 258 UserPhone: undertaker.Salesman.UserPhone,
136 Company: undertaker.Salesman.Company, 259 Company: undertaker.Salesman.Company,
137 }, 260 },
138 DividendsParticipateType: domain.SALESMAN, 261 DividendsParticipateType: domain.SALESMAN,
139 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, 262 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
140 DividendsAmount: salesmanDividendsAmount, 263 DividendsAmount: salesmanDividendsAmount,
  264 + OrderOrReturnedOrderNumber: dividendsOrder.DividendsOrderNumber,
  265 + IsSuccessfully: true,
141 }) 266 })
142 } 267 }
143 } 268 }
144 } 269 }
145 - } else if orderGood.DividendsReturnedOrderNumber != "" { // 获取分红退货单 270 + } else if orderGood.DividendsReturnedOrderNumber != "" { // 获取退货单
146 dividendsReturnedOrder, err3 := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{ 271 dividendsReturnedOrder, err3 := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{
147 "dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber, 272 "dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber,
  273 + "companyId": orderGood.CompanyId,
  274 + "orgId": orderGood.OrgId,
148 }) 275 })
149 if err3 != nil { 276 if err3 != nil {
150 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红退货单不存在") 277 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  278 + DividendsUser: nil,
  279 + DividendsParticipateType: 0,
  280 + DividendsStage: 0,
  281 + DividendsAmount: 0,
  282 + OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
  283 + IsSuccessfully: false,
  284 + Reason: "退货单" + orderGood.DividendsReturnedOrderNumber + "不存在",
  285 + })
  286 + continue
  287 + //return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, "分红退货单不存在")
151 } 288 }
152 if dividendsReturnedOrder == nil { 289 if dividendsReturnedOrder == nil {
153 - return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber)) 290 + dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
  291 + DividendsUser: nil,
  292 + DividendsParticipateType: 0,
  293 + DividendsStage: 0,
  294 + DividendsAmount: 0,
  295 + OrderOrReturnedOrderNumber: orderGood.DividendsReturnedOrderNumber,
  296 + IsSuccessfully: false,
  297 + Reason: "退货单" + orderGood.DividendsReturnedOrderNumber + "不存在",
  298 + })
  299 + continue
  300 + //return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
154 } 301 }
155 // 匹配分红规则 302 // 匹配分红规则
156 var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule 303 var dividendsIncentivesRuleMatched *domain.DividendsIncentivesRule
@@ -163,7 +310,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -163,7 +310,7 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
163 // 计算分红 310 // 计算分红
164 for _, undertaker := range cooperationContract.Undertakers { 311 for _, undertaker := range cooperationContract.Undertakers {
165 // 添加承接人分红退货预算信息详情 312 // 添加承接人分红退货预算信息详情
166 - undertakerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.DividendsIncentivesPercentage 313 + undertakerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.DividendsIncentivesPercentage).Div(decimal.NewFromFloat(100))).Float64()
167 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 314 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
168 DividendsUser: &domain.User{ 315 DividendsUser: &domain.User{
169 UserId: undertaker.UserId, 316 UserId: undertaker.UserId,
@@ -174,18 +321,20 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -174,18 +321,20 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
174 Roles: undertaker.Roles, 321 Roles: undertaker.Roles,
175 UserInfo: undertaker.UserInfo, 322 UserInfo: undertaker.UserInfo,
176 UserType: undertaker.UserType, 323 UserType: undertaker.UserType,
177 - UserName: undertaker.UserName, 324 + UserName: undertaker.UserInfo.UserName,
178 UserPhone: undertaker.UserPhone, 325 UserPhone: undertaker.UserPhone,
179 Status: undertaker.Status, 326 Status: undertaker.Status,
180 Company: undertaker.Company, 327 Company: undertaker.Company,
181 }, 328 },
182 DividendsParticipateType: domain.UNDERTAKER, 329 DividendsParticipateType: domain.UNDERTAKER,
183 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, 330 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
184 - DividendsAmount: undertakerDividendsAmount, 331 + DividendsAmount: -undertakerDividendsAmount,
  332 + OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsOrderNumber,
  333 + IsSuccessfully: true,
185 }) 334 })
186 // 添加推荐人分红退货预算信息详情 335 // 添加推荐人分红退货预算信息详情
187 if undertaker.Referrer != nil { 336 if undertaker.Referrer != nil {
188 - referrerDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.ReferrerPercentage 337 + referrerDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
189 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 338 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
190 DividendsUser: &domain.User{ 339 DividendsUser: &domain.User{
191 UserId: undertaker.Referrer.UserId, 340 UserId: undertaker.Referrer.UserId,
@@ -196,18 +345,20 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -196,18 +345,20 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
196 Roles: undertaker.Referrer.Roles, 345 Roles: undertaker.Referrer.Roles,
197 UserInfo: undertaker.Referrer.UserInfo, 346 UserInfo: undertaker.Referrer.UserInfo,
198 UserType: undertaker.Referrer.UserType, 347 UserType: undertaker.Referrer.UserType,
199 - UserName: undertaker.Referrer.UserName, 348 + UserName: undertaker.Referrer.UserInfo.UserName,
200 UserPhone: undertaker.Referrer.UserPhone, 349 UserPhone: undertaker.Referrer.UserPhone,
201 Company: undertaker.Referrer.Company, 350 Company: undertaker.Referrer.Company,
202 }, 351 },
203 DividendsParticipateType: domain.REFERRER, 352 DividendsParticipateType: domain.REFERRER,
204 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, 353 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
205 - DividendsAmount: referrerDividendsAmount, 354 + DividendsAmount: -referrerDividendsAmount,
  355 + OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsOrderNumber,
  356 + IsSuccessfully: true,
206 }) 357 })
207 } 358 }
208 // 添加关联业务员分红退货预算信息详情 359 // 添加关联业务员分红退货预算信息详情
209 if undertaker.Salesman != nil { 360 if undertaker.Salesman != nil {
210 - salesmanDividendsAmount := -orderGood.OrderGoodAmount * dividendsIncentivesRuleMatched.SalesmanPercentage 361 + salesmanDividendsAmount, _ := decimal.NewFromFloat(orderGood.OrderGoodAmount).Mul(decimal.NewFromFloat(dividendsIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
211 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 362 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
212 DividendsUser: &domain.User{ 363 DividendsUser: &domain.User{
213 UserId: undertaker.Salesman.UserId, 364 UserId: undertaker.Salesman.UserId,
@@ -218,13 +369,15 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo @@ -218,13 +369,15 @@ func (domainService *ConfirmDividendsIncentivesEstimateService) Confirm(orderGoo
218 Roles: undertaker.Salesman.Roles, 369 Roles: undertaker.Salesman.Roles,
219 UserInfo: undertaker.Salesman.UserInfo, 370 UserInfo: undertaker.Salesman.UserInfo,
220 UserType: undertaker.Salesman.UserType, 371 UserType: undertaker.Salesman.UserType,
221 - UserName: undertaker.Salesman.UserName, 372 + UserName: undertaker.Salesman.UserInfo.UserName,
222 UserPhone: undertaker.Salesman.UserPhone, 373 UserPhone: undertaker.Salesman.UserPhone,
223 Company: undertaker.Salesman.Company, 374 Company: undertaker.Salesman.Company,
224 }, 375 },
225 DividendsParticipateType: domain.SALESMAN, 376 DividendsParticipateType: domain.SALESMAN,
226 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage, 377 DividendsStage: dividendsIncentivesRuleMatched.DividendsIncentivesStage,
227 - DividendsAmount: salesmanDividendsAmount, 378 + DividendsAmount: -salesmanDividendsAmount,
  379 + OrderOrReturnedOrderNumber: dividendsReturnedOrder.DividendsOrderNumber,
  380 + IsSuccessfully: true,
228 }) 381 })
229 } 382 }
230 } 383 }
@@ -4,6 +4,7 @@ import ( @@ -4,6 +4,7 @@ import (
4 "fmt" 4 "fmt"
5 coreDomain "github.com/linmadan/egglib-go/core/domain" 5 coreDomain "github.com/linmadan/egglib-go/core/domain"
6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
  7 + "github.com/shopspring/decimal"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
@@ -16,16 +17,8 @@ type ConfirmMoneyIncentivesEstimateService struct { @@ -16,16 +17,8 @@ type ConfirmMoneyIncentivesEstimateService struct {
16 } 17 }
17 18
18 func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *domain.CooperationContract, stage int32, undertakerUIDs []int64) ([]*service.DividendsEstimateDetail, error) { 19 func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *domain.CooperationContract, stage int32, undertakerUIDs []int64) ([]*service.DividendsEstimateDetail, error) {
19 - //var dividendsEstimateRepository domain.DividendsEstimateRepository // 分红预算单仓储  
20 var dividendsEstimateDao *dao.DividendsEstimateDao // 分红预算DAO 20 var dividendsEstimateDao *dao.DividendsEstimateDao // 分红预算DAO
21 21
22 - // 分红预算单仓储初始化  
23 - //if repo, err := repository.NewDividendsEstimateRepository(domainService.transactionContext); err != nil {  
24 - // return nil, err  
25 - //} else {  
26 - // dividendsEstimateRepository = repo  
27 - //}  
28 -  
29 // 分红预算DAO初始化 22 // 分红预算DAO初始化
30 if estimateDao, err := dao.NewDividendsEstimateDao(domainService.transactionContext); err != nil { 23 if estimateDao, err := dao.NewDividendsEstimateDao(domainService.transactionContext); err != nil {
31 return nil, err 24 return nil, err
@@ -68,7 +61,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -68,7 +61,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
68 if undertakerEstimated { 61 if undertakerEstimated {
69 return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红") 62 return nil, fmt.Errorf("用户 " + undertaker.UserName + " 已分红")
70 } else { 63 } else {
71 - undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (1 - (moneyIncentivesRuleMatched.SalesmanPercentage+moneyIncentivesRuleMatched.ReferrerPercentage)/100) 64 + undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(1).Sub(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Add(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage))).Div(decimal.NewFromFloat(100))).Float64()
72 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 65 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
73 DividendsUser: &domain.User{ 66 DividendsUser: &domain.User{
74 UserId: undertaker.UserId, 67 UserId: undertaker.UserId,
@@ -91,7 +84,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -91,7 +84,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
91 } 84 }
92 85
93 // 判断业务员在当前阶段是否已经分红 86 // 判断业务员在当前阶段是否已经分红
94 - if undertaker.Salesman.UserId != 0 { 87 + if undertaker.Salesman != nil {
95 salesmanEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{ 88 salesmanEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
96 "undertakerUid": undertaker.Salesman.UserId, 89 "undertakerUid": undertaker.Salesman.UserId,
97 "companyId": contract.Company.CompanyId, 90 "companyId": contract.Company.CompanyId,
@@ -103,7 +96,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -103,7 +96,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
103 if salesmanEstimated { 96 if salesmanEstimated {
104 return nil, fmt.Errorf("业务员 " + undertaker.Salesman.UserName + " 已分红") 97 return nil, fmt.Errorf("业务员 " + undertaker.Salesman.UserName + " 已分红")
105 } else { 98 } else {
106 - undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.SalesmanPercentage / 100) 99 + undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(moneyIncentivesRuleMatched.SalesmanPercentage).Div(decimal.NewFromFloat(100))).Float64()
107 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 100 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
108 DividendsUser: &domain.User{ 101 DividendsUser: &domain.User{
109 UserId: undertaker.Salesman.UserId, 102 UserId: undertaker.Salesman.UserId,
@@ -127,7 +120,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -127,7 +120,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
127 } 120 }
128 121
129 // 判断关联业务员在当前阶段是否已经分红 122 // 判断关联业务员在当前阶段是否已经分红
130 - if undertaker.Referrer.UserId != 0 { 123 + if undertaker.Referrer != nil {
131 referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{ 124 referrerEstimated, err := dividendsEstimateDao.UserEstimated(map[string]interface{}{
132 "undertakerUid": undertaker.Referrer.UserId, 125 "undertakerUid": undertaker.Referrer.UserId,
133 "companyId": contract.Company.CompanyId, 126 "companyId": contract.Company.CompanyId,
@@ -139,7 +132,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do @@ -139,7 +132,7 @@ func (domainService *ConfirmMoneyIncentivesEstimateService) Confirm(contract *do
139 if referrerEstimated { 132 if referrerEstimated {
140 return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红") 133 return nil, fmt.Errorf("推荐人 " + undertaker.Salesman.UserName + " 已分红")
141 } else { 134 } else {
142 - undertakerDividendsAmount := moneyIncentivesRuleMatched.MoneyIncentivesAmount * (moneyIncentivesRuleMatched.ReferrerPercentage / 100) 135 + undertakerDividendsAmount, _ := decimal.NewFromFloat(moneyIncentivesRuleMatched.MoneyIncentivesAmount).Mul(decimal.NewFromFloat(moneyIncentivesRuleMatched.ReferrerPercentage).Div(decimal.NewFromFloat(100))).Float64()
143 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{ 136 dividendsEstimateDetails = append(dividendsEstimateDetails, &service.DividendsEstimateDetail{
144 DividendsUser: &domain.User{ 137 DividendsUser: &domain.User{
145 UserId: undertaker.Referrer.UserId, 138 UserId: undertaker.Referrer.UserId,
@@ -317,6 +317,7 @@ func (ptr *CooperationStatisticsService) CompanyPaymentHistoryStatistics(queryOp @@ -317,6 +317,7 @@ func (ptr *CooperationStatisticsService) CompanyPaymentHistoryStatistics(queryOp
317 Limit int `json:"limit" valid:"Required"` 317 Limit int `json:"limit" valid:"Required"`
318 Offset int `json:"offset"` 318 Offset int `json:"offset"`
319 OrgId int64 `json:"orgId" valid:"Required"` 319 OrgId int64 `json:"orgId" valid:"Required"`
  320 + UserId int64 `json:"userId" valid:"Required"`
320 SortByActuallyPaidAmount int `json:"sortByActuallyPaidAmount" valid:"Required"` 321 SortByActuallyPaidAmount int `json:"sortByActuallyPaidAmount" valid:"Required"`
321 BeginTime time.Time `json:"beginTime"` 322 BeginTime time.Time `json:"beginTime"`
322 EndTime time.Time `json:"endTime"` 323 EndTime time.Time `json:"endTime"`
@@ -326,13 +327,23 @@ func (ptr *CooperationStatisticsService) CompanyPaymentHistoryStatistics(queryOp @@ -326,13 +327,23 @@ func (ptr *CooperationStatisticsService) CompanyPaymentHistoryStatistics(queryOp
326 } 327 }
327 queryOptions = tool_funs.SimpleStructToMap(&request) 328 queryOptions = tool_funs.SimpleStructToMap(&request)
328 329
  330 + // 按关联相关人过滤
  331 + var retMap = make([]interface{}, 0)
  332 + contractNumbers, err := ptr.getRelevantContracts(map[string]interface{}{"userId": request.UserId})
  333 + if len(contractNumbers) == 0 {
  334 + return retMap, nil
  335 + }
  336 + if err != nil {
  337 + return retMap, err
  338 + }
  339 + queryOptions["cooperationContractNumbers"] = contractNumbers
  340 +
329 var responses []usersStatisticsResponse 341 var responses []usersStatisticsResponse
330 creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext) 342 creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
331 if err := creditAccountDao.CooperationUsersDividendsStatistics(queryOptions, &responses); err != nil { 343 if err := creditAccountDao.CooperationUsersDividendsStatistics(queryOptions, &responses); err != nil {
332 return nil, err 344 return nil, err
333 } 345 }
334 346
335 - var retMap = make([]interface{}, 0)  
336 for i := range responses { 347 for i := range responses {
337 retMap = append(retMap, map[string]interface{}{ 348 retMap = append(retMap, map[string]interface{}{
338 "paymentAmount": responses[i].ActuallyPaidAmount, 349 "paymentAmount": responses[i].ActuallyPaidAmount,
@@ -354,21 +365,75 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query @@ -354,21 +365,75 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query
354 365
355 var request = struct { 366 var request = struct {
356 OrgId int64 `json:"orgId"` 367 OrgId int64 `json:"orgId"`
  368 + UserId int64 `json:"userId"`
357 UserBaseId int64 `json:"userBaseId"` 369 UserBaseId int64 `json:"userBaseId"`
  370 + BeginTime time.Time `json:"beginTime"`
  371 + EndTime time.Time `json:"endTime"`
358 }{} 372 }{}
359 if err := LoadQueryObject(queryOptions, &request); err != nil { 373 if err := LoadQueryObject(queryOptions, &request); err != nil {
360 return nil, err 374 return nil, err
361 } 375 }
362 queryOptions = tool_funs.SimpleStructToMap(&request) 376 queryOptions = tool_funs.SimpleStructToMap(&request)
363 377
  378 + // 按关联相关人过滤
  379 + var contractNumbers []string
  380 + var err error
  381 + if request.UserId > 0 {
  382 + var retMap = make([]interface{}, 0)
  383 + contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"userId": request.UserId})
  384 + if len(contractNumbers) == 0 {
  385 + return retMap, nil
  386 + }
  387 + if err != nil {
  388 + return retMap, err
  389 + }
  390 + queryOptions["cooperationContractNumbers"] = contractNumbers
  391 + }
  392 +
364 var dividends = &CreditAccountStatisticsResponse{} 393 var dividends = &CreditAccountStatisticsResponse{}
  394 + var xAxisData []string
  395 + var values []float64
  396 + var queryItems []queryItem
  397 + if !request.BeginTime.IsZero() && request.BeginTime.AddDate(0, 3, 0).Before(request.EndTime) {
  398 + queryItems, xAxisData = histogramStatisticsByYear()
  399 + } else {
  400 + queryItems, xAxisData = histogramStatisticsByMonth()
  401 + }
  402 + for i := range queryItems {
  403 + item := queryItems[i]
  404 + if len(contractNumbers) == 0 && request.UserId > 0 { //没有相关的合约 查看分红预算单为空
  405 + continue
  406 + }
  407 + queryOptions["beginTime"] = item.BeginTime
  408 + queryOptions["endTime"] = item.EndTime
  409 + if err := creditAccountDao.DividendsStatistics(queryOptions, dividends); err != nil {
  410 + return nil, err
  411 + }
  412 + values = append(values, dividends.Paid)
  413 + }
  414 + return map[string]interface{}{
  415 + "xAxis": map[string]interface{}{
  416 + "data": xAxisData,
  417 + },
  418 + "source": map[string]interface{}{
  419 + "value": values,
  420 + },
  421 + }, nil
  422 +}
  423 +
  424 +type queryItem struct {
  425 + BeginTime time.Time
  426 + EndTime time.Time
  427 +}
  428 +
  429 +func histogramStatisticsByMonth() ([]queryItem, []string) {
  430 + ret := make([]queryItem, 0)
365 year, month := time.Now().Year(), time.Now().Month() 431 year, month := time.Now().Year(), time.Now().Month()
366 var beginTime = time.Date(year, month, 1, 0, 0, 0, 0, time.Local) 432 var beginTime = time.Date(year, month, 1, 0, 0, 0, 0, time.Local)
367 var endTime time.Time 433 var endTime time.Time
368 var increaseDay = 5 434 var increaseDay = 5
369 var monthEnd = time.Date(year, month+1, 1, 0, 0, 0, 0, time.Local).Add(-time.Second) 435 var monthEnd = time.Date(year, month+1, 1, 0, 0, 0, 0, time.Local).Add(-time.Second)
370 var xAxisData []string 436 var xAxisData []string
371 - var values []float64  
372 for { 437 for {
373 if beginTime.AddDate(0, 0, increaseDay).After(monthEnd) { 438 if beginTime.AddDate(0, 0, increaseDay).After(monthEnd) {
374 endTime = monthEnd 439 endTime = monthEnd
@@ -376,25 +441,30 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query @@ -376,25 +441,30 @@ func (ptr *CooperationStatisticsService) PaymentHistoryHistogramStatistics(query
376 } else { 441 } else {
377 endTime = beginTime.AddDate(0, 0, increaseDay).Add(-time.Second) 442 endTime = beginTime.AddDate(0, 0, increaseDay).Add(-time.Second)
378 } 443 }
379 - xAxisData = append(xAxisData, endTime.Format("01-02"))  
380 - queryOptions["beginTime"] = beginTime  
381 - queryOptions["endTime"] = beginTime.AddDate(0, 0, increaseDay)  
382 - if err := creditAccountDao.DividendsStatistics(queryOptions, dividends); err != nil {  
383 - return nil, err 444 + item := queryItem{
  445 + BeginTime: beginTime,
  446 + EndTime: beginTime.AddDate(0, 0, increaseDay).Add(-time.Second),
384 } 447 }
385 - dividends.Accounting = dividends.Total - dividends.Accounted  
386 - values = append(values, dividends.Paid) 448 + xAxisData = append(xAxisData, item.EndTime.Format("01-02"))
387 beginTime = endTime 449 beginTime = endTime
388 if endTime == monthEnd { 450 if endTime == monthEnd {
389 break 451 break
390 } 452 }
  453 + ret = append(ret, item)
391 } 454 }
392 - return map[string]interface{}{  
393 - "xAxis": map[string]interface{}{  
394 - "data": xAxisData,  
395 - },  
396 - "source": map[string]interface{}{  
397 - "value": values,  
398 - },  
399 - }, nil 455 + return ret, xAxisData
  456 +}
  457 +
  458 +func histogramStatisticsByYear() ([]queryItem, []string) {
  459 + ret := make([]queryItem, 0)
  460 + var xAxisData = []string{"3月", "6月", "9月", "12月"}
  461 + year, _ := time.Now().Year(), time.Now().Month()
  462 + var increase = 3
  463 + for i := 0; i < 4; i++ {
  464 + ret = append(ret, queryItem{
  465 + BeginTime: time.Date(year, time.Month(1+i*increase), 1, 0, 0, 0, 0, time.Local),
  466 + EndTime: time.Date(year, time.Month(1+(i+1)*increase), 1, 0, 0, 0, 0, time.Local),
  467 + })
  468 + }
  469 + return ret, xAxisData
400 } 470 }
@@ -52,21 +52,15 @@ func (ptr *CooperationStatisticsService) cooperationCompanyStatistics(userBaseId @@ -52,21 +52,15 @@ func (ptr *CooperationStatisticsService) cooperationCompanyStatistics(userBaseId
52 52
53 // 2.相关合约统计 53 // 2.相关合约统计
54 cooperationContractRelevantRepository, _ := repository.NewCooperationContractRelevantRepository(ptr.transactionContext) 54 cooperationContractRelevantRepository, _ := repository.NewCooperationContractRelevantRepository(ptr.transactionContext)
55 - cooperationContractCount, _, err := cooperationContractRelevantRepository.Find(map[string]interface{}{"userBaseId": userBaseId, 55 + cooperationContractCount, _, err := cooperationContractRelevantRepository.Find(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId,
56 "limit": 1}) 56 "limit": 1})
57 if err != nil { 57 if err != nil {
58 return nil, err 58 return nil, err
59 } 59 }
60 60
61 // 3.个人分红统计 61 // 3.个人分红统计
62 - type response struct {  
63 - Total float64 `json:"total"`  
64 - Accounting float64 `json:"accounting"`  
65 - Accounted float64 `json:"accounted"`  
66 - Paid float64 `json:"paid"`  
67 - }  
68 creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext) 62 creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
69 - var allDividends = &response{} 63 + var allDividends = &CreditAccountStatisticsResponse{}
70 if err := creditAccountDao.DividendsStatistics(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId}, allDividends); err != nil { 64 if err := creditAccountDao.DividendsStatistics(map[string]interface{}{"userBaseId": userBaseId, "orgId": orgId}, allDividends); err != nil {
71 return nil, err 65 return nil, err
72 } 66 }
@@ -76,7 +70,7 @@ func (ptr *CooperationStatisticsService) cooperationCompanyStatistics(userBaseId @@ -76,7 +70,7 @@ func (ptr *CooperationStatisticsService) cooperationCompanyStatistics(userBaseId
76 OrgId: orgId, 70 OrgId: orgId,
77 CooperationProjectCount: cooperationProjectCount, 71 CooperationProjectCount: cooperationProjectCount,
78 CooperationContractCount: cooperationContractCount, 72 CooperationContractCount: cooperationContractCount,
79 - DividendsIncome: utils.Round(allDividends.Total, 2), 73 + DividendsIncome: utils.Round(allDividends.Accounted, 2),
80 } 74 }
81 return ret, nil 75 return ret, nil
82 } 76 }
@@ -105,7 +99,7 @@ func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(que @@ -105,7 +99,7 @@ func (ptr *CooperationStatisticsService) PersonCooperationContractStatistics(que
105 } 99 }
106 queryOptions = tool_funs.SimpleStructToMap(&request) 100 queryOptions = tool_funs.SimpleStructToMap(&request)
107 101
108 - cooperationContractUndertaker, _ := repository.NewCooperationContractUndertakerRepository(ptr.transactionContext) 102 + cooperationContractUndertaker, _ := repository.NewCooperationContractRelevantRepository(ptr.transactionContext)
109 _, contractUndertakers, err := cooperationContractUndertaker.Find(queryOptions) 103 _, contractUndertakers, err := cooperationContractUndertaker.Find(queryOptions)
110 if err != nil { 104 if err != nil {
111 return nil, nil 105 return nil, nil
1 package domain_service 1 package domain_service
2 2
3 import ( 3 import (
4 - "encoding/json"  
5 "fmt" 4 "fmt"
6 "github.com/go-pg/pg/v10" 5 "github.com/go-pg/pg/v10"
7 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 6 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
@@ -48,6 +47,8 @@ const ( @@ -48,6 +47,8 @@ const (
48 CreditAccountStatistics = "CreditAccountStatistics" 47 CreditAccountStatistics = "CreditAccountStatistics"
49 // 公司/个人 - 支付历史统计直方图 48 // 公司/个人 - 支付历史统计直方图
50 PaymentHistoryHistogramStatistics = "PaymentHistoryHistogramStatistics" 49 PaymentHistoryHistogramStatistics = "PaymentHistoryHistogramStatistics"
  50 + // 用户相关的项目合约编号列表查询
  51 + RelevantCooperationContractNumbers = "RelevantCooperationContractNumbers"
51 ) 52 )
52 53
53 // CooperationStatisticsService 共创统计服务 54 // CooperationStatisticsService 共创统计服务
@@ -77,6 +78,7 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma @@ -77,6 +78,7 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma
77 //企业 78 //企业
78 CompanyId int64 `json:"companyId"` 79 CompanyId int64 `json:"companyId"`
79 OrgId int64 `json:"orgId"` 80 OrgId int64 `json:"orgId"`
  81 + UserId int64 `json:"userId"`
80 //个人 82 //个人
81 UserBaseId int64 `json:"userBaseId"` 83 UserBaseId int64 `json:"userBaseId"`
82 Offset int `json:"offset"` 84 Offset int `json:"offset"`
@@ -90,11 +92,11 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma @@ -90,11 +92,11 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma
90 // 1.根据个人、企业查询合约列表 92 // 1.根据个人、企业查询合约列表
91 var contracts []*domain.CooperationContract 93 var contracts []*domain.CooperationContract
92 var err error 94 var err error
93 - if _, ok := queryOptions["userBaseId"]; ok {  
94 - contracts, err = ptr.getUserContracts(queryOptions)  
95 - } else if v, ok := queryOptions["orgId"]; ok {  
96 - queryOptions["orgId"], _ = (v.(json.Number)).Int64()  
97 - contracts, err = ptr.getCompanyContracts(queryOptions) 95 + if request.UserBaseId > 0 {
  96 + contracts, err = ptr.getUserContracts(request.UserBaseId, queryOptions)
  97 + } else if request.OrgId > 0 {
  98 + queryOptions["orgId"] = request.OrgId
  99 + contracts, err = ptr.getCompanyContracts(request.UserId, queryOptions)
98 } 100 }
99 if err != nil { 101 if err != nil {
100 return nil, err 102 return nil, err
@@ -131,32 +133,59 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma @@ -131,32 +133,59 @@ func (ptr *CooperationStatisticsService) SearchContractDividends(queryOptions ma
131 // getUserContracts 获取用户的合约列表 133 // getUserContracts 获取用户的合约列表
132 // 134 //
133 // p1 p1_desc 135 // p1 p1_desc
134 -func (ptr *CooperationStatisticsService) getUserContracts(queryOptions map[string]interface{}) ([]*domain.CooperationContract, error) {  
135 - undertakerRepository, _ := repository.NewCooperationContractUndertakerRepository(ptr.transactionContext)  
136 - _, undertakers, err := undertakerRepository.Find(queryOptions)  
137 - var numbers []string  
138 - for i := range undertakers {  
139 - numbers = append(numbers, undertakers[i].CooperationContractNumber) 136 +func (ptr *CooperationStatisticsService) getUserContracts(userBaseId int64, queryOptions map[string]interface{}) ([]*domain.CooperationContract, error) {
  137 + var contracts = make([]*domain.CooperationContract, 0)
  138 + if userBaseId == 0 {
  139 + return contracts, nil
140 } 140 }
141 - if len(numbers) == 0 {  
142 - return []*domain.CooperationContract{}, nil 141 + contractNumbers, err := ptr.getRelevantContracts(map[string]interface{}{"userBaseId": userBaseId})
  142 + if len(contractNumbers) == 0 {
  143 + return contracts, nil
143 } 144 }
144 - queryOptions["inCooperationContractNumber"] = numbers  
145 - contractRepository, _ := repository.NewCooperationContractRepository(ptr.transactionContext)  
146 - _, contracts, err := contractRepository.Find(queryOptions) 145 + if err != nil {
  146 + return contracts, err
  147 + }
  148 + queryOptions["cooperationContractNumbers"] = contractNumbers
  149 + contractRepository, _ := dao.NewCooperationContractDao(ptr.transactionContext)
  150 + _, contracts, err = contractRepository.Find(queryOptions)
147 return contracts, err 151 return contracts, err
148 } 152 }
149 153
150 // getCompanyContracts 获取组织合约列表 154 // getCompanyContracts 获取组织合约列表
151 // 155 //
152 // p1 p1_desc 156 // p1 p1_desc
153 -func (ptr *CooperationStatisticsService) getCompanyContracts(queryOptions map[string]interface{}) ([]*domain.CooperationContract, error) {  
154 - contractRepository, _ := repository.NewCooperationContractRepository(ptr.transactionContext)  
155 - // TODO: 参数查询条件  
156 - _, contracts, err := contractRepository.Find(queryOptions) 157 +func (ptr *CooperationStatisticsService) getCompanyContracts(userId int64, queryOptions map[string]interface{}) ([]*domain.CooperationContract, error) {
  158 + var contracts = make([]*domain.CooperationContract, 0)
  159 + if userId == 0 {
  160 + return contracts, nil
  161 + }
  162 + contractNumbers, err := ptr.getRelevantContracts(map[string]interface{}{"userId": userId})
  163 + if len(contractNumbers) == 0 {
  164 + return contracts, nil
  165 + }
  166 + if err != nil {
  167 + return contracts, err
  168 + }
  169 + queryOptions["cooperationContractNumbers"] = contractNumbers
  170 + contractRepository, _ := dao.NewCooperationContractDao(ptr.transactionContext)
  171 + _, contracts, err = contractRepository.Find(queryOptions)
157 return contracts, err 172 return contracts, err
158 } 173 }
159 174
  175 +//getRelevantContracts 获取相关人的合约
  176 +func (ptr *CooperationStatisticsService) getRelevantContracts(queryOptions map[string]interface{}) ([]string, error) {
  177 + undertakerRepository, _ := repository.NewCooperationContractRelevantRepository(ptr.transactionContext)
  178 + _, undertakers, err := undertakerRepository.Find(queryOptions)
  179 + var numbers []string
  180 + for i := range undertakers {
  181 + numbers = append(numbers, undertakers[i].CooperationContractNumber)
  182 + }
  183 + if len(numbers) == 0 {
  184 + return []string{}, nil
  185 + }
  186 + return numbers, err
  187 +}
  188 +
160 // getContractsDividendsEstimate 合约分红预算 189 // getContractsDividendsEstimate 合约分红预算
161 func (ptr *CooperationStatisticsService) getContractsDividendsEstimate(numbers []string) (map[string]*domain.DividendsEstimate, error) { 190 func (ptr *CooperationStatisticsService) getContractsDividendsEstimate(numbers []string) (map[string]*domain.DividendsEstimate, error) {
162 var estimates []*domain.DividendsEstimate 191 var estimates []*domain.DividendsEstimate
@@ -320,6 +349,7 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st @@ -320,6 +349,7 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st
320 //企业 349 //企业
321 CompanyId int64 `json:"companyId"` 350 CompanyId int64 `json:"companyId"`
322 OrgId int64 `json:"orgId"` 351 OrgId int64 `json:"orgId"`
  352 + UserId int64 `json:"userId"`
323 //个人 353 //个人
324 UserBaseId int64 `json:"userBaseId"` 354 UserBaseId int64 `json:"userBaseId"`
325 }{} 355 }{}
@@ -335,14 +365,32 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st @@ -335,14 +365,32 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st
335 Paid float64 `json:"paid"` 365 Paid float64 `json:"paid"`
336 } 366 }
337 creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext) 367 creditAccountDao, _ := dao.NewCreditAccountDao(ptr.transactionContext)
  368 + var contractNumbers []string
  369 + var err error
  370 + if request.OrgId > 0 && request.UserId > 0 {
  371 + contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"orgId": request.OrgId, "userId": request.UserId})
  372 + if err != nil {
  373 + return struct{}{}, err
  374 + }
  375 + } else if request.UserBaseId > 0 {
  376 + contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"orgId": request.OrgId, "userBaseId": request.UserBaseId})
  377 + if err != nil {
  378 + return struct{}{}, err
  379 + }
  380 + }
338 381
339 - var allDividends = &response{} 382 + queryOptions["cooperationContractNumbers"] = contractNumbers
  383 +
  384 + var allDividends = &CreditAccountStatisticsResponse{}
  385 + var annualDividends = &CreditAccountStatisticsResponse{}
  386 + var quarterDividends = &CreditAccountStatisticsResponse{}
  387 +
  388 + if len(contractNumbers) > 0 {
340 if err := creditAccountDao.DividendsStatistics(queryOptions, allDividends); err != nil { 389 if err := creditAccountDao.DividendsStatistics(queryOptions, allDividends); err != nil {
341 return nil, err 390 return nil, err
342 } 391 }
343 allDividends.Accounting = allDividends.Total - allDividends.Accounted 392 allDividends.Accounting = allDividends.Total - allDividends.Accounted
344 393
345 - var annualDividends = &response{}  
346 queryOptions["beginTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local) 394 queryOptions["beginTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local)
347 queryOptions["endTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local).AddDate(1, 0, 0) 395 queryOptions["endTime"] = time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.Local).AddDate(1, 0, 0)
348 if err := creditAccountDao.DividendsStatistics(queryOptions, annualDividends); err != nil { 396 if err := creditAccountDao.DividendsStatistics(queryOptions, annualDividends); err != nil {
@@ -350,12 +398,12 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st @@ -350,12 +398,12 @@ func (ptr *CooperationStatisticsService) DividendsStatistics(queryOptions map[st
350 } 398 }
351 annualDividends.Accounting = annualDividends.Total - annualDividends.Accounted 399 annualDividends.Accounting = annualDividends.Total - annualDividends.Accounted
352 400
353 - var quarterDividends = &response{}  
354 queryOptions["beginTime"], queryOptions["endTime"] = quarterBeginEnd() 401 queryOptions["beginTime"], queryOptions["endTime"] = quarterBeginEnd()
355 if err := creditAccountDao.DividendsStatistics(queryOptions, quarterDividends); err != nil { 402 if err := creditAccountDao.DividendsStatistics(queryOptions, quarterDividends); err != nil {
356 return nil, err 403 return nil, err
357 } 404 }
358 quarterDividends.Accounting = quarterDividends.Total - quarterDividends.Accounted 405 quarterDividends.Accounting = quarterDividends.Total - quarterDividends.Accounted
  406 + }
359 407
360 ret := map[string]interface{}{ 408 ret := map[string]interface{}{
361 "allDividends": allDividends, 409 "allDividends": allDividends,
@@ -395,6 +443,8 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m @@ -395,6 +443,8 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m
395 var request = struct { 443 var request = struct {
396 CompanyId int64 `json:"companyId"` 444 CompanyId int64 `json:"companyId"`
397 OrgId int64 `json:"orgId"` 445 OrgId int64 `json:"orgId"`
  446 + UserId int64 `json:"userId"`
  447 +
398 UserBaseId int64 `json:"userBaseId"` 448 UserBaseId int64 `json:"userBaseId"`
399 DividendsAccountStatus int32 `json:"dividendsAccountStatus"` // 分红结算状态 449 DividendsAccountStatus int32 `json:"dividendsAccountStatus"` // 分红结算状态
400 Offset int64 `json:"offset"` 450 Offset int64 `json:"offset"`
@@ -405,10 +455,18 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m @@ -405,10 +455,18 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m
405 } 455 }
406 queryOptions = tool_funs.SimpleStructToMap(&request) 456 queryOptions = tool_funs.SimpleStructToMap(&request)
407 457
408 - dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)  
409 - _, estimates, err := dividendsEstimateRepository.Find(queryOptions) 458 + var contractNumbers []string
  459 + var err error
  460 + if request.OrgId > 0 && request.UserId > 0 {
  461 + contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"orgId": request.OrgId, "userId": request.UserId})
410 if err != nil { 462 if err != nil {
411 - return nil, err 463 + return struct{}{}, err
  464 + }
  465 + } else if request.UserBaseId > 0 {
  466 + contractNumbers, err = ptr.getRelevantContracts(map[string]interface{}{"orgId": request.OrgId, "userBaseId": request.UserBaseId})
  467 + if err != nil {
  468 + return struct{}{}, err
  469 + }
412 } 470 }
413 type response struct { 471 type response struct {
414 // 承接人分红预算记录ID 472 // 承接人分红预算记录ID
@@ -429,6 +487,18 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m @@ -429,6 +487,18 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m
429 CustomerName string `json:"customerName"` 487 CustomerName string `json:"customerName"`
430 } 488 }
431 var results = make([]response, 0) 489 var results = make([]response, 0)
  490 + if len(contractNumbers) == 0 {
  491 + return results, nil
  492 + }
  493 +
  494 + queryOptions["cooperationContractNumbers"] = contractNumbers
  495 +
  496 + dividendsEstimateRepository, _ := repository.NewDividendsEstimateRepository(ptr.transactionContext)
  497 + _, estimates, err := dividendsEstimateRepository.Find(queryOptions)
  498 + if err != nil {
  499 + return nil, err
  500 + }
  501 +
432 dividendsOrderRepository, _ := repository.NewDividendsOrderRepository(ptr.transactionContext) 502 dividendsOrderRepository, _ := repository.NewDividendsOrderRepository(ptr.transactionContext)
433 dividendsReturnedOrderRepository, _ := repository.NewDividendsReturnedOrderRepository(ptr.transactionContext) 503 dividendsReturnedOrderRepository, _ := repository.NewDividendsReturnedOrderRepository(ptr.transactionContext)
434 for i := range estimates { 504 for i := range estimates {
@@ -441,8 +511,11 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m @@ -441,8 +511,11 @@ func (ptr *CooperationStatisticsService) SearchDividendsEstimates(queryOptions m
441 DividendsType: item.DividendsType, 511 DividendsType: item.DividendsType,
442 DividendsUser: item.DividendsUser, 512 DividendsUser: item.DividendsUser,
443 } 513 }
  514 + // TODO:优化查询 统一查询到map里面
444 if item.DividendsType == 1 { 515 if item.DividendsType == 1 {
445 - order, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": item.OrderOrReturnedOrderNum}) 516 + order, err := dividendsOrderRepository.FindOne(map[string]interface{}{
  517 + "dividendsOrderNumber": item.OrderOrReturnedOrderNum,
  518 + })
446 if err != nil { 519 if err != nil {
447 return nil, err 520 return nil, err
448 } 521 }
@@ -469,6 +542,8 @@ func (ptr *CooperationStatisticsService) CreditAccountStatistics(queryOptions ma @@ -469,6 +542,8 @@ func (ptr *CooperationStatisticsService) CreditAccountStatistics(queryOptions ma
469 UserBaseId int64 `json:"userBaseId"` 542 UserBaseId int64 `json:"userBaseId"`
470 BeginTime time.Time `json:"beginTime"` 543 BeginTime time.Time `json:"beginTime"`
471 EndTime time.Time `json:"endTime"` 544 EndTime time.Time `json:"endTime"`
  545 + // 合约编号列表
  546 + CooperationContractNumbers []string `json:"cooperationContractNumbers"`
472 }{} 547 }{}
473 if err := LoadQueryObject(queryOptions, &request); err != nil { 548 if err := LoadQueryObject(queryOptions, &request); err != nil {
474 return nil, err 549 return nil, err
@@ -490,4 +565,26 @@ type CreditAccountStatisticsResponse struct { @@ -490,4 +565,26 @@ type CreditAccountStatisticsResponse struct {
490 Accounting float64 `json:"accounting"` 565 Accounting float64 `json:"accounting"`
491 Accounted float64 `json:"accounted"` 566 Accounted float64 `json:"accounted"`
492 Paid float64 `json:"paid"` 567 Paid float64 `json:"paid"`
  568 + Unpaid float64 `json:"unpaid"`
  569 +}
  570 +
  571 +//getRelevantContracts 获取相关人的合约
  572 +func (ptr *CooperationStatisticsService) RelevantCooperationContractNumbers(queryOptions map[string]interface{}) (interface{}, error) {
  573 + var request = struct {
  574 + //企业
  575 + CompanyId int64 `json:"companyId" valid:"Required"`
  576 + OrgId int64 `json:"orgId" valid:"Required"`
  577 + UserId int64 `json:"userId" valid:"Required"`
  578 + //个人
  579 + //UserBaseId int64 `json:"userBaseId"`
  580 + //Offset int `json:"offset"`
  581 + //Limit int `json:"limit"`
  582 + }{}
  583 + if err := LoadQueryObject(queryOptions, &request); err != nil {
  584 + return nil, err
  585 + }
  586 + queryOptions = tool_funs.SimpleStructToMap(&request)
  587 +
  588 + contractNumbers, err := ptr.getRelevantContracts(queryOptions)
  589 + return contractNumbers, err
493 } 590 }
@@ -172,6 +172,33 @@ func (service *UserService) OperatorFrom(companyId int64, orgId int64, userId in @@ -172,6 +172,33 @@ func (service *UserService) OperatorFrom(companyId int64, orgId int64, userId in
172 } 172 }
173 } 173 }
174 174
  175 +// VisitorFrom 获取游客
  176 +func (service *UserService) VisitorFrom(companyId int64, orgId int64, userBaseId int64) (*domain.User, error) {
  177 + var returnData *domain.User
  178 + if userAdaptor, err := adaptor.NewUserAdaptor(); err != nil {
  179 + return nil, err
  180 + } else {
  181 + if visitor, err := userAdaptor.ToParticipator(companyId, orgId, userBaseId, "Visitor"); err != nil {
  182 + return nil, err
  183 + } else {
  184 + if visitor != nil {
  185 + log.Logger.Debug("游客", map[string]interface{}{
  186 + "visitor interface": visitor,
  187 + })
  188 + visitorJson, err1 := json.Marshal(visitor)
  189 + if err1 != nil {
  190 + return nil, err
  191 + }
  192 + err2 := json.Unmarshal(visitorJson, &returnData)
  193 + if err2 != nil {
  194 + return nil, err2
  195 + }
  196 + }
  197 + return returnData, nil
  198 + }
  199 + }
  200 +}
  201 +
175 func NewUserService() (*UserService, error) { 202 func NewUserService() (*UserService, error) {
176 return &UserService{}, nil 203 return &UserService{}, nil
177 } 204 }
@@ -17,6 +17,8 @@ type ContractUndertakerFeedback struct { @@ -17,6 +17,8 @@ type ContractUndertakerFeedback struct {
17 CooperationContractNumber string `comment:"共创合约编号"` 17 CooperationContractNumber string `comment:"共创合约编号"`
18 // 项目合约名称 18 // 项目合约名称
19 CooperationContractName string `comment:"项目合约名称"` 19 CooperationContractName string `comment:"项目合约名称"`
  20 + // 模式名称
  21 + CooperationModeName string `comment:"模式名称"`
20 // 共创合约承接人 22 // 共创合约承接人
21 ContractUndertaker *domain.Undertaker `comment:"共创合约承接人"` 23 ContractUndertaker *domain.Undertaker `comment:"共创合约承接人"`
22 // 数据所属组织机构 24 // 数据所属组织机构
@@ -29,8 +29,8 @@ type CooperationApplication struct { @@ -29,8 +29,8 @@ type CooperationApplication struct {
29 CooperationProjectNumber string `comment:"共创项目编号"` 29 CooperationProjectNumber string `comment:"共创项目编号"`
30 // 数据所属组织机构 30 // 数据所属组织机构
31 Org *domain.Org `comment:"数据所属组织机构"` 31 Org *domain.Org `comment:"数据所属组织机构"`
32 - // 是否被取消标志位  
33 - IsCanceled bool `comment:"是否被取消标志位"` 32 + // 是否被取消标志位 1正常,2取消
  33 + IsCanceled int32 `comment:"是否被取消标志位" pg:",default:1"`
34 // 公司 34 // 公司
35 Company *domain.Company `comment:"公司"` 35 Company *domain.Company `comment:"公司"`
36 // 创建时间 36 // 创建时间
@@ -25,7 +25,7 @@ type CooperationContractByUndertaker struct { @@ -25,7 +25,7 @@ type CooperationContractByUndertaker struct {
25 Department *domain.Department `comment:"共创合约发起部门"` 25 Department *domain.Department `comment:"共创合约发起部门"`
26 // 组织机构 26 // 组织机构
27 Org *domain.Org `comment:"组织机构"` 27 Org *domain.Org `comment:"组织机构"`
28 - // 共创合约状态 28 + // 共创合约状态 1正常,2关闭
29 ContractStatus int32 `comment:"共创合约状态"` 29 ContractStatus int32 `comment:"共创合约状态"`
30 // 共创模式名称 30 // 共创模式名称
31 CooperationModeName string `comment:"共创合约名称"` 31 CooperationModeName string `comment:"共创合约名称"`
@@ -10,7 +10,7 @@ type DividendsOrder struct { @@ -10,7 +10,7 @@ type DividendsOrder struct {
10 // 分红订单ID 10 // 分红订单ID
11 DividendsOrderId int64 `comment:"分红订单ID" pg:",pk"` 11 DividendsOrderId int64 `comment:"分红订单ID" pg:",pk"`
12 // 分红订单号 12 // 分红订单号
13 - DividendsOrderNumber string `comment:"分红订单号"` 13 + DividendsOrderNumber string `comment:"分红订单号" pg:",unique"`
14 // 分红订单原单号 14 // 分红订单原单号
15 DividendsOriginalOrderNum string `comment:"分红订单原单号"` 15 DividendsOriginalOrderNum string `comment:"分红订单原单号"`
16 // 分红订单金额 16 // 分红订单金额
@@ -13,7 +13,7 @@ type OrderGood struct { @@ -13,7 +13,7 @@ type OrderGood struct {
13 // 订单产品单价 13 // 订单产品单价
14 OrderGoodPrice float64 `comment:"订单产品单价"` 14 OrderGoodPrice float64 `comment:"订单产品单价"`
15 // 订单产品数量 15 // 订单产品数量
16 - OrderGoodQuantity int64 `comment:"订单产品数量"` 16 + OrderGoodQuantity float64 `comment:"订单产品数量"`
17 // 关联分红订单号 17 // 关联分红订单号
18 DividendsOrderNumber string `comment:"关联分红订单号"` 18 DividendsOrderNumber string `comment:"关联分红订单号"`
19 // 关联的分红退货单号 19 // 关联的分红退货单号
@@ -13,6 +13,7 @@ func TransformToContractUndertakerFeedbackDomainModelFromPgModels( @@ -13,6 +13,7 @@ func TransformToContractUndertakerFeedbackDomainModelFromPgModels(
13 FeedbackContent: contractUndertakerFeedbackModel.FeedbackContent, 13 FeedbackContent: contractUndertakerFeedbackModel.FeedbackContent,
14 CooperationContractNumber: contractUndertakerFeedbackModel.CooperationContractNumber, 14 CooperationContractNumber: contractUndertakerFeedbackModel.CooperationContractNumber,
15 CooperationContractName: contractUndertakerFeedbackModel.CooperationContractName, 15 CooperationContractName: contractUndertakerFeedbackModel.CooperationContractName,
  16 + CooperationModeName: contractUndertakerFeedbackModel.CooperationModeName,
16 ContractUndertaker: contractUndertakerFeedbackModel.ContractUndertaker, 17 ContractUndertaker: contractUndertakerFeedbackModel.ContractUndertaker,
17 Org: contractUndertakerFeedbackModel.Org, 18 Org: contractUndertakerFeedbackModel.Org,
18 Company: contractUndertakerFeedbackModel.Company, 19 Company: contractUndertakerFeedbackModel.Company,
1 package transform 1 package transform
2 2
3 import ( 3 import (
  4 + "github.com/shopspring/decimal"
4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
6 ) 7 )
@@ -8,9 +9,10 @@ import ( @@ -8,9 +9,10 @@ import (
8 func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *models.DividendsOrder, goods []*models.OrderGood) (*domain.DividendsOrder, error) { 9 func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *models.DividendsOrder, goods []*models.OrderGood) (*domain.DividendsOrder, error) {
9 var orderGoods []*domain.OrderGood 10 var orderGoods []*domain.OrderGood
10 for _, good := range goods { 11 for _, good := range goods {
  12 + orderGoodAmount, _ := decimal.NewFromFloatWithExponent(good.OrderGoodAmount, -2).Float64()
11 orderGoods = append(orderGoods, &domain.OrderGood{ 13 orderGoods = append(orderGoods, &domain.OrderGood{
12 OrderGoodId: good.OrderGoodId, 14 OrderGoodId: good.OrderGoodId,
13 - OrderGoodAmount: good.OrderGoodAmount, 15 + OrderGoodAmount: orderGoodAmount,
14 OrderGoodName: good.OrderGoodName, 16 OrderGoodName: good.OrderGoodName,
15 OrderGoodPrice: good.OrderGoodPrice, 17 OrderGoodPrice: good.OrderGoodPrice,
16 OrderGoodQuantity: good.OrderGoodQuantity, 18 OrderGoodQuantity: good.OrderGoodQuantity,
@@ -24,11 +26,12 @@ func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *model @@ -24,11 +26,12 @@ func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *model
24 UpdatedAt: good.UpdatedAt, 26 UpdatedAt: good.UpdatedAt,
25 }) 27 })
26 } 28 }
  29 + dividendsOrderAmount, _ := decimal.NewFromFloatWithExponent(dividendsOrderModel.DividendsOrderAmount, -2).Float64()
27 return &domain.DividendsOrder{ 30 return &domain.DividendsOrder{
28 DividendsOrderId: dividendsOrderModel.DividendsOrderId, 31 DividendsOrderId: dividendsOrderModel.DividendsOrderId,
29 DividendsOrderNumber: dividendsOrderModel.DividendsOrderNumber, 32 DividendsOrderNumber: dividendsOrderModel.DividendsOrderNumber,
30 DividendsOriginalOrderNum: dividendsOrderModel.DividendsOriginalOrderNum, 33 DividendsOriginalOrderNum: dividendsOrderModel.DividendsOriginalOrderNum,
31 - DividendsOrderAmount: dividendsOrderModel.DividendsOrderAmount, 34 + DividendsOrderAmount: dividendsOrderAmount,
32 OrderTime: dividendsOrderModel.OrderTime, 35 OrderTime: dividendsOrderModel.OrderTime,
33 DividendTime: dividendsOrderModel.DividendTime, 36 DividendTime: dividendsOrderModel.DividendTime,
34 DividendStatus: dividendsOrderModel.DividendStatus, 37 DividendStatus: dividendsOrderModel.DividendStatus,
1 package transform 1 package transform
2 2
3 import ( 3 import (
  4 + "github.com/shopspring/decimal"
4 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
5 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" 6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models"
6 ) 7 )
@@ -10,9 +11,10 @@ func TransformToDividendsReturnedOrderDomainModelFromPgModels( @@ -10,9 +11,10 @@ func TransformToDividendsReturnedOrderDomainModelFromPgModels(
10 goods []*models.OrderGood) (*domain.DividendsReturnedOrder, error) { 11 goods []*models.OrderGood) (*domain.DividendsReturnedOrder, error) {
11 var orderGoods []*domain.OrderGood 12 var orderGoods []*domain.OrderGood
12 for _, good := range goods { 13 for _, good := range goods {
  14 + orderGoodAmount, _ := decimal.NewFromFloatWithExponent(good.OrderGoodAmount, -2).Float64()
13 orderGoods = append(orderGoods, &domain.OrderGood{ 15 orderGoods = append(orderGoods, &domain.OrderGood{
14 OrderGoodId: good.OrderGoodId, 16 OrderGoodId: good.OrderGoodId,
15 - OrderGoodAmount: good.OrderGoodAmount, 17 + OrderGoodAmount: orderGoodAmount,
16 OrderGoodName: good.OrderGoodName, 18 OrderGoodName: good.OrderGoodName,
17 OrderGoodPrice: good.OrderGoodPrice, 19 OrderGoodPrice: good.OrderGoodPrice,
18 OrderGoodQuantity: good.OrderGoodQuantity, 20 OrderGoodQuantity: good.OrderGoodQuantity,
@@ -26,10 +28,11 @@ func TransformToDividendsReturnedOrderDomainModelFromPgModels( @@ -26,10 +28,11 @@ func TransformToDividendsReturnedOrderDomainModelFromPgModels(
26 UpdatedAt: good.UpdatedAt, 28 UpdatedAt: good.UpdatedAt,
27 }) 29 })
28 } 30 }
  31 + dividendsReturnedOrderRefund, _ := decimal.NewFromFloatWithExponent(dividendsReturnedOrderModel.DividendsReturnedOrderRefund, -2).Float64()
29 return &domain.DividendsReturnedOrder{ 32 return &domain.DividendsReturnedOrder{
30 DividendsReturnedOrderId: dividendsReturnedOrderModel.DividendsReturnedOrderId, 33 DividendsReturnedOrderId: dividendsReturnedOrderModel.DividendsReturnedOrderId,
31 DividendsReturnedOrderNumber: dividendsReturnedOrderModel.DividendsReturnedOrderNumber, 34 DividendsReturnedOrderNumber: dividendsReturnedOrderModel.DividendsReturnedOrderNumber,
32 - DividendsReturnedOrderRefund: dividendsReturnedOrderModel.DividendsReturnedOrderRefund, 35 + DividendsReturnedOrderRefund: dividendsReturnedOrderRefund,
33 OriginalOrderNum: dividendsReturnedOrderModel.OriginalOrderNum, 36 OriginalOrderNum: dividendsReturnedOrderModel.OriginalOrderNum,
34 DividendsOrderNumber: dividendsReturnedOrderModel.DividendsOrderNumber, 37 DividendsOrderNumber: dividendsReturnedOrderModel.DividendsOrderNumber,
35 DividendsReturnedCustomerName: dividendsReturnedOrderModel.DividendsReturnedCustomerName, 38 DividendsReturnedCustomerName: dividendsReturnedOrderModel.DividendsReturnedCustomerName,
@@ -15,14 +15,11 @@ import ( @@ -15,14 +15,11 @@ import (
15 15
16 type ContractUndertakerFeedbackRepository struct { 16 type ContractUndertakerFeedbackRepository struct {
17 transactionContext *pgTransaction.TransactionContext 17 transactionContext *pgTransaction.TransactionContext
  18 + IdWorker *snowflake.IdWorker
18 } 19 }
19 20
20 func (repository *ContractUndertakerFeedbackRepository) nextIdentify() (int64, error) { 21 func (repository *ContractUndertakerFeedbackRepository) nextIdentify() (int64, error) {
21 - IdWorker, err := snowflake.NewIdWorker(1)  
22 - if err != nil {  
23 - return 0, err  
24 - }  
25 - id, err := IdWorker.NextId() 22 + id, err := repository.IdWorker.NextId()
26 return id, err 23 return id, err
27 } 24 }
28 25
@@ -33,6 +30,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF @@ -33,6 +30,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
33 "feedback_content", 30 "feedback_content",
34 "cooperation_contract_number", 31 "cooperation_contract_number",
35 "cooperation_contract_name", 32 "cooperation_contract_name",
  33 + "cooperation_mode_name",
36 "contract_undertaker", 34 "contract_undertaker",
37 "org", 35 "org",
38 "company", 36 "company",
@@ -60,6 +58,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF @@ -60,6 +58,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
60 &contractUndertakerFeedback.FeedbackContent, 58 &contractUndertakerFeedback.FeedbackContent,
61 &contractUndertakerFeedback.CooperationContractNumber, 59 &contractUndertakerFeedback.CooperationContractNumber,
62 &contractUndertakerFeedback.CooperationContractName, 60 &contractUndertakerFeedback.CooperationContractName,
  61 + &contractUndertakerFeedback.CooperationModeName,
63 &contractUndertakerFeedback.ContractUndertaker, 62 &contractUndertakerFeedback.ContractUndertaker,
64 &contractUndertakerFeedback.Org, 63 &contractUndertakerFeedback.Org,
65 &contractUndertakerFeedback.Company, 64 &contractUndertakerFeedback.Company,
@@ -73,6 +72,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF @@ -73,6 +72,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
73 contractUndertakerFeedback.FeedbackContent, 72 contractUndertakerFeedback.FeedbackContent,
74 contractUndertakerFeedback.CooperationContractNumber, 73 contractUndertakerFeedback.CooperationContractNumber,
75 contractUndertakerFeedback.CooperationContractName, 74 contractUndertakerFeedback.CooperationContractName,
  75 + contractUndertakerFeedback.CooperationModeName,
76 contractUndertakerFeedback.ContractUndertaker, 76 contractUndertakerFeedback.ContractUndertaker,
77 contractUndertakerFeedback.Org, 77 contractUndertakerFeedback.Org,
78 contractUndertakerFeedback.Company, 78 contractUndertakerFeedback.Company,
@@ -90,6 +90,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF @@ -90,6 +90,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
90 &contractUndertakerFeedback.FeedbackContent, 90 &contractUndertakerFeedback.FeedbackContent,
91 &contractUndertakerFeedback.CooperationContractNumber, 91 &contractUndertakerFeedback.CooperationContractNumber,
92 &contractUndertakerFeedback.CooperationContractName, 92 &contractUndertakerFeedback.CooperationContractName,
  93 + &contractUndertakerFeedback.CooperationModeName,
93 &contractUndertakerFeedback.ContractUndertaker, 94 &contractUndertakerFeedback.ContractUndertaker,
94 &contractUndertakerFeedback.Org, 95 &contractUndertakerFeedback.Org,
95 &contractUndertakerFeedback.Company, 96 &contractUndertakerFeedback.Company,
@@ -103,6 +104,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF @@ -103,6 +104,7 @@ func (repository *ContractUndertakerFeedbackRepository) Save(contractUndertakerF
103 contractUndertakerFeedback.FeedbackContent, 104 contractUndertakerFeedback.FeedbackContent,
104 contractUndertakerFeedback.CooperationContractNumber, 105 contractUndertakerFeedback.CooperationContractNumber,
105 contractUndertakerFeedback.CooperationContractName, 106 contractUndertakerFeedback.CooperationContractName,
  107 + contractUndertakerFeedback.CooperationModeName,
106 contractUndertakerFeedback.ContractUndertaker, 108 contractUndertakerFeedback.ContractUndertaker,
107 contractUndertakerFeedback.Org, 109 contractUndertakerFeedback.Org,
108 contractUndertakerFeedback.Company, 110 contractUndertakerFeedback.Company,
@@ -134,7 +136,7 @@ func (repository *ContractUndertakerFeedbackRepository) FindOne(queryOptions map @@ -134,7 +136,7 @@ func (repository *ContractUndertakerFeedbackRepository) FindOne(queryOptions map
134 query.SetWhereByQueryOption("contract_undertaker_feedback.feedback_id = ?", "contractUndertakerFeedbackId") 136 query.SetWhereByQueryOption("contract_undertaker_feedback.feedback_id = ?", "contractUndertakerFeedbackId")
135 if err := query.First(); err != nil { 137 if err := query.First(); err != nil {
136 if err.Error() == "pg: no rows in result set" { 138 if err.Error() == "pg: no rows in result set" {
137 - return nil, fmt.Errorf("没有此资源") 139 + return nil, fmt.Errorf("承接人反馈信息不存在")
138 } else { 140 } else {
139 return nil, err 141 return nil, err
140 } 142 }
@@ -202,8 +204,13 @@ func NewContractUndertakerFeedbackRepository(transactionContext *pgTransaction.T @@ -202,8 +204,13 @@ func NewContractUndertakerFeedbackRepository(transactionContext *pgTransaction.T
202 if transactionContext == nil { 204 if transactionContext == nil {
203 return nil, fmt.Errorf("transactionContext参数不能为nil") 205 return nil, fmt.Errorf("transactionContext参数不能为nil")
204 } else { 206 } else {
  207 + idWorker, err := snowflake.NewIdWorker(1)
  208 + if err != nil {
  209 + return nil, err
  210 + }
205 return &ContractUndertakerFeedbackRepository{ 211 return &ContractUndertakerFeedbackRepository{
206 transactionContext: transactionContext, 212 transactionContext: transactionContext,
  213 + IdWorker: idWorker,
207 }, nil 214 }, nil
208 } 215 }
209 } 216 }