作者 唐旭辉

Merge branch 'dev' into test

... ... @@ -12,5 +12,5 @@ ENV GO111MODULE on
ENV GOPROXY https://goproxy.cn
# RUN ["go","mod","tidy"]
RUN ["go","build","-mod=vendor"]
EXPOSE 8082
EXPOSE 8082 443
ENTRYPOINT ["./partnermg"]
\ No newline at end of file
... ...
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEAjlYTMGgbnNvRnlNpSBXkXCC9FGcRjHnZb5ez/bgatsUawan9
Ou4a92X2cF1xQvALrvV8FgNpkUL4o8XUeWAN4DWOpSNKNUyEYy68jXr4FSUFSBEt
UytZrAWd5K+nvdNiACZFUfNyCDy2vs1mBtsA9TVyJEjk2MU+xMjCg8Jiv4LwGJze
33x7VDi/qurbaWQpLHvpsrDTtaC51s+JWu5etK1rDO45gjpo6QmaSuNxkuPAjJVO
1qwCf0Fz5H3EHiVFmz09nVbFCH/7a/d8WB1NMNRZAEOkOLUdVFLkrINMawcWBqx4
dl+ODIa8D50IiHuAbx4j6kXbNkDpQAYz+zOmNQIDAQABAoIBAB+bfyLgd4NHcB7V
vHsgu2d28K37blLwywdkG3jj3XDJR9YKMtzXe58FIirVIT3hUuLdChtUUijLA65Q
k8yJN0Oa+Qx0T/oSfhKNUhsj27vMTwYwJE3EAmN4EtYx6JC3hFtupDWc1y17mAQ6
VeX/U5DgN7LVihYWBQiLYWCDdcy7iBCCdgODHv1Zp6/Y1XLv5L9vUU1XK1GcIgZb
Ubbql6np6tzQm3LMS1xyhl4vwFSRDx9sSZ9C6dWlNT+3qLNjnPCsvY6709DgGgYz
Qu3C31uxDLzjS4KAYbOMmJl/knzyyhXHvRb1hz7kOsdmzUGOZl9ga/bcIbzDmpAG
7PnK1mECgYEA2zj0CjPj4TIuP2jVYkToMz6yE9glwZBWS7PEL/PicIf13ZH37Uuq
7HxAquKOlJKWnvOmLkNxfkTScomueC3OCrR0OSnBf6vhcgZ5qg8l/waXyNFMjwgq
Ng6bqrd5xDxHKsL38KvkWQzbtFra21g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G
A1UdEwEB/wQFMAMBAf8wHQYDVR0OBBYEFAh2zcsH/yT2xc3tu5C84oQ3RnX3MFIG
A1UdIwRLMEmhQqRAMD4xCzAJBgNVBAYTAlBMMRswGQYDVQQKExJVbml6ZXRvIFNw
LiB6IG8uby4xEjAQBgNVBAMTCUNlcnR1bSBDQYIDAQAgMA4GA1UdDwEB/wQEAwIB
BjAsBgNVHR8EJTAjMCGgH6AdhhtodHRwOi8vY3JsLmNlcnR1bS5wbC9jYS5jcmww
aAYIKwYBBQUHAQEEXDBaMCgGCCsGAQUFBzABhhxodHRwOi8vc3ViY2Eub2NzcC1j
ZXJ0dW0uY29tMC4GCCsGAQUFBzAChiJodHRwOi8vcmVwb3NpdG9yeS5jZXJ0dW0u
cGwvY2EuY2VyMDkGA1UdIAQyMDAwLgYEVR0gADAmMCQGCCsGAQUFBwIBFhhodHRw
Oi8vd3d3LmNlcnR1bS5wbC9DUFMwDQYJKoZIhvcNAQELBQADggEBAI3m/UBmo0yc
p6uh2oTdHDAH5tvHLeyDoVbkHTwmoaUJK+h9Yr6ydZTdCPJ/KEHkgGcCToqPwzXQ
1aknKOrS9KsGhkOujOP5iH3g271CgYACEnWy6BdxqyGVMUZCDYgQOdNv7C9C6kBT
Yr/rynieq6LVLgXqM6vp1peUQl4E7Sztapx6lX0FKgV/CF1mrWHUdqx1lpdzY70a
QVkppV4ig8OLWfqaova9ML9yHRyZhpzyhTwd9yaWLy75ArG1qVDoOPqbCl60BMDO
TjksygtbYvBNWFA0meaaLNKQ1wmB1sCqXs7+0vehukvZ1oaOGR+mBkdCcuBWCgAc
eLmNzJkEN0k=
-----END CERTIFICATE-----
... ...
appname = partnermg
runmode = "${RUN_MODE||dev}"
httpport = "${HTTP_PORT||8082}"
EnableHTTPS = true
HTTPSPort = "443"
HTTPSCertFile = "conf/_.fjmaimaimai.com_bundle.crt"
HTTPSKeyFile = "conf/_.fjmaimaimai.com.key"
#开启监控
EnableAdmin = false
#开启JSON请求
... ... @@ -10,6 +13,7 @@ copyrequestbody = true
enablexsrf = false
xsrfkey = asdfioerjlasdfmFADFOEJF2323SDFF
xsrfexpire = 3600
#是否将错误信息进行渲染
EnableErrorsRender =false
[lang]
... ...
... ... @@ -10,6 +10,9 @@ spec:
- name: "http"
port: 80
targetPort: 8082
- name: "https"
port: 443
targetPort: 443
selector:
k8s-app: mmm-partnermg
---
... ... @@ -48,6 +51,7 @@ spec:
imagePullPolicy: Always
ports:
- containerPort: 8082
- containerPort: 443
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
... ... @@ -86,6 +90,8 @@ spec:
value: "dev"
- name: Log_PREFIX
value: "[partnermg_dev]"
- name: APP_NAME
value: ""
volumes:
- name: accesslogs
emptyDir: {}
... ...
... ... @@ -10,6 +10,9 @@ spec:
- name: "http"
port: 80
targetPort: 8082
- name: "https"
port: 443
targetPort: 443
selector:
k8s-app: mmm-partnermg
---
... ... @@ -45,6 +48,7 @@ spec:
imagePullPolicy: Always
ports:
- containerPort: 8082
- containerPort: 443
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
... ... @@ -83,6 +87,8 @@ spec:
value: "dev"
- name: Log_PREFIX
value: "[partnermg_prd]"
- name: APP_NAME
value: "mmm-partnermg"
volumes:
- name: accesslogs
emptyDir: {}
... ...
... ... @@ -10,6 +10,9 @@ spec:
- name: "http"
port: 80
targetPort: 8082
- name: "https"
port: 443
targetPort: 443
selector:
k8s-app: mmm-partnermg
---
... ... @@ -45,6 +48,7 @@ spec:
imagePullPolicy: Always
ports:
- containerPort: 8082
- containerPort: 443
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
... ... @@ -83,6 +87,8 @@ spec:
value: "dev"
- name: Log_PREFIX
value: "[partnermg_test]"
- name: APP_NAME
value: "partnermg"
volumes:
- name: accesslogs
emptyDir: {}
... ...
... ... @@ -196,6 +196,7 @@ func (service SyncEmployeeService) addEmployeeData(datas []EmployeeData) error {
Permission: []domain.AdminPermissionBase{}, //初始化权限
AccessPartners: []domain.Partner{}, //默认初始化
AdminType: data.AdminType,
IsSenior: 2,
}
newUser.EntryTime, _ = time.Parse("2006-01-02", data.EntryTime)
if err = usersRepository.Add(&newUser); err != nil {
... ...
... ... @@ -8,6 +8,7 @@ var LOG_LEVEL = "debug"
var LOG_File = "./logs/partnermg.log"
var IMPORT_EXCEL = "./download/订单数据模板.xlsx"
var Log_PREFIX = "[partnermg_dev]"
var APP_NAME = ""
var (
UCENTER_HOST = "https://suplus-ucenter-test.fjmaimaimai.com" //统一用户中心地址
UCENTER_SECRET = "cykbjnfqgctn"
... ... @@ -43,4 +44,7 @@ func init() {
if os.Getenv("Log_PREFIX") != "" {
Log_PREFIX = os.Getenv("Log_PREFIX")
}
if os.Getenv("APP_NAME") != "" {
APP_NAME = os.Getenv("APP_NAME")
}
}
... ...
... ... @@ -682,7 +682,7 @@ func (c *OrderInfoController) DownloadTemplate() {
} else {
logs.Info(resp)
ret = map[string]interface{}{
"url": "http://" + c.Ctx.Request.Host + "/download/订单数据模板.xlsx",
"url": "http://" + c.Ctx.Request.Host + "/" + constant.APP_NAME + "/download/订单数据模板.xlsx",
}
c.ResponseData(ret)
}
... ... @@ -690,7 +690,7 @@ func (c *OrderInfoController) DownloadTemplate() {
/**
* @Author SteveChan
* @Description //TODO 导入excel订单
* @Description // 导入excel订单
* @Date 10:52 2021/1/6
* @Param
* @return
... ... @@ -701,14 +701,6 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
file, h, _ := c.GetFile("file")
companyId := c.GetUserCompany()
// Json数据解析
//jsonMap := make(map[string]interface{})
//err := json.Unmarshal([]byte(where), &jsonMap)
//if err != nil {
// logs.Error(err)
// c.ResponseError(errors.New("json数据解析失败"))
//}
if typeCode != "PARTNER_ORDER_FILE" {
c.ResponseError(errors.New("类型编码错误"))
}
... ... @@ -716,8 +708,8 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
// 返回字段定义
ret := map[string]interface{}{}
// 返回信息表头定义 0: 订单号, 1: 发货单号, 2: 客户名称, 3: 订单区域, 4: 编号, 5: 合伙人, 6: 类型, 7: 业务抽成比例, 8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例
var tableHeader = []string{"错误详情", "行号", "订单号", "发货单号", "客户名称", "订单区域", "编号", "合伙人", "类型", "业务抽成比例", "产品名称", "数量", "单价", "合伙人分红比例"}
// 返回信息表头定义 0: 订单号, 1: 发货单号, 2: 客户名称, 3: 订单区域, 4: 编号, 5: 合伙人, 6: 类型, 7: 业务员抽成比例, 8: 产品名称, 9: 数量, 10: 单价, 11: 合伙人分红比例
var tableHeader = []string{"错误详情", "行号", "订单号", "发货单号", "客户名称", "订单区域", "编号", "合伙人", "类型", "业务员抽成比例", "产品名称", "数量", "单价", "合伙人分红比例"}
// 文件后缀名校验
ext := path.Ext(h.Filename)
... ... @@ -743,6 +735,32 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
return
}
// 文件列数据校验
overColumnLine := make([]interface{}, 0)
for i, row := range rows {
if i > 2 && row != nil {
if len(row) > constant.EXCEL_COLUMN {
var tmpRow []string
tmpRow = append(tmpRow, "存在无效的数据列,请删除无效的列数据") // 错误信息
s := strconv.Itoa(i + 1)
tmpRow = append(tmpRow, s) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
overColumnLine = append(overColumnLine, tmpRow)
}
}
}
if len(overColumnLine) > 0 {
ret = map[string]interface{}{
"successCount": 0,
"fail": map[string]interface{}{
"tableHeader": tableHeader,
"tableData": overColumnLine,
},
}
c.ResponseData(ret)
return
}
// 数据行计数
rowCnt := 0
... ... @@ -753,38 +771,52 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
// 必填项校验
nullLine := make([]interface{}, 0)
nullFlag := false
for i, row := range rows {
if i > 2 && row != nil {
rowCnt++
if len(row) == constant.EXCEL_COLUMN { // 中间空字符校验
if len(row) == constant.EXCEL_COLUMN { // 必填项内容为空
var tmpRow = row
nullCell := make([]interface{}, 0)
var myRow []string
for j, cell := range row {
if j != 8 { // 业务员抽成比例非必填
if cell == "" || cell == " " { // 空字符串填充
tmpRow[j] = "null"
for j, _ := range row {
if j != 7 { // 业务员抽成比例非必填
if row[j] == "" || row[j] == " " { // 空字符补位
tmpRow[j] = ""
col := strconv.Itoa(j + 1)
nullCell = append(nullCell, col)
nullFlag = true
}
}
}
if nullFlag {
myRow = append(myRow, "必填项不能为空") // 错误信息
s := strconv.Itoa(i + 1)
myRow = append(myRow, s) // 行号
myRow = append(myRow, tmpRow...) // 错误行数据
b := strings.Replace(strings.Trim(fmt.Sprint(nullCell), "[]"), " ", ",", -1)
myRow = append(myRow, "第"+s+"行的第"+b+"列必填项为空") // 错误信息
myRow = append(myRow, s) // 行号
myRow = append(myRow, tmpRow...) // 错误行数据
nullLine = append(nullLine, myRow)
nullFlag = false
}
} else if len(row) > 0 && len(row) < constant.EXCEL_COLUMN { // 尾部空字符校验
} else if len(row) > 0 && len(row) < constant.EXCEL_COLUMN { // 必填项不存在
var myRow []string
for i := 0; i < constant.EXCEL_COLUMN-len(row); i++ { // null补位
myRow = append(myRow, "null")
}
myRow = append(myRow, "必填项不能为空") // 错误信息
myRow = append(myRow, "必填项为空")
s := strconv.Itoa(i + 1)
myRow = append(myRow, s) // 行号
myRow = append(myRow, row...) // 错误行数据
emptyCell := make([]interface{}, 0)
// 错误信息
for k := 0; k < constant.EXCEL_COLUMN-len(row); k++ { // 空字符补位
myRow = append(myRow, "")
}
for k, cell := range myRow {
if k != 0 && cell == "" {
emptyCell = append(emptyCell, k-1)
}
}
b := strings.Replace(strings.Trim(fmt.Sprint(emptyCell), "[]"), " ", ",", -1)
myRow[0] = "第" + s + "行的第" + b + "列必填项为空"
nullLine = append(nullLine, myRow)
}
}
... ... @@ -810,17 +842,21 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
if i > 2 && row != nil && len(row) == constant.EXCEL_COLUMN { // 数据行
var myRow []string
for j, cell := range row {
r := strconv.Itoa(i + 1)
col := strconv.Itoa(j + 1)
switch j {
case 0, 1, 2, 3, 4, 5, 8: // 订单号、发货单号、客户名称、订单区域、编号、合伙人、产品名称长度校验
{
cellStr := strings.TrimSpace(cell)
lenCellStr := utf8.RuneCountInString(cellStr)
if lenCellStr > 50 {
var tmpRow []string
tmpRow = append(tmpRow, tableHeader[j+2]+"长度超过50位,请重新输入") // 错误信息
s := strconv.Itoa(i + 1)
tmpRow = append(tmpRow, s) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列"+tableHeader[j+2]+"长度超过50位,请重新输入") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
myRow = tmpRow
}
}
... ... @@ -828,139 +864,120 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
{
if !utils.IsContain(partnerType, cell) {
var tmpRow []string
tmpRow = append(tmpRow, "合伙人类型须为以下类型:事业合伙、业务合伙、研发合伙、业务-产品应用合伙") // 错误信息
s := strconv.Itoa(i + 1)
tmpRow = append(tmpRow, s) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列合伙人类型错误,合伙人类型必须为以下类型:事业合伙、业务合伙、研发合伙、业务-产品应用合伙") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
myRow = tmpRow
}
}
case 7: // 业务员抽成比例,非必填,精确到小数点后两位
{
var (
typeErrFlag bool
lenErrFlag bool
ratioErrFlag bool
)
if len(cell) > 0 {
// 参数类型转换
shareRatio, err := strconv.ParseFloat(cell, 64)
if err != nil {
typeErrFlag = true
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列业务员抽成比例格式错误,业务员抽成比例必须为数字") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
myRow = tmpRow
}
// 比例不能超过100%
if shareRatio > 100 {
ratioErrFlag = true
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列业务员抽成比例超过限额,请输入正确的业务员抽成比例,并保留两位小数") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
myRow = tmpRow
}
// 长度校验
regexpStr := `^(100|[1-9]\d|\d)(.\d{1,2})?$`
ok := regexp.MustCompile(regexpStr).MatchString(cell)
if !ok {
lenErrFlag = true
}
if typeErrFlag || lenErrFlag || ratioErrFlag {
var tmpRow []string
tmpRow = append(tmpRow, "业务员抽成比例格式错误,请输入正确的业务员抽成比例比例,保留两位小数") // 错误信息
s := strconv.Itoa(i + 1)
tmpRow = append(tmpRow, s) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列业务员抽成比例超过最大长度,请输入正确的业务员抽成比例,并保留两位小数") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
myRow = tmpRow
typeErrFlag = false
lenErrFlag = false
ratioErrFlag = false
}
}
}
case 9: // 数量不超过16位正整数
{
var (
typeErrFlag bool
lenErrFlag bool
)
//参数类型转换
orderNum, err := strconv.ParseInt(cell, 10, 64)
if err != nil {
typeErrFlag = true
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列产品数量格式错误,产品数量必须整数") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
myRow = tmpRow
}
// 长度校验
if orderNum > 1e16 {
lenErrFlag = true
}
if typeErrFlag || lenErrFlag {
var tmpRow []string
tmpRow = append(tmpRow, "数量长度超过最大限制十六位整数,请重新填写") // 错误信息
s := strconv.Itoa(i + 1)
tmpRow = append(tmpRow, s) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列产品数量长度超过最大限制十六位整数,请重新填写") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
myRow = tmpRow
typeErrFlag = false
lenErrFlag = false
}
}
case 10: // 单价,精确到小数点后两位,小数点左侧最多可输入16位数字
{
// 参数类型转换
univalent, err := strconv.ParseFloat(cell, 64)
if err != nil {
univalent, typeErr := strconv.ParseFloat(cell, 64)
if typeErr != nil {
var tmpRow []string
tmpRow = append(tmpRow, "单价格式错误,请输入正确的单价,保留两位小数点,小数点前面不能超过十六位数字") // 错误信息
s := strconv.Itoa(i + 1)
tmpRow = append(tmpRow, s) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列单价格式错误,产品单价必须为数字类型") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
myRow = tmpRow
}
// 长度校验
if univalent >= 1e16 {
var tmpRow []string
tmpRow = append(tmpRow, "单价格式错误,请输入正确的单价,保留两位小数点,小数点前面不能超过十六位数字") // 错误信息
s := strconv.Itoa(i + 1)
tmpRow = append(tmpRow, s) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列产品单价超过最大限制,产品单价小数点前面不能超过十六位数字,并保留两位小数") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
myRow = tmpRow
}
}
case 11: // 合伙人分红比例,精确到小数点后两位
{
var (
typeErrFlag bool
lenErrFlag bool
ratioErrFlag bool
)
//参数类型转换
partnerRatio, err := strconv.ParseFloat(cell, 64)
if err != nil {
typeErrFlag = true
partnerRatio, parseErr := strconv.ParseFloat(cell, 64)
if parseErr != nil {
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列合伙人分红比例类型错误,合伙人分红比例必须为数字") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
myRow = tmpRow
}
// 合伙人分红比例超额
if partnerRatio > 100 {
ratioErrFlag = true
var tmpRow []string
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列合伙人分红比例超过限额,请输入正确的合伙人分红比例,并保留两位小数") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
myRow = tmpRow
}
// 长度判断
regexpStr := `^(100|[1-9]\d|\d)(.\d{1,2})?$`
ok := regexp.MustCompile(regexpStr).MatchString(cell)
if !ok {
lenErrFlag = true
}
if typeErrFlag || lenErrFlag || ratioErrFlag {
var tmpRow []string
tmpRow = append(tmpRow, "合伙人分红比例格式错误,请输入正确的合伙人分红比例,保留两位小数") // 错误信息
s := strconv.Itoa(i + 1)
tmpRow = append(tmpRow, s) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
tmpRow = append(tmpRow, "第"+r+"行第"+col+"列合伙人分红比例超过最大长度,请输入正确的合伙人分红比例,并保留两位小数") // 错误信息
tmpRow = append(tmpRow, r) // 行号
tmpRow = append(tmpRow, row...) // 错误行数据
myRow = tmpRow
typeErrFlag = false
lenErrFlag = false
ratioErrFlag = false
}
}
}
... ... @@ -1006,6 +1023,29 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
price, _ := strconv.ParseFloat(row[10], 64) // 单价
percent, _ := strconv.ParseFloat(row[11], 64) // 合伙人分红比例
// 获取partnerId
var partnerInfo *domain.PartnerInfo
orderQueryData := orderQuery.GetPartnerIdQuery{
Code: row[4],
PartnerCategory: 0,
CompanyId: companyId,
}
// 1: 事业合伙、2: 业务合伙、3: 研发合伙、4: 业务-产品应用合伙
switch row[6] {
case "事业合伙":
orderQueryData.PartnerCategory = 1
case "业务合伙":
orderQueryData.PartnerCategory = 2
case "研发合伙":
orderQueryData.PartnerCategory = 3
case "业务-产品应用合伙":
orderQueryData.PartnerCategory = 4
default:
orderQueryData.PartnerCategory = 0
}
// 初始化建订单命令集
orderCommands[hashString] = &orderCmd.CreateOrderCommand{
OrderType: 0,
... ... @@ -1025,30 +1065,10 @@ func (c *OrderInfoController) ImportOrderFromExcel() {
},
},
CompanyId: companyId,
PartnerCategory: 1,
PartnerCategory: int64(orderQueryData.PartnerCategory),
LineNumbers: []int{i}, // 记录行号
}
// 获取partnerId
var partnerInfo *domain.PartnerInfo
orderQueryData := orderQuery.GetPartnerIdQuery{
Code: row[4],
PartnerCategory: 0,
CompanyId: companyId,
}
// 1: 事业合伙、2: 业务合伙、3: 研发合伙、4: 业务-产品应用合伙
switch row[6] {
case "事业合伙":
orderQueryData.PartnerCategory = 1
case "业务合伙":
orderQueryData.PartnerCategory = 2
case "研发合伙":
orderQueryData.PartnerCategory = 3
case "业务-产品应用合伙":
orderQueryData.PartnerCategory = 4
default:
orderQueryData.PartnerCategory = 0
}
partnerInfo, err = orderSrv.GetPartnerIdByCodeAndCategory(orderQueryData)
if err != nil || partnerInfo == nil { // 检索合伙人错误
var tmpRow []string
... ...