作者 唐旭辉

更新

... ... @@ -19,4 +19,6 @@ type CreateOrderCommand struct {
//货品
Goods []OrderGoodData `json:"goods"`
CompanyId int64 `json:"companyId"`
PartnerCategory int64 `json:"partner_category"`
}
... ...
... ... @@ -20,4 +20,6 @@ type UpdateOrderCommand struct {
//货品
Goods []OrderGoodData `json:"goods"`
CompanyId int64 `json:"companyId"`
PartnerCategory int64 `json:"partner_category"`
}
... ...
... ... @@ -229,6 +229,16 @@ func (service OrderInfoService) CreateNewOrder(cmd command.CreateOrderCommand) (
SalesmanBonusPercent: cmd.SalesmanBonusPercent,
CompanyId: cmd.CompanyId,
}
var cmdPartnerCategoryOk bool
for _, v := range partnerData.PartnerCategoryInfos {
if v.Id == cmd.PartnerCategory {
newOrder.PartnerCategory = v
cmdPartnerCategoryOk = true
}
}
if !cmdPartnerCategoryOk {
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "合伙人类型选择错误")
}
var orderGoods []domain.OrderGood
for _, good := range cmd.Goods {
m := domain.NewOrderGood()
... ... @@ -384,7 +394,7 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
// return nil, lib.ThrowError(lib.BUSINESS_ERROR, "订单号已存在")
// }
//检查delivery_code是否重复
if len(cmd.DeliveryCode) > 0 {
if cmd.DeliveryCode != oldOrderData.DeliveryCode {
if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode, cmd.CompanyId, cmd.Id); err != nil {
return nil, lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
} else if ok {
... ... @@ -418,6 +428,16 @@ func (service OrderInfoService) UpdateOrderData(cmd command.UpdateOrderCommand)
}
newOrderGoods = append(newOrderGoods, m)
}
var cmdPartnerCategoryOk bool
for _, v := range partnerData.PartnerCategoryInfos {
if v.Id == cmd.PartnerCategory {
oldOrderData.PartnerCategory = v
cmdPartnerCategoryOk = true
}
}
if !cmdPartnerCategoryOk {
return nil, lib.ThrowError(lib.BUSINESS_ERROR, "合伙人类型选择错误")
}
oldOrderData.OrderCode = cmd.OrderCode
oldOrderData.DeliveryCode = cmd.DeliveryCode
oldOrderData.Buyer.BuyerName = cmd.BuyerName
... ...
... ... @@ -40,10 +40,11 @@ func (reponsitory OrderBaseRepository) transformPgModelToDomainModel(orderModel
PartnerInfo: domain.Partner{
Id: orderModel.PartnerId,
},
BonusStatus: orderModel.BonusStatus,
CompanyId: orderModel.CompanyId,
DataFrom: orderModel.DataFrom,
Remark: orderModel.Remark,
BonusStatus: orderModel.BonusStatus,
CompanyId: orderModel.CompanyId,
DataFrom: orderModel.DataFrom,
Remark: orderModel.Remark,
PartnerCategory: orderModel.PartnerCategory,
}
return order, nil
}
... ... @@ -65,7 +66,7 @@ func (repository OrderBaseRepository) Save(orderInfo *domain.OrderBase) error {
PartnerBonusExpense: orderInfo.OrderCompute.PartnerBonusExpense, IsDisable: orderInfo.IsDisable,
CreateTime: orderInfo.CreateTime, BonusStatus: orderInfo.BonusStatus,
CompanyId: orderInfo.CompanyId, DataFrom: orderInfo.DataFrom,
Remark: orderInfo.Remark,
Remark: orderInfo.Remark, PartnerCategory: orderInfo.PartnerCategory,
}
if m.Id == 0 {
_, err = tx.Model(m).
... ...
... ... @@ -280,63 +280,63 @@ func (postData *postOrderGood) Valid() error {
// return
// }
func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) error {
// func (c *OrderInfoController) addOrderPurpose(param postPurposeOrderDetail) error {
newGoods := []orderCmd.OrderGoodData{}
for _, v := range param.Product {
g := orderCmd.OrderGoodData{
GoodName: v.ProductName,
PlanGoodNumber: v.OrderNum,
Price: v.Univalence,
PartnerBonusPercent: v.PartnerRatio,
}
newGoods = append(newGoods, g)
}
companyId := c.GetUserCompany()
createcmd := orderCmd.CreateOrderCommand{
OrderType: domain.OrderIntention,
OrderCode: param.OrderId,
DeliveryCode: "",
BuyerName: param.BuyerName,
OrderRegion: param.OrderDist,
PartnerId: param.PartnerId,
SalesmanBonusPercent: param.CommissionProportion,
Goods: newGoods,
CompanyId: companyId,
}
orderSrv := orderService.NewOrderInfoService(nil)
_, err := orderSrv.CreateNewOrder(createcmd)
return err
}
// newGoods := []orderCmd.OrderGoodData{}
// for _, v := range param.Product {
// g := orderCmd.OrderGoodData{
// GoodName: v.ProductName,
// PlanGoodNumber: v.OrderNum,
// Price: v.Univalence,
// PartnerBonusPercent: v.PartnerRatio,
// }
// newGoods = append(newGoods, g)
// }
// companyId := c.GetUserCompany()
// createcmd := orderCmd.CreateOrderCommand{
// OrderType: domain.OrderIntention,
// OrderCode: param.OrderId,
// DeliveryCode: "",
// BuyerName: param.BuyerName,
// OrderRegion: param.OrderDist,
// PartnerId: param.PartnerId,
// SalesmanBonusPercent: param.CommissionProportion,
// Goods: newGoods,
// CompanyId: companyId,
// }
// orderSrv := orderService.NewOrderInfoService(nil)
// _, err := orderSrv.CreateNewOrder(createcmd)
// return err
// }
func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) error {
orderSrv := orderService.NewOrderInfoService(nil)
newGoods := []orderCmd.OrderGoodData{}
for _, v := range param.Product {
g := orderCmd.OrderGoodData{
GoodName: v.ProductName,
PlanGoodNumber: v.OrderNum,
Price: v.Univalence,
PartnerBonusPercent: v.PartnerRatio,
}
newGoods = append(newGoods, g)
}
companyId := c.GetUserCompany()
updatecmd := orderCmd.UpdateOrderCommand{
Id: param.Id,
OrderType: domain.OrderIntention,
OrderCode: param.OrderId,
DeliveryCode: "",
BuyerName: param.BuyerName,
OrderRegion: param.OrderDist,
PartnerId: param.PartnerId,
SalesmanBonusPercent: param.CommissionProportion,
Goods: newGoods,
CompanyId: companyId,
}
_, err := orderSrv.UpdateOrderData(updatecmd)
return err
}
// func (c *OrderInfoController) editOrderPurpose(param postPurposeOrderDetail) error {
// orderSrv := orderService.NewOrderInfoService(nil)
// newGoods := []orderCmd.OrderGoodData{}
// for _, v := range param.Product {
// g := orderCmd.OrderGoodData{
// GoodName: v.ProductName,
// PlanGoodNumber: v.OrderNum,
// Price: v.Univalence,
// PartnerBonusPercent: v.PartnerRatio,
// }
// newGoods = append(newGoods, g)
// }
// companyId := c.GetUserCompany()
// updatecmd := orderCmd.UpdateOrderCommand{
// Id: param.Id,
// OrderType: domain.OrderIntention,
// OrderCode: param.OrderId,
// DeliveryCode: "",
// BuyerName: param.BuyerName,
// OrderRegion: param.OrderDist,
// PartnerId: param.PartnerId,
// SalesmanBonusPercent: param.CommissionProportion,
// Goods: newGoods,
// CompanyId: companyId,
// }
// _, err := orderSrv.UpdateOrderData(updatecmd)
// return err
// }
type postOrderPurposeDelivery struct {
ShipmentsId string `json:"shipmentsId"` //发货单号
... ... @@ -543,6 +543,8 @@ func (c *OrderInfoController) GetOrderReal() {
"product": allGoods,
"create_time": orderinfo.CreateTime.Local().Format("2006-01-02 15:04:06"),
"update_time": orderinfo.UpdateTime.Local().Format("2006-01-02 15:04:06"),
"partnerCategoryId": orderinfo.PartnerCategory.Id,
"partnerCategoryName": orderinfo.PartnerCategory.Name,
}
if orderinfo.OrderCompute.UseOrderAmount >= 0 {
rsp["orderNumCountControl"] = fmt.Sprint(orderinfo.OrderCompute.UseOrderCount)
... ... @@ -557,7 +559,8 @@ func (c *OrderInfoController) GetOrderReal() {
//实际订单
type postRealOrderDetail struct {
postPurposeOrderDetail
ShipmentsId string `json:"shipmentsId"` //发货单号
PartnerCategory int64 `json:"partner_category"`
ShipmentsId string `json:"shipmentsId"` //发货单号
}
func (postData *postRealOrderDetail) Valid() error {
... ... @@ -622,6 +625,7 @@ func (c *OrderInfoController) addOrderReal(param postRealOrderDetail) error {
SalesmanBonusPercent: param.CommissionProportion,
Goods: newGoods,
CompanyId: companyId,
PartnerCategory: param.PartnerCategory,
}
_, err := orderSrv.CreateNewOrder(createcmd)
return err
... ... @@ -651,6 +655,7 @@ func (c *OrderInfoController) editOrderReal(param postRealOrderDetail) error {
SalesmanBonusPercent: param.CommissionProportion,
Goods: newGoods,
CompanyId: companyId,
PartnerCategory: param.PartnerCategory,
}
orderSrv := orderService.NewOrderInfoService(nil)
_, err := orderSrv.UpdateOrderData(updatecmd)
... ...