作者 yangfu

Merge branch 'dev' of http://gitlab.fjmaimaimai.com/allied-creation/allied-creat…

…ion-cooperation into dev
正在显示 39 个修改的文件 包含 624 行增加153 行删除
@@ -18,27 +18,6 @@ import ( @@ -18,27 +18,6 @@ import (
18 type CooperationApplicationService struct { 18 type CooperationApplicationService struct {
19 } 19 }
20 20
21 -// ApprovalCooperationApplication 审核共创申请  
22 -func (cooperationApplicationService *CooperationApplicationService) ApprovalCooperationApplication(approvalCooperationApplicationCommand *command.ApprovalCooperationApplicationCommand) (interface{}, error) {  
23 - if err := approvalCooperationApplicationCommand.ValidateCommand(); err != nil {  
24 - return nil, application.ThrowError(application.ARG_ERROR, err.Error())  
25 - }  
26 - transactionContext, err := factory.CreateTransactionContext(nil)  
27 - if err != nil {  
28 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
29 - }  
30 - if err := transactionContext.StartTransaction(); err != nil {  
31 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
32 - }  
33 - defer func() {  
34 - _ = transactionContext.RollbackTransaction()  
35 - }()  
36 - if err := transactionContext.CommitTransaction(); err != nil {  
37 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())  
38 - }  
39 - return nil, nil  
40 -}  
41 -  
42 // ApplyForCooperation 申请共创 21 // ApplyForCooperation 申请共创
43 func (cooperationApplicationService *CooperationApplicationService) ApplyForCooperation(applyForCooperationCommand *command.ApplyForCooperationCommand) (interface{}, error) { 22 func (cooperationApplicationService *CooperationApplicationService) ApplyForCooperation(applyForCooperationCommand *command.ApplyForCooperationCommand) (interface{}, error) {
44 if err := applyForCooperationCommand.ValidateCommand(); err != nil { 23 if err := applyForCooperationCommand.ValidateCommand(); err != nil {
@@ -68,8 +47,6 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -68,8 +47,6 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
68 } 47 }
69 if cooperationProject == nil { 48 if cooperationProject == nil {
70 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", applyForCooperationCommand.CooperationProjectNumber)) 49 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", applyForCooperationCommand.CooperationProjectNumber))
71 - } else {  
72 -  
73 } 50 }
74 51
75 // 用户REST服务初始化 52 // 用户REST服务初始化
@@ -156,9 +133,73 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop @@ -156,9 +133,73 @@ func (cooperationApplicationService *CooperationApplicationService) ApplyForCoop
156 } 133 }
157 } 134 }
158 135
159 -// BatchApprovalCooperationApplication 一键审核共创申请  
160 -func (cooperationApplicationService *CooperationApplicationService) BatchApprovalCooperationApplication(batchApprovalCooperatioinApplicatonCommand *command.BatchApprovalCooperationApplicationCommand) (interface{}, error) {  
161 - if err := batchApprovalCooperatioinApplicatonCommand.ValidateCommand(); err != nil { 136 +// ApprovalCooperationApplication 审核共创申请
  137 +func (cooperationApplicationService *CooperationApplicationService) ApprovalCooperationApplication(approvalCooperationApplicationCommand *command.ApprovalCooperationApplicationCommand) (interface{}, error) {
  138 + if err := approvalCooperationApplicationCommand.ValidateCommand(); err != nil {
  139 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  140 + }
  141 + transactionContext, err := factory.CreateTransactionContext(nil)
  142 + if err != nil {
  143 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  144 + }
  145 + if err := transactionContext.StartTransaction(); err != nil {
  146 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  147 + }
  148 + defer func() {
  149 + _ = transactionContext.RollbackTransaction()
  150 + }()
  151 + var cooperationApplicationRepository domain.CooperationApplicationRepository
  152 + if value, err := factory.CreateCooperationApplicationRepository(map[string]interface{}{
  153 + "transactionContext": transactionContext,
  154 + }); err != nil {
  155 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  156 + } else {
  157 + cooperationApplicationRepository = value
  158 + }
  159 + cooperationApplication, err := cooperationApplicationRepository.FindOne(map[string]interface{}{"cooperationApplicationId": approvalCooperationApplicationCommand.CooperationApplicationId})
  160 + if err != nil {
  161 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  162 + }
  163 + if cooperationApplication == nil {
  164 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(approvalCooperationApplicationCommand.CooperationApplicationId, 10)))
  165 + }
  166 + if err := cooperationApplication.Update(tool_funs.SimpleStructToMap(approvalCooperationApplicationCommand)); err != nil {
  167 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  168 + }
  169 + if cooperationApplicationSaved, err := cooperationApplicationRepository.Save(cooperationApplication); err != nil {
  170 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  171 + } else {
  172 + if err := transactionContext.CommitTransaction(); err != nil {
  173 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  174 + }
  175 + return cooperationApplicationSaved, nil
  176 + }
  177 +}
  178 +
  179 +// BatchApprovalCooperationApplication 批量审核共创申请
  180 +func (cooperationApplicationService *CooperationApplicationService) BatchApprovalCooperationApplication(batchApprovalCooperationApplicationCommand *command.BatchApprovalCooperationApplicationCommand) (interface{}, error) {
  181 + if err := batchApprovalCooperationApplicationCommand.ValidateCommand(); err != nil {
  182 + return nil, application.ThrowError(application.ARG_ERROR, err.Error())
  183 + }
  184 + transactionContext, err := factory.CreateTransactionContext(nil)
  185 + if err != nil {
  186 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  187 + }
  188 + if err := transactionContext.StartTransaction(); err != nil {
  189 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  190 + }
  191 + defer func() {
  192 + _ = transactionContext.RollbackTransaction()
  193 + }()
  194 + if err := transactionContext.CommitTransaction(); err != nil {
  195 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  196 + }
  197 + return nil, nil
  198 +}
  199 +
  200 +// OneClickApprovalCooperationApplication 一键审核共创申请
  201 +func (cooperationApplicationService *CooperationApplicationService) OneClickApprovalCooperationApplication(oneClickApprovalCooperationApplicationCommand *command.OneClickApprovalCooperationApplicationCommand) (interface{}, error) {
  202 + if err := oneClickApprovalCooperationApplicationCommand.ValidateCommand(); err != nil {
162 return nil, application.ThrowError(application.ARG_ERROR, err.Error()) 203 return nil, application.ThrowError(application.ARG_ERROR, err.Error())
163 } 204 }
164 transactionContext, err := factory.CreateTransactionContext(nil) 205 transactionContext, err := factory.CreateTransactionContext(nil)
@@ -540,6 +540,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper @@ -540,6 +540,7 @@ func (cooperationContractService *CooperationContractService) BatchOperateCooper
540 defer func() { 540 defer func() {
541 _ = transactionContext.RollbackTransaction() 541 _ = transactionContext.RollbackTransaction()
542 }() 542 }()
  543 + // 共创合约仓储初始化
