作者 陈志颖

合并分支 'dev-v0.6.0' 到 'test'

Dev v0.6.0



查看合并请求 !2
1 appname = partner 1 appname = partner
2 runmode = "${RUN_MODE||dev}" 2 runmode = "${RUN_MODE||dev}"
3 -httpport = "${HTTP_PORT||8080}" 3 +httpport = "${HTTP_PORT||8082}"
4 4
5 #开启监控 5 #开启监控
6 EnableAdmin = false 6 EnableAdmin = false
@@ -108,6 +108,9 @@ func newQueryOptionV2(request *protocolx.PartnersRequest) map[string]interface{} @@ -108,6 +108,9 @@ func newQueryOptionV2(request *protocolx.PartnersRequest) map[string]interface{}
108 if request.EndTime > 0 { 108 if request.EndTime > 0 {
109 queryOption["endTime"] = request.EndTime / 1000 109 queryOption["endTime"] = request.EndTime / 1000
110 } 110 }
  111 + if request.Keyword != "" {
  112 + queryOption["keyword"] = request.Keyword
  113 + }
111 queryOption["limit"] = request.PageSize 114 queryOption["limit"] = request.PageSize
112 queryOption["offset"] = request.PageSize * request.PageIndex 115 queryOption["offset"] = request.PageSize * request.PageIndex
113 116
@@ -133,6 +133,7 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR @@ -133,6 +133,7 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR
133 Offset: request.PageIndex * request.PageSize, 133 Offset: request.PageIndex * request.PageSize,
134 Limit: request.PageSize, 134 Limit: request.PageSize,
135 SortByUpdateTime: domain.DESC, 135 SortByUpdateTime: domain.DESC,
  136 + JoinWays: request.JoinWays,
