...
|
...
|
@@ -9,6 +9,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/dao"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
)
|
...
|
...
|
@@ -90,6 +91,29 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
|
salesman = data
|
|
|
}
|
|
|
|
|
|
// 分红订单DAO初始化
|
|
|
var dividendsOrderDao *dao.DividendsOrderDao
|
|
|
if value, err := factory.CreateDividendsOrderDao(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
|
|
}); err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
} else {
|
|
|
dividendsOrderDao = value
|
|
|
}
|
|
|
// 生成分红订单号
|
|
|
dividendsOrderNumber, err := dividendsOrderDao.GenerateDividendsOrderNumber()
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
// 校验分红订单编号是否唯一
|
|
|
numberAvailable, _ := dividendsOrderDao.CheckDividendsOrderNumberAvailable(map[string]interface{}{
|
|
|
"companyId": createDividendsOrderCommand.CompanyId,
|
|
|
"orgId": createDividendsOrderCommand.OrgId,
|
|
|
"dividendsOrderNumber": dividendsOrderNumber,
|
|
|
})
|
|
|
if !numberAvailable {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
|
|
|
}
|
|
|
// 获取订单产品
|
|
|
var orderGoods []*domain.OrderGood
|
|
|
for _, orderGood := range createDividendsOrderCommand.OrderGoods {
|
...
|
...
|
@@ -99,7 +123,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
|
OrderGoodName: orderGood.OrderGoodName,
|
|
|
OrderGoodPrice: orderGood.OrderGoodPrice,
|
|
|
OrderGoodQuantity: orderGood.OrderGoodQuantity,
|
|
|
DividendsOrderNumber: "", //TODO 分红订单号,规则生成
|
|
|
DividendsOrderNumber: dividendsOrderNumber,
|
|
|
DividendsReturnedOrderNumber: "",
|
|
|
CooperationContractNumber: orderGood.CooperationContractNumber,
|
|
|
OrderGoodExpense: 0,
|
...
|
...
|
@@ -113,7 +137,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
|
|
|
|
newDividendsOrder := &domain.DividendsOrder{
|
|
|
DividendsOrderId: 0,
|
|
|
DividendsOrderNumber: "", // TODO 分红订单号,规则生成
|
|
|
DividendsOrderNumber: dividendsOrderNumber,
|
|
|
DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum,
|
|
|
DividendsOrderAmount: createDividendsOrderCommand.DividendsOrderAmount,
|
|
|
OrderSalesman: salesman,
|
...
|
...
|
|