更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -13,8 +13,6 @@ import (
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
// resolveUserName 按租户 + 用户ID 解析用户显示名(优先真实姓名,退化到账号,最后退化到登录名)。
|
||||
// 注意:JWT 里的 Username 是登录账号,直接存会导致前端"负责人"显示成账号。
|
||||
func resolveUserName(claims *jwtutil.Claims) string {
|
||||
if claims == nil {
|
||||
return ""
|
||||
@@ -30,40 +28,29 @@ func resolveUserName(claims *jwtutil.Claims) string {
|
||||
return claims.Username
|
||||
}
|
||||
|
||||
// CRM 业务管线(线索/商机/项目/回访)公共辅助方法。
|
||||
// related_type 约定:1=线索 2=商机 3=项目
|
||||
|
||||
// pipelineClaims 解析租户端后台 JWT。
|
||||
// CRM 管线接口只挂在 /backend/** 下(平台端无对应路由、平台前端也不调),
|
||||
// 此前顺带放行 platform 等于让平台令牌能读写租户的商机与投标数据。
|
||||
func pipelineClaims(c *beego.Controller) (*jwtutil.Claims, error) {
|
||||
return identity.Claims(c.Ctx.Request.Header.Get("Authorization"), identity.EndBackend)
|
||||
}
|
||||
|
||||
// pipelineOk 统一成功响应。
|
||||
func pipelineOk(c *beego.Controller, data interface{}) {
|
||||
c.Data["json"] = map[string]interface{}{"code": 200, "msg": "success", "data": data}
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
// pipelineErr 统一错误响应。
|
||||
func pipelineErr(c *beego.Controller, httpStatus, bizCode int, msg string) {
|
||||
c.Ctx.Output.SetStatus(httpStatus)
|
||||
c.Data["json"] = map[string]interface{}{"code": bizCode, "msg": msg}
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
// pipelineTenantID 返回当前租户ID字符串。
|
||||
func pipelineTenantID(claims *jwtutil.Claims) string {
|
||||
return fmt.Sprintf("%d", claims.TenantId)
|
||||
}
|
||||
|
||||
// pipelineUID 返回当前用户ID字符串。
|
||||
func pipelineUID(claims *jwtutil.Claims) string {
|
||||
return fmt.Sprintf("%d", claims.UserID)
|
||||
}
|
||||
|
||||
// parsePipelineDateTime 解析时间:支持 "2006-01-02 15:04:05"、"2006-01-02T15:04:05"、"2006-01-02"。
|
||||
func parsePipelineDateTime(s string) *time.Time {
|
||||
s = strings.TrimSpace(s)
|
||||
if s == "" {
|
||||
@@ -71,8 +58,6 @@ func parsePipelineDateTime(s string) *time.Time {
|
||||
}
|
||||
layouts := []string{
|
||||
"2006-01-02 15:04:05",
|
||||
// 带时区偏移的 RFC3339:前端编辑时回显的是后端 JSON 序列化的 time.Time
|
||||
// (如 2026-09-12T00:00:00+08:00),缺此布局会解析失败导致日期被写空。
|
||||
time.RFC3339Nano,
|
||||
time.RFC3339,
|
||||
"2006-01-02T15:04:05",
|
||||
@@ -88,7 +73,6 @@ func parsePipelineDateTime(s string) *time.Time {
|
||||
return nil
|
||||
}
|
||||
|
||||
// parsePipelineDate 解析日期(仅取年月日,返回当天零点)。
|
||||
func parsePipelineDate(s string) *time.Time {
|
||||
s = strings.TrimSpace(s)
|
||||
if s == "" {
|
||||
@@ -100,7 +84,6 @@ func parsePipelineDate(s string) *time.Time {
|
||||
return parsePipelineDateTime(s)
|
||||
}
|
||||
|
||||
// crmWriteLog 写入 CRM 操作日志(失败静默忽略,不影响主流程)。
|
||||
func crmWriteLog(tenantID string, relatedType int8, relatedID uint64, action, content string, claims *jwtutil.Claims) {
|
||||
if models.Orm == nil || relatedID == 0 {
|
||||
return
|
||||
@@ -123,7 +106,6 @@ func crmWriteLog(tenantID string, relatedType int8, relatedID uint64, action, co
|
||||
_, _ = models.Orm.Insert(&log)
|
||||
}
|
||||
|
||||
// relatedTypeText 关联类型文案。
|
||||
func relatedTypeText(t int8) string {
|
||||
switch t {
|
||||
case 1:
|
||||
@@ -137,7 +119,6 @@ func relatedTypeText(t int8) string {
|
||||
}
|
||||
}
|
||||
|
||||
// mobileInMobiles 判断手机号是否已存在于 mobiles(JSON 数组或普通字符串)中。
|
||||
func mobileInMobiles(mobile, mobiles string) bool {
|
||||
mobile = strings.TrimSpace(mobile)
|
||||
if mobile == "" || strings.TrimSpace(mobiles) == "" {
|
||||
@@ -149,8 +130,6 @@ func mobileInMobiles(mobile, mobiles string) bool {
|
||||
return strings.Contains(mobiles, mobile)
|
||||
}
|
||||
|
||||
// entityContactMobiles 过程库联系人的手机号集合(JSON 数组字符串):
|
||||
// 优先取新的 mobiles 字段,缺省时回退旧的单个 mobile。
|
||||
func entityContactMobiles(src models.TenantCrmEntityContact) string {
|
||||
if s := strings.TrimSpace(src.Mobiles); s != "" {
|
||||
return s
|
||||
@@ -158,7 +137,6 @@ func entityContactMobiles(src models.TenantCrmEntityContact) string {
|
||||
return buildMobiles(src.Mobile)
|
||||
}
|
||||
|
||||
// mobilesMatched 判断两组手机号是否有交集(JSON 数组或分隔符字符串)
|
||||
func mobilesMatched(a, b string) bool {
|
||||
for _, x := range splitMobiles(a) {
|
||||
if x == "" {
|
||||
@@ -173,7 +151,6 @@ func mobilesMatched(a, b string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
// mergeCompanyContact 合并过程库联系人到正式库联系人:仅补齐正式库空缺字段,不覆盖已有数据。
|
||||
func mergeCompanyContact(dst *models.ErpCompanyContact, src models.TenantCrmEntityContact) {
|
||||
changed := false
|
||||
if dst.Wechat == "" && strings.TrimSpace(src.Wechat) != "" {
|
||||
@@ -212,10 +189,6 @@ func mergeCompanyContact(dst *models.ErpCompanyContact, src models.TenantCrmEnti
|
||||
}
|
||||
}
|
||||
|
||||
// syncContactsToCompany 把线索/商机过程库(yz_tenant_crm_entity_contact)的联系人
|
||||
// 去重同步到正式公司联系人库(yz_backend_contact_company,company_type=customer)。
|
||||
// 去重键:company_type + company_id + name + mobile;命中则补齐字段,否则新增。
|
||||
// 返回 (新增数, 合并数)。
|
||||
func syncContactsToCompany(tenantID string, customerID uint64, contacts []models.TenantCrmEntityContact) (int, int) {
|
||||
if models.Orm == nil || customerID == 0 || len(contacts) == 0 {
|
||||
return 0, 0
|
||||
@@ -229,7 +202,6 @@ func syncContactsToCompany(tenantID string, customerID uint64, contacts []models
|
||||
}
|
||||
mobiles := entityContactMobiles(src)
|
||||
mobile := firstMobile(mobiles)
|
||||
// 本次待同步集合内去重(同名同手机只处理一次)
|
||||
key := name + "|" + mobile
|
||||
if seen[key] {
|
||||
continue
|
||||
@@ -247,7 +219,6 @@ func syncContactsToCompany(tenantID string, customerID uint64, contacts []models
|
||||
|
||||
matched := false
|
||||
for i := range existingList {
|
||||
// 有手机号时手机号需有交集才视为同一人;无手机号时按同名视为同一人
|
||||
if mobile == "" || mobilesMatched(mobiles, existingList[i].Mobiles) {
|
||||
mergeCompanyContact(&existingList[i], src)
|
||||
merged++
|
||||
@@ -283,25 +254,18 @@ func syncContactsToCompany(tenantID string, customerID uint64, contacts []models
|
||||
return inserted, merged
|
||||
}
|
||||
|
||||
// relatedRef 关联对象引用(related_type + related_id)
|
||||
type relatedRef struct {
|
||||
Type int8
|
||||
ID uint64
|
||||
}
|
||||
|
||||
// relatedChain 返回详情页需要展示的关联链路(上游 + 自身),顺序:线索 → 商机 → 项目。
|
||||
// 线索 → [线索]
|
||||
// 商机 → [线索, 商机]
|
||||
// 项目 → [线索, 商机, 项目]
|
||||
// 过程数据(联系人 / 跟进记录 / 附件)只存在创建时的对象上、不做搬迁,
|
||||
// 由上层按链路累积查询,从而在商机里能看到线索阶段的数据,在项目里能看到全部阶段的数据。
|
||||
func relatedChain(tenantID string, relatedType int8, relatedID uint64) []relatedRef {
|
||||
if models.Orm == nil || relatedID == 0 {
|
||||
return []relatedRef{{Type: relatedType, ID: relatedID}}
|
||||
}
|
||||
refs := make([]relatedRef, 0, 3)
|
||||
switch relatedType {
|
||||
case 2: // 商机:来源线索 + 自身
|
||||
case 2:
|
||||
var biz models.TenantCrmBusiness
|
||||
if err := models.Orm.QueryTable(new(models.TenantCrmBusiness)).
|
||||
Filter("id", relatedID).Filter("tenant_id", tenantID).
|
||||
@@ -311,7 +275,7 @@ func relatedChain(tenantID string, relatedType int8, relatedID uint64) []related
|
||||
}
|
||||
}
|
||||
refs = append(refs, relatedRef{Type: 2, ID: relatedID})
|
||||
case 3: // 项目:来源商机 + 商机的来源线索 + 自身
|
||||
case 3:
|
||||
var proj models.TenantCrmProject
|
||||
if err := models.Orm.QueryTable(new(models.TenantCrmProject)).
|
||||
Filter("id", relatedID).Filter("tenant_id", tenantID).
|
||||
@@ -329,13 +293,12 @@ func relatedChain(tenantID string, relatedType int8, relatedID uint64) []related
|
||||
}
|
||||
}
|
||||
refs = append(refs, relatedRef{Type: 3, ID: relatedID})
|
||||
default: // 线索:仅自身
|
||||
default:
|
||||
refs = append(refs, relatedRef{Type: relatedType, ID: relatedID})
|
||||
}
|
||||
return refs
|
||||
}
|
||||
|
||||
// attachBusinessName 批量填充项目的「来源商机名称」(非表字段,仅用于展示)。
|
||||
func attachBusinessName(tenantID string, list []models.TenantCrmProject) {
|
||||
ids := make([]uint64, 0, len(list))
|
||||
seen := map[uint64]bool{}
|
||||
@@ -365,7 +328,6 @@ func attachBusinessName(tenantID string, list []models.TenantCrmProject) {
|
||||
}
|
||||
}
|
||||
|
||||
// attachClueName 批量填充商机的「来源线索名称」(非表字段,仅用于展示)。
|
||||
func attachClueName(tenantID string, list []models.TenantCrmBusiness) {
|
||||
ids := make([]uint64, 0, len(list))
|
||||
seen := map[uint64]bool{}
|
||||
@@ -395,4 +357,3 @@ func attachClueName(tenantID string, list []models.TenantCrmBusiness) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user