diff --git a/app/adminapi/controller/WorkbenchController.php b/app/adminapi/controller/WorkbenchController.php index d482addc6..bf8de1704 100755 --- a/app/adminapi/controller/WorkbenchController.php +++ b/app/adminapi/controller/WorkbenchController.php @@ -32,7 +32,14 @@ class WorkbenchController extends BaseAdminController */ public function index() { - $result = WorkbenchLogic::index(); + $year=date('Y'); + $date = $this->request->get('date'); + if($date==''){ + $date= $year.'/01/01-'.date('Y/m/t', strtotime("$year/12/01")); + } + $where = []; + $time = getDay($date); + $result = WorkbenchLogic::index($where, $time); return $this->data($result); } } \ No newline at end of file diff --git a/app/adminapi/logic/WorkbenchLogic.php b/app/adminapi/logic/WorkbenchLogic.php index 136ed98c4..5965f3a91 100755 --- a/app/adminapi/logic/WorkbenchLogic.php +++ b/app/adminapi/logic/WorkbenchLogic.php @@ -16,6 +16,18 @@ namespace app\adminapi\logic; use app\common\logic\BaseLogic; +use app\common\model\cost_project\CostProject; +use app\common\model\financial\FinancialBidMargin; +use app\common\model\financial\FinancialBidMarginRecovery; +use app\common\model\financial\FinancialBorrowMoney; +use app\common\model\financial\FinancialInvoice; +use app\common\model\financial\FinancialPerformanceMoneyApply; +use app\common\model\financial\FinancialPerformanceMoneyRecovery; +use app\common\model\financial\FinancialRefund; +use app\common\model\financial\FinancialRepayment; +use app\common\model\financial\FinancialSettlement; +use app\common\model\financial\FinancialUsingFunds; +use app\common\model\marketing\MarketingContract; use app\common\service\ConfigService; use app\common\service\FileService; @@ -34,175 +46,169 @@ class WorkbenchLogic extends BaseLogic * @author 段誉 * @date 2021/12/29 15:58 */ - public static function index() + public static function index($where, $time) { - return [ - // 版本信息 - 'version' => self::versionInfo(), - // 今日数据 - 'today' => self::today(), - // 常用功能 - 'menu' => self::menu(), - // 近15日访客数 - 'visitor' => self::visitor(), - // 服务支持 - 'support' => self::support() + $data = []; + $datearr = explode('-', $time); + $time = TimeConvert(['start_time' => $datearr[0], 'end_time' => $datearr[1]]); + $marketingContract = new MarketingContract(); + $costProject = new CostProject(); + $financialInvoice = new FinancialInvoice(); + $financialRefund = new FinancialRefund(); + $financialSettlement = new FinancialSettlement(); + + $financialBidMargin = new FinancialBidMargin(); + $financialBidMarginRecovery = new FinancialBidMarginRecovery(); + $financialPerformanceMoneyApply = new FinancialPerformanceMoneyApply(); + $financialPerformanceMoneyRecovery = new FinancialPerformanceMoneyRecovery(); + $financialUsingFunds = new FinancialUsingFunds(); + $financialBorrowMoney = new FinancialBorrowMoney(); + $financialRepayment = new FinancialRepayment(); + $where_1 = [ + ['review_status', '=', 1], + ['contract_type', '=', 0], + ['status', '=', 0] ]; - } - - - /** - * @notes 常用功能 - * @return array[] - * @author 段誉 - * @date 2021/12/29 16:40 - */ - public static function menu(): array - { - return [ - [ - 'name' => '管理员', - 'image' => FileService::getFileUrl(config('project.default_image.menu_admin')), - 'url' => '/permission/admin' - ], - [ - 'name' => '角色管理', - 'image' => FileService::getFileUrl(config('project.default_image.menu_role')), - 'url' => '/permission/role' - ], - [ - 'name' => '部门管理', - 'image' => FileService::getFileUrl(config('project.default_image.menu_dept')), - 'url' => '/organization/department' - ], - [ - 'name' => '字典管理', - 'image' => FileService::getFileUrl(config('project.default_image.menu_dict')), - 'url' => '/dev_tools/dict' - ], - [ - 'name' => '代码生成器', - 'image' => FileService::getFileUrl(config('project.default_image.menu_generator')), - 'url' => '/dev_tools/code' - ], - [ - 'name' => '素材中心', - 'image' => FileService::getFileUrl(config('project.default_image.menu_file')), - 'url' => '/material/index' - ], - [ - 'name' => '菜单权限', - 'image' => FileService::getFileUrl(config('project.default_image.menu_auth')), - 'url' => '/permission/menu' - ], - [ - 'name' => '网站信息', - 'image' => FileService::getFileUrl(config('project.default_image.menu_web')), - 'url' => '/setting/website/information' - ], + $total_apply_amount = $marketingContract->statistics_count($where_1, $time, 'sum', ''); + $apply_amount_value = $marketingContract->statistics_count($where_1, $time, 'group', 'create_time'); + $data[] = [ + 'title' => '待立项项目', + 'desc' => '', + 'total_money' => $total_apply_amount, + 'value' => $apply_amount_value['y'] ?? 0, + 'type' => 1, ]; - } - - - /** - * @notes 版本信息 - * @return array - * @author 段誉 - * @date 2021/12/29 16:08 - */ - public static function versionInfo(): array - { - return [ - 'version' => config('project.version'), - 'website' => config('project.website.url'), - 'name' => ConfigService::get('website', 'name'), - 'based' => 'vue3.x、ElementUI、MySQL', - 'channel' => [ - 'website' => 'https://www.likeadmin.cn', - 'gitee' => 'https://gitee.com/likeadmin/likeadmin_php', - ] + $total_apply_amount = $marketingContract->statistics_count(['status' => 1], $time, 'sum', ''); + $apply_amount_value = $marketingContract->statistics_count(['status' => 1], $time, 'group', 'create_time'); + $data[] = [ + 'title' => '已立项项目', + 'desc' => '', + 'total_money' => $total_apply_amount, + 'value' => $apply_amount_value['y'] ?? 0, + 'type' => 1, ]; - } - - /** - * @notes 今日数据 - * @return int[] - * @author 段誉 - * @date 2021/12/29 16:15 - */ - public static function today(): array - { - return [ - 'time' => date('Y-m-d H:i:s'), - // 今日销售额 - 'today_sales' => 100, - // 总销售额 - 'total_sales' => 1000, - - // 今日访问量 - 'today_visitor' => 10, - // 总访问量 - 'total_visitor' => 100, - - // 今日新增用户量 - 'today_new_user' => 30, - // 总用户量 - 'total_new_user' => 3000, - - // 订单量 (笔) - 'order_num' => 12, - // 总订单量 - 'order_sum' => 255 + //开票金额 + $total_apply_amount = $financialInvoice->ContractFinancialMoney([], $time, 'sum', '', 'apply_amount'); + $apply_amount_value = $financialInvoice->ContractFinancialMoney([], $time, 'group', 'create_time', 'apply_amount'); + $data[] = [ + 'title' => '开票金额', + 'desc' => '', + 'total_money' => $total_apply_amount, + 'value' => $apply_amount_value['y'] ?? 0, + 'type' => 1, ]; - } - - - /** - * @notes 访问数 - * @return array - * @author 段誉 - * @date 2021/12/29 16:57 - */ - public static function visitor(): array - { - $num = []; - $date = []; - for ($i = 0; $i < 15; $i++) { - $where_start = strtotime("- " . $i . "day"); - $date[] = date('Y/m/d', $where_start); - $num[$i] = rand(0, 100); - } - - return [ - 'date' => $date, - 'list' => [ - ['name' => '访客数', 'data' => $num] - ] + //回款金额 + $total_amount = $financialRefund->statistics([], $time, 'sum', '', 'amount'); + $amount_value = $financialRefund->statistics($where, $time, 'group', 'create_time', 'amount'); + $data[] = [ + 'title' => '回款金额', + 'desc' => '', + 'total_money' => $total_amount, + 'value' => $amount_value['y'] ?? 0, + 'type' => 1, ]; - } - - - /** - * @notes 服务支持 - * @return array[] - * @author 段誉 - * @date 2022/7/18 11:18 - */ - public static function support() - { - return [ - [ - 'image' => FileService::getFileUrl(config('project.default_image.qq_group')), - 'title' => '官方公众号', - 'desc' => '关注官方公众号', - ], - [ - 'image' => FileService::getFileUrl(config('project.default_image.customer_service')), - 'title' => '添加企业客服微信', - 'desc' => '想了解更多请添加客服', - ] + //结算金额 + $total_amount = $financialSettlement->statistics([], $time, 'sum', '', 'amount'); + $amount_value = $financialSettlement->statistics([], $time, 'group', 'create_time', 'amount'); + $data[] = [ + 'title' => '结算金额', + 'desc' => '', + 'total_money' => $total_amount, + 'value' => $amount_value['y'] ?? 0, + 'type' => 1, ]; - } -} \ No newline at end of file + //投资金额 + $total_apply_amount = $costProject->statistics([], $time, 'sum', '', 'invest'); + $apply_amount_value = $costProject->statistics([], $time, 'group', 'create_time', 'invest'); + $data[] = [ + 'title' => '投资金额', + 'desc' => '', + 'total_money' => $total_apply_amount, + 'value' => $apply_amount_value['y'] ?? 0, + 'type' => 1, + ]; + //签约金额 + $total_apply_amount = $marketingContract->statistics([], $time, 'sum', '', 'signed_amount'); + $apply_amount_value = $marketingContract->statistics([], $time, 'group', 'create_time', 'signed_amount'); + $data[] = [ + 'title' => '签约金额', + 'desc' => '', + 'total_money' => $total_apply_amount, + 'value' => $apply_amount_value['y'] ?? 0, + 'type' => 1, + ]; + //保证金申请 + $total_bid_margin = $financialBidMargin->statistics([], $time, 'sum', '', 'bid_margin'); + $bid_margin_value = $financialBidMargin->statistics([], $time, 'group', 'create_time', 'bid_margin'); + $data[] = [ + 'title' => '保证金申请', + 'desc' => '', + 'total_money' => $total_bid_margin, + 'value' => $bid_margin_value['y']??[], + 'type' => 1, + ]; + //保证金回收 + $total_pay_amount = $financialBidMarginRecovery->statistics([], $time, 'sum', '', 'pay_amount'); + $pay_amount_value = $financialBidMarginRecovery->statistics([], $time, 'group', 'create_time', 'pay_amount'); + $data[] = [ + 'title' => '保证金回收', + 'desc' => '', + 'total_money' => $total_pay_amount, + 'value' => $pay_amount_value['y']??[], + 'type' => 1, + ]; + //履约申请 + $apply_amount = $financialPerformanceMoneyApply->statistics([], $time, 'sum', '', 'apply_amount'); + $apply_amount_value = $financialPerformanceMoneyApply->statistics([], $time, 'group', 'create_time', 'apply_amount'); + $data[] = [ + 'title' => '履约申请', + 'desc' => '', + 'total_money' => $apply_amount, + 'value' => $apply_amount_value['y']??[], + 'type' => 1, + ]; + //履约回收 + $recovery_amount = $financialPerformanceMoneyRecovery->statistics([], $time, 'sum', '', 'recovery_amount'); + $recovery_amount_value = $financialPerformanceMoneyRecovery->statistics([], $time, 'group', 'create_time', 'recovery_amount'); + $data[] = [ + 'title' => '履约回收', + 'desc' => '', + 'total_money' => $recovery_amount, + 'value' => $recovery_amount_value['y']??[], + 'type' => 1, + ]; + //用款 + $has_pay_amount = $financialUsingFunds->statistics([], $time, 'sum', '', 'has_pay_amount'); + $has_pay_amount_value = $financialUsingFunds->statistics([], $time, 'group', 'create_time', 'has_pay_amount'); + $data[] = [ + 'title' => '用款', + 'desc' => '', + 'total_money' => $has_pay_amount, + 'value' => $has_pay_amount_value['y']??[], + 'type' => 1, + ]; + //借款 + $amount = $financialBorrowMoney->statistics([], $time, 'sum', '', 'amount'); + $amount_value = $financialBorrowMoney->statistics([], $time, 'group', 'create_time', 'amount'); + $data[] = [ + 'title' => '借款', + 'desc' => '', + 'total_money' => $amount, + 'value' => $amount_value['y']??[], + 'type' => 1, + ]; + //还款 + $amount = $financialRepayment->statistics([], $time, 'sum', '', 'amount'); + $amount_value = $financialRepayment->statistics([], $time, 'group', 'create_time', 'amount'); + $data[] = [ + 'title' => '还款', + 'desc' => '', + 'total_money' => $amount, + 'value' => $amount_value['y']??[], + 'type' => 1, + ]; + return $data; + } +} diff --git a/app/adminapi/logic/financial/FinancialStatisticsLogic.php b/app/adminapi/logic/financial/FinancialStatisticsLogic.php index 4ba04c002..7623fb679 100644 --- a/app/adminapi/logic/financial/FinancialStatisticsLogic.php +++ b/app/adminapi/logic/financial/FinancialStatisticsLogic.php @@ -55,15 +55,15 @@ class FinancialStatisticsLogic extends BaseLogic 'type' => 1, ]; //结算金额 - // $total_capply_amount=$marketingContract->ContractFinancialMoney([],$time,'sum','','amount'); - // $total_apply_amount_value=$marketingContract->ContractFinancialMoney([],$time,'group','create_time','amount'); - // $data[]=[ - // 'title' => '回款金额', - // 'desc' => '', - // 'total_money' => $total_capply_amount, - // 'value' => $total_apply_amount_value['y'], - // 'type' => 1, - // ]; + $total_capply_amount=$marketingContract->ContractFinancialMoney([],$time,'sum','','amount'); + $total_apply_amount_value=$marketingContract->ContractFinancialMoney([],$time,'group','create_time','amount'); + $data[]=[ + 'title' => '回款金额', + 'desc' => '', + 'total_money' => $total_capply_amount, + 'value' => $total_apply_amount_value['y'], + 'type' => 1, + ]; //保证金申请 $total_bid_margin = $financialBidMargin->statistics([], $time, 'sum', '', 'bid_margin');