作者 yangfu

共创申请,共创统计修改

@@ -18,7 +18,7 @@ type SearchContractUndertakerFeedbackQuery struct { @@ -18,7 +18,7 @@ type SearchContractUndertakerFeedbackQuery struct {
18 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员 18 // 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
19 UserId int64 `cname:"用户ID" json:"userId"` 19 UserId int64 `cname:"用户ID" json:"userId"`
20 // 用户基础数据id 20 // 用户基础数据id
21 - UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"` 21 + UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
22 // 共创合约名称 22 // 共创合约名称
23 CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName,omitempty"` 23 CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName,omitempty"`
24 // 承接人姓名 24 // 承接人姓名
@@ -22,7 +22,7 @@ type SearchCooperationApplicationQuery struct { @@ -22,7 +22,7 @@ type SearchCooperationApplicationQuery struct {
22 // 页面大小 22 // 页面大小
23 PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"` 23 PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"`
24 // 公司ID,通过集成REST上下文获取 24 // 公司ID,通过集成REST上下文获取
25 - CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"` 25 + CompanyId int64 `cname:"公司ID" json:"companyId"`
26 // 组织机构ID 26 // 组织机构ID
27 OrgId int64 `cname:"组织机构ID" json:"orgId"` 27 OrgId int64 `cname:"组织机构ID" json:"orgId"`
28 // 关联的组织机构ID列表 28 // 关联的组织机构ID列表
@@ -174,6 +174,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApprovalCoop @@ -174,6 +174,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApprovalCoop
174 if cooperationApplication == nil { 174 if cooperationApplication == nil {
175 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10))) 175 return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10)))
176 } 176 }
  177 + if approvalCooperationApplicationCommand.Action == 1 {
  178 + cooperationApplication.CooperationApplicationStatus = 2
  179 + } else if approvalCooperationApplicationCommand.Action == 2 {
  180 + cooperationApplication.CooperationApplicationStatus = 3
  181 + }
177 if err := cooperationApplication.Update(tool_funs.SimpleStructToMap(approvalCooperationApplicationCommand)); err != nil { 182 if err := cooperationApplication.Update(tool_funs.SimpleStructToMap(approvalCooperationApplicationCommand)); err != nil {
178 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 183 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
179 } 184 }
@@ -17,13 +17,15 @@ type CreateCooperationProjectCommand struct { @@ -17,13 +17,15 @@ type CreateCooperationProjectCommand struct {
17 // 共创模式编码 17 // 共创模式编码
18 CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"` 18 CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"`
19 // 共创项目发起人uid 19 // 共创项目发起人uid
20 - SponsorUid string `cname:"共创项目发起人UID" json:"sponsorUid" valid:"Required"` 20 + SponsorUid int64 `cname:"共创项目发起人UID" json:"sponsorUid,string" valid:"Required"`
21 // 共创项目发布人uid 21 // 共创项目发布人uid
22 - PublisherUid string `cname:"共创项目发布人UID" json:"publisherUid" valid:"Required"` 22 + PublisherUid int64 `cname:"共创项目发布人UID" json:"publisherUid,string" valid:"Required"`
23 // 共创项目描述 23 // 共创项目描述
24 CooperationProjectDescription string `cname:"共创项目描述" json:"cooperationProjectDescription,omitempty"` 24 CooperationProjectDescription string `cname:"共创项目描述" json:"cooperationProjectDescription,omitempty"`
25 // 附件 25 // 附件
26 Attachment []*domain.Attachment `cname:"附件" json:"attachment"` 26 Attachment []*domain.Attachment `cname:"附件" json:"attachment"`
  27 + // 所属部门Id
  28 + DepartmentId int64 `json:"departmentId,string"`
27 // 公司ID,通过集成REST上下文获取 29 // 公司ID,通过集成REST上下文获取
28 CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"` 30 CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
29 // 组织机构ID 31 // 组织机构ID
@@ -75,7 +75,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro @@ -75,7 +75,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
75 75
76 // Sponsor 76 // Sponsor
77 var sponsor *domain.User 77 var sponsor *domain.User
78 - if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.UserId); err != nil { 78 + if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.SponsorUid); err != nil {
79 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 79 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
80 } else { 80 } else {
81 sponsor = data 81 sponsor = data
@@ -83,7 +83,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro @@ -83,7 +83,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
83 83
84 // Publisher 84 // Publisher
85 var publisher *domain.User 85 var publisher *domain.User
86 - if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.UserId); err != nil { 86 + if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.PublisherUid); err != nil {
87 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error()) 87 return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
88 } else { 88 } else {
89 publisher = data 89 publisher = data
@@ -121,6 +121,14 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro @@ -121,6 +121,14 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
121 organization = data 121 organization = data
122 } 122 }
123 123
  124 + // 获取组织机构信息
  125 + var department *domain.Org
  126 + if data, err := organizationService.OrgFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.DepartmentId); err != nil {
  127 + return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
  128 + } else {
  129 + department = data
  130 + }
  131 +
