浏览代码

Merge branch 'cygx_9.3.1_0' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 2 年之前
父节点
当前提交
abcea7b51d

+ 37 - 1
controllers/activity_special.go

@@ -10,7 +10,7 @@ import (
 	"time"
 )
 
-//专项调研活动
+// 专项调研活动
 type ActivitySpecialCoAntroller struct {
 	BaseAuthController
 }
@@ -230,6 +230,22 @@ func (this *ActivitySpecialCoAntroller) SpecialTripAdd() {
 				br.ErrMsg = "获取日程数量信息失败,Err:" + err.Error()
 				return
 			}
+			//流水记录表
+			itemBill := new(models.CygxActivitySpecialTripBill)
+			itemBill.UserId = user.UserId
+			itemBill.ActivityId = activityInfo.ActivityId
+			itemBill.CreateTime = time.Now()
+			itemBill.Mobile = user.Mobile
+			itemBill.Email = user.Email
+			itemBill.CompanyId = user.CompanyId
+			itemBill.CompanyName = user.CompanyName
+			itemBill.RealName = user.RealName
+			itemBill.Source = 1
+			itemBill.DoType = 2
+			itemBill.BillDetailed = 1 // 流水加一
+			itemBill.RegisterPlatform = 1
+			itemBill.ChartPermissionId = activityInfo.ChartPermissionId
+
 			go services.ActivitySpecialUserRmind(user, activityId, 2)
 			//判断是删除还是添加
 			if total == 0 {
@@ -273,7 +289,9 @@ func (this *ActivitySpecialCoAntroller) SpecialTripAdd() {
 					br.ErrMsg = "二次报名,更改报名是否有效状态失败,Err:" + err.Error()
 					return
 				}
+				itemBill.BillDetailed = 0 // 取消报名之后二次报名,不扣除流水记录
 			}
