|
|
@@ -15,9 +15,9 @@ use Yii;
|
|
|
|
|
|
class CouponService extends BaseService
|
|
|
{
|
|
|
-
|
|
|
+
|
|
|
public static $baseFile = '\biz\promote\classes\CouponClass';
|
|
|
-
|
|
|
+
|
|
|
//优惠券列表 shish 2019.12.11
|
|
|
public static function getCouponList($where)
|
|
|
{
|
|
|
@@ -52,9 +52,9 @@ class CouponService extends BaseService
|
|
|
}
|
|
|
return $coupon['amount'];
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//销卷并分成 shish 2019.8.25
|
|
|
- public static function destroyToGetReward($data)
|
|
|
+ public static function destroyToGetReward($data, $merchantId)
|
|
|
{
|
|
|
validate::easyCheck(['id'], $data);
|
|
|
$couponId = $data['id'];
|
|
|
@@ -65,7 +65,6 @@ class CouponService extends BaseService
|
|
|
if (empty($coupon)) {
|
|
|
util::fail('找不到优惠卷');
|
|
|
}
|
|
|
- $merchantId = Yii::$app->params['merchantId'];
|
|
|
if ($coupon['merchantId'] != $merchantId) {
|
|
|
util::fail('你没有权限操作');
|
|
|
}
|
|
|
@@ -126,18 +125,15 @@ class CouponService extends BaseService
|
|
|
}
|
|
|
|
|
|
//是否领取过老带新的卷 shish 2019.8.25
|
|
|
- public static function hasGained()
|
|
|
+ public static function hasGained($userId, $merchantId)
|
|
|
{
|
|
|
- $userId = Yii::$app->params['userId'];
|
|
|
- $merchantId = Yii::$app->params['merchantId'];
|
|
|
$return = self::getByCondition(['merchantId' => $merchantId, 'userId' => $userId]);
|
|
|
return empty($return) ? false : true;
|
|
|
}
|
|
|
|
|
|
//获取我的优惠卷 $status null全部 0未使用 1使用 2过期
|
|
|
- public static function getMyCoupon($status = null)
|
|
|
+ public static function getMyCoupon($userId, $status = null)
|
|
|
{
|
|
|
- $userId = Yii::$app->params['userId'];
|
|
|
$where = ['userId' => $userId];
|
|
|
if (isset($status) != false) {
|
|
|
$where['status'] = $status;
|
|
|
@@ -146,11 +142,9 @@ class CouponService extends BaseService
|
|
|
}
|
|
|
|
|
|
//取出部分可用的优惠卷 shish 2019.8.28
|
|
|
- public static function getAvailableCouponList($data)
|
|
|
+ public static function getAvailableCouponList($data, $userId, $merchantId)
|
|
|
{
|
|
|
validate::easyCheck(['categoryId', 'usageId', 'amount'], $data);
|
|
|
- $merchantId = Yii::$app->params['merchantId'];
|
|
|
- $userId = Yii::$app->params['userId'];
|
|
|
$amount = $data['amount'];
|
|
|
$categoryId = $data['categoryId'];
|
|
|
$usageId = $data['usageId'];
|
|
|
@@ -182,10 +176,8 @@ class CouponService extends BaseService
|
|
|
}
|
|
|
|
|
|
//判断用户是否有卷
|
|
|
- public static function hasCoupon()
|
|
|
+ public static function hasCoupon($userId, $merchantId)
|
|
|
{
|
|
|
- $merchantId = Yii::$app->params['merchantId'];
|
|
|
- $userId = Yii::$app->params['userId'];
|
|
|
$list = self::getAllByCondition(['merchantId' => $merchantId, 'userId' => $userId], 'id desc', '*');
|
|
|
$hasCoupon = false;
|
|
|
$time = time();
|
|
|
@@ -217,10 +209,8 @@ class CouponService extends BaseService
|
|
|
|
|
|
|
|
|
//付款成功后领取优惠券 shish 2019.9.17
|
|
|
- public static function paySuccessGetCoupon()
|
|
|
+ public static function paySuccessGetCoupon($userId, $merchantId)
|
|
|
{
|
|
|
- $userId = Yii::$app->params['userId'];
|
|
|
- $merchantId = Yii::$app->params['merchantId'];
|
|
|
/**确认是否可领卷**/
|
|
|
$flag = UserAssetService::couldGetCoupon($userId);
|
|
|
if ($flag == -1) {
|