user = $this->getUser(); // 用户信息 } /** * 兑换券详情 */ public function detail($user_coupon_id) { // 兑换券详情 $model = UserCouponModel::getDetail($user_coupon_id); // 验证是否为该门店的核销员 $clerkModel = ClerkModel::detail(['user_id' => $this->user['user_id']]); if (!$clerkModel->checkUser($clerkModel['store_id'])) { return $this->renderError($clerkModel->getError()); } //平台券可以核销 if (!empty($model['shop_supplier_id']) && $clerkModel['shop_supplier_id'] != $model['shop_supplier_id']) { return $this->renderError('很抱歉!你没有核销权限'); } if (!empty($model['use_permission']) && $model['use_permission'] ==1) { return $this->renderError('很抱歉!该券仅能线上使用'); } if ($model['is_use']) { return $this->renderError('该券可用次数已用完'); } if ($model['is_expire']) { return $this->renderError('该券已过期'); } return $this->renderSuccess('', [ 'coupon' => $model, // 兑换券详情 'clerkModel' => $clerkModel, 'setting' => [ // 积分名称 'points_name' => SettingModel::getPointsName(), ], ]); } /** * 确认核销 */ public function extract($user_coupon_id, $project_id) { // 兑换券详情 $model = UserCouponModel::detail($user_coupon_id); // 验证是否为该门店的核销员 $clerkModel = ClerkModel::detail(['user_id' => $this->user['user_id']]); // if (!$ClerkModel->checkUser($order['extract_store_id'])) { // return $this->renderError($ClerkModel->getError()); // } //平台券可以核销 if (!empty($model['shop_supplier_id']) && $clerkModel['shop_supplier_id'] != $model['shop_supplier_id']) { return $this->renderError('很抱歉!你没有核销权限'); } if (!empty($model['use_permission']) && $model['use_permission'] ==1) { return $this->renderError('很抱歉!该券仅能线上使用'); } $model['extract_store_id'] = $clerkModel['store_id']; // 确认核销 if ($model->verificationOrder($clerkModel['clerk_id'], $project_id,$clerkModel['shop_supplier_id'])) { return $this->renderSuccess('优惠券核销成功', []); } return $this->renderError($model->getError() ?:'核销失败'); } /** * 优惠核销记录列表 */ public function extract_list($search = '') { $data = $this->postData(); // 核销记录列表 $store_id = $this->user["clerkUser"]["store_id"]; $model = new StoreCouponModel; $list = $model->getList($store_id, $search, $data); return $this->renderSuccess('', compact('list')); } }