Эх сурвалжийг харах

Merge branch 'dev/v1.0.7' of BaseService/biService into feature/v1.0.7

xuzhiheng 2 жил өмнө
parent
commit
e73e08ec14

+ 2 - 1
api/biService.api

@@ -49,7 +49,8 @@ type (
 	}
 
 	ClueImportReq {
-		Pcbh string `json:"pcbh"`
+		PositionId int64  `header:"positionId,optional"`
+		Pcbh       string `json:"pcbh"`
 	}
 )
 

+ 2 - 1
api/internal/logic/clueimportlogic.go

@@ -26,7 +26,8 @@ func NewClueImportLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ClueIm
 func (l *ClueImportLogic) ClueImport(req *types.ClueImportReq) (resp *types.Resp, err error) {
 	// todo: add your logic here and delete this line
 	res, err := l.svcCtx.BiServiceRpc.ClueImport(l.ctx, &biservice.ClueImportReq{
-		Pcbh: req.Pcbh,
+		Pcbh:       req.Pcbh,
+		PositionId: req.PositionId,
 	})
 	return &types.Resp{Error_code: res.ErrorCode, Error_msg: res.ErrorMsg, Data: res.Data}, err
 }

+ 2 - 1
api/internal/types/types.go

@@ -49,5 +49,6 @@ type DistributeClueReq struct {
 }
 
 type ClueImportReq struct {
-	Pcbh string `json:"pcbh"`
+	PositionId int64  `header:"positionId,optional"`
+	Pcbh       string `json:"pcbh"`
 }

+ 1 - 0
rpc/biService.proto

