Răsfoiți Sursa

feature:客户、经销商添加开票抬头, 修改领取客户审核逻辑

liuyaqi 2 ani în urmă
părinte
comite
bc0f6a3783

+ 3 - 0
opms_parent/app/dao/base/internal/base_distributor.go

@@ -42,6 +42,7 @@ type baseDistributorColumns struct {
 	BelongSale    string // 归属销售
 	Capital       string // 注册资金
 	SaleNum       string // 销售人数
+	InvoiceHeader string // 开票抬头
 	Remark        string // 备注
 	CreatedBy     string // 创建者
 	CreatedName   string // 创建人
@@ -73,6 +74,7 @@ var (
 			BelongSale:    "belong_sale",
 			Capital:       "capital",
 			SaleNum:       "sale_num",
+			InvoiceHeader: "invoice_header",
 			Remark:        "remark",
 			CreatedBy:     "created_by",
 			CreatedName:   "created_name",
@@ -106,6 +108,7 @@ func NewBaseDistributorDao(tenant string) BaseDistributorDao {
 			BelongSale:    "belong_sale",
 			Capital:       "capital",
 			SaleNum:       "sale_num",
+			InvoiceHeader: "invoice_header",
 			Remark:        "remark",
 			CreatedBy:     "created_by",
 			CreatedName:   "created_name",

+ 3 - 0
opms_parent/app/dao/cust/internal/cust_customer.go

@@ -50,6 +50,7 @@ type custCustomerColumns struct {
 	SalesName      string // 所属销售
 	FollowUpDate   string // 最后跟进时间
 	FollowUpMan    string // 最后跟进人
+	InvoiceHeader  string // 开票抬头
 	Remark         string // 备注
 	CreatedBy      string // 创建者
 	CreatedName    string // 创建人
@@ -89,6 +90,7 @@ var (
 			SalesName:      "sales_name",
 			FollowUpDate:   "follow_up_date",
 			FollowUpMan:    "follow_up_man",
+			InvoiceHeader:  "invoice_header",
 			Remark:         "remark",
 			CreatedBy:      "created_by",
 			CreatedName:    "created_name",
@@ -130,6 +132,7 @@ func NewCustCustomerDao(tenant string) CustCustomerDao {
 			SalesName:      "sales_name",
 			FollowUpDate:   "follow_up_date",
 			FollowUpMan:    "follow_up_man",
+			InvoiceHeader:  "invoice_header",
 			Remark:         "remark",
 			CreatedBy:      "created_by",
 			CreatedName:    "created_name",

+ 2 - 0
opms_parent/app/model/base/base_distributor.go

@@ -35,6 +35,7 @@ type AddDistributor struct {
 	BusinessScope string `orm:"business_scope"  json:"businessScope"  v:"required#业务范围不能为空"`              // 业务范围
 	BelongSaleId  int    `orm:"belong_sale_id"  json:"belongSaleId"   v:"required#归属销售ID不能为空"`            // 归属销售ID
 	BelongSale    string `orm:"belong_sale"     json:"belongSale"      v:"required#归属销售不能为空"`             // 归属销售
+	InvoiceHeader string `json:"invoiceHeader"`                                                           // 开票抬头
 }
 
 //列表返回字段
@@ -54,6 +55,7 @@ type DistributorRonp struct {
 	DistDesc      string        `orm:"dist_desc"    json:"distDesc"`         // 说明
 	District      *BaseDistrict `orm:"with:id=province_id"`
 	//*Contanct
+	InvoiceHeader string `orm:"invoice_header"  json:"invoiceHeader"` // 开票抬头
 }
 
 //编辑参数

+ 1 - 0
opms_parent/app/model/base/internal/base_distributor.go

@@ -24,6 +24,7 @@ type BaseDistributor struct {
 	BelongSale    string      `orm:"belong_sale"     json:"belongSale"`    // 归属销售
 	Capital       float64     `orm:"capital"         json:"capital"`       // 注册资金
 	SaleNum       int         `orm:"sale_num"        json:"saleNum"`       // 销售人数
+	InvoiceHeader string      `orm:"invoice_header"  json:"invoiceHeader"` // 开票抬头
 	Remark        string      `orm:"remark"          json:"remark"`        // 备注
 	CreatedBy     int         `orm:"created_by"      json:"createdBy"`     // 创建者
 	CreatedName   string      `orm:"created_name"    json:"createdName"`   // 创建人

+ 2 - 0
opms_parent/app/model/cust/cust_customer.go

@@ -64,6 +64,7 @@ type CustomerAddSeq struct {
 	Remark         string      `p:"remark"          json:"remark"`                              //备注
 	SalesName      string      `p:"salesName"       json:"salesName"   `                        // 销售名称
 	SalesId        int         `p:"salesId"         json:"salesId"   `                          // 销售id
+	InvoiceHeader  string      `json:"invoiceHeader"`                                           // 开票抬头
 }
 
 // 客户联系人信息
@@ -103,6 +104,7 @@ type CustList struct {
 	SalesName      string `orm:"sales_name"   json:"salesName"`      //
 	Remark         string `orm:"remark"   json:"remark"`
 	//Follow       *Follow     `json:"follow"`
+	InvoiceHeader string `orm:"invoice_header"   json:"invoiceHeader"` // 开票抬头
 }
 
 // 跟进摘要

+ 3 - 3
opms_parent/app/model/cust/cust_customer_contact.go

@@ -20,10 +20,10 @@ type CustCustomerContactSeq struct {
 	CustId         int    `p:"custId"     json:"custId"      v:"required#客户ID不能为空" `                    // 关联客户
 	CuctName       string `p:"cuctName"     json:"cuctName"  v:"required#联系人名字不能为空"`                    // 姓名
 	CuctGender     string `p:"cuctGender"    json:"cuctGender"  v:"required|in:10,20#性别不能为空|填写错误"`      // 性别(10男20女)
-	Telephone      string `p:"telephone"    json:"telephone"  v:"phone#手机号格式错误"`       // 电话
-	Wechat         string `p:"wechat"    json:"wechat"`                            // 微信
+	Telephone      string `p:"telephone"    json:"telephone"  v:"phone#手机号格式错误"`                        // 电话
+	Wechat         string `p:"wechat"    json:"wechat"`                                                 // 微信
 	Email          string `p:"email"    json:"email" v:"email#邮箱格式错误"`                                  // 邮箱
-	Dept           string `p:"dept"            json:"dept"`                        // 部门
+	Dept           string `p:"dept"            json:"dept"`                                             // 部门
 	Postion        string `p:"postion"    json:"postion"   v:"required#岗位不能为空" `                        // 职位
 	OfficeLocation string `p:"officeLocation" json:"officeLocation"`                                    // 办公地点
 	IsDecision     string `p:"isDecision"     json:"isDecision" v:"required|in:10,20#是否关键决策人不能为空|填写错误"` // 关键决策人(10是20否)

+ 1 - 0
opms_parent/app/model/cust/internal/cust_customer.go

@@ -32,6 +32,7 @@ type CustCustomer struct {
 	SalesName      string      `orm:"sales_name"       json:"salesName"`      // 所属销售
 	FollowUpDate   *gtime.Time `orm:"follow_up_date"   json:"followUpDate"`   // 最后跟进时间
 	FollowUpMan    string      `orm:"follow_up_man"    json:"followUpMan"`    // 最后跟进人
+	InvoiceHeader  string      `orm:"invoice_header"   json:"invoiceHeader"`  // 开票抬头
 	Remark         string      `orm:"remark"           json:"remark"`         // 备注
 	CreatedBy      int         `orm:"created_by"       json:"createdBy"`      // 创建者
 	CreatedName    string      `orm:"created_name"     json:"createdName"`    // 创建人

+ 7 - 7
opms_parent/app/service/contract/ctr_contract.go

@@ -341,13 +341,13 @@ func (s CtrContractService) Add(ctx context.Context, req *model.CtrContractAddRe
 	if nbo == nil {
 		return 0, myerrors.TipsError("项目不存在")
 	}
-	c, err = s.Dao.Where("nbo_id = ?", req.NboId).One()
-	if err != nil {
-		return 0, err
-	}
-	if c != nil {
-		return 0, myerrors.TipsError("所选项目已添加合同")
-	}
+	// c, err = s.Dao.Where("nbo_id = ?", req.NboId).One()
+	// if err != nil {
+	// 	return 0, err
+	// }
+	// if c != nil {
+	// 	return 0, myerrors.TipsError("所选项目已添加合同")
+	// }
 
 	sequence, err := service.Sequence(s.Dao.DB, "contract_code")
 	if err != nil {

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

@@ -328,6 +328,48 @@ func (s *CustomerService) AssignCustomerRequest(ctx context.Context, req *model.
 		}
 	}
 
+	city := []string{}
+	cityData := s.DataScope["cust_city_id"]
+	if cityData != nil {
+		for _, i := range cityData.([]interface{}) {
+			city = append(city, i.(string))
+		}
+	}
+	fmt.Println(city)
+	cust := []*model.CustCustomer{}
+	noNeedApprovalCust := []*model.CustCustomer{}
+	noNeedApprovalCustId := []int64{}
+	for _, v := range data {
+		if service.StringSlicecontains(city, strconv.Itoa(v.CustCityId)) {
+			noNeedApprovalCust = append(noNeedApprovalCust, v)
+			noNeedApprovalCustId = append(noNeedApprovalCustId, int64(v.Id))
+		} else {
+			cust = append(cust, v)
+		}
+	}
+
+	if len(noNeedApprovalCustId) != 0 {
+		err = s.ChangeCustBelong(noNeedApprovalCustId, req.SalesId, req.SalesName)
+		if err != nil {
+			return err
+		}
+		req.Receive = AllocaTion
+		err = s.BatchCreatebelong(data, req)
+		if err != nil {
+			return err
+		}
+		err = s.CreateDynamics("领取客户", &model.AssignCustomerReq{
+			Ids:       noNeedApprovalCustId,
+			SalesId:   req.SalesId,
+			SalesName: req.SalesName,
+			Remark:    "",
+			Receive:   Receive,
+		}, noNeedApprovalCustId...)
+		if err != nil {
+			return err
+		}
+	}
+
 	remark, err := json.Marshal(map[string]string{
 		"applyUserId":   strconv.Itoa(s.GetCxtUserId()),
 		"applyUserName": s.GetCxtUserName(),
@@ -339,7 +381,7 @@ func (s *CustomerService) AssignCustomerRequest(ctx context.Context, req *model.
 	if err != nil {
 		return err
 	}
-	for _, u := range data {
+	for _, u := range cust {
 		bizCode := strconv.Itoa(u.Id) + ":" + strconv.Itoa(s.GetCxtUserId())
 		_, err = workflowSrv.StartProcessInstance(bizCode, "11", string(remark), &workflow.StartProcessInstanceRequest{
 			ProcessCode: &AssignCustomerRequestProcessCode,

+ 1 - 0
opms_parent/schema/customer.sql

@@ -23,6 +23,7 @@ CREATE TABLE `cust_customer` (
     `sales_name` varchar(90) DEFAULT NULL COMMENT '所属销售',
     `follow_up_date` datetime DEFAULT NULL COMMENT '最后跟进时间',
     `follow_up_man` VARCHAR(90) COMMENT '最后跟进人',
+    `invoice_header` varchar(255) DEFAULT NULL COMMENT '开票抬头',
     `remark` text DEFAULT NULL COMMENT '备注',
     `created_by` int(11) NOT NULL COMMENT '创建者',
     `created_name` varchar(90) NOT NULL COMMENT '创建人',

+ 4 - 1
opms_parent/schema/tmp.sql

@@ -22,4 +22,7 @@ alter table ctr_contract  add  `product_line` varchar(4) NOT NULL COMMENT '产
 
 alter table cust_customer drop column  cust_dist_code;
 alter table cust_customer drop column  cust_location;
-alter table ctr_contract modify `contract_end_time` datetime COMMENT '合同结束时间'
+alter table ctr_contract modify `contract_end_time` datetime COMMENT '合同结束时间'
+
+alter table base_distributor add `invoice_header` varchar(255) DEFAULT NULL COMMENT '开票抬头' after sale_num;
+alter table cust_customer add `invoice_header` varchar(255) DEFAULT NULL COMMENT '开票抬头' after follow_up_man;