排单修改
This commit is contained in:
parent
b36ec54841
commit
6bc496da55
@ -45,14 +45,26 @@ class BootstrapController extends Controller
|
||||
*/
|
||||
public function products(ProductService $productService)
|
||||
{
|
||||
$conditions = [
|
||||
'company_id' => $this->account->company_id,
|
||||
'carrier_operator' => $this->request->get('carrier_operator'),
|
||||
];
|
||||
$conditions = $this->request->all();
|
||||
|
||||
$conditions['company_id'] = $this->account->company_id;
|
||||
|
||||
$conditions['type'] = $conditions['type'] ? ($conditions['type'] == 1 ? 0 : $conditions['type']) : 0;
|
||||
|
||||
$res = $productService->index($conditions);
|
||||
|
||||
$res = $res->where('status', 0);
|
||||
$res = $res->where('status', 0)->transform(function ($item) {
|
||||
return [
|
||||
'id' => $item->id,
|
||||
'sn' => $item->sn,
|
||||
'name' => $item->name,
|
||||
'carrier_operator' => $item->carrier_operator,
|
||||
'carrier_operator_name' => $item->carrier_operator_name,
|
||||
'package_id' => $item->package_id,
|
||||
'package_name' => $item->package['name'] ?? '',
|
||||
'price' => $item->price
|
||||
];
|
||||
})->values();
|
||||
|
||||
return res($res, '企业套餐列表', 201);
|
||||
}
|
||||
|
45
app/Domains/Company/Http/Controllers/CardController.php
Normal file
45
app/Domains/Company/Http/Controllers/CardController.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
namespace App\Domains\Company\Http\Controllers;
|
||||
|
||||
use App\Core\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Carbon;
|
||||
use App\Domains\Virtual\Repositories\OrderCardPartitionRepository;
|
||||
|
||||
class CardController extends Controller
|
||||
{
|
||||
protected $request;
|
||||
protected $account;
|
||||
protected $orderCardPartitionRepository;
|
||||
|
||||
/**
|
||||
* 构造函数,自动注入.
|
||||
*/
|
||||
public function __construct(Request $request, OrderCardPartitionRepository $orderCardPartitionRepository)
|
||||
{
|
||||
$this->request = $request;
|
||||
$this->account = $request->user('company');
|
||||
$this->orderCardPartitionRepository = $orderCardPartitionRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$conditions = $this->request->all();
|
||||
$conditions['company_id'] = $this->account->company_id;
|
||||
$conditions['type'] = [0, 1];
|
||||
$limit = $conditions['limit'] ?? 20;
|
||||
|
||||
$cards = $this->orderCardPartitionRepository->selectRaw('distinct on (sim) sim')->withConditions($conditions)->paginate($limit);
|
||||
|
||||
$services = $this->orderCardPartitionRepository->select('MIN(service_start_at),MAX(service_end_at)')
|
||||
->withConditions(['sim' => $cards->pluck('sim')->toArray()])->groupBy('sim')->get();
|
||||
|
||||
$time = Carbon::now()->format('Y-m-d H:i:s');
|
||||
|
||||
$packages = $this->orderCardPartitionRepository->selectRaw('distinct on (sim) package_id')
|
||||
->where('service_start_at', '<=', $time);
|
||||
}
|
||||
}
|
@ -61,8 +61,16 @@ class ProductSync extends Command
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
Product::upsert($products, ['sn', 'deleted_at'], true);
|
||||
|
||||
$subSql = 'SELECT DISTINCT ON (company_id, package_id) id FROM virtual_products ORDER BY company_id, package_id, updated_at DESC';
|
||||
|
||||
Product::whereRaw("id not in ($subSql)")->update(['status' => 1]);
|
||||
|
||||
app(ProductRepository::class)->forgetCached();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -82,6 +82,22 @@ trait OrderCardConcern
|
||||
$query->where('created_at', '<=', Carbon::parse($conditions['endtime']));
|
||||
}
|
||||
|
||||
if (isset($conditions['service_start_starttime'])) {
|
||||
$query->where('created_at', '>=', Carbon::parse($conditions['service_start_starttime']));
|
||||
}
|
||||
|
||||
if (isset($conditions['service_start_endtime'])) {
|
||||
$query->where('created_at', '<=', Carbon::parse($conditions['service_start_endtime']));
|
||||
}
|
||||
|
||||
if (isset($conditions['service_end_starttime'])) {
|
||||
$query->where('created_at', '>=', Carbon::parse($conditions['service_end_starttime']));
|
||||
}
|
||||
|
||||
if (isset($conditions['service_end_endtime'])) {
|
||||
$query->where('created_at', '<=', Carbon::parse($conditions['service_end_endtime']));
|
||||
}
|
||||
|
||||
if (isset($conditions['month'])) {
|
||||
$time = Carbon::parse($conditions['month'])->format('Y-m-d H:i:s');
|
||||
$query->where(function ($subQuery) use ($time) {
|
||||
|
@ -324,23 +324,26 @@ class OrderService extends Service
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function reset($id)
|
||||
public function reset($ids)
|
||||
{
|
||||
if (!$node = $this->orderRepository->find($id)) {
|
||||
throw new NotExistException('订单不存在或已删除');
|
||||
}
|
||||
DB::transaction(function () use ($ids) {
|
||||
foreach ($ids as $id) {
|
||||
$id = intval($id);
|
||||
|
||||
DB::transaction(function () use ($id, $node) {
|
||||
if ($node->type === 0) {
|
||||
// 转销售重置
|
||||
$sql = 'UPDATE virtual_order_cards_partition SET sim=original_sim,original_sim=0
|
||||
WHERE original_sim IN (
|
||||
SELECT DISTINCT SIM FROM virtual_order_cards_partition WHERE type=0 AND order_id = ?
|
||||
)';
|
||||
DB::statement($sql, $id);
|
||||
if (!$node = $this->orderRepository->find($id)) {
|
||||
throw new NotExistException('订单不存在或已删除');
|
||||
}
|
||||
|
||||
if ($node->type === 0) {
|
||||
// 转销售重置
|
||||
$sql = 'UPDATE virtual_order_cards_partition SET sim=original_sim,original_sim=0
|
||||
WHERE original_sim IN (
|
||||
SELECT DISTINCT SIM FROM virtual_order_cards_partition WHERE type=0 AND order_id = ?
|
||||
)';
|
||||
DB::statement($sql, [$id]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->orderCardPartitionRepository->whereIn('order_id', $ids)->delete();
|
||||
app(RealOrderCardPartitionRepository::class)->whereIn('virtual_order_id', $ids)->update(['virtual_order_id' => 0]);
|
||||
});
|
||||
|
@ -110,13 +110,6 @@
|
||||
</Select>
|
||||
</li>
|
||||
|
||||
<li class="handle-item w-250">
|
||||
<Select clearable placeholder="作废状态" v-model="params.trashed">
|
||||
<Option :value="'without'">正常的</Option>
|
||||
<Option :value="'only'">已作废</Option>
|
||||
</Select>
|
||||
</li>
|
||||
|
||||
<li class="f-r">
|
||||
<div class="handle-item">
|
||||
<Button @click="index(1)" ghost type="primary">立即搜索</Button>
|
||||
|
@ -72,9 +72,14 @@
|
||||
>{{ item.name }}</Option>
|
||||
</AutoComplete>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<ul class="handle-wraper">
|
||||
<li class="handle-item w-250">
|
||||
<Select clearable placeholder="状态" v-model="params.status">
|
||||
<Option :value="0">启用</Option>
|
||||
<Option :value="1">禁用</Option>
|
||||
</Select>
|
||||
</li>
|
||||
|
||||
<li class="f-r">
|
||||
<div class="handle-item">
|
||||
<Button @click="index()" ghost type="primary">立即搜索</Button>
|
||||
|
@ -11,7 +11,8 @@ export default {
|
||||
company_id: '',
|
||||
carrier_operator: '',
|
||||
name: '',
|
||||
package_name: ''
|
||||
package_name: '',
|
||||
status: ''
|
||||
},
|
||||
editObj: {
|
||||
show: false,
|
||||
|
2
public/css/chunk-4020ddf0.e734d292.css
Normal file
2
public/css/chunk-4020ddf0.e734d292.css
Normal file
File diff suppressed because one or more lines are too long
2
public/js/app.8e8f3cf6.js
Normal file
2
public/js/app.8e8f3cf6.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/app.8e8f3cf6.js.map
Normal file
1
public/js/app.8e8f3cf6.js.map
Normal file
File diff suppressed because one or more lines are too long
2
public/js/app.babb0a64.js
Normal file
2
public/js/app.babb0a64.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/app.babb0a64.js.map
Normal file
1
public/js/app.babb0a64.js.map
Normal file
File diff suppressed because one or more lines are too long
2
public/js/chunk-4020ddf0.45571339.js
Normal file
2
public/js/chunk-4020ddf0.45571339.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/chunk-4020ddf0.45571339.js.map
Normal file
1
public/js/chunk-4020ddf0.45571339.js.map
Normal file
File diff suppressed because one or more lines are too long
2
public/js/chunk-4020ddf0.d5ad4039.js
Normal file
2
public/js/chunk-4020ddf0.d5ad4039.js
Normal file
File diff suppressed because one or more lines are too long
1
public/js/chunk-4020ddf0.d5ad4039.js.map
Normal file
1
public/js/chunk-4020ddf0.d5ad4039.js.map
Normal file
File diff suppressed because one or more lines are too long
@ -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-3e2248ef.ced8e72d.css rel=prefetch><link href=/css/chunk-ba0f074c.34c0cb30.css rel=prefetch><link href=/js/chunk-00ae0766.3874cd10.js rel=prefetch><link href=/js/chunk-07a274ec.c3ad5dec.js rel=prefetch><link href=/js/chunk-3e2248ef.43fc323a.js rel=prefetch><link href=/js/chunk-ba0f074c.129fa22a.js rel=prefetch><link href=/css/app.d71a8195.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.31440689.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.d71a8195.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.31440689.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-3e2248ef.ced8e72d.css rel=prefetch><link href=/css/chunk-4020ddf0.e734d292.css rel=prefetch><link href=/js/chunk-00ae0766.3874cd10.js rel=prefetch><link href=/js/chunk-07a274ec.c3ad5dec.js rel=prefetch><link href=/js/chunk-3e2248ef.43fc323a.js rel=prefetch><link href=/js/chunk-4020ddf0.d5ad4039.js rel=prefetch><link href=/css/app.d71a8195.css rel=preload as=style><link href=/css/chunk-vendors.3c3b2e85.css rel=preload as=style><link href=/js/app.8e8f3cf6.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.d71a8195.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.8e8f3cf6.js></script></body></html>
|
@ -1,10 +1,9 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use App\Models\Virtual\Product;
|
||||
|
||||
require_once realpath(dirname(__FILE__) . '/TestCase.php');
|
||||
|
||||
Schema::table("virtual_orders", function (Blueprint $table) {
|
||||
$table->tinyInteger('sign')->default(0)->comment('特殊标记 0:非特殊 -1:不在VD上的改企业转销售 -2:改企业的转销售');;
|
||||
});
|
||||
$subSql = 'SELECT DISTINCT ON (company_id, package_id) id FROM virtual_products ORDER BY company_id, package_id, updated_at DESC';
|
||||
|
||||
Product::whereRaw("id not in ($subSql)")->update(['status' => 1]);
|
||||
|
Loading…
x
Reference in New Issue
Block a user