作者 tangxvhui

更新 新增分红详情

... ... @@ -57,6 +57,8 @@ type OrderBase struct {
OrderCompute OrderCompute `json:"orderCompute"`
//是否关闭订单
IsDisable int `json:"isDisable"`
//分红支付状态
BonusStatus int `json:"bonusStatus"`
}
type OrderCompute struct {
... ...
... ... @@ -60,6 +60,8 @@ type OrderBase struct {
LastViewTime time.Time
//是否关闭订单
IsDisable int `pg:",use_zero"`
//分红支付状态
BonusStatus int
}
var _ pg.BeforeUpdateHook = (*OrderBase)(nil)
... ...
... ... @@ -2,6 +2,8 @@ package controllers
import (
"errors"
"fmt"
"strconv"
"github.com/astaxie/beego/logs"
orderQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/orderinfo/query"
... ... @@ -83,3 +85,106 @@ func (c *OrderDividendController) PageListOrderDividend() {
c.ResponsePageList(rsp, cnt, param.PageNumber)
return
}
//OrderDividendDetail 订单的分红详情
func (c *OrderDividendController) OrderDividendDetail() {
type Parameter struct {
Id string `json:"id"`
}
var (
param Parameter
err error
)
if err = c.BindJsonData(&param); err != nil {
logs.Error(err)
c.ResponseError(errors.New("json数据解析失败"))
return
}
orderid, _ := strconv.ParseInt(param.Id, 10, 64)
if orderid == 0 {
c.ResponseError(errors.New("参数错误"))
return
}
orderSrv := orderService.NewOrderInfoService(nil)
orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{
OrderId: orderid,
})
if err != nil {
c.ResponseError(err)
return
}
if orderinfo.OrderType != domain.OrderReal {
c.ResponseError(errors.New("参数错误"))
return
}
allGoods := []map[string]interface{}{}
for _, v := range orderinfo.Goods {
detail := map[string]interface{}{
"productName": v.GoodName,
"orderNum": v.PlanGoodNumber,
"univalence": v.Price,
"partnerRatio": v.PartnerBonusPercent,
"orderPrice": v.GoodCompute.PlanAmount,
"partnerDividendsReceivable": v.GoodCompute.PlanPartnerBonus,
}
m := map[string]interface{}{
"detail": detail,
"quantityControl": "",
"id": v.Id,
"stateOfPayment": v.BonusStatus,
"remark": v.Remark,
"orderPriceControl": "",
}
if v.GoodCompute.UseAmount >= 0 {
m["orderPriceControl"] = fmt.Sprint(v.GoodCompute.UseAmount)
}
if v.UseGoodNumber >= 0 {
m["quantityControl"] = fmt.Sprint(v.UseGoodNumber)
}
allGoods = append(allGoods, m)
}
orderData := map[string]interface{}{
"buyer": orderinfo.Buyer.BuyerName,
"shipmentsId": orderinfo.DeliveryCode,
"orderDist": orderinfo.RegionInfo.RegionName,
"partner": orderinfo.PartnerInfo.PartnerName,
"id": orderinfo.Id,
"orderNumber": orderinfo.OrderCode,
}
dividendCount := map[string]interface{}{
"orderNum": orderinfo.OrderCompute.PlanOrderCount,
"orderAmountAdjustment": orderinfo.OrderCompute.PlanOrderAmount,
"orderNumControl": "",
"orderAmountAdjustmentControl": "",
"partnerDividends": orderinfo.OrderCompute.PlanPartnerBonus,
"partnerDividendsControl": "",
"receivedDividends": orderinfo.OrderCompute.PartnerBonusHas,
"notReceivedDividend": orderinfo.OrderCompute.PartnerBonusNot,
"dividendSpending": orderinfo.OrderCompute.PartnerBonusExpense,
"commissionProportion": orderinfo.SalesmanBonusPercent,
"expectedCommission": orderinfo.OrderCompute.SalesmanBonus,
}
if orderinfo.OrderCompute.UseOrderAmount >= 0 {
dividendCount["orderAmountAdjustmentControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderAmount)
}
if orderinfo.OrderCompute.UsePartnerBonus >= 0 {
dividendCount["partnerDividendsControl"] = fmt.Sprint(orderinfo.OrderCompute.UsePartnerBonus)
}
if orderinfo.OrderCompute.UseOrderCount >= 0 {
dividendCount["orderNumControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount)
}
rsp := map[string]interface{}{
"order": orderData,
"product": allGoods,
"dividendCount": dividendCount,
"operationTime": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:06"),
}
if orderinfo.OrderCompute.UseOrderAmount >= 0 {
rsp["orderNumCountControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderAmount)
}
if orderinfo.OrderCompute.UseOrderCount >= 0 {
rsp["orderAmountAdjustmentCountControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount)
}
c.ResponseData(rsp)
return
}
... ...
... ... @@ -441,6 +441,10 @@ func (c *OrderInfoController) GetOrderReal() {
return
}
orderid, _ := strconv.ParseInt(param.Id, 10, 64)
if orderid == 0 {
c.ResponseError(errors.New("参数错误"))
return
}
orderSrv := orderService.NewOrderInfoService(nil)
orderinfo, err := orderSrv.GetOrderDetail(orderQuery.GetOrderQuery{
OrderId: orderid,
... ...
... ... @@ -30,8 +30,7 @@ func init() {
beego.NSNamespace("/dividends",
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.NSRouter("/detail", &controllers.OrderDividendController{}, "POST:OrderDividendDetail"),
),
beego.NSNamespace("/order",
beego.NSRouter("/purpose/list", &controllers.OrderInfoController{}, "POST:PageListOrderPurpose"),
... ...