修改补贴优惠券发放
This commit is contained in:
parent
f0291f4f45
commit
9a0b08b32a
@ -48,8 +48,9 @@ class StoreCouponRepository extends BaseRepository
|
||||
const TYPE_STORE_ALL = 0;
|
||||
//店铺商品券
|
||||
const TYPE_STORE_PRODUCT = 1;
|
||||
//店铺现金抵扣券,可结余
|
||||
//店铺现金抵扣券,可结余,通过购买商品获得
|
||||
const TYPE_STORE_COUPON = 2;
|
||||
//店铺现金抵扣券,可结余,通过销售补贴获得
|
||||
const TYPE_SALE_SUBSIDY = 3;
|
||||
//平台券
|
||||
const TYPE_PLATFORM_ALL = 10;
|
||||
@ -373,6 +374,9 @@ class StoreCouponRepository extends BaseRepository
|
||||
if (!empty($this->isFail)) {
|
||||
$data['is_fail'] = $this->isFail;
|
||||
}
|
||||
if (!empty($this->status)) {
|
||||
$data['status'] = $this->status;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
@ -3,10 +3,10 @@
|
||||
namespace crmeb\listens;
|
||||
|
||||
use app\common\model\store\coupon\StoreCouponDetail;
|
||||
use app\common\model\store\coupon\StoreCouponUser;
|
||||
use app\common\repositories\store\coupon\StoreCouponRepository;
|
||||
use app\common\repositories\store\coupon\StoreCouponUserRepository;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* Class OrderDeliveryListen
|
||||
@ -37,24 +37,18 @@ class OrderDeliveryListen implements ListenerInterface
|
||||
StoreCouponDetail::income($order, $couponUser['coupon_user_id'], $coupon->coupon_price, $coupon['title']);
|
||||
|
||||
//发放春耕补贴优惠券
|
||||
if (!empty($orderProduct->product->give_coupon_ids) && $couponTotal >= 1000) {
|
||||
$giveCoupons = $repo->getGiveCoupon($orderProduct->product->give_coupon_ids);
|
||||
foreach ($giveCoupons as $giveCoupon) {
|
||||
if ($giveCoupon['type'] != StoreCouponRepository::TYPE_STORE_COUPON) {
|
||||
continue;
|
||||
}
|
||||
try {
|
||||
$rate = $this->getRate($couponTotal);
|
||||
$giveCoupon->coupon_price = bcmul($couponTotal, $rate, 2);
|
||||
$repo->startTime = date('Y-m-d H:i:s');
|
||||
$repo->endTime = '2025-07-01';
|
||||
$repo->status = -1;
|
||||
$couponUser = $repo->sendCoupon($giveCoupon, $order['uid'], StoreCouponUserRepository::SEND_TYPE_BUY);
|
||||
StoreCouponDetail::income($order, $couponUser['coupon_user_id'], $giveCoupon->coupon_price, $giveCoupon['title'], 0);
|
||||
} catch (\Exception $e) {
|
||||
Log::error('自动发放买赠优惠券出错:' . $e->getMessage());
|
||||
}
|
||||
if ($couponTotal >= 1000) {
|
||||
$giveCoupon = $repo->validCouponQuery(StoreCouponRepository::TYPE_STORE_COUPON, StoreCouponRepository::GET_COUPON_TYPE_PAY)->find();
|
||||
if (empty($giveCoupon)) {
|
||||
return;
|
||||
}
|
||||
$rate = $this->getRate($couponTotal);
|
||||
$giveCoupon->coupon_price = bcmul($couponTotal, $rate, 2);
|
||||
$repo->startTime = date('Y-m-d H:i:s');
|
||||
$repo->endTime = '2025-07-01';
|
||||
$repo->status = StoreCouponUser::STATUS_REPEAL;
|
||||
$couponUser = $repo->sendCoupon($giveCoupon, $order['uid'], StoreCouponUserRepository::SEND_TYPE_BUY);
|
||||
StoreCouponDetail::income($order, $couponUser['coupon_user_id'], $giveCoupon->coupon_price, $giveCoupon['title'], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user