|
|
@@ -10,6 +10,7 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"github.com/gogf/gf/container/garray"
|
|
|
+ "github.com/gogf/gf/text/gstr"
|
|
|
"github.com/gogf/gf/util/gvalid"
|
|
|
"math"
|
|
|
"strconv"
|
|
|
@@ -298,13 +299,22 @@ func (s *CustomerService) Import(ctx context.Context, req *contract.ExcelImportR
|
|
|
}
|
|
|
//客户类型
|
|
|
idyMap, err := service.GetDictDataByType(ctx, "cust_idy")
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
idyMap = reverseMap(idyMap)
|
|
|
//客户来源
|
|
|
sourceMap, err := service.GetDictDataByType(ctx, "cust_source")
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
sourceMap = reverseMap(sourceMap)
|
|
|
|
|
|
//关键字
|
|
|
keywordsMap, err := service.GetDictDataByType(ctx, "customer_bidding_keywords")
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
keywordsMap = reverseMap(keywordsMap)
|
|
|
svc, err := sbase.NewDistrictService(ctx)
|
|
|
treeList, err := svc.GetProvincesList(0)
|
|
|
@@ -331,12 +341,17 @@ func (s *CustomerService) Import(ctx context.Context, req *contract.ExcelImportR
|
|
|
var city *base.ProvincesTree
|
|
|
var region *base.ProvincesTree
|
|
|
|
|
|
- keywords := strings.Split(data.Keyword, ",")
|
|
|
- for _, keyword := range keywords {
|
|
|
- if _, ok := keywordsMap[keyword]; !ok {
|
|
|
- return myerrors.TipsError(fmt.Sprintf("关键字 %s 不存在", keyword))
|
|
|
+ keywords := []string{}
|
|
|
+ data.Keyword = gstr.Trim(data.Keyword)
|
|
|
+ if data.Keyword != "" && data.Keyword != "无" && data.Keyword != "-" {
|
|
|
+ keywords = strings.Split(data.Keyword, ",")
|
|
|
+ for _, keyword := range keywords {
|
|
|
+ if _, ok := keywordsMap[keyword]; !ok {
|
|
|
+ return myerrors.TipsError(fmt.Sprintf("关键字 %s 不存在", keyword))
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
if data.CustProvince == "" {
|
|
|
return myerrors.TipsError("客户省份不能为空")
|
|
|
}
|
|
|
@@ -385,26 +400,29 @@ func (s *CustomerService) Import(ctx context.Context, req *contract.ExcelImportR
|
|
|
return err
|
|
|
}
|
|
|
s.CreateDynamics("创建客户", req, id)
|
|
|
+ data.CuctName = gstr.Trim(data.CuctName)
|
|
|
+ if data.CuctName != "无" && data.CuctName != "" {
|
|
|
+ seq := model.CustCustomerContactSeq{
|
|
|
+ CustId: int(id),
|
|
|
+ CuctName: data.CuctName,
|
|
|
+ CuctGender: genderMap[data.CuctGender],
|
|
|
+ Telephone: data.Telephone,
|
|
|
+ Wechat: data.Wechat,
|
|
|
+ Email: data.Email,
|
|
|
+ Dept: data.Dept,
|
|
|
+ Postion: data.Postion,
|
|
|
+ OfficeLocation: data.OfficeLocation,
|
|
|
+ IsDecision: yesOrNoMap[data.IsDecision],
|
|
|
+ Remark: data.ContactRemark,
|
|
|
+ }
|
|
|
+ err = contactService.Create(&seq)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
|
|
|
- seq := model.CustCustomerContactSeq{
|
|
|
- CustId: int(id),
|
|
|
- CuctName: data.CuctName,
|
|
|
- CuctGender: genderMap[data.CuctGender],
|
|
|
- Telephone: data.Telephone,
|
|
|
- Wechat: data.Wechat,
|
|
|
- Email: data.Email,
|
|
|
- Dept: data.Dept,
|
|
|
- Postion: data.Postion,
|
|
|
- OfficeLocation: data.OfficeLocation,
|
|
|
- IsDecision: yesOrNoMap[data.IsDecision],
|
|
|
- Remark: data.ContactRemark,
|
|
|
- }
|
|
|
- err = contactService.Create(&seq)
|
|
|
- if err != nil {
|
|
|
- return err
|
|
|
+ CustomerService.CreateDynamics("创建联系人", req, gconv.Int64(seq.CustId))
|
|
|
}
|
|
|
|
|
|
- CustomerService.CreateDynamics("创建联系人", req, gconv.Int64(seq.CustId))
|
|
|
}
|
|
|
return nil
|
|
|
})
|