Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
杨树贤
/
liexin_scm_wms_sync
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
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
44 additions
and
13 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 {
}
case
"delete"
:
operateType
=
"delete"
fmt
.
Println
(
customer
.
ErpId
)
customer
.
Status
=
0
if
logic
.
CheckCustomerExist
(
customer
.
ErpId
)
{
//如果存在,才进行删除
if
err
=
logic
.
DeleteCustomer
(
customer
.
ErpId
);
err
!=
nil
{
if
err
=
logic
.
DeleteCustomer
(
customer
);
err
!=
nil
{
goto
ERR
}
}
else
{
...
...
@@ -95,7 +97,7 @@ ERR:
AddTime
:
time
.
Now
()
.
Unix
(),
SyncTime
:
time
.
Now
()
.
Unix
(),
QueueMessage
:
string
(
dataByte
),
UniqueId
:
customer
.
ErpId
,
//有可能为
UniqueId
:
customer
.
ErpId
,
SyncError
:
err
.
Error
(),
SyncName
:
"customer"
,
}
...
...
@@ -123,7 +125,7 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) {
respData
common
.
Response
)
param
:=
req
.
Param
{
"erp_client_sn"
:
customer
.
ErpClientCode
,
"erp_client_sn"
:
customer
.
ErpClientCode
,
"customer_name"
:
customer
.
Name
,
"erp_customer_id"
:
customer
.
ErpId
,
"admin_name"
:
"系统"
,
...
...
@@ -136,7 +138,7 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) {
}
else
if
operate
==
"insert"
{
url
=
configs
.
BasicApiUrl
+
"/basic/api/ApiInsertCustomerInfo"
}
else
{
url
=
configs
.
BasicApiUrl
+
"/basic/api/Api
DeleteCustomerInfo
"
url
=
configs
.
BasicApiUrl
+
"/basic/api/Api
UpdateCustomerStatus
"
}
req
.
Debug
=
false
if
operate
==
"update"
||
operate
==
"insert"
{
...
...
@@ -155,7 +157,27 @@ func SyncCustomerData(operate string, customer model.Customer) (err error) {
return
}
}
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
...
...
cmd/queue/sync_customer/product.go
View file @
d38f1a71
...
...
@@ -8,12 +8,20 @@ import (
func
main
()
{
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
{}{
"type"
:
"
sav
e"
,
"type"
:
"
delet
e"
,
"data"
:
map
[
string
]
string
{
"FID"
:
"
Z8eVSzSLRXKa7ET9WHFzYagYZf011
="
,
"FID"
:
"
c4HiJbe4TRmrdwM+Gbrn8agYZf0
="
,
"FNUMBER"
:
"WT0050333"
,
"CFNAME"
:
"深圳市鼎驰达电子有限公司"
,
"CFNAME"
:
"深圳市鼎驰达电子有限公司
TEST
"
,
},
}
data
,
err
:=
json
.
Marshal
(
message
)
...
...
cmd/source/main.go
View file @
d38f1a71
package
main
import
"scm_server/cmd/source/
goods
"
import
"scm_server/cmd/source/
customer
"
func
main
()
{
//forever := make(chan bool)
...
...
@@ -8,6 +8,6 @@ func main() {
//go supplier.Import()
//supplier.Import()
//<-forever
//
customer.Import()
goods
.
Import
()
customer
.
Import
()
//
goods.Import()
}
internal/logic/customer.go
View file @
d38f1a71
...
...
@@ -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
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 = ?"
...
...
@@ -44,8 +44,8 @@ func UpdateCustomer(customer model.Customer) (err error) {
}
//删除供应商
func
DeleteCustomer
(
erpId
string
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
DeleteCustomerSql
,
e
rpId
)
func
DeleteCustomer
(
customer
model
.
Customer
)
(
err
error
)
{
_
,
err
=
dao
.
GetDb
()
.
Exec
(
DeleteCustomerSql
,
customer
.
Status
,
time
.
Now
()
.
Unix
(),
customer
.
E
rpId
)
return
}
...
...
internal/model/customer.go
View file @
d38f1a71
...
...
@@ -7,5 +7,6 @@ type Customer struct {
AddTime
int
SyncTime
int
SyncStatus
int
Status
int
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