正在显示
11 个修改的文件
包含
137 行增加
和
81 行删除
| @@ -143,8 +143,8 @@ func imRefreshToken(request *protocol.CheckImRequest, rsp *protocol.CheckImRespo | @@ -143,8 +143,8 @@ func imRefreshToken(request *protocol.CheckImRequest, rsp *protocol.CheckImRespo | ||
| 143 | 143 | ||
| 144 | // 获取客服id | 144 | // 获取客服id |
| 145 | func getRandomCustomerAccount(userId int64, ctx *transaction.TransactionContext) (acid int64) { | 145 | func getRandomCustomerAccount(userId int64, ctx *transaction.TransactionContext) (acid int64) { |
| 146 | - CustomerServiceRepository, _ := factory.CreateCustomerServiceRepository(ctx) | ||
| 147 | - total, customers, err := CustomerServiceRepository.Find(map[string]interface{}{"sortById": domain.ASC}) | 146 | + ImCustomerServiceRepository, _ := factory.CreateImCustomerServiceRepository(ctx) |
| 147 | + total, customers, err := ImCustomerServiceRepository.Find(map[string]interface{}{"sortById": domain.ASC}) | ||
| 148 | if err != nil { | 148 | if err != nil { |
| 149 | log.Error(err) | 149 | log.Error(err) |
| 150 | return 0 | 150 | return 0 |
| @@ -125,7 +125,7 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR | @@ -125,7 +125,7 @@ func OrderList(header *protocol.RequestHeader, request *protocol.DividendOrdersR | ||
| 125 | item := &protocol.DividendOrderListItem{ | 125 | item := &protocol.DividendOrderListItem{ |
| 126 | Id: o.Id, | 126 | Id: o.Id, |
| 127 | DeliveryNo: o.DeliveryCode, | 127 | DeliveryNo: o.DeliveryCode, |
| 128 | - OrderAmount: o.OrderAmount(), | 128 | + OrderAmount: o.PlanOrderAmount, |
| 129 | DividendReceivable: utils.Decimal(o.OrderTotalBonus()), | 129 | DividendReceivable: utils.Decimal(o.OrderTotalBonus()), |
| 130 | } | 130 | } |
| 131 | rsp.List = append(rsp.List, item) | 131 | rsp.List = append(rsp.List, item) |
| @@ -53,6 +53,6 @@ func CreateImInfoRepository(transactionContext *transaction.TransactionContext) | @@ -53,6 +53,6 @@ func CreateImInfoRepository(transactionContext *transaction.TransactionContext) | ||
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | //CreateImInfoRepository Im信息 | 55 | //CreateImInfoRepository Im信息 |
| 56 | -func CreateCustomerServiceRepository(transactionContext *transaction.TransactionContext) (domain.CustomerServiceRepository, error) { | ||
| 57 | - return repository.NewCustomerServiceRepository(transactionContext) | 56 | +func CreateImCustomerServiceRepository(transactionContext *transaction.TransactionContext) (domain.ImCustomerServiceRepository, error) { |
| 57 | + return repository.NewImCustomerServiceRepository(transactionContext) | ||
| 58 | } | 58 | } |
| @@ -81,7 +81,7 @@ func orderProducts(order *domain.OrderBase) interface{} { | @@ -81,7 +81,7 @@ func orderProducts(order *domain.OrderBase) interface{} { | ||
| 81 | item["orderCount"] = good.PlanGoodNumber | 81 | item["orderCount"] = good.PlanGoodNumber |
| 82 | item["orderAmount"] = good.PlanAmount | 82 | item["orderAmount"] = good.PlanAmount |
| 83 | item["dividendPercent"] = good.PartnerBonusPercent | 83 | item["dividendPercent"] = good.PartnerBonusPercent |
| 84 | - item["dividendReceivable"] = good.PlanPartnerBonus //已收分红 | 84 | + item["dividendReceivable"] = good.PlanPartnerBonus //应收分红 |
| 85 | item["dividendReceived"] = good.PartnerBonusHas //已收分红 | 85 | item["dividendReceived"] = good.PartnerBonusHas //已收分红 |
| 86 | item["dividendUnReceive"] = good.PartnerBonusNot // 未收分红 | 86 | item["dividendUnReceive"] = good.PartnerBonusNot // 未收分红 |
| 87 | item["dividendExpend"] = good.PartnerBonusExpense //分红支出 | 87 | item["dividendExpend"] = good.PartnerBonusExpense //分红支出 |
| @@ -176,7 +176,6 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r | @@ -176,7 +176,6 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r | ||
| 176 | Limit: request.PageSize, | 176 | Limit: request.PageSize, |
| 177 | Offset: request.PageSize * request.PageIndex, | 177 | Offset: request.PageSize * request.PageIndex, |
| 178 | SortByUpdateTime: domain.DESC, | 178 | SortByUpdateTime: domain.DESC, |
| 179 | - //IsDisable: "0", | ||
| 180 | } | 179 | } |
| 181 | if request.StartTime > 0 { | 180 | if request.StartTime > 0 { |
| 182 | queryOption.BeginTime = time.Unix(request.StartTime/1000, 0) | 181 | queryOption.BeginTime = time.Unix(request.StartTime/1000, 0) |
| @@ -189,48 +188,15 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r | @@ -189,48 +188,15 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r | ||
| 189 | //统计数据 | 188 | //统计数据 |
| 190 | if request.PageIndex == 0 { | 189 | if request.PageIndex == 0 { |
| 191 | var ( | 190 | var ( |
| 192 | - //partShipmentQuantity, allShipmentQuantity int | ||
| 193 | cumulativeQuantity int | 191 | cumulativeQuantity int |
| 194 | ) | 192 | ) |
| 195 | - //部分发货的订单数量 | ||
| 196 | - //partShipmentQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 197 | - // EndTime: request.EndTime, | ||
| 198 | - // BeginTime: request.StartTime, | ||
| 199 | - // OrderType: domain.OrderReal, | ||
| 200 | - // PartnerId: header.UserId, | ||
| 201 | - // OrderStatus: domain.OrderStatusDeliverSome, | ||
| 202 | - //}) | ||
| 203 | - //全部发货的订单数量 | ||
| 204 | - //allShipmentQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 205 | - // EndTime: request.EndTime, | ||
| 206 | - // BeginTime: request.StartTime, | ||
| 207 | - // OrderType: domain.OrderReal, | ||
| 208 | - // PartnerId: header.UserId, | ||
| 209 | - // //OrderStatus: domain.OrderStatusDeliverAll, | ||
| 210 | - //}) | ||
| 211 | //累计实发订单 | 193 | //累计实发订单 |
| 212 | cumulativeQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | 194 | cumulativeQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ |
| 213 | EndTime: time.Now().Unix() * 1000, | 195 | EndTime: time.Now().Unix() * 1000, |
| 214 | - //BeginTime: request.StartTime, | ||
| 215 | OrderType: domain.OrderReal, | 196 | OrderType: domain.OrderReal, |
| 216 | PartnerId: header.UserId, | 197 | PartnerId: header.UserId, |
| 217 | }) | 198 | }) |
| 218 | - //累计意向订单 | ||
| 219 | - //intentionQuantity, _, err = OrderDao.OrderStatics(&domain.OrderStaticQuery{ | ||
| 220 | - // EndTime: time.Now().Unix() * 1000, | ||
| 221 | - // //BeginTime: request.StartTime, | ||
| 222 | - // OrderType: domain.OrderIntention, | ||
| 223 | - // PartnerId: header.UserId, | ||
| 224 | - //}) | ||
| 225 | - //订单数量 | ||
| 226 | - //rsp.Statistics["partShipmentQuantity"] = partShipmentQuantity | ||
| 227 | - //rsp.Statistics["allShipmentQuantity"] = allShipmentQuantity | ||
| 228 | - //rsp.Statistics["orderQuantity"] = partShipmentQuantity + allShipmentQuantity //所有订单 = 部分发货 + 已经发货 | ||
| 229 | - //rsp.Statistics["cumulativeQuantity"] = cumulativeQuantity | ||
| 230 | rsp.Total = cumulativeQuantity | 199 | rsp.Total = cumulativeQuantity |
| 231 | - //实发订单 = 部分发货 + 全部发货 | ||
| 232 | - //rsp.Statistics["intentionQuantity"] = intentionQuantity | ||
| 233 | - | ||
| 234 | } | 200 | } |
| 235 | 201 | ||
| 236 | if len(orders) == 0 { | 202 | if len(orders) == 0 { |
| @@ -244,14 +210,15 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r | @@ -244,14 +210,15 @@ func List(header *protocol.RequestHeader, request *protocol.OrderListRequest) (r | ||
| 244 | return | 210 | return |
| 245 | } | 211 | } |
| 246 | func DomainOrderToOrderListItem(order *domain.OrderBase) *protocol.OrderListItem { | 212 | func DomainOrderToOrderListItem(order *domain.OrderBase) *protocol.OrderListItem { |
| 213 | + bonusStatic := order.OrderBonusStatic() | ||
| 247 | return &protocol.OrderListItem{ | 214 | return &protocol.OrderListItem{ |
| 248 | Id: order.Id, | 215 | Id: order.Id, |
| 249 | OrderType: order.OrderType, | 216 | OrderType: order.OrderType, |
| 250 | OrderNo: order.OrderCode, | 217 | OrderNo: order.OrderCode, |
| 251 | DeliveryNo: order.DeliveryCode, | 218 | DeliveryNo: order.DeliveryCode, |
| 252 | - OrderAmount: order.OrderAmount(), | 219 | + OrderAmount: order.PlanOrderAmount, |
| 253 | UpdateTime: order.UpdateTime.Unix() * 1000, | 220 | UpdateTime: order.UpdateTime.Unix() * 1000, |
| 254 | - MyDividend: order.OrderTotalBonus(), | 221 | + MyDividend: bonusStatic.OrderTotalBonus(), |
| 255 | IsRead: order.IsRead(), | 222 | IsRead: order.IsRead(), |
| 256 | } | 223 | } |
| 257 | } | 224 | } |
| @@ -2,7 +2,7 @@ package domain | @@ -2,7 +2,7 @@ package domain | ||
| 2 | 2 | ||
| 3 | import "time" | 3 | import "time" |
| 4 | 4 | ||
| 5 | -type CustomerService struct { | 5 | +type ImCustomerService struct { |
| 6 | // id | 6 | // id |
| 7 | Id int64 | 7 | Id int64 |
| 8 | // 用户id(合伙人Id) | 8 | // 用户id(合伙人Id) |
| @@ -17,14 +17,14 @@ type CustomerService struct { | @@ -17,14 +17,14 @@ type CustomerService struct { | ||
| 17 | UpdateTime time.Time | 17 | UpdateTime time.Time |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | -type CustomerServiceRepository interface { | ||
| 21 | - Save(dm *CustomerService) (*CustomerService, error) | ||
| 22 | - Remove(dm *CustomerService) (*CustomerService, error) | ||
| 23 | - FindOne(queryOptions map[string]interface{}) (*CustomerService, error) | ||
| 24 | - Find(queryOptions map[string]interface{}) (int64, []*CustomerService, error) | 20 | +type ImCustomerServiceRepository interface { |
| 21 | + Save(dm *ImCustomerService) (*ImCustomerService, error) | ||
| 22 | + Remove(dm *ImCustomerService) (*ImCustomerService, error) | ||
| 23 | + FindOne(queryOptions map[string]interface{}) (*ImCustomerService, error) | ||
| 24 | + Find(queryOptions map[string]interface{}) (int64, []*ImCustomerService, error) | ||
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | -func (m *CustomerService) Identify() interface{} { | 27 | +func (m *ImCustomerService) Identify() interface{} { |
| 28 | if m.Id == 0 { | 28 | if m.Id == 0 { |
| 29 | return nil | 29 | return nil |
| 30 | } | 30 | } |
| @@ -121,6 +121,21 @@ func (m *OrderBase) IsRead() int { | @@ -121,6 +121,21 @@ func (m *OrderBase) IsRead() int { | ||
| 121 | return 1 | 121 | return 1 |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | +func (m *OrderBase) OrderBonusStatic() *OrderStatics { | ||
| 125 | + return &OrderStatics{ | ||
| 126 | + BonusStatus: m.BonusStatus, | ||
| 127 | + PlanOrderCount: m.PlanOrderCount, | ||
| 128 | + PlanOrderAmount: m.PlanOrderAmount, | ||
| 129 | + UseOrderCount: m.UseOrderCount, | ||
| 130 | + UseOrderAmount: m.UseOrderAmount, | ||
| 131 | + PlanPartnerBonus: m.PlanPartnerBonus, | ||
| 132 | + UsePartnerBonus: m.UsePartnerBonus, | ||
| 133 | + PartnerBonusHas: m.PartnerBonusHas, | ||
| 134 | + PartnerBonusNot: m.PartnerBonusNot, | ||
| 135 | + PartnerBonusExpense: m.PartnerBonusExpense, | ||
| 136 | + } | ||
| 137 | +} | ||
| 138 | + | ||
| 124 | type OrderQueryOption struct { | 139 | type OrderQueryOption struct { |
| 125 | PartnerId int64 `json:"partnerId,omitempty"` | 140 | PartnerId int64 `json:"partnerId,omitempty"` |
| 126 | OrderType int `json:"orderType,omitempty"` | 141 | OrderType int `json:"orderType,omitempty"` |
pkg/domain/order_statics.go
0 → 100644
| 1 | +package domain | ||
| 2 | + | ||
| 3 | +import "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | ||
| 4 | + | ||
| 5 | +//分洪统计 | ||
| 6 | +type OrderStatics struct { | ||
| 7 | + //1:待支付分红 2:已支付分红 | ||
| 8 | + BonusStatus int8 | ||
| 9 | + //预计的订单内货品总数 | ||
| 10 | + PlanOrderCount int | ||
| 11 | + //预计的订单的总金额 | ||
| 12 | + PlanOrderAmount float64 | ||
| 13 | + //按需使用的订单内货品总数 (初始值=-1) | ||
| 14 | + UseOrderCount int | ||
| 15 | + //按需使用的订单内货品总数 (初始值=-1) | ||
| 16 | + UseOrderAmount float64 | ||
| 17 | + //合伙人应收分红 | ||
| 18 | + PlanPartnerBonus float64 | ||
| 19 | + //调整后的合伙人应收分红 (初始值=-1) | ||
| 20 | + UsePartnerBonus float64 | ||
| 21 | + //合伙人已收分红 | ||
| 22 | + PartnerBonusHas float64 | ||
| 23 | + //合伙人未收分红 | ||
| 24 | + PartnerBonusNot float64 | ||
| 25 | + //合伙人分红支出 | ||
| 26 | + PartnerBonusExpense float64 | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +//订单应收分红 | ||
| 30 | +func (m *OrderStatics) OrderTotalBonus() float64 { | ||
| 31 | + if m.UseOrderCount >= 0 { | ||
| 32 | + return utils.Decimal(m.UsePartnerBonus + m.PartnerBonusExpense) | ||
| 33 | + } | ||
| 34 | + return utils.Decimal(m.PlanPartnerBonus) | ||
| 35 | +} | ||
| 36 | + | ||
| 37 | +//订单已收分红 | ||
| 38 | +func (m *OrderStatics) OrderBonusReceive() float64 { | ||
| 39 | + return utils.Decimal(m.PartnerBonusHas) | ||
| 40 | +} | ||
| 41 | + | ||
| 42 | +//订单未收分红 | ||
| 43 | +func (m *OrderStatics) OrderBonusWait() float64 { | ||
| 44 | + bonusWait := m.OrderTotalBonus() - m.OrderBonusReceive() | ||
| 45 | + if bonusWait < 0 { | ||
| 46 | + return 0 | ||
| 47 | + } | ||
| 48 | + return bonusWait | ||
| 49 | +} | ||
| 50 | + | ||
| 51 | +//分红支出 | ||
| 52 | +func (m *OrderStatics) OrderBonusOutstanding() float64 { | ||
| 53 | + return utils.Decimal(m.PartnerBonusExpense) | ||
| 54 | +} | ||
| 55 | + | ||
| 56 | +//订单被取消金额 | ||
| 57 | +func (m *OrderStatics) OrderAmountCancel() float64 { | ||
| 58 | + if m.UseOrderAmount < 0 { | ||
| 59 | + return 0 | ||
| 60 | + } | ||
| 61 | + if m.PlanOrderAmount > m.UseOrderAmount { | ||
| 62 | + return 0 | ||
| 63 | + } | ||
| 64 | + return utils.Decimal(m.UseOrderAmount - m.PlanOrderAmount) | ||
| 65 | +} | ||
| 66 | + | ||
| 67 | +//订单金额 | ||
| 68 | +func (m *OrderStatics) OrderAmount() float64 { | ||
| 69 | + if m.UseOrderAmount < 0 { | ||
| 70 | + return m.PlanOrderAmount | ||
| 71 | + } | ||
| 72 | + return m.UseOrderAmount | ||
| 73 | +} |
| @@ -20,7 +20,8 @@ func (dao *OrderBaseDao) OrderStatics(option *domain.OrderStaticQuery) (count in | @@ -20,7 +20,8 @@ func (dao *OrderBaseDao) OrderStatics(option *domain.OrderStaticQuery) (count in | ||
| 20 | var orderAmount float64 | 20 | var orderAmount float64 |
| 21 | q := tx.Model(order) | 21 | q := tx.Model(order) |
| 22 | q.ColumnExpr("count(*) count") | 22 | q.ColumnExpr("count(*) count") |
| 23 | - q.ColumnExpr("sum(case when use_order_amount >0 THEN use_order_amount else plan_order_amount END) total_order_actual_amount") | 23 | + //q.ColumnExpr("sum(case when use_order_amount >0 THEN use_order_amount else plan_order_amount END) total_order_actual_amount") |
| 24 | + q.ColumnExpr("sum(plan_order_amount) total_order_actual_amount") | ||
| 24 | q.ColumnExpr("sum(use_order_amount) total_order_amount") | 25 | q.ColumnExpr("sum(use_order_amount) total_order_amount") |
| 25 | if option.PartnerId > 0 { | 26 | if option.PartnerId > 0 { |
| 26 | q.Where(`"order_base".partner_id =?`, option.PartnerId) | 27 | q.Where(`"order_base".partner_id =?`, option.PartnerId) |
| @@ -34,7 +34,7 @@ func init() { | @@ -34,7 +34,7 @@ func init() { | ||
| 34 | (*models.OrderBase)(nil), | 34 | (*models.OrderBase)(nil), |
| 35 | (*models.OrderGood)(nil), | 35 | (*models.OrderGood)(nil), |
| 36 | (*models.ImInfo)(nil), | 36 | (*models.ImInfo)(nil), |
| 37 | - (*models.CustomerService)(nil), | 37 | + (*models.ImCustomerService)(nil), |
| 38 | } { | 38 | } { |
| 39 | err := DB.CreateTable(model, &orm.CreateTableOptions{ | 39 | err := DB.CreateTable(model, &orm.CreateTableOptions{ |
| 40 | Temp: false, | 40 | Temp: false, |
| @@ -2,8 +2,8 @@ package models | @@ -2,8 +2,8 @@ package models | ||
| 2 | 2 | ||
| 3 | import "time" | 3 | import "time" |
| 4 | 4 | ||
| 5 | -type CustomerService struct { | ||
| 6 | - tableName struct{} `pg:"customer_service"` | 5 | +type ImCustomerService struct { |
| 6 | + tableName struct{} `pg:"im_customer_service"` | ||
| 7 | // id | 7 | // id |
| 8 | Id int64 | 8 | Id int64 |
| 9 | // 用户id(合伙人Id) | 9 | // 用户id(合伙人Id) |
| @@ -7,14 +7,14 @@ import ( | @@ -7,14 +7,14 @@ import ( | ||
| 7 | . "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" | 7 | . "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils" |
| 8 | ) | 8 | ) |
| 9 | 9 | ||
| 10 | -type CustomerServiceRepository struct { | 10 | +type ImCustomerServiceRepository struct { |
| 11 | transactionContext *transaction.TransactionContext | 11 | transactionContext *transaction.TransactionContext |
| 12 | } | 12 | } |
| 13 | 13 | ||
| 14 | -func (repository *CustomerServiceRepository) Save(dm *domain.CustomerService) (*domain.CustomerService, error) { | 14 | +func (repository *ImCustomerServiceRepository) Save(dm *domain.ImCustomerService) (*domain.ImCustomerService, error) { |
| 15 | var ( | 15 | var ( |
| 16 | err error | 16 | err error |
| 17 | - m = &models.CustomerService{} | 17 | + m = &models.ImCustomerService{} |
| 18 | tx = repository.transactionContext.PgTx | 18 | tx = repository.transactionContext.PgTx |
| 19 | ) | 19 | ) |
| 20 | if err = GobModelTransform(m, dm); err != nil { | 20 | if err = GobModelTransform(m, dm); err != nil { |
| @@ -32,63 +32,63 @@ func (repository *CustomerServiceRepository) Save(dm *domain.CustomerService) (* | @@ -32,63 +32,63 @@ func (repository *CustomerServiceRepository) Save(dm *domain.CustomerService) (* | ||
| 32 | return dm, nil | 32 | return dm, nil |
| 33 | } | 33 | } |
| 34 | 34 | ||
| 35 | -func (repository *CustomerServiceRepository) Remove(CustomerService *domain.CustomerService) (*domain.CustomerService, error) { | 35 | +func (repository *ImCustomerServiceRepository) Remove(ImCustomerService *domain.ImCustomerService) (*domain.ImCustomerService, error) { |
| 36 | var ( | 36 | var ( |
| 37 | tx = repository.transactionContext.PgTx | 37 | tx = repository.transactionContext.PgTx |
| 38 | - CustomerServiceModel = &models.CustomerService{Id: CustomerService.Identify().(int64)} | 38 | + ImCustomerServiceModel = &models.ImCustomerService{Id: ImCustomerService.Identify().(int64)} |
| 39 | ) | 39 | ) |
| 40 | - if _, err := tx.Model(CustomerServiceModel).Where("id = ?", CustomerService.Id).Delete(); err != nil { | ||
| 41 | - return CustomerService, err | 40 | + if _, err := tx.Model(ImCustomerServiceModel).Where("id = ?", ImCustomerService.Id).Delete(); err != nil { |
| 41 | + return ImCustomerService, err | ||
| 42 | } | 42 | } |
| 43 | - return CustomerService, nil | 43 | + return ImCustomerService, nil |
| 44 | } | 44 | } |
| 45 | 45 | ||
| 46 | -func (repository *CustomerServiceRepository) FindOne(queryOptions map[string]interface{}) (*domain.CustomerService, error) { | 46 | +func (repository *ImCustomerServiceRepository) FindOne(queryOptions map[string]interface{}) (*domain.ImCustomerService, error) { |
| 47 | tx := repository.transactionContext.PgTx | 47 | tx := repository.transactionContext.PgTx |
| 48 | - CustomerServiceModel := new(models.CustomerService) | ||
| 49 | - query := NewQuery(tx.Model(CustomerServiceModel), queryOptions) | 48 | + ImCustomerServiceModel := new(models.ImCustomerService) |
| 49 | + query := NewQuery(tx.Model(ImCustomerServiceModel), queryOptions) | ||
| 50 | query.SetWhere("id = ?", "id") | 50 | query.SetWhere("id = ?", "id") |
| 51 | query.SetWhere("user_id = ?", "user_id") | 51 | query.SetWhere("user_id = ?", "user_id") |
| 52 | if err := query.First(); err != nil { | 52 | if err := query.First(); err != nil { |
| 53 | return nil, domain.QueryNoRow | 53 | return nil, domain.QueryNoRow |
| 54 | } | 54 | } |
| 55 | - if CustomerServiceModel.Id == 0 { | 55 | + if ImCustomerServiceModel.Id == 0 { |
| 56 | return nil, domain.QueryNoRow | 56 | return nil, domain.QueryNoRow |
| 57 | } | 57 | } |
| 58 | - return repository.transformPgModelToDomainModel(CustomerServiceModel) | 58 | + return repository.transformPgModelToDomainModel(ImCustomerServiceModel) |
| 59 | } | 59 | } |
| 60 | 60 | ||
| 61 | -func (repository *CustomerServiceRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.CustomerService, error) { | 61 | +func (repository *ImCustomerServiceRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.ImCustomerService, error) { |
| 62 | tx := repository.transactionContext.PgTx | 62 | tx := repository.transactionContext.PgTx |
| 63 | - var CustomerServiceModels []*models.CustomerService | ||
| 64 | - CustomerServices := make([]*domain.CustomerService, 0) | ||
| 65 | - query := NewQuery(tx.Model(&CustomerServiceModels), queryOptions). | 63 | + var ImCustomerServiceModels []*models.ImCustomerService |
| 64 | + ImCustomerServices := make([]*domain.ImCustomerService, 0) | ||
| 65 | + query := NewQuery(tx.Model(&ImCustomerServiceModels), queryOptions). | ||
| 66 | SetOrder("create_time", "sortByCreateTime"). | 66 | SetOrder("create_time", "sortByCreateTime"). |
| 67 | SetOrder("update_time", "sortByUpdateTime"). | 67 | SetOrder("update_time", "sortByUpdateTime"). |
| 68 | SetOrder("id", "sortById") | 68 | SetOrder("id", "sortById") |
| 69 | var err error | 69 | var err error |
| 70 | if query.AffectRow, err = query.SelectAndCount(); err != nil { | 70 | if query.AffectRow, err = query.SelectAndCount(); err != nil { |
| 71 | - return 0, CustomerServices, err | 71 | + return 0, ImCustomerServices, err |
| 72 | } | 72 | } |
| 73 | - for _, CustomerServiceModel := range CustomerServiceModels { | ||
| 74 | - if CustomerService, err := repository.transformPgModelToDomainModel(CustomerServiceModel); err != nil { | ||
| 75 | - return 0, CustomerServices, err | 73 | + for _, ImCustomerServiceModel := range ImCustomerServiceModels { |
| 74 | + if ImCustomerService, err := repository.transformPgModelToDomainModel(ImCustomerServiceModel); err != nil { | ||
| 75 | + return 0, ImCustomerServices, err | ||
| 76 | } else { | 76 | } else { |
| 77 | - CustomerServices = append(CustomerServices, CustomerService) | 77 | + ImCustomerServices = append(ImCustomerServices, ImCustomerService) |
| 78 | } | 78 | } |
| 79 | } | 79 | } |
| 80 | - return int64(query.AffectRow), CustomerServices, nil | 80 | + return int64(query.AffectRow), ImCustomerServices, nil |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | -func (repository *CustomerServiceRepository) transformPgModelToDomainModel(CustomerServiceModel *models.CustomerService) (*domain.CustomerService, error) { | ||
| 84 | - m := &domain.CustomerService{} | ||
| 85 | - err := GobModelTransform(m, CustomerServiceModel) | 83 | +func (repository *ImCustomerServiceRepository) transformPgModelToDomainModel(ImCustomerServiceModel *models.ImCustomerService) (*domain.ImCustomerService, error) { |
| 84 | + m := &domain.ImCustomerService{} | ||
| 85 | + err := GobModelTransform(m, ImCustomerServiceModel) | ||
| 86 | return m, err | 86 | return m, err |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | -func NewCustomerServiceRepository(transactionContext *transaction.TransactionContext) (*CustomerServiceRepository, error) { | 89 | +func NewImCustomerServiceRepository(transactionContext *transaction.TransactionContext) (*ImCustomerServiceRepository, error) { |
| 90 | if transactionContext == nil { | 90 | if transactionContext == nil { |
| 91 | return nil, ERR_EMPTY_TC | 91 | return nil, ERR_EMPTY_TC |
| 92 | } | 92 | } |
| 93 | - return &CustomerServiceRepository{transactionContext: transactionContext}, nil | 93 | + return &ImCustomerServiceRepository{transactionContext: transactionContext}, nil |
| 94 | } | 94 | } |
-
请 注册 或 登录 后发表评论