|
@@ -2,14 +2,17 @@ package user
|
|
|
|
|
|
import (
|
|
import (
|
|
"errors"
|
|
"errors"
|
|
|
|
+ userReq "hongze/hongze_yb/models/request/user"
|
|
"hongze/hongze_yb/models/tables/chart_permission"
|
|
"hongze/hongze_yb/models/tables/chart_permission"
|
|
"hongze/hongze_yb/models/tables/company"
|
|
"hongze/hongze_yb/models/tables/company"
|
|
"hongze/hongze_yb/models/tables/company_product"
|
|
"hongze/hongze_yb/models/tables/company_product"
|
|
"hongze/hongze_yb/models/tables/rddp/msg_code"
|
|
"hongze/hongze_yb/models/tables/rddp/msg_code"
|
|
|
|
+ "hongze/hongze_yb/models/tables/yb_apply_record"
|
|
"hongze/hongze_yb/services"
|
|
"hongze/hongze_yb/services"
|
|
companyService "hongze/hongze_yb/services/company"
|
|
companyService "hongze/hongze_yb/services/company"
|
|
"hongze/hongze_yb/services/user"
|
|
"hongze/hongze_yb/services/user"
|
|
"hongze/hongze_yb/utils"
|
|
"hongze/hongze_yb/utils"
|
|
|
|
+ "strings"
|
|
"time"
|
|
"time"
|
|
)
|
|
)
|
|
|
|
|
|
@@ -185,17 +188,76 @@ func GetUserInfo(userInfo user.UserInfo) (userDetail Detail, err error, errMsg s
|
|
}
|
|
}
|
|
|
|
|
|
type Record struct {
|
|
type Record struct {
|
|
- //BusinessCardURL string `gorm:"column:business_card_url;type:varchar(255);default:''" json:"businessCardUrl"` // 名片
|
|
|
|
- //RealName string `gorm:"column:real_name;type:varchar(100);default:''" json:"realName"` // 姓名
|
|
|
|
- //CompanyName string `gorm:"column:company_name;type:varchar(255);default:''" json:"companyName"` // 客户备注的公司名称
|
|
|
|
- //Mobile string `gorm:"column:mobile;type:varchar(20);default:''" json:"mobile"` // 手机号
|
|
|
|
- BusinessCardURL string `json:"business_card_url"`
|
|
|
|
|
|
+ BusinessCardURL string `json:"business_card_url" description:"名片"`
|
|
|
|
+ RealName string `json:"real_name" description:"姓名"`
|
|
|
|
+ CompanyName string `json:"company_name" description:"客户备注的公司名称"`
|
|
|
|
+ Mobile string `json:"mobile" description:"手机号"`
|
|
}
|
|
}
|
|
|
|
|
|
-//func GetLastApplyInfo(userId int) {
|
|
|
|
-// record, err := yb_apply_record.GetLastNotOpRecordByUserId(userId)
|
|
|
|
-// if err != nil {
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
-//
|
|
|
|
-//}
|
|
|
|
|
|
+// GetLastApplyInfo 获取最近的一套申请记录
|
|
|
|
+func GetLastApplyInfo(userId int) (record Record, err error) {
|
|
|
|
+ recordInfo, err := yb_apply_record.GetLastNotOpRecordByUserId(userId)
|
|
|
|
+ if err != nil {
|
|
|
|
+ if err == utils.ErrNoRow {
|
|
|
|
+ err = nil
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ record = Record{
|
|
|
|
+ BusinessCardURL: recordInfo.BusinessCardURL,
|
|
|
|
+ RealName: recordInfo.RealName,
|
|
|
|
+ CompanyName: recordInfo.CompanyName,
|
|
|
|
+ Mobile: recordInfo.Mobile,
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+// Apply 客户申请
|
|
|
|
+func Apply(userId int, companyId int64, mobile, email string, applyInfo userReq.ApplyReq) (ybApplyRecord Record, err error) {
|
|
|
|
+ sellerName := ``
|
|
|
|
+ status := `潜在客户`
|
|
|
|
+ companyName := applyInfo.CompanyName
|
|
|
|
+
|
|
|
|
+ if companyId > 1 {
|
|
|
|
+ //客户信息
|
|
|
|
+ companyInfo, tmpErr := company.GetByCompanyId(companyId)
|
|
|
|
+ if tmpErr != nil {
|
|
|
|
+ err = tmpErr
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ companyName = companyInfo.CompanyName
|
|
|
|
+
|
|
|
|
+ //客户产品权限
|
|
|
|
+ companyProductList, tmpErr := company_product.GetListByCompanyId(companyId)
|
|
|
|
+ if tmpErr != nil {
|
|
|
|
+ err = tmpErr
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ sellerNameList := make([]string, 0)
|
|
|
|
+ statusList := make([]string, 0)
|
|
|
|
+ for _, companyProduct := range companyProductList {
|
|
|
|
+ sellerNameList = append(sellerNameList, companyProduct.SellerName)
|
|
|
|
+ statusList = append(statusList, companyProduct.Status)
|
|
|
|
+ }
|
|
|
|
+ if len(sellerNameList) > 0 && len(statusList) > 0 {
|
|
|
|
+ sellerName = strings.Join(sellerNameList, ",")
|
|
|
|
+ status = strings.Join(statusList, ",")
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ ybApplyRecord := &yb_apply_record.YbApplyRecord{
|
|
|
|
+ UserID: userId,
|
|
|
|
+ BusinessCardURL: applyInfo.BusinessCardUrl,
|
|
|
|
+ RealName: applyInfo.RealName,
|
|
|
|
+ CompanyName: applyInfo.CompanyName,
|
|
|
|
+ Mobile: mobile,
|
|
|
|
+ Email: email,
|
|
|
|
+ Permission: applyInfo.Permission,
|
|
|
|
+ SellerName: sellerName,
|
|
|
|
+ Status: status,
|
|
|
|
+ CompanyIDPay: int(companyId),
|
|
|
|
+ CompanyNamePay: companyName,
|
|
|
|
+ CreateTime: time.Now(),
|
|
|
|
+ }
|
|
|
|
+ err = ybApplyRecord.Create()
|
|
|
|
+ return
|
|
|
|
+}
|