• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang global.GetGlobalAttr函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中com/papersns/global.GetGlobalAttr函数的典型用法代码示例。如果您正苦于以下问题:Golang GetGlobalAttr函数的具体用法?Golang GetGlobalAttr怎么用?Golang GetGlobalAttr使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了GetGlobalAttr函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetPermissionQueryDict

func (o PermissionSupport) GetPermissionQueryDict(sessionId int, security Security) map[string]interface{} {
	if security.ByUnit == "true" {
		userIdI := global.GetGlobalAttr(sessionId, "userId")
		userId, err := strconv.Atoi(fmt.Sprint(userIdI))
		if err != nil {
			panic(err)
		}
		querySupport := QuerySupport{}
		session, _ := global.GetConnection(sessionId)
		collectionName := "SysUser"
		sysUser, found := querySupport.FindByMapWithSession(session, collectionName, map[string]interface{}{
			"_id": userId,
		})
		if found {
			sysUserMaster := sysUser["A"].(map[string]interface{})
			return map[string]interface{}{
				"A.createUnit": sysUserMaster["createUnit"],
			}
		}
		return map[string]interface{}{
			"_id": -1,
		}
	}
	if security.ByAdmin == "true" {
		adminUserId := global.GetGlobalAttr(sessionId, "adminUserId")
		if adminUserId != nil && fmt.Sprint(adminUserId) != "" {
			return map[string]interface{}{}
		}
		return map[string]interface{}{
			"_id": -1,
		}
	}
	return map[string]interface{}{}
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:34,代码来源:permission.go


示例2: RSetCreateFixFieldValue

func (c BaseDataAction) RSetCreateFixFieldValue(sessionId int, dataSource DataSource, bo *map[string]interface{}) {
	var result interface{} = ""
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	createTime, err := strconv.ParseInt(time.Now().Format("20060102150405"), 10, 64)
	if err != nil {
		panic(err)
	}
	_, db := global.GetConnection(sessionId)
	sysUser := map[string]interface{}{}
	query := map[string]interface{}{
		"_id": userId,
	}
	err = db.C("SysUser").Find(query).One(&sysUser)
	if err != nil {
		panic(err)
	}
	sysUserMaster := sysUser["A"].(map[string]interface{})
	modelIterator := ModelIterator{}
	modelIterator.IterateDataBo(dataSource, bo, &result, func(fieldGroupLi []FieldGroup, data *map[string]interface{}, rowIndex int, result *interface{}) {
		(*data)["createBy"] = userId
		(*data)["createTime"] = createTime
		(*data)["createUnit"] = sysUserMaster["createUnit"]
	})
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:27,代码来源:basedataaction.go


示例3: AfterQueryData

func (o BbsPostInterceptor) AfterQueryData(sessionId int, dataSetId string, items []interface{}) []interface{} {
	session, _ := global.GetConnection(sessionId)
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	collectionName := "BbsPostRead"
	interceptorCommon := InterceptorCommon{}
	commonUtil := CommonUtil{}
	for i, item := range items {
		data := item.(map[string]interface{})
		dataA := data["A"].(map[string]interface{})
		data["A"] = dataA
		items[i] = data

		bbsPostReadQuery := map[string]interface{}{
			"A.bbsPostId": data["id"],
			"A.readBy":    userId,
		}
		bbsPostRead, found := interceptorCommon.FindByMapWithSession(session, collectionName, bbsPostReadQuery)
		if !found {
			data["bbsPostReadType"] = 1 // 未读
		} else {
			bbsPostReadA := bbsPostRead["A"].(map[string]interface{})
			lastReadTime := commonUtil.GetFloat64FromMap(bbsPostReadA, "lastReadTime")
			lastReplyTime := commonUtil.GetFloat64FromMap(dataA, "lastReplyTime")
			if lastReadTime < lastReplyTime {
				dataA["bbsPostReadType"] = 1 // 未读
			} else {
				dataA["bbsPostReadType"] = 2 // 已读
			}
		}
	}
	return items
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:35,代码来源:BbsPostInterceptor.go


示例4: validateMasterDataDuplicate

func (o FinanceService) validateMasterDataDuplicate(sessionId int, dataSource DataSource, bo map[string]interface{}) string {
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	session, _ := global.GetConnection(sessionId)

	message := ""
	modelTemplateFactory := ModelTemplateFactory{}
	strId := modelTemplateFactory.GetStrId(bo)
	andQueryLi := []map[string]interface{}{}
	qb := QuerySupport{}
	andQueryLi = append(andQueryLi, map[string]interface{}{
		"deleteFlag": map[string]interface{}{
			"$ne": 9,
		},
		"A.createUnit": qb.GetCreateUnitByUserId(session, userId),
	})
	andFieldNameLi := []string{}
	modelIterator := ModelIterator{}
	var result interface{} = ""
	modelIterator.IterateAllFieldBo(dataSource, &bo, &result, func(fieldGroup FieldGroup, data *map[string]interface{}, rowIndex int, result *interface{}) {
		if fieldGroup.IsMasterField() {
			if fieldGroup.AllowDuplicate == "false" && fieldGroup.Id != "id" {
				andQueryLi = append(andQueryLi, map[string]interface{}{
					"A." + fieldGroup.Id: (*data)[fieldGroup.Id],
				})
				andFieldNameLi = append(andFieldNameLi, fieldGroup.DisplayName)
			}
		}
	})
	if len(andFieldNameLi) > 0 {
		if !(strId == "" || strId == "0") {
			andQueryLi = append(andQueryLi, map[string]interface{}{
				"_id": map[string]interface{}{
					"$ne": bo["id"],
				},
			})
		}
		duplicateQuery := map[string]interface{}{
			"$and": andQueryLi,
		}
		collectionName := modelTemplateFactory.GetCollectionName(dataSource)
		_, db := global.GetConnection(sessionId)
		duplicateQueryByte, err := json.MarshalIndent(duplicateQuery, "", "\t")
		if err != nil {
			panic(err)
		}
		log.Println("validateMasterDataDuplicate,collectionName:" + collectionName + ", query:" + string(duplicateQueryByte))
		count, err := db.C(collectionName).Find(duplicateQuery).Limit(1).Count()
		if err != nil {
			panic(err)
		}
		if count > 0 {
			message = strings.Join(andFieldNameLi, "+") + "不允许重复"
		}
	}

	return message
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:60,代码来源:service.go


示例5: addBbsPostRead

func (c BbsPostSupport) addBbsPostRead(sessionId int, bbsPostId int) {
	_, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	bbsPost := BbsPost{}
	modelTemplateFactory := ModelTemplateFactory{}
	bbsPostReadDS := modelTemplateFactory.GetDataSource("BbsPostRead")

	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	dateUtil := DateUtil{}
	sequenceNo := mongo.GetSequenceNo(db, "bbsPostReadId")
	bbsPostRead := map[string]interface{}{
		"_id": sequenceNo,
		"id":  sequenceNo,
		"A": map[string]interface{}{
			"id":           sequenceNo,
			"bbsPostId":    bbsPostId,
			"readBy":       userId,
			"lastReadTime": dateUtil.GetCurrentYyyyMMddHHmmss(),
		},
	}
	bbsPost.RSetCreateFixFieldValue(sessionId, bbsPostReadDS, &bbsPostRead)
	txnManager.Insert(txnId, "BbsPostRead", bbsPostRead)
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:27,代码来源:bbspost.go


示例6: GetFirstAccountingPeriodStartEndDate

func (o AccountInOutService) GetFirstAccountingPeriodStartEndDate(sessionId int, year int) (int, int) {
	session, _ := global.GetConnection(sessionId)
	dataSourceModelId := "AccountingPeriod"
	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	qb := QuerySupport{}
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	queryMap := map[string]interface{}{
		"A.accountingYear": year,
		"A.createUnit":     qb.GetCreateUnitByUserId(session, userId),
	}
	accountingPeriod, found := qb.FindByMapWithSession(session, collectionName, queryMap)
	if !found {
		panic(BusinessError{Message: "会计年度:" + fmt.Sprint(year) + "未找到对应会计期"})
		//		log.Println("会计年度:" + fmt.Sprint(year) + "未找到对应会计期")
		//		return 0, 0
	}
	var startDate int
	var endDate int
	bDataSetLi := accountingPeriod["B"].([]interface{})
	commonUtil := CommonUtil{}
	for _, item := range bDataSetLi {
		line := item.(map[string]interface{})
		startDate = commonUtil.GetIntFromMap(line, "startDate")
		endDate = commonUtil.GetIntFromMap(line, "endDate")
		break
	}
	return startDate, endDate
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:33,代码来源:accountinoutservice.go


示例7: addOrUpdateBbsPostRead

func (c BbsPostSupport) addOrUpdateBbsPostRead(sessionId int, bbsPostId int) {
	session, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	bbsPost := BbsPost{}
	modelTemplateFactory := ModelTemplateFactory{}
	bbsPostReadDS := modelTemplateFactory.GetDataSource("BbsPostRead")

	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	dateUtil := DateUtil{}
	qb := QuerySupport{}

	bbsPostRead, found := qb.FindByMapWithSession(session, "BbsPostRead", map[string]interface{}{
		"A.bbsPostId": bbsPostId,
		"A.readBy":    userId,
	})
	if found {
		bbsPost.RSetModifyFixFieldValue(sessionId, bbsPostReadDS, &bbsPostRead)
		bbsPostReadA := bbsPostRead["A"].(map[string]interface{})
		bbsPostRead["A"] = bbsPostReadA

		bbsPostReadA["lastReadTime"] = dateUtil.GetCurrentYyyyMMddHHmmss()
		_, updateResult := txnManager.Update(txnId, "BbsPostRead", bbsPostRead)
		if !updateResult {
			panic(BusinessError{Message: "更新意见反馈阅读记录失败"})
		}
	} else {
		c.addBbsPostRead(sessionId, bbsPostId)
	}
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:33,代码来源:bbspost.go


示例8: GetAccountingPeriodStartEndDate

func (o AccountInOutItemInterceptor) GetAccountingPeriodStartEndDate(sessionId int, year int, sequenceNo int) (int, int) {
	session, _ := global.GetConnection(sessionId)
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	collectionName := "AccountingPeriod"
	queryMap := map[string]interface{}{
		"A.accountingYear": year,
		"B.sequenceNo":     sequenceNo,
		"A.createUnit":     InterceptorCommon{}.GetCreateUnitByUserId(session, userId),
	}
	accountingPeriod, found := InterceptorCommon{}.FindByMapWithSession(session, collectionName, queryMap)
	if !found {
		//		panic(BusinessError{Message: "会计年度:" + fmt.Sprint(year) + ",会计期序号:" + fmt.Sprint(sequenceNo) + "未找到对应会计期"})
		log.Println("会计年度:" + fmt.Sprint(year) + ",会计期序号:" + fmt.Sprint(sequenceNo) + "未找到对应会计期")
		return 0, 0
	}
	var startDate int
	var endDate int
	bDataSetLi := accountingPeriod["B"].([]interface{})
	commonUtil := CommonUtil{}
	for _, item := range bDataSetLi {
		line := item.(map[string]interface{})
		if fmt.Sprint(line["sequenceNo"]) == fmt.Sprint(sequenceNo) {
			startDate = commonUtil.GetIntFromMap(line, "startDate")
			endDate = commonUtil.GetIntFromMap(line, "endDate")
			break
		}
	}
	return startDate, endDate
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:32,代码来源:AccountInOutItemInterceptor.go


示例9: CommitTxn

func (c BaseDataAction) CommitTxn(sessionId int) {
	txnId := global.GetGlobalAttr(sessionId, "txnId")
	if txnId != nil {
		_, db := global.GetConnection(sessionId)
		txnManager := TxnManager{db}
		txnManager.Commit(txnId.(int))
	}
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:8,代码来源:basedataaction.go


示例10: RSetModifyFixFieldValue

func (c Console) RSetModifyFixFieldValue(sessionId int, dataSource DataSource, bo *map[string]interface{}) {
	var result interface{} = ""
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	modifyTime, err := strconv.ParseInt(time.Now().Format("20060102150405"), 10, 64)
	if err != nil {
		panic(err)
	}
	_, db := global.GetConnection(sessionId)
	sysUser := map[string]interface{}{}
	query := map[string]interface{}{
		"_id": userId,
	}
	err = db.C("SysUser").Find(query).One(&sysUser)
	if err != nil {
		panic(err)
	}
	sysUserMaster := sysUser["A"].(map[string]interface{})

	srcBo := map[string]interface{}{}
	srcQuery := map[string]interface{}{
		"_id":          (*bo)["id"],
		"A.createUnit": sysUserMaster["createUnit"],
	}
	// log
	modelTemplateFactory := ModelTemplateFactory{}
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	srcQueryByte, err := json.Marshal(&srcQuery)
	if err != nil {
		panic(err)
	}
	log.Println("RSetModifyFixFieldValue,collectionName:" + collectionName + ", query:" + string(srcQueryByte))
	db.C(collectionName).Find(srcQuery).One(&srcBo)
	modelIterator := ModelIterator{}
	modelIterator.IterateDiffBo(dataSource, bo, srcBo, &result, func(fieldGroupLi []FieldGroup, destData *map[string]interface{}, srcData map[string]interface{}, result *interface{}) {
		if destData != nil && srcData == nil {
			(*destData)["createBy"] = userId
			(*destData)["createTime"] = modifyTime
			(*destData)["createUnit"] = sysUserMaster["createUnit"]
		} else if destData == nil && srcData != nil {
			// 删除,不处理
		} else if destData != nil && srcData != nil {
			isMasterData := fieldGroupLi[0].IsMasterField()
			isDetailDataDiff := (!fieldGroupLi[0].IsMasterField()) && modelTemplateFactory.IsDataDifferent(fieldGroupLi, *destData, srcData)
			if isMasterData || isDetailDataDiff {
				(*destData)["createBy"] = srcData["createBy"]
				(*destData)["createTime"] = srcData["createTime"]
				(*destData)["createUnit"] = srcData["createUnit"]

				(*destData)["modifyBy"] = userId
				(*destData)["modifyTime"] = modifyTime
				(*destData)["modifyUnit"] = sysUserMaster["createUnit"]
			}
		}
	})
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:58,代码来源:console.go


示例11: GetAccountingPeriodYearSequenceNo

func (o AccountInOutService) GetAccountingPeriodYearSequenceNo(sessionId int, ymd int) (int, int) {
	session, _ := global.GetConnection(sessionId)
	dataSourceModelId := "AccountingPeriod"
	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	qb := QuerySupport{}
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	queryMap := map[string]interface{}{
		"B.startDate": map[string]interface{}{
			"$lte": ymd,
		},
		"B.endDate": map[string]interface{}{
			"$gte": ymd,
		},
		"A.createUnit": qb.GetCreateUnitByUserId(session, userId),
	}
	accountingPeriod, found := qb.FindByMapWithSession(session, collectionName, queryMap)
	if !found {
		billDate, err := time.Parse("20060102", fmt.Sprint(ymd))
		if err != nil {
			panic(err)
		}
		//		log.Println("单据日期" + billDate.Format("2006-01-02") + "未找到对应会计期")
		//		return 0,0
		panic(BusinessError{Message: "单据日期" + billDate.Format("2006-01-02") + "未找到对应会计期"})
	}
	masterData := accountingPeriod["A"].(map[string]interface{})
	year, err := strconv.Atoi(fmt.Sprint(masterData["accountingYear"]))
	if err != nil {
		panic(err)
	}
	var sequenceNo int
	bDataSetLi := accountingPeriod["B"].([]interface{})
	for _, item := range bDataSetLi {
		line := item.(map[string]interface{})
		if fmt.Sprint(line["startDate"]) <= fmt.Sprint(ymd) && fmt.Sprint(ymd) <= fmt.Sprint(line["endDate"]) {
			sequenceNo, err = strconv.Atoi(fmt.Sprint(line["sequenceNo"]))
			if err != nil {
				panic(err)
			}
			break
		}
	}
	//	if sequenceNo == 0 {
	//		billDate, err := time.Parse("20060102", fmt.Sprint(ymd))
	//		if err != nil {
	//			panic(err)
	//		}
	//		panic(BusinessError{Message: "单据日期" + billDate.Format("2006-01-02") + "找到年度" + fmt.Sprint(year) + ",未找到会计期"})
	//	}

	return year, sequenceNo
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:57,代码来源:accountinoutservice.go


示例12: CheckBankAccountLimitControl

/**
 * 银行帐户赤字检查
 * @param sessionId
 * @param accountId
 * @param currencyTypeId
 * @return {code: int, message: string}
 * code AccountLimitControlStatus.SUCCESS:检查通过
 * code AccountLimitControlStatus.FORBID:赤字字段为禁止,保存时金额 < 0,需要调用方抛出异常通知客户端
 * code AccountLimitControlStatus.WARN:赤字字段为警告,保存时金额 < 0,需要调用方提供警告信息通知客户端
 */
func (o AccountInOutService) CheckBankAccountLimitControl(sessionId int, accountId int, currencyTypeId int) map[string]interface{} {
	session, _ := global.GetConnection(sessionId)
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	qb := QuerySupport{}
	queryMap := map[string]interface{}{
		"_id":          accountId,
		"A.createUnit": qb.GetCreateUnitByUserId(session, userId),
	}
	collectionName := "BankAccount"
	bankAccountBo, found := qb.FindByMapWithSession(session, collectionName, queryMap)
	if !found {
		queryMapByte, err := json.Marshal(&queryMap)
		if err != nil {
			panic(err)
		}
		panic(BusinessError{Message: "银行账户没找到,查询条件为:" + string(queryMapByte)})
	}
	bankAccountMaster := bankAccountBo["A"].(map[string]interface{})
	bDetailDataLi := bankAccountBo["B"].([]interface{})
	commonUtil := CommonUtil{}
	for _, item := range bDetailDataLi {
		bankAccountCurrencyType := item.(map[string]interface{})
		if fmt.Sprint(bankAccountCurrencyType["currencyTypeId"]) == fmt.Sprint(currencyTypeId) {
			limitsControl := fmt.Sprint(bankAccountCurrencyType["limitsControl"])
			amtOriginalCurrencyBalanceStr := fmt.Sprint(bankAccountCurrencyType["amtOriginalCurrencyBalance"])
			amtOriginalCurrencyBalance := commonUtil.GetFloat64FromString(amtOriginalCurrencyBalanceStr)

			if limitsControl == "1" { // 禁止
				if amtOriginalCurrencyBalance < 0 {
					result := map[string]interface{}{
						"code":    LIMIT_CONTROL_FORBID,
						"message": "帐户:" + fmt.Sprint(bankAccountMaster["name"]) + "出现赤字!",
					}
					return result
				}
			} else if limitsControl == "2" { // 警告
				if amtOriginalCurrencyBalance < 0 {
					result := map[string]interface{}{
						"code":    LIMIT_CONTROL_WARN,
						"message": "帐户:" + fmt.Sprint(bankAccountMaster["name"]) + "出现赤字!",
					}
					return result
				}
			}
			break
		}
	}
	return map[string]interface{}{
		"code": LIMIT_CONTROL_SUCCESS,
	}
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:64,代码来源:accountinoutservice.go


示例13: RRollbackTxn

func (c BaseDataAction) RRollbackTxn(sessionId int) {
	txnId := global.GetGlobalAttr(sessionId, "txnId")
	if txnId != nil {
		if x := recover(); x != nil {
			_, db := global.GetConnection(sessionId)
			txnManager := TxnManager{db}
			txnManager.Rollback(txnId.(int))
			panic(x)
		}
	}
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:11,代码来源:basedataaction.go


示例14: GetAccountingPeriodStartProgramDictionary

func (o ProgramDictionaryManager) GetAccountingPeriodStartProgramDictionary(sessionId int, db *mgo.Database, code string) map[string]interface{} {
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}

	collection := "AccountingPeriod"
	c := db.C(collection)
	
	session, _ := global.GetConnection(sessionId)
	queryMap := map[string]interface{}{
		"A.createUnit": o.GetCreateUnitByUserId(session, userId),
	}
	
	itemResult := []map[string]interface{}{}
	err = c.Find(queryMap).All(&itemResult)
	if err != nil {
		panic(err)
	}
	
	result := map[string]interface{}{}
	result["code"] = code
	items := []interface{}{}
	for _, item := range itemResult {
		detailLi := item["B"].([]interface{})
		for _, detail := range detailLi {
			detailMap := detail.(map[string]interface{})
			isIn := false
			for _, dictItem := range items {
				dictItemMap := dictItem.(map[string]interface{})
				if fmt.Sprint(dictItemMap["code"]) == fmt.Sprint(detailMap["sequenceNo"]) {
					isIn = true
					break
				}
			}
			if !isIn {
				items = append(items, map[string]interface{}{
					"code": detailMap["sequenceNo"],
					"name": detailMap["sequenceNo"],
					"order": detailMap["sequenceNo"],
				})
			}
		}
	}
	result["items"] = items
	
	// 排序
	o.sortProgramDictionary(&result)
	return result
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:50,代码来源:ProgramDictionary.go


示例15: LogCashAccountInOut

/**
 * 现金帐户过帐,
 * @param depositLogParam 过帐参数对象
 */
func (o AccountInOutService) LogCashAccountInOut(sessionId int, accountInOutParam AccountInOutParam) {
	session, db := global.GetConnection(sessionId)
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	collectionName := "CashAccount"
	querySupport := QuerySupport{}
	queryMap := map[string]interface{}{
		"_id":          accountInOutParam.AccountId,
		"A.createUnit": querySupport.GetCreateUnitByUserId(session, userId),
	}
	cashAccountBo, found := querySupport.FindByMapWithSession(session, collectionName, queryMap)
	if !found {
		queryMapByte, err := json.Marshal(&queryMap)
		if err != nil {
			panic(err)
		}
		panic(BusinessError{Message: "现金账户没找到,查询条件为:" + string(queryMapByte)})
	}

	mathUtil := MathUtil{}
	cashAccount := cashAccountBo["A"].(map[string]interface{})
	if fmt.Sprint(cashAccount["currencyTypeId"]) != fmt.Sprint(accountInOutParam.CurrencyTypeId) {
		panic(BusinessError{Message: "过账现金账户:" + fmt.Sprint(cashAccount["name"]) + "未找到对应币别"})
	}

	amtOriginalCurrencyBalance := fmt.Sprint(cashAccount["amtOriginalCurrencyBalance"])

	amtIncrease := accountInOutParam.AmtIncrease
	amtReduce := accountInOutParam.AmtReduce

	if accountInOutParam.DiffDataType == ADD || accountInOutParam.DiffDataType == AFTER_UPDATE { // 正过账
		amtOriginalCurrencyBalance = mathUtil.Add(amtOriginalCurrencyBalance, amtIncrease)
		amtOriginalCurrencyBalance = mathUtil.Sub(amtOriginalCurrencyBalance, amtReduce)
	} else if accountInOutParam.DiffDataType == BEFORE_UPDATE || accountInOutParam.DiffDataType == DELETE { // 反过账
		amtOriginalCurrencyBalance = mathUtil.Sub(amtOriginalCurrencyBalance, amtIncrease)
		amtOriginalCurrencyBalance = mathUtil.Add(amtOriginalCurrencyBalance, amtReduce)
	}
	commonUtil := CommonUtil{}
	cashAccount["amtOriginalCurrencyBalance"] = commonUtil.GetFloatFormat(amtOriginalCurrencyBalance)
	cashAccountBo["A"] = cashAccount
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	_, found = txnManager.Update(txnId, collectionName, cashAccountBo)
	if !found {
		panic(BusinessError{Message: "现金账户更新失败"})
	}
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:53,代码来源:accountinoutservice.go


示例16: RAfterDeleteData

func (c BbsPostSupport) RAfterDeleteData(sessionId int, dataSource DataSource, formTemplate FormTemplate, bo *map[string]interface{}) {
	// 反过账
	_, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}

	query := map[string]interface{}{
		"A.bbsPostId": (*bo)["id"],
		"A.readBy":    userId,
	}
	txnManager.RemoveAll(txnId, "BbsPostRead", query)
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:16,代码来源:bbspost.go


示例17: setBillNo

func (o GatheringBillSupport) setBillNo(sessionId int, bo *map[string]interface{}) {
	master := (*bo)["A"].(map[string]interface{})
	(*bo)["A"] = master
	session, _ := global.GetConnection(sessionId)

	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	// 单据编号
	qb := QuerySupport{}
	gatheringBillCollectionName := "GatheringBill"
	billNoQuery := map[string]interface{}{
		"A.createUnit": qb.GetCreateUnitByUserId(session, userId),
	}
	pageNo := 1
	pageSize := 1
	orderBy := "-A.billNo"
	result := qb.IndexWithSession(session, gatheringBillCollectionName, billNoQuery, pageNo, pageSize, orderBy)
	items := result["items"].([]interface{})
	dateUtil := DateUtil{}
	if len(items) > 0 {
		maxItem := items[0].(map[string]interface{})
		maxItemA := maxItem["A"].(map[string]interface{})
		maxBillNo := fmt.Sprint(maxItemA["billNo"])

		regx := regexp.MustCompile(`^.*?(\d+)$`)
		matchResult := regx.FindStringSubmatch(maxBillNo)
		if len(matchResult) >= 2 {
			matchNum := matchResult[1]
			matchInt, err := strconv.Atoi(matchNum)
			if err != nil {
				master["billNo"] = fmt.Sprint(dateUtil.GetCurrentYyyyMMdd()) + "_001"
			} else {
				matchStr := fmt.Sprint(matchInt + 1)
				if len(matchStr) < 3 {
					matchStr = "000"[:(3-len(matchStr))] + matchStr
				}
				master["billNo"] = fmt.Sprint(dateUtil.GetCurrentYyyyMMdd()) + "_" + matchStr
			}
		} else {
			master["billNo"] = fmt.Sprint(dateUtil.GetCurrentYyyyMMdd()) + "_001"
		}
	} else {
		master["billNo"] = fmt.Sprint(dateUtil.GetCurrentYyyyMMdd()) + "_001"
	}
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:47,代码来源:gatheringbill.go


示例18: CheckCashAccountLimitControl

/**
 * 检查现金帐户赤字,供过帐完毕后调用
 * @param session
 * @param accountId
 * @return {code: int, message: string}
 * code LIMIT_CONTROL_SUCCESS:检查通过
 * code LIMIT_CONTROL_FORBID:赤字字段为禁止,保存时金额 < 0,需要调用方抛出异常通知客户端
 * code LIMIT_CONTROL_WARN:赤字字段为警告,保存时金额 < 0,需要调用方提供警告信息通知客户端
 */
func (o AccountInOutService) CheckCashAccountLimitControl(sessionId int, accountId int) map[string]interface{} {
	qb := QuerySupport{}
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	session, _ := global.GetConnection(sessionId)
	queryMap := map[string]interface{}{
		"_id":          accountId,
		"A.createUnit": qb.GetCreateUnitByUserId(session, userId),
	}
	collectionName := "CashAccount"
	cashAccountBo, found := qb.FindByMapWithSession(session, collectionName, queryMap)
	if !found {
		queryMapByte, err := json.Marshal(&queryMap)
		if err != nil {
			panic(err)
		}
		panic(BusinessError{Message: "现金账户没找到,查询条件为:" + string(queryMapByte)})
	}
	cashAccount := cashAccountBo["A"].(map[string]interface{})
	limitsControl := fmt.Sprint(cashAccount["limitsControl"])
	commonUtil := CommonUtil{}
	amtOriginalCurrencyBalance := commonUtil.GetFloat64FromString(fmt.Sprint(cashAccount["amtOriginalCurrencyBalance"]))
	if limitsControl == "1" { // 禁止
		if amtOriginalCurrencyBalance < 0 {
			result := map[string]interface{}{
				"code":    LIMIT_CONTROL_FORBID,
				"message": "帐户:" + fmt.Sprint(cashAccount["name"]) + "出现赤字!",
			}
			return result
		}
	} else if limitsControl == "2" { // 警告
		if amtOriginalCurrencyBalance < 0 {
			result := map[string]interface{}{
				"code":    LIMIT_CONTROL_WARN,
				"message": "帐户:" + fmt.Sprint(cashAccount["name"]) + "出现赤字!",
			}
			return result
		}
	}
	return map[string]interface{}{
		"code": LIMIT_CONTROL_SUCCESS,
	}
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:54,代码来源:accountinoutservice.go


示例19: RAfterNewData

func (c GatheringBillSupport) RAfterNewData(sessionId int, dataSource DataSource, formTemplate FormTemplate, bo *map[string]interface{}) {
	master := (*bo)["A"].(map[string]interface{})
	(*bo)["A"] = master
	modelTemplateFactory := ModelTemplateFactory{}
	billTypeParameterDataSource := modelTemplateFactory.GetDataSource("BillReceiveTypeParameter")
	collectionName := modelTemplateFactory.GetCollectionName(billTypeParameterDataSource)
	session, _ := global.GetConnection(sessionId)
	qb := QuerySupport{}
	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}
	queryMap := map[string]interface{}{
		"A.billTypeId": 1,
		"A.createUnit": qb.GetCreateUnitByUserId(session, userId),
	}

	billTypeParameter, found := qb.FindByMapWithSession(session, collectionName, queryMap)
	if !found {
		panic(BusinessError{
			Message: "未找到收款单类型参数",
		})
	}
	billTypeParameterMaster := billTypeParameter["A"].(map[string]interface{})
	master["property"] = billTypeParameterMaster["property"]

	// 币别默认值
	currencyTypeQuery := map[string]interface{}{
		"A.code":       "RMB",
		"A.createUnit": qb.GetCreateUnitByUserId(session, userId),
	}

	currencyTypeCollectionName := "CurrencyType"
	result, found := qb.FindByMapWithSession(session, currencyTypeCollectionName, currencyTypeQuery)
	if found {
		master["currencyTypeId"] = result["id"]
	}

	// 单据编号
	c.setBillNo(sessionId, bo)
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:41,代码来源:gatheringbill.go


示例20: GetAccountingPeriod

func (o AccountInOutItemInterceptor) GetAccountingPeriod(sessionId int, year int) (map[string]interface{}, bool) {
	session, _ := global.GetConnection(sessionId)
	collectionName := "AccountingPeriod"

	userId, err := strconv.Atoi(fmt.Sprint(global.GetGlobalAttr(sessionId, "userId")))
	if err != nil {
		panic(err)
	}

	queryMap := map[string]interface{}{
		"A.accountingYear": year,
		"A.createUnit":     InterceptorCommon{}.GetCreateUnitByUserId(session, userId),
	}
	accountingPeriod, found := InterceptorCommon{}.FindByMapWithSession(session, collectionName, queryMap)
	if !found {
		//		panic(BusinessError{Message: "会计年度:" + fmt.Sprint(year) + ",会计期序号:" + fmt.Sprint(sequenceNo) + "未找到对应会计期"})
		log.Println("会计年度:" + fmt.Sprint(year) + "未找到对应会计期")
		return nil, false
	}
	return accountingPeriod, true
}
开发者ID:hongjinqiu,项目名称:finance,代码行数:21,代码来源:AccountInOutItemInterceptor.go



注:本文中的com/papersns/global.GetGlobalAttr函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang global.GetSessionId函数代码示例发布时间:2022-05-24
下一篇:
Golang global.GetConnection函数代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap