|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace app\admin\controller\user;
|
|
|
|
|
|
+use app\admin\model\Coupon;
|
|
|
use app\common\controller\Backend;
|
|
|
use app\common\library\Auth;
|
|
|
use app\common\model\Programme;
|
|
@@ -169,4 +170,24 @@ class User extends Backend
|
|
|
$this->success();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ #赠送优惠券
|
|
|
+ public function send_coupon($ids){
|
|
|
+ if($this->request->isGet()) {
|
|
|
+ $coupon = Coupon::all();
|
|
|
+ $this->assign('coupon',$coupon);
|
|
|
+ return $this->fetch();
|
|
|
+ }else{
|
|
|
+ $data=input('row/a');
|
|
|
+ $this->validate($data,[
|
|
|
+ 'coupon|券ID'=>['require','integer'],
|
|
|
+ 'num|数量'=>['require','integer','gt:0'],
|
|
|
+ ]);
|
|
|
+ $coupon=Coupon::where('id',$data['coupon'])->find();
|
|
|
+ if(!$coupon){
|
|
|
+ $this->error('优惠券不存在');
|
|
|
+ }
|
|
|
+ $coupon->sendToUser([$ids],$data['num']);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|