作者 陈志颖

合并分支 'test' 到 'master'

Test



查看合并请求 !62
@@ -24,3 +24,4 @@ @@ -24,3 +24,4 @@
24 opp 24 opp
25 /vendor 25 /vendor
26 /*.exe~ 26 /*.exe~
  27 +logs
@@ -11,5 +11,25 @@ ENV GO111MODULE on @@ -11,5 +11,25 @@ ENV GO111MODULE on
11 ENV GOPROXY https://goproxy.cn,direct 11 ENV GOPROXY https://goproxy.cn,direct
12 RUN ["go","mod","tidy"] 12 RUN ["go","mod","tidy"]
13 RUN ["go","build"] 13 RUN ["go","build"]
14 -EXPOSE 8082  
15 -ENTRYPOINT ["./partner"]  
  14 +EXPOSE 8082 443
  15 +ENTRYPOINT ["./partner"]
  16 +
  17 +#############################
  18 +## STEP 1 build executable binary
  19 +#############################
  20 +#FROM golang:alpine AS builder
  21 +#
  22 +#RUN mkdir /app
  23 +#WORKDIR /app
  24 +#COPY . /app
  25 +#RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
  26 +##RUN GO111MODULE="on" GOPROXY="https://goproxy.cn" GOFLAGS="-mod=vendor" CGO_ENABLED=0 GOOS=linux go build -o partner
  27 +#RUN GO111MODULE="on" GOPROXY="https://goproxy.cn" CGO_ENABLED=0 GOOS=linux go build -o partner
  28 +#
  29 +#############################
  30 +## STEP 2 build a small image
  31 +############################
  32 +#FROM scratch as final
  33 +#COPY --from=builder /app/partner /app/partner
  34 +#COPY --from=builder /app/conf/ /app/conf
  35 +#ENTRYPOINT ["./app/partner"]
@@ -2,6 +2,12 @@ appname = partner @@ -2,6 +2,12 @@ appname = partner
2 runmode = "${RUN_MODE||dev}" 2 runmode = "${RUN_MODE||dev}"
3 httpport = "${HTTP_PORT||8082}" 3 httpport = "${HTTP_PORT||8082}"
4 4
  5 +#开启https
  6 +EnableHTTPS = true
  7 +HTTPSPort = "443"
  8 +HTTPSCertFile = "conf/fjmaimaimai.com_pem.crt"
  9 +HTTPSKeyFile = "conf/fjmaimaimai.com_rsa.key"
  10 +
5 #开启监控 11 #开启监控
6 EnableAdmin = false 12 EnableAdmin = false
7 #开启JSON请求 13 #开启JSON请求
  1 +-----BEGIN CERTIFICATE-----
  2 +MIIGWjCCBUKgAwIBAgIQBKNf6ftifrIH+BeJ7V4uqjANBgkqhkiG9w0BAQsFADBf
  3 +MQswCQYDVQQGEwJVUzEVMBMGA1UEChMMRGlnaUNlcnQgSW5jMRkwFwYDVQQLExB3
  4 +d3cuZGlnaWNlcnQuY29tMR4wHAYDVQQDExVHZW9UcnVzdCBDTiBSU0EgQ0EgRzEw
  5 +HhcNMjEwMTA2MDAwMDAwWhcNMjIwMjA2MjM1OTU5WjCBgzELMAkGA1UEBhMCQ04x
  6 +EjAQBgNVBAgMCeemj+W7uuecgTESMBAGA1UEBwwJ56aP5bee5biCMTAwLgYDVQQK
  7 +DCfnpo/lu7rkubDkubDkubDkv6Hmga/np5HmioDmnInpmZDlhazlj7gxGjAYBgNV
  8 +BAMMESouZmptYWltYWltYWkuY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB
  9 +CgKCAQEAv1KDwfoVuXyMSNUvLapWLpyWdQd8Dy4l5Wmdiydof4+ijqCfgPgMOZGS
  10 +7ucvis1ZUZLYDKbZq8xODVEWlXf/n6sMXkq0B+eltlYqyPOZyaBUkg2qqz/iKljb
  11 +1pGE5q7gfQ5nQoEW8J/DZUlKs+7jg9O0y2S0jVj3s7QlFy6Alw9BE/7ChOxqfegN
  12 +Ua0UL8W6rFqK32eyvZUeecvtKoZwJ3YD2ayXJIN70OivjkcWLskmf6+CjalitqQs
  13 +JZ7xD6/WtrpunTCpOVNqhR81sCOT+xxDwNppDqiMNo3lFL6TeQSWT19RBllkiWdW
  14 +XXfWS7CsIrqp8i/7fjt66VmVqZnPDwIDAQABo4IC6zCCAucwHwYDVR0jBBgwFoAU
  15 +kZ9eMRWuEJ+tYMH3wcyqSDQvDCYwHQYDVR0OBBYEFEhZyphSt/IUiLKJLr78T+7j
  16 +l7tmMC0GA1UdEQQmMCSCESouZmptYWltYWltYWkuY29tgg9mam1haW1haW1haS5j
  17 +b20wDgYDVR0PAQH/BAQDAgWgMB0GA1UdJQQWMBQGCCsGAQUFBwMBBggrBgEFBQcD
  18 +AjB1BgNVHR8EbjBsMDSgMqAwhi5odHRwOi8vY3JsMy5kaWdpY2VydC5jb20vR2Vv
  19 +VHJ1c3RDTlJTQUNBRzEuY3JsMDSgMqAwhi5odHRwOi8vY3JsNC5kaWdpY2VydC5j
  20 +b20vR2VvVHJ1c3RDTlJTQUNBRzEuY3JsMEsGA1UdIAREMEIwNgYJYIZIAYb9bAEB
  21 +MCkwJwYIKwYBBQUHAgEWG2h0dHA6Ly93d3cuZGlnaWNlcnQuY29tL0NQUzAIBgZn
  22 +gQwBAgIwbwYIKwYBBQUHAQEEYzBhMCEGCCsGAQUFBzABhhVodHRwOi8vb2NzcC5k
  23 +Y29jc3AuY24wPAYIKwYBBQUHMAKGMGh0dHA6Ly9jcmwuZGlnaWNlcnQtY24uY29t
  24 +L0dlb1RydXN0Q05SU0FDQUcxLmNydDAMBgNVHRMBAf8EAjAAMIIBAgYKKwYBBAHW
  25 +eQIEAgSB8wSB8ADuAHUAKXm+8J45OSHwVnOfY6V35b5XfZxgCvj5TV0mXCVdx4QA
  26 +AAF21tCFyQAABAMARjBEAiAPHS8Wp3c0J7d5By9NQM3/tyf7/B0H7JZLJ+IlcoCG
  27 +IwIgR1+Mj5Q6nhWdqV5s9WLgSUvhpJJxvFrJOzV6zkfXZEwAdQAiRUUHWVUkVpY/
  28 +oS/x922G4CMmY63AS39dxoNcbuIPAgAAAXbW0IYsAAAEAwBGMEQCIBbGUD0dLyIT
  29 +O+KzBtFPQjiRUbcjGZsbY0gWmVzZfBPrAiAa2X20smzJK42hcMenaVrUgxC/y/j0
  30 +bYYfKRrfwEsoWDANBgkqhkiG9w0BAQsFAAOCAQEAU4aHqNW/qgzRUwBv3C9E70r/
  31 +/LMy3asBePsBARZlzd3tXrr446lsX3HKmAH4AtLACjwPv3ejsEJueeQxrwMxalW+
  32 +2ZerAJhzYqD0OovwcB2b6cDB5zWAuyllFo6ILI3KSQjzFmi4Vn993pN2b2OEUkwC
  33 +REYvMVf2BzHjVFuCiXtUWgOucsCb4ES+yWjCrw93VafyhhGCbXVXd55GNbZFE+kw
  34 +JArAwYPKwabuFYFfeSVWcRvaV+Kbo88ytPo5ZpShSOBFCPQ1JQ/BxWEmzHXQIzcz
  35 +uqELYfxmxI3q6plbgHtL1rY2B8YTWcxXF98fIfg5OKYssOV4LGcoOWPf0PUPrg==
  36 +-----END CERTIFICATE-----
  1 +-----BEGIN RSA PRIVATE KEY-----
  2 +MIIEpQIBAAKCAQEAv1KDwfoVuXyMSNUvLapWLpyWdQd8Dy4l5Wmdiydof4+ijqCf
  3 +gPgMOZGS7ucvis1ZUZLYDKbZq8xODVEWlXf/n6sMXkq0B+eltlYqyPOZyaBUkg2q
  4 +qz/iKljb1pGE5q7gfQ5nQoEW8J/DZUlKs+7jg9O0y2S0jVj3s7QlFy6Alw9BE/7C
  5 +hOxqfegNUa0UL8W6rFqK32eyvZUeecvtKoZwJ3YD2ayXJIN70OivjkcWLskmf6+C
  6 +jalitqQsJZ7xD6/WtrpunTCpOVNqhR81sCOT+xxDwNppDqiMNo3lFL6TeQSWT19R
  7 +BllkiWdWXXfWS7CsIrqp8i/7fjt66VmVqZnPDwIDAQABAoIBAHN3mF980Jm2ym+2
  8 +ghe8YvEUvlV5I+2Be4uel1+BdDbweDo+RKWwjqg77ILU8kOCNbLevhe8p0hhMIYm
  9 +90tUNemmcPuDeG4A52lJTd8j7h/a7M+NAgECuDu4j01LW/thdcjj5XwkrrSgp2u8
  10 +tSItPhC0t7u9Vp6sICrLwUrhXOhNV+qdm94VhabJFGkdR9iUYw7W7w54Z1p+Nfw8
  11 +PJdDJfwu0lr8DFB2Zw+Ota8Xg+PX71x4mWS1g+h/6xz2ivptFcKPcwd60EjB+ROi
  12 +IQC8pnUmbF0H0epoVisB3SWEMzuShmAZrckBW+0ILDUUmNzcZxcWrmzIpomCdkOv
  13 +Trtrd/ECgYEA6v37SfsSKohPncHIYfV3FE7Xt7WH09TFymAY8FXIY+K6xvX9wtWB
  14 +h+3quFWuh0VTp15m6xAF1UN6HOG0uRKwUGFqwYBy4I+88KCUO3BJzbWn2TOjt4xE
  15 +8KVwGmZafqxPjwLagCN3RBLNYF4S+jhygBIlSzHkuVkwZPGbVet7NWkCgYEA0G0b
  16 +uDPJl37gEfvhMebdTWUq+FuAVx7h7UjZQM6BNoE3cDdZHUY7pMTqqD2UDbp6O6dC
  17 +0b8Hhs8kx90DewdixSzli67jNVeTRFY3DZ85Ac/BmGyuusNm6Uwbsz4RYsyUSrRD
  18 +bukC/L1vFjB5k/UgGh0kKnBT74mO/kqASWUIebcCgYEAiShtP6UX2VNuhPnSZ7rK
  19 +IkRSjJucB/ws5g5o//5R1FtGAVMbJllQHXK0iZsZH0NLrGjhUVoszWlxIOJshYlu
  20 +97ukgATlCEVdVmWjn33O1g6tRY1qhXuN0Zf+cqpDL6SLW0GjHx+UQVtoHFNMaFgC
  21 +HNZ6hgU9JyHzqTeMHv4vD+ECgYEAhk2oTPvh7OLuk+gQZk1zUMnd9IdRndHilzoX
  22 +9DCdBnghNwgTPk/hYv0YkCyN2ILO/N18qxdDTFTySG9cLMzHknKpv2aENf0mgiRj
  23 ++T0eSNKM1yFBPktnZvGJ7+gQ3+8fpzudMDyplh6jFFNMJFERzIH2qfoTvAiRwb5U
  24 +B/c4jOUCgYEAiQOXabnrnOvkfhl/RhH/WVeLs6O3c5yei0THysGc+9CqE8txnWPN
  25 +A4XI8Tu8G2ScBN+v9oPFWlLAZxbxh1m6RM6VwP4q+Y8fmdQ+d6gH/IKTdBjH7bOt
  26 +4SHS+t8Z6PSu8K1BsF3pGRS7OWPlivSJzRyP2YIgE/xtwsEqiODdRKM=
  27 +-----END RSA PRIVATE KEY-----
@@ -10,6 +10,9 @@ spec: @@ -10,6 +10,9 @@ spec:
10 - name: "http" 10 - name: "http"
11 port: 80 11 port: 80
12 targetPort: 8082 12 targetPort: 8082
  13 + - name: "https"
  14 + port: 443
  15 + targetPort: 443
13 selector: 16 selector:
14 k8s-app: mmmpartner 17 k8s-app: mmmpartner
15 --- 18 ---
@@ -48,9 +51,10 @@ spec: @@ -48,9 +51,10 @@ spec:
48 imagePullPolicy: Always 51 imagePullPolicy: Always
49 ports: 52 ports:
50 - containerPort: 8082 53 - containerPort: 8082
51 - volumeMounts:  
52 - - mountPath: /opt/logs  
53 - name: accesslogs 54 + - containerPort: 443
  55 +# volumeMounts:
  56 +# - mountPath: /opt/logs
  57 +# name: accesslogs
54 env: 58 env:
55 - name: HTTP_PORT 59 - name: HTTP_PORT
56 value: "8082" 60 value: "8082"
@@ -97,6 +101,6 @@ spec: @@ -97,6 +101,6 @@ spec:
97 key: redis.port 101 key: redis.port
98 - name: REDIS_AUTH 102 - name: REDIS_AUTH
99 value: "" 103 value: ""
100 - volumes:  
101 - - name: accesslogs  
102 - emptyDir: {}  
  104 +# volumes:
  105 +# - name: accesslogs
  106 +# emptyDir: {}
@@ -10,6 +10,9 @@ spec: @@ -10,6 +10,9 @@ spec:
10 - name: "http" 10 - name: "http"
11 port: 80 11 port: 80
12 targetPort: 8082 12 targetPort: 8082
  13 + - name: "https"
  14 + port: 443
  15 + targetPort: 443
13 selector: 16 selector:
14 k8s-app: mmmpartner 17 k8s-app: mmmpartner
15 --- 18 ---
@@ -48,6 +51,7 @@ spec: @@ -48,6 +51,7 @@ spec:
48 imagePullPolicy: Always 51 imagePullPolicy: Always
49 ports: 52 ports:
50 - containerPort: 8082 53 - containerPort: 8082
  54 + - containerPort: 443
51 volumeMounts: 55 volumeMounts:
52 - mountPath: /opt/logs 56 - mountPath: /opt/logs
53 name: accesslogs 57 name: accesslogs
@@ -10,6 +10,9 @@ spec: @@ -10,6 +10,9 @@ spec:
10 - name: "http" 10 - name: "http"
11 port: 80 11 port: 80
12 targetPort: 8082 12 targetPort: 8082
  13 + - name: "https"
  14 + port: 443
  15 + targetPort: 443
13 selector: 16 selector:
14 k8s-app: mmmpartner 17 k8s-app: mmmpartner
15 --- 18 ---
@@ -48,9 +51,10 @@ spec: @@ -48,9 +51,10 @@ spec:
48 imagePullPolicy: Always 51 imagePullPolicy: Always
49 ports: 52 ports:
50 - containerPort: 8082 53 - containerPort: 8082
51 - volumeMounts:  
52 - - mountPath: /opt/logs  
53 - name: accesslogs 54 + - containerPort: 443
  55 +# volumeMounts:
  56 +# - mountPath: /opt/logs
  57 +# name: accesslogs
54 env: 58 env:
55 - name: HTTP_PORT 59 - name: HTTP_PORT
56 value: "8082" 60 value: "8082"
@@ -97,6 +101,6 @@ spec: @@ -97,6 +101,6 @@ spec:
97 key: redis.port 101 key: redis.port
98 - name: REDIS_AUTH 102 - name: REDIS_AUTH
99 value: "" 103 value: ""
100 - volumes:  
101 - - name: accesslogs  
102 - emptyDir: {}  
  104 +# volumes:
  105 +# - name: accesslogs
  106 +# emptyDir: {}
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: companyId
  5 + description: 公司id
  6 + type:
  7 + primitive: int64
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: deliveryCode
  5 + description: 交货编号
  6 + type:
  7 + primitive: string
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: orderCode
  5 + description: 订单编号
  6 + type:
  7 + primitive: string
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: orderId
  5 + description: 订单编号
  6 + type:
  7 + primitive: int64
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: orderType
  5 + description: 公司id
  6 + type:
  7 + primitive: int
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: partnerId
  5 + description: 订单对应的合伙人
  6 + type:
  7 + primitive: int64
  1 +version: v1
  2 +kind: Attribute
  3 +metadata:
  4 + name: salesmanBonusPercent
  5 + description: 业务员抽成比例
  6 + type:
  7 + primitive: float64
  1 +version: v1
  2 +kind: Project
  3 +metadata:
  4 + name: partner
  5 + description: 合伙人
  6 + version: 0.8.0
  7 + repository: gitlab.fjmaimaimai.com/mmm-go/partner
  8 + contact:
  9 + name: SteveChan
  10 + email: steve.d.chan@qq.com
不能预览此文件类型
@@ -381,7 +381,7 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -381,7 +381,7 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
381 381
382 // 通过密码或校验码登录的普通用户或通过校验码登录的游客,注册一个账号到配置的公司去 382 // 通过密码或校验码登录的普通用户或通过校验码登录的游客,注册一个账号到配置的公司去
383 if request.GrantType == protocol.LoginBySmsCode || request.GrantType == protocol.LoginByPassword { 383 if request.GrantType == protocol.LoginBySmsCode || request.GrantType == protocol.LoginByPassword {
384 - userErr := loginSvr.RegistryUser(request.Phone) 384 + userErr := loginSvr.RegistryGuest(request.Phone)
385 if userErr != nil { 385 if userErr != nil {
386 log.Error(userErr) 386 log.Error(userErr)
387 } 387 }
@@ -403,25 +403,30 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom @@ -403,25 +403,30 @@ func CompaniesLogin(header *protocol.RequestHeader, request *protocolx.CenterCom
403 return 403 return
404 } 404 }
405 405
406 - manageLoginErr := loginSvr.ManagerLogin(request.Phone, request.Password)  
407 - fmt.Print("用户登录:", manageLoginErr, "\n")  
408 - partnerLoginErr := loginSvr.PartnerLogin(request.Phone, request.Password)  
409 - fmt.Print("合伙人登录:", partnerLoginErr, "\n") 406 + //manageLoginErr := loginSvr.ManagerLogin(request.Phone, request.Password)
  407 + //fmt.Print("用户登录:", manageLoginErr, "\n")
  408 + //partnerLoginErr := loginSvr.PartnerLogin(request.Phone, request.Password)
  409 + //fmt.Print("合伙人登录:", partnerLoginErr, "\n")
  410 + //
  411 + //if manageLoginErr != nil && partnerLoginErr != nil {
  412 + // //if len(loginSvr.PartnerInfo) == 0 { // 不存在有效用户
  413 + // // err = protocol.NewErrWithMessage(10008)
  414 + // // return
  415 + // //}
  416 + // err = protocol.NewCustomMessage(1, "密码输入有误!")
  417 + // return
  418 + //} else if manageLoginErr != nil && partnerLoginErr == nil {
  419 + // if len(loginSvr.PartnerInfo) == 1 && len(loginSvr.NormalUsers) == 0 {
  420 + // if loginSvr.PartnerInfo[0].CompanyId == int64(constant.DEFAULT_GUEST_COMPANY) {
  421 + // err = protocol.NewCustomMessage(1, "密码输入有误!")
  422 + // return
  423 + // }
  424 + // }
  425 + //}
410 426
411 - if manageLoginErr != nil && partnerLoginErr != nil {  
412 - if len(loginSvr.PartnerInfo) == 0 { // 不存在有效用户  
413 - err = protocol.NewErrWithMessage(10008)  
414 - return  
415 - } 427 + if loginSvr.ManagerLogin(request.Phone, request.Password) != nil && loginSvr.PartnerLogin(request.Phone, request.Password) != nil {
416 err = protocol.NewCustomMessage(1, "密码输入有误!") 428 err = protocol.NewCustomMessage(1, "密码输入有误!")
417 return 429 return
418 - } else if manageLoginErr != nil && partnerLoginErr == nil {  
419 - if len(loginSvr.PartnerInfo) == 1 && len(loginSvr.NormalUsers) == 0 {  
420 - if loginSvr.PartnerInfo[0].CompanyId == int64(constant.DEFAULT_GUEST_COMPANY) {  
421 - err = protocol.NewCustomMessage(1, "密码输入有误!")  
422 - return  
423 - }  
424 - }  
425 } 430 }
426 break 431 break
427 case protocol.LoginBySmsCode: 432 case protocol.LoginBySmsCode:
@@ -146,7 +146,13 @@ func getJoinWays(transactionContext *transaction.TransactionContext) (joinWays [ @@ -146,7 +146,13 @@ func getJoinWays(transactionContext *transaction.TransactionContext) (joinWays [
146 return 146 return
147 } 147 }
148 148
149 -// 获取公司统计 149 +/**
  150 + * @Author SteveChan
  151 + * @Description //TODO 获取公司统计,增加销售日期限制
  152 + * @Date 02:45 2021/2/3
  153 + * @Param
  154 + * @return
  155 + **/
