diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index 3dad843e..b0cfd9d3 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -584,14 +584,14 @@ class StoreOrderRepository extends BaseRepository public function userOrderNumber(int $uid) { $noPay = app()->make(StoreGroupOrderRepository::class)->orderNumber($uid); - $noPostage = $this->dao->search(['uid' => $uid, 'status' => 0, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); - $all = $this->dao->search(['uid' => $uid, 'status' => -2,'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); - $noDeliver = $this->dao->search(['uid' => $uid, 'status' => 1, 'paid' => 1])->where('StoreOrder.is_del', 0)->count(); - $noComment = $this->dao->search(['uid' => $uid, 'status' => 2, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); - $done = $this->dao->search(['uid' => $uid, 'status' => 3, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); + $noPostage = $this->dao->search(['StoreOrder.uid' => $uid, 'status' => 0, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); + $all = $this->dao->search(['StoreOrder.uid' => $uid, 'status' => -2,'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); + $noDeliver = $this->dao->search(['StoreOrder.uid' => $uid, 'status' => 1, 'paid' => 1])->where('StoreOrder.is_del', 0)->count(); + $noComment = $this->dao->search(['StoreOrder.uid' => $uid, 'status' => 2, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); + $done = $this->dao->search(['StoreOrder.uid' => $uid, 'status' => 3, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); $refund = app()->make(StoreRefundOrderRepository::class)->getWhereCount(['uid' => $uid, 'status' => [0, 1, 2]]); //$orderPrice = $this->dao->search(['uid' => $uid, 'paid' => 1])->sum('pay_price'); - $orderCount = $this->dao->search(['uid' => $uid, 'paid' => 1,'is_user' => 1])->count(); + $orderCount = $this->dao->search(['StoreOrder.uid' => $uid, 'paid' => 1,'is_user' => 1])->count(); return compact('noComment', 'done', 'refund', 'noDeliver', 'noPay', 'noPostage', 'orderCount', 'all'); } diff --git a/app/event.php b/app/event.php index 3c98fcc6..2374caa0 100644 --- a/app/event.php +++ b/app/event.php @@ -57,6 +57,7 @@ return [ \crmeb\listens\SyncMerchantMarginStatusListen::class, \crmeb\listens\SyncQueueStatusListen::class, \crmeb\listens\ActivateCouponListen::class, + \crmeb\listens\SetProductProfitRateListen::class, ] : [], 'pay_success_user_recharge' => [\crmeb\listens\pay\UserRechargeSuccessListen::class], 'pay_success_user_order' => [\crmeb\listens\pay\UserOrderSuccessListen::class], diff --git a/crmeb/listens/SetProductProfitRateListen.php b/crmeb/listens/SetProductProfitRateListen.php new file mode 100644 index 00000000..d8ea62ad --- /dev/null +++ b/crmeb/listens/SetProductProfitRateListen.php @@ -0,0 +1,36 @@ +tick(1000 * 60, function () { + Log::info('定时任务:更新商品利润率'); + try { + $storeProducts = ProductAttrValue::where('profit_rate', 0) + ->where('procure_price', '>', 0) + ->whereRaw('price>procure_price') + ->limit(50) + ->select(); + foreach ($storeProducts as $storeProduct) { + $storeProduct->profit_rate = bcdiv($storeProduct->procure_price, $storeProduct->price, 2) * 100; + $storeProduct->save(); + } + } catch (\Throwable $e) { + Log::info('定时任务:更新商品利润率,error => ' . $e->getMessage()); + } + }); + } + +}