123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- package price_driven
- import (
- "errors"
- "hongze/hongze_yb/models/response"
- "hongze/hongze_yb/models/tables/company_product"
- "hongze/hongze_yb/models/tables/yb_price_driven"
- "hongze/hongze_yb/models/tables/yb_price_driven_visit_log"
- "hongze/hongze_yb/services/user"
- "hongze/hongze_yb/utils"
- )
- // GetPriceDrivenDetail 获取价格驱动详情
- func GetPriceDrivenDetail(chartPermissionId int) (resp *response.PriceDrivenItem, errMsg string, err error) {
- resp = new(response.PriceDrivenItem)
- // 获取详情
- item, e := yb_price_driven.GetPriceDrivenByChartPermissionId(chartPermissionId)
- if e != nil && e != utils.ErrNoRow {
- errMsg = "获取失败"
- err = errors.New("获取价格驱动信息失败, Err:" + e.Error())
- return
- }
- if item != nil {
- resp.PriceDrivenID = item.PriceDrivenID
- resp.ChartPermissionID = item.ChartPermissionID
- resp.MainVariable = item.MainVariable
- resp.CoreDrivenType = item.CoreDrivenType
- resp.CoreDrivenContent = item.CoreDrivenContent
- resp.CoreContent = item.CoreContent
- resp.CreateTime = item.CreateTime.Format(utils.FormatDateTime)
- resp.ModifyTime = item.ModifyTime.Format(utils.FormatDateTime)
- }
- return
- }
- // SavePriceDrivenVisitLog 保存价格驱动访问记录
- func SavePriceDrivenVisitLog(priceDrivenId, sourceAgent int, userInfo user.UserInfo) (errMsg string, err error) {
- companyInfo, e := company_product.GetByCompany2ProductId(userInfo.CompanyID, 1)
- if e != nil && e != utils.ErrNoRow {
- errMsg = "保存失败"
- err = errors.New("获取客户信息失败, Err: " + e.Error())
- return
- }
- var companyName, companyStatus string
- if companyInfo != nil {
- companyName = companyInfo.CompanyName
- companyStatus = companyInfo.Status
- } else {
- // 是否是权益用户-视作潜在用户
- equityCompany, e := company_product.GetByCompany2ProductId(userInfo.CompanyID, 2)
- if e != nil && e != utils.ErrNoRow {
- errMsg = "保存失败"
- err = errors.New("获取客户权益信息失败, Err: " + e.Error())
- return
- }
- if equityCompany != nil {
- companyName = equityCompany.CompanyName
- companyStatus = "潜在"
- }
- }
- logItem := &yb_price_driven_visit_log.YbPriceDrivenVisitLog{
- PriceDrivenID: priceDrivenId,
- UserID: int(userInfo.UserID),
- Mobile: userInfo.Mobile,
- RealName: userInfo.RealName,
- NickName: userInfo.NickName,
- CompanyID: int(userInfo.CompanyID),
- CompanyName: companyName,
- CompanyStatus: companyStatus,
- SourceAgent: sourceAgent,
- }
- if e := logItem.Create(); e != nil {
- errMsg = "保存失败"
- err = errors.New("新增价格驱动访问记录失败, Err: " + e.Error())
- return
- }
- return
- }
|