124 // 查找共创模式 132 // 查找共创模式
125 var cooperationModeRepository domain.CooperationModeRepository 133 var cooperationModeRepository domain.CooperationModeRepository
126 if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{ 134 if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
@@ -171,7 +179,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro @@ -171,7 +179,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
171 CooperationProjectPublishTime: time.Now(), 179 CooperationProjectPublishTime: time.Now(),
172 Attachment: createCooperationProjectCommand.Attachment, 180 Attachment: createCooperationProjectCommand.Attachment,
173 Company: company, 181 Company: company,
174 - Department: organization.ToDepartment(), 182 + Department: department.ToDepartment(),
175 Org: organization, 183 Org: organization,
176 Operator: operator, 184 Operator: operator,
177 OperateTime: time.Now(), 185 OperateTime: time.Now(),
@@ -28,10 +28,10 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte @@ -28,10 +28,10 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte
28 if _, ok := queryOptions["limit"]; ok { 28 if _, ok := queryOptions["limit"]; ok {
29 queryLimit = fmt.Sprintf("limit %v", queryOptions["limit"]) 29 queryLimit = fmt.Sprintf("limit %v", queryOptions["limit"])
30 } 30 }
31 - sql := fmt.Sprintf(`select order_good_name goodName,sum(order_good_amount) goodAmount from order_goods 31 + sql := fmt.Sprintf(`select order_good_name good_name,sum(order_good_amount) good_amount from order_goods
32 where company_id=? and org_id = ? %v 32 where company_id=? and org_id = ? %v
33 GROUP BY order_good_name 33 GROUP BY order_good_name
34 -order by goodAmount desc 34 +order by good_amount desc
35 %v 35 %v
36 `, queryTime, queryLimit) 36 `, queryTime, queryLimit)
37 _, err := tx.Query(&goods, sql, queryOptions["companyId"], queryOptions["orgId"]) 37 _, err := tx.Query(&goods, sql, queryOptions["companyId"], queryOptions["orgId"])
@@ -46,7 +46,7 @@ order by goodAmount desc @@ -46,7 +46,7 @@ order by goodAmount desc
46 func (dao *OrderGoodDao) CooperationModeStatistics(queryOptions map[string]interface{}) ([]*domain.CooperationModeStatisticsDto, error) { 46 func (dao *OrderGoodDao) CooperationModeStatistics(queryOptions map[string]interface{}) ([]*domain.CooperationModeStatisticsDto, error) {
47 tx := dao.transactionContext.PgTx 47 tx := dao.transactionContext.PgTx
48 var goods []*domain.CooperationModeStatisticsDto 48 var goods []*domain.CooperationModeStatisticsDto
49 - sql := fmt.Sprintf(`select count(0) cooperationPeople,sum(a.actually_paid_amount) dividendsEstimate,b.cooperation_mode_number,0 orderAmount 49 + sql := fmt.Sprintf(`select count(0) cooperation_people,sum(a.actually_paid_amount) dividends_estimate,b.cooperation_mode_number,0 order_amount
50 from credit_accounts a inner join cooperation_contracts b on a.cooperation_contract_number = b.cooperation_contract_number 50 from credit_accounts a inner join cooperation_contracts b on a.cooperation_contract_number = b.cooperation_contract_number
51 where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and b.status = 1 51 where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and b.status = 1
52 group by b.cooperation_mode_number 52 group by b.cooperation_mode_number
@@ -57,10 +57,14 @@ func (ptr *CooperationStatisticsService) CooperationGoodsStatistics(queryOptions @@ -57,10 +57,14 @@ func (ptr *CooperationStatisticsService) CooperationGoodsStatistics(queryOptions
57 // 2.计算百分比 57 // 2.计算百分比
58 var totalAmount float64 58 var totalAmount float64
59 for i := range goods { 59 for i := range goods {
60 - goods[i].Rank = int32(i) 60 + goods[i].Rank = int32(i + 1)
61 totalAmount += goods[i].GoodAmount 61 totalAmount += goods[i].GoodAmount
62 } 62 }
63 for i := range goods { 63 for i := range goods {
  64 + if totalAmount == 0 {
  65 + goods[i].GoodRatio = 0
  66 + continue
  67 + }
64 goods[i].GoodRatio = utils.Round((goods[i].GoodAmount/totalAmount)*100, 0) 68 goods[i].GoodRatio = utils.Round((goods[i].GoodAmount/totalAmount)*100, 0)
65 } 69 }
66 return goods, nil 70 return goods, nil
@@ -202,7 +202,7 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac @@ -202,7 +202,7 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
202 query.Where(`(credit_account.participator->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", participatorName)) 202 query.Where(`(credit_account.participator->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", participatorName))
203 } 203 }
204 if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 { 204 if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 {
205 - query.Where("payment_status = ", paymentStatus) 205 + query.Where("payment_status = ?", paymentStatus)
206 } 206 }
207 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 { 207 if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
208 query.Where("company->>'companyId' = '?'", companyId) 208 query.Where("company->>'companyId' = '?'", companyId)
@@ -70,6 +70,7 @@ func (controller *CreditAccountController) RemoveCreditAccount() { @@ -70,6 +70,7 @@ func (controller *CreditAccountController) RemoveCreditAccount() {
70 func (controller *CreditAccountController) SearchCreditAccount() { 70 func (controller *CreditAccountController) SearchCreditAccount() {
71 creditAccountService := service.NewCreditAccountService(nil) 71 creditAccountService := service.NewCreditAccountService(nil)
72 searchCreditAccountQuery := &query.SearchCreditAccountQuery{} 72 searchCreditAccountQuery := &query.SearchCreditAccountQuery{}
  73 + _ = controller.Unmarshal(searchCreditAccountQuery)
73 data, err := creditAccountService.SearchCreditAccount(searchCreditAccountQuery) 74 data, err := creditAccountService.SearchCreditAccount(searchCreditAccountQuery)
74 controller.Response(data, err) 75 controller.Response(data, err)
75 } 76 }