150 func getStatistics(userId int64, transactionContext *transaction.TransactionContext) (interface{}, error) { 156 func getStatistics(userId int64, transactionContext *transaction.TransactionContext) (interface{}, error) {
151 var ( 157 var (
152 UsersRepository, _ = factory.CreateUsersRepository(transactionContext) 158 UsersRepository, _ = factory.CreateUsersRepository(transactionContext)
@@ -174,19 +180,19 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont @@ -174,19 +180,19 @@ func getStatistics(userId int64, transactionContext *transaction.TransactionCont
174 if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.App}); e == nil { 180 if count, e := PartnerInfoDao.PartnerStatic(map[string]interface{}{"inPartnerIds": partnerIds, "inPartnerCategory": domain.App}); e == nil {
175 Statistics["appCount"] = count 181 Statistics["appCount"] = count
176 } 182 }
177 - if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Career}); e == nil { 183 + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Career, EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
178 Statistics["careerOrdersMoney"] = bonus.TotalOrderAmount 184 Statistics["careerOrdersMoney"] = bonus.TotalOrderAmount
179 Statistics["careerDividend"] = bonus.Bonus 185 Statistics["careerDividend"] = bonus.Bonus
180 } 186 }
181 - if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Business}); e == nil { 187 + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Business, EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
182 Statistics["businessOrdersMoney"] = bonus.TotalOrderAmount 188 Statistics["businessOrdersMoney"] = bonus.TotalOrderAmount
183 Statistics["businessDividend"] = bonus.Bonus 189 Statistics["businessDividend"] = bonus.Bonus
184 } 190 }
185 - if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Develop}); e == nil { 191 + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.Develop, EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
186 Statistics["developOrdersMoney"] = bonus.TotalOrderAmount 192 Statistics["developOrdersMoney"] = bonus.TotalOrderAmount
187 Statistics["developDividend"] = bonus.Bonus 193 Statistics["developDividend"] = bonus.Bonus
188 } 194 }
189 - if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.App}); e == nil { 195 + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: partnerIds, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: domain.App, EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
190 Statistics["appOrdersMoney"] = bonus.TotalOrderAmount 196 Statistics["appOrdersMoney"] = bonus.TotalOrderAmount
191 Statistics["appDividend"] = bonus.Bonus 197 Statistics["appDividend"] = bonus.Bonus
192 } 198 }
@@ -261,6 +267,10 @@ func newQueryOption(request *protocolx.PartnersRequest) map[string]interface{} { @@ -261,6 +267,10 @@ func newQueryOption(request *protocolx.PartnersRequest) map[string]interface{} {
261 queryOption["startTime"] = request.StartTime / 1000 267 queryOption["startTime"] = request.StartTime / 1000
262 } 268 }
263 if request.EndTime > 0 { 269 if request.EndTime > 0 {
  270 + currentDayEnd := utils.GetDayEnd().Unix() * 1000
  271 + if request.EndTime >= currentDayEnd {
  272 + request.EndTime = currentDayEnd
  273 + }
264 queryOption["endTime"] = request.EndTime / 1000 274 queryOption["endTime"] = request.EndTime / 1000
265 } 275 }
266 queryOption["limit"] = request.PageSize 276 queryOption["limit"] = request.PageSize
@@ -9,6 +9,7 @@ import ( @@ -9,6 +9,7 @@ import (
9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" 9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
10 protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/company" 10 protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/company"
11 userx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/user" 11 userx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/user"
  12 + "time"
12 ) 13 )
13 14
14 func PartnersV2(header *protocol.RequestHeader, request *protocolx.PartnersRequest) (rsp *protocolx.PartnersResponse, err error) { 15 func PartnersV2(header *protocol.RequestHeader, request *protocolx.PartnersRequest) (rsp *protocolx.PartnersResponse, err error) {
@@ -27,6 +28,9 @@ func PartnersV2(header *protocol.RequestHeader, request *protocolx.PartnersReque @@ -27,6 +28,9 @@ func PartnersV2(header *protocol.RequestHeader, request *protocolx.PartnersReque
27 log.Error(err) 28 log.Error(err)
28 return 29 return
29 } 30 }
  31 + if request.PageIndex == 0 {
  32 + rsp.Timestamp = time.Now().Unix() * 1000
  33 + }
30 if rsp.Partners == nil { 34 if rsp.Partners == nil {
31 rsp.Partners = []struct{}{} 35 rsp.Partners = []struct{}{}
32 } 36 }
@@ -106,6 +110,10 @@ func newQueryOptionV2(request *protocolx.PartnersRequest) map[string]interface{} @@ -106,6 +110,10 @@ func newQueryOptionV2(request *protocolx.PartnersRequest) map[string]interface{}
106 queryOption["startTime"] = request.StartTime / 1000 110 queryOption["startTime"] = request.StartTime / 1000
107 } 111 }
108 if request.EndTime > 0 { 112 if request.EndTime > 0 {
  113 + currentDayEnd := utils.GetDayEnd().Unix() * 1000
  114 + if request.EndTime >= currentDayEnd {
  115 + request.EndTime = currentDayEnd
  116 + }
109 queryOption["endTime"] = request.EndTime / 1000 117 queryOption["endTime"] = request.EndTime / 1000
110 } 118 }
111 if request.Keyword != "" { 119 if request.Keyword != "" {
1 package dividend 1 package dividend
2 2
3 import ( 3 import (
  4 + "fmt"
4 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" 5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory"
5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
@@ -24,13 +25,53 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis @@ -24,13 +25,53 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis
24 }() 25 }()
25 26
26 // 事业分红统计-查询订单 27 // 事业分红统计-查询订单
27 - _, orderAll, e := OrderBaseResponsitory.Find(utils.ObjectJsonToMap(domain.OrderQueryOption{PartnerId: request.PartnerId, EndTime: time.Now(), SortByCreateTime: domain.DESC, OrderTypes: domain.UserOrderTypes(domain.Career)})) 28 + _, orderAll, e := OrderBaseResponsitory.Find(utils.ObjectJsonToMap(domain.OrderQueryOption{PartnerId: request.PartnerId, EndTime: utils.GetDayEnd(), SortBySalesTime: domain.DESC, OrderTypes: domain.UserOrderTypes(domain.Career)}))
28 if e != nil { 29 if e != nil {
29 log.Error(e) 30 log.Error(e)
30 } 31 }
  32 +
  33 + //获取营销年
  34 + t := time.Now()
  35 + var last time.Time
  36 + var first time.Time
  37 + boundDate := time.Date(t.Year(), time.March, 31, 23, 59, 59, 0, time.Local) // 营销年界限
  38 + fmt.Println("营销年界限:", boundDate)
  39 + if t.Before(boundDate) || t.Equal(boundDate) {
  40 + first = time.Date(t.Year()-1, time.April, 1, 0, 0, 0, 0, time.Local)
  41 + last = time.Date(t.Year(), time.March, 31, 23, 59, 59, 0, time.Local)
  42 + } else if t.After(boundDate) {
  43 + first = time.Date(t.Year(), time.April, 1, 0, 0, 0, 0, time.Local)
  44 + last = time.Date(t.Year()+1, time.March, 31, 23, 59, 59, 0, time.Local)
  45 + }
  46 + fmt.Println("当前营销年起始:", first, last)
  47 + //last := time.Date(t.Year(), time.December, 31, 23, 59, 59, 0, time.Local)
  48 +
  49 + //first := time.Date(t.Year(), time.January, 1, 0, 0, 0, 0, time.Local)
  50 + //last := first.AddDate(1, 0, 0)
  51 +
  52 + //last := time.Date(t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second(), t.Nanosecond(), time.Local)
  53 + //last := utils.GetDayEnd()
  54 +
  55 + // 请求开始时间和结束时间都为0时,默认从营销年开始统计
  56 + if request.StartTime == 0 && request.EndTime == 0 {
  57 + request.StartTime = first.Unix() * 1000
  58 + request.EndTime = last.Unix() * 1000
  59 + } else if request.StartTime > 0 && request.EndTime > 0 { // 判断结束时间是否超过今天,超过今天的结束时间到今天为止
  60 + currentDayEnd := utils.GetDayEnd().Unix() * 1000
  61 + if request.EndTime >= currentDayEnd {
  62 + request.EndTime = currentDayEnd
  63 + }
  64 + }
  65 +
  66 + //if request.EndTime > last.Unix()*1000 {
  67 + // request.EndTime = last.Unix() * 1000
  68 + //}
  69 + fmt.Print("StartTime: ", request.StartTime, "\n")
  70 + fmt.Print("EndTime: ", request.EndTime, "\n")
  71 +
31 var orderBetween []*domain.OrderBase 72 var orderBetween []*domain.OrderBase
32 for i := range orderAll { 73 for i := range orderAll {
33 - if orderAll[i].CreateTime.Unix() >= (request.StartTime/1000) && orderAll[i].CreateTime.Unix() < (request.EndTime/1000) { 74 + if orderAll[i].SaleDate.Unix() >= (request.StartTime/1000) && orderAll[i].SaleDate.Unix() < (request.EndTime/1000) {
34 orderBetween = append(orderBetween, orderAll[i]) 75 orderBetween = append(orderBetween, orderAll[i])
35 } 76 }
36 } 77 }
@@ -60,6 +101,8 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis @@ -60,6 +101,8 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis
60 Quarters: bonusQuarters, 101 Quarters: bonusQuarters,
61 } 102 }
62 103
  104 + rsp.Timestamp = time.Now().Unix() * 1000
  105 +