543 var cooperationContractRepository domain.CooperationContractRepository 544 var cooperationContractRepository domain.CooperationContractRepository
544 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{ 545 if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
545 "transactionContext": transactionContext, 546 "transactionContext": transactionContext,
@@ -2,6 +2,7 @@ package command @@ -2,6 +2,7 @@ package command
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
5 "reflect" 6 "reflect"
6 "strings" 7 "strings"
7 8
@@ -9,10 +10,14 @@ import ( @@ -9,10 +10,14 @@ import (
9 ) 10 )
10 11
11 type PayCreditAccountCommand struct { 12 type PayCreditAccountCommand struct {
  13 + // 账期结算单ID
  14 + CreditAccountId string `cname:"账期结算单ID" json:"creditAccountId" valid:"Required"`
12 // 账期结算实付金额 15 // 账期结算实付金额
13 ActuallyPaidAmount float64 `cname:"账期结算实付金额" json:"actuallyPaidAmount" valid:"Required"` 16 ActuallyPaidAmount float64 `cname:"账期结算实付金额" json:"actuallyPaidAmount" valid:"Required"`
14 // 备注 17 // 备注
15 Remarks string `cname:"备注" json:"remarks" valid:"Required"` 18 Remarks string `cname:"备注" json:"remarks" valid:"Required"`
  19 + // 支付凭证附件
  20 + PaymentDocumentAttachment *domain.Attachment `cname:"支付凭证附件" json:"paymentDocumentAttachment" valid:"Required"`
16 // 公司ID,通过集成REST上下文获取 21 // 公司ID,通过集成REST上下文获取
17 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` 22 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
18 // 组织机构ID 23 // 组织机构ID
@@ -15,7 +15,7 @@ type SearchCreditAccountQuery struct { @@ -15,7 +15,7 @@ type SearchCreditAccountQuery struct {
15 // 页面大小 15 // 页面大小
16 PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"` 16 PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
17 // 账期结算单号 17 // 账期结算单号
18 - CreditAccountOrderNum string `cname:"账期结算单号" json:"creditAccountOrderNum"` 18 + CreditAccountOrderNum string `cname:"账期结算单号" json:"creditAccountOrderNum,omitempty"`
19 // 参与人姓名 19 // 参与人姓名
20 ParticipatorName string `cname:"参与人姓名" json:"participatorName,omitempty"` 20 ParticipatorName string `cname:"参与人姓名" json:"participatorName,omitempty"`
21 // 公司ID,通过集成REST上下文获取 21 // 公司ID,通过集成REST上下文获取
@@ -229,10 +229,34 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco @@ -229,10 +229,34 @@ func (creditAccountService *CreditAccountService) PayCreditAccount(payCreditAcco
229 defer func() { 229 defer func() {
230 _ = transactionContext.RollbackTransaction() 230 _ = transactionContext.RollbackTransaction()
231 }() 231 }()
232 - if err := transactionContext.CommitTransaction(); err != nil {  
233 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 232 + // 参数类型转换
  233 + creditAccountId, _ := strconv.ParseInt(payCreditAccountCommand.CreditAccountId, 10, 64)
  234 + var creditAccountRepository domain.CreditAccountRepository
  235 + if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
  236 + "transactionContext": transactionContext,
  237 + }); err != nil {
  238 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  239 + } else {
  240 + creditAccountRepository = value
  241 + }
  242 + creditAccount, err := creditAccountRepository.FindOne(map[string]interface{}{"creditAccountId": creditAccountId})
  243 + if err != nil {
  244 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  245 + }
  246 + if creditAccount == nil {
  247 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(creditAccountId, 10)))
  248 + }
  249 + if err := creditAccount.Update(tool_funs.SimpleStructToMap(payCreditAccountCommand)); err != nil {
  250 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  251 + }
  252 + if creditAccount, err := creditAccountRepository.Save(creditAccount); err != nil {
  253 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  254 + } else {
  255 + if err := transactionContext.CommitTransaction(); err != nil {
  256 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  257 + }
  258 + return creditAccount, nil
234 } 259 }
235 - return nil, nil  
236 } 260 }
237 261
238 // RemoveCreditAccount 移除账期结算单服务 262 // RemoveCreditAccount 移除账期结算单服务
@@ -290,10 +314,27 @@ func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCred @@ -290,10 +314,27 @@ func (creditAccountService *CreditAccountService) SearchCreditAccount(searchCred
290 defer func() { 314 defer func() {
291 _ = transactionContext.RollbackTransaction() 315 _ = transactionContext.RollbackTransaction()
292 }() 316 }()
293 - if err := transactionContext.CommitTransaction(); err != nil {  
294 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 317 + var creditAccountRepository domain.CreditAccountRepository
  318 + if value, err := factory.CreateCreditAccountRepository(map[string]interface{}{
  319 + "transactionContext": transactionContext,
  320 + }); err != nil {
  321 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  322 + } else {
  323 + creditAccountRepository = value
  324 + }
  325 + if count, creditAccounts, err := creditAccountRepository.Find(tool_funs.SimpleStructToMap(searchCreditAccountQuery)); err != nil {
  326 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  327 + } else {
  328 + if err := transactionContext.CommitTransaction(); err != nil {
  329 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  330 + }
  331 + return map[string]interface{}{
  332 + "grid": map[string]interface{}{
  333 + "total": count,
  334 + "list": creditAccounts,
  335 + },
  336 + }, nil
295 } 337 }
296 - return nil, nil  
297 } 338 }
298 339
299 // UpdateCreditAccount 更新账期结算单服务 340 // UpdateCreditAccount 更新账期结算单服务
@@ -10,16 +10,18 @@ import ( @@ -10,16 +10,18 @@ import (
10 10
11 // CancelDividendsEstimateCommand 取消分红预算 11 // CancelDividendsEstimateCommand 取消分红预算
12 type CancelDividendsEstimateCommand struct { 12 type CancelDividendsEstimateCommand struct {
13 - // 承接人分红预算记录ID  
14 - DividendsEstimateId string `cname:"承接人分红预算记录ID" json:"dividendsEstimateId" valid:"Required"`  
15 - // 公司ID,通过集成REST上下文获取 13 + // 承接人分红预算记录ID
  14 + DividendsEstimateId int64 `cname:"承接人分红预算记录ID" json:"dividendsEstimateId" valid:"Required"`
  15 + // 公司ID,通过集成REST上下文获取
16 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` 16 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
17 - // 组织机构ID 17 + // 组织机构ID
18 OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"` 18 OrgId int64 `cname:"组织机构ID" json:"orgId,string" valid:"Required"`
19 - // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 19 + // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
20 UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"` 20 UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"`
21 - // 用户基础数据id 21 + // 用户基础数据id
22 UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"` 22 UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"`
  23 + // 状态
  24 + IsCanceled bool `cname:"是否取消" json:"isCanceled,omitempty"`
23 } 25 }
24 26
25 func (cancelDividendsEstimateCommand *CancelDividendsEstimateCommand) Valid(validation *validation.Validation) { 27 func (cancelDividendsEstimateCommand *CancelDividendsEstimateCommand) Valid(validation *validation.Validation) {
@@ -8,6 +8,8 @@ import ( @@ -8,6 +8,8 @@ import (
8 type StageAndUndertaker struct { 8 type StageAndUndertaker struct {
9 // 分红阶段 9 // 分红阶段
10 Stage int32 `json:"stage"` 10 Stage int32 `json:"stage"`
  11 + // 共创承接人
  12 + Undertakers []*domain.Undertaker `json:"undertakers"`
11 } 13 }
12 14
13 type MoneyIncentivesEstimateDto struct { 15 type MoneyIncentivesEstimateDto struct {
@@ -18,11 +20,11 @@ type MoneyIncentivesEstimateDto struct { @@ -18,11 +20,11 @@ type MoneyIncentivesEstimateDto struct {
18 // 共创合约名称 20 // 共创合约名称
19 CooperationContractName string `json:"cooperationContractName"` 21 CooperationContractName string `json:"cooperationContractName"`
20 // 共创模式或者合伙模式 22 // 共创模式或者合伙模式
21 - CooperationMode *domain.CooperationMode `json:"cooperationMode"` 23 + CooperationModeName string `json:"cooperationMode"`
22 // 共创合约发起部门 24 // 共创合约发起部门
23 Department *domain.Department `json:"department"` 25 Department *domain.Department `json:"department"`
24 // 共创合约发起人 26 // 共创合约发起人
25 - CooperationContractSponsor *domain.User `json:"cooperationContractSponsor"` 27 + CooperationContractSponsorName string `json:"cooperationContractSponsor"`
26 // 创建合约时间 28 // 创建合约时间
27 CreatedAt time.Time `json:"createdAt"` 29 CreatedAt time.Time `json:"createdAt"`
28 // 阶段和承接人 30 // 阶段和承接人
@@ -31,5 +33,15 @@ type MoneyIncentivesEstimateDto struct { @@ -31,5 +33,15 @@ type MoneyIncentivesEstimateDto struct {
31 33
32 func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract) error { 34 func (dto *MoneyIncentivesEstimateDto) LoadDto(contract *domain.CooperationContract) error {
33 dto.CooperationContractId = contract.CooperationContractId 35 dto.CooperationContractId = contract.CooperationContractId
  36 + dto.CooperationContractNumber = contract.CooperationContractNumber
  37 + dto.CooperationContractName = contract.CooperationContractName
  38 + dto.CooperationModeName = contract.CooperationMode.CooperationModeName
  39 + dto.Department = contract.Department
  40 + dto.CooperationContractSponsorName = contract.CooperationContractSponsor.UserName
  41 + dto.CreatedAt = contract.CreatedAt
  42 + dto.StageAndUndertaker = &StageAndUndertaker{
  43 + Stage: 0,
  44 + Undertakers: []*domain.Undertaker{},
  45 + }
34 return nil 46 return nil
35 } 47 }
@@ -22,6 +22,8 @@ type ListMoneyIncentivesEstimateQuery struct { @@ -22,6 +22,8 @@ type ListMoneyIncentivesEstimateQuery struct {
22 UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"` 22 UserId int64 `cname:"用户ID" json:"userId,string" valid:"Required"`
23 // 用户基础数据id 23 // 用户基础数据id
24 UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"` 24 UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId,string" valid:"Required"`
  25 + // 激励方式
  26 + IncentivesType int32 `cname:"激励方式" json:"incentivesType,omitempty"`
25 } 27 }
26 28
27 func (listMoneyIncentivesEstimateQuery *ListMoneyIncentivesEstimateQuery) Valid(validation *validation.Validation) { 29 func (listMoneyIncentivesEstimateQuery *ListMoneyIncentivesEstimateQuery) Valid(validation *validation.Validation) {
@@ -11,9 +11,9 @@ import ( @@ -11,9 +11,9 @@ import (
11 // SearchDividendsEstimateQuery 查询分红预算单 11 // SearchDividendsEstimateQuery 查询分红预算单
12 type SearchDividendsEstimateQuery struct { 12 type SearchDividendsEstimateQuery struct {
13 // 承接人分红预算单号 13 // 承接人分红预算单号
14 - DividendsEstimateOrderNumber string `cname:"承接人分红预算单号" json:"dividendsEstimateOrderNumber" valid:"Required"` 14 + DividendsEstimateOrderNumber string `cname:"承接人分红预算单号" json:"dividendsEstimateOrderNumber,omitempty"`
15 // 分红类型,1订单分红,2退货冲销,3金额激励 15 // 分红类型,1订单分红,2退货冲销,3金额激励
16 - DividendsType int32 `cname:"分红类型" json:"dividendsType" valid:"Required"` 16 + DividendsType int32 `cname:"分红类型" json:"dividendsType,omitempty"`
17 // 公司ID,通过集成REST上下文获取 17 // 公司ID,通过集成REST上下文获取
18 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"` 18 CompanyId int64 `cname:"公司ID" json:"companyId,string" valid:"Required"`
19 // 组织机构ID 19 // 组织机构ID
@@ -26,6 +26,8 @@ type SearchMoneyIncentivesEstimateQuery struct { @@ -26,6 +26,8 @@ type SearchMoneyIncentivesEstimateQuery struct {
26 PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"` 26 PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"`
27 // 页面大小 27 // 页面大小
28 PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"` 28 PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"`
  29 + // 激励方式
  30 + IncentivesType int32 `cname:"激励方式" json:"incentivesType,omitempty"`
29 } 31 }
30 32
31 func (searchMoneyIncentivesEstimateQuery *SearchMoneyIncentivesEstimateQuery) Valid(validation *validation.Validation) { 33 func (searchMoneyIncentivesEstimateQuery *SearchMoneyIncentivesEstimateQuery) Valid(validation *validation.Validation) {
@@ -5,10 +5,12 @@ import ( @@ -5,10 +5,12 @@ import (
5 "github.com/linmadan/egglib-go/core/application" 5 "github.com/linmadan/egglib-go/core/application"
6 "github.com/linmadan/egglib-go/utils/tool_funs" 6 "github.com/linmadan/egglib-go/utils/tool_funs"
7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command" 7 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/command"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/dto"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/dividendsEstimate/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/factory"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain"
11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service" 12 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain/service"
  13 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
12 "strconv" 14 "strconv"
13 "time" 15 "time"
14 ) 16 )
@@ -32,10 +34,76 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive @@ -32,10 +34,76 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsIncentive
32 defer func() { 34 defer func() {
33 _ = transactionContext.RollbackTransaction() 35 _ = transactionContext.RollbackTransaction()
34 }() 36 }()
35 - if err := transactionContext.CommitTransaction(); err != nil {  
36 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 37 + // 分红订单仓储初始化
  38 + var dividendsOrderRepository domain.DividendsOrderRepository
  39 + if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
  40 + "transactionContext": transactionContext,
  41 + }); err != nil {
  42 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  43 + } else {
  44 + dividendsOrderRepository = value
  45 + }
  46 + // 分红退货单仓储初始化
  47 + var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
  48 + if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
  49 + "transactionContext": transactionContext,
  50 + }); err != nil {
  51 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  52 + } else {
  53 + dividendsReturnedOrderRepository = value
  54 + }
  55 +
  56 + // 订单产品仓储初始化
  57 + var orderGoodRepository domain.OrderGoodRepository
  58 + if value, err := factory.CreateOrderGoodRepository(map[string]interface{}{
  59 + "transactionContext": transactionContext,
  60 + }); err != nil {
  61 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  62 + } else {
  63 + orderGoodRepository = value
  64 + }
  65 +
  66 + // 获取订单产品
  67 + if count, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(listDividendsIncentivesEstimateQuery)); err != nil {
  68 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  69 + } else {
  70 + var dividendsIncentivesEstimateDtos []*dto.DividendsIncentivesEstimateDto
  71 + for _, orderGood := range orderGoods {
  72 + dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
  73 + if orderGood.DividendsOrderNumber != "" { // 查询分红订单
  74 + dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber})
  75 + if err != nil {
  76 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  77 + }
  78 + if dividendsOrder == nil {
  79 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
  80 + }
  81 + if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsOrder.DividendsOrderNumber, dividendsOrder.DividendsOriginalOrderNum, dividendsOrder.CustomerName, dividendsOrder.Region.RegionName, dividendsOrder.OrderTime); err != nil {
  82 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  83 + }
  84 + dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
  85 + } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
  86 + dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber})
  87 + if err != nil {
  88 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  89 + }
  90 + if dividendsReturnedOrder == nil {
  91 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
  92 + }
  93 + if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsReturnedOrder.DividendsReturnedOrderNumber, dividendsReturnedOrder.OriginalOrderNum, dividendsReturnedOrder.DividendsReturnedCustomerName, dividendsReturnedOrder.Region.RegionName, dividendsReturnedOrder.OrderTime); err != nil {
  94 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  95 + }
  96 + dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
  97 + }
  98 + }
  99 + if err := transactionContext.CommitTransaction(); err != nil {
  100 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  101 + }
  102 + return map[string]interface{}{
  103 + "total": count,
  104 + "list": dividendsIncentivesEstimateDtos,
  105 + }, nil
37 } 106 }
38 - return nil, nil  
39 } 107 }
40 108
41 // ListMoneyIncentivesEstimate 返回金额激励分红预算信息列表 109 // ListMoneyIncentivesEstimate 返回金额激励分红预算信息列表
@@ -53,10 +121,38 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst @@ -53,10 +121,38 @@ func (dividendsEstimateService *DividendsEstimateService) ListMoneyIncentivesEst
53 defer func() { 121 defer func() {
54 _ = transactionContext.RollbackTransaction() 122 _ = transactionContext.RollbackTransaction()
55 }() 123 }()
56 - if err := transactionContext.CommitTransaction(); err != nil {  
57 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 124 + // 共创合约仓储初始化
  125 + var cooperationContractRepository domain.CooperationContractRepository
  126 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  127 + "transactionContext": transactionContext,
  128 + }); err != nil {
  129 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  130 + } else {
  131 + cooperationContractRepository = value
  132 + }
  133 + // 查找共创合约
  134 + listMoneyIncentivesEstimateQuery.IncentivesType = 2
  135 + if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(listMoneyIncentivesEstimateQuery)); err != nil {
  136 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  137 + } else {
  138 + var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
  139 + for _, cooperationContract := range cooperationContracts {
  140 + moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
  141 + if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
  142 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  143 + }
  144 + moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
  145 + }
  146 + if err := transactionContext.CommitTransaction(); err != nil {
  147 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  148 + }
  149 + return map[string]interface{}{
  150 + "grid": map[string]interface{}{
  151 + "total": count,
  152 + "list": moneyIncentivesEstimateDtos,
  153 + },
  154 + }, nil
