作者 tangxvhui

更新 分红列表

... ... @@ -147,14 +147,7 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
defer func() {
transactionContext.RollbackTransaction()
}()
// orderDao, _ := factory.CreateOrderDao(map[string]interface{}{"transactionContext": transactionContext})
// ok, err := orderDao.OrderCodeIsExist(command.OrderCode, 0)
// if err != nil {
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
// }
// if ok {
// return lib.ThrowError(lib.BUSINESS_ERROR, "订单编号已存在")
// }
var PartnerInfoRepository domain.PartnerInfoRepository
if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ... @@ -290,14 +283,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
defer func() {
transactionContext.RollbackTransaction()
}()
// orderDao, _ := factory.CreateOrderDao(map[string]interface{}{"transactionContext": transactionContext})
// ok, err := orderDao.OrderCodeIsExist(command.OrderCode, 0)
// if err != nil {
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
// }
// if ok {
// return lib.ThrowError(lib.BUSINESS_ERROR, "订单编号已存在")
// }
var PartnerInfoRepository domain.PartnerInfoRepository
if PartnerInfoRepository, err = factory.CreatePartnerInfoRepository(map[string]interface{}{
"transactionContext": transactionContext,
... ...
... ... @@ -109,7 +109,6 @@ func (order *OrderBase) Compute() error {
planPartnerBonus = planPartnerBonus.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanPartnerBonus))
planOrderAmount = planOrderAmount.Add(decimal.NewFromFloat(order.Goods[i].GoodCompute.PlanAmount))
planOrderCount += order.Goods[i].PlanGoodNumber
goodUseAmount := decimal.NewFromFloat(order.Goods[i].GoodCompute.UseAmount)
if goodUseAmount.GreaterThanOrEqual(decimal.NewFromFloat(0)) {
//调整值非负值得情况
... ...
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(&param); 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
}
... ...
... ... @@ -28,9 +28,10 @@ func init() {
beego.NSRouter("/set-status", &controllers.PartnerInfoController{}, "POST:PartnerInfoSetState"),
),
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.NSRouter("/list", &controllers.OrderDividendController{}, "POST:PageListOrderDividend"),
// beego.NSRouter("/edit", &controllers.DividendsController{}, "POST:Edit"),
// beego.NSRouter("/detail", &controllers.DividendsController{}, "POST:Detail"),
// beego.NSRouter("/list", &controllers.DividendsController{}, "POST:List"),
),
beego.NSNamespace("/order",
beego.NSRouter("/purpose/list", &controllers.OrderInfoController{}, "POST:PageListOrderPurpose"),
... ...