real_company_id

This commit is contained in:
邓皓元 2019-03-07 17:29:52 +08:00
parent 86e7f25166
commit 24d92d01e5
5 changed files with 9 additions and 5 deletions

View File

@ -32,6 +32,7 @@ class MongoSync extends Command
if ($total) {
Artisan::call('real:sync-bloc');
Artisan::call('real:sync-company');
}
$page = 2;

View File

@ -14,6 +14,7 @@ use Dipper\Foundation\Bus\Dispatchable;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Domains\Card\Repositories\BlocRepository;
use App\Domains\Card\Repositories\CardRepository;
use App\Domains\Real\Repositories\CompanyRepository;
use App\Domains\Virtual\Repositories\OrderCardPartitionRepository;
class MongoSyncJob implements ShouldQueue
@ -60,6 +61,7 @@ class MongoSyncJob implements ShouldQueue
return ;
}
$companies = app(CompanyRepository::class)->withTrashed()->get()->keyBy('sn');
$blocs = app(BlocRepository::class)->withTrashed()->get()->pluck('id', 'sn')->toArray();
$values = [];
@ -80,7 +82,7 @@ class MongoSyncJob implements ShouldQueue
'carrier_operator' => self::$carrierOperators[$value['oType']] ?? 255,
'activated_at' => $activated_at,
'virtual_activated_at' => $activated_at,
'order_status' => intval(!empty($value['bNo'])),
'real_company_id' => empty($value['bNo']) ? -1 : ($companies[empty($value['bNo'])]['id'] ?? 0),
'created_at' => $value['sDate'] ? $value['sDate']->toDateTime()->format('Y-m-d H:i:s') : null,
'updated_at' => date('Y-m-d H:i:s'),
];
@ -93,7 +95,7 @@ class MongoSyncJob implements ShouldQueue
$sql .= ' on conflict (sim) do update set
activated_at=excluded.activated_at,
virtual_activated_at=COALESCE(cards.virtual_activated_at, excluded.activated_at),
order_status=excluded.order_status';
real_company_id=excluded.real_company_id';
$builder->connection->insert($sql, Arr::flatten($values, 1));

View File

@ -67,7 +67,7 @@ class OrderService extends Service
$orderIds = $cards->pluck('virtual_order_id')->unique()->toArray();
$virtualOrders = app(VirtualOrderRepository::class)
$virtualOrders = app(VirtualOrderRepository::class)->withTrashed()
->withConditions(['id' => $orderIds])->get()->keyBy('id');
$cards->map(function ($item) use ($virtualOrders) {

View File

@ -26,7 +26,7 @@ class CreateCardsTable extends Migration
$table->timestamp('activated_at')->nullable()->comment('激活时间');
$table->timestamp('virtual_activated_at')->nullable()->comment('虚拟激活时间');
$table->tinyInteger('type')->unsigned()->default(0)->comment('类型(0:真实卡 1:虚拟卡 2:未知卡)');
$table->tinyInteger('order_status')->unsigned()->default(0)->comment('订单状态 0:正常 1:退货');
$table->integer('real_company_id')->unsigned()->default(0)->comment("企业ID");
$table->timestamp('cancelled_at')->nullable()->comment('注销时间');
$table->timestamps();

View File

@ -107,7 +107,7 @@ export default {
{
title: "订单编号",
key: "sn",
width: 165
width: 210
},
{
@ -155,6 +155,7 @@ export default {
title: "所需卡量",
key: "",
width: 150,
fixed: 'right',
render: (h, context) => {
let select = this.selected.find(item => {
return item.id === context.row.id;