63 err = transactionContext.CommitTransaction() 106 err = transactionContext.CommitTransaction()
64 return 107 return
65 } 108 }
@@ -82,7 +125,7 @@ func QuartersBonusStatics(orders []*domain.OrderBase, action int) (bonus []proto @@ -82,7 +125,7 @@ func QuartersBonusStatics(orders []*domain.OrderBase, action int) (bonus []proto
82 bonus = make([]protocol.Bonus, 4) 125 bonus = make([]protocol.Bonus, 4)
83 for i := range orders { 126 for i := range orders {
84 o := orders[i] 127 o := orders[i]
85 - quarter := quarter(o.CreateTime) 128 + quarter := quarter(o.SaleDate)
86 static := o.OrderBonusStatic() 129 static := o.OrderBonusStatic()
87 bonus[quarter].Receivable = utils.Decimal(bonus[quarter].Receivable + static.OrderTotalReceivable()) 130 bonus[quarter].Receivable = utils.Decimal(bonus[quarter].Receivable + static.OrderTotalReceivable())
88 bonus[quarter].Received = utils.Decimal(bonus[quarter].Received + static.OrderBonusReceive()) 131 bonus[quarter].Received = utils.Decimal(bonus[quarter].Received + static.OrderBonusReceive())
@@ -123,18 +166,23 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR @@ -123,18 +166,23 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
123 }() 166 }()
124 rsp = &protocol.DividendOrdersResponse{List: make([]*protocol.DividendOrderListItem, 0)} 167 rsp = &protocol.DividendOrdersResponse{List: make([]*protocol.DividendOrderListItem, 0)}
125 168
  169 + // 判断时间是否超过今天
  170 + currentDayEnd := utils.GetDayEnd().Unix() * 1000
  171 + if request.EndTime >= currentDayEnd {
  172 + request.EndTime = currentDayEnd
  173 + }
  174 +
126 count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{ 175 count, orders, err = OrderDao.DividendOrders(&domain.DividendOrdersQueryOption{
127 - OrderTypes: domain.UserOrderTypes(domain.Career),  
128 - PartnerId: request.PartnerId,  
129 - DetailAction: request.DetailAction,  
130 - DividendAction: request.DividendAction,  
131 - StartTime: request.StartTime,  
132 - EndTime: request.EndTime,  
133 - Offset: request.PageIndex * request.PageSize,  
134 - Limit: request.PageSize,  
135 - //SortByUpdateTime: domain.DESC,  
136 - SortByCreateTime: domain.DESC,  
137 - JoinWays: request.JoinWays, 176 + OrderTypes: domain.UserOrderTypes(domain.Career),
  177 + PartnerId: request.PartnerId,
  178 + DetailAction: request.DetailAction,
  179 + DividendAction: request.DividendAction,
  180 + StartTime: request.StartTime,
  181 + EndTime: request.EndTime,
  182 + Offset: request.PageIndex * request.PageSize,
  183 + Limit: request.PageSize,
  184 + SortBySalesTime: domain.DESC,
  185 + JoinWays: request.JoinWays,
138 }) 186 })
139 if err != nil { 187 if err != nil {
140 return 188 return
@@ -38,6 +38,7 @@ func Detail(header *protocol.RequestHeader, request *protocol.OrderDetailRequest @@ -38,6 +38,7 @@ func Detail(header *protocol.RequestHeader, request *protocol.OrderDetailRequest
38 OrderStatus: orderStatus(order), 38 OrderStatus: orderStatus(order),
39 CreateTime: order.CreateTime.Unix() * 1000, 39 CreateTime: order.CreateTime.Unix() * 1000,
40 UpdateTime: order.UpdateTime.Unix() * 1000, 40 UpdateTime: order.UpdateTime.Unix() * 1000,
  41 + SalesTime: order.SaleDate.Unix() * 1000,
41 OrderDistrict: map[string]interface{}{"id": order.RegionInfo.RegionId, "name": order.RegionInfo.RegionName}, 42 OrderDistrict: map[string]interface{}{"id": order.RegionInfo.RegionId, "name": order.RegionInfo.RegionName},
42 Customer: protocol.Customer{Uname: order.Buyer.BuyerName, Phone: order.Buyer.ContactInfo}, 43 Customer: protocol.Customer{Uname: order.Buyer.BuyerName, Phone: order.Buyer.ContactInfo},
43 Products: orderProducts(order), 44 Products: orderProducts(order),
@@ -119,6 +120,13 @@ func orderTotalStatic(order *domain.OrderBase) interface{} { @@ -119,6 +120,13 @@ func orderTotalStatic(order *domain.OrderBase) interface{} {
119 return item 120 return item
120 } 121 }
121 122
  123 +/**
  124 + * @Author SteveChan
  125 + * @Description // 订单统计
  126 + * @Date 18:14 2021/1/28
  127 + * @Param
  128 + * @return
  129 + **/
122 // 订单统计 130 // 订单统计
123 func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatisticsRequest) (rsp *protocol.OrderStatisticsResponse, err error) { 131 func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatisticsRequest) (rsp *protocol.OrderStatisticsResponse, err error) {
124 var ( 132 var (
@@ -126,15 +134,18 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic @@ -126,15 +134,18 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic
126 OrderDao, _ = factory.CreateOrderBaseDao(transactionContext) 134 OrderDao, _ = factory.CreateOrderBaseDao(transactionContext)
127 BusinessBonusRepository, _ = factory.CreateBusinessBonusRepository(transactionContext) 135 BusinessBonusRepository, _ = factory.CreateBusinessBonusRepository(transactionContext)
128 ) 136 )
  137 +
129 if err = transactionContext.StartTransaction(); err != nil { 138 if err = transactionContext.StartTransaction(); err != nil {
130 return nil, err 139 return nil, err
131 } 140 }
  141 +
132 defer func() { 142 defer func() {
133 transactionContext.RollbackTransaction() 143 transactionContext.RollbackTransaction()
134 }() 144 }()
  145 +
135 rsp = &protocol.OrderStatisticsResponse{Statistics: &protocol.OrderStatics{}} 146 rsp = &protocol.OrderStatisticsResponse{Statistics: &protocol.OrderStatics{}}
136 147
137 - // 当天订单/累计订单 148 + // 今日新增实发订单
138 if rsp.Statistics.TodayRealQuantity, rsp.Statistics.TodayRealMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ 149 if rsp.Statistics.TodayRealQuantity, rsp.Statistics.TodayRealMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
139 BeginTime: utils.GetDayBegin().Unix() * 1000, 150 BeginTime: utils.GetDayBegin().Unix() * 1000,
140 EndTime: utils.GetDayEnd().Unix() * 1000, 151 EndTime: utils.GetDayEnd().Unix() * 1000,
@@ -143,19 +154,23 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic @@ -143,19 +154,23 @@ func Statistics(header *protocol.RequestHeader, request *protocol.OrderStatistic
143 }); err != nil { 154 }); err != nil {
144 return 155 return
145 } 156 }
  157 +
  158 + // 累计实发订单
146 if rsp.Statistics.CumulativeQuantity, rsp.Statistics.CumulativeMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ 159 if rsp.Statistics.CumulativeQuantity, rsp.Statistics.CumulativeMoney, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
147 - EndTime: time.Now().Unix() * 1000, 160 + //EndTime: time.Now().Unix() * 1000,
  161 + EndTime: utils.GetDayEnd().Unix() * 1000, // 累计到今天最后一刻
148 OrderTypes: domain.UserOrderTypes(domain.Career), 162 OrderTypes: domain.UserOrderTypes(domain.Career),
149 PartnerId: header.UserId, 163 PartnerId: header.UserId,
150 }); err != nil { 164 }); err != nil {
151 return 165 return
152 } 166 }
  167 +
