切换导航条
此项目
正在载入...
登录
mmm-go
/
partnermg
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
yangfu
5 years ago
提交
8a3081a8a5f0d0544bec823cfd1f9f5290bb868f
1 个父辈
31f46aa7
修改分红订单列表
隐藏空白字符变更
内嵌
并排对比
正在显示
7 个修改的文件
包含
168 行增加
和
81 行删除
pkg/application/order_payment/query/list_order_payment.go
pkg/application/order_payment/service/order_payment.go
pkg/domain/order_payment.go
pkg/infrastructure/dao/pg_order_dao.go
pkg/infrastructure/pg/models/order.go
pkg/port/beego/controllers/dividends_controller.go
pkg/port/beego/routers/router.go
pkg/application/order_payment/query/list_order_payment.go
查看文件 @
8a3081a
package
query
type
Lis
tOrderPaymentQuery
struct
{
type
Ge
tOrderPaymentQuery
struct
{
// 合伙人类别
OrderId
int64
`json:"orderId"`
}
func
(
q
*
Lis
tOrderPaymentQuery
)
ValidateQuery
()
error
{
func
(
q
*
Ge
tOrderPaymentQuery
)
ValidateQuery
()
error
{
return
nil
}
...
...
pkg/application/order_payment/service/order_payment.go
查看文件 @
8a3081a
...
...
@@ -5,6 +5,8 @@ import (
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/factory"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/order_payment/command"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/order_payment/query"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/pg/models"
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/infrastructure/utils"
"time"
//"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/order_payment/query"
...
...
@@ -86,92 +88,31 @@ func (OrderPaymentService *OrderPaymentService) CreateOrderPayment(command *comm
return
nil
,
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
}
var
bonusStatus
int
=
1
if
len
(
command
.
DivdendPaymentItem
)
>
0
{
bonusStatus
=
command
.
DivdendPaymentItem
[
len
(
command
.
DivdendPaymentItem
)
-
1
]
.
StateOfPayment
}
if
err
=
OrderDao
.
Update
(
map
[
string
]
interface
{}{
"id"
:
command
.
OrderId
,
"orderPaymentAmount"
:
command
.
TotalPaymentAmount
});
err
!=
nil
{
if
err
=
OrderDao
.
Update
(
map
[
string
]
interface
{}{
"id"
:
command
.
OrderId
,
"orderPaymentAmount"
:
command
.
TotalPaymentAmount
,
"bonusStatus"
:
bonusStatus
});
err
!=
nil
{
return
}
return
}
//// GetOrderPayment 返回合伙人
//func (OrderPaymentService *OrderPaymentService) GetOrderPayment(command query.GetOrderPaymentQuery) (data *domain.OrderPayment, err error) {
// var (
// transactionContext, _ = factory.CreateTransactionContext(nil)
// )
// if err = command.ValidateQuery(); err != nil {
// return nil, lib.ThrowError(lib.ARG_ERROR, err.Error())
// }
// if err := transactionContext.StartTransaction(); err != nil {
// return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
// }
// defer func() {
// transactionContext.RollbackTransaction()
// }()
// var OrderPaymentRepository domain.OrderPaymentRepository
// if OrderPaymentRepository, err = factory.CreateOrderPaymentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// }); err != nil {
// return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
// }
// data, err = OrderPaymentRepository.FindOne(domain.PartnerFindOneQuery{UserId: command.Id})
// if err != nil {
// return nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
// }
// err = transactionContext.CommitTransaction()
// return
//}
//
//// 更新客户价值
//func (OrderPaymentService *OrderPaymentService) UpdateOrderPayment(updateOrderPaymentCommand *command.UpdateOrderPaymentCommand) (err error) {
// var (
// transactionContext, _ = factory.CreateTransactionContext(nil)
// )
// if err = updateOrderPaymentCommand.ValidateCommand(); err != nil {
// return application.ThrowError(application.ARG_ERROR, err.Error())
// }
// if err := transactionContext.StartTransaction(); err != nil {
// return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
// }
// defer func() {
// transactionContext.RollbackTransaction()
// }()
// var OrderPaymentRepository domain.OrderPaymentRepository
// if OrderPaymentRepository, err = factory.CreateOrderPaymentRepository(map[string]interface{}{
// "transactionContext": transactionContext,
// }); err != nil {
// return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
// }
// OrderPayment, err := OrderPaymentRepository.FindOne(domain.PartnerFindOneQuery{
// UserId: updateOrderPaymentCommand.Id,
// })
// if err != nil {
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
// }
// OrderPayment.PartnerCategory = updateOrderPaymentCommand.PartnerCategory
// OrderPayment.Salesman = updateOrderPaymentCommand.Salesman
// OrderPayment.Status = updateOrderPaymentCommand.Status
// OrderPayment.RegionInfo = updateOrderPaymentCommand.RegionInfo
// if _, err = OrderPaymentRepository.Save(OrderPayment); err != nil {
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
// }
// transactionContext.CommitTransaction()
// return
//}
//
// 返回订单支付列表
func
(
OrderPaymentService
*
OrderPaymentService
)
ListOrderPayment
(
listOrderPaymentQuery
*
query
.
ListOrderPaymentQuery
)
(
int
,
[]
*
domain
.
OrderPayment
,
error
)
{
func
(
OrderPaymentService
*
OrderPaymentService
)
ListOrderPayment
(
listOrderPaymentQuery
*
query
.
GetOrderPaymentQuery
)
(
map
[
string
]
interface
{}
,
[]
*
domain
.
OrderPayment
,
error
)
{
var
(
transactionContext
,
_
=
factory
.
CreateTransactionContext
(
nil
)
OrderDao
,
_
=
factory
.
CreateOrderDao
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
OrderPayments
[]
*
domain
.
OrderPayment
count
int
err
error
)
if
err
=
listOrderPaymentQuery
.
ValidateQuery
();
err
!=
nil
{
return
0
,
nil
,
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
err
.
Error
())
return
nil
,
nil
,
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
err
.
Error
())
}
if
err
:=
transactionContext
.
StartTransaction
();
err
!=
nil
{
return
0
,
nil
,
lib
.
ThrowError
(
lib
.
TRANSACTION_ERROR
,
err
.
Error
())
return
nil
,
nil
,
lib
.
ThrowError
(
lib
.
TRANSACTION_ERROR
,
err
.
Error
())
}
defer
func
()
{
if
err
!=
nil
{
...
...
@@ -182,19 +123,99 @@ func (OrderPaymentService *OrderPaymentService) ListOrderPayment(listOrderPaymen
if
OrderPaymentRepository
,
err
=
factory
.
CreateOrderPaymentRepository
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
,
});
err
!=
nil
{
return
0
,
nil
,
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
return
nil
,
nil
,
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
queryOption
:=
domain
.
OrderPaymentQuery
{
OrderId
:
listOrderPaymentQuery
.
OrderId
,
}
orderBase
,
e
:=
OrderDao
.
GetOrderBaseInfo
(
listOrderPaymentQuery
.
OrderId
)
if
e
!=
nil
{
return
nil
,
nil
,
e
}
if
OrderPayments
,
err
=
OrderPaymentRepository
.
Find
(
queryOption
);
err
!=
nil
{
return
0
,
nil
,
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
return
nil
,
nil
,
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
//if count, err = OrderPaymentRepository.CountAll(queryOption); err != nil {
// return nil, nil, lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
//}
if
err
=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
nil
,
nil
,
lib
.
ThrowError
(
lib
.
TRANSACTION_ERROR
,
err
.
Error
())
}
if
count
,
err
=
OrderPaymentRepository
.
CountAll
(
queryOption
);
err
!=
nil
{
return
orderBase
,
OrderPayments
,
nil
}
// 返回分红管理列表
func
(
OrderPaymentService
*
OrderPaymentService
)
ListDividendOrders
(
listOrderPaymentQuery
*
query
.
ListDividendOrdersQuery
)
(
int
,
interface
{},
error
)
{
var
(
transactionContext
,
_
=
factory
.
CreateTransactionContext
(
nil
)
//OrderPayments []*domain.OrderPayment
count
int
err
error
OrderDao
,
_
=
factory
.
CreateOrderDao
(
map
[
string
]
interface
{}{
"transactionContext"
:
transactionContext
})
orders
[]
*
models
.
Order
)
if
err
=
listOrderPaymentQuery
.
ValidateQuery
();
err
!=
nil
{
return
0
,
nil
,
lib
.
ThrowError
(
lib
.
ARG_ERROR
,
err
.
Error
())
}
if
err
:=
transactionContext
.
StartTransaction
();
err
!=
nil
{
return
0
,
nil
,
lib
.
ThrowError
(
lib
.
TRANSACTION_ERROR
,
err
.
Error
())
}
defer
func
()
{
if
err
!=
nil
{
transactionContext
.
RollbackTransaction
()
}
}()
if
count
,
orders
,
err
=
OrderDao
.
GetDividendOrders
(
map
[
string
]
interface
{}{
"orderCode"
:
listOrderPaymentQuery
.
OrderNumber
,
"partnerName"
:
listOrderPaymentQuery
.
PartnerName
,
"orderType"
:
1
,
"offset"
:
(
listOrderPaymentQuery
.
PageNumber
-
1
)
*
listOrderPaymentQuery
.
PageSize
,
"limit"
:
listOrderPaymentQuery
.
PageSize
,
});
err
!=
nil
{
return
0
,
nil
,
lib
.
ThrowError
(
lib
.
INTERNAL_SERVER_ERROR
,
err
.
Error
())
}
type
DividendOrderItem
struct
{
OrderNumber
string
`json:"orderNumber"`
//订单号
OrderState
int
`json:"orderState"`
//订单状态
StateOfPayment
string
`json:"stateOfPayment"`
//支付状态
CreateTime
string
`json:"createTime"`
//订单创建时间
PartnerName
string
`json:"partnerName"`
//合伙人姓名
DividendProportion
float64
`json:"dividendProportion"`
//分红比例
DividendsReceivable
float64
`json:"dividendsReceivable"`
//应收分红
DividendSpending
float64
`json:"dividendSpending"`
//分红支出
ReceiveDividends
float64
`json:"receiveDividends"`
//实收分红
CommissionProportion
float64
`json:"commissionProportion"`
//业务员抽成比例
}
var
list
=
make
([]
DividendOrderItem
,
0
)
for
i
:=
range
orders
{
order
:=
orders
[
i
]
item
:=
DividendOrderItem
{
OrderNumber
:
order
.
OrderCode
,
OrderState
:
order
.
OrderStatus
,
StateOfPayment
:
""
,
CreateTime
:
order
.
CreateAt
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
),
PartnerName
:
order
.
PartnerInfo
.
PartnerName
,
DividendProportion
:
order
.
PartnerBonusPercent
,
DividendsReceivable
:
utils
.
Decimal
(
order
.
OrderActualAmount
*
(
order
.
PartnerBonusPercent
/
100.0
)),
DividendSpending
:
0
,
ReceiveDividends
:
utils
.
Decimal
(
order
.
OrderPaymentAmount
*
(
order
.
PartnerBonusPercent
/
100.0
)),
CommissionProportion
:
order
.
SalesmanBonusPercent
,
}
if
order
.
BonusStatus
==
domain
.
BonusPaid
{
item
.
StateOfPayment
=
"已支付分红"
}
else
{
item
.
StateOfPayment
=
"等待支付分红"
}
if
order
.
OrderActualAmount
<
order
.
OrderAmount
{
item
.
DividendSpending
=
utils
.
Decimal
(
order
.
OrderAmount
-
order
.
OrderActualAmount
)
}
list
=
append
(
list
,
item
)
}
if
err
=
transactionContext
.
CommitTransaction
();
err
!=
nil
{
return
0
,
nil
,
lib
.
ThrowError
(
lib
.
TRANSACTION_ERROR
,
err
.
Error
())
}
return
count
,
OrderPayments
,
nil
return
count
,
list
,
nil
}
...
...
pkg/domain/order_payment.go
查看文件 @
8a3081a
...
...
@@ -26,6 +26,9 @@ type OrderPayment struct {
CreateAt
time
.
Time
`json:"createAt"`
//更新时间
UpdateAt
time
.
Time
`json:"updateAt"`
//扩展
PartnerBonusPercent
float64
`json:"-"`
}
func
(
m
*
OrderPayment
)
Identify
()
interface
{}
{
...
...
pkg/infrastructure/dao/pg_order_dao.go
查看文件 @
8a3081a
...
...
@@ -17,6 +17,9 @@ func (dao *OrderDao) Update(options map[string]interface{}) (err error) {
if
v
,
ok
:=
options
[
"orderPaymentAmount"
];
ok
{
q
.
Set
(
"order_payment_amount = ?"
,
v
)
}
if
v
,
ok
:=
options
[
"bonusStatus"
];
ok
{
q
.
Set
(
"bonus_status = ?"
,
v
)
}
if
v
,
ok
:=
options
[
"id"
];
ok
{
q
.
Where
(
"id = ?"
,
v
)
}
...
...
@@ -42,6 +45,31 @@ func (dao *OrderDao) GetOrderBaseInfo(id int64) (data map[string]interface{}, er
return
}
func
(
dao
*
OrderDao
)
GetDividendOrders
(
options
map
[
string
]
interface
{})
(
count
int
,
orders
[]
*
models
.
Order
,
err
error
)
{
tx
:=
dao
.
transactionContext
.
PgTx
//Order:=new(models.Order)
q
:=
tx
.
Model
(
&
orders
)
q
.
ColumnExpr
(
`"order".*`
,
`partner_info.partner_name`
)
q
.
Relation
(
"PartnerInfo"
)
if
v
,
ok
:=
options
[
"orderCode"
];
ok
&&
len
(
v
.
(
string
))
>
0
{
q
.
Where
(
`"order".order_code like ?`
,
fmt
.
Sprintf
(
"%%%v%%"
,
v
))
}
if
v
,
ok
:=
options
[
"orderType"
];
ok
{
q
.
Where
(
`"order".order_type=?`
,
v
)
}
if
v
,
ok
:=
options
[
"partnerName"
];
ok
&&
len
(
v
.
(
string
))
>
0
{
q
.
Where
(
`partner_info.partner_name like ?`
,
"%"
+
v
.
(
string
)
+
"%"
)
}
if
v
,
ok
:=
options
[
"offset"
];
ok
{
q
.
Offset
(
v
.
(
int
))
}
if
v
,
ok
:=
options
[
"limit"
];
ok
{
q
.
Limit
(
v
.
(
int
))
}
count
,
err
=
q
.
SelectAndCount
()
return
}
func
NewOrderDao
(
transactionContext
*
transaction
.
TransactionContext
)
(
*
OrderDao
,
error
)
{
if
transactionContext
==
nil
{
return
nil
,
fmt
.
Errorf
(
"transactionContext参数不能为nil"
)
...
...
pkg/infrastructure/pg/models/order.go
查看文件 @
8a3081a
...
...
@@ -27,12 +27,15 @@ type Order struct {
OrderActualAmount
float64
//订单已支付金额(货款)
OrderPaymentAmount
float64
//最后分红状态
BonusStatus
int
//订单区域信息
OrderRegionInfo
*
domain
.
RegionInfo
Buyer
*
domain
.
Buyer
//合伙人编号
PartnerId
int64
PartnerId
int64
PartnerInfo
PartnerInfo
`pg:"fk:partner_id"`
//合伙人分红百分比
PartnerBonusPercent
float64
//业务员分红百分比
...
...
pkg/port/beego/controllers/dividends_controller.go
查看文件 @
8a3081a
...
...
@@ -88,12 +88,13 @@ func (c *DividendsController) Detail() {
return
}
cmd
:=
OrderPaymentQuery
.
Lis
tOrderPaymentQuery
{
cmd
:=
OrderPaymentQuery
.
Ge
tOrderPaymentQuery
{
OrderId
:
param
.
Id
,
}
serve
:=
OrderPaymentSvr
.
NewOrderPaymentService
(
nil
)
var
data
[]
*
domain
.
OrderPayment
_
,
data
,
err
=
serve
.
ListOrderPayment
(
&
cmd
)
var
extral
map
[
string
]
interface
{}
extral
,
data
,
err
=
serve
.
ListOrderPayment
(
&
cmd
)
if
err
!=
nil
{
c
.
ResponseError
(
err
)
return
...
...
@@ -114,10 +115,10 @@ func (c *DividendsController) Detail() {
item
:=
data
[
i
]
payment
:=
DividendPayment
{
PaymentForGoods
:
item
.
PaymentAmount
,
UpdateTime
:
item
.
UpdateAt
.
Format
(
"2006-01-02 15:04:05"
),
UpdateTime
:
item
.
UpdateAt
.
Local
()
.
Format
(
"2006-01-02 15:04:05"
),
StateOfPayment
:
item
.
BonusStatus
,
Dividend
:
item
.
BonusAmount
,
DividendProportion
:
2
,
DividendProportion
:
extral
[
"PartnerBonusPercent"
]
.
(
float64
)
,
}
rsp
.
DividendPayment
=
append
(
rsp
.
DividendPayment
,
payment
)
}
...
...
@@ -125,3 +126,33 @@ func (c *DividendsController) Detail() {
c
.
ResponseData
(
rsp
)
return
}
//分红管理
func
(
c
*
DividendsController
)
List
()
{
var
(
param
OrderPaymentQuery
.
ListDividendOrdersQuery
err
error
count
int
)
if
err
=
c
.
BindJsonData
(
&
param
);
err
!=
nil
{
logs
.
Error
(
err
)
c
.
ResponseError
(
errors
.
New
(
"json数据解析失败"
))
return
}
if
param
.
PageSize
==
0
{
param
.
PageSize
=
20
}
if
param
.
PageNumber
==
0
{
param
.
PageNumber
=
1
}
serve
:=
OrderPaymentSvr
.
NewOrderPaymentService
(
nil
)
var
data
interface
{}
count
,
data
,
err
=
serve
.
ListDividendOrders
(
&
param
)
if
err
!=
nil
{
c
.
ResponseError
(
err
)
return
}
c
.
ResponsePageList
(
data
,
count
,
param
.
PageNumber
)
return
}
...
...
pkg/port/beego/routers/router.go
查看文件 @
8a3081a
...
...
@@ -30,6 +30,7 @@ func init() {
beego
.
NSNamespace
(
"/dividends"
,
beego
.
NSRouter
(
"/edit"
,
&
controllers
.
DividendsController
{},
"POST:Edit"
),
beego
.
NSRouter
(
"/detail"
,
&
controllers
.
DividendsController
{},
"POST:Detail"
),
beego
.
NSRouter
(
"/list"
,
&
controllers
.
DividendsController
{},
"POST:List"
),
),
)
beego
.
AddNamespace
(
adminRouter
)
...
...
请
注册
或
登录
后发表评论