feat: 更新系统商店逻辑以处理管理员密码和员工信息

This commit is contained in:
mkm 2024-06-03 16:16:35 +08:00
parent e7fef4b83d
commit 3a82a0f435

View File

@ -30,8 +30,8 @@ class SystemStoreLogic extends BaseLogic
Db::startTrans(); Db::startTrans();
try { try {
$passwordSalt = Config::get('project.unique_identification'); $passwordSalt = Config::get('project.unique_identification');
$password=create_password($params['password'], $passwordSalt); $password = create_password($params['password'], $passwordSalt);
$store=SystemStore::create([ $store = SystemStore::create([
'name' => $params['name'], 'name' => $params['name'],
'introduction' => $params['introduction'], 'introduction' => $params['introduction'],
'phone' => $params['phone'], 'phone' => $params['phone'],
@ -47,15 +47,15 @@ class SystemStoreLogic extends BaseLogic
'area' => $params['area_code'], 'area' => $params['area_code'],
'street' => $params['street_code'], 'street' => $params['street_code'],
]); ]);
$taff=[ $taff = [
'store_id'=>$store['id'], 'store_id' => $store['id'],
'account'=>$params['phone'], 'account' => $params['phone'],
'pwd'=>$password, 'pwd' => $password,
'avatar'=>$params['image'], 'avatar' => $params['image'],
'staff_name'=>$params['name'], 'staff_name' => $params['name'],
'phone'=>$params['phone'], 'phone' => $params['phone'],
'is_admin'=>1, 'is_admin' => 1,
'status'=>1, 'status' => 1,
]; ];
SystemStoreStaff::create($taff); SystemStoreStaff::create($taff);
@ -80,16 +80,31 @@ class SystemStoreLogic extends BaseLogic
{ {
Db::startTrans(); Db::startTrans();
try { try {
SystemStore::where('id', $params['id'])->update([ $store = SystemStore::where('id',$params['id'])->update([
'name' => $params['name'], 'name' => $params['name'],
'introduction' => $params['introduction'], 'introduction' => $params['introduction'],
'phone' => $params['phone'],
'detailed_address' => $params['detailed_address'], 'detailed_address' => $params['detailed_address'],
'image' => $params['image'], 'image' => $params['image'],
'latitude' => $params['latitude'], 'is_show' => $params['is_show'],
'longitude' => $params['longitude'], 'longitude' => $params['longitude'],
'is_show' => $params['is_show'] 'latitude' => $params['latitude'],
'day_start' => $params['day_start'],
'day_end' => $params['day_end'],
'province' => $params['province_code'],
'city' => $params['city_code'],
'area' => $params['area_code'],
'street' => $params['street_code'],
]); ]);
if($params['password']!=''){
$passwordSalt = Config::get('project.unique_identification');
$password = create_password($params['password'], $passwordSalt);
$taff = [
'pwd' => $password,
'avatar' => $params['image'],
'staff_name' => $params['name'],
];
SystemStoreStaff::where('store_id', $params['id'])->where('is_admin', 1)->where('account', $params['phone'])->update($taff);
}
Db::commit(); Db::commit();
return true; return true;
@ -125,4 +140,4 @@ class SystemStoreLogic extends BaseLogic
{ {
return SystemStore::findOrEmpty($params['id'])->toArray(); return SystemStore::findOrEmpty($params['id'])->toArray();
} }
} }