$params['name'], 'introduction' => $params['introduction'], 'phone' => $params['phone'], 'detailed_address' => $params['detailed_address'], 'image' => $params['image'], 'is_show' => $params['is_show'], 'longitude' => $params['longitude'], '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'], 'bank' => $params['bank']??'', 'bank_code' => $params['bank_code']??'', 'bank_address' => $params['bank_address']??'', 'realname' => $params['realname']??'', 'street' => $params['street_code'], 'is_store' => $params['is_store'] ?? 0, 'is_send' => $params['is_send'] ?? 0, 'security_deposit' => $params['security_deposit'] ?? 0, ]); $taff = [ 'store_id' => $store['id'], 'account' => $params['phone'], 'pwd' => $password, 'avatar' => $params['image'], 'staff_name' => $params['staff_name'], 'phone' => $params['phone'], 'is_admin' => 1, 'status' => 1, ]; SystemStoreStaff::create($taff); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑门店列表 * @param array $params * @return bool * @author admin * @date 2024/05/31 17:45 */ public static function edit(array $params): bool { Db::startTrans(); try { $store = SystemStore::where('id',$params['id'])->update([ 'name' => $params['name'], 'introduction' => $params['introduction'], 'detailed_address' => $params['detailed_address'], 'image' => $params['image'], 'is_show' => $params['is_show'], 'longitude' => $params['longitude'], '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'], 'address' => $params['address'] ?? '', 'oblong_image' => $params['oblong_image'] ?? '', 'valid_range' => $params['valid_range'] ?? 0, 'day_time' => $params['day_time'] ?? 0, 'is_store' => $params['is_store'] ?? 0, 'is_send' => $params['is_send'] ?? 0, 'bank' => $params['bank']??'', 'bank_code' => $params['bank_code']??'', 'bank_address' => $params['bank_address']??'', 'realname' => $params['realname']??'', 'default_delivery' => $params['default_delivery'] ?? 2, 'security_deposit' => $params['security_deposit'] ?? 0, ]); $res=SystemStoreStaff::where('store_id', $params['id'])->where('is_admin', 1)->where('account', $params['phone'])->find(); if($params['password']!=''&&$res){ $passwordSalt = Config::get('project.unique_identification'); $password = create_password($params['password'], $passwordSalt); $taff = [ 'pwd' => $password, 'avatar' => $params['image'], 'staff_name' => $params['staff_name'], ]; SystemStoreStaff::where('id', $res['id'])->update($taff); } if($params['staff_name']!=''&&$res){ $taff = [ 'avatar' => $params['image'], 'staff_name' => $params['staff_name'], ]; SystemStoreStaff::where('id', $res['id'])->update($taff); } Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除门店列表 * @param array $params * @return bool * @author admin * @date 2024/05/31 17:45 */ public static function delete(array $params): bool { return SystemStore::destroy($params['id']); } /** * @notes 获取门店列表详情 * @param $params * @return array * @author admin * @date 2024/05/31 17:45 */ public static function detail($params): array { $data=SystemStore::findOrEmpty($params['id'])->toArray(); if($data){ $data['staff_name']=SystemStoreStaff::where('store_id', $params['id'])->where('is_admin', 1)->value('staff_name'); } return $data; } }