作者 陈志颖

fix:共创合约参数修改

@@ -2,6 +2,11 @@ package domain @@ -2,6 +2,11 @@ package domain
2 2
3 import "time" 3 import "time"
4 4
  5 +const (
  6 + TO_BE_DIVIDENDED = iota + 1 // 待分红
  7 + DIVIDENDED // 已分红
  8 +)
  9 +
5 // OrderGood 订单产品领域实体(包括分红订单、分红退货单) 10 // OrderGood 订单产品领域实体(包括分红订单、分红退货单)
6 type OrderGood struct { 11 type OrderGood struct {
7 // 订单产品 12 // 订单产品
@@ -20,8 +25,10 @@ type OrderGood struct { @@ -20,8 +25,10 @@ type OrderGood struct {
20 DividendsReturnedOrderNumber string `json:"dividendsReturnedOrderNumber"` 25 DividendsReturnedOrderNumber string `json:"dividendsReturnedOrderNumber"`
21 // 关联的共创合约编号 26 // 关联的共创合约编号
22 CooperationContractNumber string `json:"cooperationContractNumber"` 27 CooperationContractNumber string `json:"cooperationContractNumber"`
23 - // 订单产品费用 28 + // 订单产品支出费用
24 OrderGoodExpense float64 `json:"orderGoodExpense"` 29 OrderGoodExpense float64 `json:"orderGoodExpense"`
  30 + // 订单产品分红状态, 1待分红,2已分红
  31 + OrderGoodDividendsStatus int32 `json:"OrderGoodDividendsStatus"`
25 // 组织机构ID 32 // 组织机构ID
26 OrgId int64 `json:"orgId"` 33 OrgId int64 `json:"orgId"`
27 // 公司ID 34 // 公司ID
@@ -67,8 +74,5 @@ func (orderGood *OrderGood) Update(data map[string]interface{}) error { @@ -67,8 +74,5 @@ func (orderGood *OrderGood) Update(data map[string]interface{}) error {
67 if orderGoodExpense, ok := data["orderGoodExpense"]; ok { 74 if orderGoodExpense, ok := data["orderGoodExpense"]; ok {
68 orderGood.OrderGoodExpense = orderGoodExpense.(float64) 75 orderGood.OrderGoodExpense = orderGoodExpense.(float64)
69 } 76 }
70 - if updatedAt, ok := data["updatedAt"]; ok {  
71 - orderGood.UpdatedAt = updatedAt.(time.Time)  
72 - }  
73 return nil 77 return nil
74 } 78 }
@@ -24,8 +24,10 @@ type OrderGood struct { @@ -24,8 +24,10 @@ type OrderGood struct {
24 OrgId int64 `comment:"组织机构ID"` 24 OrgId int64 `comment:"组织机构ID"`
25 // 公司ID 25 // 公司ID
26 CompanyId int64 `comment:"公司ID"` 26 CompanyId int64 `comment:"公司ID"`
27 - // 订单产品费用  
28 - OrderGoodExpense float64 `comment:"订单产品费用"` 27 + // 订单产品支出费用
  28 + OrderGoodExpense float64 `comment:"订单产品支出费用"`
  29 + // 订单产品分红状态, 1待分红,2已分红
  30 + OrderGoodDividendsStatus int32 `comment:"订单产品分红状态"`
29 // 创建时间 31 // 创建时间
30 CreatedAt time.Time `comment:"创建时间"` 32 CreatedAt time.Time `comment:"创建时间"`
31 // 删除时间 33 // 删除时间
@@ -15,6 +15,7 @@ func TransformToOrderGoodDomainModelFromPgModels(orderGoodModel *models.OrderGoo @@ -15,6 +15,7 @@ func TransformToOrderGoodDomainModelFromPgModels(orderGoodModel *models.OrderGoo
15 DividendsOrderNumber: orderGoodModel.DividendsOrderNumber, 15 DividendsOrderNumber: orderGoodModel.DividendsOrderNumber,
16 CooperationContractNumber: orderGoodModel.CooperationContractNumber, 16 CooperationContractNumber: orderGoodModel.CooperationContractNumber,
17 OrderGoodExpense: orderGoodModel.OrderGoodExpense, 17 OrderGoodExpense: orderGoodModel.OrderGoodExpense,
  18 + OrderGoodDividendsStatus: orderGoodModel.OrderGoodDividendsStatus,
18 OrgId: orderGoodModel.OrgId, 19 OrgId: orderGoodModel.OrgId,
19 CompanyId: orderGoodModel.CompanyId, 20 CompanyId: orderGoodModel.CompanyId,
20 CreatedAt: orderGoodModel.CreatedAt, 21 CreatedAt: orderGoodModel.CreatedAt,
@@ -117,9 +117,11 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -117,9 +117,11 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
117 CreatedAt: time.Time{}, 117 CreatedAt: time.Time{},
118 }) 118 })
119 } 119 }
  120 + if len(relevantPeopleModel) > 0 {
120 if _, err := tx.Model(&relevantPeopleModel).Insert(); err != nil { 121 if _, err := tx.Model(&relevantPeopleModel).Insert(); err != nil {
121 return nil, err 122 return nil, err
122 } 123 }
  124 + }
123 125
124 // 新增承接人 126 // 新增承接人
125 var undertakersModel []*models.CooperationContractUndertaker 127 var undertakersModel []*models.CooperationContractUndertaker
@@ -144,9 +146,11 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -144,9 +146,11 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
144 DeletedAt: time.Now(), 146 DeletedAt: time.Now(),
145 }) 147 })
146 } 148 }
  149 + if len(undertakersModel) > 0 {
147 if _, err := tx.Model(&undertakersModel).Insert(); err != nil { 150 if _, err := tx.Model(&undertakersModel).Insert(); err != nil {
148 return nil, err 151 return nil, err
149 } 152 }
  153 + }
