Esempio n. 1
0
/**
 * 删除日记帐明细
 * @param sessionId
 * @param accountInOutItemParam 日记帐明细业务参数
 */
func (o AccountInOutService) deleteCashBankDailyInOut(sessionId int, accountInOutItemParam AccountInOutItemParam) {
	_, db := global.GetConnection(sessionId)
	query := map[string]interface{}{
		"A.accountId":      accountInOutItemParam.AccountId,
		"A.currencyTypeId": accountInOutItemParam.CurrencyTypeId,
		"A.accountType":    accountInOutItemParam.AccountType,
		"A.billId":         accountInOutItemParam.BillId,
		"A.billTypeId":     accountInOutItemParam.BillTypeId,
	}
	if accountInOutItemParam.BillDetailId != 0 {
		query["A.billDetailId"] = accountInOutItemParam.BillDetailId
		query["A.billDetailName"] = accountInOutItemParam.BillDetailName
	} else {
		query["A.billDetailId"] = 0 // 主数据集记录
	}
	dataSourceModelId := "AccountInOutItem"
	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	_, result := txnManager.RemoveAll(txnId, collectionName, query)
	if !result {
		queryByte, err := json.MarshalIndent(&query, "", "\t")
		if err != nil {
			panic(err)
		}
		panic("删除日记账明细失败,查询语句为:" + string(queryByte))
	}
}
Esempio n. 2
0
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)
	}
}
Esempio n. 3
0
func (o UsedCheck) deleteReference(sessionId int, referenceQueryLi []interface{}) {
	_, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	//	deleteQuery := map[string]interface{}{
	//		"reference": referenceQueryLi,
	//	}
	deleteQuery := map[string]interface{}{
	//"$and": referenceQueryLi,
	}
	andQuery := []interface{}{}
	for _, item := range referenceQueryLi {
		andQuery = append(andQuery, map[string]interface{}{
			"reference": item,
		})
	}
	deleteQuery["$and"] = andQuery
	deleteByte, err := json.MarshalIndent(&deleteQuery, "", "\t")
	if err != nil {
		panic(err)
	}
	log.Println("deleteReference,collection:PubReferenceLog,query is:" + string(deleteByte))
	count, err := db.C("PubReferenceLog").Find(deleteQuery).Limit(1).Count()
	if err != nil {
		panic(err)
	}
	if count > 0 {
		_, result := txnManager.RemoveAll(txnId, "PubReferenceLog", deleteQuery)
		if !result {
			panic("删除失败")
		}
	}
}
Esempio n. 4
0
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)
}
Esempio n. 5
0
func (o UsedCheck) Insert(sessionId int, fieldGroupLi []FieldGroup, bo *map[string]interface{}, data *map[string]interface{}) {
	_, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	createTime := DateUtil{}.GetCurrentYyyyMMddHHmmss()
	for _, fieldGroup := range fieldGroupLi {
		if fieldGroup.IsRelationField() {
			modelTemplateFactory := ModelTemplateFactory{}
			relationItem, found := modelTemplateFactory.ParseRelationExpr(fieldGroup, *bo, *data)
			if !found {
				panic("数据源:" + fieldGroup.GetDataSource().Id + ",数据集:" + fieldGroup.GetDataSetId() + ",字段:" + fieldGroup.Id + ",配置的关联模型列表,不存在返回true的记录")
			}
			referenceData := map[string]interface{}{
				"A": map[string]interface{}{
					"createBy":   (*data)["createBy"],
					"createTime": createTime,
					"createUnit": (*data)["createUnit"],
				},
				"reference":   o.GetSourceReferenceLi(db, fieldGroup, bo, data),
				"beReference": o.GetBeReferenceLi(db, fieldGroup, relationItem, data),
			}
			txnManager.Insert(txnId, "PubReferenceLog", referenceData)
		}
	}
}
Esempio n. 6
0
/**
 * 添加现金账户会计期汇总(月档)记录
 * @param sessionId
 * @param accountInOutParam 参数对象
 */
