From 2f34a03800b227cd48d851bd5c11ffb7eaafa2c1 Mon Sep 17 00:00:00 2001 From: luofei <604446095@qq.com> Date: Thu, 22 Feb 2024 15:53:37 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E8=AF=95=E8=B4=AD=E7=89=A9=E5=8D=A1?= =?UTF-8?q?=E5=8F=91=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../consumption/StoreConsumptionUserDao.php | 7 ++++-- crmeb/listens/OrderDeliveryListen.php | 25 ++++++++++++++++++- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/app/common/dao/store/consumption/StoreConsumptionUserDao.php b/app/common/dao/store/consumption/StoreConsumptionUserDao.php index 13bc530a..60ed0518 100755 --- a/app/common/dao/store/consumption/StoreConsumptionUserDao.php +++ b/app/common/dao/store/consumption/StoreConsumptionUserDao.php @@ -49,6 +49,9 @@ class StoreConsumptionUserDao extends BaseDao /** @var float $profitRate 商品毛利率 */ public $profitRate; + public $startTime; + public $endTime; + protected function getModel(): string { return StoreConsumptionUser::class; @@ -249,8 +252,8 @@ class StoreConsumptionUserDao extends BaseDao $model->balance = $model->coupon_price; $model->order_amount = $amount; $model->create_time = date('Y-m-d H:i:s'); - $model->start_time = date('Y-m-d H:i:s', time() + 7 * 86400); - $model->end_time = '2026-01-15 23:59:59'; + $model->start_time = $this->startTime ?: date('Y-m-d H:i:s', time() + 7 * 86400); + $model->end_time = $this->endTime ?: '2026-01-15 23:59:59'; $model->type = $type; $model->status = $status; } diff --git a/crmeb/listens/OrderDeliveryListen.php b/crmeb/listens/OrderDeliveryListen.php index f9352fde..87f5c440 100644 --- a/crmeb/listens/OrderDeliveryListen.php +++ b/crmeb/listens/OrderDeliveryListen.php @@ -26,8 +26,31 @@ class OrderDeliveryListen implements ListenerInterface $consumption = StoreConsumption::where('type', StoreConsumption::TYPE_PULL_CONSUMPTION)->find(); /** @var StoreConsumptionUserDao $repo */ $repo = app()->make(StoreConsumptionUserDao::class); - $repo->send($consumption, 100, $order['uid'], $order['group_order_id'], $order->total_price, StoreConsumptionUser::STATUS_UNUSED); + $repo->startTime = date('Y-m-d H:i:s'); + $repo->endTime = '2025-07-01'; + $repo->send($consumption, 1, $order['uid'], $order['group_order_id'], $order->total_price, StoreConsumptionUser::STATUS_UNUSED); + + //TODO 当商户销售和购买达到指定金额后,激活抵扣补贴 + $consumption = StoreConsumption::where('type', StoreConsumption::TYPE_OWNER_CONSUMPTION)->find(); + $repo->startTime = date('Y-m-d H:i:s'); + $repo->endTime = '2025-07-01'; + $rate = $this->getRate($order->total_price); + $repo->send($consumption, $rate, $order['uid'], $order['group_order_id'], $order->total_price, StoreConsumptionUser::STATUS_REPEAL, StoreConsumptionUser::TYPE_TWO); } } + public function getRate($orderAmount) + { + if ($orderAmount >= 1000 && $orderAmount < 5000) { + $rate = 0.05; + } elseif ($orderAmount >= 5000 && $orderAmount < 10000) { + $rate = 0.10; + } elseif ($orderAmount >= 10000 && $orderAmount < 50000) { + $rate = 0.15; + } elseif ($orderAmount >= 50000 && $orderAmount <= 100000) { + $rate = 0.20; + } + return $rate ?? 0; + } + }