150 154
151 // 新增分红激励规则 155 // 新增分红激励规则
152 var dividendsIncentivesRulesModel []*models.DividendsIncentivesRule 156 var dividendsIncentivesRulesModel []*models.DividendsIncentivesRule
@@ -166,9 +170,11 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -166,9 +170,11 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
166 CreatedAt: time.Now(), 170 CreatedAt: time.Now(),
167 }) 171 })
168 } 172 }
  173 + if len(dividendsIncentivesRulesModel) > 0 {
169 if _, err := tx.Model(&dividendsIncentivesRulesModel).Insert(); err != nil { 174 if _, err := tx.Model(&dividendsIncentivesRulesModel).Insert(); err != nil {
170 return nil, err 175 return nil, err
171 } 176 }
  177 + }
172 178
173 // 新增金额激励规则 179 // 新增金额激励规则
174 var moneyIncentivesRulesModel []*models.MoneyIncentivesRule 180 var moneyIncentivesRulesModel []*models.MoneyIncentivesRule
@@ -189,9 +195,11 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -189,9 +195,11 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
189 CreatedAt: time.Now(), 195 CreatedAt: time.Now(),
190 }) 196 })
191 } 197 }
  198 + if len(moneyIncentivesRulesModel) > 0 {
192 if _, err := tx.Model(&moneyIncentivesRulesModel).Insert(); err != nil { 199 if _, err := tx.Model(&moneyIncentivesRulesModel).Insert(); err != nil {
193 return nil, err 200 return nil, err
194 } 201 }
  202 + }