@@ -86,6 +86,7 @@ message DistributeDatas {
 
 message ClueImportReq {
 	string pcbh = 1;
+	int64 positionId = 2;
 }
 
 message ClueImportResp {

+ 13 - 3
rpc/pb/biService.pb.go

@@ -861,7 +861,8 @@ type ClueImportReq struct {
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
 
-	Pcbh string `protobuf:"bytes,1,opt,name=pcbh,proto3" json:"pcbh,omitempty"`
+	Pcbh       string `protobuf:"bytes,1,opt,name=pcbh,proto3" json:"pcbh,omitempty"`
+	PositionId int64  `protobuf:"varint,2,opt,name=positionId,proto3" json:"positionId,omitempty"`
 }
 
 func (x *ClueImportReq) Reset() {
@@ -903,6 +904,13 @@ func (x *ClueImportReq) GetPcbh() string {
 	return ""
 }
 
+func (x *ClueImportReq) GetPositionId() int64 {
+	if x != nil {
+		return x.PositionId
+	}
+	return 0
+}
+
 type ClueImportResp struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
@@ -1127,9 +1135,11 @@ var file_biService_proto_rawDesc = []byte{
 	0x65, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x2a, 0x0a, 0x10, 0x64, 0x69, 0x73,
 	0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x05, 0x20,
 	0x01, 0x28, 0x03, 0x52, 0x10, 0x64, 0x69, 0x73, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x64,
-	0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x23, 0x0a, 0x0d, 0x43, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70,
+	0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x43, 0x0a, 0x0d, 0x43, 0x6c, 0x75, 0x65, 0x49, 0x6d, 0x70,
 	0x6f, 0x72, 0x74, 0x52, 0x65, 0x71, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x63, 0x62, 0x68, 0x18, 0x01,
-	0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x63, 0x62, 0x68, 0x22, 0x6d, 0x0a, 0x0e, 0x43, 0x6c,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x63, 0x62, 0x68, 0x12, 0x1e, 0x0a, 0x0a, 0x70, 0x6f,
+	0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a,
+	0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x22, 0x6d, 0x0a, 0x0e, 0x43, 0x6c,
 	0x75, 0x65, 0x49, 0x6d, 0x70, 0x6f, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1d, 0x0a, 0x0a,
 	0x65, 0x72, 0x72, 0x6f, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03,
 	0x52, 0x09, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x65,

+ 133 - 5
service/clue.go

@@ -532,7 +532,11 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
 				})
 			} else {
 				for _, v := range dataArr {
-					clueData := JyBiTidb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": v["phone"]}, "", "")
+					phone := common.ObjToString(v["phone"])
+					cluename := common.ObjToString(v["cluename"])
+					name := common.ObjToString(v["name"])
+					position := common.ObjToString(v["position"])
+					clueData := JyBiTidb.FindOne("dwd_f_crm_clue_info", map[string]interface{}{"phone": phone}, "", "")
 					if clueData == nil || len(*clueData) == 0 {
 						countAdd++
 						JyBiTidb.Insert("dwd_f_crm_clue_info", map[string]interface{}{
@@ -542,21 +546,145 @@ func ClueImportSync(this *biservice.ClueImportReq) (string, int) {
 							"comeintime":   nowTime,
 							"createtime":   nowTime,
 							"updatetime":   nowTime,
-							"cluename":     v["cluename"],
+							"cluename":     cluename,
 							"top_cluetype": v["top_cluetype"],
 							"sub_cluetype": v["sub_cluetype"],
 							"trailstatus":  "01",
-							"name":         v["name"],
-							"phone":        v["phone"],
-							"position":     v["position"],
+							"name":         name,
+							"phone":        phone,
+							"position":     position,
 							"batch_import": this.Pcbh,
 						})
 					} else {
 						is_assign := common.IntAll((*clueData)["is_assign"])
+						clueId := common.Int64All((*clueData)["id"])
+						batch_import := common.ObjToString((*clueData)["batch_import"])
+						old_cluename := common.ObjToString((*clueData)["cluename"])
+						old_name := common.ObjToString((*clueData)["name"])
+						old_position := common.ObjToString((*clueData)["position"])
+						positionId := common.ObjToString((*clueData)["position_id"])
+						batch_imports := ""
 						if is_assign == 0 {
 							countOpen++
+							if batch_import != "" {
+								batch_imports = batch_import + "," + this.Pcbh
+							} else {
+								batch_imports = this.Pcbh
+							}
+							updateData := map[string]interface{}{
+								"batch_import": batch_imports,
+								"updatetime":   nowTime,
+								"top_cluetype": v["top_cluetype"],
+								"sub_cluetype": v["sub_cluetype"],
+							}
+							if cluename != "" && cluename != old_cluename {
+								updateData["cluename"] = cluename
+								JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+									"clue_id":      clueId,
+									"position_id":  -1,
+									"change_field": "cluename",
+									"change_type":  "基本信息变更",
+									"old_value":    old_cluename,
+									"new_value":    cluename,
+									"createtime":   nowTime,
+									"BCPCID":       common.GetRandom(32),
+									"operator_id":  this.PositionId,
+								})
+							}
+							if name != "" && name != old_name {
+								updateData["name"] = name
+								JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+									"clue_id":      clueId,
+									"position_id":  -1,
+									"change_field": "name",
+									"change_type":  "基本信息变更",
+									"old_value":    old_name,
+									"new_value":    name,
+									"createtime":   nowTime,
+									"BCPCID":       common.GetRandom(32),
+									"operator_id":  this.PositionId,
+								})
+							}
+							if position != "" && position != old_position {
+								updateData["position"] = position
+								JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+									"clue_id":      clueId,
+									"position_id":  -1,
+									"change_field": "position",
+									"change_type":  "基本信息变更",
+									"old_value":    old_position,
+									"new_value":    position,
+									"createtime":   nowTime,
+									"BCPCID":       common.GetRandom(32),
+									"operator_id":  this.PositionId,
+								})
+							}
+							JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, updateData)
 						} else if is_assign == 1 {
 							countPrivate++
+							updateData := map[string]interface{}{
+								"batch_import": batch_imports,
+								"updatetime":   nowTime,
+								"top_cluetype": v["top_cluetype"],
+								"sub_cluetype": v["sub_cluetype"],
+							}
+							updateData["is_task"] = 1
+							updateData["task_time"] = nowTime
+							updateData["tasktime"] = nowTime
+							updateData["taskstatus"] = 0
+							updateData["tasksource"] = "线索来源更新客户"
+							if cluename != "" && cluename != old_cluename {
+								updateData["cluename"] = cluename
+								JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+									"clue_id":      clueId,
+									"position_id":  positionId,
+									"change_field": "cluename",
+									"change_type":  "基本信息变更",
+									"old_value":    old_cluename,
+									"new_value":    cluename,
+									"createtime":   nowTime,
+									"BCPCID":       common.GetRandom(32),
+									"operator_id":  this.PositionId,
+								})
+							}
+							if name != "" && name != old_name {
+								updateData["name"] = name
+								JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+									"clue_id":      clueId,
+									"position_id":  positionId,
+									"change_field": "name",
+									"change_type":  "基本信息变更",
+									"old_value":    old_name,
+									"new_value":    name,
+									"createtime":   nowTime,
+									"BCPCID":       common.GetRandom(32),
+									"operator_id":  this.PositionId,
+								})
+							}
+							if position != "" && position != old_position {
+								updateData["position"] = position
+								JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+									"clue_id":      clueId,
+									"position_id":  positionId,
+									"change_field": "position",
+									"change_type":  "基本信息变更",
+									"old_value":    old_position,
+									"new_value":    position,
+									"createtime":   nowTime,
+									"BCPCID":       common.GetRandom(32),
+									"operator_id":  this.PositionId,
+								})
+							}
+							JyBiTidb.Update("dwd_f_crm_clue_info", map[string]interface{}{"id": clueId}, updateData)
+							JyBiTidb.Insert("dwd_f_crm_clue_change_record", map[string]interface{}{
+								"clue_id":     clueId,
+								"position_id": positionId,
+								"change_type": "加入任务车",
+								"new_value":   "线索来源更新客户",
+								"createtime":  nowTime,
+								"BCPCID":      common.GetRandom(32),
+								"operator_id": this.PositionId,
+							})
 						}
 					}
 				}