续费订单旧系统数据特殊处理

This commit is contained in:
邓皓元 2019-08-23 18:04:58 +08:00
parent 10c505a4a2
commit d29c1d6fc5
25 changed files with 129 additions and 80 deletions

View File

@ -1,4 +1,5 @@
<?php
namespace App\Domains\Stats\Http\Controllers;
use Illuminate\Http\Request;

View File

@ -1,4 +1,5 @@
<?php
namespace App\Domains\Stats\Services;
use App\Dicts;
@ -55,9 +56,9 @@ class CompanyReportService extends Service
$item->company_name = $company['name'];
$item->package_name = $package['name'];
$item->service_months = $package['service_months'] ?? 1;
$item->unit_price = sprintf('%.02f', $item->unit_price/100);
$item->month_price = sprintf('%.02f', $item->unit_price/$item->service_months);
$item->total_price = sprintf('%.02f', $item->unit_price/$item->service_months*$item->counts);
$item->unit_price = sprintf('%.02f', $item->unit_price / 100);
$item->month_price = sprintf('%.02f', $item->unit_price / $item->service_months);
$item->total_price = sprintf('%.02f', $item->unit_price / $item->service_months * $item->counts);
$item->type_name = self::$typeNames[$item->type];
unset($item->order);
});
@ -97,7 +98,7 @@ class CompanyReportService extends Service
$item->package_name = $package['name'];
$item->carrier_operator_name = $carrierOperators[$package['carrier_operator']];
$month_price = $item->unit_price / $package['service_months'];
$item->month_price = sprintf('%.02f', $month_price/100);
$item->month_price = sprintf('%.02f', $month_price / 100);
unset($item->order);
});

View File