136 }) 137 })
137 if err != nil { 138 if err != nil {
138 return 139 return
@@ -252,6 +252,10 @@ func DomainOrderToOrderListItem(order *domain.OrderBase) *protocol.OrderListItem @@ -252,6 +252,10 @@ func DomainOrderToOrderListItem(order *domain.OrderBase) *protocol.OrderListItem
252 OrderType: order.OrderType, 252 OrderType: order.OrderType,
253 OrderNo: order.OrderCode, 253 OrderNo: order.OrderCode,
254 DeliveryNo: order.DeliveryCode, 254 DeliveryNo: order.DeliveryCode,
  255 + OrderDistrict: map[string]interface{}{
  256 + "id": order.RegionInfo.RegionId,
  257 + "name": order.RegionInfo.RegionName,
  258 + },
255 OrderAmount: order.PlanOrderAmount, 259 OrderAmount: order.PlanOrderAmount,
256 UpdateTime: order.UpdateTime.Unix() * 1000, 260 UpdateTime: order.UpdateTime.Unix() * 1000,
257 MyDividend: bonusStatic.OrderTotalReceivable(), 261 MyDividend: bonusStatic.OrderTotalReceivable(),
@@ -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 = "123456" 7 +var REDIS_AUTH = ""
8 8
9 func init() { 9 func init() {
10 if os.Getenv("REDIS_HOST") != "" { 10 if os.Getenv("REDIS_HOST") != "" {
@@ -2,6 +2,7 @@ package domain @@ -2,6 +2,7 @@ package domain
2 2
3 import ( 3 import (
4 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" 4 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
  5 + "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/company"
5 "time" 6 "time"
6 ) 7 )
7 8
@@ -173,6 +174,7 @@ type DividendOrdersQueryOption struct { @@ -173,6 +174,7 @@ type DividendOrdersQueryOption struct {
173 Offset int `json:"offset,omitempty"` 174 Offset int `json:"offset,omitempty"`
174 Limit int `json:"limit,omitempty"` 175 Limit int `json:"limit,omitempty"`
175 SortByUpdateTime string `json:"sortByUpdateTime,omitempty"` 176 SortByUpdateTime string `json:"sortByUpdateTime,omitempty"`
  177 + JoinWays []*company.JoinWays `json:"joinWays,omitempty"` // 合伙类型
176 } 178 }
177 179
178 //买家 180 //买家
@@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/models"
8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" 9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
  10 + "strings"
10 "time" 11 "time"
11 ) 12 )
12 13
@@ -109,6 +110,20 @@ func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption @@ -109,6 +110,20 @@ func (dao *OrderBaseDao) DividendOrders(option *domain.DividendOrdersQueryOption
109 if option.EndTime > 0 { 110 if option.EndTime > 0 {
110 q.Where(`"order_base".create_time <?`, time.Unix(option.EndTime/1000, 0)) 111 q.Where(`"order_base".create_time <?`, time.Unix(option.EndTime/1000, 0))
111 } 112 }
  113 + if len(option.JoinWays) > 0 {
  114 + var joinWays []int64
  115 + for i := 0; i < len(option.JoinWays); i++ {
  116 + joinWays = append(joinWays, option.JoinWays[i].Type)
  117 + }
  118 + var filterJoinWays = strings.Builder{}
  119 + for i := range joinWays {
  120 + filterJoinWays.WriteString(fmt.Sprintf(` partner_category @>'{"id":%v}'`, joinWays[i]))
  121 + if i != (len(joinWays) - 1) {
  122 + filterJoinWays.WriteString(" or ")
  123 + }
  124 + }
  125 + q.Where(filterJoinWays.String())
  126 + }
112 //if len(option.IsDisable) > 0 { 127 //if len(option.IsDisable) > 0 {
113 // value, _ := strconv.Atoi(option.IsDisable) 128 // value, _ := strconv.Atoi(option.IsDisable)
114 // q.Where(`"order_base".is_disable =?`, value) 129 // q.Where(`"order_base".is_disable =?`, value)
@@ -96,6 +96,9 @@ func (dao *PartnerInfoDao) Partners(partnerIds []int64, queryOptions map[string] @@ -96,6 +96,9 @@ func (dao *PartnerInfoDao) Partners(partnerIds []int64, queryOptions map[string]
96 if endTime, ok := queryOptions["endTime"]; ok { 96 if endTime, ok := queryOptions["endTime"]; ok {
97 filterPartners.WriteString(fmt.Sprintf(" and cooperate_time<to_timestamp(%v)", endTime)) 97 filterPartners.WriteString(fmt.Sprintf(" and cooperate_time<to_timestamp(%v)", endTime))
98 } 98 }
  99 + if keyword, ok := queryOptions["keyword"]; ok && keyword.(string) != "" {
  100 + filterPartners.WriteString(fmt.Sprintf(` and partner_name LIKE '%v'`, fmt.Sprintf("%%%s%%", "%%" + keyword.(string) + "%")))
  101 + }
99 102
100 sql.WriteString(fmt.Sprintf(` 103 sql.WriteString(fmt.Sprintf(`
101 SELECT A.*,B.total,B.amount,COALESCE(B.bonus,0) bonus,B.bonus_expense 104 SELECT A.*,B.total,B.amount,COALESCE(B.bonus,0) bonus,B.bonus_expense
@@ -77,8 +77,7 @@ func (repository *OrderBaseRepository) Find(queryOptions map[string]interface{}) @@ -77,8 +77,7 @@ func (repository *OrderBaseRepository) Find(queryOptions map[string]interface{})
77 var OrderBaseModels []*models.OrderBase 77 var OrderBaseModels []*models.OrderBase
78 OrderBases := make([]*domain.OrderBase, 0) 78 OrderBases := make([]*domain.OrderBase, 0)
79 query := NewQuery(tx.Model(&OrderBaseModels), queryOptions) 79 query := NewQuery(tx.Model(&OrderBaseModels), queryOptions)
80 - query.  
81 - SetWhere(`"order_base".partner_id= ?`, "partnerId"). 80 + query.SetWhere(`"order_base".partner_id= ?`, "partnerId").
82 SetWhere(`"order_base".order_type= ?`, "orderType"). 81 SetWhere(`"order_base".order_type= ?`, "orderType").
83 SetWhere(`"order_base".create_time >= ?`, "beginTime"). 82 SetWhere(`"order_base".create_time >= ?`, "beginTime").
84 SetWhere(`"order_base".create_time < ?`, "endTime"). 83 SetWhere(`"order_base".create_time < ?`, "endTime").
@@ -26,8 +26,8 @@ func CreateResponseLogFilter(logger *logs.BeeLogger) func(ctx *context.Context) @@ -26,8 +26,8 @@ func CreateResponseLogFilter(logger *logs.BeeLogger) func(ctx *context.Context)
26 return func(ctx *context.Context) { 26 return func(ctx *context.Context) {
27 requestId := ctx.Request.Header.Get("requestId") 27 requestId := ctx.Request.Header.Get("requestId")
28 body, _ := json.Marshal(ctx.Input.GetData("outputData")) 28 body, _ := json.Marshal(ctx.Input.GetData("outputData"))
29 - if len(body) > 1000 {  
30 - body = body[:1000] 29 + if len(body) > 10000 {
  30 + body = body[:10000]
31 } 31 }
32 logger.Debug(fmt.Sprintf("<====Send RequestId:%v BodyData:%s", requestId, body)) 32 logger.Debug(fmt.Sprintf("<====Send RequestId:%v BodyData:%s", requestId, body))
33 } 33 }
@@ -15,4 +15,6 @@ type PartnersRequest struct { @@ -15,4 +15,6 @@ type PartnersRequest struct {
15 JoinWays []JoinWays `json:"joinWays"` 15 JoinWays []JoinWays `json:"joinWays"`
16 // 分红排序(0.从多到少 1.从少到多) 16 // 分红排序(0.从多到少 1.从少到多)
17 SortBy int `json:"sortBy"` 17 SortBy int `json:"sortBy"`
  18 + // 合伙人姓名
  19 + Keyword string `json:"keyword"`
18 } 20 }
1 package protocol 1 package protocol
2 2
  3 +import "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol/company"
  4 +
3 const ( 5 const (
4 BonusTotal = iota //0 累计分红 6 BonusTotal = iota //0 累计分红
5 BonusOutstanding //1 分红支出 7 BonusOutstanding //1 分红支出
@@ -38,6 +40,9 @@ type DividendOrdersRequest struct { @@ -38,6 +40,9 @@ type DividendOrdersRequest struct {
38 StartTime int64 `json:"startTime"` 40 StartTime int64 `json:"startTime"`
39 EndTime int64 `json:"endTime" valid:"Required"` 41 EndTime int64 `json:"endTime" valid:"Required"`
40 42
  43 + // 合作类型(空或不传,即所有类型)
  44 + JoinWays []*company.JoinWays `json:"joinWays"`
  45 +
41 PageIndex int `json:"pageIndex,omitempty"` 46 PageIndex int `json:"pageIndex,omitempty"`
42 PageSize int `json:"pageSize,omitempty"` 47 PageSize int `json:"pageSize,omitempty"`
43 48
@@ -24,6 +24,7 @@ type OrderDetailResponse struct { @@ -24,6 +24,7 @@ type OrderDetailResponse struct {
24 // MyDividend float64 `json:"myDividend"` 24 // MyDividend float64 `json:"myDividend"`
25 // MyDividendPercent float64 `json:"myDividendPercent"` 25 // MyDividendPercent float64 `json:"myDividendPercent"`
26 //} 26 //}
  27 +
27 type OrderDetail struct { 28 type OrderDetail struct {
28 Id int64 `json:"id"` 29 Id int64 `json:"id"`
29 OrderNo string `json:"orderNo"` //订单号 30 OrderNo string `json:"orderNo"` //订单号
@@ -36,6 +37,7 @@ type OrderDetail struct { @@ -36,6 +37,7 @@ type OrderDetail struct {
36 Products interface{} `json:"products"` 37 Products interface{} `json:"products"`
37 Total interface{} `json:"total"` 38 Total interface{} `json:"total"`
38 } 39 }
  40 +
39 type Customer struct { 41 type Customer struct {
40 Uname string `json:"uname"` 42 Uname string `json:"uname"`
41 Phone string `json:"phone"` 43 Phone string `json:"phone"`
@@ -110,8 +112,11 @@ type OrderListItem struct { @@ -110,8 +112,11 @@ type OrderListItem struct {
110 OrderStatus int `json:"-"` 112 OrderStatus int `json:"-"`
111 //实际订单数量 113 //实际订单数量
112 OrderActualCount int `json:"-"` 114 OrderActualCount int `json:"-"`
  115 + // 订单区域
  116 + OrderDistrict map[string]interface{} `json:"orderDistrict"`
113 //订单金额 117 //订单金额
114 OrderAmount float64 `json:"orderAmount"` 118 OrderAmount float64 `json:"orderAmount"`
  119 + // 订单更新时间
115 UpdateTime int64 `json:"updateTime"` 120 UpdateTime int64 `json:"updateTime"`
116 //我的分红 121 //我的分红
117 MyDividend float64 `json:"dividendReceivable"` 122 MyDividend float64 `json:"dividendReceivable"`