Commit d38f1a71 by mushishixian

完善删除

parent 07f9e654
...@@ -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/ApiDeleteCustomerInfo" url = configs.BasicApiUrl + "/basic/api/ApiUpdateCustomerStatus"
} }
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
......
...@@ -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": "save", "type": "delete",
"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)
......
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()
} }
...@@ -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, erpId) _, err = dao.GetDb().Exec(DeleteCustomerSql, customer.Status, time.Now().Unix(), customer.ErpId)
return return
} }
......
...@@ -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
} }
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