@ -54,13 +54,12 @@ class OrderService extends Service
DB::raw("array_to_string(array_agg(id), ',') as order_id"),
'company_id',
'package_id',
'unit_price',
'pay_channel',
DB::raw('SUM(custom_price) as custom_price'),
];
$orders = $this->orderRepository->select($select)->withConditions($conditions)->applyConditions()
->groupBy(['company_id', 'package_id', 'unit_price', 'pay_channel'])->paginate($conditions['limit']);
->groupBy(['company_id', 'package_id', 'pay_channel'])->paginate($conditions['limit']);
$order_ids = [];
$groups = [];
@ -81,11 +80,15 @@ class OrderService extends Service
$values = implode(',', $groups);
$join = DB::raw("(VALUES $values) as t(gid, o_id)");
$members = collect();
if (!empty($groups)) {
$members = $repository->join($join, 'o_id', '=', 'order_id')->select([
'gid',
DB::raw('SUM(counts) as counts'),
DB::raw('COUNT(distinct sim) as members'),
])->withConditions(['order_id' => $order_ids])->groupBy('gid')->get();
}
$orders->map(function ($item) use ($companies, $packages, $members) {
$item->company_name = $companies[$item->company_id];
@ -94,13 +97,59 @@ class OrderService extends Service
$item->members = $members[$item->gid]['members'] ?? 0;
$item->counts = $members[$item->gid]['counts'] ?? 0;
$item->custom_price = sprintf('%.02f', $item->unit_price * $item->counts / 100);
$item->unit_price = sprintf('%.02f', $item->unit_price / 100);
$item->custom_price = sprintf('%.02f', $item->custom_price / 100);
$item->pay_channel_name = CommonService::namePayChannel($item->pay_channel);
// 为兼容旧系统的错误做的处理
$this->oldDataCount($item);
});
return $orders;
return $orders->where('counts', '<>', 0)->values();
}
// 为兼容旧系统的错误做的处理
private function oldDataCount(&$item)
{
$data = [
3389 => ['members' => 1, 'counts' => 1, 'custom_price' => 60], // 福建省福信富通网络科技股份有限公司微信支付Y02 2016
3768 => ['members' => -8, 'counts' => -4, 'custom_price' => -120], // 深圳市美凯欣科技有限公司银行转账Y02 2016
4454 => ['members' => -3, 'counts' => 0, 'custom_price' => 0], // 深圳市美凯欣科技有限公司银行转账Y02 2016
5170 => ['members' => -10, 'counts' => -10, 'custom_price' => -500], // 深圳市美凯欣科技有限公司银行转账Y02 2016
9181 => ['members' => 1, 'counts' => 1, 'custom_price' => 36], // 福建省福信富通网络科技股份有限公司微信支付Y02 2017-06
12049 => ['members' => 19, 'counts' => 19, 'custom_price' => 1140], // 福建省福信富通网络科技股份有限公司微信支付Y02 2017-08
13329 => ['members' => 3, 'counts' => 3, 'custom_price' => 180], // 福建省福信富通网络科技股份有限公司微信支付Y02 2017-09
14345 => ['members' => -18, 'counts' => -18, 'custom_price' => -1056], // 福建省福信富通网络科技股份有限公司微信支付Y02 2017-10
15061 => ['members' => -6, 'counts' => -6, 'custom_price' => -360], // 福建省福信富通网络科技股份有限公司微信支付Y02 2017-11
6519 => ['members' => -1, 'counts' => -1, 'custom_price' => -8], // 深圳市和佳艺物联网有限公司支付宝Y01 2017
8069 => ['members' => -1, 'counts' => -1, 'custom_price' => -6], // 深圳市和佳艺物联网有限公司支付宝Y01 2017
15889 => ['members' => 1, 'counts' => 1, 'custom_price' => 8], // 深圳市和佳艺物联网有限公司支付宝Y01
6732 => ['members' => -1, 'counts' => -1, 'custom_price' => -8], // 深圳市路科科技有限公司支付宝Y01
5944 => ['members' => -4, 'counts' => -4, 'custom_price' => -180], // 深圳市路科科技有限公司支付宝Y01
5944 => ['members' => -4, 'counts' => -4, 'custom_price' => -180], // 深圳市路科科技有限公司支付宝Y01
6456 => ['members' => -1, 'counts' => -1, 'custom_price' => -30], // 深圳市路科科技有限公司支付宝Y01
7819 => ['members' => -1, 'counts' => -1, 'custom_price' => -8], // 深圳市美凯欣科技有限公司支付宝Y02
6456 => ['members' => -1, 'counts' => -1, 'custom_price' => -30], // 深圳市美凯欣科技有限公司银行转账Y02
8203 => ['members' => -3, 'counts' => -3, 'custom_price' => -54], // 深圳市美凯欣科技有限公司银行转账Y02
9272 => ['members' => -21, 'counts' => -16, 'custom_price' => -820], // 深圳市美凯欣科技有限公司银行转账Y02
11070 => ['members' => 3, 'counts' => 4, 'custom_price' => 120], // 深圳市美凯欣科技有限公司银行转账Y02
12357 => ['members' => 14, 'counts' => 14, 'custom_price' => 785.5], // 深圳市美凯欣科技有限公司银行转账Y02
13390 => ['members' => 11, 'counts' => 11, 'custom_price' => 530], // 深圳市美凯欣科技有限公司银行转账Y02
14432 => ['members' => 3, 'counts' => 3, 'custom_price' => 150], // 深圳市美凯欣科技有限公司银行转账Y02
16358 => ['members' => 3, 'counts' => 3, 'custom_price' => 64.5], // 深圳市美凯欣科技有限公司银行转账Y02
7734 => ['members' => -1, 'counts' => -1, 'custom_price' => -50], // 深圳思畅智能系统有限公司银行转账Y02
];
$o_ids = str_to_array($item->order_id);
foreach ($o_ids as $id) {
if (in_array($id, array_keys($data))) {
$item->members = $item->members + $data[$id]['members'] ?? 0;
$item->counts = $item->counts + $data[$id]['counts'] ?? 0;
$item->custom_price = $item->custom_price + $data[$id]['custom_price'] ?? 0;
$item->custom_price = sprintf('%.02f', $item->custom_price);
}
}
}
/**

View File

@ -6,7 +6,7 @@ use Dipper\Foundation\Support\Time;
use Illuminate\Support\Facades\Event;
use App\Domains\Account\Services\AccountService;
if (! function_exists('begin_time_consuming')) {
if (!function_exists('begin_time_consuming')) {
/**
* 初始化耗时任务
*
@ -19,7 +19,7 @@ if (! function_exists('begin_time_consuming')) {
}
}
if (! function_exists('cdn')) {
if (!function_exists('cdn')) {
/**
* 生成CDN链接, 可带时间戳防盗链
*
@ -54,7 +54,7 @@ if (! function_exists('cdn')) {
}
}
if (! function_exists('account_avatar')) {
if (!function_exists('account_avatar')) {
/**
* 单次获取账户头像
*
@ -70,7 +70,7 @@ if (! function_exists('account_avatar')) {
}
}
if (! function_exists('save_cover')) {
if (!function_exists('save_cover')) {
/**
* 保存封面
*
@ -104,7 +104,7 @@ if (! function_exists('save_cover')) {
}
}
if (! function_exists('get_cover')) {
if (!function_exists('get_cover')) {
/**
* 保存封面
*
@ -121,7 +121,7 @@ if (! function_exists('get_cover')) {
}
}
if (! function_exists('config_path')) {
if (!function_exists('config_path')) {
/**
* Get the configuration path.
*
@ -130,13 +130,13 @@ if (! function_exists('config_path')) {
*/
function config_path($path = '')
{
$path = 'config' . DIRECTORY_SEPARATOR . ($path ? DIRECTORY_SEPARATOR.$path : $path);
$path = 'config' . DIRECTORY_SEPARATOR . ($path ? DIRECTORY_SEPARATOR . $path : $path);
return base_path($path);
}
}
if (! function_exists('array_merge_sum')) {
if (!function_exists('array_merge_sum')) {
/**
* 合并数组(相同键名相加)
*
@ -158,7 +158,7 @@ if (! function_exists('array_merge_sum')) {
}
}
if (! function_exists('human_filesize')) {
if (!function_exists('human_filesize')) {
/**
* 文件大小可读性
*
@ -175,7 +175,7 @@ if (! function_exists('human_filesize')) {
$options = array_map('strtoupper', $options);
if (isset($options['unit']) && array_search($options['unit'], $size) !== false) {
for ($i=0; $i < array_search($options['unit'], $size); $i++) {
for ($i = 0; $i < array_search($options['unit'], $size); $i++) {
unset($size[$i]);
}
@ -196,7 +196,7 @@ if (! function_exists('human_filesize')) {
}
}
if (! function_exists('range_compare')) {
if (!function_exists('range_compare')) {
/**
* 区间比较
* 0:两区间完全相等
@ -270,7 +270,8 @@ if (!function_exists('single_case')) {
*/
function single_case($str)
{
$arr = array('' => '0', '' => '1', '' => '2', '' => '3', '' => '4',
$arr = array(
'' => '0', '' => '1', '' => '2', '' => '3', '' => '4',
'' => '5', '' => '6', '' => '7', '' => '8', '' => '9',
'' => 'A', '' => 'B', '' => 'C', '' => 'D', '' => 'E',
'' => 'F', '' => 'G', '' => 'H', '' => 'I', '' => 'J',
@ -291,7 +292,8 @@ if (!function_exists('single_case')) {
'' => ':', '。' => '.', '、' => ',', '' => '.', '、' => '.',
'' => ',', '' => '?', '' => '!', '…' => '-', '‖' => '|',
'”' => '"', '' => '`', '' => '`', '' => '|', '〃' => '"',
' ' => ' ');
' ' => ' '
);
return strtr($str, $arr);
}

View File

@ -21,7 +21,6 @@
<Row type="flex" justify="center" class="umar-t15" v-if="steps[current] && steps[current]['datePicker']">
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="month"

View File

@ -23,7 +23,6 @@
v-if="steps[current] && steps[current]['datePicker']"
>
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="month"

View File

@ -42,7 +42,6 @@
<li class="handle-item w-250">
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="daterange"

View File

@ -21,7 +21,6 @@
<Row type="flex" justify="center" class="umar-t15" v-if="steps[current] && steps[current]['datePicker']">
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="month"

View File

@ -47,7 +47,6 @@
<li class="handle-item w-350">
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="daterange"

View File

@ -43,7 +43,6 @@
<li class="handle-item w-250">
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="daterange"

View File

@ -69,7 +69,6 @@
<ul class="handle-wraper">
<li class="handle-item w-250">
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="month"

View File

@ -68,7 +68,6 @@
<ul class="handle-wraper">
<li class="handle-item w-250">
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="daterange"

View File

@ -34,23 +34,19 @@ export default {
},
columns: [{
title: '企业名称',
key: 'company_name'
key: 'company_name',
minWidth: 210
},
{
title: '套餐名称',
key: 'package_name',
width: 150
minWidth: 150
},
{
title: '支付方式',
key: 'pay_channel_name',
width: 120
},
{
title: '单价',
key: 'unit_price',
width: 120
},
{
title: '人数',
key: 'members',
@ -69,7 +65,7 @@ export default {
{
title: '操作',
key: 'action',
width: 170,
minWidth: 180,
render: (h, {
row,
column,

View File

@ -32,7 +32,6 @@
<li class="handle-item">
<DatePicker
:editable="false"
placeholder="开始时间"
placement="bottom-start"
type="month"
@ -44,7 +43,6 @@
<li class="handle-item">
<DatePicker
:editable="false"
placeholder="结束时间"
placement="bottom-start"
type="month"

View File

@ -65,7 +65,6 @@
<li class="handle-item w-250">
<DatePicker
:editable="false"
placeholder="激活时间"
placement="bottom-start"
type="daterange"
@ -100,7 +99,6 @@
<li class="handle-item w-250">
<DatePicker
:editable="false"
placeholder="创建时间"
placement="bottom-start"
type="daterange"

View File

@ -68,7 +68,6 @@
<li class="handle-item w-250">
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="month"

View File

@ -49,7 +49,6 @@
<li class="handle-item w-200">
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="daterange"

View File

@ -87,7 +87,6 @@
<li class="handle-item w-250">
<DatePicker
:editable="false"
placeholder="请选择时间"
placement="bottom-start"
type="daterange"

View File

@ -18,7 +18,6 @@
<div class="ui-list-content">
<p>
<DatePicker
:editable="false"
placeholder="退货时间"
placement="bottom-start"
type="date"

View File

@ -40,7 +40,6 @@
<li class="handle-item w-250">
<DatePicker
:editable="false"
placeholder="订单时间"
placement="bottom-start"
type="daterange"
@ -92,7 +91,6 @@
<li class="handle-item w-250">
<DatePicker
:editable="false"
placeholder="退货时间"
placement="bottom-start"
type="daterange"

File diff suppressed because one or more lines are too long

View File

@ -1,4 +1,5 @@
<?php
/*
|--------------------------------------------------------------------------
| Create The Application

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-05d31f73.1ad3b9ab.css rel=prefetch><link href=/css/chunk-6ea47298.6166dab5.css rel=prefetch><link href=/js/chunk-00ae0766.d130b440.js rel=prefetch><link href=/js/chunk-05d31f73.406014ff.js rel=prefetch><link href=/js/chunk-07a274ec.55e1b3b0.js rel=prefetch><link href=/js/chunk-6ea47298.b6a301d0.js rel=prefetch><link href=/css/app.be09e36f.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.7d8543b1.js rel=preload as=script><link href=/js/chunk-vendors.f1169dcc.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.be09e36f.css rel=stylesheet></head><body><noscript><strong>很抱歉如果没有启用JavaScript程序不能正常工作若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.f1169dcc.js></script><script src=/js/app.7d8543b1.js></script></body></html>
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=\favicon.ico><script src=\config.js></script><title></title><link href=/css/chunk-27c12854.1756c258.css rel=prefetch><link href=/css/chunk-6ea47298.6166dab5.css rel=prefetch><link href=/js/chunk-00ae0766.d130b440.js rel=prefetch><link href=/js/chunk-07a274ec.55e1b3b0.js rel=prefetch><link href=/js/chunk-27c12854.f9bc5661.js rel=prefetch><link href=/js/chunk-6ea47298.b6a301d0.js rel=prefetch><link href=/css/app.be09e36f.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.34dc3d8c.js rel=preload as=script><link href=/js/chunk-vendors.f1169dcc.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.be09e36f.css rel=stylesheet></head><body><noscript><strong>很抱歉如果没有启用JavaScript程序不能正常工作若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.f1169dcc.js></script><script src=/js/app.34dc3d8c.js></script></body></html>