|
@@ -18,6 +18,7 @@ type WxMyOrder struct {
|
|
|
myMenu xweb.Mapper `xweb:"/front/wxMyOrder/myMenu"` //微信我的目录
|
|
|
toMyWxOrder xweb.Mapper `xweb:"/front/wxMyOrder/toMyWxOrder"` //微信我的订单
|
|
|
myOrder xweb.Mapper `xweb:"/front/wxMyOrder/myOrder"` //查询订单
|
|
|
+ myOrderPaging xweb.Mapper `xweb:"/front/wxMyOrder/myOrder/myOrderPaging"` //查询订单--分页
|
|
|
wxToOrderDetail xweb.Mapper `xweb:"/front/wxMyOrder/wxToOrderDetail/(.*)"` //订单详情
|
|
|
wxGetOrderCode xweb.Mapper `xweb:"/front/wxMyOrder/wxGetOrderCode/(\\w+)"` //申请发票获取订单编号
|
|
|
wxApplyInvoice xweb.Mapper `xweb:"/front/wxMyOrder/wxApplyInvoice"` //申请发票
|
|
@@ -28,6 +29,12 @@ func init() {
|
|
|
xweb.AddAction(&WxMyOrder{})
|
|
|
}
|
|
|
|
|
|
+var (
|
|
|
+ pagesize_max int = 10
|
|
|
+ haveNextPage bool = false
|
|
|
+ res []map[string]interface{}
|
|
|
+)
|
|
|
+
|
|
|
func (w *WxMyOrder) MyMenu() error {
|
|
|
if w.Session().Get("userId") == nil {
|
|
|
return w.Redirect("/swordfish/about")
|
|
@@ -41,8 +48,6 @@ func (w *WxMyOrder) ToMyWxOrder() error {
|
|
|
|
|
|
func (w *WxMyOrder) MyOrder() error {
|
|
|
//每页显示数
|
|
|
- pagesize_max := 10
|
|
|
- var haveNextPage bool
|
|
|
userId := w.Session().Get("userId")
|
|
|
openid := w.Session().Get("s_m_openid")
|
|
|
queryM := map[string]interface{}{}
|
|
@@ -65,18 +70,15 @@ func (w *WxMyOrder) MyOrder() error {
|
|
|
queryM["order_status"] = map[string]interface{}{"ne": orderStatus_deleted}
|
|
|
}
|
|
|
//
|
|
|
- res := public.Mysql.Find(tableName_order, queryM, "", "create_time desc", -1, 0)
|
|
|
+ //res := *public.Mysql.Find(tableName_order, queryM, "", "create_time desc", -1, 0)
|
|
|
log.Println("res:", res)
|
|
|
//总数
|
|
|
- count := len(*res)
|
|
|
- if count > pagesize_max {
|
|
|
- haveNextPage = true
|
|
|
- } else {
|
|
|
- haveNextPage = false
|
|
|
- }
|
|
|
- log.Println("count:", count)
|
|
|
+ haveNextPage, res, _ = w.Datas(queryM, 1)
|
|
|
+ log.Println(res)
|
|
|
+ count := len(res)
|
|
|
+ log.Println("count:", len(res))
|
|
|
if res != nil {
|
|
|
- for _, v := range *res {
|
|
|
+ for _, v := range res {
|
|
|
filter_publishtime := v["filter_publishtime"]
|
|
|
if filter_publishtime != nil || filter_publishtime != "" {
|
|
|
timeArr := strings.Split(filter_publishtime.(string), "_")
|
|
@@ -107,6 +109,38 @@ func (w *WxMyOrder) MyOrder() error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
+func (w *WxMyOrder) MyOrderPaging() error {
|
|
|
+ log.Println("@@@")
|
|
|
+ userId := w.Session().Get("userId")
|
|
|
+ openid := w.Session().Get("s_m_openid")
|
|
|
+ queryM := map[string]interface{}{}
|
|
|
+ if userId == nil || openid == nil {
|
|
|
+ return w.Redirect("/swordfish/share/-1")
|
|
|
+ } else {
|
|
|
+ queryM["user_openid"] = openid
|
|
|
+ }
|
|
|
+ // 0全部 1未支付 2已支付
|
|
|
+ typ := w.GetString("type")
|
|
|
+ pageNum, _ := w.GetInteger("pageNum")
|
|
|
+ if typ != "0" && typ != "" {
|
|
|
+ var status string
|
|
|
+ if typ == "1" {
|
|
|
+ status = orderStatus_unPaid
|
|
|
+ } else if typ == "2" {
|
|
|
+ status = orderStatus_paid
|
|
|
+ }
|
|
|
+ queryM["order_status"] = status
|
|
|
+ } else {
|
|
|
+ queryM["order_status"] = map[string]interface{}{"ne": orderStatus_deleted}
|
|
|
+ }
|
|
|
+ res, haveNextPage, _ := w.Datas(queryM, pageNum)
|
|
|
+ w.ServeJson(map[string]interface{}{
|
|
|
+ "haveNextPage": haveNextPage,
|
|
|
+ "res": res,
|
|
|
+ })
|
|
|
+ return nil
|
|
|
+}
|
|
|
+
|
|
|
func (w *WxMyOrder) WxToOrderDetail(orderCode string) error {
|
|
|
myOpenid := ""
|
|
|
if openid := w.GetSession("s_m_openid"); openid != nil {
|
|
@@ -245,3 +279,19 @@ func (w *WxMyOrder) WxPaySuccess(order_code string) error {
|
|
|
w.T["order_code"] = order_code
|
|
|
return w.Render("/weixin/dataExport/dataExport_invoiceSuccess.html", &w.T)
|
|
|
}
|
|
|
+
|
|
|
+func (w *WxMyOrder) Datas(queryM map[string]interface{}, pageNum int) (haveNextPage bool, result []map[string]interface{}, err error) {
|
|
|
+ res = *public.Mysql.Find(tableName_order, queryM, "", "create_time desc", -1, 0)
|
|
|
+ if len(res) > 0 {
|
|
|
+ start := (pageNum - 1) * pagesize_max
|
|
|
+ end := pageNum * pagesize_max
|
|
|
+ if end > len(res) {
|
|
|
+ end = len(res)
|
|
|
+ }
|
|
|
+ if start < len(res) {
|
|
|
+ result = res[start:end]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ haveNextPage = len(result) >= pagesize_max
|
|
|
+ return
|
|
|
+}
|