Browse Source

分支合并

lianbingjie 3 năm trước cách đây
mục cha
commit
a3c0073b0c

+ 8 - 4
src/config.json

@@ -35,13 +35,12 @@
   "noCheck": [
   "noCheck": [
     112,
     112,
     168,
     168,
-    169,
-    191
+    169
   ],
   ],
   "banTime": 86400,
   "banTime": 86400,
   "errSaveTime": 86400,
   "errSaveTime": 86400,
   "errTimes": 4,
   "errTimes": 4,
-  "jypayrpc": "127.0.0.1:8600",
+  "jypayrpc": "192.168.3.11:84",
   "uploadPath": "./web/staticres/file/",
   "uploadPath": "./web/staticres/file/",
   "companyIp": "1.192.60.,1.192.61.,1.192.62.,1.192.63.",
   "companyIp": "1.192.60.,1.192.61.,1.192.62.,1.192.63.",
   "weixinRpcServer": "192.168.3.11:8202",
   "weixinRpcServer": "192.168.3.11:8202",
@@ -109,5 +108,10 @@
     "address": "192.168.3.109:4000",
     "address": "192.168.3.109:4000",
     "dbName": "callCenter"
     "dbName": "callCenter"
   },
   },
-  "smsServiceRpc": "127.0.0.1:932"
+  "smsServiceRpc": "127.0.0.1:932",
+  "orderInterval": "0 0/1 * * * ? ",
+  "tokenInterval": "0 0 0/1 * * ? ",
+  "wxxdAppId": "wx68e590dcddf958be",
+  "wxxdSecret": "450a0500f139d3803a24575872b14e81",
+  "wxxdHost": "https://api.weixin.qq.com"
 }
 }

+ 10 - 5
src/config/config.go

@@ -46,13 +46,18 @@ type SysConfig struct {
 		Normal_discount float64 `json:"normal_discount"`
 		Normal_discount float64 `json:"normal_discount"`
 		Senior_discount float64 `json:"senior_discount"`
 		Senior_discount float64 `json:"senior_discount"`
 	} `json:"packs_showList"` //在售数据包列表
 	} `json:"packs_showList"` //在售数据包列表
-	UserIdMap      map[string]string      `json:"userIdMap"`
-	Etcd           []string               `json:"etcd"`
-	PushGrpcServer string                 `json:"pushGrpcServer"`
-	Tidb           string                 `json:"tidb"`
+	UserIdMap      map[string]string `json:"userIdMap"`
+	Etcd           []string          `json:"etcd"`
+	PushGrpcServer string            `json:"pushGrpcServer"`
+	Tidb           string            `json:"tidb"`
+	OrdreInterval  string            `json:"orderInterval"`
+	TokenInterval  string            `json:"tokenInterval"`
+	WxxdAppId      string            `json:"wxxdAppId"`
+	WxxdSecret     string            `json:"wxxdSecret"`
+	WxxdHost       string            `json:"wxxdHost"`
 	LookAllMsg     map[string]bool        `json:"lookAllMsg"`
 	LookAllMsg     map[string]bool        `json:"lookAllMsg"`
 	CusTidbMysql   map[string]interface{} `json:"cusTidbMysql"`
 	CusTidbMysql   map[string]interface{} `json:"cusTidbMysql"`
-	SmsServiceRpc  string                 `json:"smsServiceRpc"`
+	SmsServiceRpc  string            `json:"smsServiceRpc"`
 }
 }
 
 
 var SysConfigs SysConfig
 var SysConfigs SysConfig

+ 2 - 3
src/main.go

@@ -8,6 +8,7 @@ import (
 	"fmt"
 	"fmt"
 	"net/http"
 	"net/http"
 	_ "operateAnalysis"
 	_ "operateAnalysis"
+	"order"
 	_ "order"
 	_ "order"
 	"qfw/util/endless"
 	"qfw/util/endless"
 	_ "sales"
 	_ "sales"
@@ -26,7 +27,6 @@ import (
 
 
 func main() {
 func main() {
 	//task.InitTask()
 	//task.InitTask()
-
 	// [可选] 注册自定义调度器
 	// [可选] 注册自定义调度器
 	// admin.RegisterDispatch()
 	// admin.RegisterDispatch()
 	// [可选] 设置自定义密码生成器
 	// [可选] 设置自定义密码生成器
@@ -64,15 +64,14 @@ func main() {
 		}
 		}
 	})
 	})
 	http.HandleFunc("/static/", util.StaticServer)
 	http.HandleFunc("/static/", util.StaticServer)