153 rsp.Statistics.TodayRealMoney = utils.Decimal(rsp.Statistics.TodayRealMoney) 168 rsp.Statistics.TodayRealMoney = utils.Decimal(rsp.Statistics.TodayRealMoney)
154 rsp.Statistics.CumulativeMoney = utils.Decimal(rsp.Statistics.CumulativeMoney) 169 rsp.Statistics.CumulativeMoney = utils.Decimal(rsp.Statistics.CumulativeMoney)
155 170
156 //事业分红/业务分红 171 //事业分红/业务分红
157 var careerBonus, businessBonus, total float64 //,developBonus,appBonus 172 var careerBonus, businessBonus, total float64 //,developBonus,appBonus
158 - if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: header.UserId, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil { 173 + if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: header.UserId, OrderTypes: domain.UserOrderTypes(domain.Career), EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
159 careerBonus = bonus.Bonus 174 careerBonus = bonus.Bonus
160 total += careerBonus 175 total += careerBonus
161 } 176 }
@@ -195,20 +210,39 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -195,20 +210,39 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
195 210
196 // 查询订单列表 211 // 查询订单列表
197 queryOption := &domain.OrderQueryOption{ 212 queryOption := &domain.OrderQueryOption{
198 - Limit: request.PageSize,  
199 - Offset: request.PageSize * request.PageIndex, 213 + Limit: request.PageSize,
  214 + Offset: request.PageSize * request.PageIndex,
200 //SortByUpdateTime: domain.DESC, 215 //SortByUpdateTime: domain.DESC,
201 - SortByCreateTime: domain.DESC, 216 + //SortByCreateTime: domain.DESC,
  217 + SortBySalesTime: domain.DESC,
202 PartnerId: request.PartnerId, 218 PartnerId: request.PartnerId,
203 PartnerCategoryId: request.JoinWay, 219 PartnerCategoryId: request.JoinWay,
204 OrderType: request.OrderType, 220 OrderType: request.OrderType,
205 OrderTypes: request.OrderTypes, 221 OrderTypes: request.OrderTypes,
206 } 222 }
207 - if request.StartTime > 0 { 223 + // 当月累计实发订单
  224 + d := time.Now()
  225 + if request.StartTime > 0 { // 开始时间处理
208 queryOption.BeginTime = time.Unix(request.StartTime/1000, 0) 226 queryOption.BeginTime = time.Unix(request.StartTime/1000, 0)
  227 + } else { // 开始时间为0,默认从这个月初开始
  228 + queryOption.BeginTime = utils.GetFirstDateOfMonth(d)
209 } 229 }
210 - if request.EndTime > 0 { 230 +
  231 + if request.EndTime > 0 { // 结束时间处理,判断时间是否超过今天
  232 + currentDayEnd := utils.GetDayEnd().Unix() * 1000
  233 + if request.EndTime >= currentDayEnd {
  234 + request.EndTime = currentDayEnd
  235 + }
211 queryOption.EndTime = time.Unix(request.EndTime/1000, 0) 236 queryOption.EndTime = time.Unix(request.EndTime/1000, 0)
  237 + } else { // 请求结束时间为0,默认到今天结束
  238 + //queryOption.EndTime = utils.GetNextMonthFirstDay(d)
  239 + queryOption.EndTime = utils.GetDayEnd()
  240 + }
  241 +
  242 + // 今日新增实发订单
  243 + if request.IsToday {
  244 + queryOption.BeginTime = utils.GetZeroTime(d)
  245 + queryOption.EndTime = utils.GetNextDayZeroTime(d)
212 } 246 }
213 total, orders, _ = OrderRepository.Find(utils.ObjectJsonToMap(queryOption)) 247 total, orders, _ = OrderRepository.Find(utils.ObjectJsonToMap(queryOption))
214 if len(orders) != 0 { 248 if len(orders) != 0 {
@@ -222,19 +256,21 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -222,19 +256,21 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
222 } 256 }
223 } 257 }
224 258
225 - // 【特殊处理1】 查询第0页时,需要查询累计实发订单数 259 + // 【特殊处理1】 查询第0页时,需要查询累计实发订单数,并下发时间戳
226 if request.PageIndex == 0 { 260 if request.PageIndex == 0 {
227 var ( 261 var (
228 cumulativeQuantity int 262 cumulativeQuantity int
229 ) 263 )
230 cumulativeQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ 264 cumulativeQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
231 - EndTime: time.Now().Unix() * 1000, 265 + EndTime: utils.GetDayEnd().Unix() * 1000,
232 OrderTypes: domain.UserOrderTypes(domain.Career), 266 OrderTypes: domain.UserOrderTypes(domain.Career),
233 PartnerId: request.PartnerId, 267 PartnerId: request.PartnerId,
234 PartnerCategoryId: request.JoinWay, 268 PartnerCategoryId: request.JoinWay,
235 }) 269 })
236 rsp.Total = cumulativeQuantity 270 rsp.Total = cumulativeQuantity
  271 + rsp.Timestamp = time.Now().Unix() * 1000
