添加购物卡发货事件

This commit is contained in:
luofei 2024-02-19 17:00:08 +08:00
parent 9b5f7a56d3
commit d6617700cc
5 changed files with 39 additions and 2 deletions

View File

@ -335,6 +335,7 @@ class StoreCouponRepository extends BaseRepository
'uid' => $uid,
'coupon_title' => $coupon['title'],
'coupon_price' => $coupon['coupon_price'],
'balance' => $coupon['coupon_price'],
'use_min_price' => $coupon['use_min_price'],
'type' => $type,
'coupon_id' => $coupon['coupon_id'],
@ -357,7 +358,7 @@ class StoreCouponRepository extends BaseRepository
}
/**
* TODO 优惠券发送多用户
* TODO 优惠券发送多用户
* @param $uid
* @param $id
* @author Qinii

View File

@ -1300,6 +1300,7 @@ class StoreOrderRepository extends BaseRepository
if ($order['is_virtual'] == 1 && $data['delivery_type'] != 3)
throw new ValidateException('虚拟商品只能虚拟发货');
//订单记录
/** @var StoreOrderStatusRepository $statusRepository */
$statusRepository = app()->make(StoreOrderStatusRepository::class);
switch ($data['delivery_type']) {
case 1:

View File

@ -225,7 +225,7 @@ class Order extends BaseController
'mer_id' => $this->request->merId(),
'data' => $params
]);
return app('json')->success('开始批量发货,请稍后查看');
return app('json')->success('开始批量发货,请稍后查看');
}
/**

View File

@ -67,6 +67,7 @@ return [
//操作日志
'create_operate_log' => [\crmeb\listens\CreateOperateLogListen::class], // 操作日志事件
'mini_order_shipping' => [\crmeb\listens\MiniOrderShippingListen::class], // 小程序发货管理事件
'order.delivery' => [\crmeb\listens\OrderDeliveryListen::class], // 发货事件
],
'subscribe' => [],

View File

@ -0,0 +1,34 @@
<?php
namespace crmeb\listens;
use app\common\repositories\store\coupon\StoreCouponRepository;
use app\common\repositories\store\coupon\StoreCouponUserRepository;
use crmeb\interfaces\ListenerInterface;
/**
* Class OrderDeliveryListen
*/
class OrderDeliveryListen implements ListenerInterface
{
public function handle($event): void
{
$order = $event['order'];
foreach ($order->orderProduct as $orderProduct) {
$merchantCate = $orderProduct->product->merCateId;
if (empty($merchantCate) || $merchantCate[0]['mer_cate_id']!= env('PLATFORM_CARD_TYPE_ID')) {
continue;
}
/** @var StoreCouponRepository $repo */
$repo = app()->make(StoreCouponRepository::class);
$coupon = $repo->validCouponQuery(StoreCouponRepository::TYPE_PLATFORM_CARD, StoreCouponRepository::GET_COUPON_TYPE_BUY)
->where('coupon_price', $orderProduct->product->price)->find();
if (empty($coupon)) {
return;
}
$coupon->coupon_price = bcmul($orderProduct->product_num, $orderProduct->product->price);
$repo->sendCoupon($coupon, $order['uid'],StoreCouponUserRepository::SEND_TYPE_BUY);
}
}
}