作者 yangfu

增加:bug修改

package order
import (
"github.com/tiptok/gocomm/xtime"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
... ... @@ -179,6 +180,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
OrderResponsitory, _ = factory.CreateOrderBaseRepository(transactionContext)
OrderDao, _ = factory.CreateOrderBaseDao(transactionContext)
orders []*domain.OrderBase
total int64
)
rsp = &protocol.OrderListResponse{
... ... @@ -205,7 +207,7 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
queryOption.EndTime = time.Unix(request.EndTime/1000, 0)
}
queryOption.OrderType = request.OrderType
_, orders, _ = OrderResponsitory.Find(utils.ObjectJsonToMap(queryOption))
total, orders, _ = OrderResponsitory.Find(utils.ObjectJsonToMap(queryOption))
if len(orders) != 0 {
for i := range orders {
rsp.List = append(rsp.List, DomainOrderToOrderListItem(orders[i]))
... ... @@ -225,6 +227,13 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r
})
rsp.Total = cumulativeQuantity
}
// 今天累计数量特殊处理,不需要返回所有订单总数(因为要复用rsp.Total字段)
if request.StartTime > 0 && request.EndTime > 0 {
zero := time.Time(xtime.XTime(time.Now()).DayBefore(0)).Unix()
if request.StartTime == (zero * 1000) {
rsp.Total = int(total)
}
}
err = transactionContext.CommitTransaction()
return
... ...
... ... @@ -2,11 +2,11 @@ package constant
import "os"
var POSTGRESQL_DB_NAME = "partner_dev" //partner
var POSTGRESQL_USER = "postgres" //
var POSTGRESQL_PASSWORD = "eagle1010" //pgsql@123
var POSTGRESQL_HOST = "114.55.200.59" //127.0.0.1
var POSTGRESQL_PORT = "31543" //5432
var POSTGRESQL_DB_NAME = "partner_test" //partner
var POSTGRESQL_USER = "postgres" //
var POSTGRESQL_PASSWORD = "eagle1010" //pgsql@123
var POSTGRESQL_HOST = "114.55.200.59" //127.0.0.1
var POSTGRESQL_PORT = "31543" //5432
var DISABLE_CREATE_TABLE = false
var DISABLE_SQL_GENERATE_PRINT = false
... ...
... ... @@ -53,7 +53,7 @@ func (dao *OrderBaseDao) OrderBonusStatics(option domain.OrderBonusQuery) (rsp d
tx := dao.transactionContext.PgTx
q := tx.Model(new(models.OrderBase))
q.ColumnExpr("count(*) count")
q.ColumnExpr("sum((case when use_order_count>0 then use_partner_bonus else plan_partner_bonus end)) bonus")
q.ColumnExpr("sum((case when use_order_count>=0 then use_partner_bonus else plan_partner_bonus end)) bonus")
q.ColumnExpr("sum(partner_bonus_expense) bonus_expense")
q.ColumnExpr("sum(plan_order_amount) total_order_amount")
if option.PartnerId > 0 {
... ...
... ... @@ -22,6 +22,7 @@ func (dao *PartnerInfoDao) Update(queryOptions map[string]interface{}) error {
query.SetUpdate(`account=?`, "Account")
query.SetUpdate(`password=?`, "Password")
query.SetWhere(`id=?`, "Id")
query.SetWhere(`account=?`, "oldAccount")
if _, ok := queryOptions["Id"]; !ok {
return fmt.Errorf(`error: miss param "Id"`)
}
... ... @@ -106,8 +107,8 @@ A left join
SELECT partner_id,count(*) total,sum(amount) amount,sum(bonus) bonus,sum(bonus_expense) bonus_expense FROM
(
SELECT partner_id,
(case when use_order_count>0 then plan_order_amount else plan_order_amount end) amount,
(case when use_order_count>0 then use_partner_bonus else plan_partner_bonus end) bonus,
plan_order_amount amount,
(case when use_order_count>=0 then use_partner_bonus else plan_partner_bonus end) bonus,
partner_bonus_expense bonus_expense FROM "order_base" AS "order_base"
WHERE (partner_id in (?)) and order_type =1
UNION ALL
... ...
package domain_service
import (
"fmt"
"github.com/tiptok/gocomm/xa/eda"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/domain"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/dao"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/pg/transaction"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/repository"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
"strings"
)
... ... @@ -29,16 +29,16 @@ func (s *PgPartnerAuthService) ChangeUserPhone(userId int64, newPhone, oldPhone
)
//验证新手机是否已经存在
if _, e := PartnerInfoService.FindOne(map[string]interface{}{"account": newPhone}); e == nil {
err = protocol.NewErrWithMessage(2029, err) //账号已存在
err = fmt.Errorf("账号已存在") //账号已存在
return
}
if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": userId}); err != nil || (partnerInfo.Account != oldPhone) {
err = protocol.NewErrWithMessage(502, err) //账号不存在
err = fmt.Errorf("账号不存在") //账号不存在
return
}
if err = PartnerInfoDao.Update(map[string]interface{}{
"Id": userId,
"Account": newPhone,
"oldAccount": oldPhone,
"Account": newPhone,
}); err != nil {
return
}
... ... @@ -51,17 +51,17 @@ func (s *PgPartnerAuthService) ChangeUserPassword(userId int64, newPwd, oldPwd,
PartnerInfoService, _ = repository.NewPartnerInfoRepository(s.transactionContext)
)
if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": userId}); err != nil {
err = protocol.NewErrWithMessage(502, err) //账号不存在
err = fmt.Errorf("账号不存在") //账号不存在
return
}
if !strings.EqualFold(partnerInfo.Password, oldPwd) {
//密码不一致
err = protocol.NewErrWithMessage(2028, err) //账号不存在
err = fmt.Errorf("账号不存在") //账号不存在
return
}
if err = PartnerInfoDao.Update(map[string]interface{}{
"Id": partnerInfo.Id,
"Password": newPwd,
"oldAccount": phone,
"Password": newPwd,
}); err != nil {
return
}
... ... @@ -69,17 +69,17 @@ func (s *PgPartnerAuthService) ChangeUserPassword(userId int64, newPwd, oldPwd,
}
func (s *PgPartnerAuthService) ResetUserPassword(userId int64, phone, password string) (err error) {
var (
partnerInfo *domain.PartnerInfo
//partnerInfo *domain.PartnerInfo
PartnerInfoDao, _ = dao.NewPartnerInfoDao(s.transactionContext)
PartnerInfoService, _ = repository.NewPartnerInfoRepository(s.transactionContext)
)
if partnerInfo, err = PartnerInfoService.FindOne(map[string]interface{}{"id": userId}); err != nil {
err = protocol.NewErrWithMessage(502, err) //账号不存在
if _, err = PartnerInfoService.FindOne(map[string]interface{}{"account": phone}); err != nil {
err = fmt.Errorf("账号不存在") //账号不存在
return
}
if err = PartnerInfoDao.Update(map[string]interface{}{
"Id": partnerInfo.Id,
"Password": password,
"oldAccount": phone,
"Password": password,
}); err != nil {
return
}
... ...