Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
scm_server
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
d38f1a71
authored
Apr 23, 2020
by
mushishixian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
完善删除
parent
07f9e654
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
43 additions
and
12 deletions
cmd/queue/sync_customer/main.go
cmd/queue/sync_customer/product.go
cmd/source/main.go
internal/logic/customer.go
internal/model/customer.go
cmd/queue/sync_customer/main.go
View file @
d38f1a71
...
@@ -65,9 +65,11 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
...
@@ -65,9 +65,11 @@ func (t *RecvPro) Consumer(dataByte []byte) error {
}
}
case
"delete"
:
case
"delete"
:
operateType
=
"delete"
operateType
=
"delete"
fmt
.
Println
(
customer
.
ErpId
)
customer
.
Status
=
0
if
logic
.
CheckCustomerExist
(
customer
.
ErpId
)
{
if
logic
.
CheckCustomerExist
(
customer
.
ErpId
)
{
//如果存在,才进行删除
//如果存在,才进行删除
if
err
=
logic
.
DeleteCustomer
(
customer
.
ErpId
);
err
!=
nil
{
if
err
=
logic
.
DeleteCustomer
(
customer
);
err
!=
nil
{
goto
ERR
goto
ERR
}
}
}
else
{
}
else
{
...
@@ -95,7 +97,7 @@ ERR:
...
@@ -95,7 +97,7 @@ ERR:
AddTime
:
time
.
Now
()
.
Unix
(),
AddTime
:
time
.
Now
()
.
Unix
(),
SyncTime
:
time
.
Now
()
.
Unix
(),
SyncTime
:
time
.
Now
()
.
Unix
(),
QueueMessage
:
string
(
dataByte
),
QueueMessage
:
string
(
dataByte
),
UniqueId
:
customer
.
ErpId
,
//有可能为
UniqueId
:
customer
.
ErpId
,
SyncError
:
err
.
Error
(),
SyncError
:
err
.
Error
(),
SyncName
:
"customer"
,
SyncName
:
"customer"
,
}
}
...
@@ -136,7 +138,7 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) {
...
@@ -136,7 +138,7 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) {
}
else
if
operate
==
"insert"
{
}
else
if
operate
==
"insert"
{
url
=
configs
.
BasicApiUrl
+
"/basic/api/ApiInsertCustomerInfo"
url
=
configs
.
BasicApiUrl
+
"/basic/api/ApiInsertCustomerInfo"
}
else
{
}
else
{
url
=
configs
.
BasicApiUrl
+
"/basic/api/Api
DeleteCustomerInfo
"
url
=
configs
.
BasicApiUrl
+
"/basic/api/Api
UpdateCustomerStatus
"
}
}
req
.
Debug
=
false
req
.
Debug
=
false
if
operate
==
"update"
||
operate
==
"insert"
{
if
operate
==
"update"
||
operate
==
"insert"
{
...
@@ -155,7 +157,27 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) {
...
@@ -155,7 +157,27 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) {
return
return
}
}
}
else
{
}
else
{
param
=
req
.
Param
{
"erp_customer_id"
:
customer
.
ErpId
,
"admin_name"
:
"系统"
,
"admin_id"
:
1
,
"status"
:
0
,
}
//删除
//删除
resp
,
err
=
req
.
Post
(
url
,
param
)
if
err
!=
nil
{
return
}
if
err
=
resp
.
ToJSON
(
&
respData
);
err
!=
nil
{
return
}
if
respData
.
Errcode
!=
101100
{
return
errors
.
New
(
respData
.
Errmsg
)
}
//都没问题,代表后端那边已经成功修改,修改同步表的状态
if
err
=
logic
.
SyncCustomerSuccess
(
customer
.
ErpId
);
err
!=
nil
{
return
}
}
}
return
return
...
...
cmd/queue/sync_customer/product.go
View file @
d38f1a71
...
@@ -8,12 +8,20 @@ import (
...
@@ -8,12 +8,20 @@ import (
func
main
()
{
func
main
()
{
message
:=
make
(
map
[
string
]
interface
{})
message
:=
make
(
map
[
string
]
interface
{})
//message = map[string]interface{}{
// "type": "save",
// "data": map[string]string{
// "FID": "Z8eVSzSLRXKa7ET9WHFzYagYZf023=",
// "FNUMBER": "WT0050333",
// "CFNAME": "深圳市鼎驰达电子有限公司TEST",
// },
//}
message
=
map
[
string
]
interface
{}{
message
=
map
[
string
]
interface
{}{
"type"
:
"
sav
e"
,
"type"
:
"
delet
e"
,
"data"
:
map
[
string
]
string
{
"data"
:
map
[
string
]
string
{
"FID"
:
"
Z8eVSzSLRXKa7ET9WHFzYagYZf011
="
,
"FID"
:
"
c4HiJbe4TRmrdwM+Gbrn8agYZf0
="
,
"FNUMBER"
:
"WT0050333"
,
"FNUMBER"
:
"WT0050333"
,
"CFNAME"
:
"深圳市鼎驰达电子有限公司"
,
"CFNAME"
:
"深圳市鼎驰达电子有限公司
TEST
"
,
},
},
}
}
data
,
err
:=
json
.
Marshal
(
message
)
data
,
err
:=
json
.
Marshal
(
message
)
...
...
cmd/source/main.go
View file @
d38f1a71
package
main
package
main
import
"scm_server/cmd/source/
goods
"
import
"scm_server/cmd/source/
customer
"
func
main
()
{
func
main
()
{
//forever := make(chan bool)
//forever := make(chan bool)
...
@@ -8,6 +8,6 @@ func main() {
...
@@ -8,6 +8,6 @@ func main() {
//go supplier.Import()
//go supplier.Import()
//supplier.Import()
//supplier.Import()
//<-forever
//<-forever
//
customer.Import()
customer
.
Import
()
goods
.
Import
()
//
goods.Import()
}
}
internal/logic/customer.go
View file @
d38f1a71
...
@@ -12,7 +12,7 @@ const InsertCustomerSql = "Insert INTO `lie_customer` (`erp_client_code`,`name`,
...
@@ -12,7 +12,7 @@ const InsertCustomerSql = "Insert INTO `lie_customer` (`erp_client_code`,`name`,
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` = ?"
const
DeleteCustomerSql
=
"
DELETE FROM `lie_customer`
WHERE `erp_id` = ?"
const
DeleteCustomerSql
=
"
UPDATE `lie_customer` SET `status` = ? , `update_time` = ?
WHERE `erp_id` = ?"
const
WriteCustomerSyncErrorSql
=
"UPDATE `lie_customer` SET sync_error = ? WHERE erp_id = ?"
const
WriteCustomerSyncErrorSql
=
"UPDATE `lie_customer` SET sync_error = ? WHERE erp_id = ?"
...
@@ -44,8 +44,8 @@ func UpdateCustomer(customer model.Customer) (err error) {
...
@@ -44,8 +44,8 @@ func UpdateCustomer(customer model.Customer) (err error) {
}
}
//删除供应商
//删除供应商
func
DeleteCustomer
(
erpId
string
)
(
err
error
)
{
func
DeleteCustomer
(
customer
model
.
Customer
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
DeleteCustomerSql
,
e
rpId
)
_
,
err
=
dao
.
GetDb
()
.
Exec
(
DeleteCustomerSql
,
customer
.
Status
,
time
.
Now
()
.
Unix
(),
customer
.
E
rpId
)
return
return
}
}
...
...
internal/model/customer.go
View file @
d38f1a71
...
@@ -7,5 +7,6 @@ type Customer struct {
...
@@ -7,5 +7,6 @@ type Customer struct {
AddTime
int
AddTime
int
SyncTime
int
SyncTime
int
SyncStatus
int
SyncStatus
int
Status
int
SyncError
string
SyncError
string
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment