Sfoglia il codice sorgente

cent many table manage func

abiao 5 anni fa
parent
commit
a5a67ee973

+ 2 - 2
go/gopath/src/fohow.com/apps/logics/cent_logic.go

@@ -29,7 +29,7 @@ func OptEconomicCent(loginedWxUId, count int64) {
 		//centEconomic := &economic_model.CentEconomic{}
 		mainEconomic := economic_model.GetMainEconomicByWxUId(wxUser.Id, false)
 		if mainEconomic == nil {
-			mainEconomic = new(economic_model.MainEconomic).Create(wxUser.Id, count)
+			mainEconomic = new(economic_model.MainEconomic).Create(wxUser.Id, count, o)
 		} else {
 			mainEconomic.Cent += count
 			errE = mainEconomic.Save()
@@ -38,7 +38,7 @@ func OptEconomicCent(loginedWxUId, count int64) {
 		//更新经济明细表
 		s := cent_model.FIRST_LOGIN
 		remark := fmt.Sprintf("首次登录,赠送积分")
-		centEconomic := new(economic_model.CentEconomic).Create(wxUser.Id, count, s, s, remark)
+		centEconomic := new(economic_model.CentEconomic).Create(wxUser.Id, count, s, s, remark, o)
 
 		if mainEconomic == nil || errE != nil || centEconomic == nil {
 			beego.BeeLogger.Error("execute transaction's sql fail, rollback.", err)

+ 2 - 2
go/gopath/src/fohow.com/apps/models/economic_model/cent_economic.go

@@ -55,7 +55,7 @@ func (self *CentEconomic) GetTable(WxUserId int64) string {
 	return fmt.Sprintf("cent%d_balance", split)
 }
 
-func (self *CentEconomic) Create(wxUId, c int64, s, rId, remark string) (item *CentEconomic) {
+func (self *CentEconomic) Create(wxUId, c int64, s, rId, remark string, o orm.Ormer) (item *CentEconomic) {
 	item = &CentEconomic{
 		Count:    c,
 		WxUId:    wxUId,
@@ -66,7 +66,7 @@ func (self *CentEconomic) Create(wxUId, c int64, s, rId, remark string) (item *C
 	table := self.GetTable(wxUId)
 	sql := fmt.Sprintf("insert into %s(count,wx_uid,source,relate_id,remark)values(?,?,?,?,?)", table)
 
-	o := orm.NewOrm()
+	//o := orm.NewOrm()
 	result, err := o.Raw(sql, item.Count, item.WxUId, item.Source, item.RelateId, item.Remark).Exec()
 	if err != nil {
 		beego.BeeLogger.Debug("insert into cent economice with wxUId=%d, err=[%s]", wxUId, err)

+ 2 - 2
go/gopath/src/fohow.com/apps/models/economic_model/main_economic.go

@@ -27,12 +27,12 @@ func (self *MainEconomic) TableName() string {
 	return main_economics_tablename
 }
 
-func (self *MainEconomic) Create(wxUId, c int64) (item *MainEconomic) {
+func (self *MainEconomic) Create(wxUId, c int64, o orm.Ormer) (item *MainEconomic) {
 	item = &MainEconomic{
 		Cent:  c,
 		WxUId: wxUId,
 	}
-	id, err := orm.NewOrm().Insert(item)
+	id, err := o.Insert(item)
 	if err != nil {
 		beego.BeeLogger.Error("Create MainEconomic err=[%s]", err)
 		return nil