58 } 155 }
59 - return nil, nil  
60 } 156 }
61 157
62 // CancelDividendsEstimate 取消分红预算单 158 // CancelDividendsEstimate 取消分红预算单
@@ -74,10 +170,37 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat @@ -74,10 +170,37 @@ func (dividendsEstimateService *DividendsEstimateService) CancelDividendsEstimat
74 defer func() { 170 defer func() {
75 _ = transactionContext.RollbackTransaction() 171 _ = transactionContext.RollbackTransaction()
76 }() 172 }()
77 - if err := transactionContext.CommitTransaction(); err != nil {  
78 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 173 + // 分红预算仓储初始化
  174 + var dividendsEstimateRepository domain.DividendsEstimateRepository
  175 + if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
  176 + "transactionContext": transactionContext,
  177 + }); err != nil {
  178 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  179 + } else {
  180 + dividendsEstimateRepository = value
  181 + }
  182 + dividendsEstimate, err := dividendsEstimateRepository.FindOne(map[string]interface{}{"dividendsEstimateId": cancelDividendsEstimateCommand.DividendsEstimateId})
  183 + if err != nil {
  184 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  185 + }
  186 + if dividendsEstimate == nil {
  187 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cancelDividendsEstimateCommand.DividendsEstimateId, 10)))
  188 + }
  189 + // TODO 校验是否能够取消
  190 +
  191 + // 设置取消状态
  192 + cancelDividendsEstimateCommand.IsCanceled = true
  193 + if err := dividendsEstimate.Update(tool_funs.SimpleStructToMap(cancelDividendsEstimateCommand)); err != nil {
  194 + return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
  195 + }
  196 + if dividendsEstimate, err := dividendsEstimateRepository.Save(dividendsEstimate); err != nil {
  197 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  198 + } else {
  199 + if err := transactionContext.CommitTransaction(); err != nil {
  200 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  201 + }
  202 + return dividendsEstimate, nil
79 } 203 }
80 - return nil, nil  
81 } 204 }
82 205
83 // BatchCancelDividendsEstimate 批量取消分红预算单 206 // BatchCancelDividendsEstimate 批量取消分红预算单
@@ -95,10 +218,37 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs @@ -95,10 +218,37 @@ func (dividendsEstimateService *DividendsEstimateService) BatchCancelDividendsEs
95 defer func() { 218 defer func() {
96 _ = transactionContext.RollbackTransaction() 219 _ = transactionContext.RollbackTransaction()
97 }() 220 }()
98 - if err := transactionContext.CommitTransaction(); err != nil {  
99 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 221 + // 分红预算仓储初始化
  222 + var dividendsEstimateRepository domain.DividendsEstimateRepository
  223 + if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
  224 + "transactionContext": transactionContext,
  225 + }); err != nil {
  226 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  227 + } else {
  228 + dividendsEstimateRepository = value
  229 + }
  230 + dividendsEstimateIds, _ := utils.SliceAtoi(batchCancelEstimateCommand.DividendsEstimateIds)
  231 + if count, dividendsEstimates, err := dividendsEstimateRepository.Find(map[string]interface{}{
  232 + "dividendsEstimateIds": dividendsEstimateIds,
  233 + }); err != nil {
  234 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  235 + } else {
  236 + if count > 0 {
  237 + for i, _ := range dividendsEstimates {
  238 + dividendsEstimates[i].IsCanceled = true
  239 + }
  240 + dividendsEstimatesCanceled, err := dividendsEstimateRepository.UpdateMany(dividendsEstimates)
  241 + if err != nil {
  242 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  243 + }
  244 + if err := transactionContext.CommitTransaction(); err != nil {
  245 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  246 + }
  247 + return dividendsEstimatesCanceled, nil
  248 + } else {
  249 + return map[string]interface{}{}, nil
  250 + }
100 } 251 }
101 - return nil, nil  
102 } 252 }
103 253
104 // CreateDividendsEstimate 创建分红预算单 (预留) 254 // CreateDividendsEstimate 创建分红预算单 (预留)
@@ -297,6 +447,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsEstimate( @@ -297,6 +447,7 @@ func (dividendsEstimateService *DividendsEstimateService) ListDividendsEstimate(
297 defer func() { 447 defer func() {
298 _ = transactionContext.RollbackTransaction() 448 _ = transactionContext.RollbackTransaction()
299 }() 449 }()
  450 + // 分红预算仓储初始化
300 var dividendsEstimateRepository domain.DividendsEstimateRepository 451 var dividendsEstimateRepository domain.DividendsEstimateRepository
301 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{ 452 if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
302 "transactionContext": transactionContext, 453 "transactionContext": transactionContext,
@@ -375,10 +526,28 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsEstimat @@ -375,10 +526,28 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsEstimat
375 defer func() { 526 defer func() {
376 _ = transactionContext.RollbackTransaction() 527 _ = transactionContext.RollbackTransaction()
377 }() 528 }()
378 - if err := transactionContext.CommitTransaction(); err != nil {  
379 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 529 + // 分红预算仓储初始化
  530 + var dividendsEstimateRepository domain.DividendsEstimateRepository
  531 + if value, err := factory.CreateDividendsEstimateRepository(map[string]interface{}{
  532 + "transactionContext": transactionContext,
  533 + }); err != nil {
  534 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  535 + } else {
  536 + dividendsEstimateRepository = value
  537 + }
  538 + if count, dividendsEstimates, err := dividendsEstimateRepository.Find(tool_funs.SimpleStructToMap(searchDividendsEstimateQuery)); err != nil {
  539 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  540 + } else {
  541 + if err := transactionContext.CommitTransaction(); err != nil {
  542 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  543 + }
  544 + return map[string]interface{}{
  545 + "grid": map[string]interface{}{
  546 + "total": count,
  547 + "list": dividendsEstimates,
  548 + },
  549 + }, nil
380 } 550 }
381 - return nil, nil  
382 } 551 }
383 552
384 // SearchDividendsIncentivesEstimate 查询业绩激励分红预算 553 // SearchDividendsIncentivesEstimate 查询业绩激励分红预算
@@ -396,10 +565,76 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti @@ -396,10 +565,76 @@ func (dividendsEstimateService *DividendsEstimateService) SearchDividendsIncenti
396 defer func() { 565 defer func() {
397 _ = transactionContext.RollbackTransaction() 566 _ = transactionContext.RollbackTransaction()
398 }() 567 }()
399 - if err := transactionContext.CommitTransaction(); err != nil {  
400 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 568 + // 分红订单仓储初始化
  569 + var dividendsOrderRepository domain.DividendsOrderRepository
  570 + if value, err := factory.CreateDividendsOrderRepository(map[string]interface{}{
  571 + "transactionContext": transactionContext,
  572 + }); err != nil {
  573 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  574 + } else {
  575 + dividendsOrderRepository = value
  576 + }
  577 + // 分红退货单仓储初始化
  578 + var dividendsReturnedOrderRepository domain.DividendsReturnedOrderRepository
  579 + if value, err := factory.CreateDividendsReturnedOrderRepository(map[string]interface{}{
  580 + "transactionContext": transactionContext,
  581 + }); err != nil {
  582 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  583 + } else {
  584 + dividendsReturnedOrderRepository = value
  585 + }
  586 +
  587 + // 订单产品仓储初始化
  588 + var orderGoodRepository domain.OrderGoodRepository
  589 + if value, err := factory.CreateOrderGoodRepository(map[string]interface{}{
  590 + "transactionContext": transactionContext,
  591 + }); err != nil {
  592 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  593 + } else {
  594 + orderGoodRepository = value
  595 + }
  596 +
  597 + // 获取订单产品
  598 + if count, orderGoods, err := orderGoodRepository.Find(tool_funs.SimpleStructToMap(searchDividendsIncentivesEstimateQuery)); err != nil {
  599 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  600 + } else {
  601 + var dividendsIncentivesEstimateDtos []*dto.DividendsIncentivesEstimateDto
  602 + for _, orderGood := range orderGoods {
  603 + dividendsIncentivesEstimateDto := &dto.DividendsIncentivesEstimateDto{}
  604 + if orderGood.DividendsOrderNumber != "" { // 查询分红订单
  605 + dividendsOrder, err := dividendsOrderRepository.FindOne(map[string]interface{}{"dividendsOrderNumber": orderGood.DividendsOrderNumber})
  606 + if err != nil {
  607 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  608 + }
  609 + if dividendsOrder == nil {
  610 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsOrderNumber))
  611 + }
  612 + if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsOrder.DividendsOrderNumber, dividendsOrder.DividendsOriginalOrderNum, dividendsOrder.CustomerName, dividendsOrder.Region.RegionName, dividendsOrder.OrderTime); err != nil {
  613 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  614 + }
  615 + dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
  616 + } else if orderGood.DividendsReturnedOrderNumber != "" { // 查询分红退货单
  617 + dividendsReturnedOrder, err := dividendsReturnedOrderRepository.FindOne(map[string]interface{}{"dividendsReturnedOrderNumber": orderGood.DividendsReturnedOrderNumber})
  618 + if err != nil {
  619 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  620 + }
  621 + if dividendsReturnedOrder == nil {
  622 + return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", orderGood.DividendsReturnedOrderNumber))
  623 + }
  624 + if err := dividendsIncentivesEstimateDto.LoadDto(orderGood, dividendsReturnedOrder.DividendsReturnedOrderNumber, dividendsReturnedOrder.OriginalOrderNum, dividendsReturnedOrder.DividendsReturnedCustomerName, dividendsReturnedOrder.Region.RegionName, dividendsReturnedOrder.OrderTime); err != nil {
  625 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  626 + }
  627 + dividendsIncentivesEstimateDtos = append(dividendsIncentivesEstimateDtos, dividendsIncentivesEstimateDto)
  628 + }
  629 + }
  630 + if err := transactionContext.CommitTransaction(); err != nil {
  631 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  632 + }
  633 + return map[string]interface{}{
  634 + "total": count,
  635 + "list": dividendsIncentivesEstimateDtos,
  636 + }, nil
