- OnCourierStoreStatusChanged中找不到门店不返回错误
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -107,12 +107,19 @@ func (s *StoreManager) OnCourierStoreStatusChanged(ctx *jxcontext.Context, vendo
|
||||
db := dao.GetDB()
|
||||
_, err2 := dao.GetStoreDetail2(db, 0, vendorStoreID, vendorID)
|
||||
if err = err2; err == nil {
|
||||
status := model.StoreStatusOpened
|
||||
if auditStatus != model.StoreAuditStatusOnline {
|
||||
status = model.StoreStatusDisabled
|
||||
}
|
||||
_, err = dao.UpdateEntityLogically(db, &model.StoreCourierMap{}, map[string]interface{}{
|
||||
"AuditStatus": auditStatus,
|
||||
model.FieldStatus: status,
|
||||
"AuditStatus": auditStatus,
|
||||
}, ctx.GetUserName(), map[string]interface{}{
|
||||
model.FieldVendorStoreID: vendorStoreID,
|
||||
model.FieldVendorID: vendorID,
|
||||
})
|
||||
} else if dao.IsNoRowsError(err) {
|
||||
err = nil
|
||||
}
|
||||
}
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user