This commit is contained in:
邓皓元 2019-04-17 15:58:07 +08:00
parent 6262576421
commit aa0aef4f3e
17 changed files with 111 additions and 82 deletions

View File

@ -3,8 +3,6 @@ namespace App\Domains\Export\Http\Controllers;
use App\Core\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Storage;
use App\Domains\Export\Services\ExportService;
class ExportController extends Controller

View File

@ -146,6 +146,7 @@ class AddedOrderSync extends Command
->whereIn('account_no', array_keys($this->business_type))
->where('create_time', '>=', $starttime->timestamp)
->where('create_time', '<=', $endtime->timestamp)
->where('r_id', 112370)
->orderBy('create_time')->get()->collect()->toArray();
$array = [];

View File

@ -11,6 +11,7 @@ use Illuminate\Database\Eloquent\Builder;
use App\Domains\Stats\Services\OrderService;
use Dipper\Excel\Concerns\WithColumnFormatting;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use App\Domains\Virtual\Repositories\OrderCardPartitionRepository;
class OrderDetailExport extends AbstractExport implements FromQuery, WithHeadings, WithRows, WithColumnFormatting
{
@ -29,13 +30,11 @@ class OrderDetailExport extends AbstractExport implements FromQuery, WithHeading
*/
public function query()
{
if (!$class = OrderService::$classes[$this->conditions['type']]) {
if (!isset(self::$types[$this->conditions['type']])) {
throw new NotAllowedException('统计类型不存在');
}
$repository = app($class);
$builder = $repository->forceNoReset()->withConditions($this->conditions)->applyConditions();
$builder = app(OrderCardPartitionRepository::class)->forceNoReset()->withConditions($this->conditions)->applyConditions()->orderBy('sim');
return $builder;
}
@ -102,7 +101,7 @@ class OrderDetailExport extends AbstractExport implements FromQuery, WithHeading
*/
protected function tag()
{
if ((!$tag = self::$classes[get_class($this)]) || !self::$types[$this->conditions['type']]) {
if (!isset(self::$types[$this->conditions['type']])) {
throw new NotAllowedException('类型不允许');
}

View File

@ -2,11 +2,11 @@
namespace App\Domains\Stats\Http\Controllers;
use Illuminate\Http\Request;
use App\Exceptions\NotAllowedException;
use App\Domains\Stats\Exports\OrderExport;
use App\Domains\Stats\Services\OrderService;
use App\Domains\Export\Services\ExportService;
use App\Domains\Stats\Exports\OrderDetailExport;
use App\Domains\Virtual\Repositories\OrderCardPartitionRepository;
class OrderController extends Controller
{
@ -83,13 +83,7 @@ class OrderController extends Controller
$conditions = $this->request->except(['page', 'limit']);
$conditions['order_id'] = $this->request->ids('order_id');
if (!$class = OrderService::$classes[$conditions['type']]) {
throw new NotAllowedException('统计类型不存在');
}
$repository = app($class);
$total = $repository->withConditions($conditions)->applyConditions()->count();
$total = app(OrderCardPartitionRepository::class)->withConditions($conditions)->applyConditions()->count();
try {
$export = new OrderDetailExport($conditions);

View File

@ -26,7 +26,7 @@ class CardExport extends AbstractExport implements FromQuery, WithHeadings, With
public function query()
{
$this->conditions['type'] = 0;
$builder = app(OrderCardPartitionRepository::class)->forceNoReset()->withConditions($this->conditions)->applyConditions();
$builder = app(OrderCardPartitionRepository::class)->forceNoReset()->withConditions($this->conditions)->orderBy('sim')->applyConditions();
return $builder;
}

View File

@ -35,7 +35,7 @@ class FlowPoolExportDetailExport extends AbstractExport implements FromQuery, Wi
$table = app(FlowPoolMonth::class)->getTable() . '_' . $month->format('Ym');
return app(FlowPoolMonth::class)->setTable($table)->where('pool_id', $pool_id)->select(['package_id', 'sim', 'mebibyte']);
return app(FlowPoolMonth::class)->setTable($table)->where('pool_id', $pool_id)->select(['package_id', 'sim', 'mebibyte'])->orderBy('sim');
}
public function headings(): array

View File

@ -28,7 +28,7 @@ class OrderCardExport extends AbstractExport implements FromQuery, WithHeadings,
public function query()
{
$builder = app(OrderCardPartitionRepository::class)->with('order')->forceNoReset()->select(['sim', 'order_id', 'counts', 'refunded_at'])
->withConditions($this->conditions)->orderBy('order_id');
->withConditions($this->conditions)->orderBy('order_id')->orderBy('sim');
return $builder;
}

View File

@ -33,7 +33,8 @@ class OrderExport extends AbstractExport implements FromQuery, WithHeadings, Wit
public function query()
{
$builder = app(OrderRepository::class)->forceNoReset()->withConditions($this->conditions)->applyConditions()->orderBy('order_at', 'desc');
$builder = app(OrderRepository::class)->forceNoReset()->withConditions($this->conditions)->applyConditions()
->orderBy('order_at', 'desc');
return $builder;
}
@ -100,7 +101,7 @@ class OrderExport extends AbstractExport implements FromQuery, WithHeadings, Wit
CommonService::namePayChannel($item['pay_channel']),
"{$item['transaction_no']}\t",
$item['counts'],
sprintf('%.02f', $item['custom_price']/100),
sprintf('%.02f', $item['unit_price']*$item['counts']/100),
Carbon::parse($item['order_at'])->format('Y-m-d'),
];

View File

@ -103,12 +103,13 @@ INSERT INTO vd.cards (sim, imsi, iccid, carrier_operator, "type", virtual_activa
iccid,
CASE carrieroperator WHEN 10 THEN 0 WHEN 11 THEN 1 WHEN 12 THEN 2 ELSE 255 END AS carrier_operator,
CASE WHEN substr(card_number, 4, 1)::INT >= 5 THEN 1 ELSE 0 END AS "type",
CASE card_cycle_start::int WHEN 0 THEN NULL ELSE to_timestamp(card_cycle_start::int) END AS virtual_activated_at,
CASE custom_state WHEN 13 THEN to_timestamp(update_time) ELSE NULL END AS cancelled_at,
to_timestamp(create_time) as created_at,
to_timestamp(update_time) as updated_at
CASE valid_start_time WHEN '0' THEN NULL WHEN '' THEN NULL ELSE to_timestamp(valid_start_time::int) END AS virtual_activated_at,
CASE custom_state WHEN 13 THEN to_timestamp(ckb_custom.update_time) ELSE NULL END AS cancelled_at,
to_timestamp(ckb_custom.create_time) as created_at,
to_timestamp(ckb_custom.update_time) as updated_at
FROM
ckb_custom
LEFT JOIN vd.ckb_custom_handle_log ON ckb_custom.custom_no = ckb_custom_handle_log.custom_no AND ckb_custom_handle_log.type = 10
) ON CONFLICT (sim) DO UPDATE SET
virtual_activated_at=excluded.virtual_activated_at,
cancelled_at=excluded.cancelled_at;
@ -186,7 +187,7 @@ INSERT INTO vd.virtual_order_renewal_package_cards ("type", sim, order_id, compa
SELECT
vd_old_orders.order_type AS "type",
vd_old_orders.sim::BIGINT AS sim,
virtual_orders.ID AS order_id,
virtual_orders.id AS order_id,
vd_old_orders.company_id,
vd_old_orders.package_id,
vd_old_orders.counts,
@ -207,7 +208,7 @@ INSERT INTO vd.virtual_order_flows_package_cards ("type", sim, order_id, company
SELECT
vd_old_orders.order_type AS "type",
vd_old_orders.sim::BIGINT AS sim,
virtual_orders.ID AS order_id,
virtual_orders.id AS order_id,
vd_old_orders.company_id,
vd_old_orders.package_id,
vd_old_orders.counts,
@ -222,4 +223,3 @@ INSERT INTO vd.virtual_order_flows_package_cards ("type", sim, order_id, company
WHERE
vd_old_orders.order_type = 3
) ON CONFLICT (sim, order_id, COALESCE(deleted_at::TIMESTAMP, '1970-01-01 08:00:00'::TIMESTAMP)) DO UPDATE SET counts = excluded.counts, service_start_at = excluded.service_start_at, service_end_at = excluded.service_end_at;

View File

@ -43,12 +43,12 @@ export default {
{
title: '企业名称',
key: 'company_name',
width: 300
minWidth: 300
},
{
title: '套餐名称',
key: 'package_name',
width: 110
minWidth: 110
},
{
title: '状态',
@ -75,6 +75,7 @@ export default {
{
title: '操作',
key: 'action',
width: 110,
render: (h, {
row,
column,

View File

@ -6,7 +6,7 @@
@on-visible-change="visibleChange"
v-model="my_show"
width="1440"
:z-index="source === 0 ? 1000 : 500"
:z-index="source === 0 ? 400 : 300"
>
<div class="page-handle-wrap">
<div class="search-wrap">

View File

@ -6,7 +6,7 @@
@on-visible-change="visibleChange"
v-model="my_show"
width="500"
:mask-style="{ 'z-index': source === 1 ? 2000 : 1500}"
:mask-style="{ 'z-index': source === 1 ? 1000 : 500}"
>
<div v-if="Object.keys(order_group).length" class="order-group-wrap">
<ul>
@ -58,7 +58,7 @@
<li class="ui-list">
<div class="ui-list-title">运营商:</div>
<div class="ui-list-content">
<Select v-model="params.carrier_operator" @on-change="handleChange(1)">
<Select v-model="params.carrier_operator" @on-change="handleChangeCarrierOperator">
<Option :value="0">联通</Option>
<Option :value="1">移动</Option>
<Option :value="2">电信</Option>
@ -71,7 +71,7 @@
<span class="title-require">*</span>选择套餐:
</div>
<div class="ui-list-content">
<Select filterable v-model.trim="params.package_id" @on-change="handleChange(2)">
<Select filterable v-model.trim="params.package_id" @on-change="handleChangePackage">
<Option
:key="item.id"
:value="item.id"

View File

@ -31,6 +31,7 @@ export default {
isUpdate: false,
loading: false,
companies: [],
packages: [],
completePackagesFilter: [],
transaction_nos: [],
params: {
@ -66,33 +67,58 @@ export default {
show(bool) {
this.my_show = bool;
if (bool) {
this.initCompleteCompanies().then(companies => {
this.companies = companies.filter(item => {
return item.status === 0;
});
});
this.initData().then(() => {
this.init();
this.init();
if (this.data) {
for (let k in this.data) {
if (k in this.params) {
this.params[k] = this.data[k];
if (this.data) {
for (let k in this.data) {
if (k in this.params) {
this.params[k] = this.data[k];
}
}
}
}
});
}
},
counts(val) {
if (this.my_show && this.source === 0 && this.type === 0 && val) {
this.init();
this.initData().then(() => {
this.init();
});
}
}
},
methods: {
init() {
this.handleChange(0);
initData() {
return new Promise((resolve, reject) => {
this.initCompleteCompanies()
.then(companies => {
this.companies = companies.filter(item => {
return item.status === 0;
});
})
.catch(res => {
reject(res);
});
let packageType = this.type === 1 ? 0 : this.type;
this.initCompletePackages(packageType)
.then(packages => {
this.packages = packages.filter(item => {
return item.status === 0;
});
this.completePackagesFilter = this.packages;
resolve();
})
.catch(res => {
reject(res);
});
});
},
init() {
if (this.selectedMapped.length && !Object.keys(this.order_group).length) {
this.setParamsByReal(this.selected);
this.params.counts = this.counts;
@ -100,7 +126,30 @@ export default {
if (Object.keys(this.order_group).length) {
let key = Object.keys(this.order_group)[0];
this.selectGroup(this.order_group[key], key);
this.$nextTick(() => {
this.selectGroup(this.order_group[key], key);
});
}
},
handleChangePackage(value) {
this.params.package_id = value;
let selectPackage = this.packages.find(item => {
return item.id === this.params.package_id;
});
if (selectPackage) {
this.params.carrier_operator = selectPackage.carrier_operator;
}
},
handleChangeCarrierOperator(value) {
this.params.carrier_operator = value;
if (typeof this.params.carrier_operator === "number") {
this.params.package_id = "";
this.completePackagesFilter = this.packages.filter(item => {
return item.carrier_operator === this.params.carrier_operator;
});
}
},
ok() {
@ -247,36 +296,6 @@ export default {
this.$store.dispatch("initOrder");
}
},
handleChange(type) {
let packageType = this.type === 1 ? 0 : this.type;
this.initCompletePackages(packageType).then(packages => {
packages = packages.filter(item => {
return item.status === 0;
});
if (type === 1) {
this.params.package_id = "";
}
if (type === 2) {
let selectPackage = packages.find(item => {
return item.id === this.params.package_id;
});
if (selectPackage) {
this.params.carrier_operator = selectPackage.carrier_operator;
}
}
if (typeof this.params.carrier_operator === "number") {
packages = packages.filter(item => {
return item.carrier_operator === this.params.carrier_operator;
});
}
this.completePackagesFilter = packages;
});
},
cards() {
if (this.params.company_id) {
this.$store.commit("SET_RELATION_OBJ", {
@ -311,9 +330,8 @@ export default {
if ([0, 1].indexOf(this.type)) {
this.params.package_id = item[0].package_id;
this.handleChangePackage(this.params.package_id);
}
this.handleChange(2);
},
setParamsByReal(array) {
let tmp = array

File diff suppressed because one or more lines are too long

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-23278e16.e2100cf6.css rel=prefetch><link href=/css/chunk-996b1e80.5cadf3d0.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-23278e16.cc10e924.js rel=prefetch><link href=/js/chunk-996b1e80.92847c4e.js rel=prefetch><link href=/css/app.8e379248.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.f9f71f7a.js rel=preload as=script><link href=/js/chunk-vendors.ed6443e8.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.8e379248.css rel=stylesheet></head><body><noscript><strong>很抱歉如果没有启用JavaScript程序不能正常工作若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ed6443e8.js></script><script src=/js/app.f9f71f7a.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-00bf5f96.b87abb00.css rel=prefetch><link href=/css/chunk-996b1e80.5cadf3d0.css rel=prefetch><link href=/js/chunk-00ae0766.d130b440.js rel=prefetch><link href=/js/chunk-00bf5f96.60fa58d1.js rel=prefetch><link href=/js/chunk-07a274ec.55e1b3b0.js rel=prefetch><link href=/js/chunk-996b1e80.92847c4e.js rel=prefetch><link href=/css/app.8e379248.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.2c6fccfd.js rel=preload as=script><link href=/js/chunk-vendors.ed6443e8.js rel=preload as=script><link href=/css/chunk-vendors.3c3b2e85.css rel=stylesheet><link href=/css/app.8e379248.css rel=stylesheet></head><body><noscript><strong>很抱歉如果没有启用JavaScript程序不能正常工作若要继续使用请启用它。</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ed6443e8.js></script><script src=/js/app.2c6fccfd.js></script></body></html>