1.注释后台部分接口,后端接口使用另外一个服务;
2.修改回调通知接口,通知子渠道时,如果渠道信息有备注"add channel"则在通知的url添加参数channel,回传主渠道编码;
This commit is contained in:
parent
2f382db28d
commit
7f3ef982b0
|
@ -135,7 +135,7 @@ func (e MiGuDeployService) SubscribeNotice(c *gin.Context) {
|
||||||
if channelInfo.SubscribeURL != "" {
|
if channelInfo.SubscribeURL != "" {
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
resp, err := models.NoticeSubChannel(channelInfo.SubscribeURL, orderInfo.OrderSerial,
|
resp, err := models.NoticeSubChannel(channelInfo.SubscribeURL, orderInfo.OrderSerial,
|
||||||
orderInfo.ChannelTradeNo, "1")
|
orderInfo.ChannelTradeNo, "1", channelInfo.MainChannelCode, channelInfo.Remarks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("NoticeSubChannel err:", err)
|
fmt.Println("NoticeSubChannel err:", err)
|
||||||
fmt.Println("i is:", i)
|
fmt.Println("i is:", i)
|
||||||
|
@ -238,7 +238,7 @@ func (e MiGuDeployService) UnsubscribeNotice(c *gin.Context) {
|
||||||
if channelInfo.SubscribeURL != "" {
|
if channelInfo.SubscribeURL != "" {
|
||||||
for i := 0; i < 3; i++ {
|
for i := 0; i < 3; i++ {
|
||||||
resp, err := models.NoticeSubChannel(channelInfo.SubscribeURL, orderInfo.OrderSerial,
|
resp, err := models.NoticeSubChannel(channelInfo.SubscribeURL, orderInfo.OrderSerial,
|
||||||
orderInfo.ChannelTradeNo, "2")
|
orderInfo.ChannelTradeNo, "2", channelInfo.MainChannelCode, channelInfo.Remarks)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
@ -32,6 +33,8 @@ const (
|
||||||
UnsubscribeOK = 2 // 退订
|
UnsubscribeOK = 2 // 退订
|
||||||
|
|
||||||
SKUCODE = "miguyouxizuanshihuiyuan-yy"
|
SKUCODE = "miguyouxizuanshihuiyuan-yy"
|
||||||
|
|
||||||
|
AddRemark = "add channel"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 以下是数据库表结构
|
// 以下是数据库表结构
|
||||||
|
@ -704,7 +707,7 @@ func MiGuQueryRightsInfo(r *QueryRightsInfoReq) (QueryRightsInfoResp, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NoticeSubChannel 回调通知接口 (GET 请求,返回string类型,响应头为text/plain)
|
// NoticeSubChannel 回调通知接口 (GET 请求,返回string类型,响应头为text/plain)
|
||||||
func NoticeSubChannel(baseUrl, linkId, extData, status string) (string, error) {
|
func NoticeSubChannel(baseUrl, linkId, extData, status, mainChannelCode, remarks string) (string, error) {
|
||||||
// 构建 GET 请求的 URL
|
// 构建 GET 请求的 URL
|
||||||
requestUrl, err := url.Parse(baseUrl)
|
requestUrl, err := url.Parse(baseUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -716,6 +719,11 @@ func NoticeSubChannel(baseUrl, linkId, extData, status string) (string, error) {
|
||||||
query.Set("orderId", linkId)
|
query.Set("orderId", linkId)
|
||||||
query.Set("extData", extData)
|
query.Set("extData", extData)
|
||||||
query.Set("status", status)
|
query.Set("status", status)
|
||||||
|
|
||||||
|
if strings.Contains(remarks, AddRemark) {
|
||||||
|
query.Set("channel", mainChannelCode)
|
||||||
|
}
|
||||||
|
|
||||||
requestUrl.RawQuery = query.Encode()
|
requestUrl.RawQuery = query.Encode()
|
||||||
|
|
||||||
fmt.Println("NoticeSubChannel url:", requestUrl.String())
|
fmt.Println("NoticeSubChannel url:", requestUrl.String())
|
||||||
|
@ -980,70 +988,3 @@ func CheckOrderState() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckAllOrderState 定时任务,检查所有非1小时退订订单
|
|
||||||
func CheckAllOrderState() {
|
|
||||||
if database.Db == nil {
|
|
||||||
log.Println("Database connection is nil")
|
|
||||||
fmt.Println("Database connection is nil")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 查询订单列表中未退订的用户,查询其是否退订;如果退订,则更新退订时间,判断是否为1小时内退订
|
|
||||||
var orderList []MgOrder
|
|
||||||
|
|
||||||
err := database.Db.Where("is_one_hour_cancel != 1").Order("created_at desc").
|
|
||||||
Find(&orderList).Error
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("query mg_order err:", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
for i, _ := range orderList {
|
|
||||||
for j := 0; j < 3; j++ {
|
|
||||||
var req QueryRightsInfoReq
|
|
||||||
req.AppChannelList = append(req.AppChannelList, ChannelCode)
|
|
||||||
req.Mobile = orderList[i].PhoneNumber
|
|
||||||
|
|
||||||
resp, err := MiGuQueryRightsInfo(&req)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("CheckOrderState MiGuQueryRightsInfo err:", err.Error())
|
|
||||||
logger.Errorf("CheckOrderState MiGuQueryRightsInfo err:", err.Error())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
// 有退订数据
|
|
||||||
if len(resp.ResultData) != 0 {
|
|
||||||
if resp.ResultData[0].IsUnsub == 1 {
|
|
||||||
var cancelFlag int
|
|
||||||
subscribeTime := orderList[i].SubscribeTime
|
|
||||||
// 检查 subscribeTime 是否为 nil
|
|
||||||
if subscribeTime != nil && IsWithinOneHourCancel(*subscribeTime, resp.ResultData[0].UnsubTime) {
|
|
||||||
cancelFlag = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
err = database.Db.Table("mg_order").Where("order_serial = ?", orderList[i].OrderSerial).Updates(map[string]interface{}{
|
|
||||||
"state": UnsubscribeOK,
|
|
||||||
"is_one_hour_cancel": cancelFlag,
|
|
||||||
"unsubscribe_time": resp.ResultData[0].UnsubTime,
|
|
||||||
"updated_at": time.Now(),
|
|
||||||
}).Error
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("CheckOrderState update mg_order err:", err.Error())
|
|
||||||
logger.Errorf("CheckOrderState update mg_order err:", err.Error())
|
|
||||||
logger.Errorf("CheckOrderState order_serial:", orderList[i].OrderSerial)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if j == 2 {
|
|
||||||
fmt.Println("resp.ResultData is null, phone_number is:", req.Mobile)
|
|
||||||
logger.Errorf("resp.ResultData is null, phone_number is:", req.Mobile)
|
|
||||||
}
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
|
@ -8,27 +8,27 @@ import (
|
||||||
|
|
||||||
// registerMiGuControlManageRouter 需认证的路由代码
|
// registerMiGuControlManageRouter 需认证的路由代码
|
||||||
func registerMiGuControlManageRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
func registerMiGuControlManageRouter(v1 *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) {
|
||||||
apiMiGu := migumanage.MiGuDeployService{}
|
//apiMiGu := migumanage.MiGuDeployService{}
|
||||||
api := v1.Group("/admin")
|
//api := v1.Group("/admin")
|
||||||
{
|
//{
|
||||||
api.POST("product/list", apiMiGu.ProductList) // 查询权益产品
|
// api.POST("product/list", apiMiGu.ProductList) // 查询权益产品
|
||||||
api.POST("product/add", apiMiGu.AddProduct) // 新增产品
|
// api.POST("product/add", apiMiGu.AddProduct) // 新增产品
|
||||||
//api.POST("product/update", apiMiGu.UpdateProduct) // 编辑产品
|
// //api.POST("product/update", apiMiGu.UpdateProduct) // 编辑产品
|
||||||
//api.POST("product/delete", apiMiGu.DeleteProduct) // 删除产品
|
// //api.POST("product/delete", apiMiGu.DeleteProduct) // 删除产品
|
||||||
|
//
|
||||||
api.POST("channel/list", apiMiGu.ChannelList) // 查询渠道列表
|
// api.POST("channel/list", apiMiGu.ChannelList) // 查询渠道列表
|
||||||
api.POST("channel/add", apiMiGu.AddChannel) // 新增渠道
|
// api.POST("channel/add", apiMiGu.AddChannel) // 新增渠道
|
||||||
//api.POST("channel/update", apiMiGu.UpdateChannel) // 编辑渠道
|
// //api.POST("channel/update", apiMiGu.UpdateChannel) // 编辑渠道
|
||||||
//api.POST("channel/delete", apiMiGu.DeleteChannel) // 删除渠道
|
// //api.POST("channel/delete", apiMiGu.DeleteChannel) // 删除渠道
|
||||||
|
//
|
||||||
api.POST("transaction/list", apiMiGu.TransactionList) // 查询交易流水记录
|
// api.POST("transaction/list", apiMiGu.TransactionList) // 查询交易流水记录
|
||||||
api.POST("order/list", apiMiGu.OrderList) // 查询订单列表
|
// api.POST("order/list", apiMiGu.OrderList) // 查询订单列表
|
||||||
api.POST("historical_summary/list", apiMiGu.HistoricalSummaryList) // 历史汇总查询
|
// api.POST("historical_summary/list", apiMiGu.HistoricalSummaryList) // 历史汇总查询
|
||||||
api.POST("realtime_summary/list", apiMiGu.RealtimeSummaryList) // 当日实时汇总
|
// api.POST("realtime_summary/list", apiMiGu.RealtimeSummaryList) // 当日实时汇总
|
||||||
api.POST("user_retention/list", apiMiGu.UserRetentionList) // 用户留存记录
|
// api.POST("user_retention/list", apiMiGu.UserRetentionList) // 用户留存记录
|
||||||
api.POST("sys_channel/list", apiMiGu.SysChannelList) // 查询系统所有渠道编码
|
// api.POST("sys_channel/list", apiMiGu.SysChannelList) // 查询系统所有渠道编码
|
||||||
api.POST("home/data", apiMiGu.HomepageDataSummary) // 查询首页汇总数据
|
// api.POST("home/data", apiMiGu.HomepageDataSummary) // 查询首页汇总数据
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
// registerMiGuControlManageUnAuthRouter 无需认证的路由代码
|
// registerMiGuControlManageUnAuthRouter 无需认证的路由代码
|
||||||
|
|
|
@ -92,21 +92,11 @@ func run() error {
|
||||||
// TODO
|
// TODO
|
||||||
s := gocron.NewScheduler()
|
s := gocron.NewScheduler()
|
||||||
|
|
||||||
//err := s.Every(1).Day().At("18:01").Do(models.CheckOrderState)
|
|
||||||
//if err != nil {
|
|
||||||
// fmt.Println("err:", err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
err := s.Every(10).Minute().Do(models.CheckOrderState)
|
err := s.Every(10).Minute().Do(models.CheckOrderState)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("err:", err)
|
fmt.Println("err:", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
//err = s.Every(1).Day().At("10:28").Do(models.CheckAllOrderState)
|
|
||||||
//if err != nil {
|
|
||||||
// fmt.Println("err:", err)
|
|
||||||
//}
|
|
||||||
|
|
||||||
<-s.Start()
|
<-s.Start()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
@ -6296,8 +6296,8 @@ var SwaggerInfoadmin = &swag.Spec{
|
||||||
Description: "基于Gin + Vue + Element UI的前后端分离权限管理系统的接口文档\n添加qq群: 521386980 进入技术交流群 请先star,谢谢!",
|
Description: "基于Gin + Vue + Element UI的前后端分离权限管理系统的接口文档\n添加qq群: 521386980 进入技术交流群 请先star,谢谢!",
|
||||||
InfoInstanceName: "admin",
|
InfoInstanceName: "admin",
|
||||||
SwaggerTemplate: docTemplateadmin,
|
SwaggerTemplate: docTemplateadmin,
|
||||||
LeftDelim: "{{",
|
//LeftDelim: "{{",
|
||||||
RightDelim: "}}",
|
//RightDelim: "}}",
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user