Commit 0875bfd3 by 孙龙

crm 监听数据库 同步公司 禁用启用 黑名单开启 关闭

parent d453e732
......@@ -2,6 +2,7 @@ package crm
import (
"encoding/json"
"fmt"
"github.com/ichunt2019/cfg/lib"
"github.com/ichunt2019/golang-rbmq-sl/utils/rabbitmq"
......@@ -14,6 +15,8 @@ type comUser struct {
ComId int64 `json:"com_id"`
UserId int64 `json:"user_id"`
SaleId int64 `json:"sale_id"`
IsDisable int64 `json:"is_disable"`
IsBlacklist int64 `json:"is_blacklist"`
}
......@@ -30,13 +33,13 @@ func DispenseMsg(data string) (err error){
table := gjson.Parse(data).Get("table").String()
action_type := gjson.Parse(data).Get("type").String()
olddata := gjson.Parse(data).Get("old").Map()
//fmt.Println(database,table,action_type,olddata)
fmt.Println(table,action_type,olddata)
//需要关心的操作
action_type_slice := []string{"update","insert"}
//需要关心的字段
lie_invoice_company_field := []string{"com_name","com_addr","com_tel","com_tax_registration","com_bank","com_bank_num","status"}
lie_invoice_company_field := []string{"com_name","com_addr","com_tel","com_tax_registration","com_bank","com_bank_num","status","company_category"}
lie_invoice_com_user_field := []string{"com_id","user_id","sale_id"}
pushMsg := comUser{}
......@@ -46,6 +49,22 @@ func DispenseMsg(data string) (err error){
if len(olddata) > 0{
//修改
for field,_ := range olddata{
company_category := gjson.Parse(data).Get("data.company_category").Int() //公司类别,1普通客户,2KA客户,3黑名单客户,4实体名单客户'
company_status := gjson.Parse(data).Get("data.status").Int()//状态 0禁用 1审核通过 2待审核 3审核未通过
if(field == "company_category"){//黑名单
if(company_category == 3){//加入黑名单
pushMsg.IsBlacklist = -1
}else{//解除黑名单
pushMsg.IsBlacklist = 1
}
}else if(field == "status"){//更改状态 禁用 启用
if(company_status == 0){ //禁用
pushMsg.IsDisable = -1
}else {//解除禁用
pushMsg.IsDisable = 1
}
}
if php2go.InArray(field,lie_invoice_company_field){
//分发
pushMsg.ComId = gjson.Parse(data).Get("data.id").Int()
......
......@@ -24,10 +24,10 @@ dob = 1979-05-27T07:32:00Z # 日期时间是一等公民。为什么不呢?
[rabbitmq_crm_comuser_fenfa]
queue_name="a-maxwell"
routing_key="maxwell.lie_invoice_company"
routing_key="a-maxwell"
exchange=""
type="direct"
dns="amqp://guest:guest@192.168.2.232:5672/"
dns="amqp://guest:guest@192.168.1.169:5672/"
[rabbitmq_crm_comuser]
......@@ -35,7 +35,7 @@ queue_name="crm_comusertoerp"
routing_key="crm_comusertoerp"
exchange=""
type="direct"
dns="amqp://guest:guest@192.168.2.232:5672/"
dns="amqp://guest:guest@192.168.1.252:5672/"
[rabbitmq_crm_invoice_com_apply]
......@@ -43,7 +43,7 @@ queue_name="crm_invoice_com_apply"
routing_key="crm_invoice_com_apply"
exchange=""
type="direct"
dns="amqp://guest:guest@192.168.2.232:5672/"
dns="amqp://guest:guest@192.168.1.252:5672/"
[rabbitmq_ichunt_wechat_focus]
......@@ -51,7 +51,7 @@ queue_name="szichunt_wechat_userinfo"
routing_key="szichunt_wechat_userinfo"
exchange=""
type="direct"
dns="amqp://guest:guest@192.168.2.232:5672/"
dns="amqp://guest:guest@192.168.1.252:5672/"
[servers]
......
......@@ -2,7 +2,7 @@
ShowSQL = true
[crm]
data_source_name = "liexin_crm:liexin_crm#zsyM@tcp(192.168.1.235:3306)/liexin_crm?charset=utf8&parseTime=true&loc=Asia%2FShanghai"
data_source_name = "liexin_crm:liexin_crm#zsyM@tcp(192.168.1.234:3306)/liexin_crm?charset=utf8&parseTime=true&loc=Asia%2FShanghai"
max_open_conn = 0
max_idle_conn = 0
table_prefix = "lie_"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment