Commit 2d137d12 by mushishixian

删除无关代码

parent b237c424
<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:ax2179="http://host.com/xsd" xmlns:ns1="http://org.apache.axis2/xsd" xmlns:ns="http://pdf.host.com" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ax2178="http://pdf.host.com/xsd" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" targetNamespace="http://pdf.host.com">
<wsdl:documentation>DataEndpoint</wsdl:documentation>
<wsdl:types>
<xs:schema xmlns:ax2181="http://pdf.host.com/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pdf.host.com">
<xs:import namespace="http://pdf.host.com/xsd"/>
<xs:element name="getData">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="request" nillable="true" type="ax2178:DataGenerationReq"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="getDataResp">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="return" nillable="true" type="ax2178:DataGenerationResp"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<xs:schema attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://host.com/xsd">
<xs:complexType name="BaseReq">
<xs:sequence>
<xs:element minOccurs="0" name="clientIdentification" nillable="true" type="ax2179:ClientIdentification"/>
</xs:sequence>
<xs:attribute name="TestAttr" type="xs:string"></xs:attribute>
</xs:complexType>
<xs:complexType name="BaseResp">
<xs:sequence>
<xs:element minOccurs="0" name="errorDetails" nillable="true" type="ax2179:ErrorDetails"/>
<xs:element minOccurs="0" name="success" type="xs:boolean"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
<xs:schema xmlns:ax2180="http://host.com/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://pdf.host.com/xsd">
<xs:import namespace="http://host.com/xsd"/>
<xs:complexType name="DataGenerationReq">
<xs:complexContent>
<xs:extension base="ax2180:BaseReq">
<xs:sequence>
<xs:element minOccurs="0" name="customerAccountNumber" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="pdfGenerationReqType" type="xs:int"/>
<xs:element minOccurs="0" name="withCreditTranferForm" type="xs:boolean"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="DataGenerationResp">
<xs:complexContent>
<xs:extension base="ax2180:BaseResp">
<xs:sequence>
<xs:element minOccurs="0" name="pdf" nillable="true" type="xs:base64Binary"/>
<xs:element minOccurs="0" name="url" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
</xs:schema>
</wsdl:types>
<wsdl:message name="getDataReq">
<wsdl:part name="parameters" element="ns:getData"/>
</wsdl:message>
<wsdl:message name="getDataResp">
<wsdl:part name="parameters" element="ns:getDataResp"/>
</wsdl:message>
<wsdl:portType name="DataEndpointPortType">
<wsdl:operation name="getData">
<wsdl:input message="ns:getDataReq" wsaw:Action="urn:getData"/>
<wsdl:output message="ns:getDataResp" wsaw:Action="urn:getDataResp"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="DataEndpointSoap11Binding" type="ns:DataEndpointPortType">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="getData">
<soap:operation soapAction="urn:getData" style="document"/>
<wsdl:input>
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="DataEndpointSoap12Binding" type="ns:DataEndpointPortType">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<wsdl:operation name="getData">
<soap12:operation soapAction="urn:getData" style="document"/>
<wsdl:input>
<soap12:body use="literal"/>
</wsdl:input>
<wsdl:output>
<soap12:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="DataEndpointHttpBinding" type="ns:DataEndpointPortType">
<http:binding verb="POST"/>
<wsdl:operation name="getData">
<http:operation location="DataEndpoint/getData"/>
<wsdl:input>
<mime:content type="text/xml" part="getData"/>
</wsdl:input>
<wsdl:output>
<mime:content type="text/xml" part="getData"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="DataEndpoint">
<wsdl:port name="DataEndpointHttpSoap11Endpoint" binding="ns:DataEndpointSoap11Binding">
<soap:address location="https://apitest.host.com/services/DataEndpoint.DataEndpointHttpSoap11Endpoint/"/>
</wsdl:port>
<wsdl:port name="DataEndpointHttpSoap12Endpoint" binding="ns:DataEndpointSoap12Binding">
<soap12:address location="https://apitest.host.com/services/DataEndpoint.DataEndpointHttpSoap12Endpoint/"/>
</wsdl:port>
<wsdl:port name="DataEndpointHttpEndpoint" binding="ns:DataEndpointHttpBinding">
<http:address location="https://apitest.host.com/services/DataEndpoint.DataEndpointHttpEndpoint/"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
\ No newline at end of file
...@@ -44,7 +44,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error { ...@@ -44,7 +44,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
if err = json.Unmarshal(dataByte, &message); err != nil { if err = json.Unmarshal(dataByte, &message); err != nil {
goto ERR goto ERR
} }
//转换成customer数据 //转换成customer数据
customer.ErpId = message.Data.FID customer.ErpId = message.Data.FID
customer.ErpClientCode = message.Data.FNUMBER customer.ErpClientCode = message.Data.FNUMBER
...@@ -66,7 +65,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error { ...@@ -66,7 +65,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
} }
case "delete": case "delete":
operateType = "delete" operateType = "delete"
fmt.Println(customer.ErpId)
customer.Status = 0 customer.Status = 0
if logic.CheckCustomerExist(customer.ErpId) { if logic.CheckCustomerExist(customer.ErpId) {
//如果存在,才进行删除 //如果存在,才进行删除
...@@ -91,11 +89,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error { ...@@ -91,11 +89,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
} }
return nil return nil
ERR: ERR:
//不存在的erp_id不去操作对应的数据库
if customer.ErpId != "" {
logSyncErrorToCustomer(customer.ErpId, err.Error())
}
//还要存到一个统一错误表 //还要存到一个统一错误表
syncLog = model.SyncLog{ syncLog = model.SyncLog{
AddTime: time.Now().Unix(), AddTime: time.Now().Unix(),
...@@ -105,7 +98,9 @@ ERR: ...@@ -105,7 +98,9 @@ ERR:
SyncError: err.Error(), SyncError: err.Error(),
SyncName: "customer", SyncName: "customer",
} }
logic.InsertSyncLog(syncLog) if err = logic.InsertSyncLog(syncLog); err != nil {
service.SendMessage(common.ErrorSendPhone, err.Error())
}
//发送钉钉错误消息 //发送钉钉错误消息
msg, _ := json.Marshal(syncLog) msg, _ := json.Marshal(syncLog)
...@@ -116,11 +111,6 @@ ERR: ...@@ -116,11 +111,6 @@ ERR:
return nil return nil
} }
func (t *RecvPro) FailAction(dataByte []byte) error {
fmt.Println("任务处理失败了,发送钉钉消息通知主人")
return nil
}
//同步数据 //同步数据
func SyncCustomerData(operate string, customer model.Customer) (err error) { func SyncCustomerData(operate string, customer model.Customer) (err error) {
var ( var (
...@@ -157,10 +147,6 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) { ...@@ -157,10 +147,6 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) {
paramJson, _ := json.Marshal(param) paramJson, _ := json.Marshal(param)
return errors.New(fmt.Sprintf("请求后端接口返回失败,接口链接为%s,请求参数为%s,返回的错误信息为 : %s", url, string(paramJson), respData.Errmsg)) return errors.New(fmt.Sprintf("请求后端接口返回失败,接口链接为%s,请求参数为%s,返回的错误信息为 : %s", url, string(paramJson), respData.Errmsg))
} }
//都没问题,代表后端那边已经成功修改,修改同步表的状态
if err = logic.SyncCustomerSuccess(customer.ErpId); err != nil {
return
}
} else { } else {
param = req.Param{ param = req.Param{
"erp_customer_id": customer.ErpId, "erp_customer_id": customer.ErpId,
...@@ -180,21 +166,17 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) { ...@@ -180,21 +166,17 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) {
paramJson, _ := json.Marshal(param) paramJson, _ := json.Marshal(param)
return errors.New(fmt.Sprintf("请求后端接口返回失败,接口链接为%s,请求参数为%s,返回的错误信息为 : %s", url, string(paramJson), respData.Errmsg)) return errors.New(fmt.Sprintf("请求后端接口返回失败,接口链接为%s,请求参数为%s,返回的错误信息为 : %s", url, string(paramJson), respData.Errmsg))
} }
//都没问题,代表后端那边已经成功修改,修改同步表的状态 }
if err = logic.SyncCustomerSuccess(customer.ErpId); err != nil { //都没问题,代表后端那边已经成功修改,修改同步表的状态
return if err = logic.SyncCustomerSuccess(customer.ErpId); err != nil {
} return
} }
return return
} }
func logSyncErrorToCustomer(erpId, syncError string) { func (t *RecvPro) FailAction(dataByte []byte) error {
var err error fmt.Println("任务处理失败了,发送钉钉消息通知主人")
//请求失败的话,将原因存起来 return nil
if err = logic.WriteCustomerSyncError(erpId, syncError); err != nil {
//数据库错误,发送警告
service.SendMessage(common.ErrorSendPhone, err.Error())
}
} }
func main() { func main() {
......
...@@ -92,11 +92,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error { ...@@ -92,11 +92,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
} }
return nil return nil
ERR: ERR:
//不存在的erp_id不去操作对应的数据库
if goods.ErpId != "" {
logSyncErrorToGoods(goods.ErpId, err.Error())
}
//还要存到一个统一错误表 //还要存到一个统一错误表
syncLog = model.SyncLog{ syncLog = model.SyncLog{
AddTime: time.Now().Unix(), AddTime: time.Now().Unix(),
...@@ -106,22 +101,19 @@ ERR: ...@@ -106,22 +101,19 @@ ERR:
SyncError: err.Error(), SyncError: err.Error(),
SyncName: "goods", SyncName: "goods",
} }
logic.InsertSyncLog(syncLog) //错误日志插入错误,需要告警
if err = logic.InsertSyncLog(syncLog); err != nil {
service.SendMessage(common.ErrorSendPhone, err.Error())
}
//发送钉钉错误消息 //发送钉钉错误消息
msg, _ := json.Marshal(syncLog) msg, _ := json.Marshal(syncLog)
service.SendMessage(common.ErrorSendPhone, string(msg)) service.SendMessage(common.ErrorSendPhone, string(msg))
//保存日志 //保存日志
log.Error("%s", string(msg)) log.Error("%s", string(msg))
return nil return nil
} }
func (t *RecvPro) FailAction(dataByte []byte) error {
fmt.Println("任务处理失败了,发送钉钉消息通知主人")
return nil
}
//同步数据 //同步数据
func SyncGoodsData(operate string, goods model.Goods) (err error) { func SyncGoodsData(operate string, goods model.Goods) (err error) {
var ( var (
...@@ -159,10 +151,6 @@ func SyncGoodsData(operate string, goods model.Goods) (err error) { ...@@ -159,10 +151,6 @@ func SyncGoodsData(operate string, goods model.Goods) (err error) {
paramJson, _ := json.Marshal(param) paramJson, _ := json.Marshal(param)
return errors.New(fmt.Sprintf("请求后端接口返回失败,接口链接为%s,请求参数为%s,返回的错误信息为 : %s", url, string(paramJson), respData.Errmsg)) return errors.New(fmt.Sprintf("请求后端接口返回失败,接口链接为%s,请求参数为%s,返回的错误信息为 : %s", url, string(paramJson), respData.Errmsg))
} }
//都没问题,代表后端那边已经成功修改,修改同步表的状态
if err = logic.SyncGoodsSuccess(goods.ErpId, false); err != nil {
return
}
} else { } else {
//删除,软删除 //删除,软删除
param := req.Param{ param := req.Param{
...@@ -182,22 +170,17 @@ func SyncGoodsData(operate string, goods model.Goods) (err error) { ...@@ -182,22 +170,17 @@ func SyncGoodsData(operate string, goods model.Goods) (err error) {
paramJson, _ := json.Marshal(param) paramJson, _ := json.Marshal(param)
return errors.New(fmt.Sprintf("请求后端接口返回失败,接口链接为%s,请求参数为%s,返回的错误信息为 : %s", url, string(paramJson), respData.Errmsg)) return errors.New(fmt.Sprintf("请求后端接口返回失败,接口链接为%s,请求参数为%s,返回的错误信息为 : %s", url, string(paramJson), respData.Errmsg))
} }
//都没问题,代表后端那边已经成功修改,修改同步表的状态
if err = logic.SyncGoodsSuccess(goods.ErpId, true); err != nil {
return
}
} }
//都没问题,代表后端那边已经成功修改,修改同步表的状态
if err = logic.SyncGoodsSuccess(goods.ErpId, false); err != nil {
return
}
return return
} }
func logSyncErrorToGoods(erpId, syncError string) { func (t *RecvPro) FailAction(dataByte []byte) error {
var err error fmt.Println("任务处理失败了,发送钉钉消息通知主人")
//请求失败的话,将原因存起来 return nil
if err = logic.WriteGoodsSyncError(erpId, syncError); err != nil {
//数据库错误,发送警告
service.SendMessage(common.ErrorSendPhone, err.Error())
}
} }
func main() { func main() {
......
...@@ -110,10 +110,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error { ...@@ -110,10 +110,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
} }
return nil return nil
ERR: ERR:
//不存在的billId不去操作对应的数据库
if inStore.BillId != "" {
logSyncErrorToInStore(inStore.BillId, err.Error())
}
//还要存到一个统一错误表 //还要存到一个统一错误表
syncLog = model.SyncLog{ syncLog = model.SyncLog{
AddTime: time.Now().Unix(), AddTime: time.Now().Unix(),
...@@ -123,21 +119,18 @@ ERR: ...@@ -123,21 +119,18 @@ ERR:
SyncError: err.Error(), SyncError: err.Error(),
SyncName: "inStore", SyncName: "inStore",
} }
logic.InsertSyncLog(syncLog) //错误日志插入错误,需要告警
if err = logic.InsertSyncLog(syncLog); err != nil {
service.SendMessage(common.ErrorSendPhone, err.Error())
}
//发送钉钉错误消息 //发送钉钉错误消息
msg, _ = json.Marshal(syncLog) msg, _ = json.Marshal(syncLog)
service.SendMessage(common.ErrorSendPhone, string(msg)) service.SendMessage(common.ErrorSendPhone, string(msg))
//保存日志 //保存日志
log.Error("%s", string(msg)) log.Error("%s", string(msg))
return nil return nil
} }
func (t *RecvPro) FailAction(dataByte []byte) error {
fmt.Println("任务处理失败了,发送钉钉消息通知主人")
return nil
}
//同步数据 //同步数据
func SyncInStoreData(operate string, message InStoreMessage) (err error) { func SyncInStoreData(operate string, message InStoreMessage) (err error) {
var ( var (
...@@ -147,7 +140,7 @@ func SyncInStoreData(operate string, message InStoreMessage) (err error) { ...@@ -147,7 +140,7 @@ func SyncInStoreData(operate string, message InStoreMessage) (err error) {
params req.Param params req.Param
) )
params = TransformParams(message) params = TransformParams(message)
//更新和插入接口不同 //目前还在考虑删除
if operate == "insert" { if operate == "insert" {
url = configs.InStoreApiUrl + "/in_store/add" url = configs.InStoreApiUrl + "/in_store/add"
} else { } else {
...@@ -175,15 +168,6 @@ func SyncInStoreData(operate string, message InStoreMessage) (err error) { ...@@ -175,15 +168,6 @@ func SyncInStoreData(operate string, message InStoreMessage) (err error) {
return return
} }
func logSyncErrorToInStore(erpId, syncError string) {
var err error
//请求失败的话,将原因存起来
if err = logic.WriteInStoreSyncError(erpId, syncError); err != nil {
//数据库错误,发送警告
service.SendMessage(common.ErrorSendPhone, err.Error())
}
}
func TransformParams(message InStoreMessage) (result req.Param) { func TransformParams(message InStoreMessage) (result req.Param) {
var ( var (
entry InStoreFEntrys entry InStoreFEntrys
...@@ -252,6 +236,11 @@ func TransformParams(message InStoreMessage) (result req.Param) { ...@@ -252,6 +236,11 @@ func TransformParams(message InStoreMessage) (result req.Param) {
return result return result
} }
func (t *RecvPro) FailAction(dataByte []byte) error {
fmt.Println("任务处理失败了,发送钉钉消息通知主人")
return nil
}
func main() { func main() {
t := &RecvPro{} t := &RecvPro{}
rabbitmq.Recv(rabbitmq.QueueExchange{ rabbitmq.Recv(rabbitmq.QueueExchange{
......
...@@ -111,11 +111,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error { ...@@ -111,11 +111,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
} }
return nil return nil
ERR: ERR:
//不存在的billId不去操作对应的数据库
if outStore.BillId != "" {
logSyncErrorToOutStore(outStore.BillId, err.Error())
}
//还要存到一个统一错误表 //还要存到一个统一错误表
syncLog = model.SyncLog{ syncLog = model.SyncLog{
AddTime: time.Now().Unix(), AddTime: time.Now().Unix(),
...@@ -125,7 +120,10 @@ ERR: ...@@ -125,7 +120,10 @@ ERR:
SyncError: err.Error(), SyncError: err.Error(),
SyncName: "outStore", SyncName: "outStore",
} }
logic.InsertSyncLog(syncLog) //错误日志插入错误,需要告警
if err = logic.InsertSyncLog(syncLog); err != nil {
service.SendMessage(common.ErrorSendPhone, err.Error())
}
//发送钉钉错误消息 //发送钉钉错误消息
msg, _ = json.Marshal(syncLog) msg, _ = json.Marshal(syncLog)
service.SendMessage(common.ErrorSendPhone, string(msg)) service.SendMessage(common.ErrorSendPhone, string(msg))
...@@ -135,11 +133,6 @@ ERR: ...@@ -135,11 +133,6 @@ ERR:
return nil return nil
} }
func (t *RecvPro) FailAction(dataByte []byte) error {
fmt.Println("任务处理失败了,发送钉钉消息通知主人")
return nil
}
//同步数据 //同步数据
func SyncOutStoreData(operate string, message OutStoreMessage) (err error) { func SyncOutStoreData(operate string, message OutStoreMessage) (err error) {
var ( var (
...@@ -180,15 +173,6 @@ func SyncOutStoreData(operate string, message OutStoreMessage) (err error) { ...@@ -180,15 +173,6 @@ func SyncOutStoreData(operate string, message OutStoreMessage) (err error) {
return return
} }
func logSyncErrorToOutStore(erpId, syncError string) {
var err error
//请求失败的话,将原因存起来
if err = logic.WriteOutStoreSyncError(erpId, syncError); err != nil {
//数据库错误,发送警告
service.SendMessage(common.ErrorSendPhone, err.Error())
}
}
func TransformParams(message OutStoreMessage) (params map[string]interface{}) { func TransformParams(message OutStoreMessage) (params map[string]interface{}) {
var ( var (
entry OutStoreFEntrys entry OutStoreFEntrys
...@@ -221,7 +205,6 @@ func TransformParams(message OutStoreMessage) (params map[string]interface{}) { ...@@ -221,7 +205,6 @@ func TransformParams(message OutStoreMessage) (params map[string]interface{}) {
"receive_address": message.Data.FRecPersonAddress, "receive_address": message.Data.FRecPersonAddress,
"receive_user_name": message.Data.FRecPerson, "receive_user_name": message.Data.FRecPerson,
"receive_tel": message.Data.FRecPersonContact, "receive_tel": message.Data.FRecPersonContact,
//缺一个原始单据id
"erp_in_store_id": message.Data.FSourceBillID, "erp_in_store_id": message.Data.FSourceBillID,
"erp_client_sn": message.Data.FPrincipalNo, "erp_client_sn": message.Data.FPrincipalNo,
"remark": message.Data.Remark, "remark": message.Data.Remark,
...@@ -233,6 +216,11 @@ func TransformParams(message OutStoreMessage) (params map[string]interface{}) { ...@@ -233,6 +216,11 @@ func TransformParams(message OutStoreMessage) (params map[string]interface{}) {
return return
} }
func (t *RecvPro) FailAction(dataByte []byte) error {
fmt.Println("任务处理失败了,发送钉钉消息通知主人")
return nil
}
func main() { func main() {
t := &RecvPro{} t := &RecvPro{}
rabbitmq.Recv(rabbitmq.QueueExchange{ rabbitmq.Recv(rabbitmq.QueueExchange{
......
...@@ -9,7 +9,11 @@ import ( ...@@ -9,7 +9,11 @@ import (
"github.com/mushishixian/gosoap" "github.com/mushishixian/gosoap"
"github.com/pkg/errors" "github.com/pkg/errors"
"scm_server/configs" "scm_server/configs"
"scm_server/internal/common"
"scm_server/internal/logic" "scm_server/internal/logic"
"scm_server/internal/model"
"scm_server/internal/service"
"time"
) )
type RecvPro struct { type RecvPro struct {
...@@ -28,7 +32,8 @@ func init() { ...@@ -28,7 +32,8 @@ func init() {
func (t *RecvPro) Consumer(dataByte []byte) (err error) { func (t *RecvPro) Consumer(dataByte []byte) (err error) {
fmt.Println(string(dataByte)) fmt.Println(string(dataByte))
var ( var (
message QueueStatus message QueueStatus
syncStatusLog model.SyncStatusLog
) )
//先去转换队列消息的json //先去转换队列消息的json
if err = json.Unmarshal(dataByte, &message); err != nil { if err = json.Unmarshal(dataByte, &message); err != nil {
...@@ -41,16 +46,15 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) { ...@@ -41,16 +46,15 @@ func (t *RecvPro) Consumer(dataByte []byte) (err error) {
} }
return nil return nil
ERR: ERR:
syncStatusLog.SyncName = message.SyncName
syncStatusLog.UniqueId = message.ErpId
syncStatusLog.SyncError = err.Error()
syncStatusLog.AddTime = time.Now().Unix()
//如果失败了,记录到表,并且发送钉钉消息 //如果失败了,记录到表,并且发送钉钉消息
fmt.Println(err) if err = logic.InsertSyncStatusLog(syncStatusLog); err != nil {
if err = logic.InsertSyncStatusLog(message.SyncName, message.ErpId, err.Error()); err != nil { service.SendMessage(common.ErrorSendPhone, err.Error())
fmt.Println(err)
} }
return nil service.SendMessage(common.ErrorSendPhone, syncStatusLog.SyncError)
}
func (t *RecvPro) FailAction(dataByte []byte) error {
fmt.Println("任务处理失败了,发送钉钉消息通知主人")
return nil return nil
} }
...@@ -121,14 +125,11 @@ func SyncErpDataStatus(syncName, uniqueId string) (err error) { ...@@ -121,14 +125,11 @@ func SyncErpDataStatus(syncName, uniqueId string) (err error) {
default: default:
return errors.New("同步金蝶状态出现非法的同步类型" + syncName) return errors.New("同步金蝶状态出现非法的同步类型" + syncName)
} }
fmt.Println(syncName)
fmt.Println(apiMethod) fmt.Println(apiMethod)
fmt.Println(apiUrl)
soap, err = gosoap.SoapClient(apiUrl) soap, err = gosoap.SoapClient(apiUrl)
if err != nil { if err != nil {
return return
} }
fmt.Println(fmt.Sprintf(`{"FType":"%s", "FID":"%s"}`, syncName, uniqueId))
params = gosoap.ArrayParams{ params = gosoap.ArrayParams{
{"json", fmt.Sprintf(`{"FType":"%s", "FID":"%s"}`, syncName, uniqueId)}, {"json", fmt.Sprintf(`{"FType":"%s", "FID":"%s"}`, syncName, uniqueId)},
} }
...@@ -204,6 +205,11 @@ func CheckBillDataRequest(res *gosoap.Response) (err error) { ...@@ -204,6 +205,11 @@ func CheckBillDataRequest(res *gosoap.Response) (err error) {
return errors.New("金蝶返回响应格式无法识别") return errors.New("金蝶返回响应格式无法识别")
} }
func (t *RecvPro) FailAction(dataByte []byte) error {
fmt.Println("任务处理失败了,发送钉钉消息通知主人")
return nil
}
func main() { func main() {
t := &RecvPro{} t := &RecvPro{}
rabbitmq.Recv(rabbitmq.QueueExchange{ rabbitmq.Recv(rabbitmq.QueueExchange{
......
...@@ -90,11 +90,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error { ...@@ -90,11 +90,6 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
} }
return nil return nil
ERR: ERR:
//不存在的erp_id不去操作对应的数据库
if supplier.ErpId != "" {
logSyncErrorToSupplier(supplier.ErpId, err.Error())
}
//还要存到一个统一错误表 //还要存到一个统一错误表
syncLog = model.SyncLog{ syncLog = model.SyncLog{
AddTime: time.Now().Unix(), AddTime: time.Now().Unix(),
...@@ -104,7 +99,9 @@ ERR: ...@@ -104,7 +99,9 @@ ERR:
SyncError: err.Error(), SyncError: err.Error(),
SyncName: "supplier", SyncName: "supplier",
} }
logic.InsertSyncLog(syncLog) if err = logic.InsertSyncLog(syncLog); err != nil {
service.SendMessage(common.ErrorSendPhone, err.Error())
}
//发送钉钉错误消息 //发送钉钉错误消息
msg, _ := json.Marshal(syncLog) msg, _ := json.Marshal(syncLog)
service.SendMessage(common.ErrorSendPhone, string(msg)) service.SendMessage(common.ErrorSendPhone, string(msg))
...@@ -114,11 +111,6 @@ ERR: ...@@ -114,11 +111,6 @@ ERR:
return nil return nil
} }
func (t *RecvPro) FailAction(dataByte []byte) error {
fmt.Println("任务处理失败了,发送钉钉消息通知主人")
return nil
}
//同步数据 //同步数据
func SyncSupplierData(operate string, supplier model.Supplier) (err error) { func SyncSupplierData(operate string, supplier model.Supplier) (err error) {
var ( var (
...@@ -155,10 +147,6 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) { ...@@ -155,10 +147,6 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) {
paramJson, _ := json.Marshal(param) paramJson, _ := json.Marshal(param)
return errors.New(fmt.Sprintf("请求后端接口返回失败,接口链接为%s,请求参数为%s,返回的错误信息为 : %s", url, string(paramJson), respData.Errmsg)) return errors.New(fmt.Sprintf("请求后端接口返回失败,接口链接为%s,请求参数为%s,返回的错误信息为 : %s", url, string(paramJson), respData.Errmsg))
} }
//都没问题,代表后端那边已经成功修改,修改同步表的状态
if err = logic.SyncSupplierSuccess(supplier.ErpId); err != nil {
return
}
} else { } else {
param = req.Param{ param = req.Param{
"erp_supplier_id": supplier.ErpId, "erp_supplier_id": supplier.ErpId,
...@@ -178,21 +166,17 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) { ...@@ -178,21 +166,17 @@ func SyncSupplierData(operate string, supplier model.Supplier) (err error) {
paramJson, _ := json.Marshal(param) paramJson, _ := json.Marshal(param)
return errors.New(fmt.Sprintf("请求后端接口返回失败,接口链接为%s,请求参数为%s,返回的错误信息为 : %s", url, string(paramJson), respData.Errmsg)) return errors.New(fmt.Sprintf("请求后端接口返回失败,接口链接为%s,请求参数为%s,返回的错误信息为 : %s", url, string(paramJson), respData.Errmsg))
} }
//都没问题,代表后端那边已经成功修改,修改同步表的状态 }
if err = logic.SyncCustomerSuccess(supplier.ErpId); err != nil { //都没问题,代表后端那边已经成功修改,修改同步表的状态
return if err = logic.SyncCustomerSuccess(supplier.ErpId); err != nil {
} return
} }
return return
} }
func logSyncErrorToSupplier(erpId, syncError string) { func (t *RecvPro) FailAction(dataByte []byte) error {
var err error fmt.Println("任务处理失败了,发送钉钉消息通知主人")
//请求失败的话,将原因存起来 return nil
if err = logic.WriteSupplierSyncError(erpId, syncError); err != nil {
//数据库错误,发送警告
service.SendMessage(common.ErrorSendPhone, err.Error())
}
} }
func main() { func main() {
......
package main
import (
"scm_server/internal/dao"
"scm_server/internal/model"
)
//向crm中插入数据
const INSERTFEEDBACK = "INSERT INTO `lie_feedback` (`user_id`, `outter_uid`, `ip`, `type`, `mobile`, `content`, `source`, `pf`, `status`, `sale_id`, `bom_url`, `responses`,`create_time`)VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"
//查询主库里面的fb数据
const SELECTFEEDBACK = "select `user_id`, `ip`, `type`, `mobile`, `content`, `create_time`, `source`, `pf`, `status`, `sale_id`, `bom_url`, `responses`, `create_time` from lie_feedback where id = ?"
func main() {
//增加rabbitmq推送过来的数据
var lieXinFeedBack model.Feedback
var lieXinFeedId int = 2
var User_Id int
err := dao.GetLiexinDb().QueryRowx(SELECTFEEDBACK,lieXinFeedId).StructScan(&lieXinFeedBack)
err_two := dao.GetDb().QueryRowx("select user_id from lie_user where outter_uid = ?",lieXinFeedBack.User_Id).Scan(&User_Id)
if err == nil && err_two == nil && User_Id != 0 {
lieXinFeedBack.Outter_Uid = lieXinFeedBack.User_Id
lieXinFeedBack.User_Id = User_Id
row,insertErr := dao.GetDb().Exec(INSERTFEEDBACK,lieXinFeedBack.User_Id,lieXinFeedBack.Outter_Uid,lieXinFeedBack.Ip,lieXinFeedBack.Type,lieXinFeedBack.Mobile,lieXinFeedBack.Content,lieXinFeedBack.Source, lieXinFeedBack.Pf,lieXinFeedBack.Status,lieXinFeedBack.Sale_Id,lieXinFeedBack.Bom_Url,lieXinFeedBack.Responses,lieXinFeedBack.Create_Time)
insertId,_ := row.LastInsertId()
if insertErr == nil {
dao.GetDb().Exec("update lie_user set fkid = ? where user_id = ?",insertId,User_Id)
}
}
}
\ No newline at end of file
package main
import (
"scm_server/internal/dao"
"scm_server/internal/service"
"fmt"
"time"
)
//查询需要发送消息的数据
const USERMESSAGE = "select `lie_l`.`msg_log_id`, `lie_l`.`user_id`, `lie_l`.`fol_id`, `lie_f`.`next_details`, `lie_f`.`remind_type`, `lie_f`.`remind_time`, `lie_l`.`sale_id` from `lie_msg_log` as `lie_l` left join `lie_follow_up` as `lie_f` on `lie_l`.`fol_id` = `lie_f`.`fol_id` where (`lie_l`.`remind_type` = 5) and `lie_l`.`status` <> -1 and `lie_f`.`remind_type` = 'wait_notify' and `lie_f`.`remind_time` <= ? order by `lie_l`.`create_time` desc"
//查找用户手机号
const MOBILEVALUE = "select mobile from user_info where userId = ?"
//修改消息为已经发送
const UPDATEHAVEREAD = "update lie_msg_log set remind_type = ? and create_time = ? where msg_log_id = ? "
type UserMessage struct {
User_Id int `json:"user_id"`
Fol_Id int `json:"fol_id"`
Next_Details string `json:"next_details"`
Remind_Type string `json:"remind_type"`
Remind_Time int `json:"remind_time"`
Sale_Id int `json:"sale_id"`
Msg_Log_id int `json:"msg_log_id"`
}
//给用户发送消息
func main() {
var userMessage []UserMessage
var mobile int64
var timeNow = time.Now().Unix()
//查找出需要发送的数据
err := dao.GetDb().Select(&userMessage,USERMESSAGE,timeNow)
if err != nil{
service.WriteErr(err)
}
if len(userMessage) <= 0 {
panic("暂无需要发送的消息")
}
for _,v := range userMessage{
mobile = 0
err := dao.GetCmsDb().QueryRowx(MOBILEVALUE,v.Sale_Id).Scan(&mobile)
if mobile == 0 {
continue
}
service.SendMessage(mobile,v.Next_Details)
_,err = dao.GetDb().Exec(UPDATEHAVEREAD,1,timeNow,v.Msg_Log_id)
if err != nil {
fmt.Println(err)
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://192.168.2.253:6888/ormrpc/services/EASLogin" xmlns:intf="http://192.168.2.253:6888/ormrpc/services/EASLogin" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns1="urn:client" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="http://192.168.2.253:6888/ormrpc/services/EASLogin">
<!--WSDL created by Apache Axis version: 1.4
Built on Apr 22, 2006 (06:55:48 PDT)-->
<wsdl:types>
<schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:client">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="WSContext">
<sequence>
<element name="slnName" nillable="true" type="xsd:string"/>
<element name="password" nillable="true" type="xsd:string"/>
<element name="dbType" type="xsd:int"/>
<element name="userName" nillable="true" type="xsd:string"/>
<element name="sessionId" nillable="true" type="xsd:string"/>
<element name="dcName" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="logoutResponse">
<wsdl:part name="logoutReturn" type="xsd:boolean"></wsdl:part>
</wsdl:message>
<wsdl:message name="logoutRequest">
<wsdl:part name="userName" type="xsd:string"></wsdl:part>
<wsdl:part name="slnName" type="xsd:string"></wsdl:part>
<wsdl:part name="dcName" type="xsd:string"></wsdl:part>
<wsdl:part name="language" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="loginResponse2">
<wsdl:part name="loginReturn" type="tns1:WSContext"></wsdl:part>
</wsdl:message>
<wsdl:message name="loginRequest">
<wsdl:part name="userName" type="xsd:string"></wsdl:part>
<wsdl:part name="password" type="xsd:string"></wsdl:part>
<wsdl:part name="slnName" type="xsd:string"></wsdl:part>
<wsdl:part name="dcName" type="xsd:string"></wsdl:part>
<wsdl:part name="language" type="xsd:string"></wsdl:part>
<wsdl:part name="dbType" type="xsd:int"></wsdl:part>
</wsdl:message>
<wsdl:message name="loginRequest1">
<wsdl:part name="userName" type="xsd:string"></wsdl:part>
<wsdl:part name="password" type="xsd:string"></wsdl:part>
<wsdl:part name="slnName" type="xsd:string"></wsdl:part>
<wsdl:part name="dcName" type="xsd:string"></wsdl:part>
<wsdl:part name="language" type="xsd:string"></wsdl:part>
<wsdl:part name="dbType" type="xsd:int"></wsdl:part>
<wsdl:part name="authPattern" type="xsd:string"></wsdl:part>
</wsdl:message>
<wsdl:message name="loginResponse">
<wsdl:part name="loginReturn" type="tns1:WSContext"></wsdl:part>
</wsdl:message>
<wsdl:message name="loginRequest2">
<wsdl:part name="userName" type="xsd:string"></wsdl:part>
<wsdl:part name="password" type="xsd:string"></wsdl:part>
<wsdl:part name="slnName" type="xsd:string"></wsdl:part>
<wsdl:part name="dcName" type="xsd:string"></wsdl:part>
<wsdl:part name="language" type="xsd:string"></wsdl:part>
<wsdl:part name="dbType" type="xsd:int"></wsdl:part>
<wsdl:part name="authPattern" type="xsd:string"></wsdl:part>
<wsdl:part name="isEncodePwd" type="xsd:int"></wsdl:part>
</wsdl:message>
<wsdl:message name="loginResponse1">
<wsdl:part name="loginReturn" type="tns1:WSContext"></wsdl:part>
</wsdl:message>
<wsdl:portType name="EASLoginProxy">
<wsdl:operation name="login" parameterOrder="userName password slnName dcName language dbType">
<wsdl:input message="intf:loginRequest" name="loginRequest"></wsdl:input>
<wsdl:output message="intf:loginResponse" name="loginResponse"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="login" parameterOrder="userName password slnName dcName language dbType authPattern">
<wsdl:input message="intf:loginRequest1" name="loginRequest1"></wsdl:input>
<wsdl:output message="intf:loginResponse1" name="loginResponse1"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="login" parameterOrder="userName password slnName dcName language dbType authPattern isEncodePwd">
<wsdl:input message="intf:loginRequest2" name="loginRequest2"></wsdl:input>
<wsdl:output message="intf:loginResponse2" name="loginResponse2"></wsdl:output>
</wsdl:operation>
<wsdl:operation name="logout" parameterOrder="userName slnName dcName language">
<wsdl:input message="intf:logoutRequest" name="logoutRequest"></wsdl:input>
<wsdl:output message="intf:logoutResponse" name="logoutResponse"></wsdl:output>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="EASLoginSoapBinding" type="intf:EASLoginProxy">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="login">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="loginRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://login.webservice.bos.kingdee.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="loginResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://192.168.2.253:6888/ormrpc/services/EASLogin" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="login">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="loginRequest1">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://login.webservice.bos.kingdee.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="loginResponse1">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://192.168.2.253:6888/ormrpc/services/EASLogin" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="login">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="loginRequest2">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://login.webservice.bos.kingdee.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="loginResponse2">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://192.168.2.253:6888/ormrpc/services/EASLogin" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="logout">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="logoutRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://login.webservice.bos.kingdee.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="logoutResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://192.168.2.253:6888/ormrpc/services/EASLogin" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="EASLoginProxyService">
<wsdl:port binding="intf:EASLoginSoapBinding" name="EASLogin">
<wsdlsoap:address location="http://192.168.2.253:6888/ormrpc/services/EASLogin"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
package main
import (
"encoding/xml"
"fmt"
"log"
"github.com/mushishixian/gosoap"
)
// GetIPLocationResponse will hold the Soap response
type GetIPLocationResponse struct {
GetIPLocationResult string `xml:"GetIpLocationResult"`
}
// GetIPLocationResult will
type GetIPLocationResult struct {
XMLName xml.Name `xml:"GeoIP"`
Country string `xml:"Country"`
State string `xml:"State"`
}
var (
r GetIPLocationResponse
)
func main() {
soap, err := gosoap.SoapClient("http://wsgeoip.lavasoft.com/ipservice.asmx?WSDL")
if err != nil {
log.Fatalf("SoapClient error: %s", err)
}
params := gosoap.Params{
"sIp": "8.8.8.8",
}
res, err := soap.Call("GetIpLocation", params)
if err != nil {
log.Fatalf("Call error: %s", err)
}
fmt.Println(string(res.Body))
res.Unmarshal(&r)
// GetIpLocationResult will be a string. We need to parse it to XML
result := GetIPLocationResult{}
err = xml.Unmarshal([]byte(r.GetIPLocationResult), &result)
if err != nil {
log.Fatalf("xml.Unmarshal error: %s", err)
}
if result.Country != "US" {
log.Fatalf("error: %+v", r)
}
log.Println("Country: ", result.Country)
log.Println("State: ", result.State)
}
\ No newline at end of file
...@@ -2,7 +2,7 @@ package dao ...@@ -2,7 +2,7 @@ package dao
import ( import (
"context" "context"
"scm_server/internal/model" "scm_server/internal/model"
"github.com/go-kratos/kratos/pkg/database/sql" "github.com/go-kratos/kratos/pkg/database/sql"
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
const ( const (
_user_Info_One = "SELECT user_id FROM lie_user WHERE user_id=?" _user_Info_One = "SELECT user_id FROM lie_user WHERE user_id=?"
) )
//通过UID获取用户信息 //通过UID获取用户信息
......
package logic
import (
"scm_server/internal/dao"
"scm_server/internal/model"
"scm_server/internal/service"
)
const INSERTCRMUSER = "INSERT INTO `lie_user` (" +
"`outter_uid`, `source`,`adtag`, `mobile`,`email`, `create_time`,`copy_ctime`, `customer_identity`,`name`, `channel_source`,`remark`,`ptag`,`channel_source_other`" +
")VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?)"
const INSERTCOMPANY = "INSERT INTO `lie_user_company` (" +
"`user_id`, `com_name`,`address`, `fixed_tel`,`fax`, `main_brand`,`com_desc`, `create_time`)VALUES(?,?,?,?,?,?,?,?)"
const INSERTISCREATEORDER = "INSERT INTO `lie_user_extend` (`user_id`, `no_create_order`,`outter_uid`)VALUES(?,?,?)"
const INSERTSALES = "INSERT INTO `lie_salesman` (`user_id`, `sale_id`,`assign_time`)VALUES(?,?,?)"
//检测会员用户是否存在
func CheckMemberIdIsHave(memberId int)(returnUserId int){
var userId int = 0
dao.GetDb().QueryRowx("select user_id from lie_user where outter_uid = ?",memberId).Scan(&userId)
return userId
}
//增加从会员系统来的用户
func InsertMemberUser(memberInfo model.MemberAddUserData)bool {
//开启事务,增加用户数据
dbTran,_ := dao.GetDb().Begin()
insertResult, err := dbTran.Exec(INSERTCRMUSER,memberInfo.User_Id,memberInfo.Source,memberInfo.Adtag,memberInfo.Mobile,memberInfo.Email,memberInfo.Create_Time,memberInfo.Create_Time, memberInfo.Customer_identity,memberInfo.User_Name,memberInfo.Channel_source,memberInfo.Remark,memberInfo.Ptag,"")
if err != nil {
service.WriteErrDetail("插入用户数据错误:增加用户数据"+err.Error())
err = dbTran.Rollback()
return false
}
//获取插入ID
lastInsertId,err := insertResult.LastInsertId()
if err != nil {
service.WriteErrDetail("插入用户数据错误:获取插入ID"+err.Error())
err = dbTran.Rollback()
return false
}
//插入是否下单
insertResult, err = dbTran.Exec(INSERTISCREATEORDER,lastInsertId,memberInfo.No_Create_Order,memberInfo.User_Id)
if err != nil {
service.WriteErrDetail("插入用户数据错误:插入是否下单"+err.Error())
err = dbTran.Rollback()
return false
}
//插入跟进销售
insertResult, err = dbTran.Exec(INSERTSALES,lastInsertId,memberInfo.Sale_Id,memberInfo.Create_Time)
if err != nil {
service.WriteErrDetail("插入用户数据错误:插入跟进销售"+err.Error())
err = dbTran.Rollback()
return false
}
//插入公司
insertResult, err = dbTran.Exec(INSERTCOMPANY,lastInsertId,memberInfo.Com_Name,memberInfo.Com_Full_addr,memberInfo.Com_Telphone,memberInfo.Com_Fax,"",memberInfo.Com_Desc, memberInfo.Create_Time)
if err != nil {
service.WriteErrDetail("插入用户数据错误:插入公司"+err.Error())
err = dbTran.Rollback()
return false
}
dbTran.Commit()
return true
}
\ No newline at end of file
...@@ -8,6 +8,8 @@ import ( ...@@ -8,6 +8,8 @@ import (
const CheckCustomerExistSql = "SELECT customer_id FROM lie_customer WHERE erp_id = ?" const CheckCustomerExistSql = "SELECT customer_id FROM lie_customer WHERE erp_id = ?"
const CheckCustomerSyncStatusSql = "SELECT status FROM lie_customer WHERE erp_id = ?"
const InsertCustomerSql = "Insert INTO `lie_customer` (`erp_client_code`,`name`,`erp_id`,`add_time`,`sync_status`) VALUES (?,?,?,?,?)" const InsertCustomerSql = "Insert INTO `lie_customer` (`erp_client_code`,`name`,`erp_id`,`add_time`,`sync_status`) VALUES (?,?,?,?,?)"
const UpdateCustomerSql = "UPDATE `lie_customer` SET `erp_client_code` = ? , `name` = ? , `update_time` = ? WHERE `erp_id` = ?" const UpdateCustomerSql = "UPDATE `lie_customer` SET `erp_client_code` = ? , `name` = ? , `update_time` = ? WHERE `erp_id` = ?"
...@@ -25,6 +27,13 @@ func CheckCustomerExist(erpId string) (exist bool) { ...@@ -25,6 +27,13 @@ func CheckCustomerExist(erpId string) (exist bool) {
return customerId > 0 return customerId > 0
} }
//获取后端同步状态
func CheckCustomerSyncStatus(erpId string) (status bool) {
var statusInt int
dao.GetDb().QueryRow(CheckCustomerSyncStatusSql, erpId).Scan(&statusInt)
return statusInt > 0
}
//插入用户 //插入用户
func InsertCustomer(customer model.Customer) (err error) { func InsertCustomer(customer model.Customer) (err error) {
_, err = dao.GetDb().Exec(InsertCustomerSql, customer.ErpClientCode, customer.Name, customer.ErpId, time.Now().Unix(), 0) _, err = dao.GetDb().Exec(InsertCustomerSql, customer.ErpClientCode, customer.Name, customer.ErpId, time.Now().Unix(), 0)
......
package logic
import (
"scm_server/internal/common"
"scm_server/internal/dao"
"scm_server/internal/model"
"scm_server/internal/service"
"fmt"
"regexp"
"strconv"
"strings"
)
//会员系统的用户逻辑
var(
adtag = ""
ptag = ""
refer = ""
)
const(
AdtagRex = "adtag=.*"
PtagRex = "ptag=.*"
ReferRex = "refer=.*"
)
//获取会员系统的用户数据sql
const GETMEMBERUSER = "select `lie_u`.`user_id`, `lie_u`.`mobile`, `lie_u`.`user_name`, `lie_u`.`email`," +
" `lie_u`.`reg_remark`, `lie_u`.`create_device`, `lie_u`.`create_time`, `lie_c`.`com_id`, `lie_c`.`type_id`," +
" `lie_c`.`com_name`, `lie_c`.`com_desc`, `lie_c`.`com_province_id`, `lie_c`.`com_city_id`, `lie_c`.`com_area_id`," +
" `lie_c`.`com_address`, `lie_c`.`com_telphone`, `lie_c`.`com_fax`, `lie_c`.`brand_list`, `lie_i`.`work_function`," +
" `lie_i`.`user_type`, `lie_i`.`sale_id` as `userinfo_sale_id` from `lie_user_main` as `lie_u` left join `lie_user_info` as " +
"`lie_i` on `lie_u`.`user_id` = `lie_i`.`user_id` left join `lie_user_company` as `lie_c` on `lie_u`.`user_id` = `lie_c`.`user_id`" +
" where `lie_u`.`is_test` = 0 and `lie_u`.`is_type` = 0 and `lie_u`.`user_id` = ? and `lie_u`.`create_device` not in (3, 20)"
//获取会员系统的用户数据sql
func GetMemberUserInfo(memberId int) model.MemberAddUserData {
var MemberUserInfo model.MemberAddUserData
err := dao.GetLiexinDb().QueryRowx(GETMEMBERUSER,memberId).StructScan(&MemberUserInfo)
if err != nil {
service.WriteErr(err)
}
return MemberUserInfo
}
//处理基本的原始数据
func HandleData(MemberUserInfo model.MemberAddUserData) model.MemberAddUserData{
var saleId = 0
//查找交易员
err := dao.GetLiexinDb().QueryRowx("select sale_id from lie_order where user_id = ? order by create_time desc",MemberUserInfo.User_Id).Scan(&saleId)
if err != nil {
service.WriteErr(err)
}
if saleId != 0 {
MemberUserInfo.Sale_Id = saleId
}
// 个人转化为贸易商
if MemberUserInfo.Type_Id == 0 {
MemberUserInfo.Type_Id = 5
}
//来源
if MemberUserInfo.Create_Device != 2 {
MemberUserInfo.Source = 1
}else{
MemberUserInfo.Source = 2
}
// 客户身份
if MemberUserInfo.Work_Function != 0 {
MemberUserInfo.Customer_identity = MemberUserInfo.Work_Function
}
//获取oems数据
//抓取adtag和ptag,refer
adtag = regexp.MustCompile(AdtagRex).FindString(MemberUserInfo.Reg_Remark)
ptag = regexp.MustCompile(PtagRex).FindString(MemberUserInfo.Reg_Remark)
refer = regexp.MustCompile(ReferRex).FindString(MemberUserInfo.Reg_Remark)
if refer != ""{
refer = strings.Split(adtag,",")[0]
//如果是以上refer则为自营样片
if strings.Contains(refer,"sample") {
MemberUserInfo.Channel_source = 10
}
}
if ptag != "" {
ptag = strings.Split(adtag,",")[0]
MemberUserInfo.Ptag = strings.Split(ptag,",")[0]
switch ptag {
case "ptag=activity-140":
case "ptag=activity-141":
case "ptag=activity-143":
case "ptag=activity-144":
MemberUserInfo.Customer_identity = 2//如果是以上ptag则为采购用户
MemberUserInfo.Channel_source = 9//如果是以上ptag则为展会用户
break
case "ptag=activity-142":
case "ptag=activity-145":
MemberUserInfo.Customer_identity = 1//如果是以上ptag则为工程师
MemberUserInfo.Channel_source = 9//如果是以上ptag则为展会用户
break
case "ptag=sample":
case "ptag=sample-pop":
case "ptag=samplereg":
case "ptag=sample-stopnav":
MemberUserInfo.Channel_source = 10//如果是以上ptag则为自营样片
break
case "ptag=jr":
MemberUserInfo.Channel_source = 11//如果是以上ptag则为信用金融
break
case "ptag=edcp":
MemberUserInfo.Channel_source = 12//如果是以上ptag则为信用贷测评
break
}
}
if adtag != "" {
adtag = strings.Split(adtag,",")[0]
MemberUserInfo.Adtag = adtag
if adtag == "adtag=bps" {
MemberUserInfo.Channel_source = 13//如果是以上adtag则为白皮书下载用户
}
if adtag == "adtag=findchips" {
MemberUserInfo.Channel_source = 14//如果是以上adtagfindchips广告
}
}
//地址
if MemberUserInfo.Com_Province_Id != 0 && MemberUserInfo.Com_City_Id != 0 && MemberUserInfo.Com_Area_Id != 0 {
MemberUserInfo.Com_Full_addr = common.AllCity[strconv.Itoa(MemberUserInfo.Com_Province_Id)] + common.AllCity[strconv.Itoa(MemberUserInfo.Com_City_Id)] + common.AllCity[strconv.Itoa(MemberUserInfo.Com_Area_Id)] + MemberUserInfo.Com_Address
}
//oems信息
var oems model.OemsUserinfo
dao.GetDb().QueryRowx("select contract,contract_name,note,outter_uid from lie_oems_userinfo where outter_uid = ?",&oems.Outter_Uid)
if oems.Outter_Uid != 0 {
fmt.Println(oems)
if MemberUserInfo.Mobile == "" {
MemberUserInfo.Mobile = oems.Contact
}
MemberUserInfo.User_Name = oems.Contact_Name
MemberUserInfo.Channel_source = 8
MemberUserInfo.Remark = oems.Note
}
//判断是否下单
var orderId int
err = dao.GetLiexinDb().QueryRowx("select order_id from lie_order where user_id = ?",MemberUserInfo.User_Id).Scan(orderId);
if orderId != 0 {
MemberUserInfo.No_Create_Order = 2
}else{
MemberUserInfo.No_Create_Order = 1
}
return MemberUserInfo
}
\ No newline at end of file
...@@ -2,13 +2,13 @@ package logic ...@@ -2,13 +2,13 @@ package logic
import ( import (
"scm_server/internal/dao" "scm_server/internal/dao"
"time" "scm_server/internal/model"
) )
//插入金蝶同步状态错误信息 //插入金蝶同步状态错误信息
const InsertSyncStatusLogSql = "Insert Into `lie_sync_status_log` ( `sync_name` , `unique_id` , `error_msg` , `add_time` ) Value (?,?,?,?)" const InsertSyncStatusLogSql = "INSERT INTO `lie_sync_status_log` ( `sync_name` , `unique_id` , `sync_error` , `add_time` ) VALUE (?,?,?,?)"
func InsertSyncStatusLog(syncName, uniqueId, errMsg string) (err error) { func InsertSyncStatusLog(syncStatusLog model.SyncStatusLog) (err error) {
_, err = dao.GetDb().Exec(InsertSyncStatusLogSql, syncName, uniqueId, errMsg, time.Now().Unix()) _, err = dao.GetDb().Exec(InsertSyncStatusLogSql, syncStatusLog.SyncName, syncStatusLog.UniqueId, syncStatusLog.SyncError, syncStatusLog.AddTime)
return return
} }
package model
type AssignActive struct {
Id int `json:"id"`
User_Id int `json:"user_id"`
Turn_Out_id int `json:"turn_out_id"`
Turn_In_id int `json:"turn_in_id"`
Assign_id int `json:"assign_id"`
Is_Success int `json:"is_success"`
No_Create_Order int `json:"no_create_order"`
Change_Time int `json:"change_time"`
Create_time int `json:"create_time"`
}
/*
CREATE TABLE `lie_assign_active` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '转入接收日志',
`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '用户ID',
`turn_out_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '转出人ID',
`turn_in_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '转入人ID',
`assign_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '分配人ID',
`is_success` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '是否成功',
`change_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '变更时间',
`create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8 COMMENT='转入接收日志表';
*/
\ No newline at end of file
package model
type Feedback struct {
User_Id int `json:"user_id"`
Outter_Uid int `json:"outter_uid"`
Ip int `json:"ip"`
Type int `json:"type"`
Mobile string `json:"mobile"`
Content string `json:"content"`
Source string `json:"source"`
Pf int `json:"pf"`
Status int `json:"status"`
Sale_Id int `json:"sale_id"`
Bom_Url string `json:"bom_url"`
Responses string `json:"responses"`
Contact_Name string `json:"contact_name"`
Company_Name string `json:"company_name"`
Company_Type int `json:"company_type"`
Note string `json:"note"`
Create_Time int `json:"create_time"`
}
/*
CREATE TABLE `lie_feedback` (
`id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT COMMENT '流水id',
`user_id` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '如果用登陆,则记录用户id',
`outter_uid` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT 'crm用户ID',
`ip` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'ip',
`type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '5.搜索无结果 6、多次搜索 7、快速找货 8、SEO落地页面反馈',
`mobile` char(16) NOT NULL DEFAULT '' COMMENT '手机号',
`content` varchar(255) NOT NULL DEFAULT ' ' COMMENT '反馈意见',
`source` varchar(100) NOT NULL DEFAULT ' ' COMMENT '页面来源',
`pf` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '1、pc 2.H5',
`status` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '0为未处理,1已处理',
`sale_id` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT '客服id',
`bom_url` varchar(255) NOT NULL DEFAULT ' ' COMMENT 'bom单excel存在OSS的地址链接',
`responses` varchar(255) NOT NULL DEFAULT ' ' COMMENT '回复内容',
`contact_name` varchar(80) NOT NULL DEFAULT ' ' COMMENT '联系名称',
`company_name` varchar(50) NOT NULL DEFAULT ' ' COMMENT '公司名称',
`company_type` tinyint(1) unsigned NOT NULL DEFAULT '0' COMMENT '1代工厂 2终端 3代理商 4贸易商 5其它',
`note` varchar(100) NOT NULL DEFAULT ' ' COMMENT '备注',
`create_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '创建时间',
PRIMARY KEY (`id`),
KEY `user_id` (`user_id`)
) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8 COMMENT='意见反馈表';
*/
\ No newline at end of file
package model
type MemberAddUserData struct {
User_Id int `json:"user_id"`
Mobile string `json:"mobile"`
User_Name string `json:"user_name"`
Email string `json:"email"`
Reg_Remark string `json:"reg_remark"`
Remark string `json:"remark"`
Create_Device int `json:"create_device"`
Create_Time int `json:"create_time"`
Com_Id int `json:"com_id"`
Type_Id int `json:"type_id"`
Com_Name string `json:"ComName"`
Com_Desc string `json:"com_desc"`
Com_Province_Id int `json:"com_provicne_id"`
Com_City_Id int `json:"com_city_id"`
Com_Area_Id int `json:"com_area_id"`
Com_Address string `json:"com_address"`
Com_Telphone string `json:"com_telphone"`
Com_Fax string `json:"com_fax"`
Brand_List string `json:"brand_list"`
Work_Function int `json:"work_function"`
User_Type int `json:"user_type"`
Userinfo_Sale_Id int `json:"userinfo_sale_id"`
Sale_Id int `json:"sale_id"`
Adtag string `json:"adtag"`
Ptag string `json:"ptag"`
Com_Full_addr string `json:"com_full_addr"`
Channel_source int `json:"channel_source"`
Source int `json:"source"`
Customer_identity int `json:"customer_identity"`
No_Create_Order int `json:"no_create_order"`
}
\ No newline at end of file
package model
type NotFollowUser struct {
Id int `json:"id"`
User_Id int `json:"user_id"`
Sale_Id int `json:"sale_id"`
Stop_Time int `json:"Stop_time"`
Update_Time int `json:"Update_time"`
}
/*
CREATE TABLE `lie_not_follow_user` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '客户ID',
`sale_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '交易员ID',
`stop_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '停止时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='客服不能跟进用户表';
*/
\ No newline at end of file
package model
type OemsUserinfo struct {
Outter_Uid int `json:"outter_uid"`
Contact string `json:"contact"`
Contact_Name string `json:"contact_name"`
Note string `json:"note"`
}
\ No newline at end of file
package model
type Salesman struct {
Id int `json:"id"`
User_Id int `json:"user_id"`
Sale_Id int `json:"sale_id"`
Assign_Time int `json:"assign_time"`
Update_Time int `json:"update_time"`
}
/*
CREATE TABLE `lie_salesman` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
`user_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '客户ID',
`sale_id` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '交易员ID',
`assign_time` int(10) unsigned NOT NULL DEFAULT '0' COMMENT '指派时间',
`update_time` int(11) unsigned NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=69 DEFAULT CHARSET=utf8;
*/
\ No newline at end of file
package model
type SyncStatusLog struct {
SyncName string
SyncError string
UniqueId string
AddTime int64
}
package model
type UserCompany struct {
Com_name string `json:"com_name"`
}
\ No newline at end of file
package model
type UserInfo struct {
Mobile int64 `json:"mobile"`
}
\ No newline at end of file
...@@ -3,4 +3,4 @@ package model ...@@ -3,4 +3,4 @@ package model
// Kratos hello kratos. // Kratos hello kratos.
type Users struct { type Users struct {
User_id int64 `json:"user_id"` User_id int64 `json:"user_id"`
} }
\ No newline at end of file
package myservice
import (
"encoding/xml"
"github.com/hooklift/gowsdl/soap"
"time"
)
// against "unused imports"
var _ time.Time
var _ xml.Name
type WSContext struct {
SlnName string `xml:"slnName,omitempty"`
Password string `xml:"password,omitempty"`
DbType int32 `xml:"dbType,omitempty"`
UserName string `xml:"userName,omitempty"`
SessionId string `xml:"sessionId,omitempty"`
DcName string `xml:"dcName,omitempty"`
}
type RequestData struct {
SlnName string `xml:"slnName,omitempty"`
Password string `xml:"password,omitempty"`
DbType int32 `xml:"dbType,omitempty"`
UserName string `xml:"userName,omitempty"`
DcName string `xml:"dcName,omitempty"`
Language string `xml:"language,omitempty"`
AuthPattern string `xml:"authPattern,omitempty"`
}
type EASLoginProxy interface {
Login(request *RequestData) (*WSContext, error)
}
type eASLoginProxy struct {
client *soap.Client
}
func NewEASLoginProxy(client *soap.Client) EASLoginProxy {
return &eASLoginProxy{
client: client,
}
}
func (service *eASLoginProxy) Login(request *RequestData) (*WSContext, error) {
response := new(WSContext)
err := service.client.Call("login", request, response)
if err != nil {
return nil, err
}
return response, nil
}
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