-
 	http.HandleFunc("/filemanage/upload", func(writer http.ResponseWriter, request *http.Request) {
 	http.HandleFunc("/filemanage/upload", func(writer http.ResponseWriter, request *http.Request) {
 		util.Upload(writer, request)
 		util.Upload(writer, request)
 	})
 	})
 	fmt.Println(config.SysConfigs.WebPort)
 	fmt.Println(config.SysConfigs.WebPort)
 	task.InitTask()
 	task.InitTask()
+	order.ShopTask()
 	err := endless.ListenAndServe(config.SysConfigs.WebPort, nil, func() {})
 	err := endless.ListenAndServe(config.SysConfigs.WebPort, nil, func() {})
 	if err != nil {
 	if err != nil {
 		fmt.Println("Listen Server Error", err)
 		fmt.Println("Listen Server Error", err)
 	}
 	}
-	//task.InitTask()
 }
 }

+ 6 - 3
src/order/orderManageService.go

@@ -1014,10 +1014,13 @@ func CourseOrderDetails(res *map[string]interface{}, name string) map[string]int
 			}
 			}
 		}
 		}
 	} else {
 	} else {
-		payInfo := util.JysqlDB.FindOne(dataBase, payMap, "", "create_time desc")
-		if payInfo != nil {
-			(result)["transaction_id"] = (*payInfo)["transaction_id"]
+		if (*res)["out_trade_no"] != nil {
+			payInfo := util.JysqlDB.FindOne(dataBase, payMap, "", "create_time desc")
+			if payInfo != nil {
+				(result)["transaction_id"] = (*payInfo)["transaction_id"]
+			}
 		}
 		}
+
 	}
 	}
 	filter_id := qutil.ObjToString((*res)["filter_id"])
 	filter_id := qutil.ObjToString((*res)["filter_id"])
 	if strings.Contains(filter_id, "ABC") {
 	if strings.Contains(filter_id, "ABC") {

+ 6 - 0
src/order/otherOrderController.go

@@ -67,6 +67,12 @@ type CreateOtherOrderParams struct {
 	SalesChannel    string `form:"salesChannel"`    // 销售渠道
 	SalesChannel    string `form:"salesChannel"`    // 销售渠道
 	OrderChannel    string `form:"orderChannel"`    // 下单渠道
 	OrderChannel    string `form:"orderChannel"`    // 下单渠道
 	PaybackCompany  string `form:"paybackCompany"`  //签约主体  回款公司
 	PaybackCompany  string `form:"paybackCompany"`  //签约主体  回款公司
+	CourseId        string `form:"courseId"`        //课程标识
+	OrderCode       string `form:"orderCode"`       //
+	Transaction_id  string `form:"transaction_id"`  //
+	Pay_time        string `form:"pay_time"`        //
+	Pay_way         string `form:"pay_way"`         //
+	ReturnStatus    int    `form:"returnStatus"`    //
 }
 }
 type UpdateReturnParams struct {
 type UpdateReturnParams struct {
 	Id                  int       `form:"id"`                  //订单id
 	Id                  int       `form:"id"`                  //订单id

+ 106 - 6
src/order/otherOrderService.go

@@ -284,9 +284,7 @@ func createVipOrder(param *CreateOtherOrderParams, code string) (bool, string) {
 			buyArea[v] = []interface{}{}
 			buyArea[v] = []interface{}{}
 		}
 		}
 	}
 	}
-	//log.Println("省份", buyArea)
 	var endTime time.Time
 	var endTime time.Time
