添加定时更新商品毛利率,调整订单数量查询的错误
This commit is contained in:
parent
9600a7fd9f
commit
0b734cc620
@ -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');
|
||||
}
|
||||
|
||||
|
@ -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],
|
||||
|
36
crmeb/listens/SetProductProfitRateListen.php
Normal file
36
crmeb/listens/SetProductProfitRateListen.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace crmeb\listens;
|
||||
|
||||
use app\common\model\store\product\ProductAttrValue;
|
||||
use crmeb\interfaces\ListenerInterface;
|
||||
use crmeb\services\TimerService;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* 定时任务:激活商户补贴
|
||||
*/
|
||||
class SetProductProfitRateListen extends TimerService implements ListenerInterface
|
||||
{
|
||||
|
||||
public function handle($event): void
|
||||
{
|
||||
$this->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());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user