- OnCourierStoreStatusChanged中找不到门店不返回错误

This commit is contained in:
gazebo
2019-07-23 15:05:07 +08:00
parent b285e33587
commit 52e63eec79
2 changed files with 23 additions and 7 deletions

View File

@@ -1040,14 +1040,23 @@ func UpdateStoreCourierMap(ctx *jxcontext.Context, db *dao.DaoDB, storeID, vendo
if db == nil {
db = dao.GetDB()
}
dummyStoreCourierMap := &model.StoreCourierMap{}
storeCourier := &model.StoreCourierMap{
StoreID: storeID,
VendorID: vendorID,
}
storeCourier.DeletedAt = utils.DefaultTimeValue
if err = dao.GetEntity(db, storeCourier, model.FieldStoreID, model.FieldVendorID, model.FieldDeletedAt); err != nil {
return 0, err
}
delete(payload, "auditStatus") // 不允许直接修改auditStatus的值
valid := dao.NormalMakeMapByStructObject(payload, dummyStoreCourierMap, userName)
if storeCourier.AuditStatus != model.StoreAuditStatusOnline {
if status, ok := payload["status"].(int); ok && status == model.StoreStatusOpened {
delete(payload, "status") // 没有通过审核的禁止改状态为正常
}
}
valid := dao.NormalMakeMapByStructObject(payload, storeCourier, userName)
if len(valid) > 0 {
num, err = dao.UpdateEntityLogically(db, dummyStoreCourierMap, valid, userName, map[string]interface{}{
model.FieldStoreID: storeID,
model.FieldVendorID: vendorID,
})
num, err = dao.UpdateEntityLogically(db, storeCourier, valid, userName, nil)
}
return num, err
}