func (o AccountInOutService) addFinAccountInOutForCash(sessionId int, accountInOutParam AccountInOutParam) map[string]interface{} {
	accountInOut := map[string]interface{}{
		"accountType":           accountInOutParam.AccountType,
		"accountId":             accountInOutParam.AccountId,
		"currencyTypeId":        accountInOutParam.CurrencyTypeId,
		"exchangeRateShow":      accountInOutParam.ExchangeRateShow,
		"exchangeRate":          accountInOutParam.ExchangeRate,
		"accountingPeriodYear":  accountInOutParam.AccountingPeriodYear,
		"accountingPeriodMonth": accountInOutParam.AccountingPeriodMonth,
		"amtIncrease":           "0",
		"amtReduce":             "0",
		"createBy":              accountInOutParam.CreateBy,
		"createTime":            accountInOutParam.CreateTime,
		"createUnit":            accountInOutParam.CreateUnit,
	}
	_, db := global.GetConnection(sessionId)
	dataSourceModelId := "AccountInOut"
	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	masterSeqName := GetMasterSequenceName(dataSource)
	masterSeqId := GetSequenceNo(db, masterSeqName)
	accountInOut["id"] = masterSeqId
	bo := map[string]interface{}{
		"_id": masterSeqId,
		"id":  masterSeqId,
		"A":   accountInOut,
	}
	modelTemplateFactory.ConvertDataType(dataSource, &bo)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	return txnManager.Insert(txnId, collectionName, bo)
}
Esempio n. 7
0
/**
初始化系统参数
*/
func (o StepService) InitSystemParameter(sessionId int, sysUser map[string]interface{}) {
	sysUserMaster := sysUser["A"].(map[string]interface{})
	txnId := global.GetTxnId(sessionId)
	session, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	qb := QuerySupport{}
	initDataLi := []map[string]interface{}{
		map[string]interface{}{
			"percentDecimals":    3,
			"percentRoundingWay": 2,
			"thousandDecimals":   2,
			//			"currencyTypeId": xxxx,
			"costDecimals": 3,
			//			"taxTypeId": xxxx,
		},
	}
	for _, initData := range initDataLi {
		_, found := qb.FindByMapWithSession(session, "SystemParameter", map[string]interface{}{
			"A.createUnit": sysUserMaster["createUnit"],
		})
		if !found {
			id := mongo.GetSequenceNo(db, "systemParameterId")
			aData := map[string]interface{}{
				"id":          id,
				"createBy":    sysUserMaster["id"],
				"createTime":  DateUtil{}.GetCurrentYyyyMMddHHmmss(),
				"createUnit":  sysUserMaster["createUnit"],
				"modifyBy":    0,
				"modifyTime":  0,
				"modifyUnit":  0,
				"billStatus":  0,
				"attachCount": 0,
				"remark":      "",
			}
			for k, v := range initData {
				aData[k] = v
			}
			// 币别
			currencyType, found := qb.FindByMapWithSession(session, "CurrencyType", map[string]interface{}{
				"A.createUnit": sysUserMaster["createUnit"],
			})
			if found {
				aData["currencyTypeId"] = currencyType["id"]
			}
			taxType, found := qb.FindByMapWithSession(session, "TaxType", map[string]interface{}{
				"A.createUnit": sysUserMaster["createUnit"],
			})
			if found {
				aData["taxTypeId"] = taxType["id"]
			}
			data := map[string]interface{}{
				"_id": id,
				"id":  id,
				"A":   aData,
			}
			txnManager.Insert(txnId, "SystemParameter", data)
		}
	}
}
Esempio n. 8
0
func (o LoginService) saveOrUpdateLastSessionData(sessionId int, resStruct map[string]interface{}, sysUnitId int, sysUserId int) {
	session, db := global.GetConnection(sessionId)
	qb := QuerySupport{}
	lastSessionData, found := qb.FindByMapWithSession(session, "LastSessionData", map[string]interface{}{
		"A.sysUserId": sysUserId,
		"A.sysUnitId": sysUnitId,
	})
	txnManager := TxnManager{db}
	if !found {
		id := mongo.GetSequenceNo(db, "lastSessionDataId")
		txnId := global.GetTxnId(sessionId)
		lastSessionData := map[string]interface{}{
			"_id": id,
			"id":  id,
			"A": map[string]interface{}{
				"id":          id,
				"sysUserId":   sysUserId,
				"sysUnitId":   sysUnitId,
				"resStruct":   resStruct,
				"createBy":    sysUserId,
				"createTime":  DateUtil{}.GetCurrentYyyyMMddHHmmss(),
				"createUnit":  sysUnitId,
				"modifyBy":    0,
				"modifyTime":  0,
				"modifyUnit":  0,
				"attachCount": 0,
				"remark":      "",
			},
		}
		txnManager.Insert(txnId, "LastSessionData", lastSessionData)
	} else {
		txnId := global.GetTxnId(sessionId)
		lastSessionDataMaster := lastSessionData["A"].(map[string]interface{})
		lastSessionData["A"] = lastSessionDataMaster

		lastSessionDataMaster["modifyBy"] = sysUserId
		lastSessionDataMaster["modifyTime"] = DateUtil{}.GetCurrentYyyyMMddHHmmss()
		lastSessionDataMaster["modifyBy"] = sysUnitId

		_, updateResult := txnManager.Update(txnId, "LastSessionData", lastSessionData)
		if !updateResult {
			panic(BusinessError{Message: "更新LastSessionData失败"})
		}
	}
}
Esempio n. 9
0
func (c BankAccountSupport) RAfterDeleteData(sessionId int, dataSource DataSource, formTemplate FormTemplate, bo *map[string]interface{}) {
	// 直接删除,整个删除 账户币别中的数据
	bankAccountMasterData := (*bo)["A"].(map[string]interface{})
	_, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	query := map[string]interface{}{
		"A.bankAccountId": bankAccountMasterData["id"],
	}
	collectionName := "BankAccountCurrencyType"
	txnManager.RemoveAll(txnId, collectionName, query)
}
Esempio n. 10
0
/**
 * 现金帐户过帐,
 * @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: "现金账户更新失败"})
	}
}
Esempio n. 11
0
/**
初始化税率类别
*/
func (o StepService) InitTaxType(sessionId int, sysUser map[string]interface{}) {
	sysUserMaster := sysUser["A"].(map[string]interface{})
	txnId := global.GetTxnId(sessionId)
	session, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	qb := QuerySupport{}
	initDataLi := []map[string]interface{}{
		map[string]interface{}{
			"code": "VAT7", "name": "7%增值税扣除税率", "taxRate": 7, "isDeductTax": 2, "isDeduct": 2,
		},
		map[string]interface{}{
			"code": "VAT5", "name": "5%增值税", "taxRate": 5, "isDeductTax": 1, "isDeduct": 2,
		},
		map[string]interface{}{
			"code": "VAT17", "name": "17%增值税", "taxRate": 17, "isDeductTax": 1, "isDeduct": 2,
		},
	}
	for _, initData := range initDataLi {
		_, found := qb.FindByMapWithSession(session, "TaxType", map[string]interface{}{
			"A.code":       initData["code"],
			"A.createUnit": sysUserMaster["createUnit"],
		})
		if !found {
			id := mongo.GetSequenceNo(db, "taxTypeId")
			aData := map[string]interface{}{
				"id":          id,
				"createBy":    sysUserMaster["id"],
				"createTime":  DateUtil{}.GetCurrentYyyyMMddHHmmss(),
				"createUnit":  sysUserMaster["createUnit"],
				"modifyBy":    0,
				"modifyTime":  0,
				"modifyUnit":  0,
				"billStatus":  0,
				"attachCount": 0,
				"remark":      "",
			}
			for k, v := range initData {
				aData[k] = v
			}
			data := map[string]interface{}{
				"_id": id,
				"id":  id,
				"A":   aData,
			}
			txnManager.Insert(txnId, "TaxType", data)
		}
	}
}
Esempio n. 12
0
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)
}
Esempio n. 13
0
/**
初始化币别
*/
func (o StepService) InitCurrencyType(sessionId int, sysUser map[string]interface{}) {
	sysUserMaster := sysUser["A"].(map[string]interface{})
	txnId := global.GetTxnId(sessionId)
	session, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	qb := QuerySupport{}
	initDataLi := []map[string]interface{}{
		map[string]interface{}{
			"code":             "RMB",
			"name":             "人民币",
			"currencyTypeSign": "",
			"roundingWay":      2, // 四舍五入
			"amtDecimals":      3, // 3代表2位小数
			"upDecimals":       3, // 3代表2位小数
		},
	}
	for _, initData := range initDataLi {
		_, found := qb.FindByMapWithSession(session, "CurrencyType", map[string]interface{}{
			"A.code":       initData["code"],
			"A.createUnit": sysUserMaster["createUnit"],
		})
		if !found {
			id := mongo.GetSequenceNo(db, "currencyTypeId")
			aData := map[string]interface{}{
				"id":          id,
				"createBy":    sysUserMaster["id"],
				"createTime":  DateUtil{}.GetCurrentYyyyMMddHHmmss(),
				"createUnit":  sysUserMaster["createUnit"],
				"modifyBy":    0,
				"modifyTime":  0,
				"modifyUnit":  0,
				"billStatus":  0,
				"attachCount": 0,
				"remark":      "",
			}
			for k, v := range initData {
				aData[k] = v
			}
			data := map[string]interface{}{
				"_id": id,
				"id":  id,
				"A":   aData,
			}
			txnManager.Insert(txnId, "CurrencyType", data)
		}
	}
}
Esempio n. 14
0
/**
初始化付款单类型参数
*/
func (o StepService) InitBillPaymentTypeParameter(sessionId int, sysUser map[string]interface{}) {
	sysUserMaster := sysUser["A"].(map[string]interface{})
	txnId := global.GetTxnId(sessionId)
	session, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	qb := QuerySupport{}
	initDataLi := []map[string]interface{}{
		map[string]interface{}{
			"billTypeId": 2,
			"property":   2,
		},
	}
	for _, initData := range initDataLi {
		_, found := qb.FindByMapWithSession(session, "BillTypeParameter", map[string]interface{}{
			"A.billTypeId": initData["billTypeId"],
			"A.createUnit": sysUserMaster["createUnit"],
		})
		if !found {
			id := mongo.GetSequenceNo(db, "billTypeParameterId")
			aData := map[string]interface{}{
				"id":          id,
				"createBy":    sysUserMaster["id"],
				"createTime":  DateUtil{}.GetCurrentYyyyMMddHHmmss(),
				"createUnit":  sysUserMaster["createUnit"],
				"modifyBy":    0,
				"modifyTime":  0,
				"modifyUnit":  0,
				"billStatus":  0,
				"attachCount": 0,
				"remark":      "",
			}
			for k, v := range initData {
				aData[k] = v
			}
			data := map[string]interface{}{
				"_id": id,
				"id":  id,
				"A":   aData,
			}
			txnManager.Insert(txnId, "BillTypeParameter", data)
		}
	}
}
Esempio n. 15
0
/**
* 添加日记账明细
 */
