删除支付后的活动商品判断

This commit is contained in:
mkm 2024-01-28 15:57:49 +08:00
parent d6a56e119f
commit fb5d12d93c
2 changed files with 8 additions and 7 deletions

View File

@ -23,6 +23,7 @@ use app\common\repositories\store\product\SpuRepository;
use think\db\Query;
use think\exception\ValidateException;
use think\facade\Db;
use think\facade\Log;
/**
*
@ -147,18 +148,19 @@ class StoreActivityDao extends BaseDao
if (empty($productIds)) {
return;
}
$find = StoreActivityOrderProduct::where('user_id', $order['uid'])->where('status', 1)->find();
// $find = StoreActivityOrderProduct::where('user_id', $order['uid'])->where('status', 1)->find();
foreach ($productIds as $productId) {
if (!empty($find['product_id']) && $find['product_id'] == $productId && $activityId == 2) {
throw new ValidateException('活动商品限购1个');
}
// if (!empty($find['product_id']) && $find['product_id'] == $productId && $activityId == 2) {
// throw new ValidateException('活动商品限购1个');
// }
$model = new StoreActivityOrderProduct();
$model->user_id = $order['uid'];
$model->activity_id = $activityId;
$model->product_id = $productId;
$model->number = 1;
if (!$model->save()) {
throw new ValidateException('活动商品数据保存失败');
Log::error('活动商品数据保存失败productId'.$productId);
// throw new ValidateException('活动商品数据保存失败');
}
}
}

View File

@ -164,8 +164,7 @@ class StoreOrderRepository extends BaseRepository
Db::commit();
} catch (Exception $e) {
Db::rollback();
halt($e);
throw new ValidateException('余额支付失败');
throw new ValidateException('余额支付失败'.$e->getMessage());
}
return app('json')->status('success', '余额支付成功', ['order_id' => $groupOrder['group_order_id']]);