cxhxy/app/api/model/food/Comment.php
test_service d3170b4d1c 1
2023-12-01 15:43:29 +08:00

29 lines
596 B
PHP

<?php
namespace app\api\model\food;
use app\common\model\food\Comment as CommentModel;
use think\facade\Db;
class Comment extends CommentModel
{
/**
* 添加
*/
public function add(array $data)
{
$order = Order::get($data['order_id']);
$data['shop_id'] = $order['shop_id'];
// 开启事务
Db::startTrans();
try {
$order->save(['is_cmt' => 1]);
$this->save($data);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
}
return false;
}
}