Bläddra i källkod

fix:客户产品状态变更时,新增日志入库

Roc 3 år sedan
förälder
incheckning
6d1e37ac3b

+ 4 - 2
models/db_init.go

@@ -18,6 +18,7 @@ import (
 	"hongze/hongze_mobile_admin/models/tables/company_permission_log"
 	"hongze/hongze_mobile_admin/models/tables/company_product"
 	"hongze/hongze_mobile_admin/models/tables/company_product_log"
+	"hongze/hongze_mobile_admin/models/tables/company_product_update_log"
 	"hongze/hongze_mobile_admin/models/tables/company_report_permission"
 	"hongze/hongze_mobile_admin/models/tables/contract"
 	"hongze/hongze_mobile_admin/models/tables/contract_approval"
@@ -81,10 +82,11 @@ func init() {
 		new(resource.Resource),
 		new(wx_token.WxToken),
 		new(wx_user.WxUser),
-		new(seal.Seal), //用印表
-		new(seal.SealOperationRecord),	// 用印操作记录表
+		new(seal.Seal),                //用印表
+		new(seal.SealOperationRecord), // 用印操作记录表
 		new(roadshow.RsCalendar),
 		new(roadshow.RsCalendarResearcher),
+		new(company_product_update_log.CompanyProductUpdateLog), //客户产品状态变更记录表
 	)
 
 }

+ 23 - 0
models/tables/company_product_update_log/company_product_update_log.go

@@ -0,0 +1,23 @@
+package company_product_update_log
+
+import (
+	"github.com/rdlucklib/rdluck_tools/orm"
+	"time"
+)
+
+// CompanyProductUpdateLog 客户产品变更日志表
+type CompanyProductUpdateLog struct {
+	Id         int       `orm:"column(id);pk"`
+	CompanyId  int       `description:"客户id"`
+	ProductId  int       `description:"产品id"`
+	Status     string    `description:"变更后的状态"`
+	Source     string    `description:"来源"`
+	CreateTime time.Time `description:"创建时间"`
+}
+
+// AddCompanyProductUpdateLog 新增客户产品变更日志
+func AddCompanyProductUpdateLog(item *CompanyProductUpdateLog) (lastId int64, err error) {
+	o := orm.NewOrm()
+	lastId, err = o.Insert(item)
+	return
+}

+ 29 - 0
services/company_approval/company_approval.go

@@ -15,6 +15,7 @@ import (
 	"hongze/hongze_mobile_admin/models/tables/company_delay_permission"
 	"hongze/hongze_mobile_admin/models/tables/company_product"
 	"hongze/hongze_mobile_admin/models/tables/company_product_log"
+	"hongze/hongze_mobile_admin/models/tables/company_product_update_log"
 	"hongze/hongze_mobile_admin/models/tables/contract_approval"
 	"hongze/hongze_mobile_admin/models/tables/contract_approval_record"
 	"hongze/hongze_mobile_admin/services"
@@ -773,6 +774,34 @@ func afterApproved(companyApprovalId int, opUserId int, opUserName string) (err
 		services.AddCompanyOperationRecord(recodeInfo.CompanyId, companyProduct.SellerId, opUserId, recodeInfo.ProductId, opUserId, companyProduct.CompanyName,
 			companyProduct.ProductName, opUserName, remark, operation, approveContent, opUserName, "", companyProduct.Status)
 	}
+
+	//新增客户产品状态变更日志
+	{
+		updateSource := ``
+		switch recodeInfo.ApplyMethod {
+		case 1: //试用转正式
+			updateSource = `turn_positive`
+		case 2: //冻结->试用
+			updateSource = "thaw"
+		case 3: //试用延期
+			updateSource = "delay"
+		case 4: //原销售申请领取流失客户
+			updateSource = "apply_receive"
+		case 5: //正式客户申请续约
+			updateSource = "service_update"
+		case 6: //正式客户新增补充协议
+			updateSource = "add_agreement"
+		}
+		companyProductUpdateLog := &company_product_update_log.CompanyProductUpdateLog{
+			Id:         0,
+			CompanyId:  companyProduct.CompanyId,
+			ProductId:  companyProduct.ProductId,
+			Status:     companyProduct.Status,
+			Source:     updateSource,
+			CreateTime: time.Now(),
+		}
+		go company_product_update_log.AddCompanyProductUpdateLog(companyProductUpdateLog)
+	}
 	return
 }