浏览代码

no message

xingzai 6 月之前
父节点
当前提交
a012351d97
共有 5 个文件被更改,包括 91 次插入14 次删除
  1. 3 2
      controllers/activity.go
  2. 49 6
      controllers/order.go
  3. 2 2
      models/order/order.go
  4. 36 4
      services/order.go
  5. 1 0
      services/wx_pay.go

+ 3 - 2
controllers/activity.go

@@ -925,8 +925,9 @@ func (this *ActivityNoLoginController) Detail() {
 
 	//已结束的活动,音视频作为商品的价格处理
 	if activityInfo.ActiveState == "3" {
-		resp.GoodsList = services.GetGoodsInfoByActivityVivo(activityInfo)              //音视频回放商品信息
-		resp.VivoPoints = services.GetActivityVivoPoints(activityInfo, user, havePower) //单场活动信息
+		resp.GoodsList = services.GetGoodsInfoByActivityVivo(activityInfo)                                             //音视频回放商品信息
+		resp.VivoPoints = services.GetActivityVivoPoints(activityInfo, user, havePower)                                //单场活动信息
+		resp.OrderCode, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivtyVivo(uid, activityId) //截止支付时间倒计时
 	} else {
 		if (!activityInfo.IsResearchPoints && activityInfo.IsLimitPeople == 0) || activityInfo.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
 			resp.GoodsList = services.GetUserGoodsCardList() //日卡月卡商品信息

+ 49 - 6
controllers/order.go

@@ -143,6 +143,7 @@ func (this *OrderController) AddByActivity() {
 	uid := user.UserId
 	goodsId := req.GoodsId
 	sourceId := req.SourceId
+	source := req.Source
 	if goodsId == 0 {
 		br.Msg = "支付失败"
 		br.ErrMsg = "支付失败,goodsId 信息错误Err:" + err.Error()
@@ -163,14 +164,20 @@ func (this *OrderController) AddByActivity() {
 	}
 	var title string
 	var oldOrderCode string
+	var payTimeCountdown int
 	//var _ int
 	item := new(order.CygxOrder)
-	if (!activityDetail.IsResearchPoints && activityDetail.IsLimitPeople == 0) || activityDetail.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
-		oldOrderCode = services.GetHaverEquallyOrderByUser10Min(uid, goodsId) //获取用户十分钟之内是否有相同的订单信息
-		item.OrderType = 1
+	if source == "ActivityVivo" {
+		oldOrderCode, payTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivtyVivo(uid, sourceId)
+		item.OrderType = 3
 	} else {
-		oldOrderCode, _ = services.GetHaverEquallyOrderByUser10MinByActivty(uid, sourceId)
-		item.OrderType = 2
+		if (!activityDetail.IsResearchPoints && activityDetail.IsLimitPeople == 0) || activityDetail.YidongActivityId != "" { //易董的活动 或者(不扣点且不限制人数)走月卡日卡逻辑
+			oldOrderCode = services.GetHaverEquallyOrderByUser10Min(uid, goodsId) //获取用户十分钟之内是否有相同的订单信息
+			item.OrderType = 1
+		} else {
+			oldOrderCode, payTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, sourceId)
+			item.OrderType = 2
+		}
 	}
 
 	title = activityDetail.ActivityName
@@ -190,6 +197,8 @@ func (this *OrderController) AddByActivity() {
 		item.GoodsName = "日卡"
 	case 2:
 		item.GoodsName = "月卡"
+	case 9:
+		item.GoodsName = "活动回放"
 	}
 	//如果活动有自定义的价格就优先按照自定义的价格来
 	if activityDetail.ActivityPrice > 0 {
@@ -215,6 +224,40 @@ func (this *OrderController) AddByActivity() {
 	item.ModifyTime = time.Now()
 	item.RegisterPlatform = utils.REGISTER_PLATFORM
 
+	//如果是音视频的订单,数据做二次处理
+	if source == "ActivityVivo" {
+		vivoPointsSetDetail, err := models.GetCygxActivityVivoPointsSetByActivityId(sourceId)
+		if err != nil {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,Err:" + err.Error()
+			return
+		}
+		item.GoodsMoney = vivoPointsSetDetail.GoodsMoney
+		item.OrderMoney = vivoPointsSetDetail.GoodsMoney
+		item.Source = vivoPointsSetDetail.Source
+		if vivoPointsSetDetail.Source == utils.CYGX_OBJ_ACTIVITYVIDEO {
+			activityVideoInfo, err := models.GetCygxActivityVideoByActivityId(sourceId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取信息失败,Err:" + err.Error()
+				return
+			}
+			title = activityVideoInfo.VideoName
+		} else if vivoPointsSetDetail.Source == utils.CYGX_OBJ_ACTIVITYVOICE {
+			activityVoiceInfo, err := models.GetCygxActivityVoiceByActivityId(sourceId)
+			if err != nil {
+				br.Msg = "获取信息失败"
+				br.ErrMsg = "获取信息失败,Err:" + err.Error()
+				return
+			}
+			title = activityVoiceInfo.VoiceName
+		} else {
+			br.Msg = "获取信息失败"
+			br.ErrMsg = "获取信息失败,音视频数据类型错误"
+			return
+		}
+	}
+
 	//如果十分钟之内有相同的订单就修改,没有就新增
 	if oldOrderCode == "" {
 		err = order.AddCygxOrder(item)
@@ -229,7 +272,7 @@ func (this *OrderController) AddByActivity() {
 		return
 	}
 	resp := new(order.WxNativeApiResp)
-	_, resp.PayTimeCountdown = services.GetHaverEquallyOrderByUser10MinByActivty(uid, sourceId) //截止支付时间倒计时
+	resp.PayTimeCountdown = payTimeCountdown //截止支付时间倒计时
 	resp.CodeUrl = codeUrl
 	resp.OrderCode = item.OrderCode
 	br.Data = resp

+ 2 - 2
models/order/order.go

@@ -25,8 +25,8 @@ type PrepayWithRequestPaymentResponse struct {
 }
 
 type CygxOrderAddReq struct {
-	GoodsId int `description:"商品ID"`
-	//Source   string `description:"资源(文章、活动)"`
+	GoodsId         int    `description:"商品ID"`
+	Source          string `description:"资源(文章、活动)"`
 	SourceId        int    `description:"资源ID"`
 	InviteShareCode string `description:"销售账号邀请码"`
 }

+ 36 - 4
services/order.go

@@ -200,15 +200,15 @@ func GetActivityVivoPoints(item *models.ActivityDetail, wxUser *models.WxUserIte
 		vivoPointsResp.ResourceUrl = activityVideoInfo.VideoUrl
 		vivoPointsResp.PlaySeconds = activityVideoInfo.VideoDuration
 	} else if vivoPointsSetDetail.Source == utils.CYGX_OBJ_ACTIVITYVOICE { //活动音频
-		activityVideoInfo, e := models.GetCygxActivityVoiceByActivityId(activityId)
+		activityVoiceInfo, e := models.GetCygxActivityVoiceByActivityId(activityId)
 		if e != nil {
 			err = errors.New("GetCygxActivityVoiceByActivityId, Err: " + e.Error())
 			return
 		}
 		vivoPointsResp.Type = 1
-		vivoPointsResp.Title = activityVideoInfo.VoiceName
-		vivoPointsResp.ResourceUrl = activityVideoInfo.VoiceUrl
-		vivoPointsResp.PlaySeconds = activityVideoInfo.VoicePlaySeconds
+		vivoPointsResp.Title = activityVoiceInfo.VoiceName
+		vivoPointsResp.ResourceUrl = activityVoiceInfo.VoiceUrl
+		vivoPointsResp.PlaySeconds = activityVoiceInfo.VoicePlaySeconds
 	}
 	return
 }
@@ -274,6 +274,38 @@ func GetHaverEquallyOrderByUser10MinByActivty(userId, sourceId int) (orderCode s
 	return
 }
 
+// 获取用户十分钟之内是否有相同的订单信息
+func GetHaverEquallyOrderByUser10MinByActivtyVivo(userId, sourceId int) (orderCode string, seconds int) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("获取用户十分钟之内是否有相同的订单信息失败 GetHaverEquallyOrderByUser10MinByActivty, err:", err.Error()), 2)
+		}
+	}()
+	var condition string
+	var pars []interface{}
+	endTime := time.Now().Add(-10 * time.Minute)
+	condition = `  AND order_status = 1  AND source IN ( 'activityvideo', 'activityvoice') AND  user_id = ? AND  source_id = ? AND create_time > ?  AND register_platform = ? ORDER BY order_id DESC  `
+	pars = append(pars, userId, sourceId, endTime, utils.REGISTER_PLATFORM)
+	orderList, e := order.GetCygxOrderList(condition, pars, 0, 1)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCygxOrderList, Err: " + e.Error())
+		return
+	}
+	if len(orderList) == 0 {
+		return
+	} else {
+		for _, v := range orderList {
+			orderCode = v.OrderCode
+			duration := time.Now().Sub(v.CreateTime)
+			// 将时间差转换为秒数
+			seconds = 600 - int(duration.Seconds())
+		}
+	}
+	return
+}
+
 // 获取用户十分钟之内是否有相同的文章订单信息
 func GetHaverEquallyOrderByUser10MinByArticle(userId, sourceId, goodsId int) (orderCode string, seconds int) {
 	var err error

+ 1 - 0
services/wx_pay.go

@@ -78,6 +78,7 @@ func ExampleNativeApiServicePrepay(orderDetail *order.CygxOrder) (codeUrl string
 	)
 
 	if err != nil {
+		fmt.Println(err)
 		return
 	}
 	codeUrl = *resp.CodeUrl