func (o AccountInOutService) addCashBankDailyInOut(sessionId int, accountInOutItemParam AccountInOutItemParam) {
	_, db := global.GetConnection(sessionId)
	dataSourceModelId := "AccountInOutItem"
	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	masterSeqName := GetMasterSequenceName(dataSource)
	masterSeqId := GetSequenceNo(db, masterSeqName)
	accountInOutItem := accountInOutItemParam.ToMap()
	accountInOutItem["id"] = masterSeqId
	bo := map[string]interface{}{
		"_id": masterSeqId,
		"id":  masterSeqId,
		"A":   accountInOutItem,
	}
	modelTemplateFactory.ConvertDataType(dataSource, &bo)

	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	txnManager.Insert(txnId, collectionName, bo)
}
Esempio n. 16
0
func (c BbsPostSupport) bbsPostReplyAfterSaveData(sessionId int, dataSource DataSource, bo *map[string]interface{}, diffDateRowLi *[]DiffDataRow) {
	session, 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)
	}
	// 更新bbsPostId对应的主题帖的 lastReplyBy = self,lastReplyTime = currentTime,
	commonUtil := CommonUtil{}
	dateUtil := DateUtil{}
	master := (*bo)["A"].(map[string]interface{})
	qb := QuerySupport{}
	mainBbsPostQuery := map[string]interface{}{
		"_id": commonUtil.GetIntFromMap(master, "bbsPostId"),
	}
	bbsPostCollectionName := "BbsPost"
	mainBbsPost, found := qb.FindByMapWithSession(session, bbsPostCollectionName, mainBbsPostQuery)
	if !found {
		panic(BusinessError{Message: "主题帖未找到"})
	}
	mainBbsPostMaster := mainBbsPost["A"].(map[string]interface{})
	mainBbsPost["A"] = mainBbsPostMaster
	mainBbsPostMaster["lastReplyBy"] = userId
	mainBbsPostMaster["lastReplyTime"] = dateUtil.GetCurrentYyyyMMddHHmmss()
	if _, updateResult := txnManager.Update(txnId, bbsPostCollectionName, mainBbsPost); !updateResult {
		panic(BusinessError{Message: "主题帖更新失败"})
	}

	for _, item := range *diffDateRowLi {
		isNewOrUpdate := (item.SrcData != nil && item.DestData != nil) || (item.SrcData == nil && item.DestData != nil)
		if isNewOrUpdate {
			// 旧数据反过账,新数据正过账,修改后,更新 bbsPostId,readBy,bbsPostId
			bbsPostId := commonUtil.GetIntFromMap(*item.DestData, "bbsPostId")
			c.addOrUpdateBbsPostRead(sessionId, bbsPostId)
		}
	}
}
Esempio n. 17
0
/**
 * 银行帐户过帐,
 * @param sessionId
 * @param accountInOutParam 过帐参数对象
 */
