作者 tangxvhui

Merge branch 'dev-tangxvhui' into test

@@ -26,3 +26,4 @@ opp @@ -26,3 +26,4 @@ opp
26 /*.exe~ 26 /*.exe~
27 logs 27 logs
28 tmp 28 tmp
  29 +/partner
@@ -3,7 +3,7 @@ runmode = "${RUN_MODE||dev}" @@ -3,7 +3,7 @@ runmode = "${RUN_MODE||dev}"
3 httpport = "${HTTP_PORT||8082}" 3 httpport = "${HTTP_PORT||8082}"
4 4
5 #开启https 5 #开启https
6 -EnableHTTPS = true 6 +EnableHTTPS = false
7 HTTPSPort = "443" 7 HTTPSPort = "443"
8 HTTPSCertFile = "conf/fjmaimaimai.com_pem.crt" 8 HTTPSCertFile = "conf/fjmaimaimai.com_pem.crt"
9 HTTPSKeyFile = "conf/fjmaimaimai.com_rsa.key" 9 HTTPSKeyFile = "conf/fjmaimaimai.com_rsa.key"
@@ -3,24 +3,24 @@ module gitlab.fjmaimaimai.com/mmm-go/partner @@ -3,24 +3,24 @@ module gitlab.fjmaimaimai.com/mmm-go/partner
3 go 1.14 3 go 1.14
4 4
5 require ( 5 require (
6 - github.com/Shopify/sarama v1.26.4 6 + github.com/Shopify/sarama v1.38.1
7 github.com/ajg/form v1.5.1 // indirect 7 github.com/ajg/form v1.5.1 // indirect
8 github.com/astaxie/beego v1.12.3 8 github.com/astaxie/beego v1.12.3
9 github.com/dgrijalva/jwt-go v3.2.0+incompatible 9 github.com/dgrijalva/jwt-go v3.2.0+incompatible
10 github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect 10 github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
11 github.com/gavv/httpexpect v2.0.0+incompatible 11 github.com/gavv/httpexpect v2.0.0+incompatible
12 - github.com/gin-gonic/gin v1.5.0  
13 - github.com/go-pg/pg/v10 v10.0.0-beta.2 12 + github.com/gin-gonic/gin v1.9.1
  13 + github.com/go-pg/pg/v10 v10.11.2
14 github.com/imkira/go-interpol v1.1.0 // indirect 14 github.com/imkira/go-interpol v1.1.0 // indirect
15 github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect 15 github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88 // indirect
16 github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9 16 github.com/linmadan/egglib-go v0.0.0-20191217144343-ca4539f95bf9
17 github.com/moul/http2curl v1.0.0 // indirect 17 github.com/moul/http2curl v1.0.0 // indirect
18 - github.com/onsi/ginkgo v1.15.0  
19 - github.com/onsi/gomega v1.10.5  
20 - github.com/sergi/go-diff v1.1.0 // indirect  
21 - github.com/shopspring/decimal v1.2.0 18 + github.com/onsi/ginkgo v1.16.5
  19 + github.com/onsi/gomega v1.30.0
  20 + github.com/sergi/go-diff v1.3.1 // indirect
  21 + github.com/shopspring/decimal v1.3.1
22 github.com/tiptok/gocomm v1.0.5 22 github.com/tiptok/gocomm v1.0.5
23 - github.com/valyala/fasthttp v1.19.0 // indirect 23 + github.com/valyala/fasthttp v1.50.0 // indirect
24 github.com/xeipuuv/gojsonschema v1.2.0 // indirect 24 github.com/xeipuuv/gojsonschema v1.2.0 // indirect
25 github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect 25 github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
26 github.com/yudai/gojsondiff v1.0.0 // indirect 26 github.com/yudai/gojsondiff v1.0.0 // indirect
不能预览此文件类型
@@ -2,12 +2,13 @@ package dividend @@ -2,12 +2,13 @@ package dividend
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "time"
  6 +
5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" 9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" 10 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" 11 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
10 - "time"  
11 ) 12 )
12 13
13 // 分红统计 14 // 分红统计
@@ -25,7 +26,13 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis @@ -25,7 +26,13 @@ func Statistics(header *protocol.RequestHeader, request *protocol.DividendStatis
25 }() 26 }()
26 27
27 // 事业分红统计-查询订单 28 // 事业分红统计-查询订单
28 - _, orderAll, e := OrderBaseResponsitory.Find(utils.ObjectJsonToMap(domain.OrderQueryOption{PartnerId: request.PartnerId, EndTime: utils.GetDayEnd(), SortBySalesTime: domain.DESC, OrderTypes: domain.UserOrderTypes(domain.Career)})) 29 + _, orderAll, e := OrderBaseResponsitory.Find(utils.ObjectJsonToMap(
  30 + domain.OrderQueryOption{
  31 + PartnerId: request.PartnerId,
  32 + EndTime: utils.GetDayEnd(),
  33 + SortBySalesTime: domain.DESC,
  34 + OrderTypes: domain.UserOrderTypes(domain.Career),
  35 + }))
29 if e != nil { 36 if e != nil {
30 log.Error(e) 37 log.Error(e)
31 } 38 }
@@ -122,8 +129,8 @@ func AllBonusStatics(orders []*domain.OrderBase, action int) (bonus protocol.Bon @@ -122,8 +129,8 @@ func AllBonusStatics(orders []*domain.OrderBase, action int) (bonus protocol.Bon
122 } 129 }
123 130
124 // 订单-季度分红统计 131 // 订单-季度分红统计
125 -func QuartersBonusStatics(orders []*domain.OrderBase, action int) (bonus []protocol.Bonus) {  
126 - bonus = make([]protocol.Bonus, 4) 132 +func QuartersBonusStatics(orders []*domain.OrderBase, action int) (bonus [4]protocol.Bonus) {
  133 + bonus = [4]protocol.Bonus{}
127 for i := range orders { 134 for i := range orders {
128 o := orders[i] 135 o := orders[i]
129 quarter := quarter(o.SaleDate) 136 quarter := quarter(o.SaleDate)
  1 +package dividend
  2 +
  3 +import (
  4 + "fmt"
  5 + "time"
  6 +
  7 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory"
  8 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
  9 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
  10 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
  11 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
  12 +)
  13 +
  14 +// 分红统计
  15 +func StatisticsV2(header *protocol.RequestHeader, request *protocol.DividendStatisticsRequest) (rsp *protocol.DividendStatisticsV2Response, err error) {
  16 + var (
  17 + transactionContext, _ = factory.CreateTransactionContext(nil)
  18 + OrderBaseResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext)
  19 + )
  20 + if err = transactionContext.StartTransaction(); err != nil {
  21 + return nil, err
  22 + }
  23 + defer func() {
  24 + transactionContext.RollbackTransaction()
  25 + }()
  26 +
  27 + // 事业分红统计-查询订单
  28 + _, orderAll, e := OrderBaseResponsitory.Find(utils.ObjectJsonToMap(
  29 + domain.OrderQueryOption{
  30 + PartnerId: request.PartnerId,
  31 + EndTime: utils.GetDayEnd(),
  32 + SortBySalesTime: domain.DESC,
  33 + OrderTypes: domain.UserOrderTypes(domain.Career),
  34 + }))
  35 + if e != nil {
  36 + log.Error(e)
  37 + }
  38 + err = transactionContext.CommitTransaction()
  39 + if err != nil {
  40 + return nil, err
  41 + }
  42 + //获取营销年
  43 + t := time.Now()
  44 + var last time.Time
  45 + var first time.Time
  46 + boundDate := time.Date(t.Year(), time.March, 31, 23, 59, 59, 0, time.Local) // 营销年界限
  47 + fmt.Println("营销年界限:", boundDate)
  48 + if t.Before(boundDate) || t.Equal(boundDate) {
  49 + first = time.Date(t.Year()-1, time.April, 1, 0, 0, 0, 0, time.Local)
  50 + last = time.Date(t.Year(), time.March, 31, 23, 59, 59, 0, time.Local)
  51 + } else if t.After(boundDate) {
  52 + first = time.Date(t.Year(), time.April, 1, 0, 0, 0, 0, time.Local)
  53 + last = time.Date(t.Year()+1, time.March, 31, 23, 59, 59, 0, time.Local)
  54 + }
  55 + fmt.Println("当前营销年起始:", first, last)
  56 + // 请求开始时间和结束时间都为0时,默认从营销年开始统计
  57 + if request.StartTime == 0 && request.EndTime == 0 {
  58 + request.StartTime = first.Unix() * 1000
  59 + request.EndTime = last.Unix() * 1000
  60 + } else if request.StartTime > 0 && request.EndTime > 0 { // 判断结束时间是否超过今天,超过今天的结束时间到今天为止
  61 + currentDayEnd := utils.GetDayEnd().Unix() * 1000
  62 + if request.EndTime >= currentDayEnd {
  63 + request.EndTime = currentDayEnd
  64 + }
  65 + }
  66 +
  67 + fmt.Println("StartTime: ", request.StartTime)
  68 + fmt.Println("EndTime: ", request.EndTime)
  69 +
  70 + var orderBetween []*domain.OrderBase
  71 + for i := range orderAll {
  72 + if orderAll[i].SaleDate.Unix() >= (request.StartTime/1000) && orderAll[i].SaleDate.Unix() < (request.EndTime/1000) {
  73 + orderBetween = append(orderBetween, orderAll[i])
  74 + }
  75 + }
  76 + //0:全部分类,
  77 + //Career int = 1 //事业
  78 + //Business int = 2 //业务
  79 + //Develop int = 3 //研发
  80 + //App int = 4 //业务产品-应用
  81 + //累计分红
  82 + var (
  83 + bonusAll protocol.Bonus
  84 + bonusAllCareer protocol.Bonus
  85 + bonusAllBusiness protocol.Bonus
  86 + bonusAllDevelop protocol.Bonus
  87 + bonusAllApp protocol.Bonus
  88 + )
  89 + for _, val := range orderAll {
  90 + static := val.OrderBonusStatic()
  91 + bonusAll.Received = utils.Decimal(bonusAll.Received + static.OrderBonusReceive())
  92 + bonusAll.Outstanding = utils.Decimal(bonusAll.Outstanding + static.OrderBonusWait())
  93 + bonusAll.Receivable = utils.Decimal(bonusAll.Receivable + static.OrderTotalReceivable())
  94 + if val.PartnerCategory == nil {
  95 + continue
  96 + }
  97 + switch val.PartnerCategory.Id {
  98 + case int64(domain.Career):
  99 + bonusAllCareer.Received = utils.Decimal(bonusAllCareer.Received + static.OrderBonusReceive())
  100 + bonusAllCareer.Outstanding = utils.Decimal(bonusAllCareer.Outstanding + static.OrderBonusWait())
  101 + bonusAllCareer.Receivable = utils.Decimal(bonusAllCareer.Receivable + static.OrderTotalReceivable())
  102 + case int64(domain.Business):
  103 + bonusAllBusiness.Received = utils.Decimal(bonusAllBusiness.Received + static.OrderBonusReceive())
  104 + bonusAllBusiness.Outstanding = utils.Decimal(bonusAllBusiness.Outstanding + static.OrderBonusWait())
  105 + bonusAllBusiness.Receivable = utils.Decimal(bonusAllBusiness.Receivable + static.OrderTotalReceivable())
  106 + case int64(domain.App):
  107 + bonusAllApp.Received = utils.Decimal(bonusAllApp.Received + static.OrderBonusReceive())
  108 + bonusAllApp.Outstanding = utils.Decimal(bonusAllApp.Outstanding + static.OrderBonusWait())
  109 + bonusAllApp.Receivable = utils.Decimal(bonusAllApp.Receivable + static.OrderTotalReceivable())
  110 + case int64(domain.Develop):
  111 + bonusAllDevelop.Received = utils.Decimal(bonusAllDevelop.Received + static.OrderBonusReceive())
  112 + bonusAllDevelop.Outstanding = utils.Decimal(bonusAllDevelop.Outstanding + static.OrderBonusWait())
  113 + bonusAllDevelop.Receivable = utils.Decimal(bonusAllDevelop.Receivable + static.OrderTotalReceivable())
  114 + }
  115 + }
  116 + //0:全部分类,
  117 + //Career int = 1 //事业
  118 + //Business int = 2 //业务
  119 + //Develop int = 3 //研发
  120 + //App int = 4 //业务产品-应用
  121 + //季度分红
  122 + var (
  123 + bonusQuarters = [4]protocol.Bonus{}
  124 + bonusQuartersCareer = [4]protocol.Bonus{}
  125 + bonusQuartersBusiness = [4]protocol.Bonus{}
  126 + bonusQuartersDevelop = [4]protocol.Bonus{}
  127 + bonusQuartersApp = [4]protocol.Bonus{}
  128 + )
  129 + //月度分红
  130 + var (
  131 + bonusMonths = [12]protocol.Bonus{}
  132 + bonusMonthsCareer = [12]protocol.Bonus{}
  133 + bonusMonthsBusiness = [12]protocol.Bonus{}
  134 + bonusMonthsDevelop = [12]protocol.Bonus{}
  135 + bonusMonthsApp = [12]protocol.Bonus{}
  136 + )
  137 + var (
  138 + quarterNum int // 对应季度在数组中的位置
  139 + monthNum int //对应月份在数组中的位置
  140 + )
  141 + for _, val := range orderBetween {
  142 + quarterNum = quarter(val.SaleDate)
  143 + monthNum = int(val.SaleDate.Month()) - 1
  144 + static := val.OrderBonusStatic()
  145 + bonusQuarters[quarterNum].Receivable = utils.Decimal(bonusQuarters[quarterNum].Receivable + static.OrderTotalReceivable())
  146 + bonusQuarters[quarterNum].Received = utils.Decimal(bonusQuarters[quarterNum].Received + static.OrderBonusReceive())
  147 + bonusQuarters[quarterNum].Outstanding = utils.Decimal(bonusQuarters[quarterNum].Outstanding + static.OrderBonusWait())
  148 +
  149 + bonusMonths[monthNum].Receivable = utils.Decimal(bonusMonths[monthNum].Receivable + static.OrderTotalReceivable())
  150 + bonusMonths[monthNum].Received = utils.Decimal(bonusMonths[monthNum].Received + static.OrderBonusReceive())
  151 + bonusMonths[monthNum].Outstanding = utils.Decimal(bonusMonths[monthNum].Outstanding + static.OrderBonusWait())
  152 + if val.PartnerCategory == nil {
  153 + continue
  154 + }
  155 + // 分类合并计数
  156 + switch val.PartnerCategory.Id {
  157 + case int64(domain.Career):
  158 + bonusQuartersCareer[quarterNum].Receivable = utils.Decimal(bonusQuartersCareer[quarterNum].Receivable + static.OrderTotalReceivable())
  159 + bonusQuartersCareer[quarterNum].Received = utils.Decimal(bonusQuartersCareer[quarterNum].Received + static.OrderBonusReceive())
  160 + bonusQuartersCareer[quarterNum].Outstanding = utils.Decimal(bonusQuartersCareer[quarterNum].Outstanding + static.OrderBonusWait())
  161 +
  162 + bonusMonthsCareer[monthNum].Receivable = utils.Decimal(bonusMonthsCareer[monthNum].Receivable + static.OrderTotalReceivable())
  163 + bonusMonthsCareer[monthNum].Received = utils.Decimal(bonusMonthsCareer[monthNum].Received + static.OrderBonusReceive())
  164 + bonusMonthsCareer[monthNum].Outstanding = utils.Decimal(bonusMonthsCareer[monthNum].Outstanding + static.OrderBonusWait())
  165 + case int64(domain.Business):
  166 + bonusQuartersBusiness[quarterNum].Receivable = utils.Decimal(bonusQuartersBusiness[quarterNum].Receivable + static.OrderTotalReceivable())
  167 + bonusQuartersBusiness[quarterNum].Received = utils.Decimal(bonusQuartersBusiness[quarterNum].Received + static.OrderBonusReceive())
  168 + bonusQuartersBusiness[quarterNum].Outstanding = utils.Decimal(bonusQuartersBusiness[quarterNum].Outstanding + static.OrderBonusWait())
  169 +
  170 + bonusMonthsBusiness[monthNum].Receivable = utils.Decimal(bonusMonthsBusiness[monthNum].Receivable + static.OrderTotalReceivable())
  171 + bonusMonthsBusiness[monthNum].Received = utils.Decimal(bonusMonthsBusiness[monthNum].Received + static.OrderBonusReceive())
  172 + bonusMonthsBusiness[monthNum].Outstanding = utils.Decimal(bonusMonthsBusiness[monthNum].Outstanding + static.OrderBonusWait())
  173 + case int64(domain.App):
  174 + bonusQuartersApp[quarterNum].Receivable = utils.Decimal(bonusQuartersApp[quarterNum].Receivable + static.OrderTotalReceivable())
  175 + bonusQuartersApp[quarterNum].Received = utils.Decimal(bonusQuartersApp[quarterNum].Received + static.OrderBonusReceive())
  176 + bonusQuartersApp[quarterNum].Outstanding = utils.Decimal(bonusQuartersApp[quarterNum].Outstanding + static.OrderBonusWait())
  177 +
  178 + bonusMonthsApp[monthNum].Receivable = utils.Decimal(bonusMonthsApp[monthNum].Receivable + static.OrderTotalReceivable())
  179 + bonusMonthsApp[monthNum].Received = utils.Decimal(bonusMonthsApp[monthNum].Received + static.OrderBonusReceive())
  180 + bonusMonthsApp[monthNum].Outstanding = utils.Decimal(bonusMonthsApp[monthNum].Outstanding + static.OrderBonusWait())
  181 + case int64(domain.Develop):
  182 + bonusQuartersDevelop[quarterNum].Receivable = utils.Decimal(bonusQuartersDevelop[quarterNum].Receivable + static.OrderTotalReceivable())
  183 + bonusQuartersDevelop[quarterNum].Received = utils.Decimal(bonusQuartersDevelop[quarterNum].Received + static.OrderBonusReceive())
  184 + bonusQuartersDevelop[quarterNum].Outstanding = utils.Decimal(bonusQuartersDevelop[quarterNum].Outstanding + static.OrderBonusWait())
  185 +
  186 + bonusMonthsDevelop[monthNum].Receivable = utils.Decimal(bonusMonthsDevelop[monthNum].Receivable + static.OrderTotalReceivable())
  187 + bonusMonthsDevelop[monthNum].Received = utils.Decimal(bonusMonthsDevelop[monthNum].Received + static.OrderBonusReceive())
  188 + bonusMonthsDevelop[monthNum].Outstanding = utils.Decimal(bonusMonthsDevelop[monthNum].Outstanding + static.OrderBonusWait())
  189 + }
  190 + }
  191 + // 整理输出数据
  192 + rsp = &protocol.DividendStatisticsV2Response{
  193 + Statistics: protocol.DividendStatistics{
  194 + Received: bonusAll.Received,
  195 + Outstanding: bonusAll.Outstanding,
  196 + Receivable: bonusAll.Receivable,
  197 + Quarters: bonusQuarters,
  198 + Months: bonusMonths,
  199 + },
  200 + StatisticsCareer: protocol.DividendStatistics{
  201 + Received: bonusAllCareer.Receivable,
  202 + Outstanding: bonusAllCareer.Outstanding,
  203 + Receivable: bonusAllCareer.Receivable,
  204 + Quarters: bonusQuartersCareer,
  205 + Months: bonusMonthsCareer,
  206 + },
  207 + StatisticsBusiness: protocol.DividendStatistics{
  208 + Received: bonusAllBusiness.Receivable,
  209 + Outstanding: bonusAllBusiness.Outstanding,
  210 + Receivable: bonusAllBusiness.Receivable,
  211 + Quarters: bonusQuartersBusiness,
  212 + Months: bonusMonthsBusiness,
  213 + },
  214 + StatisticsDevelop: protocol.DividendStatistics{
  215 + Received: bonusAllDevelop.Received,
  216 + Outstanding: bonusAllDevelop.Outstanding,
  217 + Receivable: bonusAllDevelop.Receivable,
  218 + Quarters: bonusQuartersDevelop,
  219 + Months: bonusMonthsDevelop,
  220 + },
  221 + StatisticsApp: protocol.DividendStatistics{
  222 + Received: bonusAllApp.Received,
  223 + Outstanding: bonusAllApp.Outstanding,
  224 + Receivable: bonusAllApp.Receivable,
  225 + Quarters: bonusQuartersApp,
  226 + Months: bonusMonthsApp,
  227 + },
  228 + Timestamp: 0,
  229 + }
  230 + rsp.Timestamp = time.Now().Unix() * 1000
  231 +
  232 + return
  233 +}
@@ -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 = "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 7 +var POSTGRESQL_PASSWORD = "eagle1010" //pgsql@123/1993618jack/eagle1010
  8 +var POSTGRESQL_HOST = "114.55.200.59" //127.0.0.1/114.55.200.59
  9 +var POSTGRESQL_PORT = "31543" //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
@@ -25,8 +25,8 @@ func (m *PartnerCategoryInfo) Identify() interface{} { @@ -25,8 +25,8 @@ func (m *PartnerCategoryInfo) Identify() interface{} {
25 } 25 }
26 26
27 const ( 27 const (
28 - Career = iota + 1  
29 - Business  
30 - Develop  
31 - App 28 + Career int = 1 //事业
  29 + Business int = 2 //业务
  30 + Develop int = 3 //研发
  31 + App int = 4 //业务产品-应用
32 ) 32 )
@@ -2,6 +2,9 @@ package domain_service @@ -2,6 +2,9 @@ package domain_service
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "strings"
  6 + "time"
  7 +
5 "github.com/tiptok/gocomm/xa/eda" 8 "github.com/tiptok/gocomm/xa/eda"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" 9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 10 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
@@ -14,8 +17,6 @@ import ( @@ -14,8 +17,6 @@ import (
14 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log" 17 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/log"
15 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" 18 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
16 protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth" 19 protocolx "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/auth"
17 - "strings"  
18 - "time"  
19 ) 20 )
20 21
21 type PgLoginService struct { 22 type PgLoginService struct {
@@ -182,7 +183,7 @@ func (svr *PgLoginService) PartnerLogin(phone string, password string) (err erro @@ -182,7 +183,7 @@ func (svr *PgLoginService) PartnerLogin(phone string, password string) (err erro
182 return 183 return
183 } 184 }
184 185
185 -//管理层登录 186 +// 管理层登录
186 func (svr *PgLoginService) ManagerLogin(phone string, password string) (err error) { 187 func (svr *PgLoginService) ManagerLogin(phone string, password string) (err error) {
187 if len(svr.Users) == 0 { 188 if len(svr.Users) == 0 {
188 //子账号 189 //子账号
@@ -198,7 +199,7 @@ func (svr *PgLoginService) ManagerLogin(phone string, password string) (err erro @@ -198,7 +199,7 @@ func (svr *PgLoginService) ManagerLogin(phone string, password string) (err erro
198 return 199 return
199 } 200 }
200 201
201 -//合伙人统计信息 202 +// 合伙人统计信息
202 func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) { 203 func (svr *PgLoginService) PartnerStaticInfo() (interface{}, error) {
203 response := make(map[string]interface{}) 204 response := make(map[string]interface{})
204 response["id"] = protocolx.AdminTypePartner 205 response["id"] = protocolx.AdminTypePartner
@@ -564,7 +565,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -564,7 +565,7 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
564 // 用户在正常公司存在且无效或者存在非高管或者不存在、合伙人在正常公司存在且无效或者不存在、合伙人在游客公司不存在、注册合伙人到游客公司 565 // 用户在正常公司存在且无效或者存在非高管或者不存在、合伙人在正常公司存在且无效或者不存在、合伙人在游客公司不存在、注册合伙人到游客公司
565 if !isGuestPartner && (isUser && !isUserAvailable || isUser && !isUserSenior || !isUser) && (isPartner && !isPartnerAvailable || !isPartner) { 566 if !isGuestPartner && (isUser && !isUserAvailable || isUser && !isUserSenior || !isUser) && (isPartner && !isPartnerAvailable || !isPartner) {
566 id := time.Now().Unix() 567 id := time.Now().Unix()
567 - errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{ 568 + m := &models.PartnerInfo{
568 Id: id, 569 Id: id,
569 CompanyId: int64(constant.DEFAULT_GUEST_COMPANY), 570 CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
570 PartnerName: phone, 571 PartnerName: phone,
@@ -581,14 +582,16 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -581,14 +582,16 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
581 UpdateAt: time.Now(), 582 UpdateAt: time.Now(),
582 PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}}, 583 PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
583 Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}}, 584 Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
584 - }) 585 + }
  586 + _, errPartner = svr.transactionContext.PgDd.Model(m).Insert()
585 } 587 }
586 588
587 // 合伙人不存在、用户存在、非高管(普通用户)-> 注册用户 589 // 合伙人不存在、用户存在、非高管(普通用户)-> 注册用户
588 // 合伙人不存在、用户不存在(游客)-> 注册用户 590 // 合伙人不存在、用户不存在(游客)-> 注册用户
589 if errPartner != nil && errUser == nil { 591 if errPartner != nil && errUser == nil {
590 id := time.Now().Unix() 592 id := time.Now().Unix()
591 - errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{ 593 +
  594 + m := &models.PartnerInfo{
592 Id: id, 595 Id: id,
593 CompanyId: int64(constant.DEFAULT_GUEST_COMPANY), 596 CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
594 PartnerName: phone, 597 PartnerName: phone,
@@ -605,7 +608,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error { @@ -605,7 +608,8 @@ func (svr *PgLoginService) RegistryUser(phone string) error {
605 UpdateAt: time.Now(), 608 UpdateAt: time.Now(),
606 PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}}, 609 PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
607 Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}}, 610 Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
608 - }) 611 + }
  612 + _, errPartner = svr.transactionContext.PgDd.Model(&m).Insert()
609 } 613 }
610 614
611 return errPartner 615 return errPartner
@@ -688,7 +692,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { @@ -688,7 +692,7 @@ func (svr *PgLoginService) RegistryGuest(phone string) error {
688 // 注册用户 692 // 注册用户
689 if errUser != nil && errPartner != nil { 693 if errUser != nil && errPartner != nil {
690 id := time.Now().Unix() 694 id := time.Now().Unix()
691 - errPartner = svr.transactionContext.PgDd.Insert(&models.PartnerInfo{ 695 + m := &models.PartnerInfo{
692 Id: id, 696 Id: id,
693 CompanyId: int64(constant.DEFAULT_GUEST_COMPANY), 697 CompanyId: int64(constant.DEFAULT_GUEST_COMPANY),
694 PartnerName: phone, 698 PartnerName: phone,
@@ -705,7 +709,8 @@ func (svr *PgLoginService) RegistryGuest(phone string) error { @@ -705,7 +709,8 @@ func (svr *PgLoginService) RegistryGuest(phone string) error {
705 UpdateAt: time.Now(), 709 UpdateAt: time.Now(),
706 PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}}, 710 PartnerCategoryInfos: []*domain.PartnerCategoryInfo{{Id: 1, Code: phone}},
707 Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}}, 711 Salesman: []*domain.Salesman{{Name: phone, Telephone: phone}},
708 - }) 712 + }
  713 + _, errPartner = svr.transactionContext.PgDd.Model(m).Insert()
709 } 714 }
710 715
711 // 删除用户 716 // 删除用户
@@ -3,6 +3,7 @@ package pg @@ -3,6 +3,7 @@ package pg
3 import ( 3 import (
4 "context" 4 "context"
5 "fmt" 5 "fmt"
  6 +
6 "github.com/go-pg/pg/v10" 7 "github.com/go-pg/pg/v10"
7 "github.com/go-pg/pg/v10/orm" 8 "github.com/go-pg/pg/v10/orm"
8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant" 9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
@@ -38,7 +39,7 @@ func init() { @@ -38,7 +39,7 @@ func init() {
38 (*models.PartnerCategoryInfo)(nil), 39 (*models.PartnerCategoryInfo)(nil),
39 (*models.Users)(nil), 40 (*models.Users)(nil),
40 } { 41 } {
41 - err := DB.CreateTable(model, &orm.CreateTableOptions{ 42 + err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
42 Temp: false, 43 Temp: false,
43 IfNotExists: true, 44 IfNotExists: true,
44 FKConstraints: true, 45 FKConstraints: true,
@@ -2,6 +2,7 @@ package repository @@ -2,6 +2,7 @@ package repository
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 +
5 "github.com/go-pg/pg/v10" 6 "github.com/go-pg/pg/v10"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models"
@@ -23,12 +24,12 @@ func (repository *BusinessBonusRepository) Save(dm *domain.BusinessBonus) (*doma @@ -23,12 +24,12 @@ func (repository *BusinessBonusRepository) Save(dm *domain.BusinessBonus) (*doma
23 return nil, err 24 return nil, err
24 } 25 }
25 if dm.Identify() == nil { 26 if dm.Identify() == nil {
26 - if err = tx.Insert(m); err != nil { 27 + if _, err = tx.Model(m).Returning("*").Insert(); err != nil {
27 return nil, err 28 return nil, err
28 } 29 }
29 return dm, nil 30 return dm, nil
30 } 31 }
31 - if err = tx.Update(m); err != nil { 32 + if _, err = tx.Model(m).Update(m); err != nil {
32 return nil, err 33 return nil, err
33 } 34 }
34 return dm, nil 35 return dm, nil
@@ -22,12 +22,12 @@ func (repository *CompanyRepository) Save(dm *domain.Company) (*domain.Company, @@ -22,12 +22,12 @@ func (repository *CompanyRepository) Save(dm *domain.Company) (*domain.Company,
22 return nil, err 22 return nil, err
23 } 23 }
24 if dm.Id == 0 { 24 if dm.Id == 0 {
25 - if err = tx.Insert(m); err != nil { 25 + if _, err = tx.Model(m).Returning("*").Insert(); err != nil {
26 return nil, err 26 return nil, err
27 } 27 }
28 return dm, nil 28 return dm, nil
29 } 29 }
30 - if err = tx.Update(m); err != nil { 30 + if _, err = tx.Model(m).Update(m); err != nil {
31 return nil, err 31 return nil, err
32 } 32 }
33 return dm, nil 33 return dm, nil
@@ -21,12 +21,12 @@ func (repository *ImCustomerServiceRepository) Save(dm *domain.ImCustomerService @@ -21,12 +21,12 @@ func (repository *ImCustomerServiceRepository) Save(dm *domain.ImCustomerService
21 return nil, err 21 return nil, err
22 } 22 }
23 if dm.Identify() == nil { 23 if dm.Identify() == nil {
24 - if err = tx.Insert(m); err != nil { 24 + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil {
25 return nil, err 25 return nil, err
26 } 26 }
27 return dm, nil 27 return dm, nil
28 } 28 }
29 - if err = tx.Update(m); err != nil { 29 + if _, err = tx.Model(m).Update(m); err != nil {
30 return nil, err 30 return nil, err
31 } 31 }
32 return dm, nil 32 return dm, nil
@@ -21,12 +21,12 @@ func (repository *ImInfoRepository) Save(dm *domain.ImInfo) (*domain.ImInfo, err @@ -21,12 +21,12 @@ func (repository *ImInfoRepository) Save(dm *domain.ImInfo) (*domain.ImInfo, err
21 return nil, err 21 return nil, err
22 } 22 }
23 if dm.Identify() == nil { 23 if dm.Identify() == nil {
24 - if err = tx.Insert(m); err != nil { 24 + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil {
25 return nil, err 25 return nil, err
26 } 26 }
27 return dm, nil 27 return dm, nil
28 } 28 }
29 - if err = tx.Update(m); err != nil { 29 + if _, err = tx.Model(m).Update(m); err != nil {
30 return nil, err 30 return nil, err
31 } 31 }
32 return dm, nil 32 return dm, nil
@@ -2,6 +2,7 @@ package repository @@ -2,6 +2,7 @@ package repository
2 2
3 import ( 3 import (
4 "encoding/json" 4 "encoding/json"
  5 +
5 "github.com/go-pg/pg/v10" 6 "github.com/go-pg/pg/v10"
6 "github.com/go-pg/pg/v10/orm" 7 "github.com/go-pg/pg/v10/orm"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
@@ -28,12 +29,12 @@ func (repository *OrderBaseRepository) Save(dm *domain.OrderBase) (*domain.Order @@ -28,12 +29,12 @@ func (repository *OrderBaseRepository) Save(dm *domain.OrderBase) (*domain.Order
28 // return dm, err 29 // return dm, err
29 //} 30 //}
30 //m.Id = dm.Id 31 //m.Id = dm.Id
31 - if err = tx.Insert(m); err != nil { 32 + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil {
32 return nil, err 33 return nil, err
33 } 34 }
34 return dm, nil 35 return dm, nil
35 } 36 }
36 - if err = tx.Update(m); err != nil { 37 + if _, err = tx.Model(m).Update(m); err != nil {
37 return nil, err 38 return nil, err
38 } 39 }
39 return dm, nil 40 return dm, nil
@@ -25,12 +25,12 @@ func (repository *OrderGoodRepository) Save(dm *domain.OrderGood) (*domain.Order @@ -25,12 +25,12 @@ func (repository *OrderGoodRepository) Save(dm *domain.OrderGood) (*domain.Order
25 // return dm, err 25 // return dm, err
26 //} 26 //}
27 //m.Id = dm.Id 27 //m.Id = dm.Id
28 - if err = tx.Insert(m); err != nil { 28 + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil {
29 return nil, err 29 return nil, err
30 } 30 }
31 return dm, nil 31 return dm, nil
32 } 32 }
33 - if err = tx.Update(m); err != nil { 33 + if _, err = tx.Model(m).Update(m); err != nil {
34 return nil, err 34 return nil, err
35 } 35 }
36 return dm, nil 36 return dm, nil
@@ -2,6 +2,7 @@ package repository @@ -2,6 +2,7 @@ package repository
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 +
5 "github.com/go-pg/pg/v10" 6 "github.com/go-pg/pg/v10"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models"
@@ -23,12 +24,12 @@ func (repository *PartnerCategoryInfoRepository) Save(dm *domain.PartnerCategory @@ -23,12 +24,12 @@ func (repository *PartnerCategoryInfoRepository) Save(dm *domain.PartnerCategory
23 return nil, err 24 return nil, err
24 } 25 }
25 if dm.Identify() == nil { 26 if dm.Identify() == nil {
26 - if err = tx.Insert(m); err != nil { 27 + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil {
27 return nil, err 28 return nil, err
28 } 29 }
29 return dm, nil 30 return dm, nil
30 } 31 }
31 - if err = tx.Update(m); err != nil { 32 + if _, err = tx.Model(m).Update(m); err != nil {
32 return nil, err 33 return nil, err
33 } 34 }
34 return dm, nil 35 return dm, nil
@@ -27,12 +27,12 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.P @@ -27,12 +27,12 @@ func (repository *PartnerInfoRepository) Save(dm *domain.PartnerInfo) (*domain.P
27 // return dm, err 27 // return dm, err
28 //} 28 //}
29 //m.Id = dm.Id 29 //m.Id = dm.Id
30 - if err = tx.Insert(m); err != nil { 30 + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil {
31 return nil, err 31 return nil, err
32 } 32 }
33 return dm, nil 33 return dm, nil
34 } 34 }
35 - if err = tx.Update(m); err != nil { 35 + if _, err = tx.Model(m).Update(m); err != nil {
36 return nil, err 36 return nil, err
37 } 37 }
38 return dm, nil 38 return dm, nil
@@ -25,12 +25,12 @@ func (repository *PartnerSubAccountRepository) Save(dm *domain.PartnerSubAccount @@ -25,12 +25,12 @@ func (repository *PartnerSubAccountRepository) Save(dm *domain.PartnerSubAccount
25 return dm, err 25 return dm, err
26 } 26 }
27 m.Id = dm.Id 27 m.Id = dm.Id
28 - if err = tx.Insert(m); err != nil { 28 + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil {
29 return nil, err 29 return nil, err
30 } 30 }
31 return dm, nil 31 return dm, nil
32 } 32 }
33 - if err = tx.Update(m); err != nil { 33 + if _, err = tx.Model(m).Update(m); err != nil {
34 return nil, err 34 return nil, err
35 } 35 }
36 return dm, nil 36 return dm, nil
@@ -2,6 +2,7 @@ package repository @@ -2,6 +2,7 @@ package repository
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 +
5 "github.com/tiptok/gocomm/common" 6 "github.com/tiptok/gocomm/common"
6 . "github.com/tiptok/gocomm/pkg/orm/pgx" 7 . "github.com/tiptok/gocomm/pkg/orm/pgx"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
@@ -23,12 +24,12 @@ func (repository *SysMessageConsumeRepository) Save(dm *domain.SysMessageConsume @@ -23,12 +24,12 @@ func (repository *SysMessageConsumeRepository) Save(dm *domain.SysMessageConsume
23 return nil, err 24 return nil, err
24 } 25 }
25 if dm.Identify() == nil { 26 if dm.Identify() == nil {
26 - if err = tx.Insert(m); err != nil { 27 + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil {
27 return nil, err 28 return nil, err
28 } 29 }
29 return dm, nil 30 return dm, nil
30 } 31 }
31 - if err = tx.Update(m); err != nil { 32 + if _, err = tx.Model(m).Update(m); err != nil {
32 return nil, err 33 return nil, err
33 } 34 }
34 return dm, nil 35 return dm, nil
@@ -2,6 +2,7 @@ package repository @@ -2,6 +2,7 @@ package repository
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 +
5 "github.com/tiptok/gocomm/common" 6 "github.com/tiptok/gocomm/common"
6 . "github.com/tiptok/gocomm/pkg/orm/pgx" 7 . "github.com/tiptok/gocomm/pkg/orm/pgx"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
@@ -23,7 +24,7 @@ func (repository *SysMessageProduceRepository) Save(dm *domain.SysMessageProduce @@ -23,7 +24,7 @@ func (repository *SysMessageProduceRepository) Save(dm *domain.SysMessageProduce
23 return nil, err 24 return nil, err
24 } 25 }
25 26
26 - if err = tx.Insert(m); err != nil { 27 + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil {
27 return nil, err 28 return nil, err
28 } 29 }
29 return dm, nil 30 return dm, nil
@@ -2,6 +2,7 @@ package repository @@ -2,6 +2,7 @@ package repository
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 +
5 "github.com/go-pg/pg/v10" 6 "github.com/go-pg/pg/v10"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models"
@@ -23,12 +24,12 @@ func (repository *UsersRepository) Save(dm *domain.Users) (*domain.Users, error) @@ -23,12 +24,12 @@ func (repository *UsersRepository) Save(dm *domain.Users) (*domain.Users, error)
23 return nil, err 24 return nil, err
24 } 25 }
25 if dm.Identify() == nil { 26 if dm.Identify() == nil {
26 - if err = tx.Insert(m); err != nil { 27 + if _, err = tx.Model(m).Returning("*").Insert(m); err != nil {
27 return nil, err 28 return nil, err
28 } 29 }
29 return dm, nil 30 return dm, nil
30 } 31 }
31 - if err = tx.Update(m); err != nil { 32 + if _, err = tx.Model(m).Update(m); err != nil {
32 return nil, err 33 return nil, err
33 } 34 }
34 return dm, nil 35 return dm, nil
@@ -9,7 +9,7 @@ type DividendController struct { @@ -9,7 +9,7 @@ type DividendController struct {
9 BaseController 9 BaseController
10 } 10 }
11 11
12 -//DividendStatistics 12 +// DividendStatistics
13 func (this *DividendController) DividendStatistics() { 13 func (this *DividendController) DividendStatistics() {
14 var msg *protocol.ResponseMessage 14 var msg *protocol.ResponseMessage
15 defer func() { 15 defer func() {
@@ -31,7 +31,29 @@ func (this *DividendController) DividendStatistics() { @@ -31,7 +31,29 @@ func (this *DividendController) DividendStatistics() {
31 msg = protocol.NewReturnResponse(dividend.Statistics(header, request)) 31 msg = protocol.NewReturnResponse(dividend.Statistics(header, request))
32 } 32 }
33 33
34 -//DividendOrders 分红订单 34 +// DividendStatisticsV2 分红统计
  35 +func (this *DividendController) DividendStatisticsV2() {
  36 + var msg *protocol.ResponseMessage
  37 + defer func() {
  38 + this.Resp(msg)
  39 + }()
  40 + var request *protocol.DividendStatisticsRequest
  41 + if err := this.JsonUnmarshal(&request); err != nil {
  42 + msg = protocol.BadRequestParam(1)
  43 + return
  44 + }
  45 + if b, m := this.Valid(request); !b {
  46 + msg = m
  47 + return
  48 + }
  49 + header := this.GetRequestHeader(this.Ctx)
  50 + if request.PartnerId == 0 {
  51 + request.PartnerId = header.UserId
  52 + }
  53 + msg = protocol.NewReturnResponse(dividend.StatisticsV2(header, request))
  54 +}
  55 +
  56 +// DividendOrders 分红订单
35 func (this *DividendController) DividendOrders() { 57 func (this *DividendController) DividendOrders() {
36 var msg *protocol.ResponseMessage 58 var msg *protocol.ResponseMessage
37 defer func() { 59 defer func() {
1 package controllers 1 package controllers
2 2
3 import ( 3 import (
  4 + "time"
  5 +
4 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/order" 6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/order"
5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
6 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
7 - "time"  
8 ) 9 )
9 10
10 type OrderController struct { 11 type OrderController struct {
11 BaseController 12 BaseController
12 } 13 }
13 14
14 -//OrderStatistics 订单统计 15 +// OrderStatistics 订单统计
15 // @router /statistics [post] 16 // @router /statistics [post]
16 func (this *OrderController) Statistics() { 17 func (this *OrderController) Statistics() {
17 var msg *protocol.ResponseMessage 18 var msg *protocol.ResponseMessage
@@ -31,7 +32,7 @@ func (this *OrderController) Statistics() { @@ -31,7 +32,7 @@ func (this *OrderController) Statistics() {
31 msg = protocol.NewReturnResponse(order.Statistics(header, request)) 32 msg = protocol.NewReturnResponse(order.Statistics(header, request))
32 } 33 }
33 34
34 -//OrderStatistics 订单统计 35 +// OrderStatistics 订单统计
35 // @router /statistics [post] 36 // @router /statistics [post]
36 func (this *OrderController) StatisticsV2() { 37 func (this *OrderController) StatisticsV2() {
37 var msg *protocol.ResponseMessage 38 var msg *protocol.ResponseMessage
@@ -54,7 +55,7 @@ func (this *OrderController) StatisticsV2() { @@ -54,7 +55,7 @@ func (this *OrderController) StatisticsV2() {
54 msg = protocol.NewReturnResponse(order.StatisticsV2(header, request)) 55 msg = protocol.NewReturnResponse(order.StatisticsV2(header, request))
55 } 56 }
56 57
57 -//OrderDetail 订单详情 58 +// OrderDetail 订单详情
58 // @router /orderDetail [post] 59 // @router /orderDetail [post]
59 func (this *OrderController) OrderDetail() { 60 func (this *OrderController) OrderDetail() {
60 var msg *protocol.ResponseMessage 61 var msg *protocol.ResponseMessage
@@ -74,7 +75,7 @@ func (this *OrderController) OrderDetail() { @@ -74,7 +75,7 @@ func (this *OrderController) OrderDetail() {
74 msg = protocol.NewReturnResponse(order.Detail(header, request)) 75 msg = protocol.NewReturnResponse(order.Detail(header, request))
75 } 76 }
76 77
77 -//OrderList 78 +// OrderList
78 func (this *OrderController) OrderList() { 79 func (this *OrderController) OrderList() {
79 var msg *protocol.ResponseMessage 80 var msg *protocol.ResponseMessage
80 defer func() { 81 defer func() {
@@ -97,7 +98,7 @@ func (this *OrderController) OrderList() { @@ -97,7 +98,7 @@ func (this *OrderController) OrderList() {
97 msg = protocol.NewReturnResponse(order.List(header, request)) 98 msg = protocol.NewReturnResponse(order.List(header, request))
98 } 99 }
99 100
100 -//OrderList 101 +// OrderList
101 func (this *OrderController) Intentions() { 102 func (this *OrderController) Intentions() {
102 var msg *protocol.ResponseMessage 103 var msg *protocol.ResponseMessage
103 defer func() { 104 defer func() {
@@ -47,7 +47,7 @@ func InitV2() { @@ -47,7 +47,7 @@ func InitV2() {
47 nsV2.Router("/auth/login", &controllers.AuthController{}, "Post:LoginV2") 47 nsV2.Router("/auth/login", &controllers.AuthController{}, "Post:LoginV2")
48 nsV2.Router("/user/userInfo", &controllers.UserController{}, "Post:UserInfoV2") 48 nsV2.Router("/user/userInfo", &controllers.UserController{}, "Post:UserInfoV2")
49 nsV2.Router("/company/partners", &controllers.CompanyController{}, "post:PartnersV2") 49 nsV2.Router("/company/partners", &controllers.CompanyController{}, "post:PartnersV2")
50 - 50 + nsV2.Router("/dividend/statistics", &controllers.DividendController{}, "Post:DividendStatisticsV2")
51 nsV2.Router("/order/statistics", &controllers.OrderController{}, "Post:StatisticsV2") 51 nsV2.Router("/order/statistics", &controllers.OrderController{}, "Post:StatisticsV2")
52 beego.AddNamespace(nsV2) 52 beego.AddNamespace(nsV2)
53 } 53 }
@@ -9,14 +9,27 @@ const ( @@ -9,14 +9,27 @@ const (
9 9
10 /*DividendStatistics 分红统计*/ 10 /*DividendStatistics 分红统计*/
11 type DividendStatisticsRequest struct { 11 type DividendStatisticsRequest struct {
12 - StartTime int64 `json:"startTime"`  
13 - EndTime int64 `json:"endTime"` 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"`
  21 +}
  22 +
  23 +// Career int = 1 //事业
  24 +// Business int = 2 //业务
  25 +// Develop int = 3 //研发
  26 +// App int = 4 //业务产品-应用
  27 +type DividendStatisticsV2Response struct {
  28 + Statistics DividendStatistics `json:"statistics"` // 全部
  29 + StatisticsCareer DividendStatistics `json:"statisticsCareer"` // 事业分类
  30 + StatisticsBusiness DividendStatistics `json:"statisticsBusiness"` // 业务分类
  31 + StatisticsDevelop DividendStatistics `json:"statisticsDevelop"` // 研发a分类
  32 + StatisticsApp DividendStatistics `json:"statisticsApp"` // 业务产品-应用
20 Timestamp int64 `json:"timestamp"` 33 Timestamp int64 `json:"timestamp"`
21 } 34 }
22 35
@@ -24,7 +37,8 @@ type DividendStatistics struct { @@ -24,7 +37,8 @@ type DividendStatistics struct {
24 Received float64 `json:"received"` //总已收分红 37 Received float64 `json:"received"` //总已收分红
25 Outstanding float64 `json:"outstanding"` //总未收分红/分红支出 38 Outstanding float64 `json:"outstanding"` //总未收分红/分红支出
26 Receivable float64 `json:"receivable"` //总应收分红 39 Receivable float64 `json:"receivable"` //总应收分红
27 - Quarters []Bonus `json:"quarters"` 40 + Quarters [4]Bonus `json:"quarters"` //4个季度分红
  41 + Months [12]Bonus `json:"months"` //12个月度分红
28 } 42 }
29 43
30 type Bonus struct { 44 type Bonus struct {