Commit d38f1a71 by mushishixian

完善删除

parent 07f9e654
......@@ -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/ApiDeleteCustomerInfo"
url = configs.BasicApiUrl + "/basic/api/ApiUpdateCustomerStatus"
}
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
......
......@@ -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": "save",
"type": "delete",
"data": map[string]string{
"FID": "Z8eVSzSLRXKa7ET9WHFzYagYZf011=",
"FID": "c4HiJbe4TRmrdwM+Gbrn8agYZf0=",
"FNUMBER": "WT0050333",
"CFNAME": "深圳市鼎驰达电子有限公司",
"CFNAME": "深圳市鼎驰达电子有限公司TEST",
},
}
data,err := json.Marshal(message)
......
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()
}
......@@ -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, erpId)
func DeleteCustomer(customer model.Customer) (err error) {
_, err = dao.GetDb().Exec(DeleteCustomerSql, customer.Status, time.Now().Unix(), customer.ErpId)
return
}
......
......@@ -7,5 +7,6 @@ type Customer struct {
AddTime int
SyncTime int
SyncStatus int
Status int
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