|
|
@@ -26,6 +26,7 @@ import (
|
|
|
"github.com/gogf/gf/os/gtime"
|
|
|
"github.com/gogf/gf/util/gconv"
|
|
|
"github.com/mozillazg/go-pinyin"
|
|
|
+ excelizev2 "github.com/xuri/excelize/v2"
|
|
|
|
|
|
"dashoo.cn/micro/app/dao/cust"
|
|
|
platdao "dashoo.cn/micro/app/dao/plat"
|
|
|
@@ -240,6 +241,43 @@ func reverseMap(originalMap map[string]string) map[string]string {
|
|
|
return reversedMap
|
|
|
}
|
|
|
|
|
|
+var contactExcelHeader = []partner.ExcelHeader{
|
|
|
+ {Name: "*客户名称", Width: 30},
|
|
|
+ {Name: "助计名", Width: 30},
|
|
|
+ {Name: "*客户类型", Width: 30},
|
|
|
+ {Name: "*客户来源", Width: 30},
|
|
|
+ {Name: "所在省", Width: 30},
|
|
|
+ {Name: "所在市", Width: 30},
|
|
|
+ {Name: "所在区县", Width: 30},
|
|
|
+ {Name: "详细地址", Width: 30},
|
|
|
+ {Name: "招标关键字(以逗号分隔)", Width: 40},
|
|
|
+ {Name: "备注", Width: 30},
|
|
|
+ {Name: "*联系人姓名", Width: 30},
|
|
|
+ {Name: "*联系人性别", Width: 30},
|
|
|
+ {Name: "*联系人电话", Width: 30},
|
|
|
+ {Name: "联系人微信", Width: 30},
|
|
|
+ {Name: "联系人邮箱", Width: 30},
|
|
|
+ {Name: "联系人部门", Width: 30},
|
|
|
+ {Name: "*联系人职位", Width: 30},
|
|
|
+ {Name: "联系人办公地点", Width: 30},
|
|
|
+ {Name: "*关键决策人(是/否)", Width: 30},
|
|
|
+ {Name: "联系人备注", Width: 30},
|
|
|
+}
|
|
|
+
|
|
|
+func ExcelTemplate() (*excelizev2.File, error) {
|
|
|
+ tempData := [][]string{
|
|
|
+ {
|
|
|
+ "张三", "张三(备注)", "医院", "经销商", "北京市", "北京市", "朝阳区", "ffff", "20387,生物样本库", "备注",
|
|
|
+ "李四", "男", "18000000000", "weixin", "abc@163.com", "部门", "职务", "办公地点", "否", "联系人备注",
|
|
|
+ },
|
|
|
+ }
|
|
|
+ excel, err := partner.NewExcel(contactExcelHeader, tempData)
|
|
|
+ if err != nil {
|
|
|
+ return nil, err
|
|
|
+ }
|
|
|
+ return excel, nil
|
|
|
+}
|
|
|
+
|
|
|
// Create 导入客户
|
|
|
func (s *CustomerService) Import(ctx context.Context, req *contract.ExcelImportReq) (err error) {
|
|
|
validErr := gvalid.CheckStruct(ctx, req, nil)
|
|
|
@@ -253,7 +291,7 @@ func (s *CustomerService) Import(ctx context.Context, req *contract.ExcelImportR
|
|
|
return myerrors.TipsError(fmt.Sprintf("下载 excel 异常 %s", err.Error()))
|
|
|
}
|
|
|
|
|
|
- // 解析excel,构造销售目标数据
|
|
|
+ // 解析excel
|
|
|
excelData, err := s.parseExcel(buf)
|
|
|
if err != nil {
|
|
|
return myerrors.TipsError(fmt.Sprintf("解析 excel 异常 %s", err.Error()))
|
|
|
@@ -270,8 +308,6 @@ func (s *CustomerService) Import(ctx context.Context, req *contract.ExcelImportR
|
|
|
keywordsMap = reverseMap(keywordsMap)
|
|
|
svc, err := sbase.NewDistrictService(ctx)
|
|
|
treeList, err := svc.GetProvincesList(0)
|
|
|
- fmt.Println("treeList", treeList)
|
|
|
- //insertContactList := make([]*model.CustCustomerContactSeq, 0)
|
|
|
contactService, err := NewCustomerContactService(ctx)
|
|
|
if err != nil {
|
|
|
return err
|
|
|
@@ -295,7 +331,7 @@ func (s *CustomerService) Import(ctx context.Context, req *contract.ExcelImportR
|
|
|
var city *base.ProvincesTree
|
|
|
var region *base.ProvincesTree
|
|
|
|
|
|
- keywords := strings.Split(data.Keyword, ",")
|
|
|
+ keywords := strings.Split(data.Keyword, ",")
|
|
|
for _, keyword := range keywords {
|
|
|
if _, ok := keywordsMap[keyword]; !ok {
|
|
|
return myerrors.TipsError(fmt.Sprintf("关键字 %s 不存在", keyword))
|
|
|
@@ -388,18 +424,18 @@ func (s CustomerService) parseExcel(b []byte) ([]*model.CustomerAddImport, error
|
|
|
return nil, err
|
|
|
}
|
|
|
|
|
|
- // 客户名称 助计名 所在地区 详细地址 所在省 所在市 所在区县 客户行业 客户级别 客户来源 备注 销售名称 开票抬头 关联客户 姓名 性别 电话 微信 邮箱 部门 职位 办公地点 是否关键决策人 招标关键字
|
|
|
+ // 客户名称 助计名 客户类型 客户来源 所在省 所在市 所在区县 详细地址 招标关键字 备注 姓名 性别 电话 微信 邮箱 部门 职位 办公地点 是否关键决策人 联系人备注
|
|
|
var saleTargets []*model.CustomerAddImport
|
|
|
for _, row := range rows[1:] {
|
|
|
temp := &model.CustomerAddImport{
|
|
|
CustName: row[0],
|
|
|
AbbrName: row[1],
|
|
|
- CustAddress: row[2],
|
|
|
- CustProvince: row[3],
|
|
|
- CustCity: row[4],
|
|
|
- CustRegion: row[5],
|
|
|
- CustIndustry: row[6],
|
|
|
- CustSource: row[7],
|
|
|
+ CustIndustry: row[2],
|
|
|
+ CustSource: row[3],
|
|
|
+ CustProvince: row[4],
|
|
|
+ CustCity: row[5],
|
|
|
+ CustRegion: row[6],
|
|
|
+ CustAddress: row[7],
|
|
|
Keyword: row[8],
|
|
|
Remark: row[9],
|
|
|
CuctName: row[10],
|