作者 yangfu

增加:bug修改

1 package order 1 package order
2 2
3 import ( 3 import (
  4 + "github.com/tiptok/gocomm/xtime"
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"
@@ -179,6 +180,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -179,6 +180,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
179 OrderResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext) 180 OrderResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext)
180 OrderDao, _ = factory.CreateOrderBaseDao(transactionContext) 181 OrderDao, _ = factory.CreateOrderBaseDao(transactionContext)
181 orders []*domain.OrderBase 182 orders []*domain.OrderBase
  183 + total int64
182 ) 184 )
183 185
184 rsp = &protocol.OrderListResponse{ 186 rsp = &protocol.OrderListResponse{
@@ -205,7 +207,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -205,7 +207,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
205 queryOption.EndTime = time.Unix(request.EndTime/1000, 0) 207 queryOption.EndTime = time.Unix(request.EndTime/1000, 0)
206 } 208 }
207 queryOption.OrderType = request.OrderType 209 queryOption.OrderType = request.OrderType
208 - _, orders, _ = OrderResponsitory.Find(utils.ObjectJsonToMap(queryOption)) 210 + total, orders, _ = OrderResponsitory.Find(utils.ObjectJsonToMap(queryOption))
209 if len(orders) != 0 { 211 if len(orders) != 0 {
210 for i := range orders { 212 for i := range orders {
211 rsp.List = append(rsp.List, DomainOrderToOrderListItem(orders[i])) 213 rsp.List = append(rsp.List, DomainOrderToOrderListItem(orders[i]))
@@ -225,6 +227,13 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r @@ -225,6 +227,13 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
225 }) 227 })
226 rsp.Total = cumulativeQuantity 228 rsp.Total = cumulativeQuantity
227 } 229 }
  230 + // 今天累计数量特殊处理,不需要返回所有订单总数(因为要复用rsp.Total字段)
  231 + if request.StartTime > 0 && request.EndTime > 0 {
  232 + zero := time.Time(xtime.XTime(time.Now()).DayBefore(0)).Unix()
  233 + if request.StartTime == (zero * 1000) {
  234 + rsp.Total = int(total)
  235 + }
  236 + }
228 237
229 err = transactionContext.CommitTransaction() 238 err = transactionContext.CommitTransaction()
230 return 239 return
@@ -2,11 +2,11 @@ package constant @@ -2,11 +2,11 @@ package constant
2 2
3 import "os" 3 import "os"
4 4
5 -var POSTGRESQL_DB_NAME = "partner_dev" //partner  
6 -var POSTGRESQL_USER = "postgres" //  
7 -var POSTGRESQL_PASSWORD = "eagle1010" //pgsql@123  
8 -var POSTGRESQL_HOST = "114.55.200.59" //127.0.0.1  
9 -var POSTGRESQL_PORT = "31543" //5432 5 +var POSTGRESQL_DB_NAME = "partner_test" //partner
  6 +var POSTGRESQL_USER = "postgres" //
  7 +var POSTGRESQL_PASSWORD = "eagle1010" //pgsql@123
  8 +var POSTGRESQL_HOST = "114.55.200.59" //127.0.0.1
  9 +var POSTGRESQL_PORT = "31543" //5432