401 } 637 }
402 - return nil, nil  
403 } 638 }
404 639
405 // SearchMoneyIncentivesEstimate 查询金额激励分红预算 640 // SearchMoneyIncentivesEstimate 查询金额激励分红预算
@@ -417,10 +652,38 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE @@ -417,10 +652,38 @@ func (dividendsEstimateService *DividendsEstimateService) SearchMoneyIncentivesE
417 defer func() { 652 defer func() {
418 _ = transactionContext.RollbackTransaction() 653 _ = transactionContext.RollbackTransaction()
419 }() 654 }()
420 - if err := transactionContext.CommitTransaction(); err != nil {  
421 - return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) 655 + // 共创合约仓储初始化
  656 + var cooperationContractRepository domain.CooperationContractRepository
  657 + if value, err := factory.CreateCooperationContractRepository(map[string]interface{}{
  658 + "transactionContext": transactionContext,
  659 + }); err != nil {
  660 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  661 + } else {
  662 + cooperationContractRepository = value
  663 + }
  664 + // 查找共创合约
  665 + searchMoneyIncentivesEstimateQuery.IncentivesType = 2
  666 + if count, cooperationContracts, err := cooperationContractRepository.Find(tool_funs.SimpleStructToMap(searchMoneyIncentivesEstimateQuery)); err != nil {
  667 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  668 + } else {
  669 + var moneyIncentivesEstimateDtos []*dto.MoneyIncentivesEstimateDto
  670 + for _, cooperationContract := range cooperationContracts {
  671 + moneyIncentivesEstimateDto := &dto.MoneyIncentivesEstimateDto{}
  672 + if err := moneyIncentivesEstimateDto.LoadDto(cooperationContract); err != nil {
  673 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  674 + }
  675 + moneyIncentivesEstimateDtos = append(moneyIncentivesEstimateDtos, moneyIncentivesEstimateDto)
  676 + }
  677 + if err := transactionContext.CommitTransaction(); err != nil {
  678 + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
  679 + }
  680 + return map[string]interface{}{
  681 + "grid": map[string]interface{}{
  682 + "total": count,
  683 + "list": moneyIncentivesEstimateDtos,
  684 + },
  685 + }, nil
422 } 686 }
423 - return nil, nil  
424 } 687 }
425 688
426 // UpdateDividendsEstimate 更新分红预算单(预留) 689 // UpdateDividendsEstimate 更新分红预算单(预留)
@@ -35,8 +35,6 @@ type CreateDividendsOrderCommand struct { @@ -35,8 +35,6 @@ type CreateDividendsOrderCommand struct {
35 Remarks string `cname:"备注" json:"remarks" valid:"Required"` 35 Remarks string `cname:"备注" json:"remarks" valid:"Required"`
36 // 订单区域名称 36 // 订单区域名称
37 RegionName string `cname:"订单区域名称" json:"regionName,omitempty"` 37 RegionName string `cname:"订单区域名称" json:"regionName,omitempty"`
38 - // 订单业务员uid  
39 - SalesmanUid string `cname:"订单业务员uid" json:"salesmanUid,omitempty"`  
40 // 订单操作人uid 38 // 订单操作人uid
41 OperatorUid string `cname:"订单操作人uid" json:"operatorUid,omitempty"` 39 OperatorUid string `cname:"订单操作人uid" json:"operatorUid,omitempty"`
42 // 订单产品列表 40 // 订单产品列表
@@ -83,15 +83,6 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -83,15 +83,6 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
83 operator = data 83 operator = data
84 } 84 }
85 85
86 - // 获取业务员  
87 - commandSalesmanUid, _ := strconv.ParseInt(createDividendsOrderCommand.SalesmanUid, 10, 64)  
88 - var salesman *domain.Salesman  
89 - if data, err := userService.SalesmanFrom(createDividendsOrderCommand.CompanyId, createDividendsOrderCommand.OrgId, commandSalesmanUid); err != nil {  
90 - return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())  
91 - } else {  
92 - salesman = data  
93 - }  
94 -  
95 // 分红订单DAO初始化 86 // 分红订单DAO初始化
96 var dividendsOrderDao *dao.DividendsOrderDao 87 var dividendsOrderDao *dao.DividendsOrderDao
97 if value, err := factory.CreateDividendsOrderDao(map[string]interface{}{ 88 if value, err := factory.CreateDividendsOrderDao(map[string]interface{}{
@@ -154,7 +145,6 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD @@ -154,7 +145,6 @@ func (dividendsOrderService *DividendsOrderService) CreateDividendsOrder(createD
154 DividendsOrderNumber: dividendsOrderNumber, 145 DividendsOrderNumber: dividendsOrderNumber,
155 DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum, 146 DividendsOriginalOrderNum: createDividendsOrderCommand.DividendsOriginalOrderNum,
156 DividendsOrderAmount: dividendsOrderAmount, 147 DividendsOrderAmount: dividendsOrderAmount,
157 - OrderSalesman: salesman,  
158 OrderTime: orderTime, 148 OrderTime: orderTime,
159 DividendTime: time.Time{}, 149 DividendTime: time.Time{},
160 DividendStatus: 0, 150 DividendStatus: 0,
@@ -260,8 +250,7 @@ func (dividendsOrderService *DividendsOrderService) ListDividendsOrders(listDivi @@ -260,8 +250,7 @@ func (dividendsOrderService *DividendsOrderService) ListDividendsOrders(listDivi
260 } 250 }
261 return map[string]interface{}{ 251 return map[string]interface{}{
262 "grid": map[string]interface{}{ 252 "grid": map[string]interface{}{
263 - "total": count,  
264 - "list": dividendsOrders, 253 + "total": count, "list": dividendsOrders,
265 }, 254 },
266 }, nil 255 }, nil
267 } 256 }
@@ -40,6 +40,7 @@ type CooperationApplication struct { @@ -40,6 +40,7 @@ type CooperationApplication struct {
40 40
41 type CooperationApplicationRepository interface { 41 type CooperationApplicationRepository interface {
42 Save(cooperationApplication *CooperationApplication) (*CooperationApplication, error) 42 Save(cooperationApplication *CooperationApplication) (*CooperationApplication, error)
  43 + UpdateMany(cooperationApplications []*CooperationApplication) ([]*CooperationApplication, error)
43 Remove(cooperationApplication *CooperationApplication) (*CooperationApplication, error) 44 Remove(cooperationApplication *CooperationApplication) (*CooperationApplication, error)
44 FindOne(queryOptions map[string]interface{}) (*CooperationApplication, error) 45 FindOne(queryOptions map[string]interface{}) (*CooperationApplication, error)
45 Find(queryOptions map[string]interface{}) (int64, []*CooperationApplication, error) 46 Find(queryOptions map[string]interface{}) (int64, []*CooperationApplication, error)
@@ -36,6 +36,8 @@ type CooperationContract struct { @@ -36,6 +36,8 @@ type CooperationContract struct {
36 DividendsIncentivesRules []*DividendsIncentivesRule `json:"dividendsIncentivesRules"` 36 DividendsIncentivesRules []*DividendsIncentivesRule `json:"dividendsIncentivesRules"`
37 // 金额激励规则 37 // 金额激励规则
38 MoneyIncentivesRules []*MoneyIncentivesRule `json:"moneyIncentivesRules"` 38 MoneyIncentivesRules []*MoneyIncentivesRule `json:"moneyIncentivesRules"`
  39 + // 激励方式,1业绩分红激励,2金额激励
  40 + IncentivesType int32 `json:"incentivesType"`
39 // 共创承接人列表 41 // 共创承接人列表
40 Undertakers []*Undertaker `json:"undertakers"` 42 Undertakers []*Undertaker `json:"undertakers"`
41 // 共创合约相关人列表 43 // 共创合约相关人列表
@@ -42,6 +42,8 @@ type CreditAccount struct { @@ -42,6 +42,8 @@ type CreditAccount struct {
42 DeletedAt time.Time `json:"deletedAt"` 42 DeletedAt time.Time `json:"deletedAt"`
43 // 更新时间 43 // 更新时间
44 UpdatedAt time.Time `json:"updatedAt"` 44 UpdatedAt time.Time `json:"updatedAt"`
  45 + //备注
  46 + Remarks string `json:"remarks"`
45 } 47 }
46 48
47 type CreditAccountRepository interface { 49 type CreditAccountRepository interface {
@@ -68,5 +70,14 @@ func (creditAccount *CreditAccount) Update(data map[string]interface{}) error { @@ -68,5 +70,14 @@ func (creditAccount *CreditAccount) Update(data map[string]interface{}) error {
68 if paymentStatus, ok := data["paymentStatus"]; ok { 70 if paymentStatus, ok := data["paymentStatus"]; ok {
69 creditAccount.PaymentStatus = paymentStatus.(int32) 71 creditAccount.PaymentStatus = paymentStatus.(int32)
70 } 72 }
  73 + if paymentDocumentAttachment, ok := data["paymentDocumentAttachment"]; ok {
  74 + creditAccount.PaymentDocumentAttachment = paymentDocumentAttachment.(*Attachment)
  75 + }
  76 + if remarks, ok := data["remarks"]; ok {
  77 + creditAccount.Remarks = remarks.(string)
  78 + }
  79 + if actuallyPaidAmount, ok := data["actuallyPaidAmount"]; ok {
  80 + creditAccount.ActuallyPaidAmount = actuallyPaidAmount.(float64)
  81 + }
71 return nil 82 return nil
72 } 83 }
@@ -46,6 +46,8 @@ type DividendsEstimate struct { @@ -46,6 +46,8 @@ type DividendsEstimate struct {
46 Operator *User `json:"operator"` 46 Operator *User `json:"operator"`
47 // 操作时间 47 // 操作时间
48 OperateTime time.Time `json:"operateTime"` 48 OperateTime time.Time `json:"operateTime"`
  49 + // 取消状态
  50 + IsCanceled bool `json:"isCanceled"`
49 // 创建时间 51 // 创建时间
50 CreatedAt time.Time `json:"createdAt"` 52 CreatedAt time.Time `json:"createdAt"`
51 // 删除时间 53 // 删除时间
@@ -94,5 +96,8 @@ func (dividendsEstimate *DividendsEstimate) Update(data map[string]interface{}) @@ -94,5 +96,8 @@ func (dividendsEstimate *DividendsEstimate) Update(data map[string]interface{})
94 if cooperationProjectNumber, ok := data["cooperationProjectNumber"]; ok { 96 if cooperationProjectNumber, ok := data["cooperationProjectNumber"]; ok {
95 dividendsEstimate.CooperationContractNumber = cooperationProjectNumber.(string) 97 dividendsEstimate.CooperationContractNumber = cooperationProjectNumber.(string)
96 } 98 }
  99 + if isCanceled, ok := data["isCanceled"]; ok {
  100 + dividendsEstimate.IsCanceled = isCanceled.(bool)
  101 + }
97 return nil 102 return nil
98 } 103 }
@@ -12,9 +12,7 @@ type DividendsOrder struct { @@ -12,9 +12,7 @@ type DividendsOrder struct {
12 DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"` 12 DividendsOriginalOrderNum string `json:"dividendsOriginalOrderNum"`
13 // 分红订单金额 13 // 分红订单金额
14 DividendsOrderAmount float64 `json:"dividendsOrderAmount"` 14 DividendsOrderAmount float64 `json:"dividendsOrderAmount"`
15 - // 订单业务员  
16 - OrderSalesman *Salesman `json:"orderSalesman"`  
17 - // 订单产生时间 15 + // 订单日期
18 OrderTime time.Time `json:"orderTime"` 16 OrderTime time.Time `json:"orderTime"`
19 // 分红订单分红时间 17 // 分红订单分红时间
20 DividendTime time.Time `json:"dividendTime"` 18 DividendTime time.Time `json:"dividendTime"`
@@ -69,45 +67,6 @@ func (dividendsOrder *DividendsOrder) Update(data map[string]interface{}) error @@ -69,45 +67,6 @@ func (dividendsOrder *DividendsOrder) Update(data map[string]interface{}) error
69 if dividendsOrderAmount, ok := data["dividendsOrderAmount"]; ok { 67 if dividendsOrderAmount, ok := data["dividendsOrderAmount"]; ok {
70 dividendsOrder.DividendsOrderAmount = dividendsOrderAmount.(float64) 68 dividendsOrder.DividendsOrderAmount = dividendsOrderAmount.(float64)
71 } 69 }
72 - if userId, ok := data["userId"]; ok {  
73 - dividendsOrder.OrderSalesman.UserId = userId.(int64)  
74 - }  
75 - if userBaseId, ok := data["userBaseId"]; ok {  
76 - dividendsOrder.OrderSalesman.UserBaseId = userBaseId.(int64)  
77 - }  
78 - if orgId, ok := data["orgId"]; ok {  
79 - dividendsOrder.OrderSalesman.Org.OrgId = orgId.(int64)  
80 - }  
81 - if orgName, ok := data["orgName"]; ok {  
82 - dividendsOrder.OrderSalesman.Org.OrgName = orgName.(string)  
83 - }  
84 - if companyId, ok := data["companyId"]; ok {  
85 - dividendsOrder.OrderSalesman.Org.Company.CompanyId = companyId.(int64)  
86 - }  
87 - if companyLogo, ok := data["companyLogo"]; ok {  
88 - dividendsOrder.OrderSalesman.Org.Company.CompanyLogo = companyLogo.(string)  
89 - }  
90 - if companyName, ok := data["companyName"]; ok {  
91 - dividendsOrder.OrderSalesman.Org.Company.CompanyName = companyName.(string)  
92 - }  
93 - if userAvatar, ok := data["userAvatar"]; ok {  
94 - dividendsOrder.OrderSalesman.UserInfo.UserAvatar = userAvatar.(string)  
95 - }  
96 - if userEmail, ok := data["userEmail"]; ok {  
97 - dividendsOrder.OrderSalesman.UserInfo.UserEmail = userEmail.(string)  
98 - }  
99 - if userName, ok := data["userName"]; ok {  
100 - dividendsOrder.OrderSalesman.UserInfo.UserName = userName.(string)  
101 - }  
102 - if userPhone, ok := data["userPhone"]; ok {  
103 - dividendsOrder.OrderSalesman.UserInfo.UserPhone = userPhone.(string)  
104 - }  
105 - if userAccount, ok := data["userAccount"]; ok {  
106 - dividendsOrder.OrderSalesman.UserInfo.UserAccount = userAccount.(string)  
107 - }  
108 - if userType, ok := data["userType"]; ok {  
109 - dividendsOrder.OrderSalesman.UserType = userType.(int32)  
110 - }  
111 if orderTime, ok := data["orderTime"]; ok { 70 if orderTime, ok := data["orderTime"]; ok {
112 dividendsOrder.OrderTime = orderTime.(time.Time) 71 dividendsOrder.OrderTime = orderTime.(time.Time)
113 } 72 }
@@ -16,6 +16,8 @@ type DividendsReturnedOrder struct { @@ -16,6 +16,8 @@ type DividendsReturnedOrder struct {
16 DividendsOrderNumber string `json:"dividendsOrderNumber"` 16 DividendsOrderNumber string `json:"dividendsOrderNumber"`
17 // 退货客户姓名 17 // 退货客户姓名
18 DividendsReturnedCustomerName string `json:"dividendsReturnedCustomerName"` 18 DividendsReturnedCustomerName string `json:"dividendsReturnedCustomerName"`
  19 + // 订单日期
  20 + OrderTime time.Time `json:"orderTime"`
19 // 退货日期 21 // 退货日期
20 DividendsReturnedDate time.Time `json:"dividendsReturnedDate"` 22 DividendsReturnedDate time.Time `json:"dividendsReturnedDate"`
21 // 退货区域 23 // 退货区域
@@ -60,9 +62,6 @@ func (dividendsReturnedOrder *DividendsReturnedOrder) Identify() interface{} { @@ -60,9 +62,6 @@ func (dividendsReturnedOrder *DividendsReturnedOrder) Identify() interface{} {
60 } 62 }
61 63
62 func (dividendsReturnedOrder *DividendsReturnedOrder) Update(data map[string]interface{}) error { 64 func (dividendsReturnedOrder *DividendsReturnedOrder) Update(data map[string]interface{}) error {
63 - if dividendsReturnedOrderNumber, ok := data["dividendsReturnedOrderNumber"]; ok {  
64 - dividendsReturnedOrder.DividendsReturnedOrderNumber = dividendsReturnedOrderNumber.(string)  
65 - }  
66 if dividendsReturnedOrderRefund, ok := data["dividendsReturnedOrderRefund"]; ok { 65 if dividendsReturnedOrderRefund, ok := data["dividendsReturnedOrderRefund"]; ok {
67 dividendsReturnedOrder.DividendsReturnedOrderRefund = dividendsReturnedOrderRefund.(float64) 66 dividendsReturnedOrder.DividendsReturnedOrderRefund = dividendsReturnedOrderRefund.(float64)
68 } 67 }
@@ -23,10 +23,12 @@ type CooperationContract struct { @@ -23,10 +23,12 @@ type CooperationContract struct {
23 CooperationContractSponsor *domain.User `comment:"共创合约发起人"` 23 CooperationContractSponsor *domain.User `comment:"共创合约发起人"`
24 // 共创模式编号 24 // 共创模式编号
25 CooperationModeNumber string `comment:"共创模式编号"` 25 CooperationModeNumber string `comment:"共创模式编号"`
26 - // 合约状态,1启用,2禁用  
27 - Status int32 `comment:"合约状态,1启用,2禁用"` 26 + // 合约状态,1正常,2暂停
  27 + Status int32 `comment:"合约状态,1正常,2暂停"`
28 // 数据所属组织机构 28 // 数据所属组织机构
29 Org *domain.Org `comment:"数据所属组织机构"` 29 Org *domain.Org `comment:"数据所属组织机构"`
  30 + // 激励方式,1业绩分红激励,2金额激励
  31 + IncentivesType int32 `comment:"激励方式"`
30 // 公司 32 // 公司
31 Company *domain.Company `comment:"公司"` 33 Company *domain.Company `comment:"公司"`
32 // 共创合约发起部门 34 // 共创合约发起部门
@@ -23,8 +23,8 @@ type CreditAccount struct { @@ -23,8 +23,8 @@ type CreditAccount struct {
23 SettlementTime time.Time `comment:"共创账期结算时间"` 23 SettlementTime time.Time `comment:"共创账期结算时间"`
24 // 共创合约编号 24 // 共创合约编号
25 CooperationContractNumber string `comment:"共创合约编号"` 25 CooperationContractNumber string `comment:"共创合约编号"`
26 - // 参与人uid,包括承接人、推荐人、关联业务员  
27 - Participator *domain.Participator `comment:"参与人uid,包括承接人、推荐人、关联业务员" pg:",array"` 26 + // 参与人,包括承接人、推荐人、关联业务员
  27 + Participator *domain.Participator `comment:"参与人,包括承接人、推荐人、关联业务员"`
28 // 参与类型 28 // 参与类型
29 ParticipateType string `comment:"参与类型,承接人,推荐人,业务员"` 29 ParticipateType string `comment:"参与类型,承接人,推荐人,业务员"`
30 // 结算明细 30 // 结算明细
@@ -45,4 +45,6 @@ type CreditAccount struct { @@ -45,4 +45,6 @@ type CreditAccount struct {
45 DeletedAt time.Time `comment:"删除时间"` 45 DeletedAt time.Time `comment:"删除时间"`
46 // 更新时间 46 // 更新时间
47 UpdatedAt time.Time `comment:"更新时间"` 47 UpdatedAt time.Time `comment:"更新时间"`
  48 + // 备注
  49 + Remarks string `comment:"备注"`
48 } 50 }
@@ -37,6 +37,8 @@ type DividendsEstimate struct { @@ -37,6 +37,8 @@ type DividendsEstimate struct {
37 Operator *domain.User `comment:"操作人"` 37 Operator *domain.User `comment:"操作人"`
38 // 操作时间 38 // 操作时间
39 OperateTime time.Time `comment:"操作时间"` 39 OperateTime time.Time `comment:"操作时间"`
  40 + // 取消状态
  41 + IsCanceled bool `comment:"取消状态"`
40 // 创建时间 42 // 创建时间
41 CreatedAt time.Time `comment:"创建时间"` 43 CreatedAt time.Time `comment:"创建时间"`
42 // 删除时间 44 // 删除时间
@@ -15,8 +15,6 @@ type DividendsOrder struct { @@ -15,8 +15,6 @@ type DividendsOrder struct {
15 DividendsOriginalOrderNum string `comment:"分红订单原单号"` 15 DividendsOriginalOrderNum string `comment:"分红订单原单号"`
16 // 分红订单金额 16 // 分红订单金额
17 DividendsOrderAmount float64 `comment:"分红订单金额"` 17 DividendsOrderAmount float64 `comment:"分红订单金额"`
18 - // 订单业务员  
19 - OrderSalesman *domain.Salesman `comment:"订单业务员"`  
20 // 订单产生时间 18 // 订单产生时间
21 OrderTime time.Time `comment:"订单产生时间"` 19 OrderTime time.Time `comment:"订单产生时间"`
22 // 分红订单分红时间 20 // 分红订单分红时间
@@ -19,6 +19,8 @@ type DividendsReturnedOrder struct { @@ -19,6 +19,8 @@ type DividendsReturnedOrder struct {
19 DividendsOrderNumber string `comment:"关联分红订单号"` 19 DividendsOrderNumber string `comment:"关联分红订单号"`
20 // 退货客户姓名 20 // 退货客户姓名
21 DividendsReturnedCustomerName string `comment:"退货客户姓名"` 21 DividendsReturnedCustomerName string `comment:"退货客户姓名"`
  22 + // 订单日期
  23 + OrderTime time.Time `comment:"订单日期"`
22 // 退货日期 24 // 退货日期
23 DividendsReturnedDate time.Time `comment:"退货日期"` 25 DividendsReturnedDate time.Time `comment:"退货日期"`
24 // 退货区域 26 // 退货区域
@@ -118,6 +118,7 @@ func TransformToCooperationContractDomainModelFromPgModels( @@ -118,6 +118,7 @@ func TransformToCooperationContractDomainModelFromPgModels(
118 RelevantPeople: relevantPeopleDomain, 118 RelevantPeople: relevantPeopleDomain,
119 Undertakers: undertakersDomain, 119 Undertakers: undertakersDomain,
120 Status: cooperationContractModel.Status, 120 Status: cooperationContractModel.Status,
  121 + IncentivesType: cooperationContractModel.IncentivesType,
121 Org: cooperationContractModel.Org, 122 Org: cooperationContractModel.Org,
122 Company: cooperationContractModel.Company, 123 Company: cooperationContractModel.Company,
123 Department: cooperationContractModel.Department, 124 Department: cooperationContractModel.Department,
@@ -26,5 +26,6 @@ func TransformToCreditAccountDomainModelFromPgModels(creditAccountModel *models. @@ -26,5 +26,6 @@ func TransformToCreditAccountDomainModelFromPgModels(creditAccountModel *models.
26 CreatedAt: creditAccountModel.CreatedAt, 26 CreatedAt: creditAccountModel.CreatedAt,
27 DeletedAt: creditAccountModel.DeletedAt, 27 DeletedAt: creditAccountModel.DeletedAt,
28 UpdatedAt: creditAccountModel.UpdatedAt, 28 UpdatedAt: creditAccountModel.UpdatedAt,
  29 + Remarks: creditAccountModel.Remarks,
29 }, nil 30 }, nil
30 } 31 }
@@ -22,6 +22,7 @@ func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel @@ -22,6 +22,7 @@ func TransformToDividendsEstimateDomainModelFromPgModels(dividendsEstimateModel
22 Company: dividendsEstimateModel.Company, 22 Company: dividendsEstimateModel.Company,
23 Operator: dividendsEstimateModel.Operator, 23 Operator: dividendsEstimateModel.Operator,
24 OperateTime: dividendsEstimateModel.OperateTime, 24 OperateTime: dividendsEstimateModel.OperateTime,
  25 + IsCanceled: dividendsEstimateModel.IsCanceled,
25 CreatedAt: dividendsEstimateModel.CreatedAt, 26 CreatedAt: dividendsEstimateModel.CreatedAt,
26 DeletedAt: dividendsEstimateModel.DeletedAt, 27 DeletedAt: dividendsEstimateModel.DeletedAt,
27 UpdatedAt: dividendsEstimateModel.UpdatedAt, 28 UpdatedAt: dividendsEstimateModel.UpdatedAt,
@@ -28,7 +28,6 @@ func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *model @@ -28,7 +28,6 @@ func TransformToDividendsOrderDomainModelFromPgModels(dividendsOrderModel *model
28 DividendsOrderNumber: dividendsOrderModel.DividendsOrderNumber, 28 DividendsOrderNumber: dividendsOrderModel.DividendsOrderNumber,
29 DividendsOriginalOrderNum: dividendsOrderModel.DividendsOriginalOrderNum, 29 DividendsOriginalOrderNum: dividendsOrderModel.DividendsOriginalOrderNum,
30 DividendsOrderAmount: dividendsOrderModel.DividendsOrderAmount, 30 DividendsOrderAmount: dividendsOrderModel.DividendsOrderAmount,
31 - OrderSalesman: dividendsOrderModel.OrderSalesman,  
32 OrderTime: dividendsOrderModel.OrderTime, 31 OrderTime: dividendsOrderModel.OrderTime,
33 DividendTime: dividendsOrderModel.DividendTime, 32 DividendTime: dividendsOrderModel.DividendTime,
34 DividendStatus: dividendsOrderModel.DividendStatus, 33 DividendStatus: dividendsOrderModel.DividendStatus,
@@ -32,6 +32,7 @@ func TransformToDividendsReturnedOrderDomainModelFromPgModels( @@ -32,6 +32,7 @@ func TransformToDividendsReturnedOrderDomainModelFromPgModels(
32 OriginalOrderNum: dividendsReturnedOrderModel.OriginalOrderNum, 32 OriginalOrderNum: dividendsReturnedOrderModel.OriginalOrderNum,
33 DividendsOrderNumber: dividendsReturnedOrderModel.DividendsOrderNumber, 33 DividendsOrderNumber: dividendsReturnedOrderModel.DividendsOrderNumber,
34 DividendsReturnedCustomerName: dividendsReturnedOrderModel.DividendsReturnedCustomerName, 34 DividendsReturnedCustomerName: dividendsReturnedOrderModel.DividendsReturnedCustomerName,
  35 + OrderTime: dividendsReturnedOrderModel.OrderTime,
35 DividendsReturnedDate: dividendsReturnedOrderModel.DividendsReturnedDate, 36 DividendsReturnedDate: dividendsReturnedOrderModel.DividendsReturnedDate,
36 Region: dividendsReturnedOrderModel.Region, 37 Region: dividendsReturnedOrderModel.Region,
37 Remarks: dividendsReturnedOrderModel.Remarks, 38 Remarks: dividendsReturnedOrderModel.Remarks,
@@ -3,6 +3,7 @@ package repository @@ -3,6 +3,7 @@ package repository
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "github.com/go-pg/pg/v10" 5 "github.com/go-pg/pg/v10"
  6 + "time"
6 7
7 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" 8 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
8 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 9 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
@@ -141,6 +142,35 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication @@ -141,6 +142,35 @@ func (repository *CooperationApplicationRepository) Save(cooperationApplication
141 return cooperationApplication, nil 142 return cooperationApplication, nil
142 } 143 }
143 144
  145 +func (repository *CooperationApplicationRepository) UpdateMany(cooperationApplications []*domain.CooperationApplication) ([]*domain.CooperationApplication, error) {
  146 + tx := repository.transactionContext.PgTx
  147 + var cooperationApplicationModels []*models.CooperationApplication
  148 + for _, cooperationApplication := range cooperationApplications {
  149 + cooperationApplicationModels = append(cooperationApplicationModels, &models.CooperationApplication{
  150 + CooperationApplicationId: cooperationApplication.CooperationApplicationId,
  151 + CooperationApplicationApplicant: cooperationApplication.CooperationApplicationApplicant,
  152 + CooperationApplicationAttachment: cooperationApplication.CooperationApplicationAttachment,
  153 + CooperationApplicationDescription: cooperationApplication.CooperationApplicationDescription,
  154 + CooperationApplicationStatus: cooperationApplication.CooperationApplicationStatus,
  155 + CooperationApplicationVerifier: cooperationApplication.CooperationApplicationVerifier,
  156 + CooperationApplicationVerifyDescription: cooperationApplication.CooperationApplicationVerifyDescription,
  157 + CooperationApplicationVerifyTime: cooperationApplication.CooperationApplicationVerifyTime,
  158 + CooperationApplyTime: cooperationApplication.CooperationApplyTime,
  159 + CooperationProjectNumber: cooperationApplication.CooperationProject.CooperationProjectNumber,
  160 + Org: cooperationApplication.Org,
  161 + IsCanceled: cooperationApplication.IsCanceled,
  162 + Company: cooperationApplication.Company,
  163 + CreatedAt: cooperationApplication.CreatedAt,
  164 + DeletedAt: cooperationApplication.DeletedAt,
  165 + UpdatedAt: time.Now(),
  166 + })
  167 + }
  168 + if _, err := tx.Model(&cooperationApplicationModels).WherePK().Update(); err != nil {
  169 + return nil, err
  170 + }
  171 + return cooperationApplications, nil
  172 +}
  173 +
144 func (repository *CooperationApplicationRepository) Remove(cooperationApplication *domain.CooperationApplication) (*domain.CooperationApplication, error) { 174 func (repository *CooperationApplicationRepository) Remove(cooperationApplication *domain.CooperationApplication) (*domain.CooperationApplication, error) {
145 tx := repository.transactionContext.PgTx 175 tx := repository.transactionContext.PgTx
146 cooperationApplicationModel := new(models.CooperationApplication) 176 cooperationApplicationModel := new(models.CooperationApplication)
@@ -194,7 +224,7 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string @@ -194,7 +224,7 @@ func (repository *CooperationApplicationRepository) Find(queryOptions map[string
194 query.Where(`(cooperation_application.cooperation_application_applicant->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", applicantName)) 224 query.Where(`(cooperation_application.cooperation_application_applicant->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", applicantName))
195 } 225 }
196 if cooperationApplicationStatus, ok := queryOptions["cooperationApplicationStatus"]; ok && cooperationApplicationStatus.(int32) != 0 { 226 if cooperationApplicationStatus, ok := queryOptions["cooperationApplicationStatus"]; ok && cooperationApplicationStatus.(int32) != 0 {
197 - 227 + query.Where("cooperation_application_status = ?", cooperationApplicationStatus)
198 } 228 }
199 offsetLimitFlag := true 229 offsetLimitFlag := true
200 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 230 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
@@ -38,6 +38,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -38,6 +38,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
38 "cooperation_mode_number", 38 "cooperation_mode_number",
39 "status", 39 "status",
40 "org", 40 "org",
  41 + "incentives_type",
41 "company", 42 "company",
42 "operator", 43 "operator",
43 "operate_time", 44 "operate_time",
@@ -70,6 +71,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -70,6 +71,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
70 &cooperationContract.CooperationMode.CooperationModeNumber, 71 &cooperationContract.CooperationMode.CooperationModeNumber,
71 &cooperationContract.Status, 72 &cooperationContract.Status,
72 &cooperationContract.Org, 73 &cooperationContract.Org,
  74 + &cooperationContract.IncentivesType,
73 &cooperationContract.Company, 75 &cooperationContract.Company,
74 &cooperationContract.Operator, 76 &cooperationContract.Operator,
75 &cooperationContract.OperateTime, 77 &cooperationContract.OperateTime,
@@ -88,6 +90,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -88,6 +90,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
88 cooperationContract.CooperationMode.CooperationModeNumber, 90 cooperationContract.CooperationMode.CooperationModeNumber,
89 cooperationContract.Status, 91 cooperationContract.Status,
90 cooperationContract.Org, 92 cooperationContract.Org,
  93 + cooperationContract.IncentivesType,
91 cooperationContract.Company, 94 cooperationContract.Company,
92 cooperationContract.Operator, 95 cooperationContract.Operator,
93 cooperationContract.OperateTime, 96 cooperationContract.OperateTime,
@@ -213,6 +216,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -213,6 +216,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
213 &cooperationContract.CooperationMode.CooperationModeNumber, 216 &cooperationContract.CooperationMode.CooperationModeNumber,
214 &cooperationContract.Status, 217 &cooperationContract.Status,
215 &cooperationContract.Org, 218 &cooperationContract.Org,
  219 + &cooperationContract.IncentivesType,
216 &cooperationContract.Company, 220 &cooperationContract.Company,
217 &cooperationContract.Operator, 221 &cooperationContract.Operator,
218 &cooperationContract.OperateTime, 222 &cooperationContract.OperateTime,
@@ -231,6 +235,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai @@ -231,6 +235,7 @@ func (repository *CooperationContractRepository) Save(cooperationContract *domai
231 cooperationContract.CooperationMode.CooperationModeNumber, 235 cooperationContract.CooperationMode.CooperationModeNumber,
232 cooperationContract.Status, 236 cooperationContract.Status,
233 cooperationContract.Org, 237 cooperationContract.Org,
  238 + cooperationContract.IncentivesType,
234 cooperationContract.Company, 239 cooperationContract.Company,
235 cooperationContract.Operator, 240 cooperationContract.Operator,
236 cooperationContract.OperateTime, 241 cooperationContract.OperateTime,
@@ -826,7 +831,13 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in @@ -826,7 +831,13 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
826 cooperationContracts := make([]*domain.CooperationContract, 0) 831 cooperationContracts := make([]*domain.CooperationContract, 0)
827 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractModels), queryOptions) 832 query := sqlbuilder.BuildQuery(tx.Model(&cooperationContractModels), queryOptions)
828 if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" { 833 if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
829 - query.Where("cooperation_contract_number like ?", fmt.Sprintf("%%%s%%", cooperationContractNumber)) 834 + query.Where("cooperation_contract_number ilike ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
  835 + }
  836 + if cooperationContractName, ok := queryOptions["cooperationContactName"]; ok && cooperationContractName != "" {
  837 + query.Where("cooperation_contract_name like ?", fmt.Sprintf("%%%s%%", cooperationContractName))
  838 + }
  839 + if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
  840 + query.Where(`(cooperation_contract.department->>'departmentName')::test LIKE ?`, fmt.Sprintf("%%%s%%", departmentName))
830 } 841 }
831 if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" { 842 if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" {
832 query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName)) 843 query.Where(`(cooperation_contract.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName))
@@ -834,6 +845,15 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in @@ -834,6 +845,15 @@ func (repository *CooperationContractRepository) Find(queryOptions map[string]in
834 if cooperationContractIds, ok := queryOptions["cooperationContractIds"]; ok && len(cooperationContractIds.([]int64)) != 0 { 845 if cooperationContractIds, ok := queryOptions["cooperationContractIds"]; ok && len(cooperationContractIds.([]int64)) != 0 {
835 query.Where("cooperation_contract_id in (?)", pg.In(cooperationContractIds)) 846 query.Where("cooperation_contract_id in (?)", pg.In(cooperationContractIds))
836 } 847 }
  848 + if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
  849 + query.Where("company->>'companyId' = '?'", companyId)
  850 + }
  851 + if orgId, ok := queryOptions["orgId"]; ok && orgId.(int64) != 0 {
  852 + query.Where("org->>'orgId' = '?'", orgId)
  853 + }
  854 + if incentivesType, ok := queryOptions["incentivesType"]; ok && incentivesType.(int32) != 0 {
  855 + query.Where("incentives_type = ?", incentivesType)
  856 + }
837 offsetLimitFlag := true 857 offsetLimitFlag := true
838 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 858 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
839 offsetLimitFlag = offsetLimit.(bool) 859 offsetLimitFlag = offsetLimit.(bool)
@@ -46,6 +46,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco @@ -46,6 +46,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
46 "created_at", 46 "created_at",
47 "deleted_at", 47 "deleted_at",
48 "updated_at", 48 "updated_at",
  49 + "remarks",
49 } 50 }
50 insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields) 51 insertFieldsSnippet := sqlbuilder.SqlFieldsSnippet(sqlBuildFields)
51 insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields) 52 insertPlaceHoldersSnippet := sqlbuilder.SqlPlaceHoldersSnippet(sqlBuildFields)
@@ -81,6 +82,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco @@ -81,6 +82,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
81 &creditAccount.CreatedAt, 82 &creditAccount.CreatedAt,
82 &creditAccount.DeletedAt, 83 &creditAccount.DeletedAt,
83 &creditAccount.UpdatedAt, 84 &creditAccount.UpdatedAt,
  85 + &creditAccount.Remarks,
84 ), 86 ),
85 fmt.Sprintf("INSERT INTO credit_accounts (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet), 87 fmt.Sprintf("INSERT INTO credit_accounts (%s) VALUES (%s) RETURNING %s", insertFieldsSnippet, insertPlaceHoldersSnippet, returningFieldsSnippet),
86 creditAccount.CreditAccountId, 88 creditAccount.CreditAccountId,
@@ -100,8 +102,9 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco @@ -100,8 +102,9 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
100 creditAccount.Operator, 102 creditAccount.Operator,
101 creditAccount.OperateTime, 103 creditAccount.OperateTime,
102 creditAccount.CreatedAt, 104 creditAccount.CreatedAt,
103 - creditAccount.DeletedAt, 105 + nil,
104 creditAccount.UpdatedAt, 106 creditAccount.UpdatedAt,
  107 + creditAccount.Remarks,
105 ); err != nil { 108 ); err != nil {
106 return creditAccount, err 109 return creditAccount, err
107 } 110 }
@@ -127,6 +130,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco @@ -127,6 +130,7 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
127 &creditAccount.CreatedAt, 130 &creditAccount.CreatedAt,
128 &creditAccount.DeletedAt, 131 &creditAccount.DeletedAt,
129 &creditAccount.UpdatedAt, 132 &creditAccount.UpdatedAt,
  133 + &creditAccount.Remarks,
130 ), 134 ),
131 fmt.Sprintf("UPDATE credit_accounts SET %s WHERE credit_account_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet), 135 fmt.Sprintf("UPDATE credit_accounts SET %s WHERE credit_account_id=? RETURNING %s", updateFieldsSnippet, returningFieldsSnippet),
132 creditAccount.CreditAccountId, 136 creditAccount.CreditAccountId,
@@ -146,8 +150,9 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco @@ -146,8 +150,9 @@ func (repository *CreditAccountRepository) Save(creditAccount *domain.CreditAcco
146 creditAccount.Operator, 150 creditAccount.Operator,
147 creditAccount.OperateTime, 151 creditAccount.OperateTime,
148 creditAccount.CreatedAt, 152 creditAccount.CreatedAt,
149 - creditAccount.DeletedAt, 153 + nil,
150 creditAccount.UpdatedAt, 154 creditAccount.UpdatedAt,
  155 + creditAccount.Remarks,
151 creditAccount.Identify(), 156 creditAccount.Identify(),
152 ); err != nil { 157 ); err != nil {
153 return creditAccount, err 158 return creditAccount, err
@@ -190,6 +195,15 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac @@ -190,6 +195,15 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
190 var creditAccountModels []*models.CreditAccount 195 var creditAccountModels []*models.CreditAccount
191 creditAccounts := make([]*domain.CreditAccount, 0) 196 creditAccounts := make([]*domain.CreditAccount, 0)
192 query := sqlbuilder.BuildQuery(tx.Model(&creditAccountModels), queryOptions) 197 query := sqlbuilder.BuildQuery(tx.Model(&creditAccountModels), queryOptions)
  198 + if creditAccountOrderNum, ok := queryOptions["creditAccountOrderNum"]; ok && creditAccountOrderNum != "" {
  199 + query.Where("credit_account_order_num ilike ?", fmt.Sprintf("%%%s%%", creditAccountOrderNum))
  200 + }
  201 + if participatorName, ok := queryOptions["participatorName"]; ok && participatorName != "" {
  202 + query.Where(`(credit_account.participator->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", participatorName))
  203 + }
  204 + if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 {
  205 + query.Where("payment_status = ?", paymentStatus)
  206 + }
193 offsetLimitFlag := true 207 offsetLimitFlag := true
194 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 208 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
195 offsetLimitFlag = offsetLimit.(bool) 209 offsetLimitFlag = offsetLimit.(bool)
@@ -3,6 +3,7 @@ package repository @@ -3,6 +3,7 @@ package repository
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "github.com/go-pg/pg/v10" 5 "github.com/go-pg/pg/v10"
  6 + "time"
6 7
7 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" 8 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
8 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 9 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
@@ -42,6 +43,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -42,6 +43,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
42 "company", 43 "company",
43 "operator", 44 "operator",
44 "operate_time", 45 "operate_time",
  46 + "is_canceled",
45 "created_at", 47 "created_at",
46 "deleted_at", 48 "deleted_at",
47 "updated_at", 49 "updated_at",
@@ -76,6 +78,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -76,6 +78,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
76 &dividendsEstimate.Company, 78 &dividendsEstimate.Company,
77 &dividendsEstimate.Operator, 79 &dividendsEstimate.Operator,
78 &dividendsEstimate.OperateTime, 80 &dividendsEstimate.OperateTime,
  81 + &dividendsEstimate.IsCanceled,
79 &dividendsEstimate.CreatedAt, 82 &dividendsEstimate.CreatedAt,
80 &dividendsEstimate.DeletedAt, 83 &dividendsEstimate.DeletedAt,
81 &dividendsEstimate.UpdatedAt, 84 &dividendsEstimate.UpdatedAt,
@@ -96,8 +99,9 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -96,8 +99,9 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
96 dividendsEstimate.Company, 99 dividendsEstimate.Company,
97 dividendsEstimate.Operator, 100 dividendsEstimate.Operator,
98 dividendsEstimate.OperateTime, 101 dividendsEstimate.OperateTime,
  102 + dividendsEstimate.IsCanceled,
99 dividendsEstimate.CreatedAt, 103 dividendsEstimate.CreatedAt,
100 - dividendsEstimate.DeletedAt, 104 + nil,
101 dividendsEstimate.UpdatedAt, 105 dividendsEstimate.UpdatedAt,
102 ); err != nil { 106 ); err != nil {
103 return dividendsEstimate, err 107 return dividendsEstimate, err
@@ -120,6 +124,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -120,6 +124,7 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
120 &dividendsEstimate.Company, 124 &dividendsEstimate.Company,
121 &dividendsEstimate.Operator, 125 &dividendsEstimate.Operator,
122 &dividendsEstimate.OperateTime, 126 &dividendsEstimate.OperateTime,
  127 + &dividendsEstimate.IsCanceled,
123 &dividendsEstimate.CreatedAt, 128 &dividendsEstimate.CreatedAt,
124 &dividendsEstimate.DeletedAt, 129 &dividendsEstimate.DeletedAt,
125 &dividendsEstimate.UpdatedAt, 130 &dividendsEstimate.UpdatedAt,
@@ -140,8 +145,9 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -140,8 +145,9 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
140 dividendsEstimate.Company, 145 dividendsEstimate.Company,
141 dividendsEstimate.Operator, 146 dividendsEstimate.Operator,
142 dividendsEstimate.OperateTime, 147 dividendsEstimate.OperateTime,
  148 + dividendsEstimate.IsCanceled,
143 dividendsEstimate.CreatedAt, 149 dividendsEstimate.CreatedAt,
144 - dividendsEstimate.DeletedAt, 150 + nil,
145 dividendsEstimate.UpdatedAt, 151 dividendsEstimate.UpdatedAt,
146 dividendsEstimate.Identify(), 152 dividendsEstimate.Identify(),
147 ); err != nil { 153 ); err != nil {
@@ -152,7 +158,35 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di @@ -152,7 +158,35 @@ func (repository *DividendsEstimateRepository) Save(dividendsEstimate *domain.Di
152 } 158 }
153 159
154 func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []*domain.DividendsEstimate) ([]*domain.DividendsEstimate, error) { 160 func (repository *DividendsEstimateRepository) UpdateMany(dividendsEstimates []*domain.DividendsEstimate) ([]*domain.DividendsEstimate, error) {
155 - panic("implement me") 161 + tx := repository.transactionContext.PgTx
  162 + var dividendsEstimateModels []*models.DividendsEstimate
  163 + for _, dividendsEstimate := range dividendsEstimates {
  164 + dividendsEstimateModels = append(dividendsEstimateModels, &models.DividendsEstimate{
  165 + DividendsEstimateId: dividendsEstimate.DividendsEstimateId,
  166 + DividendsAccountStatus: dividendsEstimate.DividendsAccountStatus,
  167 + DividendsAmount: dividendsEstimate.DividendsAmount,
  168 + DividendsEstimateOrderNumber: dividendsEstimate.DividendsEstimateOrderNumber,
  169 + DividendsEstimateTime: dividendsEstimate.DividendsEstimateTime,
  170 + DividendsParticipateType: dividendsEstimate.DividendsParticipateType,
  171 + DividendsType: dividendsEstimate.DividendsType,
  172 + OrderOrReturnedOrderNum: dividendsEstimate.OrderOrReturnedOrderNum,
  173 + CooperationContractNumber: dividendsEstimate.CooperationContractNumber,
  174 + DividendsUser: dividendsEstimate.DividendsUser,
  175 + DividendsStage: dividendsEstimate.DividendsStage,
  176 + Org: dividendsEstimate.Org,
  177 + Company: dividendsEstimate.Company,
  178 + Operator: dividendsEstimate.Operator,
  179 + OperateTime: dividendsEstimate.OperateTime,
  180 + IsCanceled: dividendsEstimate.IsCanceled,
  181 + CreatedAt: dividendsEstimate.CreatedAt,
  182 + DeletedAt: dividendsEstimate.DeletedAt,
  183 + UpdatedAt: time.Now(),
  184 + })
  185 + }
  186 + if _, err := tx.Model(&dividendsEstimateModels).WherePK().Update(); err != nil {
  187 + return nil, err
  188 + }
  189 + return dividendsEstimates, nil
156 } 190 }
157 191
158 func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain.DividendsEstimate) (*domain.DividendsEstimate, error) { 192 func (repository *DividendsEstimateRepository) Remove(dividendsEstimate *domain.DividendsEstimate) (*domain.DividendsEstimate, error) {
@@ -189,6 +223,12 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte @@ -189,6 +223,12 @@ func (repository *DividendsEstimateRepository) Find(queryOptions map[string]inte
189 var dividendsEstimateModels []*models.DividendsEstimate 223 var dividendsEstimateModels []*models.DividendsEstimate
190 dividendsEstimates := make([]*domain.DividendsEstimate, 0) 224 dividendsEstimates := make([]*domain.DividendsEstimate, 0)
191 query := sqlbuilder.BuildQuery(tx.Model(&dividendsEstimateModels), queryOptions) 225 query := sqlbuilder.BuildQuery(tx.Model(&dividendsEstimateModels), queryOptions)
  226 + if dividendsType, ok := queryOptions["dividendsType"]; ok && dividendsType.(int32) != 0 {
  227 + query.Where("dividends_type = ?", dividendsType)
  228 + }
  229 + if dividendsEstimateOrderNumber, ok := queryOptions["dividendsEstimateOrderNumber"]; ok && dividendsEstimateOrderNumber != "" {
  230 + query.Where("dividends_estimate_order_number ilike ?", fmt.Sprintf("%%%s%%", dividendsEstimateOrderNumber))
  231 + }
192 offsetLimitFlag := true 232 offsetLimitFlag := true
193 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 233 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
194 offsetLimitFlag = offsetLimit.(bool) 234 offsetLimitFlag = offsetLimit.(bool)
@@ -33,7 +33,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend @@ -33,7 +33,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
33 "dividends_order_number", 33 "dividends_order_number",
34 "dividends_original_order_num", 34 "dividends_original_order_num",
35 "dividends_order_amount", 35 "dividends_order_amount",
36 - "order_salesman",  
37 "order_time", 36 "order_time",
38 "dividend_time", 37 "dividend_time",
39 "dividend_status", 38 "dividend_status",
@@ -67,7 +66,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend @@ -67,7 +66,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
67 &dividendsOrder.DividendsOrderNumber, 66 &dividendsOrder.DividendsOrderNumber,
68 &dividendsOrder.DividendsOriginalOrderNum, 67 &dividendsOrder.DividendsOriginalOrderNum,
69 &dividendsOrder.DividendsOrderAmount, 68 &dividendsOrder.DividendsOrderAmount,
70 - &dividendsOrder.OrderSalesman,  
71 &dividendsOrder.OrderTime, 69 &dividendsOrder.OrderTime,
72 &dividendsOrder.DividendTime, 70 &dividendsOrder.DividendTime,
73 &dividendsOrder.DividendStatus, 71 &dividendsOrder.DividendStatus,
@@ -87,7 +85,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend @@ -87,7 +85,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
87 dividendsOrder.DividendsOrderNumber, 85 dividendsOrder.DividendsOrderNumber,
88 dividendsOrder.DividendsOriginalOrderNum, 86 dividendsOrder.DividendsOriginalOrderNum,
89 dividendsOrder.DividendsOrderAmount, 87 dividendsOrder.DividendsOrderAmount,
90 - dividendsOrder.OrderSalesman,  
91 dividendsOrder.OrderTime, 88 dividendsOrder.OrderTime,
92 dividendsOrder.DividendTime, 89 dividendsOrder.DividendTime,
93 dividendsOrder.DividendStatus, 90 dividendsOrder.DividendStatus,
@@ -131,7 +128,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend @@ -131,7 +128,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
131 &dividendsOrder.DividendsOrderNumber, 128 &dividendsOrder.DividendsOrderNumber,
132 &dividendsOrder.DividendsOriginalOrderNum, 129 &dividendsOrder.DividendsOriginalOrderNum,
133 &dividendsOrder.DividendsOrderAmount, 130 &dividendsOrder.DividendsOrderAmount,
134 - &dividendsOrder.OrderSalesman,  
135 &dividendsOrder.OrderTime, 131 &dividendsOrder.OrderTime,
136 &dividendsOrder.DividendTime, 132 &dividendsOrder.DividendTime,
137 &dividendsOrder.DividendStatus, 133 &dividendsOrder.DividendStatus,
@@ -151,7 +147,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend @@ -151,7 +147,6 @@ func (repository *DividendsOrderRepository) Save(dividendsOrder *domain.Dividend
151 dividendsOrder.DividendsOrderNumber, 147 dividendsOrder.DividendsOrderNumber,
152 dividendsOrder.DividendsOriginalOrderNum, 148 dividendsOrder.DividendsOriginalOrderNum,
153 dividendsOrder.DividendsOrderAmount, 149 dividendsOrder.DividendsOrderAmount,
154 - dividendsOrder.OrderSalesman,  
155 dividendsOrder.OrderTime, 150 dividendsOrder.OrderTime,
156 dividendsOrder.DividendTime, 151 dividendsOrder.DividendTime,
157 dividendsOrder.DividendStatus, 152 dividendsOrder.DividendStatus,
@@ -35,6 +35,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -35,6 +35,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
35 "original_order_num", 35 "original_order_num",
36 "dividends_order_number", 36 "dividends_order_number",
37 "dividends_returned_customer_name", 37 "dividends_returned_customer_name",
  38 + "order_time",
38 "dividends_returned_date", 39 "dividends_returned_date",
39 "region", 40 "region",
40 "remarks", 41 "remarks",
@@ -69,6 +70,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -69,6 +70,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
69 &dividendsReturnedOrder.OriginalOrderNum, 70 &dividendsReturnedOrder.OriginalOrderNum,
70 &dividendsReturnedOrder.DividendsOrderNumber, 71 &dividendsReturnedOrder.DividendsOrderNumber,
71 &dividendsReturnedOrder.DividendsReturnedCustomerName, 72 &dividendsReturnedOrder.DividendsReturnedCustomerName,
  73 + &dividendsReturnedOrder.OrderTime,
72 &dividendsReturnedOrder.DividendsReturnedDate, 74 &dividendsReturnedOrder.DividendsReturnedDate,
73 &dividendsReturnedOrder.Region, 75 &dividendsReturnedOrder.Region,
74 &dividendsReturnedOrder.Remarks, 76 &dividendsReturnedOrder.Remarks,
@@ -89,6 +91,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -89,6 +91,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
89 dividendsReturnedOrder.OriginalOrderNum, 91 dividendsReturnedOrder.OriginalOrderNum,
90 dividendsReturnedOrder.DividendsOrderNumber, 92 dividendsReturnedOrder.DividendsOrderNumber,
91 dividendsReturnedOrder.DividendsReturnedCustomerName, 93 dividendsReturnedOrder.DividendsReturnedCustomerName,
  94 + dividendsReturnedOrder.OrderTime,
92 dividendsReturnedOrder.DividendsReturnedDate, 95 dividendsReturnedOrder.DividendsReturnedDate,
93 dividendsReturnedOrder.Region, 96 dividendsReturnedOrder.Region,
94 dividendsReturnedOrder.Remarks, 97 dividendsReturnedOrder.Remarks,
@@ -135,6 +138,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -135,6 +138,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
135 &dividendsReturnedOrder.OriginalOrderNum, 138 &dividendsReturnedOrder.OriginalOrderNum,
136 &dividendsReturnedOrder.DividendsOrderNumber, 139 &dividendsReturnedOrder.DividendsOrderNumber,
137 &dividendsReturnedOrder.DividendsReturnedCustomerName, 140 &dividendsReturnedOrder.DividendsReturnedCustomerName,
  141 + &dividendsReturnedOrder.OrderTime,
138 &dividendsReturnedOrder.DividendsReturnedDate, 142 &dividendsReturnedOrder.DividendsReturnedDate,
139 &dividendsReturnedOrder.Region, 143 &dividendsReturnedOrder.Region,
140 &dividendsReturnedOrder.Remarks, 144 &dividendsReturnedOrder.Remarks,
@@ -155,6 +159,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder @@ -155,6 +159,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
155 dividendsReturnedOrder.OriginalOrderNum, 159 dividendsReturnedOrder.OriginalOrderNum,
156 dividendsReturnedOrder.DividendsOrderNumber, 160 dividendsReturnedOrder.DividendsOrderNumber,
157 dividendsReturnedOrder.DividendsReturnedCustomerName, 161 dividendsReturnedOrder.DividendsReturnedCustomerName,
  162 + dividendsReturnedOrder.OrderTime,
158 dividendsReturnedOrder.DividendsReturnedDate, 163 dividendsReturnedOrder.DividendsReturnedDate,
159 dividendsReturnedOrder.Region, 164 dividendsReturnedOrder.Region,
160 dividendsReturnedOrder.Remarks, 165 dividendsReturnedOrder.Remarks,
@@ -3,6 +3,7 @@ package repository @@ -3,6 +3,7 @@ package repository
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "github.com/go-pg/pg/v10" 5 "github.com/go-pg/pg/v10"
  6 + "github.com/go-pg/pg/v10/orm"
6 7
7 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder" 8 "github.com/linmadan/egglib-go/persistent/pg/sqlbuilder"
8 pgTransaction "github.com/linmadan/egglib-go/transaction/pg" 9 pgTransaction "github.com/linmadan/egglib-go/transaction/pg"
@@ -164,6 +165,16 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{}) @@ -164,6 +165,16 @@ func (repository *OrderGoodRepository) Find(queryOptions map[string]interface{})
164 var orderGoodModels []*models.OrderGood 165 var orderGoodModels []*models.OrderGood
165 orderGoods := make([]*domain.OrderGood, 0) 166 orderGoods := make([]*domain.OrderGood, 0)
166 query := sqlbuilder.BuildQuery(tx.Model(&orderGoodModels), queryOptions) 167 query := sqlbuilder.BuildQuery(tx.Model(&orderGoodModels), queryOptions)
  168 + if cooperationContractNumber, ok := queryOptions["cooperationContractNumber"]; ok && cooperationContractNumber != "" {
  169 + query.Where("cooperation_contract_number ilike ?", fmt.Sprintf("%%%s%%", cooperationContractNumber))
  170 + }
  171 + if orderOrReturnedOrderNum, ok := queryOptions["orderOrReturnedOrderNum"]; ok && orderOrReturnedOrderNum != "" {
  172 + query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
  173 + q.WhereOr("dividends_order_number ilike ?", fmt.Sprintf("%%%s%%", orderOrReturnedOrderNum))
  174 + q.WhereOr("dividends_returned_order_number ilike ?", fmt.Sprintf("%%%s%%", orderOrReturnedOrderNum))
  175 + return q, nil
  176 + })
  177 + }
167 offsetLimitFlag := true 178 offsetLimitFlag := true
168 if offsetLimit, ok := queryOptions["offsetLimit"]; ok { 179 if offsetLimit, ok := queryOptions["offsetLimit"]; ok {
169 offsetLimitFlag = offsetLimit.(bool) 180 offsetLimitFlag = offsetLimit.(bool)
@@ -62,6 +62,19 @@ func (controller *CooperationContractController) BatchApprovalCooperationApplica @@ -62,6 +62,19 @@ func (controller *CooperationContractController) BatchApprovalCooperationApplica
62 controller.Response(data, err) 62 controller.Response(data, err)
63 } 63 }
64 64
  65 +func (controller *CooperationApplicationController) OneClickApprovalCooperationApplication() {
  66 + cooperationApplicationService := service.NewCooperationApplicationService(nil)
  67 + oneClickApprovalCooperationApplicationCommand := &command.OneClickApprovalCooperationApplicationCommand{}
  68 + _ = controller.Unmarshal(oneClickApprovalCooperationApplicationCommand)
  69 + header := controller.GetRequestHeader(controller.Ctx)
  70 + oneClickApprovalCooperationApplicationCommand.CompanyId = header.CompanyId
  71 + oneClickApprovalCooperationApplicationCommand.OrgId = header.OrgId
  72 + oneClickApprovalCooperationApplicationCommand.UserId = header.UserId
  73 + oneClickApprovalCooperationApplicationCommand.UserBaseId = header.UserBaseId
  74 + data, err := cooperationApplicationService.OneClickApprovalCooperationApplication(oneClickApprovalCooperationApplicationCommand)
  75 + controller.Response(data, err)
  76 +}
  77 +
65 func (controller *CooperationApplicationController) CreateCooperationApplication() { 78 func (controller *CooperationApplicationController) CreateCooperationApplication() {
66 cooperationApplicationService := service.NewCooperationApplicationService(nil) 79 cooperationApplicationService := service.NewCooperationApplicationService(nil)
67 createCooperationApplicationCommand := &command.CreateCooperationApplicationCommand{} 80 createCooperationApplicationCommand := &command.CreateCooperationApplicationCommand{}
@@ -81,7 +81,7 @@ func (controller *DividendsEstimateController) CancelDividendsEstimate() { @@ -81,7 +81,7 @@ func (controller *DividendsEstimateController) CancelDividendsEstimate() {
81 cancelDividendsEstimateCommand.OrgId = header.OrgId 81 cancelDividendsEstimateCommand.OrgId = header.OrgId
82 cancelDividendsEstimateCommand.UserId = header.UserId 82 cancelDividendsEstimateCommand.UserId = header.UserId
83 cancelDividendsEstimateCommand.UserBaseId = header.UserBaseId 83 cancelDividendsEstimateCommand.UserBaseId = header.UserBaseId
84 - dividendsEstimateId := controller.GetString(":dividendsEstimateId") 84 + dividendsEstimateId, _ := controller.GetInt64(":dividendsEstimateId")
85 cancelDividendsEstimateCommand.DividendsEstimateId = dividendsEstimateId 85 cancelDividendsEstimateCommand.DividendsEstimateId = dividendsEstimateId
86 data, err := dividendsEstimateService.CancelDividendsEstimate(cancelDividendsEstimateCommand) 86 data, err := dividendsEstimateService.CancelDividendsEstimate(cancelDividendsEstimateCommand)
87 controller.Response(data, err) 87 controller.Response(data, err)
@@ -6,14 +6,15 @@ import ( @@ -6,14 +6,15 @@ import (
6 ) 6 )
7 7
8 func init() { 8 func init() {
9 - web.Router("/cooperation-applications/apply-for-cooperation", &controllers.CooperationApplicationController{}, "Post:ApplyForCooperation") // 申请共创  
10 - web.Router("/cooperation-applications/cancel-application", &controllers.CooperationApplicationController{}, "Post:CancelCooperationApplication")  
11 - web.Router("/cooperation-applications/agree-cooperation-application", &controllers.CooperationApplicationController{}, "Post:ApprovalCooperationApplication") // 同意共创申请  
12 - web.Router("/cooperation-applications/batch-approval", &controllers.CooperationContractController{}, "Post:BatchApprovalCooperationApplication") // 一键审核  
13 - web.Router("/cooperation-applications/", &controllers.CooperationApplicationController{}, "Post:CreateCooperationApplication") // 新增共创申请  
14 - web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Put:UpdateCooperationApplication") // 编辑共创申请  
15 - web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Get:GetCooperationApplication") // 获取共创申请详情  
16 - web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Delete:RemoveCooperationApplication") // 移除共创申请  
17 - web.Router("/cooperation-applications/search", &controllers.CooperationApplicationController{}, "Post:SearchCooperationApplication") // 搜索返回共创申请列表  
18 - web.Router("/cooperation-applications/", &controllers.CooperationApplicationController{}, "Get:ListCooperationApplication") // 返回共创申请列表 9 + web.Router("/cooperation-applications/apply-for-cooperation", &controllers.CooperationApplicationController{}, "Post:ApplyForCooperation") // 申请共创
  10 + web.Router("/cooperation-applications/cancel-application", &controllers.CooperationApplicationController{}, "Post:CancelCooperationApplication") // 取消共创申请
  11 + web.Router("/cooperation-applications/approval-cooperation-application", &controllers.CooperationApplicationController{}, "Post:ApprovalCooperationApplication") // 同意共创申请
  12 + web.Router("/cooperation-applications/batch-approval", &controllers.CooperationContractController{}, "Post:BatchApprovalCooperationApplication") // 批量审核共创申请
  13 + web.Router("/cooperation-applications/oneclick-approval", &controllers.CooperationApplicationController{}, "Post:OneClickApprovalCooperationApplication") // 一键审核共创申请
  14 + web.Router("/cooperation-applications/", &controllers.CooperationApplicationController{}, "Post:CreateCooperationApplication") // 新增共创申请
  15 + web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Put:UpdateCooperationApplication") // 编辑共创申请
  16 + web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Get:GetCooperationApplication") // 获取共创申请详情
  17 + web.Router("/cooperation-applications/:cooperationApplicationId", &controllers.CooperationApplicationController{}, "Delete:RemoveCooperationApplication") // 移除共创申请
  18 + web.Router("/cooperation-applications/search", &controllers.CooperationApplicationController{}, "Post:SearchCooperationApplication") // 搜索返回共创申请列表
  19 + web.Router("/cooperation-applications/", &controllers.CooperationApplicationController{}, "Get:ListCooperationApplication") // 返回共创申请列表
19 } 20 }