195 } else { 203 } else {
196 if _, err := tx.QueryOne( 204 if _, err := tx.QueryOne(
197 pg.Scan( 205 pg.Scan(
@@ -34,6 +34,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai @@ -34,6 +34,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai
34 "dividends_order_number", 34 "dividends_order_number",
35 "cooperation_contract_number", 35 "cooperation_contract_number",
36 "order_good_expense", 36 "order_good_expense",
  37 + "order_good_dividends_status",
37 "org_id", 38 "org_id",
38 "company_id", 39 "company_id",
39 "created_at", 40 "created_at",
@@ -63,6 +64,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai @@ -63,6 +64,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai
63 &orderGood.DividendsOrderNumber, 64 &orderGood.DividendsOrderNumber,
64 &orderGood.CooperationContractNumber, 65 &orderGood.CooperationContractNumber,
65 &orderGood.OrderGoodExpense, 66 &orderGood.OrderGoodExpense,
  67 + &orderGood.OrderGoodDividendsStatus,
66 &orderGood.OrgId, 68 &orderGood.OrgId,
67 &orderGood.CompanyId, 69 &orderGood.CompanyId,
68 &orderGood.CreatedAt, 70 &orderGood.CreatedAt,
@@ -78,6 +80,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai @@ -78,6 +80,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai
78 orderGood.DividendsOrderNumber, 80 orderGood.DividendsOrderNumber,
79 orderGood.CooperationContractNumber, 81 orderGood.CooperationContractNumber,
80 orderGood.OrderGoodExpense, 82 orderGood.OrderGoodExpense,
  83 + orderGood.OrderGoodDividendsStatus,
81 orderGood.OrgId, 84 orderGood.OrgId,
82 orderGood.CompanyId, 85 orderGood.CompanyId,
83 orderGood.CreatedAt, 86 orderGood.CreatedAt,
@@ -97,6 +100,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai @@ -97,6 +100,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai
97 &orderGood.DividendsOrderNumber, 100 &orderGood.DividendsOrderNumber,
98 &orderGood.CooperationContractNumber, 101 &orderGood.CooperationContractNumber,
99 &orderGood.OrderGoodExpense, 102 &orderGood.OrderGoodExpense,
  103 + &orderGood.OrderGoodDividendsStatus,
100 &orderGood.OrgId, 104 &orderGood.OrgId,
101 &orderGood.CompanyId, 105 &orderGood.CompanyId,
102 &orderGood.CreatedAt, 106 &orderGood.CreatedAt,
@@ -112,6 +116,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai @@ -112,6 +116,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai
112 orderGood.DividendsOrderNumber, 116 orderGood.DividendsOrderNumber,
113 orderGood.CooperationContractNumber, 117 orderGood.CooperationContractNumber,
114 orderGood.OrderGoodExpense, 118 orderGood.OrderGoodExpense,
  119 + orderGood.OrderGoodDividendsStatus,
115 orderGood.OrgId, 120 orderGood.OrgId,
116 orderGood.CompanyId, 121 orderGood.CompanyId,
117 orderGood.CreatedAt, 122 orderGood.CreatedAt,
@@ -124,6 +129,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai @@ -124,6 +129,7 @@ func (repository *OrderGoodRepository) Save(orderGood *domain.OrderGood) (*domai
124 } 129 }
125 return orderGood, nil 130 return orderGood, nil
126 } 131 }
  132 +
127 func (repository *OrderGoodRepository) Remove(orderGood *domain.OrderGood) (*domain.OrderGood, error) { 133 func (repository *OrderGoodRepository) Remove(orderGood *domain.OrderGood) (*domain.OrderGood, error) {
128 tx := repository.transactionContext.PgTx 134 tx := repository.transactionContext.PgTx
129 orderGoodModel := new(models.OrderGood) 135 orderGoodModel := new(models.OrderGood)
@@ -133,6 +139,7 @@ func (repository *OrderGoodRepository) Remove(orderGood *domain.OrderGood) (*dom @@ -133,6 +139,7 @@ func (repository *OrderGoodRepository) Remove(orderGood *domain.OrderGood) (*dom
133 } 139 }
134 return orderGood, nil 140 return orderGood, nil
135 } 141 }
  142 +
136 func (repository *OrderGoodRepository) FindOne(queryOptions map[string]interface{}) (*domain.OrderGood, error) { 143 func (repository *OrderGoodRepository) FindOne(queryOptions map[string]interface{}) (*domain.OrderGood, error) {
137 tx := repository.transactionContext.PgTx 144 tx := repository.transactionContext.PgTx
138 orderGoodModel := new(models.OrderGood) 145 orderGoodModel := new(models.OrderGood)
@@ -151,6 +158,7 @@ func (repository *OrderGoodRepository) FindOne(queryOptions map[string]interface @@ -151,6 +158,7 @@ func (repository *OrderGoodRepository) FindOne(queryOptions map[string]interface
151 return transform.TransformToOrderGoodDomainModelFromPgModels(orderGoodModel) 158 return transform.TransformToOrderGoodDomainModelFromPgModels(orderGoodModel)
152 } 159 }
153 } 160 }
  161 +
154 func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.OrderGood, error) { 162 func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{}) (int64, []*domain.OrderGood, error) {
155 tx := repository.transactionContext.PgTx 163 tx := repository.transactionContext.PgTx
156 var orderGoodModels []*models.OrderGood 164 var orderGoodModels []*models.OrderGood
@@ -177,6 +185,7 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{}) @@ -177,6 +185,7 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{})
177 return int64(count), orderGoods, nil 185 return int64(count), orderGoods, nil
178 } 186 }
179 } 187 }
  188 +
