|
@@ -13,7 +13,6 @@ import (
|
|
|
"qfw/util"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
- "time"
|
|
|
|
|
|
"github.com/go-xweb/xweb"
|
|
|
"gopkg.in/mgo.v2/bson"
|
|
@@ -21,21 +20,15 @@ import (
|
|
|
|
|
|
type WxMyOrder struct {
|
|
|
*xweb.Action
|
|
|
- myMenu xweb.Mapper `xweb:"/front/wxMyOrder/myMenu"` //微信我的目录
|
|
|
- myEmail xweb.Mapper `xweb:"/front/wxMyOrder/myEmail"` //微信我的邮箱
|
|
|
- myOrder xweb.Mapper `xweb:"/front/wxMyOrder/myOrder"` //查询订单
|
|
|
- setSuccess xweb.Mapper `xweb:"/front/wxMyOrder/setSuccess"` //查询订单
|
|
|
-
|
|
|
- myOrderPaging xweb.Mapper `xweb:"/front/wxMyOrder/myOrder/myOrderPaging"` //查询订单--分页
|
|
|
+ myMenu xweb.Mapper `xweb:"/front/wxMyOrder/myMenu"` //微信我的目录
|
|
|
+ myEmail xweb.Mapper `xweb:"/front/wxMyOrder/myEmail"` //微信我的邮箱
|
|
|
+ setSuccess xweb.Mapper `xweb:"/front/wxMyOrder/setSuccess"` //查询订单
|
|
|
wxGetOrderCode xweb.Mapper `xweb:"/front/wxMyOrder/wxGetOrderCode/(\\w+)"` //申请发票获取订单编号
|
|
|
wxPaySuccess xweb.Mapper `xweb:"/front/wxMyorder/wxPaySuccess/(\\w+)"`
|
|
|
- wxDeleteOrder xweb.Mapper `xweb:"/front/wxMyorder/wxDeleteOrder"` //删除订单
|
|
|
- getOneMore xweb.Mapper `xweb:"/front/wxMyorder/getOneMore"` //获取额外一条数据
|
|
|
//需要调用微信支付接口的页面
|
|
|
- toMyWxOrder xweb.Mapper `xweb:"/weixin/pay/toMyWxOrder"` //微信我的订单
|
|
|
- wxToOrderDetail xweb.Mapper `xweb:"/weixin/pay/wxToOrderDetail"` //订单详情
|
|
|
- //测试
|
|
|
- testPay xweb.Mapper `xweb:"/weixin/pay/testPay"` //模拟去支付
|
|
|
+ toMyWxOrder xweb.Mapper `xweb:"/weixin/pay/toMyWxOrder"` //微信我的订单
|
|
|
+ wxToOrderDetail xweb.Mapper `xweb:"/weixin/pay/wxToOrderDetail"` //订单详情
|
|
|
+ getValuationList xweb.Mapper `xweb:"/front/wxMyOrder/getValuationList/(\\w+)"` //计价清单
|
|
|
}
|
|
|
|
|
|
func init() {
|
|
@@ -44,98 +37,8 @@ func init() {
|
|
|
|
|
|
var (
|
|
|
pagesize_max int = 10
|
|
|
-
|
|
|
-// haveNextPage bool = false
|
|
|
-// res []map[string]interface{}
|
|
|
)
|
|
|
|
|
|
-func (w *WxMyOrder) TestPay() error {
|
|
|
- userId := w.Session().Get("userId")
|
|
|
- order_code := w.GetString("orderCode")
|
|
|
- testBl := false
|
|
|
- queryMap := map[string]interface{}{}
|
|
|
- if userId != nil {
|
|
|
- queryMap["order_code"] = order_code
|
|
|
- queryMap["user_id"] = userId
|
|
|
- now := time.Now()
|
|
|
- testBl = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{
|
|
|
- "pay_money": 1 * 100,
|
|
|
- "order_status": 1,
|
|
|
- "pay_time": util.FormatDate(&now, util.Date_Full_Layout),
|
|
|
- "download_url": "download_url",
|
|
|
- "service_time": util.FormatDate(&now, util.Date_Full_Layout),
|
|
|
- })
|
|
|
- } else {
|
|
|
- log.Println("userid为空")
|
|
|
- }
|
|
|
- w.ServeJson(map[string]interface{}{
|
|
|
- "testBl": testBl,
|
|
|
- })
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
-//
|
|
|
-func (w *WxMyOrder) GetOneMore() error {
|
|
|
- defer util.Catch()
|
|
|
- pageNum, _ := w.GetInteger("pageNum")
|
|
|
- tabType := w.GetString("tabType")
|
|
|
- userId := w.Session().Get("userId")
|
|
|
- openid := w.Session().Get("s_m_openid")
|
|
|
- queryM := map[string]interface{}{}
|
|
|
- nextPage := false
|
|
|
- if userId == nil || openid == nil {
|
|
|
- return errors.New("未登录")
|
|
|
- } else {
|
|
|
- queryM["user_id"] = userId
|
|
|
- }
|
|
|
- var status string
|
|
|
- if tabType == "1" {
|
|
|
- status = orderStatus_unPaid
|
|
|
- } else if tabType == "2" {
|
|
|
- status = orderStatus_paid
|
|
|
- }
|
|
|
- queryM["order_status"] = status
|
|
|
-
|
|
|
- _, resData, _ := w.Datas(queryM, (pageNum - 1))
|
|
|
- //和取消支付不同 支付完成 获取最后一条订单 获取的是当前页面的最后一条 (不是下一页第一条
|
|
|
- if len(resData) > 0 {
|
|
|
- resData = resData[(len(resData) - 1):len(resData)]
|
|
|
- //用于删除订单后 判断新增的订单之后 是否有下一页
|
|
|
- nextPage = true
|
|
|
- }
|
|
|
-
|
|
|
- //start := (pageNum - 1) * pagesize_max
|
|
|
- //resData := *public.Mysql.Find(tableName_order, queryM, "id,order_code,filter_publishtime,create_time,data_spec,filter_id,filter_keys,order_money,data_count,order_status", "create_time desc", start, 1)
|
|
|
- if resData != nil {
|
|
|
- for _, v := range resData {
|
|
|
- filter_publishtime := v["filter_publishtime"]
|
|
|
- if filter_publishtime != nil || filter_publishtime != "" {
|
|
|
- timeArr := strings.Split(filter_publishtime.(string), "_")
|
|
|
- if len(timeArr) == 2 {
|
|
|
- start, err := strconv.ParseInt(timeArr[0], 10, 64)
|
|
|
- end, erro := strconv.ParseInt(timeArr[1], 10, 64)
|
|
|
- if err == nil && erro == nil {
|
|
|
- v["filter_publishtime"] = util.FormatDateByInt64(&start, layout_date) + "-" + util.FormatDateByInt64(&end, layout_date)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- v["filter_id"] = util.SE.Encode2Hex(v["filter_id"].(string))
|
|
|
- orderMoney := v["order_money"]
|
|
|
- if orderMoney != nil {
|
|
|
- v["order_money"] = float64(orderMoney.(int64)) / 100
|
|
|
- }
|
|
|
- if v["id"] != nil && orderMoney != nil && v["order_code"] != nil {
|
|
|
- v["token"] = public.GetWaitPayToken(v["id"].(int64), int(orderMoney.(int64)), v["order_code"].(string), v["pay_way"].(string), queryM["user_id"].(string))
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- w.ServeJson(map[string]interface{}{
|
|
|
- "res": resData,
|
|
|
- "nextPage": nextPage,
|
|
|
- })
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
//
|
|
|
func (w *WxMyOrder) MyMenu() error {
|
|
|
if w.Session().Get("userId") == nil {
|
|
@@ -290,122 +193,6 @@ func (w *WxMyOrder) ToMyWxOrder() error {
|
|
|
return w.Render("/weixin/dataExport/dataExport_toMyOrder.html", &w.T)
|
|
|
}
|
|
|
|
|
|
-func (w *WxMyOrder) MyOrder() error {
|
|
|
- //每页显示数
|
|
|
- userId := w.Session().Get("userId")
|
|
|
- openid := w.Session().Get("s_m_openid")
|
|
|
- queryM := map[string]interface{}{}
|
|
|
- if userId == nil || openid == nil {
|
|
|
- return errors.New("未登录")
|
|
|
- } else {
|
|
|
- queryM["user_id"] = userId
|
|
|
- }
|
|
|
- // 0全部 1未支付 2已支付
|
|
|
- typ := w.GetString("type")
|
|
|
- if typ != "0" && typ != "" {
|
|
|
- var status string
|
|
|
- if typ == "1" {
|
|
|
- status = orderStatus_unPaid
|
|
|
- } else if typ == "2" {
|
|
|
- status = orderStatus_paid
|
|
|
- } else if typ == "3" {
|
|
|
- status = orderStatus_cancel
|
|
|
- }
|
|
|
- queryM["order_status"] = status
|
|
|
- } else {
|
|
|
- queryM["order_status"] = map[string]interface{}{"ne": orderStatus_deleted}
|
|
|
- }
|
|
|
- //总数
|
|
|
- haveNextPage, res, _ := w.Datas(queryM, 1)
|
|
|
- count := len(res)
|
|
|
- if res != nil {
|
|
|
- for _, v := range res {
|
|
|
- filter_publishtime := v["filter_publishtime"]
|
|
|
- if filter_publishtime != nil || filter_publishtime != "" {
|
|
|
- timeArr := strings.Split(filter_publishtime.(string), "_")
|
|
|
- if len(timeArr) == 2 {
|
|
|
- start, err := strconv.ParseInt(timeArr[0], 10, 64)
|
|
|
- end, erro := strconv.ParseInt(timeArr[1], 10, 64)
|
|
|
- if err == nil && erro == nil {
|
|
|
- v["filter_publishtime"] = util.FormatDateByInt64(&start, layout_date) + "-" + util.FormatDateByInt64(&end, layout_date)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- v["filter_id"] = util.SE.Encode2Hex(v["filter_id"].(string))
|
|
|
- orderMoney := v["order_money"]
|
|
|
- if orderMoney != nil {
|
|
|
- v["order_money"] = float64(orderMoney.(int64)) / 100
|
|
|
- }
|
|
|
- if v["id"] != nil && orderMoney != nil && v["order_code"] != nil {
|
|
|
- v["token"] = public.GetWaitPayToken(v["id"].(int64), int(orderMoney.(int64)), v["order_code"].(string), v["pay_way"].(string), queryM["user_id"].(string))
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- w.ServeJson(map[string]interface{}{
|
|
|
- "res": res,
|
|
|
- "count": count,
|
|
|
- "pageSize": order_pageSize,
|
|
|
- "hasNextPage": haveNextPage,
|
|
|
- })
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
-func (w *WxMyOrder) MyOrderPaging() error {
|
|
|
- userId := w.Session().Get("userId")
|
|
|
- openid := w.Session().Get("s_m_openid")
|
|
|
- queryM := map[string]interface{}{}
|
|
|
- if userId == nil || openid == nil {
|
|
|
- return errors.New("未登录")
|
|
|
- } else {
|
|
|
- queryM["user_id"] = userId
|
|
|
- }
|
|
|
- // 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
|
|
|
- } else if typ == "3" {
|
|
|
- status = orderStatus_cancel
|
|
|
- }
|
|
|
- queryM["order_status"] = status
|
|
|
- } else {
|
|
|
- queryM["order_status"] = map[string]interface{}{"ne": orderStatus_deleted}
|
|
|
- }
|
|
|
- haveNextPage, res, _ := w.Datas(queryM, pageNum)
|
|
|
- if res != nil {
|
|
|
- for _, v := range res {
|
|
|
- filter_publishtime := v["filter_publishtime"]
|
|
|
- if filter_publishtime != nil || filter_publishtime != "" {
|
|
|
- timeArr := strings.Split(filter_publishtime.(string), "_")
|
|
|
- if len(timeArr) == 2 {
|
|
|
- start, err := strconv.ParseInt(timeArr[0], 10, 64)
|
|
|
- end, erro := strconv.ParseInt(timeArr[1], 10, 64)
|
|
|
- if err == nil && erro == nil {
|
|
|
- v["filter_publishtime"] = util.FormatDateByInt64(&start, layout_date) + "-" + util.FormatDateByInt64(&end, layout_date)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- v["filter_id"] = util.SE.Encode2Hex(v["filter_id"].(string))
|
|
|
- orderMoney := v["order_money"]
|
|
|
- if orderMoney != nil {
|
|
|
- v["order_money"] = float64(orderMoney.(int64)) / 100
|
|
|
- }
|
|
|
- if v["id"] != nil && orderMoney != nil && v["order_code"] != nil {
|
|
|
- v["token"] = public.GetWaitPayToken(v["id"].(int64), int(orderMoney.(int64)), v["order_code"].(string), v["pay_way"].(string), queryM["user_id"].(string))
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- w.ServeJson(map[string]interface{}{
|
|
|
- "hasNextPage": haveNextPage,
|
|
|
- "res": res,
|
|
|
- })
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
func (w *WxMyOrder) WxToOrderDetail() error {
|
|
|
myOpenid := ""
|
|
|
if openid := w.GetSession("s_m_openid"); openid != nil {
|
|
@@ -586,79 +373,10 @@ func (w *WxMyOrder) WxPaySuccess(order_code string) error {
|
|
|
return w.Render("/weixin/dataExport/dataExport_invoiceSuccess.html", &w.T)
|
|
|
}
|
|
|
|
|
|
-func (w *WxMyOrder) WxDeleteOrder() error {
|
|
|
- if userId := w.GetSession("userId"); userId != nil {
|
|
|
- queryMap := map[string]interface{}{
|
|
|
- "id": w.GetString("id"),
|
|
|
- "user_id": userId.(string),
|
|
|
- }
|
|
|
- queryM := map[string]interface{}{}
|
|
|
- queryM["user_id"] = userId
|
|
|
- nextPage := false
|
|
|
- // 0全部 1未支付 2已支付
|
|
|
- typ := w.GetString("type")
|
|
|
- cancel := w.GetString("cancel")
|
|
|
- pageNum, _ := w.GetInteger("pageNum")
|
|
|
- if typ != "0" && typ != "" {
|
|
|
- var status string
|
|
|
- if typ == "1" {
|
|
|
- status = orderStatus_unPaid
|
|
|
- } else if typ == "2" {
|
|
|
- status = orderStatus_paid
|
|
|
- } else if typ == "3" {
|
|
|
- status = orderStatus_cancel
|
|
|
- }
|
|
|
- queryM["order_status"] = status
|
|
|
- } else {
|
|
|
- queryM["order_status"] = map[string]interface{}{"ne": orderStatus_deleted}
|
|
|
- }
|
|
|
- haveNextPage, res, _ := w.Datas(queryM, pageNum)
|
|
|
- if len(res) > 0 {
|
|
|
- res = res[0:1]
|
|
|
- //用于删除订单后 判断新增的订单之后 是否有下一页
|
|
|
- nextPage = true
|
|
|
- }
|
|
|
- if res != nil {
|
|
|
- for _, v := range res {
|
|
|
- filter_publishtime := v["filter_publishtime"]
|
|
|
- if filter_publishtime != nil || filter_publishtime != "" {
|
|
|
- timeArr := strings.Split(filter_publishtime.(string), "_")
|
|
|
- if len(timeArr) == 2 {
|
|
|
- start, err := strconv.ParseInt(timeArr[0], 10, 64)
|
|
|
- end, erro := strconv.ParseInt(timeArr[1], 10, 64)
|
|
|
- if err == nil && erro == nil {
|
|
|
- v["filter_publishtime"] = util.FormatDateByInt64(&start, layout_date) + "-" + util.FormatDateByInt64(&end, layout_date)
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- v["filter_id"] = util.SE.Encode2Hex(v["filter_id"].(string))
|
|
|
- orderMoney := v["order_money"]
|
|
|
- if orderMoney != nil {
|
|
|
- v["order_money"] = float64(orderMoney.(int64)) / 100
|
|
|
- }
|
|
|
- if v["id"] != nil && orderMoney != nil && v["order_code"] != nil {
|
|
|
- v["token"] = public.GetWaitPayToken(v["id"].(int64), int(orderMoney.(int64)), v["order_code"].(string), v["pay_way"].(string), queryM["user_id"].(string))
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- var boo = false
|
|
|
- if cancel == "cancel" {
|
|
|
- //取消订单
|
|
|
- boo = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"order_status": -2})
|
|
|
- } else {
|
|
|
- //删除订单
|
|
|
- boo = public.Mysql.Update(tableName_order, queryMap, map[string]interface{}{"order_status": -1})
|
|
|
- }
|
|
|
- w.ServeJson(map[string]interface{}{
|
|
|
- "success": boo,
|
|
|
- "res": res,
|
|
|
- "hasNextPage": haveNextPage,
|
|
|
- "nextPage": nextPage,
|
|
|
- })
|
|
|
- }
|
|
|
- return nil
|
|
|
+func (w *WxMyOrder) GetValuationList(order_code string) error {
|
|
|
+ w.T["order_code"] = order_code
|
|
|
+ return w.Render("/weixin/vipsubscribe/valuation_list.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, "id,order_code,filter_publishtime,create_time,data_spec,filter_id,filter_keys,order_money,data_count,order_status,pay_way", "create_time desc", -1, 0)
|
|
|
if len(res) > 0 {
|