This commit is contained in:
邓皓元 2019-08-08 18:05:02 +08:00
parent 3ee06ecfce
commit fd2bb26303
17 changed files with 143 additions and 68 deletions

View File

@ -43,7 +43,7 @@ class AddedOrderSync extends Command
$cards = $this->getOrderItems($orders);
$orders = $this->transformer($orders, $cards);
$this->line('插入订单数据,条数:'.count($orders));
$this->line('插入订单数据,条数:' . count($orders));
foreach (array_chunk($orders, $this->chunks) as $data) {
$this->getOutput()->write('.');
Order::upsert($orders, ['sn', 'deleted_at']);
@ -76,7 +76,7 @@ class AddedOrderSync extends Command
];
}
$this->line('插入订单关联数据,条数:'.count(array_collapse($dataOrderCards)));
$this->line('插入订单关联数据,条数:' . count(array_collapse($dataOrderCards)));
$simArray = [];
@ -128,7 +128,7 @@ class AddedOrderSync extends Command
$only = ['company_id', 'package_id', 'counts', 'unit_price'];
DB::table($table)->upsert($data, ['sim', 'order_id', 'refunded_at', 'deleted_at'], $only);
DB::table($table)->upsert($data, ['sim', 'order_id'], $only);
}
}
@ -157,11 +157,11 @@ class AddedOrderSync extends Command
];
$orders = DB::connection('real')->table('jxc_custom_order')->select($select)->whereIn('status', [3, 7, 8])
->whereIn('custom_no', $this->companies->keys())
->whereIn('account_no', array_keys($this->business_type))
->where('create_time', '>=', $starttime->timestamp)
->where('create_time', '<=', $endtime->timestamp)
->orderBy('create_time')->get()->collect()->toArray();
->whereIn('custom_no', $this->companies->keys())
->whereIn('account_no', array_keys($this->business_type))
->where('create_time', '>=', $starttime->timestamp)
->where('create_time', '<=', $endtime->timestamp)
->orderBy('create_time')->get()->collect()->toArray();
$array = [];
@ -206,7 +206,7 @@ class AddedOrderSync extends Command
$order = $orders[$item['sn']];
$item['company_id'] = $order['company_id'] ?? 0;
$item['package_id'] = $this->packages[$item['package_sn']]['id'] ?? 0;
$item['unit_price'] = intval($item['unit_price'] * 100) ;
$item['unit_price'] = intval($item['unit_price'] * 100);
$item['created_at'] = $order['created_at'];
$item['updated_at'] = $order['updated_at'];
$item['deleted_at'] = $order['deleted_at'];
@ -236,6 +236,7 @@ class AddedOrderSync extends Command
}
$orderPackages[$sn][$package_id] = [
'type' => $values[0]['type'],
'unit_price' => $values[0]['unit_price'],
'counts' => array_sum(array_pluck($values, 'counts')),
'total_price' => $values[0]['unit_price'] * array_sum(array_pluck($values, 'counts')),
@ -254,6 +255,7 @@ class AddedOrderSync extends Command
foreach ($packages as $package_id => $array) {
$order = $item;
$order['type'] = $array['type'];
$order['package_id'] = $package_id;
$order['sn'] = $item['sn'] . $package_id;
$order['counts'] = $array['counts'];

View File

@ -1,4 +1,5 @@
<?php
namespace App\Domains\Real\Services;
use App\Dicts;
@ -61,8 +62,8 @@ class OrderService extends Service
$item->package_name = $item->package['name'];
$item->carrier_operator = $item->package['carrier_operator'];
$item->carrier_operator_name = $carrierOperators[$item->carrier_operator];
$item->unit_price = sprintf('%.02f', $item->unit_price/100);
$item->total_price = sprintf('%.02f', $item->total_price/100);
$item->unit_price = sprintf('%.02f', $item->unit_price / 100);
$item->total_price = sprintf('%.02f', $item->total_price / 100);
$item->shipments = $cards[$item->id]['shipments'] ?? 0;
$item->counts = $cards[$item->id]['counts'] ?? 0;
$item->refunds = $cards[$item->id]['refunds'] ?? 0;
@ -109,7 +110,7 @@ class OrderService extends Service
$packageService = app(PackageService::class);
foreach ($cards as &$item) {
$item['sim'] = (string)$item['sim'];
$item['sim'] = (string) $item['sim'];
$item['company_id'] = $item['company_id'] ?? 0;
$item['package_id'] = $item['package_id'] ?? 0;

View File

@ -12,6 +12,7 @@ use App\Domains\Stats\Services\OrderService;
use Dipper\Excel\Concerns\WithColumnFormatting;
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
use App\Domains\Virtual\Repositories\OrderCardPartitionRepository;
use App\Domains\Virtual\Services\PackageService;
class OrderDetailExport extends AbstractExport implements FromQuery, WithHeadings, WithRows, WithColumnFormatting
{
@ -41,7 +42,7 @@ class OrderDetailExport extends AbstractExport implements FromQuery, WithHeading
public function headings(): array
{
return [
$headings = [
'SIM',
'企业名称',
'套餐名称',
@ -51,6 +52,12 @@ class OrderDetailExport extends AbstractExport implements FromQuery, WithHeading
'数量',
'订单时间',
];
if (in_array($this->conditions['type'], [2, 3])) {
array_splice($headings, 2, 0, '基础套餐');
}
return $headings;
}
@ -65,8 +72,12 @@ class OrderDetailExport extends AbstractExport implements FromQuery, WithHeading
$array = [];
if (in_array($this->conditions['type'], [2, 3])) {
$basePackages = app(OrderCardPartitionRepository::class)->getCardBasePackages(collect($rows)->pluck('sim')->toArray())->keyBy('sim')->toArray();
}
foreach ($rows as $item) {
$array[] = [
$data = [
$item['sim'],
$item['company_name'],
$item['package_name'],
@ -76,6 +87,12 @@ class OrderDetailExport extends AbstractExport implements FromQuery, WithHeading
$item['counts'],
$item['order_at'],
];
if (in_array($this->conditions['type'], [2, 3])) {
array_splice($data, 2, 0, PackageService::load($basePackages[$item['sim']]['package_id'])['name']);
}
$array[] = $data;
}
return $array;

View File

@ -49,7 +49,7 @@ class OrderExport extends AbstractExport implements FromCollection, WithHeadings
public function headings(): array
{
return [
$headings = [
'企业名称',
'套餐名称',
'支付方式',
@ -58,6 +58,8 @@ class OrderExport extends AbstractExport implements FromCollection, WithHeadings
'数量',
'总金额',
];
return $headings;
}
/**

View File

@ -1,6 +1,8 @@
<?php
namespace App\Domains\Stats\Services;
use App\Dicts;
use App\Core\Service;
use Illuminate\Support\Facades\DB;
use App\Exceptions\NotAllowedException;
@ -88,8 +90,8 @@ class OrderService extends Service
}
$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->unit_price * $item->counts / 100);
$item->unit_price = sprintf('%.02f', $item->unit_price / 100);
$item->pay_channel_name = CommonService::namePayChannel($item->pay_channel);
});
@ -124,16 +126,16 @@ class OrderService extends Service
$orders = app(OrderRepository::class)->withTrashed()
->select(['id', 'unit_price', 'pay_channel', 'order_at'])
->withConditions(['id' => array_unique(array_pluck($cards, 'order_id'))])->get()->keyBy('id')->toArray();
$carrierOperators = app(Dicts::class)->get('carrier_operator');
$cards->map(function ($item) use ($companies, $packages, $carrierOperators, $orders) {
$package = $packages[$item->package_id];
$order = $orders[$item->order_id];
$item->company_name = $companies[$item->company_id];
$item->package_name = $package['name'];
$item->carrier_operator_name = $carrierOperators[$package['carrier_operator']];
$item->service_months = $package['service_months'];
$item->unit_price = sprintf('%.02f', $order['unit_price']/100);
$item->unit_price = sprintf('%.02f', $order['unit_price'] / 100);
$item->pay_channel_name = CommonService::namePayChannel($order['pay_channel']);
$item->order_at = $order['order_at'];
});

View File

@ -28,6 +28,7 @@ class FlowPoolExport extends AbstractExport implements FromCollection, WithHeadi
'name' => $item->name,
'carrier_operator_name' => $item->carrier_operator_name,
'company_name' => $item->company_name,
'total_cards' => $item->total_cards,
'minimum_flows' => $item->minimum_flows,
'excess_flows' => $item->excess_flows,
'minimum_price' => $item->minimum_price,
@ -42,6 +43,7 @@ class FlowPoolExport extends AbstractExport implements FromCollection, WithHeadi
'',
'',
'',
array_sum($list->pluck('total_cards')->toArray()) ?: 0,
'',
'',
'',
@ -60,6 +62,7 @@ class FlowPoolExport extends AbstractExport implements FromCollection, WithHeadi
'名称',
'运营商',
'客户名称',
'流量卡数',
'保底流量',
'超出流量',
'保底收入(元)',

View File

@ -1,4 +1,5 @@
<?php
namespace App\Domains\Virtual\Http\Controllers;
use Carbon\Carbon;

View File

@ -7,6 +7,15 @@ use App\Models\Virtual\OrderCardPartition;
trait OrderCardConcern
{
public function getCardBasePackages(array $simArray)
{
return $this->model->selectRaw('DISTINCT ON (sim) sim, package_id')
->whereIn('type', [0, 1])
->whereIn('sim', $simArray)
->orderBy('sim')
->orderBy('created_at', 'desc')->get();
}
/**
* 查询条件
*

View File

@ -1,4 +1,5 @@
<?php
namespace App\Domains\Virtual\Services;
use App\Dicts;
@ -42,7 +43,7 @@ class FlowPoolService extends Service
RealFlowPoolRepository $realFlowPoolRepository,
FlowPoolRepository $flowPoolRepository,
FlowPoolSettingRepository $flowPoolSettingRepository
) {
) {
$this->realFlowPoolRepository = $realFlowPoolRepository;
$this->flowPoolRepository = $flowPoolRepository;
$this->flowPoolSettingRepository = $flowPoolSettingRepository;
@ -94,7 +95,7 @@ class FlowPoolService extends Service
if (isset($array[$value])) {
array_push($array[$value], $item['company_id']);
} else {
$array[$value] =[$item['company_id']];
$array[$value] = [$item['company_id']];
}
}
}
@ -130,6 +131,33 @@ class FlowPoolService extends Service
$flows = collect($flows)->collect()->keyBy('pool_id')->toArray();
// 查询卡量
$company_ids = $flowPools->pluck('company_id')->toArray();
$package_ids = $flowPools->pluck('package_ids')->collapse()->unique()->toArray();
$conditions = [
'type' => [0, 1, 2],
'month' => $month,
'company_id' => $company_ids,
'package_id' => $package_ids,
'unit_price' => 0
];
$cards = app(OrderCardPartitionRepository::class)->select([
DB::raw("concat(company_id, '_', package_id) as index"),
DB::raw('count(distinct sim) as total'),
])->withConditions($conditions)->groupBy(['company_id', 'package_id'])->get()->pluck('total', 'index');
$flowPools->map(function ($flowPool) use ($cards) {
$total_cards = 0;
foreach ($flowPool->package_ids as $package_id) {
$index = $flowPool->company_id . '_' . $package_id;
$total_cards += $cards[$index] ?? 0;
}
$flowPool->total_cards = $total_cards;
});
// 流量统计
$flowPools->map(function ($flowPool) use ($flows) {
$flowArry = $flows[$flowPool->id];
@ -335,7 +363,7 @@ class FlowPoolService extends Service
if ($key) {
$this->flowPoolSettingRepository->create($create);
} else {
$node =$this->flowPoolSettingRepository->create($create);
$node = $this->flowPoolSettingRepository->create($create);
}
}
});
@ -480,7 +508,7 @@ class FlowPoolService extends Service
$itemMebibyte = array_sum(array_pluck($dataItems, 'mebibyte'));
if ($itemMebibyte) {
$k = $flows/$itemMebibyte;
$k = $flows / $itemMebibyte;
foreach ($dataItems as &$value) {
$value['mebibyte'] = round($value['mebibyte'] * $k, 2);
@ -594,7 +622,7 @@ class FlowPoolService extends Service
'package_id' => $value,
'package_name' => $package['name'],
'carrier_operator' => $package['carrier_operator'],
];
];
}
$item->packages = $packages;
@ -656,12 +684,12 @@ class FlowPoolService extends Service
$settings = $item->settings;
foreach ($settings as &$setting) {
$setting['gradient_price'] = sprintf('%.02f', $setting['gradient_price']/100);
$setting['gradient_price'] = sprintf('%.02f', $setting['gradient_price'] / 100);
$setting['gradient'] = sprintf('%.02f', $setting['gradient']);
$minimum_settings = $setting['minimum_settings'] ?? [];
foreach ($minimum_settings as &$minimum_setting) {
$minimum_setting['price'] = sprintf('%.02f', $minimum_setting['price']/100);
$minimum_setting['price'] = sprintf('%.02f', $minimum_setting['price'] / 100);
$minimum_setting['flows'] = floatval($minimum_setting['flows']);
}

View File

@ -101,6 +101,11 @@ export default {
key: "company_name",
width: 300
},
{
title: "流量卡数",
key: "total_cards",
width: 150
},
{
title: "保底流量",
key: "minimum_flows",
@ -346,7 +351,7 @@ export default {
let array = list_data.data;
array.push({
id: '总计',
id: "总计",
members: sumBy(list_data.data, "members"),
total_price: sumBy(list_data.data, "total_price")
});

View File

@ -5,7 +5,7 @@
:title="'选择流量卡'"
@on-visible-change="visibleChange"
v-model="my_show"
width="1440"
fullscreen
:z-index="source === 0 ? 400 : 300"
>
<div class="page-handle-wrap">
@ -98,7 +98,7 @@
</li>
<li class="handle-item w-200">
<Input placeholder="SIM" type="textarea" v-model="params.sim"/>
<Input placeholder="SIM" type="textarea" v-model="params.sim" />
</li>
<li class="f-r">
@ -221,10 +221,6 @@
<script src="./js/cards.js"></script>
<style scoped>
>>> .ivu-modal {
top: 50px;
}
>>> .ivu-table {
font-size: 12px;
}

View File

@ -111,6 +111,21 @@ export default {
let col = [];
col.push(
h("Col", { props: { span: 8 }, class: [] }, "订单ID: " + row.id)
);
col.push(
h(
"Col",
{ props: { span: 8 }, class: [] },
"订单类型: " + this.orderTypes[context.row.type]
)
);
html.push(h("Row", { class: [] }, col));
col = [];
col.push(
h("Col", { props: { span: 8 }, class: [] }, "订单编号: " + row.sn)
);
@ -228,20 +243,6 @@ export default {
});
}
},
{
title: "ID",
key: "id",
width: 80,
sortable: true
},
{
title: "订单类型",
key: "",
width: 90,
render: (h, context) => {
return h("span", this.orderTypes[context.row.type]);
}
},
{
title: "企业名称",
key: "company_name",
@ -259,11 +260,6 @@ export default {
width: 150,
sortable: true
},
{
title: "支付方式",
key: "pay_channel_name",
width: 90
},
{
title: "可用量",
key: "",
@ -299,6 +295,11 @@ export default {
);
}
},
{
title: "支付方式",
key: "pay_channel_name",
width: 90
},
{
title: "所需卡量",
key: "",
@ -309,8 +310,8 @@ export default {
let value = select.length
? select.reduce((acc, cur) => {
return acc + cur.counts;
}, 0)
return acc + cur.counts;
}, 0)
: 0;
return h("InputNumber", {

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-058111f8.53f21a89.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-058111f8.e043dbc1.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.f774c5c0.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.f774c5c0.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-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.bd1096f5.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.943d332c.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.943d332c.js></script></body></html>

File diff suppressed because one or more lines are too long