...
|
...
|
@@ -10,6 +10,7 @@ import ( |
|
|
"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"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
|
|
|
"strconv"
|
|
|
"time"
|
|
|
)
|
...
|
...
|
@@ -100,22 +101,29 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
|
} 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{}{
|
|
|
numberAvailable, err := dividendsOrderDao.CheckDividendsOrderNumberAvailable(map[string]interface{}{
|
|
|
"companyId": createDividendsOrderCommand.CompanyId,
|
|
|
"orgId": createDividendsOrderCommand.OrgId,
|
|
|
"dividendsOrderNumber": dividendsOrderNumber,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
|
|
|
}
|
|
|
if !numberAvailable {
|
|
|
return nil, application.ThrowError(application.TRANSACTION_ERROR, "新增分红订单异常")
|
|
|
}
|
|
|
|
|
|
// 获取订单产品
|
|
|
var orderGoods []*domain.OrderGood
|
|
|
var dividendsOrderAmount float64
|
|
|
for _, orderGood := range createDividendsOrderCommand.OrderGoods {
|
|
|
orderGoods = append(orderGoods, &domain.OrderGood{
|
|
|
OrderGoodId: 0,
|
...
|
...
|
@@ -126,22 +134,28 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
|
DividendsOrderNumber: dividendsOrderNumber,
|
|
|
DividendsReturnedOrderNumber: "",
|
|
|
CooperationContractNumber: orderGood.CooperationContractNumber,
|
|
|
OrderGoodExpense: 0,
|
|
|
OrderGoodExpense: orderGood.OrderGoodExpense,
|
|
|
OrgId: organization.OrgId,
|
|
|
CompanyId: company.CompanyId,
|
|
|
CreatedAt: time.Time{},
|
|
|
DeletedAt: time.Time{},
|
|
|
UpdatedAt: time.Time{},
|
|
|
})
|
|
|
// 计算分红订单金额
|
|
|
dividendsOrderAmount = dividendsOrderAmount + orderGood.OrderGoodAmount
|
|
|
}
|
|
|
|
|
|
// 订单时间转换
|
|
|
orderTimeInt, _ := strconv.ParseInt(createDividendsOrderCommand.OrderTime, 10, 64)
|
|
|
orderTime := utils.TransformTimestampToTime(orderTimeInt)
|
|
|
|
|
|
newDividendsOrder := &domain.DividendsOrder{
|
|
|
DividendsOrderId: 0,
|
|
|
DividendsOrderNumber: dividendsOrderNumber,
|
|
|
DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum,
|
|
|
DividendsOrderAmount: createDividendsOrderCommand.DividendsOrderAmount,
|
|
|
DividendsOrderAmount: dividendsOrderAmount,
|
|
|
OrderSalesman: salesman,
|
|
|
OrderTime: createDividendsOrderCommand.OrderTime,
|
|
|
OrderTime: orderTime,
|
|
|
DividendTime: time.Time{},
|
|
|
DividendStatus: 0,
|
|
|
Region: &domain.RegionInfo{
|
...
|
...
|
@@ -159,6 +173,7 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD |
|
|
Operator: operator,
|
|
|
}
|
|
|
|
|
|
// 分红订单仓储初始化
|
|
|
var dividendsOrderRepository domain.DividendsOrderRepository
|
|
|
if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
|
|
|
"transactionContext": transactionContext,
|
...
|
...
|
|