ztt 8 months ago
parent e0a4c32a45
commit cc5cc8cf61
  1. 22
      addons/shopro/controller/user/Coupon.php

@ -2,13 +2,16 @@
namespace addons\shopro\controller\user;
use addons\shopro\traits\CouponSend;
use app\admin\model\shopro\user\User;
use think\Db;
use think\helper\Str;
use addons\shopro\controller\Common;
use app\admin\model\shopro\user\Coupon as UserCouponModel;
class Coupon extends Common
{
use CouponSend;
protected $noNeedLogin = [];
protected $noNeedRight = ['*'];
@ -27,4 +30,21 @@ class Coupon extends Common
$this->success('获取成功', $userCoupons);
}
/**
* 领取优惠券
*/
public function ling() {
$user = auth_user();
$user_id = $user->id;
$coupon_id = $this->request->param('coupon_id');
$users = User::whereIn('id', $user_id)->select();
Db::transaction(function () use ($users, $coupon_id) {
$this->manualSend($users, $coupon_id);
});
$this->success('领取成功');
}
}

Loading…
Cancel
Save