Browse Source

no message

xingzai 6 months ago
parent
commit
d20e514dc7
4 changed files with 181 additions and 4 deletions
  1. 10 4
      controllers/activity.go
  2. 12 0
      models/activity.go
  3. 32 0
      models/activity_vivo_points_set.go
  4. 127 0
      services/order.go

+ 10 - 4
controllers/activity.go

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

+ 12 - 0
models/activity.go

@@ -291,6 +291,18 @@ type CygxActivityResp struct {
 	PayTimeCountdown   int                    `description:"支付时间倒计时"`
 	OrderCode          string                 `comment:"订单编号"`
 	GoodsList          []*order.CygxGoodsResp `description:"商品信息"`
+	VivoPoints         VivoPointsResp         `description:"音视频设置"`
+}
+
+type VivoPointsResp struct {
+	HavePoint       bool   `description:"是否被扣过点"`
+	PointPermission int    `description:"1:点数充足、2点数不足需付费、3:只能付费"`
+	CompanyPoints   string `description:"公司剩余点数"`
+	ActivityPoints  string `description:"本场活动要扣除的点数"`
+	Title           string `description:"标题"`
+	ResourceUrl     string `description:"链接"`
+	Type            int    `description:"类型: 1-活动音频; 2-活动视频;"`
+	PlaySeconds     string `description:"音视频时长"`
 }
 
 type CygxYidongActivityUrlResp struct {

+ 32 - 0
models/activity_vivo_points_set.go

@@ -0,0 +1,32 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivityVivoPointsSet struct {
+	PointSetId   int       `orm:"column(point_set_id);pk";comment:"主键id"`
+	ActivityId   int       `comment:"活动ID"`
+	PointsObject string    `comment:"扣点设置方式 1:同报名参会时的扣点数、2:输入其余点数"`
+	PointsNum    float64   `comment:"扣点数量"`
+	GoodsMoney   float64   `comment:"商品总价"`
+	Source       string    `comment:"来源 activityvideo 活动视频、activityvoice 活动音频"`
+	CreateTime   time.Time `comment:"创建时间"`
+	ModifyTime   time.Time `comment:"更新时间"`
+}
+
+// 根据活动ID判断音视频是否设置了扣点
+func GetCygxActivityVivoPointsSetCountByActivityId(activityId int) (count int, err error) {
+	o := orm.NewOrm()
+	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_vivo_points_set  WHERE activity_id =?  `
+	err = o.Raw(sqlCount, activityId).QueryRow(&count)
+	return
+}
+
+func GetCygxActivityVivoPointsSetByActivityId(activityId int) (item *CygxActivityVivoPointsSet, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT * FROM cygx_activity_vivo_points_set WHERE activity_id = ?  `
+	err = o.Raw(sql, activityId).QueryRow(&item)
+	return
+}

+ 127 - 0
services/order.go

@@ -86,6 +86,133 @@ func GetGoodsInfoByActivity(item *models.ActivityDetail) (goodsListResp []*order
 	return
 }
 
+// 获取单场活动音视频关联的商品配置信息
+func GetGoodsInfoByActivityVivo(item *models.ActivityDetail) (goodsListResp []*order.CygxGoodsResp) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("获取单场活动关联的商品配置信息失败 GetGoodsInfoByActivity, err:", err.Error()), 2)
+		}
+	}()
+	activityId := item.ActivityId
+
+	total, e := models.GetCygxActivityVivoPointsSetCountByActivityId(activityId)
+	if e != nil {
+		err = errors.New("GetCygxActivityPointsSetUserNum, Err: " + e.Error())
+		return
+	}
+	if total == 0 {
+		goodsListResp = make([]*order.CygxGoodsResp, 0)
+		return
+	}
+
+	vivoPointsSetDetail, e := models.GetCygxActivityVivoPointsSetByActivityId(activityId)
+	if e != nil {
+		err = errors.New("GetCygxActivityVivoPointsSetCountByActivityId, Err: " + e.Error())
+		return
+	}
+
+	var condition string
+	var pars []interface{}
+	condition = ` AND  goods_id IN  (9) `
+
+	goodsList, e := order.GetCygxGoodsList(condition, pars)
+	if e != nil {
+		err = errors.New("GetCygxGoodsList, Err: " + e.Error())
+		return
+	}
+
+	for k, _ := range goodsList {
+		goodsList[k].CurrentPrice = fmt.Sprint(vivoPointsSetDetail.GoodsMoney)
+		goodsList[k].Price = fmt.Sprint(vivoPointsSetDetail.GoodsMoney)
+		goodsList[k].PopupPriceMsg = fmt.Sprint("¥", vivoPointsSetDetail.GoodsMoney)
+	}
+
+	goodsListResp = goodsList
+	return
+}
+
+func GetActivityVivoPoints(item *models.ActivityDetail, wxUser *models.WxUserItem, havePower bool) (vivoPointsResp models.VivoPointsResp) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println(err)
+			go utils.SendAlarmMsg(fmt.Sprint("获取单场活动关联的商品配置信息失败 GetGoodsInfoByActivity, err:", err.Error()), 2)
+		}
+	}()
+	activityId := item.ActivityId
+
+	total, e := models.GetCygxActivityVivoPointsSetCountByActivityId(activityId)
+	if e != nil {
+		err = errors.New("GetCygxActivityPointsSetUserNum, Err: " + e.Error())
+		return
+	}
+	if total == 0 {
+		return
+	}
+
+	totalMySuccess, e := models.GetActivitySignupCount(wxUser.UserId, activityId)
+	if e != nil {
+		err = errors.New("GetCygxActivityPointsSetUserNum, Err: " + e.Error())
+		return
+	}
+
+	if totalMySuccess > 0 {
+		vivoPointsResp.HavePoint = true
+	}
+
+	vivoPointsSetDetail, e := models.GetCygxActivityVivoPointsSetByActivityId(activityId)
+	if e != nil {
+		err = errors.New("GetCygxActivityVivoPointsSetCountByActivityId, Err: " + e.Error())
+		return
+	}
+
+	vivoPointsResp.ActivityPoints = fmt.Sprint(vivoPointsSetDetail.PointsNum)
+	// 获取用户所在公司剩余的点
+	companyPointsNum, e := models.GetCompanyPoints(wxUser.CompanyId)
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		err = errors.New("GetCompanyPoints, Err: " + e.Error())
+		return
+	}
+	vivoPointsResp.CompanyPoints = fmt.Sprint(companyPointsNum)
+
+	if havePower {
+		if companyPointsNum >= vivoPointsSetDetail.PointsNum {
+			vivoPointsResp.PointPermission = 1
+		} else {
+			vivoPointsResp.PointPermission = 2
+		}
+	} else {
+		if vivoPointsSetDetail.GoodsMoney > 0 {
+			vivoPointsResp.PointPermission = 3
+		}
+	}
+
+	if vivoPointsSetDetail.Source == utils.CYGX_OBJ_ACTIVITYVIDEO { //活动视频
+		activityVideoInfo, e := models.GetCygxActivityVideoByActivityId(activityId)
+		if e != nil {
+			err = errors.New("GetCygxActivityVideoByActivityId, Err: " + e.Error())
+			return
+		}
+		vivoPointsResp.Type = 2
+		vivoPointsResp.Title = activityVideoInfo.VideoName
+		vivoPointsResp.ResourceUrl = activityVideoInfo.VideoUrl
+		vivoPointsResp.PlaySeconds = activityVideoInfo.VideoDuration
+	} else if vivoPointsSetDetail.Source == utils.CYGX_OBJ_ACTIVITYVOICE { //活动音频
+		activityVideoInfo, 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
+	}
+	return
+}
+
 // 获取用户十分钟之内是否有相同的订单信息
 func GetHaverEquallyOrderByUser10Min(userId, goodsId int) (orderCode string) {
 	var err error