feat(statistics): 修改销售排名接口逻辑

This commit is contained in:
mkm 2024-07-06 16:43:12 +08:00
parent e9e9a76b32
commit 9cf4e962bc
2 changed files with 15 additions and 11 deletions

View File

@ -105,7 +105,7 @@ class IndexController extends BaseLikeController
*/
public function sales_ranking()
{
$time = $this->request->get('date', date('Y-m-d'));
$time = $this->request->get('date');
$store_id = $this->store_id;
$where = [];
if ($store_id) {

View File

@ -26,7 +26,7 @@ class OrderLogic extends BaseLogic
];
return $data;
}
public static function Currday($where,$date)
public static function Currday($where, $date)
{
$startTime = strtotime($date . ' 00:00:00'); // 当天的开始时间戳
$endTime = strtotime($date . ' 23:59:59'); // 当天的结束时间戳
@ -56,32 +56,36 @@ class OrderLogic extends BaseLogic
}
return $data;
}
public static function dayPayPrice($where,$time)
public static function dayPayPrice($where, $time)
{
$todayAmount = UserRecharge::where($where)
->whereDay('create_time',$time)
->whereDay('create_time', $time)
->sum('price');
$pay_price = StoreOrder::where($where)
->whereDay('create_time',$time)
->whereDay('create_time', $time)
->sum('pay_price');
return bcadd($todayAmount, $pay_price, 2);
}
public static function dealFlexiblePrice($where,$start,$end)
public static function dealFlexiblePrice($where, $start, $end)
{
//排除退款
$todayAmount = UserRecharge::where($where)->where('status',1)
$todayAmount = UserRecharge::where($where)->where('status', 1)
->whereBetweenTime('create_time', $start, $end)
->sum('price');
$pay_price = StoreOrder::where($where)->where('refund_status',0)
$pay_price = StoreOrder::where($where)->where('refund_status', 0)
->whereBetweenTime('create_time', $start, $end)
->sum('pay_price');
return bcadd($todayAmount, $pay_price, 2);
}
public static function sales($where,$time){
$select=StoreOrder::where($where)->whereDay('create_time',$time)->limit(10)->order('id desc')->field('id,order_id,pay_price,create_time')->select();
public static function sales($where, $time)
{
$select = StoreOrder::where($where);
if ($time) {
$select->whereDay('create_time', $time);
}
$select = $select->limit(20)->order('id desc')->field('id,order_id,pay_price,create_time')->select();
return $select?->toArray();
}
}