237 } 272 }
  273 +
238 //【特殊处理2】 今天累计数量特殊处理 当前查询时间段内所有订单总数(复用rsp.Total字段) 274 //【特殊处理2】 今天累计数量特殊处理 当前查询时间段内所有订单总数(复用rsp.Total字段)
239 if request.StartTime > 0 && request.EndTime > 0 { 275 if request.StartTime > 0 && request.EndTime > 0 {
240 zero := time.Time(xtime.XTime(time.Now()).DayBefore(0)).Unix() 276 zero := time.Time(xtime.XTime(time.Now()).DayBefore(0)).Unix()
@@ -243,23 +279,39 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -243,23 +279,39 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
243 } 279 }
244 } 280 }
245 281
  282 + // 【特殊处理3】今日新增实发订单统计
  283 + if request.IsToday {
  284 + var (
  285 + todayQuantity int
  286 + )
  287 + todayQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{
  288 + BeginTime: queryOption.BeginTime.Unix() * 1000,
  289 + EndTime: queryOption.EndTime.Unix() * 1000,
  290 + OrderTypes: domain.UserOrderTypes(domain.Career),
  291 + PartnerId: request.PartnerId,
  292 + PartnerCategoryId: request.JoinWay,
  293 + })
  294 + rsp.Total = todayQuantity
  295 + }
  296 +
