浏览代码

feature: 添加客户所属省市区,修改客户编码规则,添加最后跟进人

liuyaqi 2 年之前
父节点
当前提交
98afef2de4

+ 96 - 73
opms_parent/app/dao/cust/internal/cust_customer.go

@@ -27,31 +27,38 @@ type CustCustomerDao struct {
 
 // CustCustomerColumns defines and stores column names for table cust_customer.
 type custCustomerColumns struct {
-	Id           string // 主键
-	CustCode     string // 客户编号
-	CustName     string // 客户名称
-	AbbrName     string // 助记名
-	CustIndustry string //客户行业
-	CustLevel    string // 客户级别(10 重点客户 20 普通客户 30非优客户)
-	CustDistCode int    // 所在省份ID
-	CustLocation string // 所在地区
-	CustAddress  string // 详细地址
-	CustStatus   string // 客户状态(10正常20)
-	CustSource   string // 客户来源
-	IsPublic     string // 公海客户(10是20否)
-	DeptId       string // 所属部门ID
-	DeptName     string // 所属部门
-	SalesId      string // 所属销售ID
-	SalesName    string // 所属销售
-	FollowUpDate string // 最后跟进时间
-	Remark       string // 备注
-	CreatedBy    string // 创建者
-	CreatedName  string // 创建人
-	CreatedTime  string // 创建时间
-	UpdatedBy    string // 更新者
-	UpdatedName  string // 更新人
-	UpdatedTime  string // 更新时间
-	DeletedTime  string // 删除时间
+	Id             string // 主键
+	CustCode       string // 客户编号
+	CustName       string // 客户名称
+	AbbrName       string // 助记名
+	CustDistCode   string // 客户所在省级ID
+	CustLocation   string // 所在地区
+	CustAddress    string // 详细地址
+	CustProvinceId string // 所在省ID
+	CustProvince   string // 所在省
+	CustCityId     string // 所在市ID
+	CustCity       string // 所在市
+	CustRegionId   string // 所在区县ID
+	CustRegion     string // 所在区县
+	CustIndustry   string // 客户行业
+	CustLevel      string // 客户级别(10 重点客户 20 普通客户 30非优客户)
+	CustStatus     string // 客户状态(10 待领取 20 领取审批 30 已领取)
+	CustSource     string // 客户来源
+	IsPublic       string // 公海客户(10是20否)
+	DeptId         string // 所属部门ID
+	DeptName       string // 所属部门
+	SalesId        string // 所属销售ID
+	SalesName      string // 所属销售
+	FollowUpDate   string // 最后跟进时间
+	FollowUpMan    string // 最后跟进人
+	Remark         string // 备注
+	CreatedBy      string // 创建者
+	CreatedName    string // 创建人
+	CreatedTime    string // 创建时间
+	UpdatedBy      string // 更新者
+	UpdatedName    string // 更新人
+	UpdatedTime    string // 更新时间
+	DeletedTime    string // 删除时间
 }
 
 var (
@@ -61,30 +68,38 @@ var (
 		DB:    g.DB("default"),
 		Table: "cust_customer",
 		Columns: custCustomerColumns{
-			Id:           "id",
-			CustCode:     "cust_code",
-			CustName:     "cust_name",
-			CustIndustry: "cust_industry",
-			CustLevel:    "cust_level",
-			AbbrName:     "abbr_name",
-			CustLocation: "cust_location",
-			CustAddress:  "cust_address",
-			CustSource:   "cust_source",
-			CustStatus:   "cust_status",
-			IsPublic:     "is_public",
-			DeptId:       "dept_id",
-			DeptName:     "dept_name",
-			SalesId:      "sales_id",
-			SalesName:    "sales_name",
-			FollowUpDate: "follow_up_date",
-			Remark:       "remark",
-			CreatedBy:    "created_by",
-			CreatedName:  "created_name",
-			CreatedTime:  "created_time",
-			UpdatedBy:    "updated_by",
-			UpdatedName:  "updated_name",
-			UpdatedTime:  "updated_time",
-			DeletedTime:  "deleted_time",
+			Id:             "id",
+			CustCode:       "cust_code",
+			CustName:       "cust_name",
+			AbbrName:       "abbr_name",
+			CustDistCode:   "cust_dist_code",
+			CustLocation:   "cust_location",
+			CustAddress:    "cust_address",
+			CustProvinceId: "cust_province_id",
+			CustProvince:   "cust_province",
+			CustCityId:     "cust_city_id",
+			CustCity:       "cust_city",
+			CustRegionId:   "cust_region_id",
+			CustRegion:     "cust_region",
+			CustIndustry:   "cust_industry",
+			CustLevel:      "cust_level",
+			CustStatus:     "cust_status",
+			CustSource:     "cust_source",
+			IsPublic:       "is_public",
+			DeptId:         "dept_id",
+			DeptName:       "dept_name",
+			SalesId:        "sales_id",
+			SalesName:      "sales_name",
+			FollowUpDate:   "follow_up_date",
+			FollowUpMan:    "follow_up_man",
+			Remark:         "remark",
+			CreatedBy:      "created_by",
+			CreatedName:    "created_name",
+			CreatedTime:    "created_time",
+			UpdatedBy:      "updated_by",
+			UpdatedName:    "updated_name",
+			UpdatedTime:    "updated_time",
+			DeletedTime:    "deleted_time",
 		},
 	}
 )
@@ -96,30 +111,38 @@ func NewCustCustomerDao(tenant string) CustCustomerDao {
 		DB:    g.DB(tenant),
 		Table: "cust_customer",
 		Columns: custCustomerColumns{
-			Id:           "id",
-			CustCode:     "cust_code",
-			CustName:     "cust_name",
-			AbbrName:     "abbr_name",
-			CustLocation: "cust_location",
-			CustIndustry: "cust_industry",
-			CustLevel:    "cust_level",
-			CustAddress:  "cust_address",
-			CustStatus:   "cust_status",
-			CustSource:   "cust_source",
-			IsPublic:     "is_public",
-			DeptId:       "dept_id",
-			DeptName:     "dept_name",
-			SalesId:      "sales_id",
-			SalesName:    "sales_name",
-			FollowUpDate: "follow_up_date",
-			Remark:       "remark",
-			CreatedBy:    "created_by",
-			CreatedName:  "created_name",
-			CreatedTime:  "created_time",
-			UpdatedBy:    "updated_by",
-			UpdatedName:  "updated_name",
-			UpdatedTime:  "updated_time",
-			DeletedTime:  "deleted_time",
+			Id:             "id",
+			CustCode:       "cust_code",
+			CustName:       "cust_name",
+			AbbrName:       "abbr_name",
+			CustDistCode:   "cust_dist_code",
+			CustLocation:   "cust_location",
+			CustAddress:    "cust_address",
+			CustProvinceId: "cust_province_id",
+			CustProvince:   "cust_province",
+			CustCityId:     "cust_city_id",
+			CustCity:       "cust_city",
+			CustRegionId:   "cust_region_id",
+			CustRegion:     "cust_region",
+			CustIndustry:   "cust_industry",
+			CustLevel:      "cust_level",
+			CustStatus:     "cust_status",
+			CustSource:     "cust_source",
+			IsPublic:       "is_public",
+			DeptId:         "dept_id",
+			DeptName:       "dept_name",
+			SalesId:        "sales_id",
+			SalesName:      "sales_name",
+			FollowUpDate:   "follow_up_date",
+			FollowUpMan:    "follow_up_man",
+			Remark:         "remark",
+			CreatedBy:      "created_by",
+			CreatedName:    "created_name",
+			CreatedTime:    "created_time",
+			UpdatedBy:      "updated_by",
+			UpdatedName:    "updated_name",
+			UpdatedTime:    "updated_time",
+			DeletedTime:    "deleted_time",
 		},
 	}
 	return dao

+ 1 - 0
opms_parent/app/handler/cust/customer.go

@@ -51,6 +51,7 @@ func (c *CustomerHeader) PublicGetList(ctx context.Context, req *model.CustCusto
 	return nil
 
 }
+
 //Swagger:Customer 客户,测试tag 创建客户
 func (c *CustomerHeader) Create(ctx context.Context, req *model.CustomerAddSeq, rsp *comm_def.CommonMsg) error {
 	if err := gvalid.CheckStruct(ctx, req, nil); err != nil {

+ 42 - 28
opms_parent/app/model/cust/cust_customer.go

@@ -46,18 +46,25 @@ type CustExport struct {
 
 //CustomerAddSeq 单表添加客户信息表
 type CustomerAddSeq struct {
-	CustName     string      `p:"custName"        json:"custName"      v:"required#客户名称不能为空"` // 客户名称
-	AbbrName     string      `p:"abbrName"        json:"abbrName"   `                         // 助计名
-	CustLocation string      `p:"custLocation"    json:"custLocation"    `                    // 所在地区
-	CustAddress  string      `p:"custAddress"     json:"custAddress"   `                      // 详细地址
-	FollowUpDate *gtime.Time `p:"followUpDate"    json:"followUpDate"   `                     //跟进时间
-	CustIndustry string      `p:"custIndustry"    json:"custIndustry"  v:"required#客户行业不能为空"` //客户行业
-	CustLevel    string      `p:"custLevel"       json:"custLevel"     v:"required#客户级别不能为空"` //客户级别
-	CustSource   string      `p:"custSource"      json:"source"        v:"required#客户来源不能为空"` //客户来源
-	CustDistCode int         `p:"custDistCode"    json:"custDistCode"  v:"required#省份不能为空" ` // 省份Id
-	Remark       string      `p:"remark"          json:"remark""`                            //备注
-	SalesName    string      `p:"salesName"       json:"salesName"   `                       // 销售名称
-	SalesId      int         `p:"salesId"         json:"salesId"   `                         // 销售id
+	CustName         string      `p:"custName"        json:"custName"      v:"required#客户名称不能为空"` // 客户名称
+	AbbrName         string      `p:"abbrName"        json:"abbrName"   `                         // 助计名
+	CustLocation     string      `p:"custLocation"    json:"custLocation"    `                    // 所在地区
+	CustAddress      string      `p:"custAddress"     json:"custAddress"   `                      // 详细地址
+	CustProvinceId   int         `json:"custProvinceId"`                                          // 所在省ID
+	CustProvince     string      `json:"custProvince"`                                            // 所在省
+	CustCityId       int         `json:"custCityId"`                                              // 所在市ID
+	CustCity         string      `json:"custCity"`                                                // 所在市
+	CustRegionId     int         `json:"custRegionId"`                                            // 所在区县ID
+	CustRegion       string      `json:"custRegion"`                                              // 所在区县
+	FollowUpDate     *gtime.Time `p:"followUpDate"    json:"followUpDate"   `                     //跟进时间
+	CustIndustry     string      `p:"custIndustry"    json:"custIndustry"  v:"required#客户行业不能为空"` //客户行业
+	CustIndustryCode string      `json:"custIndustryCode"`                                        //客户行业编码
+	CustLevel        string      `p:"custLevel"       json:"custLevel"     v:"required#客户级别不能为空"` //客户级别
+	CustSource       string      `p:"custSource"      json:"source"        v:"required#客户来源不能为空"` //客户来源
+	CustDistCode     int         `p:"custDistCode"    json:"custDistCode"  v:"required#省份不能为空" `  // 省份Id
+	Remark           string      `p:"remark"          json:"remark"`                              //备注
+	SalesName        string      `p:"salesName"       json:"salesName"   `                        // 销售名称
+	SalesId          int         `p:"salesId"         json:"salesId"   `                          // 销售id
 }
 
 // 客户联系人信息
@@ -73,22 +80,29 @@ type Information struct {
 //返回信息
 
 type CustList struct {
-	Id           int    `orm:"id,primary"     json:"id"`           // 主键
-	CustCode     string `orm:"cust_code"      json:"custCode"`     // 客户编号
-	CustName     string `orm:"cust_name"      json:"custName"`     // 客户名称
-	AbbrName     string `orm:"abbr_name"      json:"abbrName"`     // 助记名
-	CustLocation string `orm:"cust_location"  json:"custLocation"` // 所在地区
-	CustAddress  string `orm:"cust_address"   json:"custAddress"`  // 详细地址
-	CustStatus   string `orm:"cust_status"    json:"custStatus"`   // 客户状态(10正常20)
-	FollowUpDate string `orm:"follow_up_date" json:"followUpDate"` // 最后跟进时间
-	CustIndustry string `orm:"cust_industry"  json:"custIndustry"` // 客户行业
-	CustLevel    string `orm:"cust_level"     json:"custLevel"`    // 客户级别(10 重点客户 20 普通客户 30非优客户)
-	CustSource   string `orm:"cust_soucrce"    json:"source"`      // 客户来源
-	CreatedName  string `orm:"created_name"   json:"createdName"`  // 创建人
-	CreatedTime  string `orm:"created_time"   json:"createdTime"`  // 创建时间
-	SalesId      int    `orm:"sales_id"   json:"salesId"`          //
-	SalesName    string `orm:"sales_name"   json:"salesName"`      //
-	Remark       string `orm:"remark"   json:"remark"`
+	Id             int    `orm:"id,primary"     json:"id"`           // 主键
+	CustCode       string `orm:"cust_code"      json:"custCode"`     // 客户编号
+	CustName       string `orm:"cust_name"      json:"custName"`     // 客户名称
+	AbbrName       string `orm:"abbr_name"      json:"abbrName"`     // 助记名
+	CustLocation   string `orm:"cust_location"  json:"custLocation"` // 所在地区
+	CustAddress    string `orm:"cust_address"   json:"custAddress"`  // 详细地址
+	CustProvinceId int    `json:"custProvinceId"`                    // 所在省ID
+	CustProvince   string `json:"custProvince"`                      // 所在省
+	CustCityId     int    `json:"custCityId"`                        // 所在市ID
+	CustCity       string `json:"custCity"`                          // 所在市
+	CustRegionId   int    `json:"custRegionId"`                      // 所在区县ID
+	CustRegion     string `json:"custRegion"`                        // 所在区县
+	CustStatus     string `orm:"cust_status"    json:"custStatus"`   // 客户状态(10正常20)
+	FollowUpDate   string `orm:"follow_up_date" json:"followUpDate"` // 最后跟进时间
+	FollowUpMan    string `json:"followUpMan"`                       // 最后跟进人
+	CustIndustry   string `orm:"cust_industry"  json:"custIndustry"` // 客户行业
+	CustLevel      string `orm:"cust_level"     json:"custLevel"`    // 客户级别(10 重点客户 20 普通客户 30非优客户)
+	CustSource     string `orm:"cust_soucrce"    json:"source"`      // 客户来源
+	CreatedName    string `orm:"created_name"   json:"createdName"`  // 创建人
+	CreatedTime    string `orm:"created_time"   json:"createdTime"`  // 创建时间
+	SalesId        int    `orm:"sales_id"   json:"salesId"`          //
+	SalesName      string `orm:"sales_name"   json:"salesName"`      //
+	Remark         string `orm:"remark"   json:"remark"`
 	//Follow       *Follow     `json:"follow"`
 }
 

+ 32 - 25
opms_parent/app/model/cust/internal/cust_customer.go

@@ -10,29 +10,36 @@ import (
 
 // CustCustomer is the golang structure for table cust_customer.
 type CustCustomer struct {
-	Id           int         `orm:"id,primary"     json:"id"`              // 主键
-	CustCode     string      `orm:"cust_code"      json:"custCode"`        // 客户编号
-	CustName     string      `orm:"cust_name"      json:"custName"`        // 客户名称
-	CustDistCode int         `orm:"cust_dist_code"  json:"cust_dist_code"` //客户所在省级ID
-	AbbrName     string      `orm:"abbr_name"      json:"abbrName"`        // 助记名
-	CustLocation string      `orm:"cust_location"  json:"custLocation"`    // 所在地区
-	CustAddress  string      `orm:"cust_address"   json:"custAddress"`     // 详细地址
-	CustIndustry string      `orm:"cust_industry"   json:"custIndustry"`   //客户行业
-	CustLevel    string      `orm:"cust_level"   json:"custLevel"`         //客户级别(10 重点客户 20 普通客户 30非优客户)
-	CustSource   string      `orm:"cust_source"   json:"source"`           //客户来源
-	CustStatus   string      `orm:"cust_status"    json:"custStatus"`      // 客户状态(10正常20)
-	IsPublic     string      `orm:"is_public"      json:"isPublic"`        // 公海客户(10是20否)
-	DeptId       int         `orm:"dept_id"        json:"deptId"`          // 所属部门ID
-	DeptName     string      `orm:"dept_name"      json:"deptName"`        // 所属部门
-	SalesId      int         `orm:"sales_id"       json:"salesId"`         // 所属销售ID
-	SalesName    string      `orm:"sales_name"     json:"salesName"`       // 所属销售
-	FollowUpDate *gtime.Time `orm:"follow_up_date" json:"followUpDate"`    // 最后跟进时间
-	Remark       string      `orm:"remark"         json:"remark"`          // 备注
-	CreatedBy    int         `orm:"created_by"     json:"createdBy"`       // 创建者
-	CreatedName  string      `orm:"created_name"   json:"createdName"`     // 创建人
-	CreatedTime  *gtime.Time `orm:"created_time"   json:"createdTime"`     // 创建时间
-	UpdatedBy    int         `orm:"updated_by"     json:"updatedBy"`       // 更新者
-	UpdatedName  string      `orm:"updated_name"   json:"updatedName"`     // 更新人
-	UpdatedTime  *gtime.Time `orm:"updated_time"   json:"updatedTime"`     // 更新时间
-	DeletedTime  *gtime.Time `orm:"deleted_time"   json:"deletedTime"`     // 删除时间
+	Id             int         `orm:"id,primary"       json:"id"`             // 主键
+	CustCode       string      `orm:"cust_code"        json:"custCode"`       // 客户编号
+	CustName       string      `orm:"cust_name"        json:"custName"`       // 客户名称
+	AbbrName       string      `orm:"abbr_name"        json:"abbrName"`       // 助记名
+	CustDistCode   int         `orm:"cust_dist_code"   json:"custDistCode"`   // 客户所在省级ID
+	CustLocation   string      `orm:"cust_location"    json:"custLocation"`   // 所在地区
+	CustAddress    string      `orm:"cust_address"     json:"custAddress"`    // 详细地址
+	CustProvinceId int         `orm:"cust_province_id" json:"custProvinceId"` // 所在省ID
+	CustProvince   string      `orm:"cust_province"    json:"custProvince"`   // 所在省
+	CustCityId     int         `orm:"cust_city_id"     json:"custCityId"`     // 所在市ID
+	CustCity       string      `orm:"cust_city"        json:"custCity"`       // 所在市
+	CustRegionId   int         `orm:"cust_region_id"   json:"custRegionId"`   // 所在区县ID
+	CustRegion     string      `orm:"cust_region"      json:"custRegion"`     // 所在区县
+	CustIndustry   string      `orm:"cust_industry"    json:"custIndustry"`   // 客户行业
+	CustLevel      string      `orm:"cust_level"       json:"custLevel"`      // 客户级别(10 重点客户 20 普通客户 30非优客户)
+	CustStatus     string      `orm:"cust_status"      json:"custStatus"`     // 客户状态(10 待领取 20 领取审批 30 已领取)
+	CustSource     string      `orm:"cust_source"      json:"custSource"`     // 客户来源
+	IsPublic       string      `orm:"is_public"        json:"isPublic"`       // 公海客户(10是20否)
+	DeptId         int         `orm:"dept_id"          json:"deptId"`         // 所属部门ID
+	DeptName       string      `orm:"dept_name"        json:"deptName"`       // 所属部门
+	SalesId        int         `orm:"sales_id"         json:"salesId"`        // 所属销售ID
+	SalesName      string      `orm:"sales_name"       json:"salesName"`      // 所属销售
+	FollowUpDate   *gtime.Time `orm:"follow_up_date"   json:"followUpDate"`   // 最后跟进时间
+	FollowUpMan    string      `orm:"follow_up_man"    json:"followUpMan"`    // 最后跟进人
+	Remark         string      `orm:"remark"           json:"remark"`         // 备注
+	CreatedBy      int         `orm:"created_by"       json:"createdBy"`      // 创建者
+	CreatedName    string      `orm:"created_name"     json:"createdName"`    // 创建人
+	CreatedTime    *gtime.Time `orm:"created_time"     json:"createdTime"`    // 创建时间
+	UpdatedBy      int         `orm:"updated_by"       json:"updatedBy"`      // 更新者
+	UpdatedName    string      `orm:"updated_name"     json:"updatedName"`    // 更新人
+	UpdatedTime    *gtime.Time `orm:"updated_time"     json:"updatedTime"`    // 更新时间
+	DeletedTime    *gtime.Time `orm:"deleted_time"     json:"deletedTime"`    // 删除时间
 }

+ 12 - 1
opms_parent/app/service/base.go

@@ -1,9 +1,11 @@
 package service
 
 import (
-	"github.com/gogf/gf/os/gtime"
 	"log"
 	"reflect"
+
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/os/gtime"
 )
 
 var (
@@ -12,6 +14,15 @@ var (
 	UpdateFieldEx       = []interface{}{"id", "created_by", "created_name", "created_time"}
 )
 
+
+func Sequence(db gdb.DB, name string) (string, error) {
+	v, err := db.GetValue("select `nextval`( ? );", name)
+	if err != nil {
+		return "", err
+	}
+	return v.String(), nil
+}
+
 // SetCreatedInfo 插入数据库时设置创建信息
 func SetCreatedInfo(entry interface{}, id int, name string) {
 	v := reflect.ValueOf(entry)

+ 36 - 1
opms_parent/app/service/cust/cust_customer.go

@@ -6,6 +6,7 @@ import (
 	"fmt"
 	"math"
 	"strconv"
+	"strings"
 
 	"dashoo.cn/opms_libary/myerrors"
 	"github.com/360EntSecGroup-Skylar/excelize"
@@ -14,6 +15,7 @@ import (
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/os/gtime"
 	"github.com/gogf/gf/util/gconv"
+	"github.com/mozillazg/go-pinyin"
 
 	"dashoo.cn/micro/app/dao/cust"
 	platdao "dashoo.cn/micro/app/dao/plat"
@@ -107,6 +109,35 @@ func (s *CustomerService) GetList(req *model.CustCustomerSearchReq) (total int,
 	return
 }
 
+func (s *CustomerService) customerCode(province, industry string) (string, error) {
+	sequence, err := service.Sequence(s.Dao.DB, "customer_code")
+	if err != nil {
+		return "", err
+	}
+	return s.customerProvinceCode(province) + industry + sequence, nil
+}
+
+func (s *CustomerService) customerProvinceCode(province string) string {
+	province = strings.Trim(province, "市")
+	province = strings.Trim(province, "省")
+	province = strings.Trim(province, "特别行政区")
+	province = strings.Trim(province, "自治区")
+	province = strings.Trim(province, "壮族")
+	province = strings.Trim(province, "回族")
+	province = strings.Trim(province, "维吾尔")
+	pinyinArg := pinyin.NewArgs()
+	pinyinArg.Style = pinyin.FIRST_LETTER
+	provincePinyin := pinyin.Pinyin(province, pinyinArg)
+	provinceFirstletter := []string{}
+	for _, i := range provincePinyin {
+		provinceFirstletter = append(provinceFirstletter, i[0])
+	}
+	provinceCode := strings.Join(provinceFirstletter, "")
+	provinceCode = strings.ToUpper(provinceCode)
+	fmt.Println(provincePinyin, provinceFirstletter, provinceCode)
+	return provinceCode
+}
+
 // Create 创建客户
 func (s *CustomerService) Create(req *model.CustomerAddSeq) (insertId int64, err error) {
 	cusTomer := new(model.CustCustomer)
@@ -123,7 +154,11 @@ func (s *CustomerService) Create(req *model.CustomerAddSeq) (insertId int64, err
 		return
 	}
 	service.SetCreatedInfo(cusTomer, s.GetCxtUserId(), s.CxtUser.NickName)
-	cusTomer.CustCode = "CT" + strconv.Itoa(int(gtime.Timestamp()))
+	custCode, err := s.customerCode(req.CustProvince, req.CustIndustryCode)
+	if err != nil {
+		return 0, err
+	}
+	cusTomer.CustCode = custCode
 	cusTomer.CustStatus = "10"
 
 	roles := s.GetCxtUserRoles()

+ 5 - 2
opms_parent/app/service/plat/plat_followup.go

@@ -3,7 +3,6 @@ package plat
 import (
 	"context"
 	"database/sql"
-	"fmt"
 	"strconv"
 	"strings"
 
@@ -99,7 +98,11 @@ func (s *followupService) Create(req *model.AddPlatFollowupReq) (err error) {
 		}
 	}
 	// 更新客户 最后跟进时间 字段
-	_, err = s.Dao.DB.Update("cust_customer", fmt.Sprintf("follow_up_date='%v'", req.FollowDate.Format("Y-m-d H:i:s")), fmt.Sprintf("id='%v' AND follow_up_date<'%v'", req.CustId, req.FollowDate.Format("Y-m-d H:i:s")))
+	toUpdate := map[string]interface{}{
+		"follow_up_date": req.FollowDate,
+		"follow_up_man":  s.GetCxtUserName(),
+	}
+	_, err = s.Dao.DB.Update("cust_customer", toUpdate, "id = ?", req.CustId)
 
 	return
 }

+ 1 - 0
opms_parent/main.go

@@ -83,6 +83,7 @@ var AuthExcludePaths = []string{
 func handleAuth(ctx context.Context, req *protocol.Message, token string) error {
 	if g.Config().GetBool("setting.fake-auth-for-swagger") {
 		req.Metadata["userInfo"] = `{"createTime":796,"data":{"id":1,"uuid":"","userName":"admin","nickName":"系统管理员","deptId":1,"roles":""},"refreshTime":43200796,"tenant":"default","userKey":"admin","uuid":"9b7ac56a5b2b4d12e52277e9601dbaf1"}`
+		req.Metadata["authExclude"] = "false"
 		return nil
 	}
 

+ 35 - 0
opms_parent/schema/customer.sql

@@ -0,0 +1,35 @@
+CREATE TABLE `cust_customer` (
+    `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '主键',
+    `cust_code` varchar(32) NOT NULL COMMENT '客户编号',
+    `cust_name` varchar(90) NOT NULL COMMENT '客户名称',
+    `abbr_name` varchar(90) NOT NULL COMMENT '助记名',
+    `cust_dist_code` int(11) NOT NULL COMMENT ' 客户所在省级ID',
+    `cust_location` varchar(32) DEFAULT NULL COMMENT '所在地区',
+    `cust_address` varchar(255) DEFAULT NULL COMMENT '详细地址',
+    `cust_province_id` INT(11) COMMENT '所在省ID',
+    `cust_province` VARCHAR(90) COMMENT '所在省',
+    `cust_city_id` INT(11) COMMENT '所在市ID',
+    `cust_city` VARCHAR(90) COMMENT '所在市',
+    `cust_region_id` INT(11) COMMENT '所在区县ID',
+    `cust_region` VARCHAR(90) COMMENT '所在区县',
+    `cust_industry` varchar(4) DEFAULT NULL COMMENT '客户行业',
+    `cust_level` varchar(4) DEFAULT NULL COMMENT '客户级别(10 重点客户 20 普通客户 30非优客户)',
+    `cust_status` VARCHAR(4) DEFAULT 10 COMMENT '客户状态(10 待领取 20 领取审批 30 已领取)',
+    `cust_source` varchar(20) DEFAULT NULL COMMENT '客户来源',
+    `is_public` varchar(4) DEFAULT NULL COMMENT '公海客户(10是20否)',
+    `dept_id` int(11) DEFAULT NULL COMMENT '所属部门ID',
+    `dept_name` varchar(90) DEFAULT NULL COMMENT '所属部门',
+    `sales_id` int(11) DEFAULT NULL COMMENT '所属销售ID',
+    `sales_name` varchar(90) DEFAULT NULL COMMENT '所属销售',
+    `follow_up_date` datetime DEFAULT NULL COMMENT '最后跟进时间',
+    `follow_up_man` VARCHAR(90) COMMENT '最后跟进人',
+    `remark` text DEFAULT NULL COMMENT '备注',
+    `created_by` int(11) NOT NULL COMMENT '创建者',
+    `created_name` varchar(90) NOT NULL COMMENT '创建人',
+    `created_time` datetime NOT NULL COMMENT '创建时间',
+    `updated_by` int(11) DEFAULT NULL COMMENT '更新者',
+    `updated_name` varchar(90) DEFAULT NULL COMMENT '更新人',
+    `updated_time` datetime DEFAULT NULL COMMENT '更新时间',
+    `deleted_time` datetime DEFAULT NULL COMMENT '删除时间',
+    PRIMARY KEY (`id`)
+) ENGINE = InnoDB AUTO_INCREMENT = 118 DEFAULT CHARSET = utf8mb4 COMMENT = '客户信息'

+ 28 - 0
opms_parent/schema/function.sql

@@ -0,0 +1,28 @@
+CREATE TABLE `plat_sequence` (
+    `name` varchar(32) NOT NULL COMMENT '序列编码',
+    `current_value` int(11) DEFAULT 1000 COMMENT '当前值/初始值',
+    `increment` int(11) DEFAULT NULL COMMENT '步增值',
+    `remark` text DEFAULT NULL COMMENT '备注',
+    `created_by` int(11) NOT NULL COMMENT '创建者',
+    `created_name` varchar(90) NOT NULL COMMENT '创建人',
+    `created_time` datetime NOT NULL COMMENT '创建时间',
+    `updated_by` int(11) DEFAULT NULL COMMENT '更新者',
+    `updated_name` varchar(90) DEFAULT NULL COMMENT '更新人',
+    `updated_time` datetime DEFAULT NULL COMMENT '更新时间',
+    `deleted_time` datetime DEFAULT NULL COMMENT '删除时间',
+    PRIMARY KEY (`name`) USING BTREE
+) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COMMENT = '序列信息表' ;
+
+
+DROP FUNCTION IF EXISTS nextval;
+DELIMITER $ 
+CREATE FUNCTION nextval (seq_name VARCHAR(50)) RETURNS INTEGER LANGUAGE SQL DETERMINISTIC CONTAINS SQL SQL SECURITY DEFINER COMMENT '' BEGIN
+UPDATE plat_sequence
+SET current_value = current_value + increment
+WHERE name = seq_name;
+RETURN currval(seq_name);
+END $ 
+DELIMITER ;
+
+-- INSERT INTO plat_sequence VALUES ('customer_code', 0, 1, '', 1000, '系统管理员', '2023-02-09 10:27:42', null, null, null, null);
+-- select `nextval`('customer_code');

+ 8 - 0
opms_parent/schema/tmp.sql

@@ -0,0 +1,8 @@
+alter table cust_customer add `cust_province_id` INT(11) COMMENT '所在省ID' after cust_address;
+alter table cust_customer add `cust_province` VARCHAR(90) COMMENT '所在省' after cust_province_id;
+alter table cust_customer add `cust_city_id` INT(11) COMMENT '所在市ID' after cust_province;
+alter table cust_customer add `cust_city` VARCHAR(90) COMMENT '所在市' after cust_city_id;
+alter table cust_customer add `cust_region_id` INT(11) COMMENT '所在区县ID' after cust_city;
+alter table cust_customer add `cust_region` VARCHAR(90) COMMENT '所在区县' after cust_region_id;
+alter table cust_customer modify `cust_status` VARCHAR(4) DEFAULT 10 COMMENT '客户状态(10 待领取 20 领取审批 30 已领取)';
+alter table cust_customer add `follow_up_man` VARCHAR(90) COMMENT '最后跟进人' after follow_up_date;