作者 陈志颖

合并分支 'dev' 到 'test'

Dev



查看合并请求 !49
... ... @@ -19,6 +19,8 @@ type SearchCooperationProjectExtQuery struct {
ExtUserId int64 `cname:"用户ID" json:"extUserId,omitempty"`
// 用户基础数据id
ExtUserBaseId int64 `cname:"用户基础数据ID" json:"extUserBaseId,omitempty"`
// 共创项目承接对象,1员工,2共创用户,3公开,可多选
ExtCooperationProjectUndertakerTypes []int32 `json:"extCooperationProjectUndertakerTypes"`
}
type SearchCooperationProjectQuery struct {
... ... @@ -30,8 +32,10 @@ type SearchCooperationProjectQuery struct {
CooperationProjectName string `cname:"共创项目名称" json:"cooperationProjectName,omitempty"`
// 共创项目编号
CooperationProjectNumber string `cname:"共创项目编号" json:"cooperationProjectNumber,omitempty"`
// 共创项目承接对象,1员工,2共创用户,4公开,可以多选
// 共创项目承接对象,1员工,2共创用户,3公开
CooperationProjectUndertakerType int32 `json:"cooperationProjectUndertakerType"`
// 共创项目承接对象,1员工,2共创用户,3公开,可多选
CooperationProjectUndertakerTypes []int32 `json:"cooperationProjectUndertakerTypes"`
// 部门名称
DepartmentName string `cname:"部门名称" json:"departmentName,omitempty"`
// 关键字搜索
... ...
... ... @@ -1271,18 +1271,26 @@ func (dividendsReturnedOrderService *DividendsReturnedOrderService) UpdateDivide
var orderGoods []*domain.OrderGood
var dividendsReturnedOrderAmount float64
for _, orderGood := range updateDividendsReturnedOrderCommand.OrderGoods {
// 产品ID类型转换
orderGoodId, err3 := strconv.ParseInt(orderGood.OrderGoodId, 10, 64)
if err3 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err3.Error())
}
orderGoodFound := &domain.OrderGood{}
// 获取产品
orderGoodFound, err4 := orderGoodRepository.FindOne(map[string]interface{}{
"orderGoodId": orderGoodId,
})
if err4 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
if orderGood.OrderGoodId != "" {
orderGoodFetched, err4 := orderGoodRepository.FindOne(map[string]interface{}{
"orderGoodId": orderGoodId,
})
if err4 != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err4.Error())
}
orderGoodFound = orderGoodFetched
} else {
orderGoodFound.OrderGoodDividendsStatus = int32(1)
}
// 退货产品金额计算
... ...
... ... @@ -5,7 +5,7 @@ import "os"
const SERVICE_NAME = "allied-creation-cooperation"
// LOG_TYPE 日志相关设置
var LOG_TYPE = "terminal" // file, terminal, es
var LOG_TYPE = "console" // file, console, es
var LOG_FRAMEWORK = "beego" // beego logrus
var LOG_LEVEL = "debug"
var LOG_FILE = "app.log"
... ...
... ... @@ -3,6 +3,8 @@ package repository
import (
"fmt"
"github.com/go-pg/pg/v10"
"github.com/go-pg/pg/v10/orm"
query2 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
"time"
... ... @@ -266,6 +268,39 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
if cooperationProjectUndertakerType, ok := queryOptions["cooperationProjectUndertakerType"]; ok && cooperationProjectUndertakerType.(int32) != 0 {
query.Where(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, cooperationProjectUndertakerType)
}
if cooperationProjectUndertakerTypes, ok := queryOptions["cooperationProjectUndertakerTypes"]; ok && len(cooperationProjectUndertakerTypes.([]int32)) > 0 {
query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
for _, cooperationProjectUndertakerType := range cooperationProjectUndertakerTypes.([]int32) {
q.WhereOr(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, cooperationProjectUndertakerType)
}
return q, nil
})
}
if searchCooperationProjectExtQueries, ok := queryOptions["searchCooperationProjectExtQueries"]; ok && len(searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery)) > 0 {
for _, searchCooperationProjectExtQuery := range searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery) {
query.WhereOrGroup(func(q *orm.Query) (*orm.Query, error) {
if searchCooperationProjectExtQuery.ExtCompanyId != 0 {
q.Where("company->>'companyId' = '?'", searchCooperationProjectExtQuery.ExtCompanyId)
}
if searchCooperationProjectExtQuery.ExtOrgId != 0 {
q.Where("org->>'orgId' = '?'", searchCooperationProjectExtQuery.ExtOrgId)
}
if len(searchCooperationProjectExtQuery.ExtOrgIds) > 0 {
newOrgIds := utils.SliceItoa(searchCooperationProjectExtQuery.ExtOrgIds)
q.Where("org->>'orgId' in (?)", pg.In(newOrgIds))
}
if len(searchCooperationProjectExtQuery.ExtCooperationProjectUndertakerTypes) > 0 {
q.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
for _, cooperationProjectUndertakerType := range searchCooperationProjectExtQuery.ExtCooperationProjectUndertakerTypes {
q.WhereOr(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, cooperationProjectUndertakerType)
}
return q, nil
})
}
return q, nil
})
}
}
if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
query.Where("department->>'departmentName' like ? ", fmt.Sprintf("%%%s%%", departmentName))
}
... ...
... ... @@ -53,7 +53,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
updateFields := sqlbuilder.RemoveSqlFields(sqlBuildFields, "dividendsReturnedOrder_id")
updateFieldsSnippet := sqlbuilder.SqlUpdateFieldsSnippet(updateFields)
tx := repository.transactionContext.PgTx
if dividendsReturnedOrder.Identify() == nil {
if dividendsReturnedOrder.Identify() == nil { // 新增分红退货单
dividendsReturnedOrderId, err := repository.nextIdentify()
if err != nil {
return dividendsReturnedOrder, err
... ... @@ -137,7 +137,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
if _, err := tx.Model(&orderGoodsModel).Insert(); err != nil {
return nil, err
}
} else {
} else { // 编辑分红退货单
if _, err := tx.QueryOne(
pg.Scan(
&dividendsReturnedOrder.DividendsReturnedOrderId,
... ... @@ -200,8 +200,10 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
// 待更新分红退货单产品
var orderGoodsToUpdate []*domain.OrderGood
// 待添加分红退货单产品
var orderGoodsToAdd []*domain.OrderGood
for _, good := range dividendsReturnedOrder.Goods {
if good.OrderGoodId != 0 {
orderGoodsToUpdate = append(orderGoodsToUpdate, good)
... ... @@ -305,7 +307,7 @@ func (repository *DividendsReturnedOrderRepository) Save(dividendsReturnedOrder
}
}
if len(orderGoodModelsToDelete) > 0 {
if _, err := tx.Model(&orderGoodModelsToDelete).Delete(); err != nil {
if _, err := tx.Model(&orderGoodModelsToDelete).WherePK().Delete(); err != nil {
return nil, err
}
}
... ...