$params['cid'], 'title' => $params['title'], 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', 'money' => $params['money'], 'is_show' => $params['is_show'], 'sort' => $params['sort'], 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 编辑商品 * @param array $params * @return bool * @author BD * @date 2024/03/11 01:58 */ public static function edit(array $params): bool { Db::startTrans(); try { $langs = $params['langs']; // foreach ($langs as &$content_lang) { // $content_lang['image'] = FileService::setFileUrl($content_lang['image']); // } Goods::where('id', $params['id'])->update([ 'cid' => $params['cid'], 'title' => $params['title'], 'image' => $params['image'] ? FileService::setFileUrl($params['image']) : '', 'money' => $params['money'], 'is_show' => $params['is_show'], 'sort' => $params['sort'], 'langs' => json_encode($langs, JSON_UNESCAPED_UNICODE), ]); Db::commit(); return true; } catch (\Exception $e) { Db::rollback(); self::setError($e->getMessage()); return false; } } /** * @notes 删除商品 * @param array $params * @return bool * @author BD * @date 2024/03/11 01:58 */ public static function delete(array $params): bool { return Goods::destroy($params['id']); } /** * @notes 获取商品详情 * @param $params * @return array * @author BD * @date 2024/03/11 01:58 */ public static function detail($params): array { return Goods::findOrEmpty($params['id'])->toArray(); } }