88 lines
4.2 KiB
PHP
Executable File
88 lines
4.2 KiB
PHP
Executable File
<?php
|
||
// +----------------------------------------------------------------------
|
||
// | likeshop开源商城系统
|
||
// +----------------------------------------------------------------------
|
||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||
// | github下载:https://github.com/likeshop-github
|
||
// | 访问官网:https://www.likeshop.cn
|
||
// | 访问社区:https://home.likeshop.cn
|
||
// | 访问手册:http://doc.likeshop.cn
|
||
// | 微信公众号:likeshop技术社区
|
||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||
// | likeshop团队版权所有并拥有最终解释权
|
||
// +----------------------------------------------------------------------
|
||
// | author: likeshop.cn.team
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace app\adminapi\logic\finance;
|
||
|
||
use app\common\enum\accountLog\CoachAccountLogEnum;
|
||
use app\common\enum\accountLog\ShopAccountLogEnum;
|
||
use app\common\enum\OrderEnum;
|
||
use app\common\enum\OrderRefundEnum;
|
||
use app\common\enum\PayEnum;
|
||
use app\common\logic\BaseLogic;
|
||
use app\common\model\accountLog\CoachAccountLog;
|
||
use app\common\model\accountLog\ShopAccountLog;
|
||
use app\common\model\coach\Coach;
|
||
use app\common\model\order\Order;
|
||
use app\common\model\order\OrderRefund;
|
||
use app\common\model\RechargeOrder;
|
||
use app\common\model\settle\Settle;
|
||
use app\common\model\shop\Shop;
|
||
use app\common\model\user\User;
|
||
|
||
class CenterLogic extends BaseLogic
|
||
{
|
||
/**
|
||
* @notes 财务中心
|
||
* @return array
|
||
* @author ljj
|
||
* @date 2022/9/9 6:28 下午
|
||
*/
|
||
public function center()
|
||
{
|
||
$managementForms = [
|
||
//累计营业额
|
||
'total_amount' => Order::where(['pay_status'=>PayEnum::ISPAID])->sum('total_order_amount'),
|
||
//累计成交订单
|
||
'total_order' => Order::where(['pay_status'=>PayEnum::ISPAID])->count(),
|
||
//已退款金额
|
||
'total_refund_amount' => OrderRefund::where(['refund_status'=>OrderRefundEnum::STATUS_SUCCESS])->sum('refund_amount'),
|
||
//退款失败金额
|
||
'fail_refund_amount' => OrderRefund::where(['refund_status'=>OrderRefundEnum::STATUS_FAIL])->sum('refund_amount'),
|
||
];
|
||
$userRecharge = [
|
||
'total_user_recharge_money' => RechargeOrder::where(['pay_status'=>PayEnum::ISPAID])->sum('order_amount'),
|
||
'total_user_money' => User::sum('user_money'),
|
||
];
|
||
$coachInfo = [
|
||
'total_coach_commission' => Settle::sum('total_coach_commission'),
|
||
'total_withdraw_commission' => CoachAccountLog::where(['change_type'=>CoachAccountLogEnum::WITHDRAW_DEC_MONEY])->sum('change_amount'),
|
||
'total_may_withdraw_commission' => Coach::sum('money'),
|
||
'total_wait_settle_commission' => Order::where(['order_status'=>OrderEnum::ORDER_STATUS_SERVER_FINISH])->sum('total_order_amount'),
|
||
];
|
||
$coachIds = Coach::where('shop_id','>',0)->field('id')->select()->toArray();
|
||
$coachIds = array_column($coachIds,'id');
|
||
$shopInfo = [
|
||
'total_shop_commission' => Settle::sum('total_shop_commission'),
|
||
'total_withdraw_commission' => ShopAccountLog::where(['change_type'=>ShopAccountLogEnum::WITHDRAW_DEC_MONEY])->sum('change_amount'),
|
||
'total_may_withdraw_commission' => Shop::sum('money'),
|
||
'total_wait_settle_commission' => Order::where(['coach_id'=>$coachIds,'order_status'=>OrderEnum::ORDER_STATUS_SERVER_FINISH])->sum('total_order_amount'),
|
||
];
|
||
$depositInfo = [
|
||
'total_coach_deposit' => Coach::sum('deposit'),
|
||
'total_shop_deposit' => Shop::sum('deposit'),
|
||
];
|
||
return [
|
||
'management_forms' => $managementForms,
|
||
'user_recharge' => $userRecharge,
|
||
'coach_info' => $coachInfo,
|
||
'shop_info' => $shopInfo,
|
||
'deposit_info' => $depositInfo,
|
||
];
|
||
}
|
||
} |