|
|
package controllers
|
|
|
|
|
|
import (
|
|
|
"errors"
|
|
|
|
|
|
"github.com/astaxie/beego/logs"
|
|
|
orderQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/query"
|
|
|
orderService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/service"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain"
|
|
|
)
|
|
|
|
|
|
//OrderDividendController 订单分红管理
|
|
|
type OrderDividendController struct {
|
|
|
BaseController
|
|
|
}
|
|
|
|
|
|
//Prepare 重写 BaseController 的Prepare方法
|
|
|
func (c *OrderDividendController) Prepare() {
|
|
|
c.BaseController.Prepare()
|
|
|
return
|
|
|
if ok := c.ValidJWTToken(); !ok {
|
|
|
return
|
|
|
}
|
|
|
if ok := c.ValidAdminPermission(domain.PERMISSION_DIVIDEND); !ok {
|
|
|
return
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//PageListOrderDividend 获取实发订单分红列表
|
|
|
func (c *OrderDividendController) PageListOrderDividend() {
|
|
|
type Parameter struct {
|
|
|
SearchText string `json:"searchText"`
|
|
|
Partner int64 `json:"partner"`
|
|
|
PageSize int `json:"pageSize"`
|
|
|
PageNumber int `json:"pageNumber"`
|
|
|
}
|
|
|
var (
|
|
|
param Parameter
|
|
|
err error
|
|
|
)
|
|
|
if err = c.BindJsonData(¶m); err != nil {
|
|
|
logs.Error(err)
|
|
|
c.ResponseError(errors.New("json数据解析失败"))
|
|
|
return
|
|
|
}
|
|
|
if param.PageNumber == 0 {
|
|
|
param.PageNumber = 1
|
|
|
}
|
|
|
if param.PageSize == 0 {
|
|
|
param.PageSize = 20
|
|
|
}
|
|
|
|
|
|
orderSrv := orderService.NewOrderInfoService(nil)
|
|
|
orderinfos, cnt, err := orderSrv.PageListOrderBase(orderQuery.ListOrderBaseQuery{
|
|
|
PartnerId: param.Partner,
|
|
|
DeliveryCode: param.SearchText,
|
|
|
OrderType: domain.OrderReal,
|
|
|
Limit: param.PageSize,
|
|
|
Offset: (param.PageNumber - 1) * param.PageSize,
|
|
|
})
|
|
|
if err != nil {
|
|
|
c.ResponseError(err)
|
|
|
return
|
|
|
}
|
|
|
rsp := []map[string]interface{}{}
|
|
|
for i := range orderinfos {
|
|
|
orderinfo := orderinfos[i]
|
|
|
m := map[string]interface{}{
|
|
|
"updateTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:05"),
|
|
|
"id": orderinfo.Id,
|
|
|
"shipmentsId": orderinfo.DeliveryCode,
|
|
|
"partner": orderinfo.PartnerInfo.PartnerName,
|
|
|
"dividendsReceivable": orderinfo.OrderCompute.PlanPartnerBonus,
|
|
|
"dividendSpending": orderinfo.OrderCompute.PartnerBonusExpense,
|
|
|
"receiveDividends": orderinfo.OrderCompute.PartnerBonusHas,
|
|
|
"uncollectedDividends": orderinfo.OrderCompute.PartnerBonusNot,
|
|
|
}
|
|
|
if orderinfo.OrderCompute.UsePartnerBonus >= 0 {
|
|
|
m["dividendsReceivable"] = orderinfo.OrderCompute.UsePartnerBonus
|
|
|
}
|
|
|
rsp = append(rsp, m)
|
|
|
}
|
|
|
c.ResponsePageList(rsp, cnt, param.PageNumber)
|
|
|
return
|
|
|
} |
...
|
...
|
|