func (o AccountInOutService) LogBankAccountInOut(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 := "BankAccount"
	querySupport := QuerySupport{}
	queryMap := map[string]interface{}{
		"_id":          accountInOutParam.AccountId,
		"A.createUnit": querySupport.GetCreateUnitByUserId(session, userId),
	}
	bankAccountBo, found := querySupport.FindByMapWithSession(session, collectionName, queryMap)
	if !found {
		queryMapByte, err := json.Marshal(&queryMap)
		if err != nil {
			panic(err)
		}
		panic(BusinessError{Message: "银行账户没找到,查询条件为:" + string(queryMapByte)})
	}
	currencyTypeId := accountInOutParam.CurrencyTypeId
	bDetailDataLi := bankAccountBo["B"].([]interface{})
	mathUtil := MathUtil{}
	commonUtil := CommonUtil{}
	isFound := false
	for i, item := range bDetailDataLi {
		bankAccountCurrencyType := item.(map[string]interface{})
		if fmt.Sprint(bankAccountCurrencyType["currencyTypeId"]) == fmt.Sprint(currencyTypeId) {
			amtOriginalCurrencyBalance := fmt.Sprint(bankAccountCurrencyType["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)
			}
			bankAccountCurrencyType["amtOriginalCurrencyBalance"] = commonUtil.GetFloatFormat(amtOriginalCurrencyBalance)
			bDetailDataLi[i] = bankAccountCurrencyType
			isFound = true
			break
		}
	}
	if !isFound {
		bankAccountMaster := bankAccountBo["A"].(map[string]interface{})
		panic(BusinessError{Message: "过账银行账户:" + fmt.Sprint(bankAccountMaster["name"]) + "未找到对应币别"})
	}

	bankAccountBo["B"] = bDetailDataLi
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	_, found = txnManager.Update(txnId, collectionName, bankAccountBo)
	if !found {
		panic(BusinessError{Message: "银行账户更新失败"})
	}
}
Esempio n. 18
0
func (o StepService) Run(sysUser map[string]interface{}) {
	sysUserManster := sysUser["A"].(map[string]interface{})
	sysUnitId := CommonUtil{}.GetIntFromMap(sysUserManster, "createUnit")
	// 加锁
	lockService := LockService{}
	unitLock := lockService.GetUnitLock(fmt.Sprint(sysUnitId))
	(*unitLock).Lock()
	defer (*unitLock).Unlock()

	sessionId := global.GetSessionId()
	defer global.CloseSession(sessionId)
	defer global.RollbackTxn(sessionId)

	txnId := global.GetTxnId(sessionId)
	_, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	stepLi := []map[string]interface{}{}
	err := db.C("SysStep").Find(map[string]interface{}{
		"A.sysUnitId": sysUnitId,
	}).Sort("A.type").All(&stepLi)
	if err != nil {
		panic(err)
	}

	for _, item := range stepLi {
		master := item["A"].(map[string]interface{})
		item["A"] = master

		status := fmt.Sprint(master["status"])
		if status == "1" { // 未开始
			stepType := fmt.Sprint(master["type"])
			if stepType == "3" { //初始化供应商类别
				o.InitProviderType(sessionId, sysUser)
			} else if stepType == "5" { //初始化币别
				o.InitCurrencyType(sessionId, sysUser)
			} else if stepType == "6" { //初始化银行资料
				o.InitBank(sessionId, sysUser)
			} else if stepType == "7" { //初始化计量单位
				o.InitMeasureUnit(sessionId, sysUser)
			} else if stepType == "9" { //初始化客户类别
				o.InitCustomerType(sessionId, sysUser)
			} else if stepType == "12" { //初始化税率类别
				o.InitTaxType(sessionId, sysUser)
			} else if stepType == "14" { //初始化收入费用类别
				o.InitIncomeType(sessionId, sysUser)
			} else if stepType == "15" { //初始化收入费用项目
				o.InitIncomeItem(sessionId, sysUser)
			} else if stepType == "16" { //初始化会计期
				o.InitAccountingPeriod(sessionId, sysUser)
			} else if stepType == "18" { //初始化收款单类型参数
				o.InitBillReceiveTypeParameter(sessionId, sysUser)
			} else if stepType == "19" { //初始化付款单类型参数
				o.InitBillPaymentTypeParameter(sessionId, sysUser)
			} else if stepType == "20" { //初始化系统参数
				o.InitSystemParameter(sessionId, sysUser)
			}
		}
		master["status"] = 2
		_, updateResult := txnManager.Update(txnId, "SysStep", item)
		if !updateResult {
			panic(BusinessError{Message: "更新SysStep" + fmt.Sprint(master["name"]) + "失败"})
		}
	}

	global.CommitTxn(sessionId)
}
Esempio n. 19
0
/**
初始化银行资料
*/
func (o StepService) InitBank(sessionId int, sysUser map[string]interface{}) {
	sysUserMaster := sysUser["A"].(map[string]interface{})
	txnId := global.GetTxnId(sessionId)
	session, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	qb := QuerySupport{}
	initDataLi := []map[string]interface{}{
		map[string]interface{}{
			"code": "BPOSZT", "name": "POS在途资金银行", "bankShort": "", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
		map[string]interface{}{
			"code": "B95599", "name": "中国农业银行", "bankShort": "", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
		map[string]interface{}{
			"code": "B95595", "name": "光大银行", "bankShort": "", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
		map[string]interface{}{
			"code": "B95588", "name": "中国工商银行", "bankShort": "", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
		map[string]interface{}{
			"code": "B95580", "name": "邮政储蓄", "bankShort": "", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
		map[string]interface{}{
			"code": "B95577", "name": "华夏银行", "bankShort": "", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
		map[string]interface{}{
			"code": "B95568", "name": "中国民生银行", "bankShort": "", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
		map[string]interface{}{
			"code": "B95566", "name": "中国银行", "bankShort": "中行", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
		map[string]interface{}{
			"code": "B95561", "name": "兴业银行", "bankShort": "兴业", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
		map[string]interface{}{
			"code": "B95559", "name": "交通银行", "bankShort": "", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
		map[string]interface{}{
			"code": "B95558", "name": "中信银行", "bankShort": "", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
		map[string]interface{}{
			"code": "B95555", "name": "招商银行", "bankShort": "招行", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
		map[string]interface{}{
			"code": "B95533", "name": "中国建设银行", "bankShort": "建行", "linkman": "", "bankUrl": "", "linkPhone": "", "cusPhone": "", "complainPhone": "", "bankAddress": "",
		},
	}
	for _, initData := range initDataLi {
		_, found := qb.FindByMapWithSession(session, "Bank", map[string]interface{}{
			"A.code":       initData["code"],
			"A.createUnit": sysUserMaster["createUnit"],
		})
		if !found {
			id := mongo.GetSequenceNo(db, "bankId")
			aData := map[string]interface{}{
				"id":          id,
				"createBy":    sysUserMaster["id"],
				"createTime":  DateUtil{}.GetCurrentYyyyMMddHHmmss(),
				"createUnit":  sysUserMaster["createUnit"],
				"modifyBy":    0,
				"modifyTime":  0,
				"modifyUnit":  0,
				"billStatus":  0,
				"attachCount": 0,
				"remark":      "",
			}
			for k, v := range initData {
				aData[k] = v
			}
			data := map[string]interface{}{
				"_id": id,
				"id":  id,
				"A":   aData,
			}
			txnManager.Insert(txnId, "Bank", data)
		}
	}
}
Esempio n. 20
0
func (o FinanceService) SaveData(sessionId int, dataSource DataSource, bo *map[string]interface{}) *[]DiffDataRow {
	modelTemplateFactory := ModelTemplateFactory{}

	strId := modelTemplateFactory.GetStrId(*bo)

	modelTemplateFactory.ConvertDataType(dataSource, bo)
	// 主数据集和分录数据校验
	message := o.validateBO(sessionId, dataSource, (*bo))
	if message != "" {
		panic(BusinessError{Message: message})
	}
	_, db := global.GetConnection(sessionId)

	modelIterator := ModelIterator{}
	var result interface{} = ""

	if strId == "" || strId == "0" {
		// 主数据集和分录id赋值,
		modelIterator.IterateAllFieldBo(dataSource, bo, &result, func(fieldGroup FieldGroup, data *map[string]interface{}, rowIndex int, result *interface{}) {
			o.setDataId(db, dataSource, &fieldGroup, bo, data)
		})
		// 被用过帐
		usedCheck := UsedCheck{}
		result = ""
		diffDataRowLi := []DiffDataRow{}
		modelIterator.IterateDataBo(dataSource, bo, &result, func(fieldGroupLi []FieldGroup, data *map[string]interface{}, rowIndex int, result *interface{}) {
			diffDataRowLi = append(diffDataRowLi, DiffDataRow{
				FieldGroupLi: fieldGroupLi,
				DestBo:       bo,
				DestData:     data,
				SrcData:      nil,
				SrcBo:        nil,
			})
		})
		for i, _ := range diffDataRowLi {
			fieldGroupLi := diffDataRowLi[i].FieldGroupLi
			data := diffDataRowLi[i].DestData
			usedCheck.Insert(sessionId, fieldGroupLi, bo, data)
		}
		o.deleteExtraField(dataSource, bo)
		txnManager := TxnManager{db}
		txnId := global.GetTxnId(sessionId)
		collectionName := modelTemplateFactory.GetCollectionName(dataSource)
		txnManager.Insert(txnId, collectionName, *bo)

		return &diffDataRowLi
	}
	id, err := strconv.Atoi(strId)
	if err != nil {
		panic(err)
	}
	srcBo := map[string]interface{}{}
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	err = db.C(collectionName).Find(map[string]interface{}{"_id": id}).One(&srcBo)
	if err != nil {
		panic(err)
	}

	modelTemplateFactory.ConvertDataType(dataSource, &srcBo)
	diffDataRowLi := []DiffDataRow{}
	modelIterator.IterateDiffBo(dataSource, bo, srcBo, &result, func(fieldGroupLi []FieldGroup, destData *map[string]interface{}, srcData map[string]interface{}, result *interface{}) {
		// 分录+id
		if destData != nil {
			dataStrId := fmt.Sprint((*destData)["id"])
			if dataStrId == "" || dataStrId == "0" {
				for i, _ := range fieldGroupLi {
					o.setDataId(db, dataSource, &fieldGroupLi[i], bo, destData)
				}
			}
		}
		diffDataRowLi = append(diffDataRowLi, DiffDataRow{
			FieldGroupLi: fieldGroupLi,
			DestBo:       bo,
			DestData:     destData,
			SrcData:      srcData,
			SrcBo:        srcBo,
		})
	})

	usedCheck := UsedCheck{}
	// 删除的分录行数据的被用判断
	for _, diffDataRow := range diffDataRowLi {
		if usedCheck.CheckDeleteDetailRecordUsed(sessionId, dataSource, *bo, diffDataRow) {
			panic(BusinessError{Message: "部分分录数据已被用,不可删除"})
		}
	}

	// 被用差异行处理
	for i, _ := range diffDataRowLi {
		fieldGroupLi := diffDataRowLi[i].FieldGroupLi
		destData := diffDataRowLi[i].DestData
		srcData := diffDataRowLi[i].SrcData
		usedCheck.Update(sessionId, fieldGroupLi, bo, destData, srcData)
	}
	o.deleteExtraField(dataSource, bo)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	//	txnManager.Update(txnId int, collection string, doc map[string]interface{}) (map[string]interface{}, bool) {
	if _, updateResult := txnManager.Update(txnId, collectionName, *bo); !updateResult {
		panic("更新失败")
	}
	return &diffDataRowLi
}
Esempio n. 21
0
func (c BankAccountSupport) logBankAccountCurrencyType(sessionId int, bankAccountDataSource DataSource, bankAccountBo map[string]interface{}, diffDataRow DiffDataRow, diffDataType int) {
	if diffDataType == BEFORE_UPDATE { // 不管
		return
	}

	var addData map[string]interface{}
	var deleteData map[string]interface{}
	var afterUpdateData map[string]interface{}
	if diffDataType == ADD {
		addData = *(diffDataRow.DestData)
	} else if diffDataType == AFTER_UPDATE {
		afterUpdateData = *(diffDataRow.DestData)
	} else if diffDataType == DELETE {
		deleteData = diffDataRow.SrcData
	}

	bankAccountMasterData := bankAccountBo["A"].(map[string]interface{})
	bo := map[string]interface{}{}
	collectionName := "BankAccountCurrencyType"
	session, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)

	if diffDataType == AFTER_UPDATE { // 重新获取一遍bo
		beforeUpdateData := diffDataRow.SrcData
		qb := QuerySupport{}
		query := map[string]interface{}{
			"A.bankAccountId":  bankAccountMasterData["id"],
			"A.currencyTypeId": beforeUpdateData["currencyTypeId"],
		}
		bankAccountCurrencyType, found := qb.FindByMapWithSession(session, collectionName, query)
		if found {
			bo = bankAccountCurrencyType
		} else {
			bo["A"] = map[string]interface{}{}
		}
	}
	if diffDataType == ADD {
		bo["A"] = map[string]interface{}{
			"code":             bankAccountMasterData["code"],
			"name":             bankAccountMasterData["name"],
			"bankAccountId":    bankAccountMasterData["id"],
			"bankId":           bankAccountMasterData["bankId"],
			"accountProperty":  bankAccountMasterData["accountProperty"],
			"currencyTypeId":   addData["currencyTypeId"],
			"bankAccountBId":   addData["id"],
			"amtSecureBalance": addData["amtSecureBalance"],
			"amtLimits":        addData["amtLimits"],
			// TODO 安全余额,限额
		}
	} else if diffDataType == AFTER_UPDATE {
		boMaster := bo["A"].(map[string]interface{})
		boMaster["code"] = bankAccountMasterData["code"]
		boMaster["name"] = bankAccountMasterData["name"]
		boMaster["bankAccountId"] = bankAccountMasterData["id"]
		boMaster["bankId"] = bankAccountMasterData["bankId"]
		boMaster["accountProperty"] = bankAccountMasterData["accountProperty"]
		boMaster["currencyTypeId"] = afterUpdateData["currencyTypeId"]
		boMaster["bankAccountBId"] = afterUpdateData["id"]
		boMaster["amtSecureBalance"] = afterUpdateData["amtSecureBalance"]
		boMaster["amtLimits"] = afterUpdateData["amtLimits"]
		// TODO 安全余额,限额
		bo["A"] = boMaster
	} else if diffDataType == BEFORE_UPDATE { // 不管

	} else if diffDataType == DELETE {
		// 直接delete,return
		query := map[string]interface{}{
			"A.bankAccountId":  bankAccountMasterData["id"],
			"A.currencyTypeId": deleteData["currencyTypeId"],
		}
		txnManager.RemoveAll(txnId, collectionName, query)
		return
	}

	modelTemplateFactory := ModelTemplateFactory{}
	dataSourceModelId := "BankAccountCurrencyType"
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	modelTemplateFactory.ConvertDataType(dataSource, &bo)
	strId := modelTemplateFactory.GetStrId(bo)
	bankAccountAction := BankAccount{}
	if strId == "" || strId == "0" {
		masterSeqName := GetCollectionSequenceName(collectionName)
		masterSeqId := GetSequenceNo(db, masterSeqName)
		bo["_id"] = masterSeqId
		bo["id"] = masterSeqId
		boMaster := bo["A"].(map[string]interface{})
		boMaster["id"] = masterSeqId
		bo["A"] = boMaster
		bankAccountAction.RSetCreateFixFieldValue(sessionId, dataSource, &bo)
	} else {
		bankAccountAction.RSetModifyFixFieldValue(sessionId, dataSource, &bo)
	}

	if diffDataType == ADD {
		txnManager.Insert(txnId, collectionName, bo)
	} else if diffDataType == AFTER_UPDATE {
		if strId == "" || strId == "0" {
			txnManager.Insert(txnId, collectionName, bo)
		} else {
			txnManager.Update(txnId, collectionName, bo)
		}
	} else if diffDataType == BEFORE_UPDATE { // 不管

	} else if diffDataType == DELETE { // 前一步骤已经return,不管

	}
}
Esempio n. 22
0
/**
@param url /asdfas/zasdfasdf/?param1=value1&param2=value2
*/
func (o LoginService) DealLogin(sessionId int, url string) (resStruct map[string]interface{}, userId int, isStep bool) {
	log.Print("receive top login request, url is:", url)
	isStep = false

	thirdOpenFactory := ThirdOpenFactory{}
	thirdOpen := thirdOpenFactory.GetThirdOpen()
	resStruct = thirdOpen.GetUserInfo(url)
	topParameter := resStruct["topParameter"].(map[string]interface{})

	username := fmt.Sprint(topParameter["visitor_id"])
	nick := fmt.Sprint(topParameter["visitor_nick"])
	appKey := fmt.Sprint(resStruct["app_key"])

	session, db := global.GetConnection(sessionId)
	qb := QuerySupport{}
	query := map[string]interface{}{
		"A.nick": nick,
	}
	sysUser, found := qb.FindByMapWithSession(session, "SysUser", query)
	lockKey := ""
	if found {
		sysUserMaster := sysUser["A"].(map[string]interface{})
		lockKey = fmt.Sprint(CommonUtil{}.GetIntFromMap(sysUserMaster, "createUnit"))
	} else {
		lockKey = fmt.Sprint(nick)
	}

	// 加锁
	lockService := LockService{}
	unitLock := lockService.GetUnitLock(lockKey)
	(*unitLock).Lock()
	defer (*unitLock).Unlock()

	//	isDeptFirst := false
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	commonUtil := CommonUtil{}
	if !found {
		taobaoShop := thirdOpen.GetShopInfo(resStruct)
		shoGetResponse := taobaoShop["shop_get_response"].(map[string]interface{})
		shop := shoGetResponse["shop"].(map[string]interface{})
		sid := fmt.Sprint(shop["sid"])
		userNick := fmt.Sprint(shop["nick"])
		unit, unitFound := qb.FindByMapWithSession(session, "SysUnit", map[string]interface{}{
			"A.sid": sid,
		})
		if !unitFound {
			//			isDeptFirst = true
			cid := fmt.Sprint(shop["cid"])
			title := fmt.Sprint(shop["title"])
			id := mongo.GetSequenceNo(db, "sysUnitId")
			unit = map[string]interface{}{
				"_id": id,
				"id":  id,
				"A": map[string]interface{}{
					"id":          id,
					"code":        sid,
					"name":        title,
					"sid":         sid,
					"cid":         cid,
					"userNick":    userNick,
					"createBy":    0,
					"createTime":  DateUtil{}.GetCurrentYyyyMMddHHmmss(),
					"createUnit":  id,
					"modifyBy":    0,
					"modifyTime":  0,
					"modifyUnit":  0,
					"attachCount": 0,
					"remark":      "",
				},
			}
			txnManager.Insert(txnId, "SysUnit", unit)
		} else {
			//			isDeptFirst = false
		}
		id := mongo.GetSequenceNo(db, "sysUserId")
		sysUser = map[string]interface{}{
			"_id": id,
			"id":  id,
			"A": map[string]interface{}{
				"id":          id,
				"code":        fmt.Sprint(username),
				"name":        username,
				"type":        2,
				"status":      1,
				"nick":        nick,
				"createBy":    id,
				"createTime":  DateUtil{}.GetCurrentYyyyMMddHHmmss(),
				"createUnit":  unit["id"],
				"modifyBy":    0,
				"modifyTime":  0,
				"modifyUnit":  0,
				"attachCount": 0,
				"remark":      "",
			},
		}
		txnManager.Insert(txnId, "SysUser", sysUser)
		unitA := unit["A"].(map[string]interface{})
		unit["A"] = unitA
		unitA["createBy"] = id
		unitId := commonUtil.GetIntFromMap(unit, "id")
		isStep = o.InitStep(sessionId, unitId, id, appKey)
	} else {
		//		println(sysUser)
		sysUserMaster := sysUser["A"].(map[string]interface{})
		unitId := sysUserMaster["createUnit"].(int)
		id := sysUserMaster["id"].(int)
		isStep = o.InitStep(sessionId, unitId, id, appKey)
	}
	// 处理子账号
	if topParameter["sub_taobao_user_nick"] != nil {
		nick := fmt.Sprint(topParameter["sub_taobao_user_nick"])
		query := map[string]interface{}{
			"A.nick": nick,
		}
		subSysUser, found := qb.FindByMapWithSession(session, "SysUser", query)
		if !found {
			id := mongo.GetSequenceNo(db, "sysUserId")
			sysUserMaster := sysUser["A"].(map[string]interface{})
			subSysUser = map[string]interface{}{
				"_id": id,
				"id":  id,
				"A": map[string]interface{}{
					"id":          id,
					"code":        fmt.Sprint(username),
					"name":        username,
					"type":        2,
					"status":      1,
					"nick":        nick,
					"createBy":    id,
					"createTime":  DateUtil{}.GetCurrentYyyyMMddHHmmss(),
					"createUnit":  sysUserMaster["createUnit"],
					"modifyBy":    0,
					"modifyTime":  0,
					"modifyUnit":  0,
					"attachCount": 0,
					"remark":      "",
				},
			}
			txnManager.Insert(txnId, "SysUser", subSysUser)
		}
		sysUser = subSysUser
	}
	//	c.CommitTxn(sessionId)
	userId = commonUtil.GetIntFromMap(sysUser, "id")
	if isStep {
		go StepService{}.Run(sysUser)
	}
	// sync data thread,暂时不用处理,
	sysUserMaster := sysUser["A"].(map[string]interface{})
	sysUnitId := commonUtil.GetIntFromMap(sysUserMaster, "createUnit")
	o.saveOrUpdateLastSessionData(sessionId, resStruct, sysUnitId, userId)
	return resStruct, userId, isStep
}
Esempio n. 23
0
func (o LoginService) InitStep(sessionId int, unitId int, userId int, appKey string) bool {
	session, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)

	isStep := false
	li := o.GetStepLi()
	stepTypeLi := o.GetStepTypeLi(appKey)
	stepCount, err := db.C("SysStep").Find(map[string]interface{}{
		"A.sysUnitId": unitId,
		"A.type": map[string]interface{}{
			"$in": stepTypeLi,
		},
	}).Count()
	if err != nil {
		panic(err)
	}
	if stepCount != len(stepTypeLi) {
		isStep = true
		stepLi := []interface{}{}
		for _, item := range li {
			itemLi := item.([]interface{})
			itemType := itemLi[1].(int)
			isIn := false
			for _, stepTypeItem := range stepTypeLi {
				if itemType == stepTypeItem {
					isIn = true
					break
				}
			}
			if isIn {
				stepLi = append(stepLi, item)
			}
		}
		qb := QuerySupport{}
		for _, item := range stepLi {
			itemLi := item.([]interface{})
			itemType := itemLi[1].(int)
			_, found := qb.FindByMapWithSession(session, "SysStep", map[string]interface{}{
				"A.sysUnitId": unitId,
				"A.type":      itemType,
			})
			if !found {
				id := mongo.GetSequenceNo(db, "sysStepId")
				txnManager.Insert(txnId, "SysStep", map[string]interface{}{
					"_id": id,
					"id":  id,
					"A": map[string]interface{}{
						"id":         id,
						"name":       itemLi[0].(string),
						"type":       itemType,
						"status":     1,
						"sysUserId":  userId,
						"sysUnitId":  unitId,
						"createBy":   userId,
						"createTime": DateUtil{}.GetCurrentYyyyMMddHHmmss(),
						"createUnit": unitId,
					},
				})
			}
		}
	}
	return isStep
}
Esempio n. 24
0
/**
初始化收入费用项目
*/
func (o StepService) InitIncomeItem(sessionId int, sysUser map[string]interface{}) {
	sysUserMaster := sysUser["A"].(map[string]interface{})
	txnId := global.GetTxnId(sessionId)
	session, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	qb := QuerySupport{}
	initDataLi := []map[string]interface{}{
		map[string]interface{}{
			"code": "SHYYSR", "name": "售后营业收入", "incomeTypeId": 1, "taxTypeId": 0, "measureUnitId": 0,
		},
		map[string]interface{}{
			"code": "LSZLSR", "name": "租赁收入(零售)", "incomeTypeId": 1, "taxTypeId": 0, "measureUnitId": 0,
		},
		map[string]interface{}{
			"code": "SCZC", "name": "非常规市场推广支持", "incomeTypeId": 1, "taxTypeId": 0, "measureUnitId": 0,
		},
		map[string]interface{}{
			"code": "FPSR", "name": "废品收入", "incomeTypeId": 1, "taxTypeId": 0, "measureUnitId": 0,
		},
		map[string]interface{}{
			"code": "HYF", "name": "会员费收入", "incomeTypeId": 1, "taxTypeId": 0, "measureUnitId": 0,
		},
		map[string]interface{}{
			"code": "GZZJ", "name": "固定资产折旧", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "ZXF", "name": "装修成本摊销", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "JBGZ", "name": "基本工资总额", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "SBF", "name": "公司承担社保", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "CDZJ", "name": "场地租金", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "SCF", "name": "市场投入", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "GZCZSY", "name": "固定资产处置损益", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "ZJCB", "name": "资金成本", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "PXF", "name": "职员培训费用", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "BGF", "name": "办公费", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "POS", "name": "POS手续费", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "YHSXF", "name": "其他银行手续费", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "JTF", "name": "公务交通费", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "CLF", "name": "差旅费", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "SDF", "name": "水电费", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "WLF", "name": "电信网络等费", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "XLF", "name": "设备及车修理费", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "FLF", "name": "福利费", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "WYF", "name": "物业费与公修金", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "BAF", "name": "保安费", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "ZLCB", "name": "租赁成本", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "AQFXJ", "name": "安全风险基金", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "JZZC", "name": "捐赠支出", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "YWZDF", "name": "业务招待费", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "YZF_SH", "name": "运杂费(售后专用)", "incomeTypeId": 2,
		},
		map[string]interface{}{
			"code": "YWTGF", "name": "业务推广费", "incomeTypeId": 1, "taxTypeId": 0, "measureUnitId": 0,
		},
		map[string]interface{}{
			"code": "SJ", "name": "税金", "incomeTypeId": 1, "taxTypeId": 0, "measureUnitId": 0,
		},
		map[string]interface{}{
			"code": "WXZR", "name": "维修折让", "incomeTypeId": 1, "taxTypeId": 0, "measureUnitId": 0,
		},
	}
	taxType1Query := map[string]interface{}{
		"A.code":       "IN10",
		"A.createUnit": sysUserMaster["createUnit"],
	}
	taxType1, found := qb.FindByMapWithSession(session, "IncomeType", taxType1Query)
	if !found {
		queryByte, err := json.MarshalIndent(&taxType1Query, "", "\t")
		if err != nil {
			panic(err)
		}
		panic(BusinessError{Message: "未找到收入费用类别,查询条件为:" + string(queryByte)})
	}
	taxType1Id := taxType1["id"]

	taxType2Query := map[string]interface{}{
		"A.code":       "EX10",
		"A.createUnit": sysUserMaster["createUnit"],
	}
	taxType2, found := qb.FindByMapWithSession(session, "IncomeType", taxType2Query)
	if !found {
		queryByte, err := json.MarshalIndent(&taxType2Query, "", "\t")
		if err != nil {
			panic(err)
		}
		panic(BusinessError{Message: "未找到收入费用类别,查询条件为:" + string(queryByte)})
	}
	taxType2Id := taxType2["id"]

	for _, initData := range initDataLi {
		_, found := qb.FindByMapWithSession(session, "IncomeItem", map[string]interface{}{
			"A.code":       initData["code"],
			"A.createUnit": sysUserMaster["createUnit"],
		})
		if !found {
			id := mongo.GetSequenceNo(db, "incomeItemId")
			aData := map[string]interface{}{
				"id":          id,
				"createBy":    sysUserMaster["id"],
				"createTime":  DateUtil{}.GetCurrentYyyyMMddHHmmss(),
				"createUnit":  sysUserMaster["createUnit"],
				"modifyBy":    0,
				"modifyTime":  0,
				"modifyUnit":  0,
				"billStatus":  0,
				"attachCount": 0,
				"remark":      "",
			}
			for k, v := range initData {
				if k == "incomeTypeId" && fmt.Sprint(v) == "1" {
					aData[k] = taxType1Id
				} else if k == "incomeTypeId" && fmt.Sprint(v) == "2" {
					aData[k] = taxType2Id
				} else {
					aData[k] = v
				}
			}
			data := map[string]interface{}{
				"_id": id,
				"id":  id,
				"A":   aData,
			}
			txnManager.Insert(txnId, "IncomeItem", data)
		}
	}
}
Esempio n. 25
0
/**
 * 现金月档过帐,
 * 1.月档记录不存在,则给其新增一条
 * 2.正反过帐
 * @param accountInOutParam	参数对象
 */
func (o AccountInOutService) logMonthInOut(sessionId int, accountInOutParam AccountInOutParam) {
	session, db := global.GetConnection(sessionId)
	// 参数中加入 currencyTypeId
	commonUtil := CommonUtil{}
	mathUtil := MathUtil{}
	amtIncrease := accountInOutParam.AmtIncrease
	amtReduce := accountInOutParam.AmtReduce

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

	qb := QuerySupport{}
	query := map[string]interface{}{
		"A.accountId":             accountInOutParam.AccountId,
		"A.currencyTypeId":        accountInOutParam.CurrencyTypeId,
		"A.accountType":           accountInOutParam.AccountType,
		"A.accountingPeriodYear":  accountInOutParam.AccountingPeriodYear,
		"A.accountingPeriodMonth": accountInOutParam.AccountingPeriodMonth,
		"A.createUnit":            qb.GetCreateUnitByUserId(session, userId),
	}

	dataSourceModelId := "AccountInOut"
	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)

	accountInOut, found := qb.FindByMapWithSession(session, collectionName, query)
	if !found {
		accountInOut = o.addFinAccountInOutForCash(sessionId, accountInOutParam)
	} else { // 设置modifyBy等字段
		masterData := accountInOut["A"].(map[string]interface{})
		masterData["modifyBy"] = accountInOutParam.ModifyBy
		masterData["modifyUnit"] = accountInOutParam.ModifyUnit
		masterData["modifyTime"] = accountInOutParam.ModifyTime
		accountInOut["A"] = masterData
	}

	masterData := accountInOut["A"].(map[string]interface{})
	accountInOut["A"] = masterData
	amtIncreaseInDb := fmt.Sprint(masterData["amtIncrease"])
	amtReduceInDb := fmt.Sprint(masterData["amtReduce"])

	increaseCountInDb := commonUtil.GetIntFromString(fmt.Sprint(masterData["increaseCount"]))
	reduceCountInDb := commonUtil.GetIntFromString(fmt.Sprint(masterData["reduceCount"]))

	if accountInOutParam.DiffDataType == ADD || accountInOutParam.DiffDataType == AFTER_UPDATE {
		amtIncreaseInDb = mathUtil.Add(amtIncreaseInDb, amtIncrease)
		amtReduceInDb = mathUtil.Add(amtReduceInDb, amtReduce)

		if commonUtil.GetFloat64FromString(amtIncrease) > 0 {
			increaseCountInDb += 1
		}
		if commonUtil.GetFloat64FromString(amtReduce) > 0 {
			reduceCountInDb += 1
		}
	} else {
		amtIncreaseInDb = mathUtil.Sub(amtIncreaseInDb, amtIncrease)
		amtReduceInDb = mathUtil.Sub(amtReduceInDb, amtReduce)

		if commonUtil.GetFloat64FromString(amtIncrease) > 0 {
			increaseCountInDb -= 1
		}
		if commonUtil.GetFloat64FromString(amtReduce) > 0 {
			reduceCountInDb -= 1
		}
	}
	masterData["amtIncrease"] = commonUtil.GetFloatFormat(amtIncreaseInDb)
	masterData["amtReduce"] = commonUtil.GetFloatFormat(amtReduceInDb)
	masterData["increaseCount"] = increaseCountInDb
	masterData["reduceCount"] = reduceCountInDb

	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	_, found = txnManager.Update(txnId, collectionName, accountInOut)
	if !found {
		panic(BusinessError{Message: "月档更新失败"})
	}
}
Esempio n. 26
0
/**
初始化会计期
*/
func (o StepService) InitAccountingPeriod(sessionId int, sysUser map[string]interface{}) {
	sysUserMaster := sysUser["A"].(map[string]interface{})
	txnId := global.GetTxnId(sessionId)
	session, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	qb := QuerySupport{}
	initDataLi := []map[string]interface{}{
		map[string]interface{}{
			"accountingYear": 2014, "numAccountingPeriod": 12,
		},
		map[string]interface{}{
			"accountingYear": 2015, "numAccountingPeriod": 12,
		},
		map[string]interface{}{
			"accountingYear": 2016, "numAccountingPeriod": 12,
		},
	}
	for _, initData := range initDataLi {
		_, found := qb.FindByMapWithSession(session, "AccountingPeriod", map[string]interface{}{
			"A.accountingYear": initData["accountingYear"],
			"A.createUnit":     sysUserMaster["createUnit"],
		})
		if !found {
			id := mongo.GetSequenceNo(db, "accountingPeriodId")
			aData := map[string]interface{}{
				"id":          id,
				"createBy":    sysUserMaster["id"],
				"createTime":  DateUtil{}.GetCurrentYyyyMMddHHmmss(),
				"createUnit":  sysUserMaster["createUnit"],
				"modifyBy":    0,
				"modifyTime":  0,
				"modifyUnit":  0,
				"billStatus":  0,
				"attachCount": 0,
				"remark":      "",
			}
			for k, v := range initData {
				aData[k] = v
			}
			data := map[string]interface{}{
				"_id": id,
				"id":  id,
				"A":   aData,
			}
			detailDataLi := []interface{}{}
			year := aData["accountingYear"].(int)
			for i := 0; i < aData["numAccountingPeriod"].(int); i++ {
				id := mongo.GetSequenceNo(db, "accountingPeriodId")
				data := map[string]interface{}{
					"createBy":    sysUserMaster["id"],
					"createTime":  DateUtil{}.GetCurrentYyyyMMddHHmmss(),
					"createUnit":  sysUserMaster["createUnit"],
					"modifyBy":    0,
					"modifyTime":  0,
					"modifyUnit":  0,
					"billStatus":  0,
					"attachCount": 0,
					"remark":      "",
				}
				data["id"] = id
				data["sequenceNo"] = i + 1
				numStr := fmt.Sprint(i + 1)
				if i+1 < 10 {
					numStr = "0" + numStr
				}
				startDateStr := fmt.Sprint(year) + numStr + "01"
				startDate, err := strconv.Atoi(startDateStr)
				if err != nil {
					panic(err)
				}
				data["startDate"] = startDate
				startTime, err := time.Parse("20060102", startDateStr)
				if err != nil {
					panic(err)
				}
				nextMonthTime := startTime.AddDate(0, 1, -1)
				data["endDate"], err = strconv.Atoi(nextMonthTime.Format("20060102"))
				if err != nil {
					panic(err)
				}
				detailDataLi = append(detailDataLi, data)
			}
			data["B"] = detailDataLi
			txnManager.Insert(txnId, "AccountingPeriod", data)
		}
	}
}
Esempio n. 27
0
func (c CashAccountInit) dealDelete(sessionId int, dataSource DataSource, formTemplate FormTemplate, queryData map[string]interface{}, nowIdLi []int) []map[string]interface{} {
	modelTemplateFactory := ModelTemplateFactory{}
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	_, db := global.GetConnection(sessionId)
	queryMap := map[string]interface{}{
		"_id": map[string]interface{}{
			"$nin": nowIdLi,
		},
		"A.accountType": 1,
	}
	permissionSupport := PermissionSupport{}
	permissionQueryDict := permissionSupport.GetPermissionQueryDict(sessionId, formTemplate.Security)
	for k, v := range permissionQueryDict {
		queryMap[k] = v
	}

	strAccountId := fmt.Sprint(queryData["accountId"])
	if strAccountId != "" && strAccountId != "0" {
		accountIdLi := []int{}
		for _, item := range strings.Split(strAccountId, ",") {
			accountId, err := strconv.Atoi(item)
			if err != nil {
				panic(err)
			}
			accountIdLi = append(accountIdLi, accountId)
		}
		queryMap["A.accountId"] = map[string]interface{}{
			"$in": accountIdLi,
		}
	}
	queryMapByte, err := json.Marshal(&queryMap)
	if err != nil {
		panic(err)
	}
	log.Println("dealDelete,collectionName:" + collectionName + ", query:" + string(queryMapByte))
	toDeleteLi := []map[string]interface{}{}
	coll := db.C(collectionName)
	err = coll.Find(queryMap).All(&toDeleteLi)
	if err != nil {
		panic(err)
	}
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	modelIterator := ModelIterator{}
	usedCheck := UsedCheck{}
	for _, item := range toDeleteLi {
		if usedCheck.CheckUsed(sessionId, dataSource, item) {
			panic(BusinessError{Message: "已被用,不能删除"})
		}

		// 删除被用,帐户初始化不存在被用,不判断被用
		var result interface{} = ""
		modelIterator.IterateDataBo(dataSource, &item, &result, func(fieldGroupLi []FieldGroup, data *map[string]interface{}, rowIndex int, result *interface{}) {
			usedCheck.DeleteAll(sessionId, fieldGroupLi, *data)
		})

		c.RActionSupport.RBeforeDeleteData(sessionId, dataSource, formTemplate, &item)
		_, removeResult := txnManager.Remove(txnId, collectionName, item)
		if !removeResult {
			panic("删除失败")
		}
		c.RActionSupport.RAfterDeleteData(sessionId, dataSource, formTemplate, &item)
	}
	return toDeleteLi
}
Esempio n. 28
0
func (c BaseDataAction) RDeleteDataCommon() ModelRenderVO {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)
	defer c.RRollbackTxn(sessionId)

	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}

	dataSourceModelId := c.Params.Get("dataSourceModelId")
	formTemplateId := c.Params.Get("formTemplateId")
	strId := c.Params.Get("id")
	id, err := strconv.Atoi(strId)
	if err != nil {
		panic(err)
	}

	_, db := global.GetConnection(sessionId)
	querySupport := QuerySupport{}
	queryMap := map[string]interface{}{
		"_id": id,
	}
	formTemplate := FormTemplate{}
	if formTemplateId != "" {
		templateManager := TemplateManager{}
		formTemplate = templateManager.GetFormTemplate(formTemplateId)
	}
	permissionSupport := PermissionSupport{}
	permissionQueryDict := permissionSupport.GetPermissionQueryDict(sessionId, formTemplate.Security)
	for k, v := range permissionQueryDict {
		queryMap[k] = v
	}

	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	// 列表页也调用这个删除方法,但是列表页又没有传递formTemplateId,只有 gatheringBill等要做赤字判断,走与form相同的逻辑,才会传 formTemplateId,
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	bo, found := querySupport.FindByMap(collectionName, queryMap)
	if !found {
		panic("DeleteData, dataSouceModelId=" + dataSourceModelId + ", id=" + strId + " not found")
	}
	// 将客户端传入的各种参数写入,程序在业务方法before,after中有可能会用到
	c.setRequestParameterToBo(&bo)

	modelTemplateFactory.ConvertDataType(dataSource, &bo)
	c.RActionSupport.RBeforeDeleteData(sessionId, dataSource, formTemplate, &bo)

	usedCheck := UsedCheck{}
	if usedCheck.CheckUsed(sessionId, dataSource, bo) {
		panic(BusinessError{Message: "已被用,不能删除"})
	}

	modelIterator := ModelIterator{}
	var result interface{} = ""
	modelIterator.IterateDataBo(dataSource, &bo, &result, func(fieldGroupLi []FieldGroup, data *map[string]interface{}, rowIndex int, result *interface{}) {
		//		if fieldGroupLi[0].IsMasterField() {
		usedCheck.DeleteAll(sessionId, fieldGroupLi, *data)
		//		}
	})

	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	_, removeResult := txnManager.Remove(txnId, dataSourceModelId, bo)
	if !removeResult {
		panic("删除失败")
	}

	c.RActionSupport.RAfterDeleteData(sessionId, dataSource, formTemplate, &bo)

	// 列表页也调用这个删除方法,但是列表页又没有传递formTemplateId
	relationBo := map[string]interface{}{}
	if formTemplateId != "" {
		templateManager := TemplateManager{}
		columnModelData := templateManager.GetColumnModelDataForFormTemplate(sessionId, formTemplate, bo)
		bo = columnModelData["bo"].(map[string]interface{})
		relationBo = columnModelData["relationBo"].(map[string]interface{})
	}

	modelTemplateFactory.ClearReverseRelation(&dataSource)
	c.CommitTxn(sessionId)
	return ModelRenderVO{
		UserId:       userId,
		Bo:           bo,
		RelationBo:   relationBo,
		DataSource:   dataSource,
		FormTemplate: formTemplate,
	}
}
Esempio n. 29
0
func (c BillAction) RUnCancelDataCommon() ModelRenderVO {
	sessionId := global.GetSessionId()
	global.SetGlobalAttr(sessionId, "userId", c.Session["userId"])
	global.SetGlobalAttr(sessionId, "adminUserId", c.Session["adminUserId"])
	defer global.CloseSession(sessionId)
	defer c.RRollbackTxn(sessionId)

	userId, err := strconv.Atoi(c.Session["userId"])
	if err != nil {
		panic(err)
	}

	dataSourceModelId := c.Params.Get("dataSourceModelId")
	formTemplateId := c.Params.Get("formTemplateId")
	strId := c.Params.Get("id")
	id, err := strconv.Atoi(strId)
	if err != nil {
		panic(err)
	}
	querySupport := QuerySupport{}
	queryMap := map[string]interface{}{
		"_id": id,
	}
	templateManager := TemplateManager{}
	formTemplate := templateManager.GetFormTemplate(formTemplateId)
	permissionSupport := PermissionSupport{}
	permissionQueryDict := permissionSupport.GetPermissionQueryDict(sessionId, formTemplate.Security)
	for k, v := range permissionQueryDict {
		queryMap[k] = v
	}

	modelTemplateFactory := ModelTemplateFactory{}
	dataSource := modelTemplateFactory.GetDataSource(dataSourceModelId)
	collectionName := modelTemplateFactory.GetCollectionName(dataSource)
	bo, found := querySupport.FindByMap(collectionName, queryMap)
	if !found {
		panic("UnCancelData, dataSouceModelId=" + dataSourceModelId + ", id=" + strId + " not found")
	}

	c.setRequestParameterToBo(&bo)

	modelTemplateFactory.ConvertDataType(dataSource, &bo)
	c.RSetModifyFixFieldValue(sessionId, dataSource, &bo)
	c.RActionSupport.RBeforeUnCancelData(sessionId, dataSource, formTemplate, &bo)
	mainData := bo["A"].(map[string]interface{})
	if fmt.Sprint(mainData["billStatus"]) == "1" {
		panic(BusinessError{Message: "单据已经反作废,不可再次反作废"})
	}
	mainData["billStatus"] = 1

	_, db := global.GetConnection(sessionId)
	txnManager := TxnManager{db}
	txnId := global.GetTxnId(sessionId)
	_, updateResult := txnManager.Update(txnId, dataSourceModelId, bo)
	if !updateResult {
		panic("反作废失败")
	}

	c.RActionSupport.RAfterUnCancelData(sessionId, dataSource, formTemplate, &bo)

	bo, _ = querySupport.FindByMap(collectionName, queryMap)

	usedCheck := UsedCheck{}
	usedCheckBo := usedCheck.GetFormUsedCheck(sessionId, dataSource, bo)

	columnModelData := templateManager.GetColumnModelDataForFormTemplate(sessionId, formTemplate, bo)
	bo = columnModelData["bo"].(map[string]interface{})
	relationBo := columnModelData["relationBo"].(map[string]interface{})

	modelTemplateFactory.ClearReverseRelation(&dataSource)
	c.CommitTxn(sessionId)
	return ModelRenderVO{
		UserId:       userId,
		Bo:           bo,
		RelationBo:   relationBo,
		UsedCheckBo:  usedCheckBo,
		DataSource:   dataSource,
		FormTemplate: formTemplate,
	}
}