-	//log.Println(param.VipStartTime)
 	vipStartTime, _ := time.ParseInLocation(qutil.Date_Short_Layout, param.VipStartTime, time.Local)
 	vipStartTime, _ := time.ParseInLocation(qutil.Date_Short_Layout, param.VipStartTime, time.Local)
 	if param.VipType == 1 {
 	if param.VipType == 1 {
 		d, _ := time.ParseDuration("-24h")
 		d, _ := time.ParseDuration("-24h")
@@ -401,12 +399,16 @@ func createVipOrder(param *CreateOtherOrderParams, code string) (bool, string) {
 		}
 		}
 	}
 	}
 	//orderStatus := 1
 	//orderStatus := 1
-	payWay := ""
+	payWay := "wx_app"
 	returnStatus := 1
 	returnStatus := 1
 	if param.ChargeMode == 1 {
 	if param.ChargeMode == 1 {
-		//orderStatus = 0
 		returnStatus = 0
 		returnStatus = 0
-		payWay = "transferAccounts"
+		if param.Pay_way == "" {
+			payWay = "transferAccounts"
+		}
+	}
+	if param.ReturnStatus == 1 {
+		returnStatus = 1
 	}
 	}
 	if param.Badge != "" {
 	if param.Badge != "" {
 		payWay = ""
 		payWay = ""
@@ -434,6 +436,7 @@ func createVipOrder(param *CreateOtherOrderParams, code string) (bool, string) {
 			"order_status":       1,
 			"order_status":       1,
 			"user_id":            userId,
 			"user_id":            userId,
 			//"pay_time":           qutil.NowFormat(qutil.Date_Full_Layout),
 			//"pay_time":           qutil.NowFormat(qutil.Date_Full_Layout),
+			"out_trade_no":         code,
 			"return_status":        returnStatus,
 			"return_status":        returnStatus,
 			"refund_status":        0,
 			"refund_status":        0,
 			"company_name":         param.CompanyName,
 			"company_name":         param.CompanyName,
@@ -446,6 +449,9 @@ func createVipOrder(param *CreateOtherOrderParams, code string) (bool, string) {
 			"order_channel":        param.OrderChannel,
 			"order_channel":        param.OrderChannel,
 			"signing_subject":      param.PaybackCompany,
 			"signing_subject":      param.PaybackCompany,
 		}
 		}
+		if param.Pay_time != "" {
+			insertData["pay_time"] = param.Pay_time
+		}
 		if param.OrderMoney != 0 {
 		if param.OrderMoney != 0 {
 			insertData["order_money"] = param.OrderMoney
 			insertData["order_money"] = param.OrderMoney
 		}
 		}
@@ -464,7 +470,6 @@ func createVipOrder(param *CreateOtherOrderParams, code string) (bool, string) {
 			insertData["return_status"] = 1
 			insertData["return_status"] = 1
 			insertData["vip_type"] = 0
 			insertData["vip_type"] = 0
 		}
 		}
-
 		contractData := map[string]interface{}{
 		contractData := map[string]interface{}{
 			"order_code":        code,
 			"order_code":        code,
 			"customer_name":     param.CustomerName,
 			"customer_name":     param.CustomerName,
@@ -926,3 +931,98 @@ func SupplementaryOrder(res *map[string]interface{}) map[string]interface{} {
 	result["returnInfo"] = returnInfo
 	result["returnInfo"] = returnInfo
 	return result
 	return result
 }
 }
+
+//创建课程订单
+func createCourseOrder(param *CreateOtherOrderParams, code string) (bool, string) {
+	userData, ok := util.MQFW.FindOne("user", map[string]interface{}{"s_phone": param.Phone})
+	userId := ""
+	if ok && userData != nil && len(*userData) > 0 {
+		userId = mongodb.BsonIdToSId((*userData)["_id"])
+	} else {
+		userData, ok = util.MQFW.FindOne("user", map[string]interface{}{"s_m_phone": param.Phone})
+		if ok && userData != nil && len(*userData) > 0 {
+			userId = mongodb.BsonIdToSId((*userData)["_id"])
+		} else {
+			now := time.Now()
+			data := map[string]interface{}{
+				"i_appid":       2,
+				"s_phone":       param.Phone,
+				"s_password":    "",
+				"l_registedate": now.Unix(),
+				"i_ts_guide":    2,
+				"o_jy": map[string]interface{}{
+					"i_apppush":    1,
+					"i_ratemode":   2,
+					"l_modifydate": now.Unix(),
+				},
+				"s_regsource": "qmx_admin",
+			}
+			_id := util.MQFW.Save("user", data)
+			if _id != "" {
+				userId = _id
+			}
+		}
+	}
+	//订单创建
+	data, _ := util.MQFW.FindById("jy_course", param.CourseId, false)
+	price := qutil.IntAll((*data)["i_price"])
+	//生成订单号
+	detail := map[string]interface{}{
+		"_id":          param.CourseId,
+		"s_fileUrl":    (*data)["s_fileUrl"],
+		"s_picUrl":     (*data)["s_picUrl"],
+		"s_courseDate": (*data)["s_courseDate"],
+		"l_endtime":    (*data)["l_endtime"],
+		"i_price":      price,
+		"phone":        param.Phone,
+		"courseType":   "中标必听课",
+		"i_exist":      (*data)["i_exist"],
+		"i_num":        (*data)["i_num"],
+		"i_drawer":     (*data)["i_drawer"],
+		"s_name":       (*data)["s_name"], //此处传课程展示的信息;比如课程名称 结束时间 图片之类的("_id"课程mgo库id),
+	}
+	filterStr, _ := json.Marshal(detail)
+	payWay := "wx_app"
+	returnStatus := 1
+	if param.ChargeMode == 1 {
+		returnStatus = 0
+		if param.Pay_way == "" {
+			payWay = "transferAccounts"
+		}
+	}
+	if param.ReturnStatus == 1 {
+		returnStatus = 1
+	}
+	insertData := map[string]interface{}{
+		"user_phone":           param.Phone,
+		"product_type":         "中标必听课",
+		"salesperson":          "",
+		"filter":               string(filterStr),
+		"order_code":           code,
+		"original_price":       price,
+		"create_time":          param.CreateTime,                        // 订单补录需求20210926 该字段调整为存储订单时间 不再由系统生成
+		"entry_time":           qutil.NowFormat(qutil.Date_Full_Layout), //录入时间 订单补录需求20210926 增加 系统生成
+		"prepay_time":          param.CreateTime,
+		"order_money":          param.OrderMoney, // 2021-12-29 订单优化需求改为录入字段
+		"pay_money":            param.ContractMoney,
+		"is_backstage_order":   1,
+		"order_status":         1,
+		"out_trade_no":         code,
+		"pay_time":             param.Pay_time,
+		"user_id":              userId,
+		"return_status":        returnStatus,
+		"refund_status":        0,
+		"company_name":         param.CompanyName,
+		"billingMode":          param.ChargeMode, //计费模式 0 免费  1 收费
+		"sale_time":            param.CreateTime, // 订单补录需求20210926 补充需求 该字段取订单时间
+		"pay_way":              payWay,
+		"commission":           param.Commission,      // 佣金 2021-12-29 订单优化需求新增字段
+		"procedures_money":     param.ProceduresMoney, // 手续费 2021-12-29 订单优化需求新增字段
+		"distribution_channel": param.SalesChannel,
+		"order_channel":        param.OrderChannel,
+		"signing_subject":      param.PaybackCompany,
+		"filter_id":            param.CourseId,
+	}
+	ok_1 := util.JysqlDB.Insert("dataexport_order", insertData)
+	return ok_1 > 0, ""
+}

+ 297 - 0
src/order/smallShopTask.go

@@ -0,0 +1,297 @@
+package order
+
+import (
+	"config"
+	"encoding/json"
+	"fmt"
+	"github.com/cron"
+	"io/ioutil"
+	"log"
+	"mongodb"
+	"net/http"
+	qutil "qfw/util"
+	"qfw/util/redis"
+	"regexp"
+	"strings"
+	"time"
+	"util"
+)
+
+type wxToken struct {
+	ErrorCode    int    `json:"errcode,omitempty"`
+	ErrorMessage string `json:"errmsg,omitempty"`
+	AccessToken  string `json:"access_token"`
+	ExpiresIn    int64  `json:"expires_in"`
+	LastTime     int64  `json:"last_time"`
+}
+
+type wxxdOrder struct {
+	ErrorCode int `json:"errcode"`
+	Total_num int `json:"total_num"`
+	Orders    []struct {
+		Order_id     int    `json:"order_id"`
+		Status       int    `json:"status"`
+		Create_time  string `json:"create_time"`
+		Update_time  string `json:"update_time"`
+		Order_detail struct {
+			Product_infos []struct {
+				Title     string `json:"title"`
+				Sku_attrs []struct {
+					Attr_key   string `json:"attr_key"`
+					Attr_value string `json:"attr_value"`
+				} `json:"sku_attrs"`
+			} `json:"product_infos"`
+			Price_info struct {
+				Product_price    int  `json:"product_price"`
+				Order_price      int  `json:"order_price"`
+				Discounted_price int  `json:"discounted_price"`
+				Freight          int  `json:"freight"`
+				Is_discounted    bool `json:"is_discounted"`
+			} `json:"price_info"`
+			Couponcode_info struct {
+				Phone_number string `json:"phone_number"`
+			} `json:"couponcode_info"`
+			Pay_info struct {
+				Transaction_id string `json:"transaction_id"`
+				Pay_time       string `json:"pay_time"`
+			} `json:"pay_info"`
+		} `json:"order_detail"`
+	} `json:"orders"`
+}
+
+func ShopTask() {
+	go func() {
+		TokenHandle()
+		OrderHandle()
+		// 获取未执行的消息
+		c := cron.New()
+		c.AddFunc(config.SysConfigs.OrdreInterval, func() {
+			//订单处理
+			OrderHandle()
+		})
+		c.Start()
+		c2 := cron.New()
+		c2.AddFunc(config.SysConfigs.TokenInterval, func() {
+			//订单处理
+			TokenHandle()
+		})
+		c2.Start()
+	}()
+
+}
+func TokenHandle() string {
+	appid := config.SysConfigs.WxxdAppId
+	tokenKey := fmt.Sprintf("wxxdToken_%s", appid)
+	token := ""
+	resp, err := http.Get(config.SysConfigs.WxxdHost + "/cgi-bin/token?grant_type=client_credential&appid=" + config.SysConfigs.WxxdAppId + "&secret=" + config.SysConfigs.WxxdSecret)
+	if err != nil {
+		log.Println(config.SysConfigs.WxxdAppId, "Get access token error", err)
+	} else {
+		defer resp.Body.Close()
+		body, err := ioutil.ReadAll(resp.Body)
+		if err != nil {
+			log.Println(config.SysConfigs.WxxdAppId, "Read access token error", err)
+		} else {
+			var res wxToken
+			if err := json.Unmarshal(body, &res); err != nil {
+				log.Println(appid, "Parse access token error", err)
+			} else if res.ErrorCode != 0 {
+				log.Println(appid, "Reply access token error", res.ErrorCode, res.ErrorMessage)
+			} else if res.AccessToken != "" {
+				token = res.AccessToken
+				redis.Put("other", tokenKey, res.AccessToken, 3600)
+			}
+		}
+	}
+
+	return token
+}
+
+func OrderHandle() {
+	//拉取核销过得数据
+	//获取token
+	appid := config.SysConfigs.WxxdAppId
+	tokenKey := fmt.Sprintf("wxxdToken_%s", appid)
+	token := ""
+	if fool, _ := redis.Exists("other", tokenKey); fool {
+		//存在
+		token = qutil.ObjToString(redis.Get("other", tokenKey))
+	} else {
+		token = TokenHandle()
+	}
+	//拉取核销人数据
+	//获取最后一次拉数据时间 ,如果没有,以当天时间凌晨0点为准
+	//start_update_time := "2022-04-18 06:22:44"
+	start_update_time := ""
+	data := util.JysqlDB.SelectBySql("select  update_time from  wxxd_order  ORDER BY update_time  desc LIMIT 1")
+	if len((*data)) > 0 {
+		start_update_time = qutil.ObjToString((*data)[0]["update_time"])
+	} else {
+		t := time.Now()
+		addTime := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
+		start_update_time = addTime.Format(qutil.Date_Full_Layout)
+	}
+	client := &http.Client{}
+	log.Println(start_update_time)
+	var jsonData = strings.NewReader(`{ "start_update_time": "` + start_update_time + `", "end_update_time": "` + time.Now().Format(qutil.Date_Full_Layout) + `", "status":"100", "page": 1, "page_size": 50, "source": 1 //选填,默认1 } `)
+	req, err := http.NewRequest("POST", config.SysConfigs.WxxdHost+"/product/order/get_list?access_token="+token, jsonData)
+	if err != nil {
+		log.Fatal(err)
+	}
+	req.Header.Set("User-Agent", "Apipost client Runtime/+https://www.apipost.cn/")
+	req.Header.Set("Content-Type", "application/json")
+	resp, err := client.Do(req)
+	if err != nil {
+		log.Fatal(err)
+	}
+	bodyText, err := ioutil.ReadAll(resp.Body)
+	if err != nil {
+		log.Fatal(err)
+	}
+	var res wxxdOrder
+	if err := json.Unmarshal(bodyText, &res); err != nil {
+		log.Println(appid, "Parse access token error", err)
+	}
+	//循环处理一天数据
+	log.Println(res)
+	if res.Total_num > 0 {
+		for _, value := range res.Orders {
+			//先判断订单是否创建过
+			data := util.JysqlDB.CountBySql("select  count(id) from  wxxd_order   where   order_id=?", value.Order_id)
+			if data > 0 {
+				log.Println("此", value.Order_id, "订单核销创建过")
+				continue
+			}
+			/*if  value.Order_id!=3202692702381539840{
+				continue
+			}*/
+			orderStatus := false
+			code := fmt.Sprintf("%s%s", time.Now().Format("150405"), qutil.GetRandom(6))
+			param := &CreateOtherOrderParams{}
+			param.Phone = value.Order_detail.Couponcode_info.Phone_number
+			param.CourseId = value.Order_detail.Couponcode_info.Phone_number
+			param.ContractMoney = value.Order_detail.Price_info.Order_price
+			param.OrderMoney = param.ContractMoney
+			param.OrderMoney = value.Order_detail.Price_info.Product_price
+			param.ChargeMode = 1
+			param.ProceduresMoney = "0"
+			param.OrderChannel = "d03"
+			param.Commission = "0"
+			param.ReturnStatus = 1
+			param.SalesChannel = "x012"
+			param.PaybackCompany = "h01"
+			param.CreateTime = value.Create_time
+			param.Pay_time = value.Order_detail.Pay_info.Pay_time
+			param.Pay_way = "wx_app"
+			param.Transaction_id = value.Order_detail.Pay_info.Transaction_id
+			if strings.Index(value.Order_detail.Product_infos[0].Title, "超级订阅") >= 0 {
+				//超级订阅
+				param.ProductType = "VIP订阅"
+				//根据标题获取季度还是身份
+				titleArr := strings.Split(value.Order_detail.Product_infos[0].Title, " ")
+				if len(titleArr) == 0 {
+					continue
+				}
+				param.CycleUnit = 2
+				for _, skuValue := range value.Order_detail.Product_infos[0].Sku_attrs {
+					if skuValue.Attr_key == "月" {
+						rCharacter := regexp.MustCompile(`\d`)
+						numb := ""
+						for _, value := range rCharacter.FindAllStringSubmatch(skuValue.Attr_value, -1) {
+							numb += value[0]
+						}
+						param.CycleCount = qutil.IntAll(numb)
+					}
+					if titleArr[2] == "单省" {
+						if skuValue.Attr_key != "月" {
+							param.Area = skuValue.Attr_value
+						}
+
+					} else if titleArr[2] == "全国" {
+						param.Area = "全国"
+					}
+				}
+				param.VipStartTime, param.VipType = vipInfo(param.Phone)
+				orderStatus, _ = createVipOrder(param, code)
+			} else if strings.Index(value.Order_detail.Product_infos[0].Title, "剑鱼投标课") >= 0 {
+				//线上课程
+				//根据线上课程名称查找Id
+				data, _ := util.MQFW.FindOne("jy_course", map[string]interface{}{"s_name": value.Order_detail.Product_infos[0].Sku_attrs[0].Attr_value})
+				param.CourseId = mongodb.BsonIdToSId((*data)["_id"])
+				orderStatus, _ = createCourseOrder(param, code)
+			}
+			if orderStatus {
+				//插入一条回款记录
+				payInsertData := map[string]interface{}{
+					"transaction_id": value.Order_detail.Pay_info.Transaction_id,
+					"out_trade_no":   code,
+					"user_openid":    "",
+					"total_fee":      value.Order_detail.Price_info.Order_price,
+					"create_time":    value.Order_detail.Pay_info.Pay_time,
+					"cash_fee":       value.Order_detail.Price_info.Product_price,
+					"time_end":       value.Order_detail.Pay_info.Pay_time,
+					"user_id":        "",
+					"pay_channel":    1,
+				}
+				util.JysqlDB.Insert("weixin_pay", payInsertData)
+				//成功的话插入一条记录
+				insertData := map[string]interface{}{
+					"order_id":    value.Order_id,
+					"create_time": time.Now().Format(qutil.Date_Full_Layout),
+					"status":      value.Status,
+					"update_time": value.Update_time,
+					"order_code":  code,
+				}
+				util.JysqlDB.Insert("wxxd_order", insertData)
+				log.Println(value.Order_id, ":创建成功")
+			}
+		}
+	}
+}
+func vipInfo(phone string) (string, int) {
+	//查找之前是否开通超级订阅
+	vipStartTime := time.Now().Format(qutil.Date_Short_Layout)
+	vipType := 0
+	userData, ok := util.MQFW.FindOne("user", map[string]interface{}{"s_phone": phone})
+	userId := ""
+	if ok && userData != nil && len(*userData) > 0 {
+		userId = mongodb.BsonIdToSId((*userData)["_id"])
+	} else {
+		userData, ok = util.MQFW.FindOne("user", map[string]interface{}{"s_m_phone": phone})
+		if ok && userData != nil && len(*userData) > 0 {
+			userId = mongodb.BsonIdToSId((*userData)["_id"])
+		} else {
+			return vipStartTime, vipType
+		}
+	}
+	userInfo, oks := util.MQFW.FindOneByField("user", map[string]interface{}{"_id": mongodb.StringTOBsonId(userId)}, `{"_id":1,"i_vip_expire_tip":1,"i_vip_status":1,"l_vip_endtime":1,"l_vip_starttime":1,"o_vipjy":1,"s_m_phone":1,"s_phone":1}`)
+	if oks && userInfo != nil && len(*userInfo) > 0 {
+		//先判断用户是否有即将生效的超级订阅订单
+		query := map[string]interface{}{
+			"_id": mongodb.StringTOBsonId(userId),
+			"l_vip_starttime": map[string]interface{}{
+				"$gt": time.Now().Unix(),
+			},
+		}
+		count1 := util.MQFW.Count("user", query)
+		if count1 > 0 {
+			t := qutil.Int64All((*userInfo)["l_vip_endtime"])
+			_t := time.Unix(t, 0)
+			vipStartTime = (_t.AddDate(0, 0, 1)).Format(qutil.Date_Short_Layout)
+			vipType = 1
+		}
+		//查询是有是超级订阅的数据
+		//判断用户购买过超级订阅并且在有效期内   i_vip_status 开启状态:0-暂不使用vip订阅 1-试用 2-正式 -1-试用到期 -2-正式到期
+		userDatas, oks := util.MQFW.FindOneByField("user", map[string]interface{}{"_id": mongodb.StringTOBsonId(userId), "i_vip_status": 2}, `{"_id":1,"i_vip_expire_tip":1,"i_vip_status":1,"l_vip_endtime":1,"l_vip_starttime":1,"o_vipjy":1}`)
+		if oks && userDatas != nil && len(*userDatas) > 0 {
+			//正在生效的
+			if fmt.Sprint((*userInfo)["i_vip_status"]) == "2" {
+				t := qutil.Int64All((*userInfo)["l_vip_endtime"])
+				_t := time.Unix(t, 0)
+				vipStartTime = (_t.AddDate(0, 0, 1)).Format(qutil.Date_Short_Layout)
+				vipType = 1
+			}
+		}
+	}
+	return vipStartTime, vipType
+}