180 func NewOrderGoodRepository(transactionContext *pgTransaction.TransactionContext) (*OrderGoodRepository, error) { 189 func NewOrderGoodRepository(transactionContext *pgTransaction.TransactionContext) (*OrderGoodRepository, error) {
181 if transactionContext == nil { 190 if transactionContext == nil {
182 return nil, fmt.Errorf("transactionContext参数不能为nil") 191 return nil, fmt.Errorf("transactionContext参数不能为nil")
@@ -105,12 +105,16 @@ func (controller *DividendsEstimateController) BatchCancelDividendsEstimate() { @@ -105,12 +105,16 @@ func (controller *DividendsEstimateController) BatchCancelDividendsEstimate() {
105 func (controller *DividendsEstimateController) SearchDividendsEstimate() { 105 func (controller *DividendsEstimateController) SearchDividendsEstimate() {
106 dividendsEstimateService := service.NewDividendsEstimateService(nil) 106 dividendsEstimateService := service.NewDividendsEstimateService(nil)
107 searchDividendsEstimateQuery := &query.SearchDividendsEstimateQuery{} 107 searchDividendsEstimateQuery := &query.SearchDividendsEstimateQuery{}
108 - // 解析头部信息 108 + _ = controller.Unmarshal(searchDividendsEstimateQuery)
109 header := controller.GetRequestHeader(controller.Ctx) 109 header := controller.GetRequestHeader(controller.Ctx)
110 searchDividendsEstimateQuery.CompanyId = header.CompanyId 110 searchDividendsEstimateQuery.CompanyId = header.CompanyId
111 searchDividendsEstimateQuery.OrgId = header.OrgId 111 searchDividendsEstimateQuery.OrgId = header.OrgId
112 searchDividendsEstimateQuery.UserId = header.UserId 112 searchDividendsEstimateQuery.UserId = header.UserId
113 searchDividendsEstimateQuery.UserBaseId = header.UserBaseId 113 searchDividendsEstimateQuery.UserBaseId = header.UserBaseId
  114 + pageSize, _ := controller.GetInt64("pageSize")
  115 + searchDividendsEstimateQuery.PageSize = pageSize
  116 + pageNumber, _ := controller.GetInt64("pageNumber")
  117 + searchDividendsEstimateQuery.PageNumber = pageNumber
114 data, err := dividendsEstimateService.SearchDividendsEstimate(searchDividendsEstimateQuery) 118 data, err := dividendsEstimateService.SearchDividendsEstimate(searchDividendsEstimateQuery)
115 controller.Response(data, err) 119 controller.Response(data, err)
116 } 120 }
@@ -152,6 +156,10 @@ func (controller *DividendsEstimateController) ListMoneyIncentivesEstimate() { @@ -152,6 +156,10 @@ func (controller *DividendsEstimateController) ListMoneyIncentivesEstimate() {
152 listMoneyIncentivesEstimateQuery.OrgId = header.OrgId 156 listMoneyIncentivesEstimateQuery.OrgId = header.OrgId
153 listMoneyIncentivesEstimateQuery.UserId = header.UserId 157 listMoneyIncentivesEstimateQuery.UserId = header.UserId
154 listMoneyIncentivesEstimateQuery.UserBaseId = header.UserBaseId 158 listMoneyIncentivesEstimateQuery.UserBaseId = header.UserBaseId
  159 + pageSize, _ := controller.GetInt64("pageSize")
  160 + listMoneyIncentivesEstimateQuery.PageSize = pageSize
  161 + pageNumber, _ := controller.GetInt64("pageNumber")
  162 + listMoneyIncentivesEstimateQuery.PageNumber = pageNumber
155 data, err := dividendsEstimateService.ListMoneyIncentivesEstimate(listMoneyIncentivesEstimateQuery) 163 data, err := dividendsEstimateService.ListMoneyIncentivesEstimate(listMoneyIncentivesEstimateQuery)
156 controller.Response(data, err) 164 controller.Response(data, err)
157 } 165 }
@@ -160,11 +168,16 @@ func (controller *DividendsEstimateController) ListMoneyIncentivesEstimate() { @@ -160,11 +168,16 @@ func (controller *DividendsEstimateController) ListMoneyIncentivesEstimate() {
160 func (controller *DividendsEstimateController) SearchMoneyIncentivesEstimate() { 168 func (controller *DividendsEstimateController) SearchMoneyIncentivesEstimate() {
161 dividendsEstimateService := service.NewDividendsEstimateService(nil) 169 dividendsEstimateService := service.NewDividendsEstimateService(nil)
162 searchMoneyIncentivesEstimateQuery := &query.SearchMoneyIncentivesEstimateQuery{} 170 searchMoneyIncentivesEstimateQuery := &query.SearchMoneyIncentivesEstimateQuery{}
  171 + _ = controller.Unmarshal(searchMoneyIncentivesEstimateQuery)
163 header := controller.GetRequestHeader(controller.Ctx) 172 header := controller.GetRequestHeader(controller.Ctx)
164 searchMoneyIncentivesEstimateQuery.CompanyId = header.CompanyId 173 searchMoneyIncentivesEstimateQuery.CompanyId = header.CompanyId
165 searchMoneyIncentivesEstimateQuery.OrgId = header.OrgId 174 searchMoneyIncentivesEstimateQuery.OrgId = header.OrgId
166 searchMoneyIncentivesEstimateQuery.UserId = header.UserId 175 searchMoneyIncentivesEstimateQuery.UserId = header.UserId
167 searchMoneyIncentivesEstimateQuery.UserBaseId = header.UserBaseId 176 searchMoneyIncentivesEstimateQuery.UserBaseId = header.UserBaseId
  177 + pageSize, _ := controller.GetInt64("pageSize")
  178 + searchMoneyIncentivesEstimateQuery.PageSize = pageSize
  179 + pageNumber, _ := controller.GetInt64("pageNumber")
  180 + searchMoneyIncentivesEstimateQuery.PageNumber = pageNumber
168 data, err := dividendsEstimateService.SearchMoneyIncentivesEstimate(searchMoneyIncentivesEstimateQuery) 181 data, err := dividendsEstimateService.SearchMoneyIncentivesEstimate(searchMoneyIncentivesEstimateQuery)
169 controller.Response(data, err) 182 controller.Response(data, err)
170 } 183 }
@@ -178,6 +191,10 @@ func (controller *DividendsEstimateController) ListDividendsIncentivesEstimate() @@ -178,6 +191,10 @@ func (controller *DividendsEstimateController) ListDividendsIncentivesEstimate()
178 listDividendsIncentivesQuery.OrgId = header.OrgId 191 listDividendsIncentivesQuery.OrgId = header.OrgId
179 listDividendsIncentivesQuery.UserId = header.UserId 192 listDividendsIncentivesQuery.UserId = header.UserId
180 listDividendsIncentivesQuery.UserBaseId = header.UserBaseId 193 listDividendsIncentivesQuery.UserBaseId = header.UserBaseId
  194 + pageSize, _ := controller.GetInt64("pageSize")
  195 + listDividendsIncentivesQuery.PageSize = pageSize
  196 + pageNumber, _ := controller.GetInt64("pageNumber")
  197 + listDividendsIncentivesQuery.PageNumber = pageNumber
181 data, err := dividendsEstimateService.ListDividendsIncentivesEstimate(listDividendsIncentivesQuery) 198 data, err := dividendsEstimateService.ListDividendsIncentivesEstimate(listDividendsIncentivesQuery)
182 controller.Response(data, err) 199 controller.Response(data, err)
183 } 200 }
@@ -186,11 +203,16 @@ func (controller *DividendsEstimateController) ListDividendsIncentivesEstimate() @@ -186,11 +203,16 @@ func (controller *DividendsEstimateController) ListDividendsIncentivesEstimate()
186 func (controller *DividendsEstimateController) SearchDividendsIncentivesEstimate() { 203 func (controller *DividendsEstimateController) SearchDividendsIncentivesEstimate() {
187 dividendsEstimateService := service.NewDividendsEstimateService(nil) 204 dividendsEstimateService := service.NewDividendsEstimateService(nil)
188 searchDividendsIncentivesQuery := &query.SearchDividendsIncentivesEstimateQuery{} 205 searchDividendsIncentivesQuery := &query.SearchDividendsIncentivesEstimateQuery{}
  206 + _ = controller.Unmarshal(searchDividendsIncentivesQuery)
189 header := controller.GetRequestHeader(controller.Ctx) 207 header := controller.GetRequestHeader(controller.Ctx)
190 searchDividendsIncentivesQuery.CompanyId = header.CompanyId 208 searchDividendsIncentivesQuery.CompanyId = header.CompanyId
191 searchDividendsIncentivesQuery.OrgId = header.OrgId 209 searchDividendsIncentivesQuery.OrgId = header.OrgId
192 searchDividendsIncentivesQuery.UserId = header.UserId 210 searchDividendsIncentivesQuery.UserId = header.UserId
193 searchDividendsIncentivesQuery.UserBaseId = header.UserBaseId 211 searchDividendsIncentivesQuery.UserBaseId = header.UserBaseId
  212 + pageSize, _ := controller.GetInt64("pageSize")
  213 + searchDividendsIncentivesQuery.PageSize = pageSize
  214 + pageNumber, _ := controller.GetInt64("pageNumber")
  215 + searchDividendsIncentivesQuery.PageNumber = pageNumber
194 data, err := dividendsEstimateService.SearchDividendsIncentivesEstimate(searchDividendsIncentivesQuery) 216 data, err := dividendsEstimateService.SearchDividendsIncentivesEstimate(searchDividendsIncentivesQuery)
195 controller.Response(data, err) 217 controller.Response(data, err)
196 } 218 }