246 err = transactionContext.CommitTransaction() 297 err = transactionContext.CommitTransaction()
247 return 298 return
248 } 299 }
249 func DomainOrderToOrderListItem(order *domain.OrderBase) *protocol.OrderListItem { 300 func DomainOrderToOrderListItem(order *domain.OrderBase) *protocol.OrderListItem {
250 bonusStatic := order.OrderBonusStatic() 301 bonusStatic := order.OrderBonusStatic()
251 return &protocol.OrderListItem{ 302 return &protocol.OrderListItem{
252 - Id: order.Id,  
253 - OrderType: order.OrderType,  
254 - OrderNo: order.OrderCode,  
255 - DeliveryNo: order.DeliveryCode,  
256 - OrderDistrict: map[string]interface{}{  
257 - "id": order.RegionInfo.RegionId, 303 + Id: order.Id,
  304 + OrderType: order.OrderType,
  305 + OrderNo: order.OrderCode,
  306 + DeliveryNo: order.DeliveryCode,
  307 + OrderDistrict: map[string]interface{}{
  308 + "id": order.RegionInfo.RegionId,
258 "name": order.RegionInfo.RegionName, 309 "name": order.RegionInfo.RegionName,
259 }, 310 },
260 - OrderAmount: order.PlanOrderAmount,  
261 - UpdateTime: order.UpdateTime.Unix() * 1000,  
262 - MyDividend: bonusStatic.OrderTotalReceivable(),  
263 - IsRead: order.IsRead(), 311 + OrderAmount: order.PlanOrderAmount,
  312 + UpdateTime: order.UpdateTime.Unix() * 1000,
  313 + SalesTime: order.SaleDate.Unix() * 1000,
  314 + MyDividend: bonusStatic.OrderTotalReceivable(),
  315 + IsRead: order.IsRead(),
264 } 316 }
265 } 317 }
@@ -6,7 +6,6 @@ import ( @@ -6,7 +6,6 @@ import (
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
9 - "time"  
10 ) 9 )
11 10
12 // 订单统计 11 // 订单统计
@@ -25,7 +24,7 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist @@ -25,7 +24,7 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist
25 24
26 //事业分红/业务分红 25 //事业分红/业务分红
27 var total float64 26 var total float64
28 - if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil { 27 + if bonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career), EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
29 total += bonus.Bonus 28 total += bonus.Bonus
30 } 29 }
31 calcOrderStatic := func(catId int, total float64) protocol.OrderStatic { 30 calcOrderStatic := func(catId int, total float64) protocol.OrderStatic {
@@ -37,12 +36,12 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist @@ -37,12 +36,12 @@ func StatisticsV2(header *protocol.RequestHeader, request *protocol.OrderStatist
37 PartnerCategoryId: catId, 36 PartnerCategoryId: catId,
38 }) 37 })
39 cumulativeQuantity, cumulativeMoney, _ := OrderDao.OrderStatics(&domain.OrderStaticQuery{ 38 cumulativeQuantity, cumulativeMoney, _ := OrderDao.OrderStatics(&domain.OrderStaticQuery{
40 - EndTime: time.Now().Unix() * 1000, 39 + EndTime: utils.GetDayEnd().Unix() * 1000,
41 OrderTypes: domain.UserOrderTypes(domain.Career), 40 OrderTypes: domain.UserOrderTypes(domain.Career),
42 PartnerId: request.PartnerId, 41 PartnerId: request.PartnerId,
43 PartnerCategoryId: catId, 42 PartnerCategoryId: catId,
44 }) 43 })
45 - bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: catId}) 44 + bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: request.PartnerId, OrderTypes: domain.UserOrderTypes(domain.Career), PartnerCategoryId: catId, EndTime: utils.GetDayEnd().Unix() * 1000})
46 var percent float64 = 0 45 var percent float64 = 0
47 if bonus.Bonus != 0 { 46 if bonus.Bonus != 0 {
48 percent = utils.DecimalToNumber(bonus.Bonus * 100 / total) 47 percent = utils.DecimalToNumber(bonus.Bonus * 100 / total)
@@ -66,12 +66,12 @@ func getDetail(userId int64, transactionContext *transaction.TransactionContext) @@ -66,12 +66,12 @@ func getDetail(userId int64, transactionContext *transaction.TransactionContext)
66 } 66 }
67 } 67 }
68 p.CooperateTime = partner.CooperateTime.Unix() * 1000 68 p.CooperateTime = partner.CooperateTime.Unix() * 1000
69 - if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: userId, OrderTypes: domain.UserOrderTypes(domain.Career)}); e == nil { 69 + if bonus, e := OrderBaseDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: userId, OrderTypes: domain.UserOrderTypes(domain.Career), EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
70 p.CareerOrdersCount = int(bonus.Total) 70 p.CareerOrdersCount = int(bonus.Total)
71 p.CareerOrdersMoney = utils.Decimal(bonus.TotalOrderAmount) 71 p.CareerOrdersMoney = utils.Decimal(bonus.TotalOrderAmount)
72 p.CareerDividend = utils.Decimal(bonus.Bonus) 72 p.CareerDividend = utils.Decimal(bonus.Bonus)
73 } 73 }
74 - if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: userId, IsDisable: 1}); e == nil { 74 + if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: userId, IsDisable: 1, EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
75 p.BusinessOrdersCount = int(businessBonus.Total) 75 p.BusinessOrdersCount = int(businessBonus.Total)
76 p.BusinessOrdersMoney = utils.Decimal(businessBonus.TotalOrderAmount) 76 p.BusinessOrdersMoney = utils.Decimal(businessBonus.TotalOrderAmount)
77 p.BusinessDividend = utils.Decimal(businessBonus.Bonus) 77 p.BusinessDividend = utils.Decimal(businessBonus.Bonus)
@@ -8,7 +8,7 @@ import ( @@ -8,7 +8,7 @@ import (
8 const SERVICE_NAME = "partner" 8 const SERVICE_NAME = "partner"
9 9
10 var LOG_LEVEL = "debug" 10 var LOG_LEVEL = "debug"
11 -var LOG_File = "app.log" 11 +var LOG_File = "logs/app.log"
12 var LOG_PREFIX = "[partner_dev]" 12 var LOG_PREFIX = "[partner_dev]"
13 13
14 var MMM_SMS_SERVICE_HOST = "https://sms.fjmaimaimai.com:9897" 14 var MMM_SMS_SERVICE_HOST = "https://sms.fjmaimaimai.com:9897"
@@ -4,9 +4,9 @@ import "os" @@ -4,9 +4,9 @@ import "os"
4 4
5 var POSTGRESQL_DB_NAME = "partner_test" //partner_test/partner_dev 5 var POSTGRESQL_DB_NAME = "partner_test" //partner_test/partner_dev
6 var POSTGRESQL_USER = "postgres" //postgres 6 var POSTGRESQL_USER = "postgres" //postgres
7 -var POSTGRESQL_PASSWORD = "eagle1010" //pgsql@123/1993618jack  
8 -var POSTGRESQL_HOST = "114.55.200.59" //127.0.0.1/114.55.200.59  
9 -var POSTGRESQL_PORT = "31543" //5432/31543 7 +var POSTGRESQL_PASSWORD = "1993618jack" //pgsql@123/1993618jack/eagle1010
  8 +var POSTGRESQL_HOST = "127.0.0.1" //127.0.0.1/114.55.200.59
  9 +var POSTGRESQL_PORT = "5432" //5432/31543
10 var DISABLE_CREATE_TABLE = true 10 var DISABLE_CREATE_TABLE = true
11 var DISABLE_SQL_GENERATE_PRINT = false 11 var DISABLE_SQL_GENERATE_PRINT = false
12 12
@@ -4,7 +4,7 @@ import "os" @@ -4,7 +4,7 @@ import "os"
4 4
5 var REDIS_HOST = "127.0.0.1" 5 var REDIS_HOST = "127.0.0.1"
6 var REDIS_PORT = "6379" 6 var REDIS_PORT = "6379"
7 -var REDIS_AUTH = "" 7 +var REDIS_AUTH = "" // 1993618@jack
8 8
9 func init() { 9 func init() {
10 if os.Getenv("REDIS_HOST") != "" { 10 if os.Getenv("REDIS_HOST") != "" {
@@ -42,6 +42,8 @@ type OrderBase struct { @@ -42,6 +42,8 @@ type OrderBase struct {
42 DeliveryTime time.Time 42 DeliveryTime time.Time
43 //更新时间 43 //更新时间
44 UpdateTime time.Time 44 UpdateTime time.Time
  45 + //销售日期
  46 + SaleDate time.Time
45 //上一次查看时间 已读情况 47 //上一次查看时间 已读情况
46 LastViewTime time.Time 48 LastViewTime time.Time
47 //合伙人应收分红 49 //合伙人应收分红
@@ -157,25 +159,27 @@ type OrderQueryOption struct { @@ -157,25 +159,27 @@ type OrderQueryOption struct {
157 //IsDisable string `json:"isDisable,omitempty"` 159 //IsDisable string `json:"isDisable,omitempty"`
158 SortByCreateTime string `json:"sortByCreateTime,omitempty"` 160 SortByCreateTime string `json:"sortByCreateTime,omitempty"`
159 SortByUpdateTime string `json:"sortByUpdateTime,omitempty"` 161 SortByUpdateTime string `json:"sortByUpdateTime,omitempty"`
  162 + SortBySalesTime string `json:"sortBySalesTime,omitempty"`
160 Offset int `json:"offset,omitempty"` 163 Offset int `json:"offset,omitempty"`
161 Limit int `json:"limit,omitempty"` 164 Limit int `json:"limit,omitempty"`
162 PartnerCategoryId int `json:"partnerCategoryId,omitempty"` 165 PartnerCategoryId int `json:"partnerCategoryId,omitempty"`
163 } 166 }
164 167
165 type DividendOrdersQueryOption struct { 168 type DividendOrdersQueryOption struct {
166 - PartnerId int64 `json:"partnerId"`  
167 - OrderType int `json:"orderType"` //订单类型  
168 - OrderTypes []int `json:"orderTypes,omitempty"`  
169 - DetailAction int `json:"detailAction"` //明细类型(0已收明细、1未收明细)  
170 - DividendAction int `json:"dividendAction"` //分红类型(0累计分红、1分红支出)  
171 - IsDisable string `json:"isDisable,omitempty"`  
172 - StartTime int64 `json:"startTime" `  
173 - EndTime int64 `json:"endTime"`  
174 - Offset int `json:"offset,omitempty"`  
175 - Limit int `json:"limit,omitempty"`  
176 - SortByUpdateTime string `json:"sortByUpdateTime,omitempty"`  
177 - SortByCreateTime string `json:"sortByCreateTime,omitempty"`  
178 - JoinWays []*company.JoinWays `json:"joinWays,omitempty"` // 合伙类型 169 + PartnerId int64 `json:"partnerId"`
  170 + OrderType int `json:"orderType"` //订单类型
  171 + OrderTypes []int `json:"orderTypes,omitempty"`
  172 + DetailAction int `json:"detailAction"` //明细类型(0已收明细、1未收明细)
  173 + DividendAction int `json:"dividendAction"` //分红类型(0累计分红、1分红支出)
  174 + IsDisable string `json:"isDisable,omitempty"`
  175 + StartTime int64 `json:"startTime" `
  176 + EndTime int64 `json:"endTime"`
  177 + Offset int `json:"offset,omitempty"`
  178 + Limit int `json:"limit,omitempty"`
  179 + SortByUpdateTime string `json:"sortByUpdateTime,omitempty"`
  180 + SortByCreateTime string `json:"sortByCreateTime,omitempty"`
  181 + SortBySalesTime string `json:"sortBySalesTime,omitempty"`
  182 + JoinWays []*company.JoinWays `json:"joinWays,omitempty"` // 合伙类型
179 } 183 }
180 184
181 //买家 185 //买家
@@ -32,6 +32,7 @@ type OrderBonusQuery struct { @@ -32,6 +32,7 @@ type OrderBonusQuery struct {
32 OrderType int `json:"orderType,omitempty"` 32 OrderType int `json:"orderType,omitempty"`
33 OrderTypes []int `json:"orderTypes,omitempty"` 33 OrderTypes []int `json:"orderTypes,omitempty"`
34 PartnerCategoryId int `json:"partnerCategoryId,omitempty"` //订单所属类型 34 PartnerCategoryId int `json:"partnerCategoryId,omitempty"` //订单所属类型
  35 + EndTime int64 `json:"endTime,omitempty"`
35 //IsGroupByPartnerCategoryId bool `json:"isGroupByPartnerCategoryId,omitempty"` 36 //IsGroupByPartnerCategoryId bool `json:"isGroupByPartnerCategoryId,omitempty"`
36 } 37 }
37 38
@@ -35,10 +35,10 @@ func (dao *OrderBaseDao) OrderStatics(option *domain.OrderStaticQuery) (count in @@ -35,10 +35,10 @@ func (dao *OrderBaseDao) OrderStatics(option *domain.OrderStaticQuery) (count in
35 q.Where(`"order_base".order_type in (?)`, pg.In(option.OrderTypes)) 35 q.Where(`"order_base".order_type in (?)`, pg.In(option.OrderTypes))
36 } 36 }
37 if option.BeginTime > 0 { 37 if option.BeginTime > 0 {
38 - q.Where(`"order_base".create_time >=?`, time.Unix(option.BeginTime/1000, 0)) 38 + q.Where(`"order_base".sale_date >=?`, time.Unix(option.BeginTime/1000, 0))
39 } 39 }
40 if option.EndTime > 0 { 40 if option.EndTime > 0 {
41 - q.Where(`"order_base".create_time <?`, time.Unix(option.EndTime/1000, 0)) 41 + q.Where(`"order_base".sale_date <?`, time.Unix(option.EndTime/1000, 0))
42 } 42 }
43 if option.PartnerCategoryId > 0 { 43 if option.PartnerCategoryId > 0 {
44 q.Where(`"order_base".partner_category @>'{"id":?}'`, option.PartnerCategoryId) 44 q.Where(`"order_base".partner_category @>'{"id":?}'`, option.PartnerCategoryId)
@@ -82,6 +82,9 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d @@ -82,6 +82,9 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d
82 if option.PartnerCategoryId > 0 { 82 if option.PartnerCategoryId > 0 {
83 q.Where(`"order_base".partner_category @>'{"id":?}'`, option.PartnerCategoryId) 83 q.Where(`"order_base".partner_category @>'{"id":?}'`, option.PartnerCategoryId)
84 } 84 }
  85 + if option.EndTime > 0 {
  86 + q.Where(`"order_base".sale_date <?`, time.Unix(option.EndTime/1000, 0))
  87 + }
85 //if option.IsGroupByPartnerCategoryId{ 88 //if option.IsGroupByPartnerCategoryId{
86 // q.Group(`partner_category`) 89 // q.Group(`partner_category`)
87 //} 90 //}
@@ -105,10 +108,10 @@ func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption @@ -105,10 +108,10 @@ func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption
105 q.Where(`"order_base".partner_id=?`, option.PartnerId) 108 q.Where(`"order_base".partner_id=?`, option.PartnerId)
106 } 109 }
107 if option.StartTime > 0 { 110 if option.StartTime > 0 {
108 - q.Where(`"order_base".create_time >=?`, time.Unix(option.StartTime/1000, 0)) 111 + q.Where(`"order_base".sale_date >=?`, time.Unix(option.StartTime/1000, 0))
109 } 112 }
110 if option.EndTime > 0 { 113 if option.EndTime > 0 {
111 - q.Where(`"order_base".create_time <?`, time.Unix(option.EndTime/1000, 0)) 114 + q.Where(`"order_base".sale_date <?`, time.Unix(option.EndTime/1000, 0))
112 } 115 }
113 if len(option.JoinWays) > 0 { 116 if len(option.JoinWays) > 0 {
114 var joinWays []int64 117 var joinWays []int64
@@ -150,6 +153,9 @@ func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption @@ -150,6 +153,9 @@ func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption
150 if len(option.SortByCreateTime) > 0 { 153 if len(option.SortByCreateTime) > 0 {
151 q.Order(fmt.Sprintf("order_base.create_time %v", option.SortByCreateTime)) 154 q.Order(fmt.Sprintf("order_base.create_time %v", option.SortByCreateTime))
152 } 155 }
  156 + if len(option.SortBySalesTime) > 0 {
  157 + q.Order(fmt.Sprintf("order_base.sale_date %v", option.SortBySalesTime))
  158 + }
153 count, err = q.Distinct().SelectAndCount() 159 count, err = q.Distinct().SelectAndCount()
154 for i := range orders { 160 for i := range orders {
155 var domainOrder *domain.OrderBase 161 var domainOrder *domain.OrderBase
@@ -115,7 +115,7 @@ A left join @@ -115,7 +115,7 @@ A left join
115 plan_order_amount amount, 115 plan_order_amount amount,
116 (case when use_order_count>=0 then use_partner_bonus else plan_partner_bonus end) bonus, 116 (case when use_order_count>=0 then use_partner_bonus else plan_partner_bonus end) bonus,
117 partner_bonus_expense bonus_expense FROM "order_base" AS "order_base" 117 partner_bonus_expense bonus_expense FROM "order_base" AS "order_base"
118 - WHERE (partner_id in (?)) and (order_type in (?)) 118 + WHERE (partner_id in (?)) and (order_type in (?) and (sale_date < ?) )
119 UNION ALL 119 UNION ALL
120 SELECT partner_info_id partner_id, 120 SELECT partner_info_id partner_id,
121 0 amount, bonus bonus, bonus_expense bonus_expense FROM business_bonus 121 0 amount, bonus bonus, bonus_expense bonus_expense FROM business_bonus
@@ -132,7 +132,7 @@ GROUP BY partner_id @@ -132,7 +132,7 @@ GROUP BY partner_id
132 sql.WriteString(fmt.Sprintf(" \nOFFSET %v", offset)) 132 sql.WriteString(fmt.Sprintf(" \nOFFSET %v", offset))
133 } 133 }
134 } 134 }
135 - _, err = tx.Query(&statics, sql.String(), pg.In(partnerIds), pg.In(partnerIds), pg.In(domain.UserOrderTypes(domain.Career)), pg.In(partnerIds)) 135 + _, err = tx.Query(&statics, sql.String(), pg.In(partnerIds), pg.In(partnerIds), pg.In(domain.UserOrderTypes(domain.Career)), GetDayEnd(), pg.In(partnerIds))
136 return 136 return
137 } 137 }
138 138
@@ -153,17 +153,29 @@ func (svr *PgLoginService) CheckIsPartner(phone string, companyId int64) (ok boo @@ -153,17 +153,29 @@ func (svr *PgLoginService) CheckIsPartner(phone string, companyId int64) (ok boo
153 return ok, nil 153 return ok, nil
154 } 154 }
155 155
156 -//合伙人登录 156 +// 合伙人登录
157 func (svr *PgLoginService) PartnerLogin(phone string, password string) (err error) { 157 func (svr *PgLoginService) PartnerLogin(phone string, password string) (err error) {
158 if len(svr.PartnerInfo) == 0 { 158 if len(svr.PartnerInfo) == 0 {
159 //子账号 159 //子账号
160 err = protocol.NewErrWithMessage(502, err) //账号不存在 160 err = protocol.NewErrWithMessage(502, err) //账号不存在
161 return 161 return
162 } 162 }
163 - if !strings.EqualFold(svr.PartnerInfo[0].Password, password) { 163 +
  164 + var misMatch bool
  165 + for _, partnerInfo := range svr.PartnerInfo {
  166 + if !strings.EqualFold(partnerInfo.Password, password) {
  167 + misMatch = true
  168 + } else {
  169 + misMatch = false
  170 + break
  171 + }
  172 + }
  173 +
  174 + if misMatch {
164 err = protocol.NewCustomMessage(1, "密码输入错误!") 175 err = protocol.NewCustomMessage(1, "密码输入错误!")
165 return 176 return
166 } 177 }
  178 +
167 return 179 return
168 } 180 }
169 181
@@ -226,12 +238,12 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { @@ -226,12 +238,12 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
226 return response, nil 238 return response, nil
227 } 239 }
228 240
229 - totalBonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: doGetPartnerIds(), OrderTypes: domain.UserOrderTypes(domain.Career)}) 241 + totalBonus, e := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: doGetPartnerIds(), OrderTypes: domain.UserOrderTypes(domain.Career), EndTime: utils.GetDayEnd().Unix() * 1000})
230 if e != nil { 242 if e != nil {
231 return response, e 243 return response, e
232 } 244 }
233 245
234 - if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: doGetPartnerIds(), IsDisable: 1}); e == nil { 246 + if businessBonus, e := BusinessBonusDao.OrderBonusStatics(domain.OrderBonusQuery{InPartnerIds: doGetPartnerIds(), IsDisable: 1, EndTime: utils.GetDayEnd().Unix() * 1000}); e == nil {
235 totalBonus.Bonus += businessBonus.Bonus 247 totalBonus.Bonus += businessBonus.Bonus
236 } 248 }
237 249
@@ -278,7 +290,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { @@ -278,7 +290,7 @@ func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
278 continue 290 continue
279 } 291 }
280 292
281 - bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: partner.Id, OrderTypes: domain.UserOrderTypes(domain.Career)}) 293 + bonus, _ := OrderDao.OrderBonusStatics(domain.OrderBonusQuery{PartnerId: partner.Id, OrderTypes: domain.UserOrderTypes(domain.Career), EndTime: utils.GetDayEnd().Unix() * 1000})
282 if v, ok := mapPartnerBussinessBonus[partner.Id]; ok { 294 if v, ok := mapPartnerBussinessBonus[partner.Id]; ok {
283 bonus.Bonus += v.Bonus 295 bonus.Bonus += v.Bonus
284 } 296 }
@@ -454,7 +466,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -454,7 +466,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
454 isUserSenior bool 466 isUserSenior bool
455 ) 467 )
456 468
457 - partnerInfo, _ := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人在正常公司是否存在 469 + partnerInfo, errPartner := PartnerInfoService.FindOne(map[string]interface{}{"account": phone, "isNot": constant.DEFAULT_GUEST_COMPANY}) // 合伙人在正常公司是否存在
458 if partnerInfo == nil { 470 if partnerInfo == nil {
459 isPartner = false 471 isPartner = false
460 } else { 472 } else {
@@ -480,7 +492,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -480,7 +492,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
480 isGuestPartnerAvailable = true 492 isGuestPartnerAvailable = true
481 } 493 }
482 494
483 - user, _ := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在 495 + user, errUser := UsersRepository.FindOne(map[string]interface{}{"phone": phone, "deleteAtIsNull": true}) // 用户是否存在
484 if user == nil { 496 if user == nil {
485 isUser = false 497 isUser = false
486 } else { 498 } else {
@@ -571,27 +583,27 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -571,27 +583,27 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
571 583
572 // 合伙人不存在、用户存在、非高管(普通用户)-> 注册用户 584 // 合伙人不存在、用户存在、非高管(普通用户)-> 注册用户
573 // 合伙人不存在、用户不存在(游客)-> 注册用户 585 // 合伙人不存在、用户不存在(游客)-> 注册用户
574 - //if errPartner != nil && errUser == nil && errSenior == nil || errPartner != nil && errUser != nil {  
575 - // id := time.Now().Unix()  
576 - // errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{  
577 - // Id: id,  
578 - // CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),  
579 - // PartnerName: phone,  
580 - // Account: phone,  
581 - // Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",  
582 - // Status: 1,  
583 - // PartnerCategory: 1,  
584 - // RegionInfo: &domain.RegionInfo{  
585 - // RegionName: "客户区域",  
586 - // RegionId: 0,  
587 - // },  
588 - // CooperateTime: time.Now(),  
589 - // CreateAt: time.Now(),  
590 - // UpdateAt: time.Now(),  
591 - // PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},  
592 - // Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},  
593 - // })  
594 - //} 586 + if errPartner != nil && errUser == nil {
  587 + id := time.Now().Unix()
  588 + errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{
  589 + Id: id,
  590 + CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
  591 + PartnerName: phone,
  592 + Account: phone,
  593 + Password: "7c4a8d09ca3762af61e59520943dc26494f8941b",
  594 + Status: 1,
  595 + PartnerCategory: 1,
  596 + RegionInfo: &domain.RegionInfo{
  597 + RegionName: "客户区域",
  598 + RegionId: 0,
  599 + },
  600 + CooperateTime: time.Now(),
  601 + CreateAt: time.Now(),
  602 + UpdateAt: time.Now(),
  603 + PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
  604 + Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
  605 + })
  606 + }
