Example #1
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)
}
Example #2
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)
		}
	}
}
Example #3
0
func (c ResumeTest) SeqTest() revel.Result {
	//	db *mgo.Database, sequenceName string
	connectionFactory := mongo.GetInstance()
	session, db := connectionFactory.GetConnection()
	defer session.Close()
	sequenceName := "sysUserId"
	seq := mongo.GetSequenceNo(db, sequenceName)

	c.Response.ContentType = "text/plain; charset=utf-8"
	return c.RenderText(strconv.Itoa(seq))
}
Example #4
0
func (o FinanceService) setDataId(db *mgo.Database, dataSource DataSource, fieldGroup *FieldGroup, bo *map[string]interface{}, data *map[string]interface{}) {
	if fieldGroup.Id == "id" {
		if fieldGroup.IsMasterField() {
			masterSeqName := GetMasterSequenceName((dataSource))
			masterSeqId := mongo.GetSequenceNo(db, masterSeqName)
			//			(*data)["_id"] = masterSeqId
			(*data)["id"] = masterSeqId
			(*bo)["_id"] = masterSeqId
			(*bo)["id"] = masterSeqId
		} else {
			detailData, found := fieldGroup.GetDetailData()
			if found {
				detailSeqName := GetDetailSequenceName((dataSource), detailData)
				detailSeqId := mongo.GetSequenceNo(db, detailSeqName)
				//				(*data)["_id"] = detailSeqId
				(*data)["id"] = detailSeqId
			}
		}
	}
}
Example #5
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)
		}
	}
}
Example #6
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)
		}
	}
}
Example #7
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失败"})
		}
	}
}
Example #8
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)
		}
	}
}
Example #9
0
func (c Test) AddRemoveTestData() revel.Result {
	userIdLi := []int{10, 20}
	modelTemplateFactory := ModelTemplateFactory{}
	dataSourceInfoLi := modelTemplateFactory.GetDataSourceInfoLi()
	//	 GetCollectionName
	// 初始化数据只有 billType,BillTypeParameter,CurrencyType,
	connectionFactory := mongo.GetInstance()
	_, db := connectionFactory.GetConnection()
	modelIterator := ModelIterator{}
	for _, item := range dataSourceInfoLi {
		collectionName := modelTemplateFactory.GetCollectionName(item.DataSource)
		_, err := db.C(collectionName).RemoveAll(map[string]interface{}{})
		if err != nil {
			panic(err)
		}
		if collectionName == "BillType" || collectionName == "BillTypeParameter" || collectionName == "CurrencyType" {

		} else {
			for _, userId := range userIdLi {
				for i := 0; i < 25; i += 1 {
					masterData := map[string]interface{}{}
					bo := map[string]interface{}{
						"A": masterData,
					}
					var result interface{} = ""
					modelIterator.IterateAllField(&item.DataSource, &result, func(fieldGroup *FieldGroup, result *interface{}) {
						if fieldGroup.IsMasterField() {
							c.initData(userId, *fieldGroup, &masterData)
						} else {
							dataSetId := fieldGroup.GetDataSetId()
							if bo[dataSetId] == nil {
								bo[dataSetId] = []interface{}{}
							}
							dataSetDataLi := bo[dataSetId].([]interface{})
							bo[dataSetId] = dataSetDataLi

							if len(dataSetDataLi) == 0 {
								dataSetDataLi = append(dataSetDataLi, map[string]interface{}{})
							}
							dataSetData0 := dataSetDataLi[0].(map[string]interface{})
							dataSetDataLi[0] = dataSetData0

							c.initData(userId, *fieldGroup, &dataSetData0)
						}
					})
					collectionSequenceName := mongo.GetCollectionSequenceName(collectionName)
					id := mongo.GetSequenceNo(db, collectionSequenceName)
					bo["_id"] = id
					bo["id"] = id
					masterData["id"] = id
					masterData["createBy"] = userId
					masterData["createUnit"] = userId
					masterData["createTime"] = DateUtil{}.GetCurrentYyyyMMddHHmmss()
					masterData["modifyBy"] = userId
					masterData["modifyUnit"] = userId
					masterData["modifyTime"] = DateUtil{}.GetCurrentYyyyMMddHHmmss()
					modelIterator.IterateDataBo(item.DataSource, &bo, &result, func(fieldGroupLi []FieldGroup, data *map[string]interface{}, rowIndex int, result *interface{}) {
						if !fieldGroupLi[0].IsMasterField() {
							id := mongo.GetSequenceNo(db, collectionSequenceName)
							(*data)["id"] = id
							(*data)["createBy"] = userId
							(*data)["createUnit"] = userId
							(*data)["createTime"] = DateUtil{}.GetCurrentYyyyMMddHHmmss()
							(*data)["modifyBy"] = userId
							(*data)["modifyUnit"] = userId
							(*data)["modifyTime"] = DateUtil{}.GetCurrentYyyyMMddHHmmss()
						}
					})
					modelTemplateFactory.ConvertDataType(item.DataSource, &bo)
					db.C(collectionName).Insert(bo)
				}
			}
		}
	}
	return c.RenderText("success")
}
Example #10
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)
		}
	}
}
Example #11
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)
		}
	}
}
Example #12
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)
		}
	}
}
Example #13
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
}
Example #14
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
}