Browse Source

Merge branch 'cygx_fix_bug_point_06-17' of http://8.136.199.33:3000/hongze/hongze_cygx into debug

xingzai 9 months ago
parent
commit
7b9faa38fa
3 changed files with 40 additions and 5 deletions
  1. 7 0
      models/activity_points_company.go
  2. 30 5
      services/activity_points.go
  3. 3 0
      services/product_interior.go

+ 7 - 0
models/activity_points_company.go

@@ -40,3 +40,10 @@ func GetCygxActivityPointsCompanyCountByCompanyId(companyId int) (count int, err
 	err = o.Raw(sqlCount, companyId).QueryRow(&count)
 	return
 }
+
+// 添加
+func AddCygxActivityPointsCompany(item *CygxActivityPointsCompany) (err error) {
+	o := orm.NewOrm()
+	_, err = o.Insert(item)
+	return
+}

+ 30 - 5
services/activity_points.go

@@ -223,13 +223,38 @@ func YanXuanActivityPointsBillSignupAddReduce(log models.YanXuanActivityPointsRe
 		err = errors.New("GetWxUserItemByUserId" + e.Error())
 		return
 	}
-
-	// 获取用户所在公司剩余的点
-	companyPointsNum, e := models.GetCompanyPoints(user.CompanyId)
-	if e != nil && e.Error() != utils.ErrNoRow() {
-		err = errors.New("GetCompanyPoints, Err: " + e.Error())
+	companyId := user.CompanyId
+	//判断公司是不是满足扣点情况,如果是后台超管手动给试用客户报名,就写入一条点数初始化数据
+	total, e := models.GetCygxActivityPointsCompanyCountByCompanyId(companyId)
+	if e != nil {
+		err = errors.New("GetCygxActivityPointsCompanyCountByCompanyId, Err: " + e.Error())
 		return
 	}
+	var companyPointsNum float64
+	if total == 0 {
+		companyPointsNum = 0
+		itemPointsCompany := new(models.CygxActivityPointsCompany)
+
+		itemPointsCompany.CompanyId = companyId
+		itemPointsCompany.CompanyName = user.CompanyName
+		itemPointsCompany.CreateTime = time.Now()
+		itemPointsCompany.ModifyTime = time.Now()
+
+		e = models.AddCygxActivityPointsCompany(itemPointsCompany)
+		if e != nil {
+			err = errors.New("AddCygxActivityPointsCompany, Err: " + e.Error())
+			return
+		}
+	} else {
+		// 获取用户所在公司剩余的点
+		companyPointsNum, e = models.GetCompanyPoints(user.CompanyId)
+		if e != nil && e.Error() != utils.ErrNoRow() {
+			err = errors.New("GetCompanyPoints, Err: " + e.Error())
+			return
+		}
+
+	}
+
 	//获取需要添加的流水信息
 	var items []*models.CygxActivityPointsBill
 	item := new(models.CygxActivityPointsBill)

+ 3 - 0
services/product_interior.go

@@ -250,6 +250,9 @@ func GetCygxProductInteriorHistoryListPvMap(productInteriorIs []int) (mapPv map[
 
 // 用户产品内测阅读,模板消息推送
 func ProductInteriorHistoryUserRmind(user *models.WxUserItem, productInteriorId int) (err error) {
+	if user.UserId == 0 {
+		return
+	}
 	//30秒内阅读同一篇报告不做重复推送
 	key := "CYGX_" + utils.CYGX_OBJ_PRODUCTINTERIOR + "_READ" + strconv.Itoa(productInteriorId) + "_" + strconv.Itoa(user.UserId)
 	if utils.Rc.IsExist(key) {