10 var DISABLE_CREATE_TABLE = false 10 var DISABLE_CREATE_TABLE = false
11 var DISABLE_SQL_GENERATE_PRINT = false 11 var DISABLE_SQL_GENERATE_PRINT = false
12 12
@@ -53,7 +53,7 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d @@ -53,7 +53,7 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d
53 tx := dao.transactionContext.PgTx 53 tx := dao.transactionContext.PgTx
54 q := tx.Model(new(models.OrderBase)) 54 q := tx.Model(new(models.OrderBase))
55 q.ColumnExpr("count(*) count") 55 q.ColumnExpr("count(*) count")
56 - q.ColumnExpr("sum((case when use_order_count>0 then use_partner_bonus else plan_partner_bonus end)) bonus") 56 + q.ColumnExpr("sum((case when use_order_count>=0 then use_partner_bonus else plan_partner_bonus end)) bonus")
57 q.ColumnExpr("sum(partner_bonus_expense) bonus_expense") 57 q.ColumnExpr("sum(partner_bonus_expense) bonus_expense")
58 q.ColumnExpr("sum(plan_order_amount) total_order_amount") 58 q.ColumnExpr("sum(plan_order_amount) total_order_amount")
59 if option.PartnerId > 0 { 59 if option.PartnerId > 0 {
@@ -22,6 +22,7 @@ func (dao *PartnerInfoDao) Update(queryOptions map[string]interface{}) error { @@ -22,6 +22,7 @@ func (dao *PartnerInfoDao) Update(queryOptions map[string]interface{}) error {
22 query.SetUpdate(`account=?`, "Account") 22 query.SetUpdate(`account=?`, "Account")
23 query.SetUpdate(`password=?`, "Password") 23 query.SetUpdate(`password=?`, "Password")
24 query.SetWhere(`id=?`, "Id") 24 query.SetWhere(`id=?`, "Id")
  25 + query.SetWhere(`account=?`, "oldAccount")
25 if _, ok := queryOptions["Id"]; !ok { 26 if _, ok := queryOptions["Id"]; !ok {
26 return fmt.Errorf(`error: miss param "Id"`) 27 return fmt.Errorf(`error: miss param "Id"`)
27 } 28 }
@@ -106,8 +107,8 @@ A left join @@ -106,8 +107,8 @@ A left join
106 SELECT partner_id,count(*) total,sum(amount) amount,sum(bonus) bonus,sum(bonus_expense) bonus_expense FROM 107 SELECT partner_id,count(*) total,sum(amount) amount,sum(bonus) bonus,sum(bonus_expense) bonus_expense FROM
107 ( 108 (
108 SELECT partner_id, 109 SELECT partner_id,
109 - (case when use_order_count>0 then plan_order_amount else plan_order_amount end) amount,  
110 - (case when use_order_count>0 then use_partner_bonus else plan_partner_bonus end) bonus, 110 + plan_order_amount amount,
  111 + (case when use_order_count>=0 then use_partner_bonus else plan_partner_bonus end) bonus,
111 partner_bonus_expense bonus_expense FROM "order_base" AS "order_base" 112 partner_bonus_expense bonus_expense FROM "order_base" AS "order_base"
112 WHERE (partner_id in (?)) and order_type =1 113 WHERE (partner_id in (?)) and order_type =1
113 UNION ALL 114 UNION ALL
1 package domain_service 1 package domain_service
2 2
3 import ( 3 import (
  4 + "fmt"
4 "github.com/tiptok/gocomm/xa/eda" 5 "github.com/tiptok/gocomm/xa/eda"
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/dao" 7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/dao"
7 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction" 8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
8 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/repository" 9 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/repository"
9 - "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"  
10 "strings" 10 "strings"
11 ) 11 )
12 12
@@ -29,16 +29,16 @@ func (s *PgPartnerAuthService) ChangeUserPhone(userId int64, newPhone, oldPhone @@ -29,16 +29,16 @@ func (s *PgPartnerAuthService) ChangeUserPhone(userId int64, newPhone, oldPhone
29 ) 29 )
30 //验证新手机是否已经存在 30 //验证新手机是否已经存在
31 if _, e := PartnerInfoService.FindOne(map[string]interface{}{"account": newPhone}); e == nil { 31 if _, e := PartnerInfoService.FindOne(map[string]interface{}{"account": newPhone}); e == nil {
32 - err = protocol.NewErrWithMessage(2029, err) //账号已存在 32 + err = fmt.Errorf("账号已存在") //账号已存在
33 return 33 return
34 } 34 }
35 if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": userId}); err != nil || (partnerInfo.Account != oldPhone) { 35 if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": userId}); err != nil || (partnerInfo.Account != oldPhone) {
36 - err = protocol.NewErrWithMessage(502, err) //账号不存在 36 + err = fmt.Errorf("账号不存在") //账号不存在
37 return 37 return
38 } 38 }
39 if err = PartnerInfoDao.Update(map[string]interface{}{ 39 if err = PartnerInfoDao.Update(map[string]interface{}{
40 - "Id": userId,  
41 - "Account": newPhone, 40 + "oldAccount": oldPhone,
  41 + "Account": newPhone,
42 }); err != nil { 42 }); err != nil {
43 return 43 return
44 } 44 }
@@ -51,17 +51,17 @@ func (s *PgPartnerAuthService) ChangeUserPassword(userId int64, newPwd, oldPwd, @@ -51,17 +51,17 @@ func (s *PgPartnerAuthService) ChangeUserPassword(userId int64, newPwd, oldPwd,
51 PartnerInfoService, _ = repository.NewPartnerInfoRepository(s.transactionContext) 51 PartnerInfoService, _ = repository.NewPartnerInfoRepository(s.transactionContext)
52 ) 52 )
53 if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": userId}); err != nil { 53 if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": userId}); err != nil {
54 - err = protocol.NewErrWithMessage(502, err) //账号不存在 54 + err = fmt.Errorf("账号不存在") //账号不存在
55 return 55 return
56 } 56 }
57 if !strings.EqualFold(partnerInfo.Password, oldPwd) { 57 if !strings.EqualFold(partnerInfo.Password, oldPwd) {
58 //密码不一致 58 //密码不一致
59 - err = protocol.NewErrWithMessage(2028, err) //账号不存在 59 + err = fmt.Errorf("账号不存在") //账号不存在
60 return 60 return
61 } 61 }
62 if err = PartnerInfoDao.Update(map[string]interface{}{ 62 if err = PartnerInfoDao.Update(map[string]interface{}{
63 - "Id": partnerInfo.Id,  
64 - "Password": newPwd, 63 + "oldAccount": phone,
  64 + "Password": newPwd,
65 }); err != nil { 65 }); err != nil {
66 return 66 return
67 } 67 }
@@ -69,17 +69,17 @@ func (s *PgPartnerAuthService) ChangeUserPassword(userId int64, newPwd, oldPwd, @@ -69,17 +69,17 @@ func (s *PgPartnerAuthService) ChangeUserPassword(userId int64, newPwd, oldPwd,
69 } 69 }
70 func (s *PgPartnerAuthService) ResetUserPassword(userId int64, phone, password string) (err error) { 70 func (s *PgPartnerAuthService) ResetUserPassword(userId int64, phone, password string) (err error) {
71 var ( 71 var (
72 - partnerInfo *domain.PartnerInfo 72 + //partnerInfo *domain.PartnerInfo
73 PartnerInfoDao, _ = dao.NewPartnerInfoDao(s.transactionContext) 73 PartnerInfoDao, _ = dao.NewPartnerInfoDao(s.transactionContext)
74 PartnerInfoService, _ = repository.NewPartnerInfoRepository(s.transactionContext) 74 PartnerInfoService, _ = repository.NewPartnerInfoRepository(s.transactionContext)
75 ) 75 )
76 - if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": userId}); err != nil {  
77 - err = protocol.NewErrWithMessage(502, err) //账号不存在 76 + if _, err = PartnerInfoService.FindOne(map[string]interface{}{"account": phone}); err != nil {
  77 + err = fmt.Errorf("账号不存在") //账号不存在
78 return 78 return
79 } 79 }
80 if err = PartnerInfoDao.Update(map[string]interface{}{ 80 if err = PartnerInfoDao.Update(map[string]interface{}{
81 - "Id": partnerInfo.Id,  
82 - "Password": password, 81 + "oldAccount": phone,
  82 + "Password": password,
83 }); err != nil { 83 }); err != nil {
84 return 84 return
85 } 85 }