| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?php
- namespace app\admin\logic;
- use app\common\model\PaymentModel;
- use app\common\model\ShopGoods;
- use think\facade\Cache;
- /**
- * 充值购买记录
- * Class ShopGoodsLogic
- * @package app\admin\logic
- */
- class PaymentLogic
- {
- /**
- * 支付统计
- * @param array $orderType 支付类型如:[4,5]
- * @param string $time 时间节点如:2023-03-01
- * @return mixed
- * @throws \think\db\exception\DbException
- */
- public static function getTotal(array $orderType, $time='0')
- {
- $cacheKey = "caches:payment:total_{$time}";
- if(!Cache::has($cacheKey)){
- $data = PaymentModel::whereIn('order_type', $orderType)
- ->where('state', 6)
- ->where(function($query) use($time){
- if($time){
- $query->where('creat_at','>=', $time);
- }
- })->sum('total_fee');
- if($data){
- Cache::set($cacheKey, $data, rand(3,5));
- }
- return $data;
- }
- return Cache::get($cacheKey);
- }
- }
|