修改:优惠券赠送支持任意类型
This commit is contained in:
parent
465d2d38c0
commit
803aa1d6d5
|
|
@ -85,7 +85,9 @@ class StoreCouponDao extends BaseDao
|
|||
{
|
||||
$query = StoreCoupon::getDB()
|
||||
->where('status', 1)
|
||||
->where('send_type', $send_type)
|
||||
->when(isset($where['send_type']) && $where['send_type'] !== '', function ($query) use ($send_type) {
|
||||
$query->where('send_type', $send_type);
|
||||
})
|
||||
->where('is_del', 0)
|
||||
->order('sort DESC,coupon_id DESC')
|
||||
->when(!is_null($type), function ($query) use ($type) {
|
||||
|
|
@ -188,6 +190,16 @@ class StoreCouponDao extends BaseDao
|
|||
})->where('coupon_id', $id)->find();
|
||||
}
|
||||
|
||||
|
||||
public function validSvipCouponTwo($id, $uid)
|
||||
{
|
||||
return $this->validCouponQuery(null,'')->when($uid, function (BaseQuery $query, $uid) {
|
||||
$query->with(['svipIssue' => function (BaseQuery $query) use ($uid) {
|
||||
$query->where('uid', $uid);
|
||||
}]);
|
||||
})->where('coupon_id', $id)->find();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $merId
|
||||
* @param null $uid
|
||||
|
|
|
|||
|
|
@ -300,7 +300,9 @@ class StoreCouponRepository extends BaseRepository
|
|||
// 购买会员卡赠送优惠券 支持重复赠送
|
||||
public function buyMembershipCardGive($id, $order){
|
||||
$uid = $order['uid'];
|
||||
$coupon = $this->dao->validSvipCoupon($id,$uid);
|
||||
$coupon = $this->dao->validSvipCouponTwo($id,$uid);
|
||||
|
||||
|
||||
if (!$coupon) throw new ValidateException('优惠券失效');
|
||||
// 获取酒道馆id 和关联的品牌ID
|
||||
$bindShop = [];
|
||||
|
|
|
|||
|
|
@ -19,7 +19,14 @@ class CardOpeningEvent
|
|||
|
||||
$StoreCouponRepository = app()->make(StoreCouponRepository::class);
|
||||
foreach ($coupon as $val){
|
||||
$StoreCouponRepository->buyMembershipCardGive($val, $order);
|
||||
try {
|
||||
$StoreCouponRepository->buyMembershipCardGive($val, $order);
|
||||
} catch (\Exception $e) {
|
||||
Log::info('会员卡开通成功 - 错误: '.var_export([
|
||||
'msg' => $e->getMessage(),
|
||||
'coupon_id' => $val
|
||||
],1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue