浏览代码

no message

zhangchuanxing 4 月之前
父节点
当前提交
cb88f7446f

+ 5 - 0
controllers/company.go

@@ -2983,6 +2983,9 @@ func (this *CompanyController) Add() {
 	if productId == utils.COMPANY_PRODUCT_RAI_ID && req.Status == utils.COMPANY_STATUS_FOREVER { // 权益的永续客户给一个状态初始化的记录
 		companyProduct.InitStatus = req.Status
 	}
+
+	companyProduct.SellerIdInit = seller.AdminId
+	companyProduct.SellerNameInit = seller.RealName
 	companyProductId, err := company.AddCompanyProduct(companyProduct)
 	if err != nil {
 		br.Msg = "新增失败"
@@ -5119,6 +5122,8 @@ func (this *CompanyController) Receive() {
 		companyProduct.OpenCode = services.GenerateOpenCompanyProductCode(req.CompanyId, productId)
 		companyProduct.TodoStatus = "无任务"
 		companyProduct.TryStage = 1
+		companyProduct.SellerIdInit = seller.AdminId
+		companyProduct.SellerNameInit = seller.RealName
 		_, err = company.AddCompanyProduct(companyProduct)
 		if err != nil {
 			br.Msg = "新增失败"

+ 18 - 1
controllers/statistic_company_merge.go

@@ -2258,7 +2258,7 @@ func init323() {
 }
 
 //func init() {
-//	init16_1_02()
+//	init16_1_03()
 //}
 
 func init16_1_01() {
@@ -2320,3 +2320,20 @@ func init16_1_02() {
 		}
 	}
 }
+
+func init16_1_03() {
+	CompanyApprovalList, e := company.GetCompanyOperationRecordListinitcrm16_1()
+	if e != nil && e.Error() != utils.ErrNoRow() {
+		fmt.Println(e)
+		return
+	}
+
+	for _, v := range CompanyApprovalList {
+		fmt.Println(v.CompanyId, v.SellerId, "__", v.SysRealName)
+		e = company.UpdateCompanyProductsellerInit(v.SellerId, v.SysRealName, v.CompanyId, 2)
+		if e != nil {
+			fmt.Println(e)
+			return
+		}
+	}
+}

+ 9 - 2
models/company/company_operation_record.go

@@ -40,7 +40,7 @@ type CompanyOperationRecordList struct {
 	ProductName         string
 }
 
-//新增客户操作记录
+// 新增客户操作记录
 func AddCompanyOperationRecord(item *CompanyOperationRecord) (lastId int64, err error) {
 	o := orm.NewOrm()
 	lastId, err = o.Insert(item)
@@ -59,7 +59,7 @@ type CompanyOperationRecordListResp struct {
 	ShowButton bool
 }
 
-//获取客户正式转试用的次数
+// 获取客户正式转试用的次数
 func GetCompanyProductOperationRecordCount(companyId, productId int) (total int64, err error) {
 	o := orm.NewOrm()
 	sql := `SELECT count(1) ct FROM company_operation_record 
@@ -88,3 +88,10 @@ func GetTryOutCompanyOperationRecordList() (list []*CompanyOperationRecord, err
 	_, err = o.Raw(sql).QueryRows(&list)
 	return
 }
+
+func GetCompanyOperationRecordListinitcrm16_1() (items []*CompanyOperationRecord, err error) {
+	o := orm.NewOrm()
+	sql := `SELECT  * FROM company_operation_record WHERE  product_id =2 AND operation = 'add'     `
+	_, err = o.Raw(sql).QueryRows(&items)
+	return
+}

+ 10 - 0
models/company/company_product.go

@@ -62,6 +62,8 @@ type CompanyProduct struct {
 	ShareSellerId       int       `description:"共享销售员id"`
 	ShareGroupId        int       `description:"共享销售员所属分组ID"`
 	IsUserMaker         int       `description:"近四周之内是否包含决策人互动过 ,0否,1是"`
+	SellerIdInit        int       `description:"初始化所属销售id"`
+	SellerNameInit      string    `description:"初始化所属销售名称"`
 }
 
 // 新增客户产品
@@ -701,3 +703,11 @@ func UpdateSharGroupid(sharGroupid, shareSellerId int) (err error) {
 	_, err = o.Raw(sql, sharGroupid, shareSellerId).Exec()
 	return
 }
+
+// 更新公司初始化销售
+func UpdateCompanyProductsellerInit(seller_id_init int, seller_name_init string, companyId, productId int) (err error) {
+	o := orm.NewOrm()
+	sql := `UPDATE company_product SET seller_id_init=? , seller_name_init = ? WHERE company_id=? AND product_id=? `
+	_, err = o.Raw(sql, seller_id_init, seller_name_init, companyId, productId).Exec()
+	return
+}

+ 1 - 1
models/statistic_report.go

@@ -799,7 +799,7 @@ func GetIncrementalCompanyListByOperationRecord(condition string, pars []interfa
 	sql1 += ` GROUP BY a.company_id, a.product_id `
 
 	//查询真正的数据
-	sql := `SELECT a.id, a.company_id, a.sys_real_name as  seller_name_init , b.company_name, c.seller_id, c.seller_name, a.product_id, a.product_name, a.create_time, b.region_type, c.renewal_reason, c.renewal_todo, c.status FROM company_operation_record a
+	sql := `SELECT a.id, a.company_id, b.company_name, c.seller_id, c.seller_name, c.seller_name_init, a.product_id, a.product_name, a.create_time, b.region_type, c.renewal_reason, c.renewal_todo, c.status FROM company_operation_record a
 		RIGHT JOIN company b ON a.company_id = b.company_id
 		JOIN company_product c ON b.company_id = c.company_id 
 		AND a.product_id = c.product_id