abiao лет назад: 5
Родитель
Сommit
cbb81d7916

+ 21 - 12
go/gopath/src/fohow.com/apps/controllers/railsadmin_controller/user_perfomance_controller.go

@@ -44,11 +44,11 @@ func (self *RailsadminController) UserPerfomance() {
 
 	//统计团队业绩
 	inviteList := user_model.GetWxUsersByInviteIdAll(wxUserId, true)
-	orderPerfomance, shopOrderPerfomance, shopPerfomance, balanceOrderPerfomance = GetTeamPerfomance(inviteList, orderPerfomance, shopOrderPerfomance, shopPerfomance, balanceOrderPerfomance, beginTime, endTime)
-	userSummary.OrderPerfomance = orderPerfomance
-	userSummary.ShopOrderPerfomance = shopOrderPerfomance
-	userSummary.ShopPerfomance = shopPerfomance
-	userSummary.BalancePerfomance = balanceOrderPerfomance
+	inviteOrderPerfomance, inviteShopOrderPerfomance, inviteShopPerfomance, inviteBalanceOrderPerfomance := GetTeamPerfomance(inviteList, beginTime, endTime)
+	userSummary.OrderPerfomance = orderPerfomance + inviteOrderPerfomance
+	userSummary.ShopOrderPerfomance = shopOrderPerfomance + inviteShopOrderPerfomance
+	userSummary.ShopPerfomance = shopPerfomance + inviteShopPerfomance
+	userSummary.BalancePerfomance = balanceOrderPerfomance + inviteBalanceOrderPerfomance
 	userSummary.Total = orderPerfomance + shopOrderPerfomance + shopPerfomance + balanceOrderPerfomance
 
 	userSummary.Save()
@@ -57,17 +57,26 @@ func (self *RailsadminController) UserPerfomance() {
 	self.ServeJSON()
 }
 
-func GetTeamPerfomance(list []*user_model.WxUser, orderPerfomance, shopOrderPerfomance, shopPerfomance, balanceOrderPerfomance, beginTime, endTime int64) (OrderPerfomance, ShopOrderPerfomance, ShopPerfomance, BalanceOrderPerfomance int64) {
-
+func GetTeamPerfomance(list []*user_model.WxUser, beginTime, endTime int64) (OrderPerfomance, ShopOrderPerfomance, ShopPerfomance, BalanceOrderPerfomance int64) {
+	orderPerfomance := int64(0)
+	shopOrderPerfomance := int64(0)
+	shopPerfomance := int64(0)
+	balanceOrderPerfomance := int64(0)
 	//递归获取
 	for _, item := range list {
-		orderPerfomance += summary_model.GetSumOrderPerfomance(item.Id, int64(0), beginTime, endTime)
-		shopOrderPerfomance += summary_model.GetSumOrderPerfomance(item.Id, int64(2), beginTime, endTime)
-		shopPerfomance += summary_model.GetSumShopPerfomance(item.Id, beginTime, endTime)
-		balanceOrderPerfomance += summary_model.GetSumOrderPerfomance(item.Id, int64(0), beginTime, endTime)
+		orderPerfomance = summary_model.GetSumOrderPerfomance(item.Id, int64(0), beginTime, endTime)
+		shopOrderPerfomance = summary_model.GetSumOrderPerfomance(item.Id, int64(2), beginTime, endTime)
+		shopPerfomance = summary_model.GetSumShopPerfomance(item.Id, beginTime, endTime)
+		balanceOrderPerfomance = summary_model.GetSumOrderPerfomance(item.Id, int64(0), beginTime, endTime)
 
 		secondList := user_model.GetWxUsersByInviteIdAll(item.Id, false)
-		GetTeamPerfomance(secondList, orderPerfomance, shopOrderPerfomance, shopPerfomance, balanceOrderPerfomance, beginTime, endTime)
+		newOrderPerfomance, newShopOrderPerfomance, newShopPerfomance, newBalanceOrderPerfomance := GetTeamPerfomance(secondList, beginTime, endTime)
+
+		orderPerfomance += newOrderPerfomance
+		shopOrderPerfomance += newShopOrderPerfomance
+		shopPerfomance += newShopPerfomance
+		balanceOrderPerfomance += newBalanceOrderPerfomance
+
 	}
 	return orderPerfomance, shopOrderPerfomance, shopPerfomance, balanceOrderPerfomance
 }

+ 2 - 2
go/gopath/src/fohow.com/apps/models/summary_model/user_perfomance.go

@@ -70,12 +70,12 @@ func GetSumOrderPerfomance(wxUserId, orderType, beginTime, endTime int64) int64
 	ret := &Ret{}
 	o := orm.NewOrm()
 	tbn := "orders"
-	sql := fmt.Sprintf("SELECT sum(`paied_price`-`freight`) as count FROM `%s` WHERE  paied_at > %d and paied_at< %d and  status in (?, ?, ?) and wx_user_id=? and order_type=?;", tbn, beginTime, endTime)
+	sql := fmt.Sprintf("SELECT sum(`paied_price`-`freight`) as count FROM `%s` WHERE  paied_at >%d and paied_at<%d and  status in (%s,%s,%s) and wx_user_id=%d and order_type=%d;", tbn, beginTime, endTime, order_model.STATUS_PROCESSING, order_model.STATUS_DISPATCH, order_model.STATUS_COMPLETE, wxUserId, orderType)
 	if orderType == int64(2) {
 		beego.BeeLogger.Warn("orders sql=[%s]", sql)
 	}
 
-	err := o.Raw(sql, order_model.STATUS_PROCESSING, order_model.STATUS_DISPATCH, order_model.STATUS_COMPLETE, wxUserId, orderType).QueryRow(ret)
+	err := o.Raw(sql).QueryRow(ret)
 	if err != nil {
 		beego.BeeLogger.Error("GetSumOrderPerfomance err=[%s]", err)
 		return 0