...
|
...
|
@@ -534,110 +534,6 @@ func (service OrderInfoService) deleteOldOrderGoods(newGoods []domain.OrderGood, |
|
|
return
|
|
|
}
|
|
|
|
|
|
//Delivery 发货
|
|
|
// func (service OrderInfoService) Delivery(cmd command.OrderDeliveryCommand) error {
|
|
|
// var (
|
|
|
// transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
// err error
|
|
|
// )
|
|
|
// if err = transactionContext.StartTransaction(); err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// defer func() {
|
|
|
// transactionContext.RollbackTransaction()
|
|
|
// }()
|
|
|
// var (
|
|
|
// orderBaseRepository domain.OrderBaseRepository
|
|
|
// orderGoodRepository domain.OrderGoodRepository
|
|
|
// oldOrderData *domain.OrderBase
|
|
|
// oldOrderGoods []domain.OrderGood
|
|
|
// orderBaseDao *dao.OrderBaseDao
|
|
|
// )
|
|
|
|
|
|
// if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// }); err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// if orderGoodRepository, err = factory.CreateOrderGoodRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// }); err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// //获取旧的订单
|
|
|
// oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{
|
|
|
// CompanyId: cmd.CompanyId,
|
|
|
// OrderId: cmd.OrderId,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err))
|
|
|
// }
|
|
|
// if oldOrderData.OrderType != domain.OrderIntention {
|
|
|
// return lib.ThrowError(lib.BUSINESS_ERROR, "订单类型已发生变更")
|
|
|
// }
|
|
|
// if orderBaseDao, err = factory.CreateOrderBaseDao(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// }); err != nil {
|
|
|
// return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
|
|
|
// }
|
|
|
// //检查delivery_code是否重复
|
|
|
// if ok, err := orderBaseDao.DeliveryCodeExist(cmd.DeliveryCode, cmd.CompanyId, cmd.OrderId); err != nil {
|
|
|
// return lib.ThrowError(lib.TRANSACTION_ERROR, err.Error())
|
|
|
// } else if ok {
|
|
|
// return lib.ThrowError(lib.BUSINESS_ERROR, "发货号已存在")
|
|
|
// }
|
|
|
// //获取旧的订单中的商品
|
|
|
// oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{
|
|
|
// OrderId: cmd.OrderId,
|
|
|
// CompanyId: cmd.CompanyId,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单中的商品列表失败:%s", err))
|
|
|
// }
|
|
|
// for _, newGood := range cmd.Goods {
|
|
|
// for i := range oldOrderGoods {
|
|
|
// if newGood.Id != oldOrderGoods[i].Id {
|
|
|
// continue
|
|
|
// }
|
|
|
// oldOrderGoods[i].GoodName = newGood.GoodName
|
|
|
// oldOrderGoods[i].PlanGoodNumber = newGood.PlanGoodNumber
|
|
|
// oldOrderGoods[i].Price = newGood.Price
|
|
|
// oldOrderGoods[i].PartnerBonusPercent = newGood.PartnerBonusPercent
|
|
|
// oldOrderGoods[i].Remark = newGood.Remark
|
|
|
// err = oldOrderGoods[i].Compute()
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的数值失败:%s", err))
|
|
|
// }
|
|
|
// err = oldOrderGoods[i].CurrentBonusStatus.WartPayPartnerBonus(&oldOrderGoods[i])
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的分红数值失败:%s", err))
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// oldOrderData.DeliveryCode = cmd.DeliveryCode
|
|
|
// oldOrderData.DeliveryTime = time.Now()
|
|
|
// oldOrderData.Goods = oldOrderGoods
|
|
|
// //变更订单类型
|
|
|
// oldOrderData.OrderType = domain.OrderReal
|
|
|
// err = oldOrderData.Compute()
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中合计的数值失败:%s", err))
|
|
|
// }
|
|
|
// err = orderBaseRepository.Save(oldOrderData)
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单数据失败:%s", err))
|
|
|
// }
|
|
|
// err = orderGoodRepository.Save(oldOrderGoods)
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单中的商品数据失败:%s", err))
|
|
|
// }
|
|
|
// err = transactionContext.CommitTransaction()
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// return nil
|
|
|
// }
|
|
|
|
|
|
//DisableOrEnable 开启关闭订单
|
|
|
func (service OrderInfoService) DisableOrEnable(cmd command.DisableOrderCommand) error {
|
|
|
var (
|
...
|
...
|
@@ -682,102 +578,6 @@ func (service OrderInfoService) DisableOrEnable(cmd command.DisableOrderCommand) |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
//UpdateGoodBouns 分红时,更新货品的分红相关的数值
|
|
|
// func (service OrderInfoService) UpdateGoodBouns(cmd command.UpdateGoodBouns) error {
|
|
|
// var (
|
|
|
// transactionContext, _ = factory.CreateTransactionContext(nil)
|
|
|
// err error
|
|
|
// )
|
|
|
// if err = transactionContext.StartTransaction(); err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// defer func() {
|
|
|
// transactionContext.RollbackTransaction()
|
|
|
// }()
|
|
|
// var (
|
|
|
// orderBaseRepository domain.OrderBaseRepository
|
|
|
// orderGoodRepository domain.OrderGoodRepository
|
|
|
// oldOrderData *domain.OrderBase
|
|
|
// oldOrderGoods []domain.OrderGood
|
|
|
// )
|
|
|
// if orderBaseRepository, err = factory.CreateOrderBaseRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// }); err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// if orderGoodRepository, err = factory.CreateOrderGoodRepository(map[string]interface{}{
|
|
|
// "transactionContext": transactionContext,
|
|
|
// }); err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// //获取旧的订单
|
|
|
// oldOrderData, err = orderBaseRepository.FindOne(domain.OrderBaseFindOneQuery{
|
|
|
// OrderId: cmd.Id,
|
|
|
// CompanyId: cmd.CompanyId,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单:%s", err))
|
|
|
// }
|
|
|
// if oldOrderData.OrderType != domain.OrderReal {
|
|
|
// return lib.ThrowError(lib.BUSINESS_ERROR, fmt.Sprintf("指定的订单的订单类型发生变更"))
|
|
|
// }
|
|
|
// //获取旧的订单中的商品
|
|
|
// oldOrderGoods, _, err = orderGoodRepository.Find(domain.OrderGoodFindQuery{
|
|
|
// OrderId: cmd.Id,
|
|
|
// })
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("未找到指定的订单中的商品列表失败:%s", err))
|
|
|
// }
|
|
|
// for _, newGood := range cmd.GoodBouns {
|
|
|
// for i := range oldOrderGoods {
|
|
|
// if newGood.GoodId != oldOrderGoods[i].Id {
|
|
|
// continue
|
|
|
// }
|
|
|
// oldOrderGoods[i].UseGoodNumber = newGood.UseGoodNumber
|
|
|
// oldOrderGoods[i].Remark = newGood.Remark
|
|
|
// oldOrderGoods[i].BonusStatus = newGood.BounsStatus
|
|
|
// err = oldOrderGoods[i].Compute()
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的数值失败:%s", err))
|
|
|
// }
|
|
|
// switch newGood.BounsStatus {
|
|
|
// case domain.OrderGoodWaitPay:
|
|
|
// err = oldOrderGoods[i].CurrentBonusStatus.WartPayPartnerBonus(&oldOrderGoods[i])
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的分红数值失败:%s", err))
|
|
|
// }
|
|
|
// case domain.OrderGoodHasPay:
|
|
|
// err = oldOrderGoods[i].CurrentBonusStatus.PayPartnerBonus(&oldOrderGoods[i])
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中商品的分红数值失败:%s", err))
|
|
|
// }
|
|
|
// default:
|
|
|
// return lib.ThrowError(lib.ARG_ERROR, fmt.Sprintf("货品的支付状态错误"))
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// oldOrderData.Goods = oldOrderGoods
|
|
|
|
|
|
// err = oldOrderData.Compute()
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("核算订单中合计的数值失败:%s", err))
|
|
|
// }
|
|
|
// err = orderBaseRepository.Save(oldOrderData)
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单数据失败:%s", err))
|
|
|
// }
|
|
|
// err = orderGoodRepository.Save(oldOrderGoods)
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, fmt.Sprintf("保存订单中的商品数据失败:%s", err))
|
|
|
// }
|
|
|
// err = transactionContext.CommitTransaction()
|
|
|
// if err != nil {
|
|
|
// return lib.ThrowError(lib.INTERNAL_SERVER_ERROR, err.Error())
|
|
|
// }
|
|
|
// return nil
|
|
|
|
|
|
// }
|
|
|
|
|
|
//PageListOrderBouns 获取订单的分红列表
|
|
|
func (service OrderInfoService) PageListOrderBonus(listOrderQuery query.ListOrderBonusQuery) ([]map[string]interface{}, int, error) {
|
|
|
transactionContext, err := factory.CreateTransactionContext(nil)
|
...
|
...
|
|