Ver Fonte

Merge branch 'master' of http://8.136.199.33:3000/cxzhang/hongze_mfyx into mfyx_3.4

xingzai há 7 meses atrás
pai
commit
f5747905aa

+ 3 - 0
controllers/wechat.go

@@ -472,7 +472,10 @@ func (this *WechatCommonController) WxpayNotify() {
 
 	if itemNotify.OutTradeNo != "" {
 		go services.HandleOrderByWechatPay(itemNotify)
+		item.Url = itemNotify.OutTradeNo // 记录一下同一笔订单微信推送了几次
+		go models.AddCygxShanghaiCompanyLog(item)
 	}
+
 	resp.Code = "SUCCESS"
 	br.Data = resp
 	br.Ret = 200

+ 13 - 6
controllers/yanxuan_special.go

@@ -160,12 +160,12 @@ func (this *BaseAuthMobileController) Detail() {
 		this.ServeJSON()
 	}()
 	user := this.User
-	//if sysUser == nil {
-	//	br.Msg = "请登录"
-	//	br.ErrMsg = "请登录1,SysUser Is Empty"
-	//	br.Ret = 408
-	//	return
-	//}
+	if user == nil {
+		br.Msg = "请登录"
+		br.ErrMsg = "请登录1,SysUser Is Empty"
+		br.Ret = 408
+		return
+	}
 
 	specialId, _ := this.GetInt("Id", 0)
 	isSendWx, _ := this.GetInt("IsSendWx", 0)
@@ -201,6 +201,9 @@ func (this *BaseAuthMobileController) Detail() {
 	if inviteShareCode != "" {
 		go services.AddCygxUserAdminShareHistory(user, utils.CYGX_OBJ_YANXUANSPECIAL, item.Title, inviteShareCode, specialId)
 	}
+	if userId == 0 {
+		item.Content = utils.InterceptHtmlLength(item.Content, 150)
+	}
 	var resp models.CygxYanxuanSpecialResp
 	resp.HasPermission = 1
 	resp.CygxYanxuanSpecialItem = *item
@@ -266,6 +269,10 @@ func (this *BaseAuthMobileController) Detail() {
 		br.ErrMsg = "校验用户权限失败,Err:" + err.Error()
 		return
 	}
+	//看自己的文章时不设权限限制,不需要判断是否有研选订阅权限,都可以看。
+	if user.UserId == item.UserId {
+		havePower = true
+	}
 	var hasPermission int
 	if havePower {
 		hasPermission = 1

+ 13 - 0
models/admin.go

@@ -2,6 +2,7 @@ package models
 
 import (
 	"github.com/beego/beego/v2/client/orm"
+	"hongze/hongze_mfyx/utils"
 	"time"
 )
 
@@ -111,3 +112,15 @@ func GetUserSellerRelationUserList() (items []*GetSellerUserMobileResp, err erro
 	_, err = o.Raw(sql).QueryRows(&items)
 	return
 }
+
+// 根据多个ID获取管理员列表信息
+func GetAdminByAdminIds(adminId []int) (items []*AdminMobileResp, err error) {
+	lenArr := len(adminId)
+	if lenArr == 0 {
+		return
+	}
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := ` SELECT mobile  FROM admin  WHERE admin_id  IN (` + utils.GetOrmInReplace(lenArr) + `)`
+	_, err = o.Raw(sql, adminId).QueryRows(&items)
+	return
+}

+ 82 - 0
models/company/company_product.go

@@ -0,0 +1,82 @@
+package company
+
+import (
+	"github.com/beego/beego/v2/client/orm"
+	"time"
+)
+
+type CompanyProduct struct {
+	CompanyProductId    int       `orm:"column(company_product_id);pk" description:"客户产品id"`
+	CompanyId           int       `description:"客户id"`
+	ProductId           int       `description:"产品id"`
+	ProductName         string    `description:"产品名称"`
+	CompanyName         string    `description:"客户名称"`
+	Source              string    `description:"来源"`
+	Reasons             string    `description:"新增理由"`
+	Status              string    `description:"客户状态"`
+	IndustryId          int       `description:"行业id"`
+	IndustryName        string    `description:"行业名称"`
+	SellerId            int       `description:"销售id"`
+	SellerName          string    `description:"销售名称"`
+	GroupId             int       `description:"销售分组id"`
+	DepartmentId        int       `description:"销售部门id"`
+	IsSuspend           int       `description:"1:暂停,0:启用"`
+	SuspendTime         time.Time `description:"暂停启用时间"`
+	TryOutTime          time.Time `description:"正式转试用时间"`
+	RenewalReason       string    `description:"正式转试用后的续约情况说明"`
+	RenewalTodo         string    `description:"未续约说明中的待办事项说明"`
+	LastDescriptionTime time.Time `description:"上次添加说明时间"`
+	RenewalIntention    int       `description:"是否勾选无续约意向,1:确认,0:未确认"`
+	ApproveStatus       string    `description:"审批状态:'审批中','通过','驳回'"`
+	FreezeTime          time.Time `description:"冻结时间"`
+	FreezeReason        time.Time `description:"冻结理由"`
+	Remark              string    `description:"备注信息"`
+	CreateTime          time.Time `description:"创建时间"`
+	ModifyTime          time.Time `description:"修改时间"`
+	StartDate           string    `description:"开始日期"`
+	EndDate             string    `description:"结束日期"`
+	ContractEndDate     time.Time `description:"合同结束日期"`
+	LoseReason          string    `description:"流失原因"`
+	LossTime            time.Time `description:"流失时间"`
+	CompanyType         string    `description:"客户类型"`
+	OpenCode            string    `description:"开放给第三方的编码,不让第三方定位我们的客户信息"`
+	Scale               string    `description:"管理规模,空不填,1::50亿以下,2:50~100亿,3:100亿以上。"`
+	ViewTotal           int       `description:"总阅读次数"`
+	RoadShowTotal       int       `description:"累计路演次数"`
+	LastViewTime        time.Time `description:"最后一次阅读时间"`
+	PackageType         int       `description:"套餐类型"`
+	IsFormal            int       `description:"是否已经转正式,0是没有转正式,1是已经转过正式"`
+	TodoStatus          string    `description:"任务处理状态;枚举值:'无任务','未完成','已完成'"`
+	TodoCreateTime      time.Time `description:"任务创建时间"`
+	TodoApproveTime     time.Time `description:"任务审批时间"`
+	TryStage            int       `description:"试用客户子标签:1未分类、2  推进、3 跟踪、4 预备"`
+	TryOutDayTotal      int       `description:"客户总试用天数"`
+	CloseReason         string    `description:"关闭原因"`
+	CloseTime           time.Time `description:"关闭时间"`
+	OverseasLabel       int       `description:"海外客户试用子标签:1未分类、2  推进、3 跟踪、4 预备、"`
+	IsOverseas          int       `description:"是否显示在海外客户0:显示,1:不显示"`
+	ShareSellerId       int       `description:"共享销售员id"`
+}
+
+func GetCompanyProductByCompanyIdAndProductId(companyId, productId int) (item *CompanyProduct, err error) {
+	o := orm.NewOrmUsingDB("weekly_report")
+	sql := `SELECT b.* FROM company AS a
+			INNER JOIN company_product AS b ON a.company_id=b.company_id
+			WHERE a.company_id=? AND b.product_id=? LIMIT 1 `
+	err = o.Raw(sql, companyId, productId).QueryRow(&item)
+	return
+}
+
+func GetCompanyProductCount(companyId, productId int) (count int, err error) {
+	sql := ` SELECT COUNT(1) AS count FROM  company_product WHERE company_id = ? AND product_id = ? `
+	o := orm.NewOrmUsingDB("weekly_report")
+	err = o.Raw(sql, companyId, productId).QueryRow(&count)
+	return
+}
+
+func GetCompanyProductDetailByCompanyId(companyId, productId int) (item *CompanyProduct, err error) {
+	sql := ` SELECT * FROM company_product WHERE company_id = ? AND product_id = ?; `
+	o := orm.NewOrmUsingDB("weekly_report")
+	err = o.Raw(sql, companyId, productId).QueryRow(&item)
+	return
+}

+ 2 - 0
models/cygx_yanxuan_special_record.go

@@ -19,6 +19,7 @@ type CygxYanxuanSpecialRecord struct {
 	RegisterPlatform           int       // 来源 1小程序,2:网页
 	YanxuanSpecialId           int       // cygx_yanxuan_special 表主键ID
 	StopTime                   int       // 停留时间
+	PermissionCode             int       // 权限状态,1:有权限,0:无权限
 }
 
 type CygxYanxuanSpecialRecordResp struct {
@@ -91,6 +92,7 @@ type CygxYanxuanSpecialRecordLog struct {
 	RegisterPlatform           int       // 来源 1小程序,2:网页
 	YanxuanSpecialId           int       // cygx_yanxuan_special 表主键ID
 	StopTime                   int       // 停留时间
+	PermissionCode             int       // 权限状态,1:有权限,0:无权限
 }
 
 func AddCygxYanxuanSpecialRecordLog(item *CygxYanxuanSpecialRecordLog) (lastId int64, err error) {

+ 18 - 4
services/activity.go

@@ -729,7 +729,13 @@ func ArticleUserRemind(user *models.WxUserItem, articleDetail *models.ArticleDet
 	}
 	if sellerItemQy != nil {
 		articleId := articleDetail.ArticleId
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if err != nil {
 			err = errors.New("GetWxOpenIdByMobileList, Err: " + e.Error())
 			return err
@@ -743,7 +749,7 @@ func ArticleUserRemind(user *models.WxUserItem, articleDetail *models.ArticleDet
 
 		if articleDetail.ArticleTypeId > 0 {
 			// 类目模版买方研选
-			openIdListMfyx, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
+			openIdListMfyx, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
 			if e != nil {
 				err = errors.New("GetMfyxWxOpenIdByMobileList, Err: " + e.Error())
 				return err
@@ -808,7 +814,15 @@ func ActivityUserRemind(user *models.WxUserItem, activityDetail *models.Activity
 	} else if source == 4 {
 		sourceMsg = "活动报名"
 	}
-	openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+
+	sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+	if e != nil {
+		err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+		return
+	}
+	sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+
+	openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 	if e != nil {
 		err = errors.New("GetUserRecordListByMobile, Err: " + e.Error())
 		return err
@@ -820,7 +834,7 @@ func ActivityUserRemind(user *models.WxUserItem, activityDetail *models.Activity
 	SendWxMsgWithActivityUserRemind(keyword1, keyword2, openIdList, activityDetail.ActivityId)
 
 	// 买方研选类目模版
-	openIdListMfyx, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
+	openIdListMfyx, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
 	keyword1 = utils.TruncateActivityNameString(user.RealName + "-" + user.CompanyName)
 	keyword2 = fmt.Sprint("互动提醒:", sourceMsg)
 	keyword3 := utils.TruncateActivityNameString(activityDetail.ActivityName)

+ 32 - 0
services/admin.go

@@ -1,7 +1,9 @@
 package services
 
 import (
+	"errors"
 	"hongze/hongze_mfyx/models"
+	"hongze/hongze_mfyx/models/company"
 	"hongze/hongze_mfyx/utils"
 )
 
@@ -84,3 +86,33 @@ func GetAdminCheckUserMobileMap(user *models.WxUserItem) (mapItem map[string]str
 	mapItem = mapMobile
 	return
 }
+
+// 根据公司ID获取权益销售、共享销售手机号
+func GetCompanySellerAndShareMobileByRai(companyId int) (mobiles []string, err error) {
+	productDetail, e := company.GetCompanyProductDetailByCompanyId(companyId, 2)
+	if e != nil {
+		err = errors.New("GetCompanyProductDetailByCompanyId, Err: " + e.Error())
+		return
+	}
+
+	var adminIds []int
+	adminIds = append(adminIds, productDetail.SellerId)
+	if productDetail.ShareSellerId > 0 {
+		adminIds = append(adminIds, productDetail.ShareSellerId)
+	}
+
+	listAdmin, e := models.GetAdminByAdminIds(adminIds)
+	if e != nil {
+		err = errors.New("GetAdminByAdminIds, Err: " + e.Error())
+		return
+	}
+
+	mobiles = make([]string, 0)
+	for _, v := range listAdmin {
+		if v.Mobile != "" {
+			mobiles = append(mobiles, v.Mobile)
+		}
+	}
+
+	return
+}

+ 16 - 3
services/cygx_yanxuan_special_company.go

@@ -15,13 +15,24 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 			go utils.SendAlarmMsg(fmt.Sprint("记录用户阅读时长 失败 AddSpecialRecord Err:"+err.Error(), "userId:", user.UserId, "specialId:", specialId), 2)
 		}
 	}()
-	if user.CompanyId <= 1 {
+	if user.CompanyId == 0 {
 		return
 	}
+	//校验研选专栏权限,以及无权限的时候的对应状态码
+	havePower, e := GetYanxuanSpecialDetailUserPower(user)
+	if e != nil {
+		err = errors.New("GetYanxuanSpecialDetailUserPower, Err: " + e.Error())
+		return
+	}
+
+	var permissionCode int
+	if havePower {
+		permissionCode = 1
+	}
+
 	var sellerName string
 	//获取销售信息
 	sellerName, _ = GetSellerName(user)
-
 	if stopTime >= 3 {
 
 		//判断一个用户是否阅读过 某一篇研选专栏
@@ -44,6 +55,7 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 		item.RegisterPlatform = utils.REGISTER_PLATFORM
 		item.YanxuanSpecialId = specialId
 		item.StopTime = stopTime
+		item.PermissionCode = permissionCode
 		_, e = models.AddCygxYanxuanSpecialRecord(item) // 添加历史记录
 		if e != nil {
 			err = errors.New("AddCygxYanxuanSpecialRecord, Err: " + e.Error())
@@ -97,7 +109,8 @@ func AddSpecialRecord(user *models.WxUserItem, specialId, stopTime int) (err err
 	itemLog.RegisterPlatform = utils.REGISTER_PLATFORM
 	itemLog.YanxuanSpecialId = specialId
 	itemLog.StopTime = stopTime
-	_, e := models.AddCygxYanxuanSpecialRecordLog(itemLog) // 添加历史记录
+	itemLog.PermissionCode = permissionCode
+	_, e = models.AddCygxYanxuanSpecialRecordLog(itemLog) // 添加历史记录
 	if e != nil {
 		err = errors.New("AddCygxYanxuanSpecialRecordLog, Err: " + e.Error())
 		return

+ 8 - 1
services/keyword.go

@@ -5,6 +5,7 @@ import (
 	"fmt"
 	"hongze/hongze_mfyx/models"
 	"hongze/hongze_mfyx/utils"
+	"strings"
 	"time"
 )
 
@@ -90,7 +91,13 @@ func SearchKeywordUserRmind(user *models.WxUserItem, keyWord string) (err error)
 		return
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 7 - 1
services/micro_roadshow.go

@@ -939,7 +939,13 @@ func MicroRoadshowVideoUserRmind(user *models.WxUserItem, videoId int) (err erro
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 8 - 1
services/minutes_summary.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hongze_mfyx/models"
 	"hongze/hongze_mfyx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -41,7 +42,13 @@ func MinutesSummaryHistoryUserRmind(user *models.WxUserItem, articleId int) (err
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 5 - 0
services/order.go

@@ -168,6 +168,11 @@ func HandleOrderByWechatPay(itemCallback *WechatPayCallback) {
 		return
 	}
 
+	tradeState, _, _ := GetQueryOrderByOutTradeNo(outTradeNo) //主动查询微信支付信息
+	if tradeState != "SUCCESS" {
+		return
+	}
+
 	go AddCygxOrderPayment(itemCallback) // 记录支付交易信息
 
 	if itemCallback.TradeState != "SUCCESS" { // 回调显示支付不成功,模版消息推送

+ 7 - 1
services/product_interior.go

@@ -280,7 +280,13 @@ func ProductInteriorHistoryUserRmind(user *models.WxUserItem, productInteriorId
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 8 - 1
services/research_summary.go

@@ -6,6 +6,7 @@ import (
 	"hongze/hongze_mfyx/models"
 	"hongze/hongze_mfyx/utils"
 	"strconv"
+	"strings"
 	"time"
 )
 
@@ -41,7 +42,13 @@ func ResearchSummaryHistoryUserRmind(user *models.WxUserItem, articleId int) (er
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetSellerByAdminId, Err: " + e.Error())
 			return

+ 59 - 5
services/wx_category_template_msg.go

@@ -12,6 +12,7 @@ import (
 	"strconv"
 	"strings"
 	"time"
+	"unicode"
 )
 
 type SendWxCategoryTemplate struct {
@@ -470,9 +471,10 @@ func SendReviewCategoryTemplateMsgAdmin(specialId int) (err error) {
 	var keyword3 string
 	var keyword4 string
 	var keyword5 string
-	keyword1 = specialItem.NickName
+	keyword1 = checkNickNameString(specialItem.NickName)
 	keyword2 = specialItem.RealName + "-" + user.CompanyName
-	keyword3 = specialItem.SpecialName
+	keyword2 = utils.TruncateActivityNameString(keyword2)
+	keyword3 = checkSpecialNameString(specialItem.SpecialName)
 	keyword4 = time.Now().Format(utils.FormatDateTimeMinute2)
 	keyword5 = "研选专栏提交了内容待审核"
 	openIdArr := make([]string, 0)
@@ -498,6 +500,46 @@ func SendReviewCategoryTemplateMsgAdmin(specialId int) (err error) {
 	return
 }
 
+func checkNickNameString(s string) string {
+	var trimmedString string
+	hanCount := 0
+	for _, r := range s {
+		if unicode.Is(unicode.Han, r) {
+			trimmedString += string(r)
+			hanCount++
+			if hanCount == 5 {
+				break
+			}
+		} else {
+			return "作者昵称"
+		}
+	}
+	if trimmedString == "" {
+		trimmedString = "作者昵称"
+	}
+	return trimmedString
+}
+
+func checkSpecialNameString(s string) string {
+	var trimmedString string
+	hanCount := 0
+	for _, r := range s {
+		if unicode.Is(unicode.Han, r) {
+			trimmedString += string(r)
+			hanCount++
+			if hanCount == 5 {
+				break
+			}
+		} else {
+			return "专栏名称"
+		}
+	}
+	if trimmedString == "" {
+		trimmedString = "专栏名称"
+	}
+	return trimmedString
+}
+
 // 研选专栏审核完成时,给提交人发送类目模板消息
 func SendWxCategoryMsgSpecialAuthor(specialId, status int) (err error) {
 	defer func() {
@@ -673,7 +715,13 @@ func SendWxCategoryMsgInteractive(user *models.WxUserItem, interactive string, a
 		return err
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetMfyxWxOpenIdByMobileList, Err: " + e.Error())
 			return
@@ -739,7 +787,13 @@ func SearchKeywordUserRmindCategoryMsg(user *models.WxUserItem, keyWord string)
 		return
 	}
 	if sellerItemQy != nil {
-		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sellerItemQy.Mobile)
+		sllerAndShareMobileArr, e := GetCompanySellerAndShareMobileByRai(user.CompanyId) //获取所属销售以及对应销售的手机号
+		if e != nil {
+			err = errors.New("GetCompanySellerAndShareMobileByRai, Err: " + e.Error())
+			return
+		}
+		sllerAndShareMobiles := strings.Join(sllerAndShareMobileArr, ",")
+		openIdList, e := models.GetMfyxWxOpenIdByMobileList(sllerAndShareMobiles)
 		if e != nil {
 			err = errors.New("GetMfyxWxOpenIdByMobileList, Err: " + e.Error())
 			return
@@ -942,7 +996,7 @@ func SendWxCategoryMsgWxPay(orderDetail *order.CygxOrder) (err error) {
 	}
 
 	if adminId > 0 {
-		adminDetail, e := models.GetSellerByAdminId(orderDetail.ShareId)
+		adminDetail, e := models.GetSellerByAdminId(adminId)
 		if e != nil {
 			err = errors.New("GetYanxuanSpecialFollowUserById, Err: " + e.Error())
 			return

+ 111 - 0
services/wx_pay.go

@@ -142,3 +142,114 @@ func WxDecodeNotify(body []byte) (wechatPayCallback *WechatPayCallback) {
 	wechatPayCallback = datamap
 	return
 }
+
+// Transaction
+type Transaction struct {
+	Amount          TransactionAmount `json:"amount,omitempty"`
+	Appid           string            `json:"appid,omitempty"`
+	Attach          string            `json:"attach,omitempty"`
+	BankType        string            `json:"bank_type,omitempty"`
+	Mchid           string            `json:"mchid,omitempty"`
+	OutTradeNo      string            `json:"out_trade_no,omitempty"`
+	Payer           TransactionPayer  `json:"payer,omitempty"`
+	PromotionDetail []PromotionDetail `json:"promotion_detail,omitempty"`
+	SuccessTime     time.Time         `json:"success_time,omitempty"`
+	TradeState      string            `json:"trade_state,omitempty"`
+	TradeStateDesc  string            `json:"trade_state_desc,omitempty"`
+	TradeType       string            `json:"trade_type,omitempty"`
+	TransactionId   string            `json:"transaction_id,omitempty"`
+}
+
+// TransactionAmount
+type TransactionAmount struct {
+	Currency      string `json:"currency,omitempty"`
+	PayerCurrency string `json:"payer_currency,omitempty"`
+	PayerTotal    int64  `json:"payer_total,omitempty"`
+	Total         int64  `json:"total,omitempty"`
+}
+
+// PromotionDetail
+type PromotionDetail struct {
+	// 券ID
+	CouponId *string `json:"coupon_id,omitempty"`
+	// 优惠名称
+	Name *string `json:"name,omitempty"`
+	// GLOBAL:全场代金券;SINGLE:单品优惠
+	Scope *string `json:"scope,omitempty"`
+	// CASH:充值;NOCASH:预充值。
+	Type *string `json:"type,omitempty"`
+	// 优惠券面额
+	Amount *int64 `json:"amount,omitempty"`
+	// 活动ID,批次ID
+	StockId *string `json:"stock_id,omitempty"`
+	// 单位为分
+	WechatpayContribute *int64 `json:"wechatpay_contribute,omitempty"`
+	// 单位为分
+	MerchantContribute *int64 `json:"merchant_contribute,omitempty"`
+	// 单位为分
+	OtherContribute *int64 `json:"other_contribute,omitempty"`
+	// CNY:人民币,境内商户号仅支持人民币。
+	Currency    *string                `json:"currency,omitempty"`
+	GoodsDetail []PromotionGoodsDetail `json:"goods_detail,omitempty"`
+}
+
+// PromotionGoodsDetail
+type PromotionGoodsDetail struct {
+	// 商品编码
+	GoodsId *string `json:"goods_id"`
+	// 商品数量
+	Quantity *int64 `json:"quantity"`
+	// 商品价格
+	UnitPrice *int64 `json:"unit_price"`
+	// 商品优惠金额
+	DiscountAmount *int64 `json:"discount_amount"`
+	// 商品备注
+	GoodsRemark *string `json:"goods_remark,omitempty"`
+}
+
+// TransactionPayer
+type TransactionPayer struct {
+	Openid string `json:"openid,omitempty"`
+}
+
+// 根据订单号查询订单状态
+func GetQueryOrderByOutTradeNo(outTradeNo string) (tradeState string, statusCode int, itemResp *Transaction) {
+	var err error
+	defer func() {
+		if err != nil {
+			fmt.Println("err", err)
+			go utils.SendAlarmMsg(fmt.Sprint("根据订单号查询订单状态 失败 GetQueryOrderByOutTradeNo, err:", err.Error(), "outTradeNo", outTradeNo), 2)
+		}
+	}()
+	ctx := context.Background()
+	svc := jsapi.JsapiApiService{Client: utils.WechatCertClient}
+	resp, result, err := svc.QueryOrderByOutTradeNo(ctx,
+		jsapi.QueryOrderByOutTradeNoRequest{
+			OutTradeNo: core.String(outTradeNo),
+			Mchid:      core.String(utils.Mchid),
+		},
+	)
+	statusCode = result.Response.StatusCode
+
+	//订单状态码不存在直接返回
+	if statusCode == 404 {
+		err = nil
+		return
+	}
+	tradeState = *resp.TradeState
+	data, err := json.Marshal(resp)
+	if err != nil {
+		return
+	}
+	jsonstr := string(data)
+	//item := new(Transaction)
+	if err = json.Unmarshal([]byte(jsonstr), &itemResp); err != nil {
+		return
+	}
+	//utils.FileLog.Info(jsonstr)
+	////itemResp = item
+	//fmt.Println(itemResp)
+	//fmt.Println(tradeState)
+	//fmt.Println(itemResp.TransactionId)
+	return
+}

+ 18 - 2
utils/common.go

@@ -948,10 +948,26 @@ func InterceptHtmlLength(body string, length int) (newbody string) {
 		return
 	}
 	bodyText := doc.Text()
-	if len(bodyText) < length {
+	//if len(bodyText) < length {
+	//	length = len(bodyText)
+	//}
+	//newbody = bodyText[0:length]
+
+	totalCharCount := utf8.RuneCountInString(bodyText)
+	if totalCharCount < length {
 		length = len(bodyText)
 	}
-	newbody = bodyText[0:length]
+	// 计算前15个汉字所需的字节位置
+	hanziCount := 0
+	byteIndex := 0
+	for byteIndex < len(bodyText) && hanziCount < length {
+		r, size := utf8.DecodeRuneInString(bodyText[byteIndex:])
+		if r != utf8.RuneError {
+			hanziCount++
+		}
+		byteIndex += size
+	}
+	newbody = bodyText[:byteIndex] + "…"
 	return
 }