595 607
596 return errPartner 608 return errPartner
597 } 609 }
@@ -627,7 +639,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { @@ -627,7 +639,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error {
627 CooperateTime: time.Now(), 639 CooperateTime: time.Now(),
628 CreateAt: time.Now(), 640 CreateAt: time.Now(),
629 UpdateAt: time.Now(), 641 UpdateAt: time.Now(),
630 - PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1}}, 642 + PartnerCategoryInfos: []*models.PartnerCategoryInfo{&models.PartnerCategoryInfo{Id: 1, Code: phone}},
631 Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}}, 643 Salesman: []*domain.Salesman{&domain.Salesman{Name: phone, Telephone: phone}},
632 }) 644 })
633 } 645 }
@@ -42,6 +42,8 @@ type OrderBase struct { @@ -42,6 +42,8 @@ type OrderBase struct {
42 DeliveryTime time.Time 42 DeliveryTime time.Time
43 //更新时间 43 //更新时间
44 UpdateTime time.Time 44 UpdateTime time.Time
  45 + //销售日期
  46 + SaleDate time.Time
45 //上一次查看时间 已读情况 47 //上一次查看时间 已读情况
46 LastViewTime time.Time 48 LastViewTime time.Time
47 //合伙人应收分红 49 //合伙人应收分红
@@ -79,12 +79,13 @@ func (repository *OrderBaseRepository) Find(queryOptions map[string]interface{}) @@ -79,12 +79,13 @@ func (repository *OrderBaseRepository) Find(queryOptions map[string]interface{})
79 query := NewQuery(tx.Model(&OrderBaseModels), queryOptions) 79 query := NewQuery(tx.Model(&OrderBaseModels), queryOptions)
80 query.SetWhere(`"order_base".partner_id= ?`, "partnerId"). 80 query.SetWhere(`"order_base".partner_id= ?`, "partnerId").
81 SetWhere(`"order_base".order_type= ?`, "orderType"). 81 SetWhere(`"order_base".order_type= ?`, "orderType").
82 - SetWhere(`"order_base".create_time >= ?`, "beginTime").  
83 - SetWhere(`"order_base".create_time < ?`, "endTime"). 82 + SetWhere(`"order_base".sale_date >= ?`, "beginTime").
  83 + SetWhere(`"order_base".sale_date < ?`, "endTime").
84 //SetWhere(`"order_base".is_disable = ?`, "isDisable"). 84 //SetWhere(`"order_base".is_disable = ?`, "isDisable").
85 SetLimit(). 85 SetLimit().
86 SetOrder(`order_base.create_time`, "sortByCreateTime"). 86 SetOrder(`order_base.create_time`, "sortByCreateTime").
87 - SetOrder(`order_base.update_time`, "sortByUpdateTime") 87 + SetOrder(`order_base.update_time`, "sortByUpdateTime").
  88 + SetOrder(`order_base.sale_date`, "sortBySalesTime")
88 if v, ok := queryOptions["orderTypes"]; ok { 89 if v, ok := queryOptions["orderTypes"]; ok {
89 query.Where(`"order_base".order_type in (?)`, pg.In(v)) 90 query.Where(`"order_base".order_type in (?)`, pg.In(v))
90 } 91 }
@@ -13,3 +13,25 @@ func GetDayEnd() time.Time { @@ -13,3 +13,25 @@ func GetDayEnd() time.Time {
13 nextDay := t.AddDate(0, 0, 1) 13 nextDay := t.AddDate(0, 0, 1)
14 return nextDay 14 return nextDay
15 } 15 }
  16 +
  17 +//获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。
  18 +func GetFirstDateOfMonth(d time.Time) time.Time {
  19 + d = d.AddDate(0, 0, -d.Day()+1)
  20 + return GetZeroTime(d)
  21 +}
  22 +
  23 +//获取传入的时间所在月份的最后一天,即某月最后一天的23:59:59。如传入time.Now(), 返回当前月份的最后一天的23:59:59。
  24 +func GetNextMonthFirstDay(d time.Time) time.Time {
  25 + d = GetFirstDateOfMonth(d).AddDate(0, 1, 0)
  26 + return GetZeroTime(d)
  27 +}
  28 +
  29 +//获取某一天的0点时间
  30 +func GetZeroTime(d time.Time) time.Time {
  31 + return time.Date(d.Year(), d.Month(), d.Day(), 0, 0, 0, 0, time.Local)
  32 +}
  33 +
  34 +//获取某一天的23点59分59秒
  35 +func GetNextDayZeroTime(d time.Time) time.Time {
  36 + return time.Date(d.Year(), d.Month(), d.Day(), 0, 0, 0, 0, time.Local).AddDate(0, 0, 1)
  37 +}
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 . "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" 5 . "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/middleware" 6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/middleware"
7 _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/routers" 7 _ "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/routers"
  8 + "time"
8 ) 9 )
9 10
10 func init() { 11 func init() {
@@ -15,4 +16,8 @@ func init() { @@ -15,4 +16,8 @@ func init() {
15 16
16 beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequstLogFilter(Logger)) 17 beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequstLogFilter(Logger))
17 beego.InsertFilter("/*", beego.AfterExec, middleware.CreateResponseLogFilter(Logger), false) 18 beego.InsertFilter("/*", beego.AfterExec, middleware.CreateResponseLogFilter(Logger), false)
  19 +
  20 + // 默认时区设置
  21 + timeLocal, _ := time.LoadLocation("Asia/Chongqing")
  22 + time.Local = timeLocal
18 } 23 }
@@ -2,5 +2,6 @@ package company @@ -2,5 +2,6 @@ package company
2 2
3 type PartnersResponse struct { 3 type PartnersResponse struct {
4 // 唯一标识 4 // 唯一标识
5 - Partners interface{} `json:"partners"` 5 + Partners interface{} `json:"partners"`
  6 + Timestamp int64 `json:"timestamp"`
6 } 7 }
@@ -9,14 +9,15 @@ const ( @@ -9,14 +9,15 @@ const (
9 9
10 /*DividendStatistics 分红统计*/ 10 /*DividendStatistics 分红统计*/
11 type DividendStatisticsRequest struct { 11 type DividendStatisticsRequest struct {
12 - StartTime int64 `json:"startTime" valid:"Required"`  
13 - EndTime int64 `json:"endTime" valid:"Required"` 12 + StartTime int64 `json:"startTime"`
  13 + EndTime int64 `json:"endTime"`
14 //分红类型(0累计分红、1分红支出) 14 //分红类型(0累计分红、1分红支出)
15 //DividendAction int `json:"dividendAction"` 15 //DividendAction int `json:"dividendAction"`
16 PartnerId int64 `json:"partnerId"` 16 PartnerId int64 `json:"partnerId"`
17 } 17 }
18 type DividendStatisticsResponse struct { 18 type DividendStatisticsResponse struct {
19 Statistics DividendStatistics `json:"statistics"` 19 Statistics DividendStatistics `json:"statistics"`
  20 + Timestamp int64 `json:"timestamp"`
20 } 21 }
21 22
22 type DividendStatistics struct { 23 type DividendStatistics struct {
@@ -41,7 +42,7 @@ type DividendOrdersRequest struct { @@ -41,7 +42,7 @@ type DividendOrdersRequest struct {
41 EndTime int64 `json:"endTime" valid:"Required"` 42 EndTime int64 `json:"endTime" valid:"Required"`
42 43
43 // 合作类型(空或不传,即所有类型) 44 // 合作类型(空或不传,即所有类型)
44 - JoinWays []*company.JoinWays `json:"joinWays"` 45 + JoinWays []*company.JoinWays `json:"joinWays"`
45 46
46 PageIndex int `json:"pageIndex,omitempty"` 47 PageIndex int `json:"pageIndex,omitempty"`
47 PageSize int `json:"pageSize,omitempty"` 48 PageSize int `json:"pageSize,omitempty"`
@@ -32,6 +32,7 @@ type OrderDetail struct { @@ -32,6 +32,7 @@ type OrderDetail struct {
32 OrderStatus int `json:"orderStatus"` //订单状态 1.待支付 2.已支付 3.已支付退货 4待支付退货 32 OrderStatus int `json:"orderStatus"` //订单状态 1.待支付 2.已支付 3.已支付退货 4待支付退货
33 CreateTime int64 `json:"createTime"` 33 CreateTime int64 `json:"createTime"`
34 UpdateTime int64 `json:"updateTime"` 34 UpdateTime int64 `json:"updateTime"`
  35 + SalesTime int64 `json:"salesTime"` // 销售日期
35 OrderDistrict interface{} `json:"orderDistrict"` 36 OrderDistrict interface{} `json:"orderDistrict"`
36 Customer Customer `json:"customer"` 37 Customer Customer `json:"customer"`
37 Products interface{} `json:"products"` 38 Products interface{} `json:"products"`
@@ -87,14 +88,15 @@ type OrderListRequest struct { @@ -87,14 +88,15 @@ type OrderListRequest struct {
87 PageSize int `json:"pageSize" valid:"Required"` 88 PageSize int `json:"pageSize" valid:"Required"`
88 OrderType int `json:"-"` 89 OrderType int `json:"-"`
89 OrderTypes []int `json:"-"` 90 OrderTypes []int `json:"-"`
90 -  
91 - PartnerId int64 `json:"partnerId"`  
92 - JoinWay int `json:"joinWay"` //合伙方式(0或不传,即所有合伙方式) 91 + IsToday bool `json:"isToday"`
  92 + PartnerId int64 `json:"partnerId"`
  93 + JoinWay int `json:"joinWay"` //合伙方式(0或不传,即所有合伙方式)
93 } 94 }
94 type OrderListResponse struct { 95 type OrderListResponse struct {
95 List []*OrderListItem `json:"list"` 96 List []*OrderListItem `json:"list"`
96 Statistics map[string]interface{} `json:"-"` 97 Statistics map[string]interface{} `json:"-"`
97 Total int `json:"total"` 98 Total int `json:"total"`
  99 + Timestamp int64 `json:"timestamp"`
98 } 100 }
99 101
100 type OrderListItem struct { 102 type OrderListItem struct {
@@ -117,7 +119,9 @@ type OrderListItem struct { @@ -117,7 +119,9 @@ type OrderListItem struct {
117 //订单金额 119 //订单金额
118 OrderAmount float64 `json:"orderAmount"` 120 OrderAmount float64 `json:"orderAmount"`
119 // 订单更新时间 121 // 订单更新时间
120 - UpdateTime int64 `json:"updateTime"` 122 + UpdateTime int64 `json:"updateTime"`
  123 + //销售时间
  124 + SalesTime int64 `json:"salesTime"`
121 //我的分红 125 //我的分红
122 MyDividend float64 `json:"dividendReceivable"` 126 MyDividend float64 `json:"dividendReceivable"`
123 //是否已读(0未读,1已读) 127 //是否已读(0未读,1已读)