正在显示
8 个修改的文件
包含
196 行增加
和
15 行删除
1 | package dto | 1 | package dto |
2 | 2 | ||
3 | -import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | 3 | +import ( |
4 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | ||
5 | + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/pg/models" | ||
6 | +) | ||
4 | 7 | ||
5 | type CooperationContractByUndertakerDto struct { | 8 | type CooperationContractByUndertakerDto struct { |
9 | + // 承接人ID | ||
10 | + UndertakerId int64 `json:"undertakerId,string"` | ||
11 | + // 承接人编号 | ||
12 | + UndertakerCode string `json:"undertakerCode"` | ||
13 | + // 承接人姓名 | ||
14 | + UndertakerName string `json:"undertakerName"` | ||
15 | + // 承接人电话 | ||
16 | + UndertakerPhone string `json:"undertakerPhone"` | ||
17 | + // 项目合约编号 | ||
18 | + CooperationContractNumber string `json:"cooperationContractNumber"` | ||
19 | + // 项目合约名称 | ||
20 | + CooperationContractName string `json:"cooperationContractName"` | ||
21 | + // 合同附件 | ||
22 | + Attachment []*domain.Attachment | ||
23 | + // 发起人姓名 | ||
24 | + SponsorName string `json:"sponsorName"` | ||
25 | + // 发起部门名称 | ||
26 | + DepartmentName string `json:"departmentName"` | ||
27 | + // 共创模式名称 | ||
28 | + CooperationModeName string `json:"cooperationModeName"` | ||
29 | + // 组织机构名称 | ||
30 | + OrgName string `json:"orgName"` | ||
6 | } | 31 | } |
7 | 32 | ||
8 | -func (dto *CooperationContractByUndertakerDto) LoadDto(contract *domain.CooperationContract) error { | 33 | +func (dto *CooperationContractByUndertakerDto) LoadDto(contractByUndertaker *models.CooperationContractByUndertaker) error { |
34 | + dto.UndertakerId = contractByUndertaker.CooperationContractUndertakerId | ||
35 | + dto.UndertakerCode = contractByUndertaker.UndertakerCode | ||
36 | + dto.UndertakerName = contractByUndertaker.UndertakerName | ||
37 | + dto.UndertakerPhone = contractByUndertaker.UndertakerPhone | ||
38 | + dto.CooperationContractNumber = contractByUndertaker.CooperationContractNumber | ||
39 | + dto.CooperationContractName = contractByUndertaker.CooperationContractName | ||
40 | + dto.Attachment = contractByUndertaker.ContractAttachment | ||
41 | + dto.SponsorName = contractByUndertaker.CooperationContractSponsor.UserName | ||
42 | + if contractByUndertaker.Department != nil { | ||
43 | + dto.DepartmentName = contractByUndertaker.Department.DepartmentName | ||
44 | + } | ||
45 | + dto.CooperationModeName = contractByUndertaker.CooperationModeName | ||
46 | + if contractByUndertaker.Org != nil { | ||
47 | + dto.OrgName = contractByUndertaker.Org.OrgName | ||
48 | + } | ||
9 | return nil | 49 | return nil |
10 | } | 50 | } |
@@ -9,10 +9,6 @@ import ( | @@ -9,10 +9,6 @@ import ( | ||
9 | ) | 9 | ) |
10 | 10 | ||
11 | type SearchCooperationContractByUndertakerQuery struct { | 11 | type SearchCooperationContractByUndertakerQuery struct { |
12 | - // 页面大小 | ||
13 | - PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"` | ||
14 | - // 页面大小 | ||
15 | - PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"` | ||
16 | // 共创合约名称 | 12 | // 共创合约名称 |
17 | CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName,omitempty"` | 13 | CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName,omitempty"` |
18 | // 项目发起人姓名 | 14 | // 项目发起人姓名 |
@@ -27,6 +23,10 @@ type SearchCooperationContractByUndertakerQuery struct { | @@ -27,6 +23,10 @@ type SearchCooperationContractByUndertakerQuery struct { | ||
27 | UserId int64 `cname:"用户ID" json:"userId"` | 23 | UserId int64 `cname:"用户ID" json:"userId"` |
28 | // 用户基础数据id | 24 | // 用户基础数据id |
29 | UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"` | 25 | UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"` |
26 | + // 页面大小 | ||
27 | + PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"` | ||
28 | + // 页面大小 | ||
29 | + PageSize int64 `cname:"页面大小" json:"pageSize,omitempty"` | ||
30 | } | 30 | } |
31 | 31 | ||
32 | func (searchCooperationContractByUndertakerQuery *SearchCooperationContractByUndertakerQuery) Valid(validation *validation.Validation) { | 32 | func (searchCooperationContractByUndertakerQuery *SearchCooperationContractByUndertakerQuery) Valid(validation *validation.Validation) { |
@@ -794,7 +794,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC | @@ -794,7 +794,7 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC | ||
794 | } | 794 | } |
795 | } | 795 | } |
796 | 796 | ||
797 | -// SearchCooperationContractByUndertaker TODO 根据承接人返回共创项目合约 | 797 | +// SearchCooperationContractByUndertaker 根据承接人返回共创项目合约 |
798 | func (cooperationContractService *CooperationContractService) SearchCooperationContractByUndertaker(searchCooperationContractByUndertakerQuery *query.SearchCooperationContractByUndertakerQuery) (interface{}, error) { | 798 | func (cooperationContractService *CooperationContractService) SearchCooperationContractByUndertaker(searchCooperationContractByUndertakerQuery *query.SearchCooperationContractByUndertakerQuery) (interface{}, error) { |
799 | if err := searchCooperationContractByUndertakerQuery.ValidateQuery(); err != nil { | 799 | if err := searchCooperationContractByUndertakerQuery.ValidateQuery(); err != nil { |
800 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) | 800 | return nil, application.ThrowError(application.ARG_ERROR, err.Error()) |
@@ -809,10 +809,39 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC | @@ -809,10 +809,39 @@ func (cooperationContractService *CooperationContractService) SearchCooperationC | ||
809 | defer func() { | 809 | defer func() { |
810 | _ = transactionContext.RollbackTransaction() | 810 | _ = transactionContext.RollbackTransaction() |
811 | }() | 811 | }() |
812 | - if err := transactionContext.CommitTransaction(); err != nil { | 812 | + |
813 | + // 共创合约DAO初始化 | ||
814 | + var cooperationContractDao *dao.CooperationContractDao | ||
815 | + if value, err := factory.CreateCooperationContractDao(map[string]interface{}{ | ||
816 | + "transactionContext": transactionContext, | ||
817 | + }); err != nil { | ||
813 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 818 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
819 | + } else { | ||
820 | + cooperationContractDao = value | ||
821 | + } | ||
822 | + | ||
823 | + // 查询共创项目合约 | ||
824 | + if count, cooperationContractByUndertakers, err := cooperationContractDao.SearchCooperationContractByUndertaker(tool_funs.SimpleStructToMap(searchCooperationContractByUndertakerQuery)); err != nil { | ||
825 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
826 | + } else { | ||
827 | + var cooperationContractByUndertakerDtos []*dto.CooperationContractByUndertakerDto | ||
828 | + for _, cooperationContractByUndertaker := range cooperationContractByUndertakers { | ||
829 | + cooperationContractByUndertakerDto := &dto.CooperationContractByUndertakerDto{} | ||
830 | + if err := cooperationContractByUndertakerDto.LoadDto(cooperationContractByUndertaker); err != nil { | ||
831 | + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) | ||
832 | + } | ||
833 | + cooperationContractByUndertakerDtos = append(cooperationContractByUndertakerDtos, cooperationContractByUndertakerDto) | ||
834 | + } | ||
835 | + if err := transactionContext.CommitTransaction(); err != nil { | ||
836 | + return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | ||
837 | + } | ||
838 | + return map[string]interface{}{ | ||
839 | + "grid": map[string]interface{}{ | ||
840 | + "total": count, | ||
841 | + "list": cooperationContractByUndertakerDtos, | ||
842 | + }, | ||
843 | + }, nil | ||
814 | } | 844 | } |
815 | - return nil, nil | ||
816 | } | 845 | } |
817 | 846 | ||
818 | // UpdateCooperationContract 更新共创合约服务 | 847 | // UpdateCooperationContract 更新共创合约服务 |
@@ -8,6 +8,34 @@ import ( | @@ -8,6 +8,34 @@ import ( | ||
8 | "time" | 8 | "time" |
9 | ) | 9 | ) |
10 | 10 | ||
11 | +type ( | ||
12 | + ImportDividendsReturnedOrderData struct { | ||
13 | + //退货客户名称 | ||
14 | + DividendsReturnedCustomerName string `json:"dividendsReturnedCustomerName"` | ||
15 | + //来源单号,源单号,订单号 | ||
16 | + OriginalOrderNum string `json:"originalOrderNum"` | ||
17 | + //订单产品名称 | ||
18 | + OrderGoodName string `json:"orderGoodName"` | ||
19 | + //退货日期 | ||
20 | + DividendsReturnedDate time.Time `json:"dividendsReturnedDate"` | ||
21 | + //退货区域名称 | ||
22 | + RegionName string `json:"regionName"` | ||
23 | + //订单产品单价 | ||
24 | + OrderGoodPrice float64 `json:"orderGoodPrice"` | ||
25 | + //订单产品数量 | ||
26 | + OrderGoodQuantity int64 `json:"orderGoodQuantity"` | ||
27 | + //合约编号 | ||
28 | + CooperationContractNumber string `json:"cooperationContractNumber"` | ||
29 | + //订单日期 | ||
30 | + OrderTime string `json:"orderTime"` | ||
31 | + } | ||
32 | + // ReqImportDividendsReturnedOrder 请求参数 | ||
33 | + ReqImportDividendsReturnedOrder struct { | ||
34 | + // 分红退货单数据 | ||
35 | + DividendsReturnedOrderData []ImportDividendsReturnedOrderData `json:"dividendsReturnedOrderData"` //分红退货单数据列表 | ||
36 | + } | ||
37 | +) | ||
38 | + | ||
11 | // DividendsReturnedOrderData 分红退货单数据 | 39 | // DividendsReturnedOrderData 分红退货单数据 |
12 | type DividendsReturnedOrderData struct { | 40 | type DividendsReturnedOrderData struct { |
13 | // 退货金额 | 41 | // 退货金额 |
@@ -77,6 +77,57 @@ func (dao *CooperationContractDao) CheckContractNumberAvailable(queryOptions map | @@ -77,6 +77,57 @@ func (dao *CooperationContractDao) CheckContractNumberAvailable(queryOptions map | ||
77 | return !ok, err | 77 | return !ok, err |
78 | } | 78 | } |
79 | 79 | ||
80 | +// SearchCooperationContractByUndertaker 查询共创合约并根据承接人返回 | ||
81 | +func (dao *CooperationContractDao) SearchCooperationContractByUndertaker(queryOptions map[string]interface{}) (int, []*models.CooperationContractByUndertaker, error) { | ||
82 | + tx := dao.transactionContext.PgTx | ||
83 | + var cooperationContractByUndertakerModels []*models.CooperationContractByUndertaker | ||
84 | + var cooperationUndertakerModels []*models.CooperationContractUndertaker | ||
85 | + query := tx.Model(&cooperationUndertakerModels) | ||
86 | + query.ColumnExpr("cooperation_contract_undertaker.cooperation_contract_undertaker_id") | ||
87 | + query.ColumnExpr("cooperation_contract_undertaker.user_info->>'userCode' AS undertaker_code") | ||
88 | + query.ColumnExpr("cooperation_contract_undertaker.user_info->>'userName' AS undertaker_name") | ||
89 | + query.ColumnExpr("cooperation_contract_undertaker.user_info->>'userPhone' AS undertaker_phone") | ||
90 | + query.ColumnExpr("cooperation_contract_undertaker.contract_attachment") | ||
91 | + query.ColumnExpr("A.cooperation_contract_sponsor") | ||
92 | + query.ColumnExpr("A.cooperation_contract_number") | ||
93 | + query.ColumnExpr("A.cooperation_contract_name") | ||
94 | + query.ColumnExpr("A.cooperation_contract_description") | ||
95 | + query.ColumnExpr("A.department") | ||
96 | + query.ColumnExpr("A.org") | ||
97 | + query.ColumnExpr("A.status AS contract_status") | ||
98 | + query.ColumnExpr("B.cooperation_mode_name") | ||
99 | + if cooperationContractName, ok := queryOptions["cooperationContractName"]; ok && cooperationContractName != "" { | ||
100 | + query = query.Where("A.cooperation_contract_name ilike ?", fmt.Sprintf("%%%s%%", cooperationContractName)) | ||
101 | + } | ||
102 | + if sponsorName, ok := queryOptions["sponsorName"]; ok && sponsorName != "" { | ||
103 | + query = query.Where(`A.cooperation_contract_sponsor->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", sponsorName)) | ||
104 | + } | ||
105 | + query.Join("JOIN cooperation_contracts AS A ON A.cooperation_contract_number = cooperation_contract_undertaker.cooperation_contract_number") | ||
106 | + query.Join("JOIN cooperation_modes AS B ON B.cooperation_mode_number = A.cooperation_mode_number") | ||
107 | + query = query.Order("cooperation_contract_undertaker_id DESC") | ||
108 | + if offset, ok := queryOptions["offset"]; ok && offset.(int64) != 0 { | ||
109 | + offset := offset.(int64) | ||
110 | + if offset > -1 { | ||
111 | + query = query.Offset(int(offset)) | ||
112 | + } | ||
113 | + } else { | ||
114 | + query = query.Offset(0) | ||
115 | + } | ||
116 | + if limit, ok := queryOptions["limit"]; ok && limit.(int64) != 0 { | ||
117 | + limit := limit.(int64) | ||
118 | + if limit > -1 { | ||
119 | + query = query.Limit(int(limit)) | ||
120 | + } | ||
121 | + } else { | ||
122 | + query = query.Limit(20) | ||
123 | + } | ||
124 | + if count, err := query.SelectAndCount(&cooperationContractByUndertakerModels); err != nil { | ||
125 | + return 0, nil, err | ||
126 | + } else { | ||
127 | + return count, cooperationContractByUndertakerModels, nil | ||
128 | + } | ||
129 | +} | ||
130 | + | ||
80 | func NewCooperationContractDao(transactionContext *pgTransaction.TransactionContext) (*CooperationContractDao, error) { | 131 | func NewCooperationContractDao(transactionContext *pgTransaction.TransactionContext) (*CooperationContractDao, error) { |
81 | if transactionContext == nil { | 132 | if transactionContext == nil { |
82 | return nil, fmt.Errorf("transactionContext参数不能为nil") | 133 | return nil, fmt.Errorf("transactionContext参数不能为nil") |
1 | +package models | ||
2 | + | ||
3 | +import "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/domain" | ||
4 | + | ||
5 | +type CooperationContractByUndertaker struct { | ||
6 | + // 共创合约承接人ID | ||
7 | + CooperationContractUndertakerId int64 `comment:"共创合约承接人ID"` | ||
8 | + // 承接人编号 | ||
9 | + UndertakerCode string `comment:"承接人编号"` | ||
10 | + // 承接人姓名 | ||
11 | + UndertakerName string `comment:"承接人姓名"` | ||
12 | + // 承接人电话 | ||
13 | + UndertakerPhone string `comment:"承接人电话"` | ||
14 | + // 共创合约附件 | ||
15 | + ContractAttachment []*domain.Attachment `comment:"共创合约附件"` | ||
16 | + // 共创合约发起人 | ||
17 | + CooperationContractSponsor *domain.User `comment:"共创合约发起人"` | ||
18 | + // 共创合约编号 | ||
19 | + CooperationContractNumber string `comment:"共创合约编号"` | ||
20 | + // 共创合约名称 | ||
21 | + CooperationContractName string `comment:"共创合约名称"` | ||
22 | + // 共创合约描述 | ||
23 | + CooperationContractDescription string `comment:"共创合约描述"` | ||
24 | + // 共创合约发起部门 | ||
25 | + Department *domain.Department `comment:"共创合约发起部门"` | ||
26 | + // 组织机构 | ||
27 | + Org *domain.Org `comment:"组织机构"` | ||
28 | + // 共创合约状态 | ||
29 | + ContractStatus int32 `comment:"共创合约状态"` | ||
30 | + // 共创模式名称 | ||
31 | + CooperationModeName string `comment:"共创合约名称"` | ||
32 | +} |
@@ -18,37 +18,37 @@ func (adaptor *UserAdaptor) ToParticipator(companyId int64, orgId int64, userId | @@ -18,37 +18,37 @@ func (adaptor *UserAdaptor) ToParticipator(companyId int64, orgId int64, userId | ||
18 | return map[string]interface{}{}, err | 18 | return map[string]interface{}{}, err |
19 | } else { | 19 | } else { |
20 | switch aRoleName { | 20 | switch aRoleName { |
21 | - case "Relevant": | 21 | + case "Relevant": // 相关人 |
22 | relevant, err := userTranslator.ToRelevantFromRepresentation(response) | 22 | relevant, err := userTranslator.ToRelevantFromRepresentation(response) |
23 | if err != nil { | 23 | if err != nil { |
24 | return map[string]interface{}{}, err | 24 | return map[string]interface{}{}, err |
25 | } | 25 | } |
26 | return relevant, nil | 26 | return relevant, nil |
27 | - case "Referrer": | 27 | + case "Referrer": // 推荐人 |
28 | referrer, err := userTranslator.ToReferrerFromRepresentation(response) | 28 | referrer, err := userTranslator.ToReferrerFromRepresentation(response) |
29 | if err != nil { | 29 | if err != nil { |
30 | return map[string]interface{}{}, err | 30 | return map[string]interface{}{}, err |
31 | } | 31 | } |
32 | return referrer, nil | 32 | return referrer, nil |
33 | - case "Salesman": | 33 | + case "Salesman": // 业务员 |
34 | salesman, err := userTranslator.ToSalesmanFromRepresentation(response) | 34 | salesman, err := userTranslator.ToSalesmanFromRepresentation(response) |
35 | if err != nil { | 35 | if err != nil { |
36 | return map[string]interface{}{}, nil | 36 | return map[string]interface{}{}, nil |
37 | } | 37 | } |
38 | return salesman, nil | 38 | return salesman, nil |
39 | - case "Undertaker": | 39 | + case "Undertaker": // 承接人 |
40 | undertaker, err := userTranslator.ToUndertakerFromRepresentation(response) | 40 | undertaker, err := userTranslator.ToUndertakerFromRepresentation(response) |
41 | if err != nil { | 41 | if err != nil { |
42 | return map[string]interface{}{}, nil | 42 | return map[string]interface{}{}, nil |
43 | } | 43 | } |
44 | return undertaker, nil | 44 | return undertaker, nil |
45 | - case "Operator": | 45 | + case "Operator": // 操作人 |
46 | operator, err := userTranslator.ToOperatorFromRepresentation(response) | 46 | operator, err := userTranslator.ToOperatorFromRepresentation(response) |
47 | if err != nil { | 47 | if err != nil { |
48 | return map[string]interface{}{}, nil | 48 | return map[string]interface{}{}, nil |
49 | } | 49 | } |
50 | return operator, nil | 50 | return operator, nil |
51 | - case "User": | 51 | + case "User": // 用户 |
52 | user, err := userTranslator.ToUserFromRepresentation(response) | 52 | user, err := userTranslator.ToUserFromRepresentation(response) |
53 | if err != nil { | 53 | if err != nil { |
54 | return map[string]interface{}{}, nil | 54 | return map[string]interface{}{}, nil |
@@ -122,6 +122,7 @@ func (controller *CooperationContractController) SearchCooperationContract() { | @@ -122,6 +122,7 @@ func (controller *CooperationContractController) SearchCooperationContract() { | ||
122 | func (controller *CooperationContractController) SearchCooperationContractByUndertaker() { | 122 | func (controller *CooperationContractController) SearchCooperationContractByUndertaker() { |
123 | cooperationContractService := service.NewCooperationContractService(nil) | 123 | cooperationContractService := service.NewCooperationContractService(nil) |
124 | searchCooperationContractByUndertakerQuery := &query.SearchCooperationContractByUndertakerQuery{} | 124 | searchCooperationContractByUndertakerQuery := &query.SearchCooperationContractByUndertakerQuery{} |
125 | + _ = controller.Unmarshal(searchCooperationContractByUndertakerQuery) | ||
125 | data, err := cooperationContractService.SearchCooperationContractByUndertaker(searchCooperationContractByUndertakerQuery) | 126 | data, err := cooperationContractService.SearchCooperationContractByUndertaker(searchCooperationContractByUndertakerQuery) |
126 | controller.Response(data, err) | 127 | controller.Response(data, err) |
127 | } | 128 | } |
-
请 注册 或 登录 后发表评论