Przeglądaj źródła

显示时间调整-4

abiao 3 lat temu
rodzic
commit
f2ca4555b1

+ 18 - 0
go/gopath/src/fohow.com/apps/controllers/order_controller/order_controller.go

@@ -772,6 +772,24 @@ func (self *OrderController) DisrictList() {
 	self.ServeResultJSON()
 }
 
+//获取用户订单列表
+func (self *OrderController) DisrictSum() {
+
+	wxUId := self.GetCurrentWxUserIdByToken()
+	wxUser := user_model.GetWxUserById(wxUId, true)
+
+	if wxUser.Rank <= user_model.WX_USER_RANK_ONE || wxUser.TcBl <= 0 {
+		self.ReturnError(404, apps.WrongUserRank, "", nil)
+	}
+	count := order_model.GetDistrictOrderSum(wxUser.TcBl, wxUser.TcArea)
+
+	type Ret struct {
+		Sum int64 `json:"sum"`
+	}
+	self.Data["json"] = &Ret{Sum: count}
+	self.ServeResultJSON()
+}
+
 //用户更改订单状态
 func (self *OrderController) Operate() {
 	oId := self.Ctx.Input.Param(":order_id")

+ 45 - 0
go/gopath/src/fohow.com/apps/models/order_model/order.go

@@ -850,6 +850,51 @@ func GetDistrictOrdersCount(tcBl int64, tcArea string) int64 {
 	return ret.Count
 }
 
+func GetDistrictOrderSum(tcBl int64, tcArea string) int64 {
+
+	var areaSql, excuteSql string
+	excuteSql = fmt.Sprintf(" select sum(floor(dis_amount*%d/100)) as dis_amount  from orders where dis_amount>0 and  ", tcBl)
+
+	areaArr := helper.NewStr(tcArea).Explode(",")
+	//if len(areaArr) > 0 {
+	for key, ar := range areaArr {
+		if key == 0 {
+			areaSql = fmt.Sprintf("( address like %s", "'%"+ar+"%'")
+		} else {
+			areaSql = areaSql + fmt.Sprintf(" or address like %s", "'%"+ar+"%'")
+		}
+
+		if key == (len(areaArr) - 1) {
+			areaSql = areaSql + " )"
+		}
+	}
+	//}
+
+	excuteSql = excuteSql + areaSql
+
+	//pay支付时间
+	d := time.Now()
+	beginDay := helper.GetFirstDateOfMonth(d)
+	beginTime := beginDay.Unix()
+	endDay := helper.GetLastDateOfMonth(d)
+	endTime := endDay.Unix()
+
+	sql := excuteSql + fmt.Sprintf(" and  paied_at > %d and paied_at < %d and  status in ('processing','complete','dispatch') order by paied_at desc", beginTime, endTime)
+
+	type Ret struct {
+		Count int64 `json:"count"`
+	}
+
+	var ret Ret
+	err := orm.NewOrm().Raw(sql).QueryRow(&ret)
+
+	if err != nil {
+		return 0
+	}
+
+	return ret.Count
+}
+
 //根据用户快递单号和Tkey得到物流信息查询的密钥
 func GenExpressPassword(expressNo string) string {
 	md5CtxUsn := md5.New()

+ 1 - 0
go/gopath/src/fohow.com/routers/routes.go

@@ -116,6 +116,7 @@ func init() {
 
 	//区代订单列表
 	beego.Router("/v1/district/orders", &order_controller.OrderController{}, "get:DisrictList")
+	beego.Router("/v1/district/total", &order_controller.OrderController{}, "get:DisrictSum")
 
 	//订单详情
 	beego.Router("/v1/order/:order_id", &order_controller.OrderController{}, "get:Detail")