saas_id = get_saas_user_id(); $form->store_id = get_store_id(); $form->id = post_params('id'); return $this->asJson($form->sendCoupon()); } /** * saas领取优惠券 * @return \yii\web\Response */ public function actionSaasReceive() { $form = new CouponForm(); $form->saas_id = get_saas_user_id(); $form->id = get_params('id'); $form->send_type = get_params('send_type'); return $this->asJson($form->sendSaasCoupon()); } /** * 我的优惠券列表 * @return \yii\web\Response */ public function actionIndex() { $form = new CouponForm(); $form->attributes = get_params(); //$form->store_id = get_store_id(); $form->saas_id = get_saas_user_id(); return $this->asJson($form->search()); } /** * 优惠券详情 * @return \yii\web\Response */ public function actionDetail() { $form = new CouponForm(); $form->saas_id = get_saas_user_id(); $form->id = get_params('user_coupon_id'); $form->coupon_id = get_params('coupon_id'); return $this->asJson($form->detail()); } /** * 分享领取优惠券 */ public function actionShareReceive() { $user_id = get_saas_user_id(); $user_coupon_id = post_params('id'); $user_coupon = SaasCoupon::findOne(['id' => $user_coupon_id, 'is_delete' => 0, 'give_user_id' => 0]); if (!$user_coupon) { return $this->asJson([ 'code' => 1, 'msg' => '优惠券已转赠或不存在' ]); } if ($user_id == $user_coupon->saas_id) { return $this->asJson([ 'code' => 1, 'msg' => '不能领取自己的优惠券' ]); } $user_coupon->give_user_id = $user_coupon->saas_id; $user_coupon->saas_id = $user_id; if (!$user_coupon->save()) { return $this->asJson([ 'code' => 1, 'msg' => '领取失败' ]); } return $this->asJson([ 'code' => 0, 'msg' => '领取成功' ]); } }