添加优惠券拒绝领取

This commit is contained in:
luofei 2024-03-21 10:34:04 +08:00
parent ca07bd58a8
commit f7dcde9937
2 changed files with 24 additions and 0 deletions

View File

@ -246,6 +246,7 @@ class Store extends BaseController
}
Db::startTrans();
try {
$couponDetail->status = StoreCouponDetail::STATUS_VALID;
$couponDetail->send_status = StoreCouponDetail::SEND_FINISHED;
if (!$couponDetail->save()) {
throw new \Exception('优惠券详情保存出错');
@ -263,4 +264,26 @@ class Store extends BaseController
}
}
/**
* 拒绝领取
* @param $id
* @return mixed
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function refuse($id)
{
$userId = $this->request->uid();
$couponDetail = StoreCouponDetail::where('id', $id)->where('uid', $userId)->find();
if (empty($couponDetail) || $couponDetail['send_status'] != StoreCouponDetail::SEND_CONFIRM) {
return app('json')->fail('当前状态不支持操作');
}
$couponDetail->send_status = StoreCouponDetail::SEND_AUDIT;
if (!$couponDetail->save()) {
throw new \Exception('优惠券详情保存出错');
}
return app('json')->success('领取成功');
}
}

View File

@ -319,6 +319,7 @@ Route::group('api/', function () {
Route::get('subsidy', 'Store/subsidy');
Route::get('subsidyRecord', 'Store/subsidyRecord');
Route::get('subsidyReceive', 'Store/receive');
Route::get('subsidyRefuse', 'Store/refuse');
})->prefix('api.server.')->middleware(\app\common\middleware\MerchantServerMiddleware::class, 1);
//管理员订单