diff --git a/app/controller/api/server/Store.php b/app/controller/api/server/Store.php index 21b75ebb..b85899fd 100644 --- a/app/controller/api/server/Store.php +++ b/app/controller/api/server/Store.php @@ -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('领取成功'); + } + } diff --git a/route/api.php b/route/api.php index 326be8b7..ade06cd4 100644 --- a/route/api.php +++ b/route/api.php @@ -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); //管理员订单