+			go models.AddCygxActivitySpecialTripBill(itemBill)
 		}
 	} else {
 		hasPermission, sellerName, sellerMobile, popupMsg, err := services.GetUserHasPermission(user)
@@ -332,11 +350,27 @@ func (this *ActivitySpecialCoAntroller) Tripcancel() {
 		br.ErrMsg = "操作失败,Err:" + errInfo.Error()
 		return
 	}
+	//流水记录表
+	itemBill := new(models.CygxActivitySpecialTripBill)
+	itemBill.UserId = user.UserId
+	itemBill.ActivityId = activityInfo.ActivityId
+	itemBill.CreateTime = time.Now()
+	itemBill.Mobile = user.Mobile
+	itemBill.Email = user.Email
+	itemBill.CompanyId = user.CompanyId
+	itemBill.CompanyName = user.CompanyName
+	itemBill.RealName = user.RealName
+	itemBill.Source = 1
+	itemBill.DoType = 2
+	itemBill.BillDetailed = 1 // 流水加一
+	itemBill.RegisterPlatform = 1
+	itemBill.ChartPermissionId = activityInfo.ChartPermissionId
 	resultTime := utils.StrTimeToTime(activityInfo.ActivityTime)
 	//48小时之内的取消也扣除一次参会记录
 	var isValid int
 	if time.Now().Add(+time.Hour * 48).After(resultTime) {
 		isValid = 1
+		itemBill.BillDetailed = 0 //48小时之内取消的活动扣点不返回
 	}
 	err = models.CancelActivitySpecialTripIsValid(isValid, activityInfo.ActivityId, uid)
 	if err != nil {
@@ -344,6 +378,8 @@ func (this *ActivitySpecialCoAntroller) Tripcancel() {
 		br.ErrMsg = "CancelActivitySpecialTrip,Err:" + err.Error()
 		return
 	}
+	go models.AddCygxActivitySpecialTripBill(itemBill)
+
 	br.Ret = 200
 	br.Success = true
 	br.Msg = "已取消"

+ 5 - 5
models/activity_special.go

@@ -5,14 +5,14 @@ import (
 	"github.com/beego/beego/v2/client/orm"
 )
 
-//专项调研活动列表
+// 专项调研活动列表
 type CygxActivitySpecialDetail struct {
 	ActivityId            int    `description:"活动ID "`
 	ActivityTypeName      string `description:"活动名称"`
 	SpecialType           int    `description:"调研形式、 1 线上 , 2 线下"`
 	City                  string `description:"调研城市"`
 	ChartPermissionName   string `description:"行业名称"`
-	ChartPermissionId     string `description:"行业Id"`
+	ChartPermissionId     int    `description:"行业Id"`
 	ResearchTheme         string `description:"调研主题"`
 	ActivityTimeText      string `description:"活动预期时间带文字"`
 	TripImgLink           string `description:"行程图片链接"`
@@ -40,7 +40,7 @@ type CygxActivitySpecialDetail struct {
 	AdminId               int    `description:"管理员ID"`
 }
 
-//获取数量
+// 获取数量
 func GetActivitySpecialCount(condition string, pars []interface{}) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count  FROM cygx_activity_special as art WHERE 1= 1  `
 	if condition != "" {
@@ -51,7 +51,7 @@ func GetActivitySpecialCount(condition string, pars []interface{}) (count int, e
 	return
 }
 
-//主题列表
+// 主题列表
 func GetActivitySpecialListAll(condition string, pars []interface{}, startSize, pageSize int) (items []*CygxActivitySpecialDetail, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT	*
@@ -64,7 +64,7 @@ func GetActivitySpecialListAll(condition string, pars []interface{}, startSize,
 	return
 }
 
-//修改发布状态
+// 修改发布状态
 func UpdateActivitySpecialPublishStatus(publishStatus, activityId int) (err error) {
 	sql := ` UPDATE cygx_activity_special SET  publish_status= ?  WHERE activity_id = ?`
 	o := orm.NewOrm()

+ 42 - 8
models/activity_special_trip.go

@@ -1,6 +1,7 @@
 package models
 
 import (
+	"fmt"
 	//"hongze/hongze_admin/models"
 	"github.com/beego/beego/v2/client/orm"
 	"time"
@@ -50,7 +51,7 @@ func GetCygxActivitySpecialTripList(condition string, pars []interface{}) (item
 	return
 }
 
-//获取某一用户的报名的数量
+// 获取某一用户的报名的数量
 func GetUserActivitySpecialTripCount(uid, activityId int) (count int, err error) {
 	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_trip  WHERE  user_id=?  AND   activity_id =? `
 	o := orm.NewOrm()
@@ -58,7 +59,7 @@ func GetUserActivitySpecialTripCount(uid, activityId int) (count int, err error)
 	return
 }
 
-//获取某一活动的报名的数量
+// 获取某一活动的报名的数量
 func GetActivitySpecialTripCountByActivityId(condition string, pars []interface{}) (count int, err error) {
 	sqlCount := `SELECT COUNT(1) AS count FROM cygx_activity_special_trip as t   INNER JOIN wx_user as  u on u.user_id = t.user_id WHERE    1 = 1 ` + condition
 	o := orm.NewOrm()
@@ -66,7 +67,7 @@ func GetActivitySpecialTripCountByActivityId(condition string, pars []interface{
 	return
 }
 
-//获取某一活动的报名的数量 (同时关联活动类型进行获取)
+// 获取某一活动的报名的数量 (同时关联活动类型进行获取)
 func GetActivitySpecialTripCountByActivitySpecial(condition string, pars []interface{}) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count
 		FROM
@@ -79,7 +80,7 @@ func GetActivitySpecialTripCountByActivitySpecial(condition string, pars []inter
 	return
 }
 
-//获取空降的公司报名的记录
+// 获取空降的公司报名的记录
 func GetActivitySpecialTripAirborneCountByActivitySpecial(condition string, pars []interface{}) (count int, err error) {
 	sqlCount := ` SELECT COUNT(1) AS count
 		FROM
@@ -92,14 +93,47 @@ func GetActivitySpecialTripAirborneCountByActivitySpecial(condition string, pars
 	return
 }
 
-//添加
+// 添加
 func AddCygxActivitySpecialTrip(item *CygxActivitySpecialTrip) (err error) {
-	o := orm.NewOrm()
+	o, err := orm.NewOrm().Begin()
+	if err != nil {
+		return
+	}
+	defer func() {
+		fmt.Println(err)
+		if err == nil {
+			o.Commit()
+		} else {
+			o.Rollback()
+		}
+	}()
 	_, err = o.Insert(item)
+	if err != nil {
+		return
+	}
+	//itemBill := new(CygxActivitySpecialTripBill)
+	//itemBill.UserId = item.UserId
+	//itemBill.ActivityId = item.ActivityId
+	//itemBill.CreateTime = time.Now()
+	//itemBill.Mobile = item.Mobile
+	//itemBill.Email = item.Email
+	//itemBill.CompanyId = item.CompanyId
+	//itemBill.CompanyName = item.CompanyName
+	//itemBill.RealName = item.RealName
+	//itemBill.Source = 1
+	//itemBill.BillDetailed = -1 // 流水减一
+	//itemBill.DoType = 1
+	//itemBill.RegisterPlatform = 1
+	//itemBill.ChartPermissionId = itemActivity.ChartPermissionId
+	//
+	//_, err = o.Insert(itemBill)
+	//if err != nil {
+	//	return
+	//}
 	return
 }
 
-//取消
+// 取消
 func CancelActivitySpecialTrip(uid int, item *CygxActivitySpecialDetail) (err error) {
 	o := orm.NewOrm()
 	sql := `DELETE  FROM cygx_activity_special_trip   WHERE user_id=?  AND activity_id=? `
@@ -107,7 +141,7 @@ func CancelActivitySpecialTrip(uid int, item *CygxActivitySpecialDetail) (err er
 	return
 }
 
-//CancelActivitySpecialTripIsValid  处理活动报名是否有效
+// CancelActivitySpecialTripIsValid  处理活动报名是否有效
 func CancelActivitySpecialTripIsValid(isValid, activityId, userId int) (err error) {
 	sql := ` UPDATE cygx_activity_special_trip SET  is_valid= ?,is_cancel = 1  WHERE activity_id = ? AND  user_id = ? `
 	o := orm.NewOrm()

+ 44 - 0
models/activity_special_trip_bill.go

@@ -0,0 +1,44 @@
+package models
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CygxActivitySpecialTripBill struct {
+	Id                int       `orm:"column(id);pk"`
+	UserId            int       `description:"用户id,多个用,隔开"`
+	ActivityId        int       `description:"活动ID"`
+	CreateTime        time.Time `description:"创建时间"`
+	Mobile            string    `description:"手机号"`
+	Email             string    `description:"邮箱号"`
+	CompanyId         int       `description:"公司ID"`
+	CompanyName       string    `description:"公司名称"`
+	RealName          string    `description:"用户实际名称"`
+	AdminId           int       `description:"销售/管理员ID"`
+	Source            int       `description:"来源,1小程序,2后台添加, 3开发人员手动添加"`
+	BillDetailed      int       `description:"流水明细,判断是进账还是出账"`
+	DoType            int       `description:"操作方式,1报名,2取消报名"`
+	RegisterPlatform  int       `description:"来源 1小程序,2:网页"`
+	ChartPermissionId int       `description:"行业id"`
+}
+
+// 添加
+func AddCygxActivitySpecialTripBill(item *CygxActivitySpecialTripBill) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	if err != nil {
+		return
+	}
+	return
+}
+
+func GetCygxActivitySpecialTripBill(condition string, pars []interface{}) (item []*CygxActivitySpecialTripBill, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT *
+			FROM
+			cygx_activity_special_trip_bill  
+			WHERE 1 = 1 ` + condition
+	_, err = o.Raw(sql, pars).QueryRows(&item)
+	return
+}

+ 1 - 0
models/article.go

@@ -565,6 +565,7 @@ type ArticleResultApidate struct {
 	Corpus        Corpus                   `json:"corpus"`
 	Cover         string                   `json:"cover"`
 	TypeId        int                      `json:"type_id"`
+	IsActive      bool                     `json:"is_active"`
 }
 
 type ArticleField struct {

+ 1 - 0
models/db.go

@@ -131,6 +131,7 @@ func init() {
 		new(CygxResearchSummaryVoiceHistory),
 		new(CygxMinutesSummaryVoiceHistory),
 		new(CygxReportSelectionVoiceHistory),
+		new(CygxActivitySpecialTripBill),
 	)
 	// 记录ORM查询日志
 	orm.Debug = true

+ 2 - 1
services/activity_special.go

@@ -909,6 +909,7 @@ func GetSpecialDetailUserPower(user *models.WxUserItem, activityInfo *models.Cyg
 		return
 	}
 	var userTypeStr string
+	userTypeStr = mapUserType[userType]
 	// 永续客户、大套餐客户可以查看行业升级套餐客户 权限
 	if userTypeStr == "1" || userTypeStr == "2" {
 		if strings.Contains(activityInfo.CustomerTypeIds, userTypeStr) || strings.Contains(activityInfo.CustomerTypeIds, "8") {
@@ -916,7 +917,7 @@ func GetSpecialDetailUserPower(user *models.WxUserItem, activityInfo *models.Cyg
 			return
 		}
 	}
-	userTypeStr = mapUserType[userType]
+
 	permissionStr, e := GetCompanyPermissionUpgrade(user.CompanyId)
 	if e != nil {
 		err = errors.New("GetCompanyPermissionUpgrade, Err: " + e.Error())

+ 21 - 17
services/activity_special_trip.go

@@ -51,14 +51,15 @@ func SpecialTripPopupMsg(activityInfo *models.CygxActivitySpecialDetail, user *m
 	return
 }
 
-//获取用户剩余报名次数
+// 获取用户剩余报名次数
 func GetTripRemainingtimesBycompany(user *models.WxUserItem, activityInfo *models.CygxActivitySpecialDetail) (errMsg string, tripRemaining int, err error) {
 
 	//获取 专项调研客户类型   //1、永续客户 //2、大套餐客户(4个行业全开通的正式客户) //3、分行业套餐客户(开通对应行业的正式客户) //4、仅开通专家套餐的正式客户 //5、开通对应行业套餐或专家套餐的试用客户;6、冻结客户;7、流失客户 8:行业升级套餐客户
 	msgTemplate := "您的专项调研次数已用完,如仍想参加,请与您的对口销售商议"
-	var tripTota int
+	//var tripTota int
 	var airborneTota int
-	userType, _, e := GetActivitySpecialUserType(user.CompanyId)
+	//userType, _, e := GetActivitySpecialUserType(user.CompanyId)
+	userType, _, e := GetUserType(user.CompanyId)
 	if e != nil {
 		err = errors.New("获取客户身份信息失败 GetActivitySpecialUserType, Err: " + e.Error())
 		return
@@ -81,20 +82,22 @@ func GetTripRemainingtimesBycompany(user *models.WxUserItem, activityInfo *model
 			err = errors.New("GetActivitySpecialTripAirborneCountByActivitySpecial, Err: " + e.Error())
 			return
 		}
-
-		condition += ` AND is_valid = 1 `
-
-		tripTota, e = models.GetActivitySpecialTripCountByActivitySpecial(condition, pars)
+		//condition += ` AND is_valid = 1 `
+		listTripBill, e := models.GetCygxActivitySpecialTripBill(condition, pars)
 		if e != nil {
 			err = errors.New("GetActivitySpecialTripCountByActivitySpecial, Err: " + e.Error())
 			return
 		}
-		tripTota += airborneTota
-		if tripTota >= 12 {
+		var TripBillNum int
+		for _, v := range listTripBill {
+			TripBillNum += v.BillDetailed
+		}
+		tripRemaining = 10 - airborneTota + TripBillNum
+		if tripRemaining <= 0 {
 			errMsg = msgTemplate
 			return
 		}
-		tripRemaining = 12 - tripTota
+		//tripRemaining = 12 - tripTota
 	} else {
 		var condition string
 		var pars []interface{}
@@ -111,24 +114,25 @@ func GetTripRemainingtimesBycompany(user *models.WxUserItem, activityInfo *model
 			return
 		}
 
-		condition += ` AND is_valid = 1 `
-
-		tripTota, e = models.GetActivitySpecialTripCountByActivitySpecial(condition, pars)
+		listTripBill, e := models.GetCygxActivitySpecialTripBill(condition, pars)
 		if e != nil {
 			err = errors.New("GetActivitySpecialTripCountByActivitySpecial, Err: " + e.Error())
 			return
 		}
-		tripTota += airborneTota
-		if tripTota >= 6 {
+		var TripBillNum int
+		for _, v := range listTripBill {
+			TripBillNum += v.BillDetailed
+		}
+		tripRemaining = 5 - airborneTota + TripBillNum
+		if tripRemaining <= 0 {
 			errMsg = msgTemplate
 			return
 		}
-		tripRemaining = 6 - tripTota
 	}
 	return
 }
 
-//用户搜专项调研操作操作行为,模板消息推送
+// 用户搜专项调研操作操作行为,模板消息推送
 func ActivitySpecialUserRmind(user *models.WxUserItem, activityId, TripStatus int) (err error) {
 	defer func() {
 		if err != nil {

+ 4 - 5
services/article.go

@@ -720,8 +720,9 @@ func HandleArticleListByApi(artcleId int) (err error) {
 	item.Body = ""
 	item.Result = string(body)
 	go models.AddCygxShanghaiCompanyLog(item)
-
+	go models.UpdateCygxArticleCeluePush(artcleId)
 	articleResult := articleResultDate.Data
+
 	exitMap := make(map[int]int)
 	classMap := make(map[int]int)
 	reportMap := make(map[int]int)
@@ -758,8 +759,8 @@ func HandleArticleListByApi(artcleId int) (err error) {
 		return
 	}
 
-	//状态等于 2 跟 4 的进行同步
-	if exitMap[articleResult.SeriesId] > 0 && (articleResult.PublishStatus == 2 || articleResult.PublishStatus == 4) {
+	//状态等于 2 跟 4 的进行同步 IsActive 为false 软删除的也不同步
+	if exitMap[articleResult.SeriesId] > 0 && (articleResult.PublishStatus == 2 || articleResult.PublishStatus == 4) && articleResult.IsActive {
 		articleResult.PublishDate = time.Date(articleResult.PublishDate.Year(), articleResult.PublishDate.Month(), articleResult.PublishDate.Day(), articleResult.PublishDate.Hour(), articleResult.PublishDate.Minute(), articleResult.PublishDate.Second(), articleResult.PublishDate.Nanosecond(), time.Local)
 		item := new(models.Tactics2)
 		itemArticleData := new(models.CygxArticleData)
@@ -820,9 +821,7 @@ func HandleArticleListByApi(artcleId int) (err error) {
 			fmt.Println("UpdateArticlePublish Err:", err.Error())
 			return err
 		}
-
 		go UpdateResourceData(artcleId, "article", "delete", time.Now().Format(utils.FormatDateTime))
-		go models.UpdateCygxArticleCeluePush(artcleId)
 		return err
 	}
 

+ 3 - 2
utils/config.go

@@ -141,7 +141,7 @@ func init() {
 	SummaryArticleId = 1000000         //手动添加的纪要库开始ID
 	YanxSummaryPermissionId = 1001     //研选纪要分类ID
 	YanxViewpointPermissionId = 1002   //研选观点分类ID
-	WxMsgTemplateIdAskMsgMobileAll = "15557270714,18767183922,18621268829,15618524605"
+	WxMsgTemplateIdAskMsgMobileAll = "15557270714,18767183922,18621268829,18955528215"
 	WxMsgTemplateIdAskMsgMobilePublic = "15557270714,18767183922,18621268829"
 	HtgjDefaultSaleName = "王芳"
 	HtgjSalt = "HTGJ&HZ"
@@ -174,7 +174,8 @@ func init() {
 		WxMsgTemplateIdAskMsg = "PaoDanHGlt1kFw5q-4_ipJSwO3FyZpxSSNg4rwB7YCk"
 		WxMsgTemplateIdArticleUserRemind = "7qe3i4MrGxAIPhJeMgoqqw6j0A_foUB65DLSmxKe05s"
 		WxMsgTemplateIdAskMsgMobile = ""
-		ActSendMsgMobile = "15618524605"
+		//ActSendMsgMobile = "15618524605"
+		ActSendMsgMobile = "18955528215" // 汪洋手机号
 		ArticleTaskClassMobile = "15557270714,18767183922,15216736473,15000123056,18701809782,17706316791,18652179672"
 
 		ShangHaiCrmApiLink = "https://crm.hzinsights.com/"