作者 陈志颖

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

…ion-cooperation into dev
... ... @@ -18,7 +18,7 @@ type SearchContractUndertakerFeedbackQuery struct {
// 用户ID,通过集成REST上下文获取,可翻译成发起人、承接人、推荐人、业务员
UserId int64 `cname:"用户ID" json:"userId"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId" valid:"Required"`
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
// 共创合约名称
CooperationContractName string `cname:"共创合约名称" json:"cooperationContractName,omitempty"`
// 承接人姓名
... ...
... ... @@ -22,7 +22,7 @@ type SearchCooperationApplicationQuery struct {
// 页面大小
PageNumber int64 `cname:"页码" json:"pageNumber,omitempty"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
CompanyId int64 `cname:"公司ID" json:"companyId"`
// 组织机构ID
OrgId int64 `cname:"组织机构ID" json:"orgId"`
// 关联的组织机构ID列表
... ...
... ... @@ -174,6 +174,11 @@ func (cooperationApplicationService *CooperationApplicationService) ApprovalCoop
if cooperationApplication == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", strconv.FormatInt(cooperationApplicationId, 10)))
}
if approvalCooperationApplicationCommand.Action == 1 {
cooperationApplication.CooperationApplicationStatus = 2
} else if approvalCooperationApplicationCommand.Action == 2 {
cooperationApplication.CooperationApplicationStatus = 3
}
if err := cooperationApplication.Update(tool_funs.SimpleStructToMap(approvalCooperationApplicationCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
... ...
... ... @@ -17,13 +17,15 @@ type CreateCooperationProjectCommand struct {
// 共创模式编码
CooperationModeNumber string `cname:"共创模式编码" json:"cooperationModeNumber" valid:"Required"`
// 共创项目发起人uid
SponsorUid string `cname:"共创项目发起人UID" json:"sponsorUid" valid:"Required"`
SponsorUid int64 `cname:"共创项目发起人UID" json:"sponsorUid,string" valid:"Required"`
// 共创项目发布人uid
PublisherUid string `cname:"共创项目发布人UID" json:"publisherUid" valid:"Required"`
PublisherUid int64 `cname:"共创项目发布人UID" json:"publisherUid,string" valid:"Required"`
// 共创项目描述
CooperationProjectDescription string `cname:"共创项目描述" json:"cooperationProjectDescription,omitempty"`
// 附件
Attachment []*domain.Attachment `cname:"附件" json:"attachment"`
// 所属部门Id
DepartmentId int64 `json:"departmentId,string"`
// 公司ID,通过集成REST上下文获取
CompanyId int64 `cname:"公司ID" json:"companyId" valid:"Required"`
// 组织机构ID
... ...
... ... @@ -75,7 +75,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
// Sponsor
var sponsor *domain.User
if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.UserId); err != nil {
if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.SponsorUid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
sponsor = data
... ... @@ -83,7 +83,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
// Publisher
var publisher *domain.User
if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.UserId); err != nil {
if data, err := userService.UserFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.OrgId, createCooperationProjectCommand.PublisherUid); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
publisher = data
... ... @@ -121,6 +121,14 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
organization = data
}
// 获取组织机构信息
var department *domain.Org
if data, err := organizationService.OrgFrom(createCooperationProjectCommand.CompanyId, createCooperationProjectCommand.DepartmentId); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
department = data
}
// 查找共创模式
var cooperationModeRepository domain.CooperationModeRepository
if value, err := factory.CreateCooperationModeRepository(map[string]interface{}{
... ... @@ -171,7 +179,7 @@ func (cooperationProjectService *CooperationProjectService) CreateCooperationPro
CooperationProjectPublishTime: time.Now(),
Attachment: createCooperationProjectCommand.Attachment,
Company: company,
Department: organization.ToDepartment(),
Department: department.ToDepartment(),
Org: organization,
Operator: operator,
OperateTime: time.Now(),
... ...
... ... @@ -28,10 +28,10 @@ func (dao *OrderGoodDao) CooperationGoodsStatistics(queryOptions map[string]inte
if _, ok := queryOptions["limit"]; ok {
queryLimit = fmt.Sprintf("limit %v", queryOptions["limit"])
}
sql := fmt.Sprintf(`select order_good_name goodName,sum(order_good_amount) goodAmount from order_goods
sql := fmt.Sprintf(`select order_good_name good_name,sum(order_good_amount) good_amount from order_goods
where company_id=? and org_id = ? %v
GROUP BY order_good_name
order by goodAmount desc
order by good_amount desc
%v
`, queryTime, queryLimit)
_, err := tx.Query(&goods, sql, queryOptions["companyId"], queryOptions["orgId"])
... ... @@ -46,7 +46,7 @@ order by goodAmount desc
func (dao *OrderGoodDao) CooperationModeStatistics(queryOptions map[string]interface{}) ([]*domain.CooperationModeStatisticsDto, error) {
tx := dao.transactionContext.PgTx
var goods []*domain.CooperationModeStatisticsDto
sql := fmt.Sprintf(`select count(0) cooperationPeople,sum(a.actually_paid_amount) dividendsEstimate,b.cooperation_mode_number,0 orderAmount
sql := fmt.Sprintf(`select count(0) cooperation_people,sum(a.actually_paid_amount) dividends_estimate,b.cooperation_mode_number,0 order_amount
from credit_accounts a inner join cooperation_contracts b on a.cooperation_contract_number = b.cooperation_contract_number
where a.company->>'companyId' = '?' and a.org->>'orgId' = '?' and b.status = 1
group by b.cooperation_mode_number
... ...
... ... @@ -57,10 +57,14 @@ func (ptr *CooperationStatisticsService) CooperationGoodsStatistics(queryOptions
// 2.计算百分比
var totalAmount float64
for i := range goods {
goods[i].Rank = int32(i)
goods[i].Rank = int32(i + 1)
totalAmount += goods[i].GoodAmount
}
for i := range goods {
if totalAmount == 0 {
goods[i].GoodRatio = 0
continue
}
goods[i].GoodRatio = utils.Round((goods[i].GoodAmount/totalAmount)*100, 0)
}
return goods, nil
... ...
... ... @@ -202,7 +202,7 @@ func (repository *CreditAccountRepository) Find(queryOptions map[string]interfac
query.Where(`(credit_account.participator->>'userName')::text LIKE ?`, fmt.Sprintf("%%%s%%", participatorName))
}
if paymentStatus, ok := queryOptions["paymentStatus"]; ok && paymentStatus.(int32) != 0 {
query.Where("payment_status = ", paymentStatus)
query.Where("payment_status = ?", paymentStatus)
}
if companyId, ok := queryOptions["companyId"]; ok && companyId.(int64) != 0 {
query.Where("company->>'companyId' = '?'", companyId)
... ...
... ... @@ -70,6 +70,7 @@ func (controller *CreditAccountController) RemoveCreditAccount() {
func (controller *CreditAccountController) SearchCreditAccount() {
creditAccountService := service.NewCreditAccountService(nil)
searchCreditAccountQuery := &query.SearchCreditAccountQuery{}
_ = controller.Unmarshal(searchCreditAccountQuery)
data, err := creditAccountService.SearchCreditAccount(searchCreditAccountQuery)
controller.Response(data, err)
}
... ...