作者 陈志颖

fix:共创合约参数修改

... ... @@ -2,6 +2,11 @@ package domain
import "time"
const (
TO_BE_DIVIDENDED = iota + 1 // 待分红
DIVIDENDED // 已分红
)
// OrderGood 订单产品领域实体(包括分红订单、分红退货单)
type OrderGood struct {
// 订单产品
... ... @@ -20,8 +25,10 @@ type OrderGood struct {
DividendsReturnedOrderNumber string `json:"dividendsReturnedOrderNumber"`
// 关联的共创合约编号
CooperationContractNumber string `json:"cooperationContractNumber"`
// 订单产品费用
// 订单产品支出费用
OrderGoodExpense float64 `json:"orderGoodExpense"`
// 订单产品分红状态, 1待分红,2已分红
OrderGoodDividendsStatus int32 `json:"OrderGoodDividendsStatus"`
// 组织机构ID
OrgId int64 `json:"orgId"`
// 公司ID
... ... @@ -67,8 +74,5 @@ func (orderGood *OrderGood) Update(data map[string]interface{}) error {
if orderGoodExpense, ok := data["orderGoodExpense"]; ok {
orderGood.OrderGoodExpense = orderGoodExpense.(float64)
}
if updatedAt, ok := data["updatedAt"]; ok {
orderGood.UpdatedAt = updatedAt.(time.Time)
}
return nil
}
... ...
... ... @@ -24,8 +24,10 @@ type OrderGood struct {
OrgId int64 `comment:"组织机构ID"`
// 公司ID
CompanyId int64 `comment:"公司ID"`
// 订单产品费用
OrderGoodExpense float64 `comment:"订单产品费用"`
// 订单产品支出费用
OrderGoodExpense float64 `comment:"订单产品支出费用"`
// 订单产品分红状态, 1待分红,2已分红
OrderGoodDividendsStatus int32 `comment:"订单产品分红状态"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
// 删除时间
... ...
... ... @@ -15,6 +15,7 @@ func TransformToOrderGoodDomainModelFromPgModels(orderGoodModel *models.OrderGoo
DividendsOrderNumber: orderGoodModel.DividendsOrderNumber,
CooperationContractNumber: orderGoodModel.CooperationContractNumber,
OrderGoodExpense: orderGoodModel.OrderGoodExpense,
OrderGoodDividendsStatus: orderGoodModel.OrderGoodDividendsStatus,
OrgId: orderGoodModel.OrgId,
CompanyId: orderGoodModel.CompanyId,
CreatedAt: orderGoodModel.CreatedAt,
... ...
... ... @@ -117,8 +117,10 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
CreatedAt: time.Time{},
})
}
if _, err := tx.Model(&relevantPeopleModel).Insert(); err != nil {
return nil, err
if len(relevantPeopleModel) > 0 {
if _, err := tx.Model(&relevantPeopleModel).Insert(); err != nil {
return nil, err
}
}
// 新增承接人
... ... @@ -144,8 +146,10 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
DeletedAt: time.Now(),
})
}
if _, err := tx.Model(&undertakersModel).Insert(); err != nil {
return nil, err
if len(undertakersModel) > 0 {
if _, err := tx.Model(&undertakersModel).Insert(); err != nil {
return nil, err
}
}
// 新增分红激励规则
... ... @@ -166,8 +170,10 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
CreatedAt: time.Now(),
})
}
if _, err := tx.Model(&dividendsIncentivesRulesModel).Insert(); err != nil {
return nil, err
if len(dividendsIncentivesRulesModel) > 0 {
if _, err := tx.Model(&dividendsIncentivesRulesModel).Insert(); err != nil {
return nil, err
}
}
// 新增金额激励规则
... ... @@ -189,8 +195,10 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
CreatedAt: time.Now(),
})
}
if _, err := tx.Model(&moneyIncentivesRulesModel).Insert(); err != nil {
return nil, err
if len(moneyIncentivesRulesModel) > 0 {
if _, err := tx.Model(&moneyIncentivesRulesModel).Insert(); err != nil {
return nil, err
}
}
} else {
if _, err := tx.QueryOne(
... ...
... ... @@ -34,6 +34,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai
"dividends_order_number",
"cooperation_contract_number",
"order_good_expense",
"order_good_dividends_status",
"org_id",
"company_id",
"created_at",
... ... @@ -63,6 +64,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai
&orderGood.DividendsOrderNumber,
&orderGood.CooperationContractNumber,
&orderGood.OrderGoodExpense,
&orderGood.OrderGoodDividendsStatus,
&orderGood.OrgId,
&orderGood.CompanyId,
&orderGood.CreatedAt,
... ... @@ -78,6 +80,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai
orderGood.DividendsOrderNumber,
orderGood.CooperationContractNumber,
orderGood.OrderGoodExpense,
orderGood.OrderGoodDividendsStatus,
orderGood.OrgId,
orderGood.CompanyId,
orderGood.CreatedAt,
... ... @@ -97,6 +100,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai
&orderGood.DividendsOrderNumber,
&orderGood.CooperationContractNumber,
&orderGood.OrderGoodExpense,
&orderGood.OrderGoodDividendsStatus,
&orderGood.OrgId,
&orderGood.CompanyId,
&orderGood.CreatedAt,
... ... @@ -112,6 +116,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai
orderGood.DividendsOrderNumber,
orderGood.CooperationContractNumber,
orderGood.OrderGoodExpense,
orderGood.OrderGoodDividendsStatus,
orderGood.OrgId,
orderGood.CompanyId,
orderGood.CreatedAt,
... ... @@ -124,6 +129,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai
}
return orderGood, nil
}
func (repository *OrderGoodRepository) Remove(orderGood *domain.OrderGood) (*domain.OrderGood, error) {
tx := repository.transactionContext.PgTx
orderGoodModel := new(models.OrderGood)
... ... @@ -133,6 +139,7 @@ func (repository *OrderGoodRepository) Remove(orderGood *domain.OrderGood) (*dom
}
return orderGood, nil
}
func (repository *OrderGoodRepository) FindOne(queryOptions map[string]interface{}) (*domain.OrderGood, error) {
tx := repository.transactionContext.PgTx
orderGoodModel := new(models.OrderGood)
... ... @@ -151,6 +158,7 @@ func (repository *OrderGoodRepository) FindOne(queryOptions map[string]interface
return transform.TransformToOrderGoodDomainModelFromPgModels(orderGoodModel)
}
}
func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.OrderGood, error) {
tx := repository.transactionContext.PgTx
var orderGoodModels []*models.OrderGood
... ... @@ -177,6 +185,7 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{})
return int64(count), orderGoods, nil
}
}
func NewOrderGoodRepository(transactionContext *pgTransaction.TransactionContext) (*OrderGoodRepository, error) {
if transactionContext == nil {
return nil, fmt.Errorf("transactionContext参数不能为nil")
... ...
... ... @@ -105,12 +105,16 @@ func (controller *DividendsEstimateController) BatchCancelDividendsEstimate() {
func (controller *DividendsEstimateController) SearchDividendsEstimate() {
dividendsEstimateService := service.NewDividendsEstimateService(nil)
searchDividendsEstimateQuery := &query.SearchDividendsEstimateQuery{}
// 解析头部信息
_ = controller.Unmarshal(searchDividendsEstimateQuery)
header := controller.GetRequestHeader(controller.Ctx)
searchDividendsEstimateQuery.CompanyId = header.CompanyId
searchDividendsEstimateQuery.OrgId = header.OrgId
searchDividendsEstimateQuery.UserId = header.UserId
searchDividendsEstimateQuery.UserBaseId = header.UserBaseId
pageSize, _ := controller.GetInt64("pageSize")
searchDividendsEstimateQuery.PageSize = pageSize
pageNumber, _ := controller.GetInt64("pageNumber")
searchDividendsEstimateQuery.PageNumber = pageNumber
data, err := dividendsEstimateService.SearchDividendsEstimate(searchDividendsEstimateQuery)
controller.Response(data, err)
}
... ... @@ -152,6 +156,10 @@ func (controller *DividendsEstimateController) ListMoneyIncentivesEstimate() {
listMoneyIncentivesEstimateQuery.OrgId = header.OrgId
listMoneyIncentivesEstimateQuery.UserId = header.UserId
listMoneyIncentivesEstimateQuery.UserBaseId = header.UserBaseId
pageSize, _ := controller.GetInt64("pageSize")
listMoneyIncentivesEstimateQuery.PageSize = pageSize
pageNumber, _ := controller.GetInt64("pageNumber")
listMoneyIncentivesEstimateQuery.PageNumber = pageNumber
data, err := dividendsEstimateService.ListMoneyIncentivesEstimate(listMoneyIncentivesEstimateQuery)
controller.Response(data, err)
}
... ... @@ -160,11 +168,16 @@ func (controller *DividendsEstimateController) ListMoneyIncentivesEstimate() {
func (controller *DividendsEstimateController) SearchMoneyIncentivesEstimate() {
dividendsEstimateService := service.NewDividendsEstimateService(nil)
searchMoneyIncentivesEstimateQuery := &query.SearchMoneyIncentivesEstimateQuery{}
_ = controller.Unmarshal(searchMoneyIncentivesEstimateQuery)
header := controller.GetRequestHeader(controller.Ctx)
searchMoneyIncentivesEstimateQuery.CompanyId = header.CompanyId
searchMoneyIncentivesEstimateQuery.OrgId = header.OrgId
searchMoneyIncentivesEstimateQuery.UserId = header.UserId
searchMoneyIncentivesEstimateQuery.UserBaseId = header.UserBaseId
pageSize, _ := controller.GetInt64("pageSize")
searchMoneyIncentivesEstimateQuery.PageSize = pageSize
pageNumber, _ := controller.GetInt64("pageNumber")
searchMoneyIncentivesEstimateQuery.PageNumber = pageNumber
data, err := dividendsEstimateService.SearchMoneyIncentivesEstimate(searchMoneyIncentivesEstimateQuery)
controller.Response(data, err)
}
... ... @@ -178,6 +191,10 @@ func (controller *DividendsEstimateController) ListDividendsIncentivesEstimate()
listDividendsIncentivesQuery.OrgId = header.OrgId
listDividendsIncentivesQuery.UserId = header.UserId
listDividendsIncentivesQuery.UserBaseId = header.UserBaseId
pageSize, _ := controller.GetInt64("pageSize")
listDividendsIncentivesQuery.PageSize = pageSize
pageNumber, _ := controller.GetInt64("pageNumber")
listDividendsIncentivesQuery.PageNumber = pageNumber
data, err := dividendsEstimateService.ListDividendsIncentivesEstimate(listDividendsIncentivesQuery)
controller.Response(data, err)
}
... ... @@ -186,11 +203,16 @@ func (controller *DividendsEstimateController) ListDividendsIncentivesEstimate()
func (controller *DividendsEstimateController) SearchDividendsIncentivesEstimate() {
dividendsEstimateService := service.NewDividendsEstimateService(nil)
searchDividendsIncentivesQuery := &query.SearchDividendsIncentivesEstimateQuery{}
_ = controller.Unmarshal(searchDividendsIncentivesQuery)
header := controller.GetRequestHeader(controller.Ctx)
searchDividendsIncentivesQuery.CompanyId = header.CompanyId
searchDividendsIncentivesQuery.OrgId = header.OrgId
searchDividendsIncentivesQuery.UserId = header.UserId
searchDividendsIncentivesQuery.UserBaseId = header.UserBaseId
pageSize, _ := controller.GetInt64("pageSize")
searchDividendsIncentivesQuery.PageSize = pageSize
pageNumber, _ := controller.GetInt64("pageNumber")
searchDividendsIncentivesQuery.PageNumber = pageNumber
data, err := dividendsEstimateService.SearchDividendsIncentivesEstimate(searchDividendsIncentivesQuery)
controller.Response(data, err)
}
... ...