迁移文件优化
This commit is contained in:
parent
8799c9147c
commit
7dade947a4
@ -13,6 +13,10 @@ class CreateAccountsTable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('accounts')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('accounts', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('账户ID');
|
||||
$table->string('username', 32)->default('')->comment('登录名');
|
||||
|
@ -13,6 +13,10 @@ class CreateConfigsTable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('configs')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('configs', function (Blueprint $table) {
|
||||
$table->string('name', 100)->comment('配置名称');
|
||||
$table->text('value')->nullable()->comment('缓存值');
|
||||
|
@ -13,6 +13,7 @@ class CreateFileTables extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (!Schema::hasTable('files')) {
|
||||
// 文件表
|
||||
Schema::create('files', function (Blueprint $table) {
|
||||
$table->bigInteger('id')->unsigned()->default(0)->comment('附件全局唯一ID');
|
||||
@ -32,7 +33,9 @@ class CreateFileTables extends Migration
|
||||
|
||||
$table->comment('文件表');
|
||||
});
|
||||
}
|
||||
|
||||
if (!Schema::hasTable('file_withs')) {
|
||||
// 文件关联表
|
||||
Schema::create('file_withs', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
@ -50,6 +53,7 @@ class CreateFileTables extends Migration
|
||||
$table->comment('文件关联表');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
|
@ -13,6 +13,10 @@ class CreateLogs extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('logs')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('logs', function (Blueprint $table) {
|
||||
$table->bigInteger('id')->unsigned()->default(0)->comment('日志ID');
|
||||
$table->string('request_url', 255)->default('')->comment('请求地址');
|
||||
|
@ -13,6 +13,7 @@ class CreatePermissionTables extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (!Schema::hasTable('permissions')) {
|
||||
Schema::create('permissions', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name', 32)->default('')->comment('标识');
|
||||
@ -31,7 +32,9 @@ class CreatePermissionTables extends Migration
|
||||
|
||||
$table->comment('权限表');
|
||||
});
|
||||
}
|
||||
|
||||
if (!Schema::hasTable('roles')) {
|
||||
Schema::create('roles', function (Blueprint $table) {
|
||||
$table->increments('id');
|
||||
$table->string('name', 32)->default('')->comment('标识');
|
||||
@ -42,7 +45,9 @@ class CreatePermissionTables extends Migration
|
||||
|
||||
$table->comment('角色表');
|
||||
});
|
||||
}
|
||||
|
||||
if (!Schema::hasTable('account_has_roles')) {
|
||||
Schema::create('account_has_roles', function (Blueprint $table) use ($tableNames) {
|
||||
$table->unsignedInteger('role_id');
|
||||
$table->unsignedInteger('account_id');
|
||||
@ -50,7 +55,9 @@ class CreatePermissionTables extends Migration
|
||||
|
||||
$table->comment('账号角色关联表');
|
||||
});
|
||||
}
|
||||
|
||||
if (!Schema::hasTable('role_has_permissions')) {
|
||||
Schema::create('role_has_permissions', function (Blueprint $table) use ($tableNames) {
|
||||
$table->unsignedInteger('permission_id');
|
||||
$table->unsignedInteger('role_id');
|
||||
@ -59,6 +66,7 @@ class CreatePermissionTables extends Migration
|
||||
$table->comment('角色权限关联表');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
|
@ -36,20 +36,16 @@ class AddedOrderSync extends Command
|
||||
}
|
||||
|
||||
$dataOrderCards = [];
|
||||
$dataPackageCards = [];
|
||||
|
||||
foreach ($orderItems as $key => $value) {
|
||||
$dataOrderCards[$value['type']][] = [
|
||||
'sim' => $value['sim'],
|
||||
'company_id' => $value['company_id'],
|
||||
'order_id' => $value['order_id'],
|
||||
'package_id' => $value['package_id'],
|
||||
'counts' => $value['counts'],
|
||||
'unit_price' => $value['unit_price'],
|
||||
];
|
||||
|
||||
$dataPackageCards[$value['type']][] = [
|
||||
'package_id' => $value['package_id'],
|
||||
'sim' => $value['sim'],
|
||||
];
|
||||
}
|
||||
|
||||
$this->line('插入订单数据,条数:'.count($orders));
|
||||
@ -76,24 +72,6 @@ class AddedOrderSync extends Command
|
||||
}
|
||||
unset($dataOrderCards);
|
||||
$this->line('插入订单关联数据成功');
|
||||
|
||||
$this->line('插入套餐关联数据,条数:'.count(array_collapse($dataPackageCards)));
|
||||
$tables = [
|
||||
'',
|
||||
'real_package_renewal_cards',
|
||||
'real_package_renewal_package_cards',
|
||||
'real_package_flows_package_cards',
|
||||
'real_package_optional_package_cards',
|
||||
'real_package_additional_package_cards',
|
||||
];
|
||||
foreach ($dataPackageCards as $type => $packageCards) {
|
||||
foreach (array_chunk($packageCards, $this->chunks) as $data) {
|
||||
echo '.';
|
||||
DB::table($tables[$type])->upsert($data, ['sim', 'package_id']);
|
||||
}
|
||||
}
|
||||
unset($dataPackageCards);
|
||||
$this->line('插入套餐关联数据成功');
|
||||
}
|
||||
|
||||
// 查询订单
|
||||
@ -120,10 +98,9 @@ class AddedOrderSync extends Command
|
||||
->whereIn('custom_no', $this->companies->keys())
|
||||
->where('create_time', '>=', $starttime->timestamp)
|
||||
->where('create_time', '<=', $endtime->timestamp)
|
||||
->orderBy('create_time')->get()->toArray();
|
||||
->orderBy('create_time')->get()->collect()->toArray();
|
||||
|
||||
foreach ($orders as &$item) {
|
||||
$item = (array)$item;
|
||||
$item['company_id'] = $this->companies[$item['company_id']]['id'] ?? 0;
|
||||
$item['total_price'] = floatval($item['total_price']) * 100;
|
||||
$item['counts'] = !empty($item['counts']) ? $item['counts'] : 1;
|
||||
@ -154,11 +131,11 @@ class AddedOrderSync extends Command
|
||||
];
|
||||
|
||||
$orderItems = DB::connection('real')->table('jxc_custom_order_item')->select($select)
|
||||
->whereIn('sn', array_keys($orders))->where('goods_type', '<', 6)->get()->toArray();
|
||||
->whereIn('sn', array_keys($orders))->where('goods_type', '<', 6)->get()->collect()->toArray();
|
||||
|
||||
foreach ($orderItems as &$item) {
|
||||
$item = (array)$item;
|
||||
$item['order_id'] = $orders[$item['order_sn']]['id'] ?? 0;
|
||||
$item['company_id'] = $orders[$item['order_sn']]['company_id'] ?? 0;
|
||||
$item['package_id'] = $this->packages[$item['package_id']]['id'] ?? 0;
|
||||
$item['unit_price'] = floatval($item['unit_price']) * 100;
|
||||
}
|
||||
|
@ -20,13 +20,12 @@ class BlocSync extends Command
|
||||
{
|
||||
$select = ['id', 'bloc_code as sn', "bloc_name as name", 'carrieroperator as carrier_operator', 'create_time as created_at', 'del'];
|
||||
|
||||
$blocs = DB::connection('real')->table('jxc_bloc_manage')->select($select)->get()->toArray();
|
||||
$carders = DB::connection('real')->table('jxc_carder_manage')->select(['bloc_code', 'inside_card_from_sn'])->get()->toArray();
|
||||
$blocs = DB::connection('real')->table('jxc_bloc_manage')->select($select)->get()->collect()->toArray();
|
||||
$carders = DB::connection('real')->table('jxc_carder_manage')->select(['bloc_code', 'inside_card_from_sn'])->get()->collect()->toArray();
|
||||
$carders = array_pluck($carders, 'inside_card_from_sn', 'bloc_code');
|
||||
|
||||
foreach ($blocs as &$item) {
|
||||
$item = (array)$item;
|
||||
$item['shorthand'] = $carders[$item['id']] ?? '';
|
||||
$item['shorthand'] = $carders[$item['sn']] ?? '';
|
||||
$item['carrier_operator'] = $this->carrier_operator[$item['carrier_operator']];
|
||||
$item['created_at'] = Carbon::createFromTimestamp($item['created_at']);
|
||||
$item['updated_at'] = date('Y-m-d H:i:s');
|
||||
|
@ -68,7 +68,7 @@ class MongoSync extends Command
|
||||
];
|
||||
}
|
||||
|
||||
Card::upsert($values, 'sim');
|
||||
Card::upsert($values, 'sim', true);
|
||||
|
||||
if ($page * $this->limit >= $total) {
|
||||
break;
|
||||
|
286
app/Domains/Virtual/Commands/Sync/CardSync.php
Normal file
286
app/Domains/Virtual/Commands/Sync/CardSync.php
Normal file
@ -0,0 +1,286 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Virtual\Commands\Sync;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Card\Card;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Domains\Virtual\Services\CommonService;
|
||||
use App\Domains\Virtual\Services\ProductService;
|
||||
use App\Domains\Card\Repositories\BlocRepository;
|
||||
use App\Domains\Card\Repositories\CardRepository;
|
||||
use App\Domains\Virtual\Repositories\CompanyRepository;
|
||||
use App\Domains\Virtual\Repositories\PackageRepository;
|
||||
use App\Domains\Virtual\Repositories\ProductRepository;
|
||||
|
||||
class CardSync extends Command
|
||||
{
|
||||
protected $name = 'virtual:sync-card';
|
||||
|
||||
protected $description = '同步VD卡信息数据';
|
||||
|
||||
protected static $carrierOperators = [10 => 0, 11 => 1, 12 => 2];
|
||||
protected static $payChannels = [10 => 'wx', 11 => 'alipay', 12 => 'bank'];
|
||||
|
||||
protected $blocs;
|
||||
protected $packages;
|
||||
protected $product;
|
||||
|
||||
protected $limit = 1;
|
||||
|
||||
const FILENAME = 'app/command/sync-card.json';
|
||||
const INIT_ID = 0; // '2000-01-01 00:00:00'
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$contents = $this->getFile();
|
||||
$maxId = $contents['maxId'];
|
||||
$nextId = $contents['maxId'];
|
||||
|
||||
$this->saveFile(1, $maxId);
|
||||
|
||||
$query = DB::connection('vd_old')->table('ckb_custom')
|
||||
->select(['id', 'custom_no', 'imsi', 'carrieroperator', 'iccid', 'card_number', 'card_from', 'iccid', 'company', 'custom_state'])
|
||||
->where('id', '>', $maxId);
|
||||
|
||||
$logQuery = DB::connection('vd_old')->table('ckb_custom_handle_log')
|
||||
->select(['type', 'company', 'pay_type', 'content', 'valid_start_time', 'valid_end_time', 'sale_account', 'order_account', 'create_time']);
|
||||
|
||||
$total = $query->count();
|
||||
|
||||
$this->line('待同步条数:' . $total);
|
||||
|
||||
if ($total) {
|
||||
$this->blocs = app(BlocRepository::class)->get()->pluck('id', 'shorthand')->toArray();
|
||||
$this->packages = app(PackageRepository::class)->get()->keyBy('sn');
|
||||
$this->product = app(ProductRepository::class)->get()->keyBy('sn');
|
||||
}
|
||||
|
||||
$page = 1;
|
||||
|
||||
while ($total) {
|
||||
echo $page . PHP_EOL;
|
||||
$value = $query->offset(($page - 1) * $this->limit)->limit($this->limit)->get()->first();
|
||||
|
||||
if (!$value) {
|
||||
break;
|
||||
}
|
||||
|
||||
$value = (array)$value;
|
||||
|
||||
$logs = $logQuery->where('custom_no', $value['custom_no'])->get()->collect();
|
||||
$existedCard = Card::where('sim', $value['card_number'])->first();
|
||||
|
||||
dd($logs);
|
||||
|
||||
$card = $this->transformerCard($value, $logs, $existedCard);
|
||||
$order = $this->transformerOrder($value, $logs, $existedCard);
|
||||
$renewals = $this->transformerRenewals($value, $logs, $existedCard);
|
||||
$renewalPackages = $this->transformerRenewalPackages($value, $logs, $existedCard);
|
||||
$flows = $this->transformerFlows($value, $logs, $existedCard);
|
||||
|
||||
$nextId = $value['id'];
|
||||
|
||||
if ($page * $this->limit >= $total) {
|
||||
break;
|
||||
}
|
||||
|
||||
$page++;
|
||||
}
|
||||
|
||||
app(CardRepository::class)->forgetCached();
|
||||
|
||||
$this->saveFile(0, $nextId);
|
||||
}
|
||||
|
||||
// 卡数据转换
|
||||
protected function transformerCard($value, $logs, $existedCard)
|
||||
{
|
||||
// 判断卡类型
|
||||
$type = ($value['card_number'][3] >= 5) ? 1 : ($existedCard ? 0 : 2);
|
||||
|
||||
// 激活记录
|
||||
$activateLog = $logs->where('type', 10)->first();
|
||||
$activate_at = $activateLog ? date('Y-m-d H:i:s', $activateLog['valid_start_time']) : null;
|
||||
|
||||
return [
|
||||
'sim' => $value['card_number'],
|
||||
'imsi' => $value['imsi'],
|
||||
'iccid' => $value['iccid'],
|
||||
'bloc_id' => $this->blocs[$value['card_from']] ?? 0,
|
||||
'carrier_operator' => self::$carrierOperators[$value['carrieroperator']],
|
||||
'activate_at' => $existedCard ? $existedCard->activate_at : $activate_at,
|
||||
'virtual_activate_at' => $activate_at,
|
||||
'type' => $type,
|
||||
];
|
||||
}
|
||||
|
||||
// 销售记录
|
||||
protected function transformerOrder($value, $logs, $existedCard)
|
||||
{
|
||||
if (!$sellLog = $logs->where('type', 13)->first()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$package = $this->getPackage($sellLog['content']);
|
||||
|
||||
$unit_price = floatval($sellLog['sale_account']) * 100;
|
||||
$custom_price = floatval($sellLog['order_account']) * 100;
|
||||
|
||||
$product = $this->getProduct($package, $sellLog['company'], $unit_price);
|
||||
|
||||
$order = [
|
||||
'type' => 1,
|
||||
'company_id' => $sellLog['company'],
|
||||
'package_id' => $package['id'],
|
||||
'product_id' => $product['id'],
|
||||
'pay_channel' => self::$payChannels[$sellLog['pay_type']],
|
||||
'unit_price' => $unit_price,
|
||||
'counts' => DB::raw('counts + 1'),
|
||||
'total_price' => DB::raw("total_price + {$unit_price}"),
|
||||
'custom_price' => DB::raw("custom_price + {$custom_price}"),
|
||||
'order_at' => date('Y-m-d H:i:s'),
|
||||
'order_status' => 4,
|
||||
'transaction_status' => 1,
|
||||
];
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
// 续费记录
|
||||
protected function transformerRenewals($value, $logs, $existedCard)
|
||||
{
|
||||
$renewalLogs = $logs->where('type', 11)->get();
|
||||
|
||||
if (empty($renewalLog)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$array = [];
|
||||
|
||||
foreach ($renewalLogs as $item) {
|
||||
$package = $this->getPackage($sellLog['content']);
|
||||
$unit_price = floatval($sellLog['sale_account']) * 100;
|
||||
$custom_price = floatval($sellLog['order_account']) * 100;
|
||||
|
||||
$array[] = [
|
||||
'sn' => $sn,
|
||||
'type' => 1,
|
||||
'company_id' => $sellLog['company'],
|
||||
'package_id' => $package['id'],
|
||||
'product_id' => $product['id'],
|
||||
'pay_channel' => self::$payChannels[$sellLog['pay_type']],
|
||||
'unit_price' => $unit_price,
|
||||
'counts' => DB::raw('counts + 1'),
|
||||
'total_price' => DB::raw("total_price + {$unit_price}"),
|
||||
'custom_price' => DB::raw("custom_price + {$custom_price}"),
|
||||
'order_at' => date('Y-m-d H:i:s'),
|
||||
'order_status' => 4,
|
||||
'transaction_status' => 1,
|
||||
];
|
||||
}
|
||||
|
||||
return $array;
|
||||
}
|
||||
|
||||
// 续费包记录
|
||||
protected function transformerRenewalPackages($value, $logs, $existedCard)
|
||||
{
|
||||
$renewalLog = $logs->where('type', 14)->get();
|
||||
|
||||
if (empty($renewalLog)) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
// 加油包记录
|
||||
protected function transformerFlows($value, $logs, $existedCard)
|
||||
{
|
||||
$flowsLog = $logs->where('type', 15)->get();
|
||||
|
||||
if (empty($flowsLog)) {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取套餐
|
||||
*
|
||||
* @param string $sn
|
||||
* @return void
|
||||
*/
|
||||
protected function getPackage($sn)
|
||||
{
|
||||
if (!$package = $this->packages[$sn]) {
|
||||
throw new \Exception('套餐不存在');
|
||||
}
|
||||
|
||||
return $package;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取定价
|
||||
*
|
||||
* @param string $sn
|
||||
* @return void
|
||||
*/
|
||||
protected function getProduct($package, $companyId, $price)
|
||||
{
|
||||
$sn = strtoupper($package['sn'] . '_' . $companyId . '_' . $price);
|
||||
|
||||
if (!$product = $this->products[$sn]) {
|
||||
$product = app(ProductService::class)->store([
|
||||
'name' => $package['name'] . '' . $price,
|
||||
'company_id' => $companyId,
|
||||
'package_id' => $package['id'],
|
||||
'base_price' => $price,
|
||||
'renewal_price' => $price,
|
||||
]);
|
||||
$this->products[$sn] = $product;
|
||||
}
|
||||
|
||||
return $product;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件内容
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function getFile()
|
||||
{
|
||||
$file = storage_path(self::FILENAME);
|
||||
|
||||
if (!file_exists($file)) {
|
||||
$dir = dirname($file);
|
||||
if (null !== $dir && !is_dir($dir)) {
|
||||
mkdir($dir, 0777, true);
|
||||
}
|
||||
|
||||
$this->saveFile(0, self::INIT_ID);
|
||||
}
|
||||
|
||||
$contents = file_get_contents($file);
|
||||
|
||||
return json_decode($contents, 256);
|
||||
}
|
||||
|
||||
/**
|
||||
* 写入文件
|
||||
*
|
||||
* @param integer $status 状态 1运行中 0运行结束
|
||||
* @param integer $maxId 最后查询的ID
|
||||
* @return void
|
||||
*/
|
||||
protected function saveFile(int $status, int $maxId)
|
||||
{
|
||||
$file = storage_path(self::FILENAME);
|
||||
|
||||
$contents = json_encode([
|
||||
'status' => $status,
|
||||
'maxId' => $maxId,
|
||||
]);
|
||||
|
||||
file_put_contents($file, $contents);
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ class ProductSync extends Command
|
||||
{
|
||||
$packages = app(PackageRepository::class)->where('type', 0)->get()->keyBy('sn')->toArray();
|
||||
|
||||
$fields = ['company', 'content', 'order_account'];
|
||||
$fields = ['company', 'content', 'sale_account'];
|
||||
|
||||
$list = DB::connection('vd_old')->table('ckb_custom_handle_log')->select($fields)
|
||||
->where('type', 13)
|
||||
@ -33,13 +33,13 @@ class ProductSync extends Command
|
||||
throw new \Exception('套餐不存在');
|
||||
}
|
||||
|
||||
$base_price = floatval($value['order_account']) * 100;
|
||||
$base_price = floatval($value['sale_account']) * 100;
|
||||
|
||||
$products[] = [
|
||||
'sn' => strtoupper($package['sn'] . '_' . $value['company'] . '_' . $base_price),
|
||||
'company_id' => $value['company'],
|
||||
'package_id' => $package['id'],
|
||||
'name' => $package['name'] . ' ' . $value['order_account'],
|
||||
'name' => $package['name'] . ' ' . $value['sale_account'],
|
||||
'base_price' => $base_price,
|
||||
'renewal_price' => 0,
|
||||
'created_at' => date('Y-m-d H:i:s'),
|
||||
|
@ -25,6 +25,7 @@ class VirtualServiceProvider extends ServiceProvider
|
||||
\App\Domains\Virtual\Commands\Sync\CompanySync::class,
|
||||
\App\Domains\Virtual\Commands\Sync\PackageSync::class,
|
||||
\App\Domains\Virtual\Commands\Sync\ProductSync::class,
|
||||
\App\Domains\Virtual\Commands\Sync\CardSync::class,
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,10 @@
|
||||
namespace App\Domains\Virtual\Repositories;
|
||||
|
||||
use App\Core\Repository;
|
||||
use App\Models\Virtual\Bloc as Model;
|
||||
use App\Models\Virtual\Order as Model;
|
||||
use App\Domains\Virtual\Services\CommonService;
|
||||
|
||||
class BlocRepository extends Repository
|
||||
class AddedOrderRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* 是否关闭缓存
|
||||
@ -26,10 +27,12 @@ class BlocRepository extends Repository
|
||||
*/
|
||||
protected $fieldSearchable = [
|
||||
'id' => '=',
|
||||
'created_at' => 'like',
|
||||
'sn' => 'like',
|
||||
'package.name' => 'like',
|
||||
];
|
||||
|
||||
public function model() {
|
||||
public function model()
|
||||
{
|
||||
return Model::class;
|
||||
}
|
||||
|
||||
@ -42,7 +45,7 @@ class BlocRepository extends Repository
|
||||
*/
|
||||
public function transform($model)
|
||||
{
|
||||
return $model->toArray();
|
||||
return $model;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -57,6 +60,19 @@ class BlocRepository extends Repository
|
||||
$this->model = $this->model->whereIn('id', $conditions['id']);
|
||||
}
|
||||
|
||||
if (isset($conditions['company_id'])) {
|
||||
$this->model = $this->model->where('company_id', $conditions['company_id']);
|
||||
}
|
||||
|
||||
|
||||
if (isset($conditions['starttime'])) {
|
||||
$this->model = $this->model->where('order_at', '>=', $conditions['starttime']);
|
||||
}
|
||||
|
||||
if (isset($conditions['endtime'])) {
|
||||
$this->model = $this->model->where('order_at', '<=', $conditions['endtime']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
208
app/Domains/Virtual/Services/AddedOrderService.php
Normal file
208
app/Domains/Virtual/Services/AddedOrderService.php
Normal file
@ -0,0 +1,208 @@
|
||||
<?php
|
||||
namespace App\Domains\Virtual\Services;
|
||||
|
||||
use App\Dicts;
|
||||
use App\Core\Service;
|
||||
use App\Models\Virtual\AddedOrder;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use App\Exceptions\NotExistException;
|
||||
use App\Exceptions\NotAllowedException;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use App\Domains\Virtual\Services\CommonService;
|
||||
use App\Domains\Virtual\Repositories\OrderRepository;
|
||||
use App\Domains\Virtual\Repositories\ProductRepository;
|
||||
|
||||
class AddedOrderService extends Service
|
||||
{
|
||||
protected $orderRepository;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(OrderRepository $orderRepository)
|
||||
{
|
||||
$this->orderRepository = $orderRepository;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
*
|
||||
* @param array $conditions
|
||||
* @return mixed
|
||||
*/
|
||||
public function paginate(array $conditions = [])
|
||||
{
|
||||
$limit = $conditions['limit'] ?? 35;
|
||||
|
||||
$res = $this->orderRepository->with(['company:id,name','package:id,name,carrier_operator'])
|
||||
->withConditions($conditions)->applyConditions()->orderBy('order_at', 'desc')->paginate($limit);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 订单计数
|
||||
*
|
||||
* @param array $conditions
|
||||
* @return mixed
|
||||
*/
|
||||
public function count(array $conditions = [])
|
||||
{
|
||||
$select = [
|
||||
DB::raw('COUNT(*) as total_count'),
|
||||
DB::raw('SUM(custom_price) as total_price'),
|
||||
DB::raw('SUM(custom_price*transaction_status) as transacted_price'),
|
||||
];
|
||||
|
||||
$res = $this->orderRepository->select($select)->withConditions($conditions)->applyConditions()->first()->toArray();
|
||||
|
||||
$res['total_price'] = $res['total_price'] ?: 0;
|
||||
$res['transacted_price'] = $res['transacted_price'] ?: 0;
|
||||
unset($res['company']);
|
||||
unset($res['package']);
|
||||
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下单
|
||||
*
|
||||
* @param array $attributes
|
||||
* @return Order
|
||||
*/
|
||||
public function store(array $attributes = [])
|
||||
{
|
||||
$attributes['sn'] = $attributes['sn'] ?: $this->generateSn();
|
||||
|
||||
$rule = [
|
||||
'company_id' => ['exists:virtual_companies,id'],
|
||||
'product_id' => [],
|
||||
'counts' => [],
|
||||
'pay_channel' => [Rule::in(array_collapse(app(Dicts::class)->get('pay_channel')))],
|
||||
'contacts' => ['display_length:2,32'],
|
||||
'mobile' => ['cn_phone'],
|
||||
'area' => ['max:255'],
|
||||
'address' => ['max:255'],
|
||||
'order_status' => ['in:0,1,2,3,4'],
|
||||
'transaction_status' => ['in:0,1,2'],
|
||||
'extends' => ['array'],
|
||||
];
|
||||
|
||||
$message = [
|
||||
'company_id.required' => '请输入企业ID',
|
||||
'company_id.exists' => '企业不存在或已删除',
|
||||
'product_id.required' => '请选择套餐',
|
||||
'counts.required' => '请输入订购数量',
|
||||
'pay_channel.required' => '请选择支付方式',
|
||||
'pay_channel.in' => '支付方式不合法',
|
||||
'contacts.required' => '联系人不能为空',
|
||||
'contacts.display_length' => '联系人名称长度不合法',
|
||||
'mobile.required' => '手机号不能为空',
|
||||
'mobile.cn_phone' => '手机号不合法',
|
||||
'area.required' => '请选择区域',
|
||||
'address.required' => '请输入详细地址',
|
||||
];
|
||||
|
||||
if (!$attributes['id']) {
|
||||
$rule['company_id'][] = 'required';
|
||||
$rule['product_id'][] = 'required';
|
||||
$rule['counts'][] = 'required';
|
||||
$rule['pay_channel'][] = 'required';
|
||||
$rule['contacts'][] = 'required';
|
||||
$rule['mobile'][] = 'required';
|
||||
$rule['area'][] = 'required';
|
||||
$rule['address'][] = 'required';
|
||||
}
|
||||
|
||||
Validator::validate($attributes, $rule, $message);
|
||||
|
||||
if (!$attributes['id']) {
|
||||
if (!$product = app(ProductRepository::class)->withConditions(['id' => $attributes['product_id']])->first()) {
|
||||
throw new NotExistException('套餐不存在或已删除');
|
||||
}
|
||||
|
||||
if ($product->company_id != $attributes['company_id']) {
|
||||
throw new NotAllowedException('非法操作');
|
||||
}
|
||||
|
||||
$attributes['unit_price'] = $product->base_price;
|
||||
$attributes['total_price'] = $attributes['unit_price'] * $attributes['counts'];
|
||||
$attributes['custom_price'] = $attributes['unit_price'] * $attributes['counts'];
|
||||
$attributes['order_at'] = $attributes['order_at'] ?? date('Y-m-d H:i:s');
|
||||
$attributes['package_id'] = $attributes['package_id'] ?? $product->package_id;
|
||||
|
||||
$node = $this->orderRepository->create($attributes);
|
||||
}
|
||||
|
||||
if ($attributes['id']) {
|
||||
if (!$node = $this->orderRepository->find($attributes['id'])) {
|
||||
throw new NotExistException('订单不存在或已删除');
|
||||
}
|
||||
|
||||
if (!empty($attributes['extends']) && is_array($attributes['extends'])) {
|
||||
$attributes['extends'] = array_merge($node->extends ?: [], $attributes['extends']);
|
||||
}
|
||||
|
||||
$this->orderRepository->setModel($node)->update($attributes);
|
||||
}
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* 取消订单
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function cancel($id)
|
||||
{
|
||||
if (!$node = $this->orderRepository->find($id)) {
|
||||
throw new NotExistException('订单不存在或已删除');
|
||||
}
|
||||
|
||||
if ($node->order_status !== 0) {
|
||||
throw new NotExistException('订单已出库,不能取消');
|
||||
}
|
||||
|
||||
if ($node->transaction_status !== 0) {
|
||||
throw new NotExistException('订单已付款,不能取消');
|
||||
}
|
||||
|
||||
$this->orderRepository->setModel($node)->update(['order_status' => 1]);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* 确认收货
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function received($id)
|
||||
{
|
||||
if (!$node = $this->orderRepository->find($id)) {
|
||||
throw new NotExistException('订单不存在或已删除');
|
||||
}
|
||||
|
||||
if ($node->order_status !== 3) {
|
||||
throw new NotExistException('订单未发货,不能修改');
|
||||
}
|
||||
|
||||
$this->orderRepository->setModel($node)->update(['order_status' => 4]);
|
||||
|
||||
return $node;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成订单编号
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function generateSn()
|
||||
{
|
||||
return date('YmdHis') . explode('.', microtime(true))[1] . sprintf('%02d', rand(0, 99));
|
||||
}
|
||||
}
|
@ -29,31 +29,31 @@ class OrderCard extends Model
|
||||
// 续费套餐
|
||||
public function renewalPackages()
|
||||
{
|
||||
return $this->belongsToMany(Package::class, 'real_package_renewal_cards', 'sim', 'package_id');
|
||||
return $this->belongsToMany(Package::class, 'real_added_order_renewal_cards', 'sim', 'package_id');
|
||||
}
|
||||
|
||||
// 续费包套餐
|
||||
public function renewalPackagePackages()
|
||||
{
|
||||
return $this->belongsToMany(Package::class, 'real_package_renewal_package_cards', 'sim', 'package_id');
|
||||
return $this->belongsToMany(Package::class, 'real_added_order_renewal_package_cards', 'sim', 'package_id');
|
||||
}
|
||||
|
||||
// 加油包套餐
|
||||
public function flowPackagePackages()
|
||||
{
|
||||
return $this->belongsToMany(Package::class, 'real_package_flows_package_cards', 'sim', 'package_id');
|
||||
return $this->belongsToMany(Package::class, 'real_added_order_flows_package_cards', 'sim', 'package_id');
|
||||
}
|
||||
|
||||
// 可选包套餐
|
||||
public function optionalPackagePackages()
|
||||
{
|
||||
return $this->belongsToMany(Package::class, 'real_package_optional_package_cards', 'sim', 'package_id');
|
||||
return $this->belongsToMany(Package::class, 'real_added_order_optional_package_cards', 'sim', 'package_id');
|
||||
}
|
||||
|
||||
// 附加包套餐
|
||||
public function additionalPackagePackages()
|
||||
{
|
||||
return $this->belongsToMany(Package::class, 'real_package_additional_package_cards', 'sim', 'package_id');
|
||||
return $this->belongsToMany(Package::class, 'real_added_order_additional_package_cards', 'sim', 'package_id');
|
||||
}
|
||||
|
||||
// 续费订单
|
||||
|
@ -29,31 +29,31 @@ class OrderCard extends Model
|
||||
// 续费套餐
|
||||
public function renewalPackages()
|
||||
{
|
||||
return $this->belongsToMany(Package::class, 'virtual_package_renewal_cards', 'sim', 'package_id');
|
||||
return $this->belongsToMany(Package::class, 'virtual_added_order_renewal_cards', 'sim', 'package_id');
|
||||
}
|
||||
|
||||
// 续费包套餐
|
||||
public function renewalPackagePackages()
|
||||
{
|
||||
return $this->belongsToMany(Package::class, 'virtual_package_renewal_package_cards', 'sim', 'package_id');
|
||||
return $this->belongsToMany(Package::class, 'virtual_added_order_renewal_package_cards', 'sim', 'package_id');
|
||||
}
|
||||
|
||||
// 加油包套餐
|
||||
public function flowPackagePackages()
|
||||
{
|
||||
return $this->belongsToMany(Package::class, 'virtual_package_flows_package_cards', 'sim', 'package_id');
|
||||
return $this->belongsToMany(Package::class, 'virtual_added_order_flows_package_cards', 'sim', 'package_id');
|
||||
}
|
||||
|
||||
// 可选包套餐
|
||||
public function optionalPackagePackages()
|
||||
{
|
||||
return $this->belongsToMany(Package::class, 'virtual_package_optional_package_cards', 'sim', 'package_id');
|
||||
return $this->belongsToMany(Package::class, 'virtual_added_order_optional_package_cards', 'sim', 'package_id');
|
||||
}
|
||||
|
||||
// 附加包套餐
|
||||
public function additionalPackagePackages()
|
||||
{
|
||||
return $this->belongsToMany(Package::class, 'virtual_package_additional_package_cards', 'sim', 'package_id');
|
||||
return $this->belongsToMany(Package::class, 'virtual_added_order_additional_package_cards', 'sim', 'package_id');
|
||||
}
|
||||
|
||||
// 续费订单
|
||||
|
12
composer.lock
generated
12
composer.lock
generated
@ -626,17 +626,17 @@
|
||||
},
|
||||
{
|
||||
"name": "dipper/foundation",
|
||||
"version": "1.1.9",
|
||||
"version": "1.1.13",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "ssh://gogs@git.fxft.net:2222/composer/foundation.git",
|
||||
"reference": "94efaf5b1e21d1bc4f7bae4fc6c4d3f741b399d0"
|
||||
"reference": "7fa8390645a5cd52bc68666a9af9d8b008860200"
|
||||
},
|
||||
"dist": {
|
||||
"type": "tar",
|
||||
"url": "https://composer.fxft.online/dist/dipper/foundation/dipper-foundation-1.1.9-51f1b8.tar",
|
||||
"reference": "94efaf5b1e21d1bc4f7bae4fc6c4d3f741b399d0",
|
||||
"shasum": "b17959dd9990df31f7e6c3cff53749afe151f670"
|
||||
"url": "https://composer.fxft.online/dist/dipper/foundation/dipper-foundation-1.1.13-c3e049.tar",
|
||||
"reference": "7fa8390645a5cd52bc68666a9af9d8b008860200",
|
||||
"shasum": "e8c31e9bf07ea46e491c969a83465fc969f7e96e"
|
||||
},
|
||||
"require": {
|
||||
"barryvdh/laravel-cors": "~0.11",
|
||||
@ -670,7 +670,7 @@
|
||||
}
|
||||
],
|
||||
"description": "The Foundation of the Dipper Architecture project for Lumen",
|
||||
"time": "2018-12-21T07:43:51+00:00"
|
||||
"time": "2018-12-24T06:42:58+00:00"
|
||||
},
|
||||
{
|
||||
"name": "dipper/jwt-auth",
|
||||
|
@ -13,6 +13,10 @@ class CreateFailedJobsTable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('failed_jobs')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('failed_jobs', function (Blueprint $table) {
|
||||
$table->bigIncrements('id');
|
||||
$table->text('connection');
|
||||
|
@ -1,234 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Dicts;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateBaseTables extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
foreach (app(Dicts::class)->get('tables') as $prefix => $type) {
|
||||
Schema::create("{$prefix}_companies", function (Blueprint $table) use ($type) {
|
||||
$table->increments('id')->comment('企业ID');
|
||||
$table->string('sn', 32)->comment('企业编号');
|
||||
$table->string('name', 32)->default('')->comment('企业名称');
|
||||
$table->string('contacts', 20)->default('')->comment('联系人');
|
||||
$table->string('mobile', 20)->default('')->comment('手机号');
|
||||
$table->string('address')->default('')->comment('地址');
|
||||
$table->text('remark')->nullable()->comment('订单备注');
|
||||
$table->text('extends')->nullable()->comment('扩展信息');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->comment("{$type}企业");
|
||||
});
|
||||
|
||||
Schema::create("{$prefix}_packages", function (Blueprint $table) use ($type) {
|
||||
$table->increments('id')->comment('企业ID');
|
||||
$table->integer('parent_id')->unsigned()->default(0)->comment('父级ID');
|
||||
$table->string('sn', 20)->comment('套餐编号');
|
||||
$table->string('name', 32)->comment('套餐名称');
|
||||
$table->tinyInteger('type')->unsigned()->default(255)->comment('套餐类型(0:基础套餐 1:续费包 2:加油包 3:可选包 4:附加包)');
|
||||
$table->tinyInteger('carrier_operator')->unsigned()->default(255)->comment('运营商(0:联通 1:移动 2:电信)');
|
||||
$table->integer('cost_price')->unsigned()->default(0)->comment('成本价格');
|
||||
$table->integer('guide_price')->unsigned()->default(0)->comment('指导价格');
|
||||
$table->integer('renewal_cost_price')->unsigned()->default(0)->comment('续费成本价格');
|
||||
$table->integer('renewal_guide_price')->unsigned()->default(0)->comment('续费指导价格');
|
||||
$table->integer('flows')->unsigned()->default(0)->comment('套餐流量(M)');
|
||||
$table->integer('voices')->unsigned()->default(0)->comment('套餐语音(分钟)');
|
||||
$table->integer('messages')->unsigned()->default(0)->comment('套餐短信(条)');
|
||||
$table->tinyInteger('has_messages')->unsigned()->default(255)->comment('是否开通短信服务(0:无 1:有)');
|
||||
$table->tinyInteger('has_lbs')->unsigned()->default(255)->comment('是否开通LBS服务(0:无 1:有)');
|
||||
$table->tinyInteger('reset_months')->unsigned()->default(0)->comment('重置周期(月)');
|
||||
$table->tinyInteger('service_months')->unsigned()->default(0)->comment('套餐周期(月)');
|
||||
$table->tinyInteger('effect_months')->unsigned()->default(0)->comment('生效延迟周期(月)');
|
||||
$table->tinyInteger('delay_months')->unsigned()->default(0)->comment('服务延长周期(月)');
|
||||
$table->text('description')->nullable()->comment('描述');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->index('name');
|
||||
$table->index('parent_id');
|
||||
$table->index('type');
|
||||
$table->index('carrier_operator');
|
||||
|
||||
$table->comment("{$type}套餐");
|
||||
});
|
||||
|
||||
Schema::create("{$prefix}_order_cards", function (Blueprint $table) use ($type) {
|
||||
$table->increments('id')->comment('关联表ID');
|
||||
$table->bigInteger('sim')->unsigned()->default(0)->comment('sim号');
|
||||
$table->integer('order_id')->unsigned()->default(0)->comment('订单ID');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment("{$type}企业ID");
|
||||
$table->integer('package_id')->unsigned()->default(0)->comment('套餐ID');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sim', 'order_id']);
|
||||
$table->unique(['sim', 'deleted_at']);
|
||||
|
||||
$table->comment("{$type}订单企业套餐卡关联表");
|
||||
});
|
||||
|
||||
Schema::create("{$prefix}_added_orders", function (Blueprint $table) use ($type) {
|
||||
$table->increments('id')->comment('订单ID');
|
||||
$table->string('sn', 32)->comment('订单编号');
|
||||
$table->tinyInteger('type')->unsigned()->default(0)->comment('订单类型(1:套餐续费 2:续费包 3:加油包 4:可选包 5:附加包)');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment("{$type}企业ID");
|
||||
$table->string('transaction_no', 64)->comment('交易流水号');
|
||||
$table->string('pay_channel', 20)->default('')->comment('支付频道');
|
||||
$table->integer('unit_price')->unsigned()->default(0)->comment('单价');
|
||||
$table->integer('counts')->unsigned()->default(0)->comment('数量');
|
||||
$table->integer('total_price')->unsigned()->default(0)->comment('总价');
|
||||
$table->timestamp('order_at')->nullable()->comment('下单时间');
|
||||
$table->text('remark')->nullable()->comment('订单备注');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->index('type');
|
||||
$table->index('company_id');
|
||||
$table->index('order_at');
|
||||
|
||||
$table->comment("{$type}增值包订单");
|
||||
});
|
||||
}
|
||||
|
||||
Schema::create("real_orders", function (Blueprint $table) {
|
||||
$table->increments('id')->comment('订单ID');
|
||||
$table->string('sn', 32)->comment('订单编号');
|
||||
$table->tinyInteger('type')->unsigned()->default(0)->comment('订单类型(0:基础套餐)');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment("企业ID");
|
||||
$table->string('transaction_no', 64)->comment('交易流水号');
|
||||
$table->string('pay_channel', 20)->default('')->comment('支付频道');
|
||||
$table->integer('unit_price')->unsigned()->default(0)->comment('单价');
|
||||
$table->integer('counts')->unsigned()->default(0)->comment('数量');
|
||||
$table->integer('total_price')->unsigned()->default(0)->comment('总价');
|
||||
$table->timestamp('order_at')->nullable()->comment('下单时间');
|
||||
$table->string('address')->default('')->comment('收货地址');
|
||||
$table->string('contacts')->default('')->comment('联系人');
|
||||
$table->string('mobile')->default('')->comment('电话');
|
||||
$table->text('logistics_remark')->nullable()->comment('物流备注');
|
||||
$table->text('remark')->nullable()->comment('订单备注');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->index('type');
|
||||
$table->index('company_id');
|
||||
$table->index('order_at');
|
||||
|
||||
$table->comment('RD订单');
|
||||
});
|
||||
|
||||
Schema::create("blocs", function (Blueprint $table) {
|
||||
$table->increments('id')->comment('集团ID');
|
||||
$table->string('sn', 32)->comment('集团编号');
|
||||
$table->string('name', 32)->comment('集团名称');
|
||||
$table->string('shorthand', 32)->comment('英文简称');
|
||||
$table->tinyInteger('carrier_operator')->unsigned()->default(255)->comment('运营商(0:联通 1:移动 2:电信)');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->index('name');
|
||||
$table->index('carrier_operator');
|
||||
|
||||
$table->comment('卡源集团');
|
||||
});
|
||||
|
||||
Schema::create("cards", function (Blueprint $table) {
|
||||
$table->bigInteger('sim')->unsigned()->default(0)->comment('sim号');
|
||||
$table->string('imsi', 32)->default('')->comment('imsi号');
|
||||
$table->string('iccid', 32)->default('')->comment('iccid号');
|
||||
$table->integer('bloc_id')->unsigned()->default(0)->comment('来源集团ID');
|
||||
$table->tinyInteger('carrier_operator')->unsigned()->default(255)->comment('运营商(0:联通 1:移动 2:电信)');
|
||||
$table->timestamp('activate_at')->nullable()->comment('激活时间');
|
||||
$table->timestamp('virtual_activate_at')->nullable()->comment('虚拟激活时间');
|
||||
$table->tinyInteger('type')->unsigned()->default(0)->comment('类型(0:真实卡 1:虚拟卡)');
|
||||
$table->timestamps();
|
||||
|
||||
$table->primary('sim');
|
||||
$table->comment('卡基础信息表');
|
||||
});
|
||||
|
||||
Schema::create("virtual_company_accounts", function (Blueprint $table) {
|
||||
$table->increments('id')->comment('自增ID');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
|
||||
$table->string('nickname', 32)->default('')->comment('昵称');
|
||||
$table->string('mobile', 20)->default('')->comment('手机号');
|
||||
$table->string('username', 32)->default('')->comment('登录名');
|
||||
$table->string('password', 32)->default('')->comment('密码');
|
||||
$table->string('salt', 6)->default('')->comment('盐');
|
||||
$table->tinyInteger('status')->unsigned()->default(0)->comment('状态 0未激活 1正常 2禁用');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['mobile', 'deleted_at']);
|
||||
$table->comment('VD企业账号表');
|
||||
});
|
||||
|
||||
Schema::create("virtual_company_addresses", function (Blueprint $table) {
|
||||
$table->increments('id')->comment('自增ID');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
|
||||
$table->string('contacts', 20)->default('')->comment('联系人');
|
||||
$table->string('mobile', 20)->default('')->comment('手机号');
|
||||
$table->string('area')->default('')->comment('区域');
|
||||
$table->string('address')->default('')->comment('地址');
|
||||
$table->tinyInteger('default')->unsigned()->default(0)->comment('是否默认 0:不是 1:是');
|
||||
$table->tinyInteger('status')->unsigned()->default(0)->comment('状态 0:正常 1:禁用');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->comment('VD企业收货地址表');
|
||||
});
|
||||
|
||||
Schema::create("virtual_products", function (Blueprint $table) {
|
||||
$table->increments('id')->comment('自增ID');
|
||||
$table->string('sn', 32)->comment('产品编码');
|
||||
$table->string('name', 32)->comment('产品名称');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
|
||||
$table->integer('package_id')->unsigned()->default(0)->comment('套餐ID');
|
||||
$table->integer('base_price')->unsigned()->default(0)->comment('基础价格');
|
||||
$table->integer('renewal_price')->unsigned()->default(0)->comment('续费价格');
|
||||
$table->text('remark')->nullable()->comment('备注');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
|
||||
$table->comment('VD企业定价表');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
foreach (app(Dicts::class)->get('tables') as $prefix => $type) {
|
||||
Schema::dropIfExists("{$prefix}_added_orders");
|
||||
Schema::dropIfExists("{$prefix}_orders");
|
||||
Schema::dropIfExists("{$prefix}_order_cards");
|
||||
Schema::dropIfExists("{$prefix}_packages");
|
||||
Schema::dropIfExists("{$prefix}_companies");
|
||||
}
|
||||
|
||||
Schema::dropIfExists("cards");
|
||||
Schema::dropIfExists("blocs");
|
||||
Schema::dropIfExists("virtual_products");
|
||||
Schema::dropIfExists("virtual_company_addresses");
|
||||
Schema::dropIfExists("virtual_company_accounts");
|
||||
}
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Dicts;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateOrderTables extends Migration
|
||||
{
|
||||
protected $tables = [
|
||||
'added_order_renewal_cards' => '卡关联可选包订单',
|
||||
'added_order_renewal_package_cards' => '卡关联加油包订单',
|
||||
'added_order_flows_package_cards' => '卡关联续费包订单',
|
||||
'added_order_optional_package_cards' => '卡关联续费订单',
|
||||
'added_order_additional_package_cards' => '卡关联基础订单',
|
||||
];
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
foreach (app(Dicts::class)->get('tables') as $prefix => $type) {
|
||||
foreach ($this->tables as $table_name => $table_comment) {
|
||||
$table_name = $prefix . '_' . $table_name;
|
||||
$table_comment = $type . $table_comment;
|
||||
Schema::create($table_name, function (Blueprint $table) use ($prefix, $table_comment) {
|
||||
$table->integer('order_id')->unsigned()->default(0)->comment('订单ID');
|
||||
$table->bigInteger('sim')->unsigned()->default(0)->comment('SIM卡号');
|
||||
|
||||
if ($prefix === 'virtual') {
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment("企业ID");
|
||||
$table->integer('package_id')->unsigned()->default(0)->comment('套餐ID');
|
||||
}
|
||||
|
||||
$table->integer('counts')->unsigned()->default(1)->comment('数量');
|
||||
$table->integer('unit_price')->unsigned()->default(0)->comment('单价');
|
||||
$table->primary(['order_id', 'sim']);
|
||||
$table->comment($table_comment);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
foreach (app(Dicts::class)->get('tables') as $prefix => $type) {
|
||||
foreach ($this->tables as $table_name => $table_comment) {
|
||||
$table_name = $prefix . '_' . $table_name;
|
||||
Schema::dropIfExists($table_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
<?php
|
||||
|
||||
use App\Dicts;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreatePackageTables extends Migration
|
||||
{
|
||||
protected $tables = [
|
||||
'real_package_renewal_cards' => '卡关联续费套餐',
|
||||
'real_package_renewal_package_cards' => '卡关联续费包套餐',
|
||||
'real_package_flows_package_cards' => '卡关联加油包套餐',
|
||||
'real_package_optional_package_cards' => '卡关联可选包套餐',
|
||||
'real_package_additional_package_cards' => '卡关联附加套餐',
|
||||
];
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
foreach ($this->tables as $table_name => $table_comment) {
|
||||
Schema::create($table_name, function (Blueprint $table) use ($table_comment) {
|
||||
$table->integer('package_id')->unsigned()->default(0)->comment('套餐ID');
|
||||
$table->bigInteger('sim')->unsigned()->default(0)->comment('SIM卡号');
|
||||
$table->primary(['package_id', 'sim']);
|
||||
$table->comment($table_comment);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
foreach ($this->tables as $table_name => $table_comment) {
|
||||
Schema::dropIfExists($table_name);
|
||||
}
|
||||
}
|
||||
}
|
46
database/migrations/2018_12_24_164210_create_blocs_table.php
Normal file
46
database/migrations/2018_12_24_164210_create_blocs_table.php
Normal file
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateBlocsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('blocs')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('blocs', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('集团ID');
|
||||
$table->string('sn', 32)->comment('集团编号');
|
||||
$table->string('name', 32)->comment('集团名称');
|
||||
$table->string('shorthand', 32)->comment('英文简称');
|
||||
$table->tinyInteger('carrier_operator')->unsigned()->default(255)->comment('运营商(0:联通 1:移动 2:电信)');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->index('name');
|
||||
$table->index('carrier_operator');
|
||||
|
||||
$table->comment('卡源集团');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('blocs');
|
||||
}
|
||||
}
|
45
database/migrations/2018_12_24_164218_create_cards_table.php
Normal file
45
database/migrations/2018_12_24_164218_create_cards_table.php
Normal file
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateCardsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('cards')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('cards', function (Blueprint $table) {
|
||||
$table->bigInteger('sim')->unsigned()->default(0)->comment('sim号');
|
||||
$table->string('imsi', 32)->default('')->comment('imsi号');
|
||||
$table->string('iccid', 32)->default('')->comment('iccid号');
|
||||
$table->integer('bloc_id')->unsigned()->default(0)->comment('来源集团ID');
|
||||
$table->tinyInteger('carrier_operator')->unsigned()->default(255)->comment('运营商(0:联通 1:移动 2:电信)');
|
||||
$table->timestamp('activate_at')->nullable()->comment('激活时间');
|
||||
$table->timestamp('virtual_activate_at')->nullable()->comment('虚拟激活时间');
|
||||
$table->tinyInteger('type')->unsigned()->default(0)->comment('类型(0:真实卡 1:虚拟卡)');
|
||||
$table->timestamps();
|
||||
|
||||
$table->primary('sim');
|
||||
$table->comment('卡基础信息表');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('cards');
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateRealCompaniesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('real_companies')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('real_companies', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('企业ID');
|
||||
$table->string('sn', 32)->comment('企业编号');
|
||||
$table->string('name', 32)->default('')->comment('企业名称');
|
||||
$table->string('contacts', 20)->default('')->comment('联系人');
|
||||
$table->string('mobile', 20)->default('')->comment('手机号');
|
||||
$table->string('address')->default('')->comment('地址');
|
||||
$table->text('remark')->nullable()->comment('订单备注');
|
||||
$table->text('extends')->nullable()->comment('扩展信息');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->comment("RD企业");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('real_companies');
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateRealPackagesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('real_packages')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('real_packages', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('企业ID');
|
||||
$table->integer('parent_id')->unsigned()->default(0)->comment('父级ID');
|
||||
$table->string('sn', 20)->comment('套餐编号');
|
||||
$table->string('name', 32)->comment('套餐名称');
|
||||
$table->tinyInteger('type')->unsigned()->default(255)->comment('套餐类型(0:基础套餐 1:续费包 2:加油包 3:可选包 4:附加包)');
|
||||
$table->tinyInteger('carrier_operator')->unsigned()->default(255)->comment('运营商(0:联通 1:移动 2:电信)');
|
||||
$table->integer('cost_price')->unsigned()->default(0)->comment('成本价格');
|
||||
$table->integer('guide_price')->unsigned()->default(0)->comment('指导价格');
|
||||
$table->integer('renewal_cost_price')->unsigned()->default(0)->comment('续费成本价格');
|
||||
$table->integer('renewal_guide_price')->unsigned()->default(0)->comment('续费指导价格');
|
||||
$table->integer('flows')->unsigned()->default(0)->comment('套餐流量(M)');
|
||||
$table->integer('voices')->unsigned()->default(0)->comment('套餐语音(分钟)');
|
||||
$table->integer('messages')->unsigned()->default(0)->comment('套餐短信(条)');
|
||||
$table->tinyInteger('has_messages')->unsigned()->default(255)->comment('是否开通短信服务(0:无 1:有)');
|
||||
$table->tinyInteger('has_lbs')->unsigned()->default(255)->comment('是否开通LBS服务(0:无 1:有)');
|
||||
$table->tinyInteger('reset_months')->unsigned()->default(0)->comment('重置周期(月)');
|
||||
$table->tinyInteger('service_months')->unsigned()->default(0)->comment('套餐周期(月)');
|
||||
$table->tinyInteger('effect_months')->unsigned()->default(0)->comment('生效延迟周期(月)');
|
||||
$table->tinyInteger('delay_months')->unsigned()->default(0)->comment('服务延长周期(月)');
|
||||
$table->text('description')->nullable()->comment('描述');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->index('name');
|
||||
$table->index('parent_id');
|
||||
$table->index('type');
|
||||
$table->index('carrier_operator');
|
||||
|
||||
$table->comment("RD套餐");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('real_packages');
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateRealOrdersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('real_orders')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('real_orders', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('订单ID');
|
||||
$table->string('sn', 32)->comment('订单编号');
|
||||
$table->tinyInteger('type')->unsigned()->default(0)->comment('订单类型(0:基础套餐)');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment("企业ID");
|
||||
$table->string('transaction_no', 64)->comment('交易流水号');
|
||||
$table->string('pay_channel', 20)->default('')->comment('支付频道');
|
||||
$table->integer('unit_price')->unsigned()->default(0)->comment('单价');
|
||||
$table->integer('counts')->unsigned()->default(0)->comment('数量');
|
||||
$table->integer('total_price')->unsigned()->default(0)->comment('总价');
|
||||
$table->timestamp('order_at')->nullable()->comment('下单时间');
|
||||
$table->string('address')->default('')->comment('收货地址');
|
||||
$table->string('contacts')->default('')->comment('联系人');
|
||||
$table->string('mobile')->default('')->comment('电话');
|
||||
$table->text('logistics_remark')->nullable()->comment('物流备注');
|
||||
$table->text('remark')->nullable()->comment('订单备注');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->index('type');
|
||||
$table->index('company_id');
|
||||
$table->index('order_at');
|
||||
|
||||
$table->comment('RD订单');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('real_orders');
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateRealOrderCardsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('real_order_cards')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('real_order_cards', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('关联表ID');
|
||||
$table->bigInteger('sim')->unsigned()->default(0)->comment('sim号');
|
||||
$table->integer('order_id')->unsigned()->default(0)->comment('订单ID');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
|
||||
$table->integer('package_id')->unsigned()->default(0)->comment('套餐ID');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sim', 'order_id']);
|
||||
$table->unique(['sim', 'deleted_at']);
|
||||
|
||||
$table->comment("RD订单企业套餐卡关联表");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('real_order_cards');
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateRealAddedOrdersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('real_added_orders')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('real_added_orders', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('订单ID');
|
||||
$table->string('sn', 32)->comment('订单编号');
|
||||
$table->tinyInteger('type')->unsigned()->default(0)->comment('订单类型(1:套餐续费 2:续费包 3:加油包 4:可选包 5:附加包)');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
|
||||
$table->string('transaction_no', 64)->comment('交易流水号');
|
||||
$table->string('pay_channel', 20)->default('')->comment('支付频道');
|
||||
$table->integer('unit_price')->unsigned()->default(0)->comment('单价');
|
||||
$table->integer('counts')->unsigned()->default(0)->comment('数量');
|
||||
$table->integer('total_price')->unsigned()->default(0)->comment('总价');
|
||||
$table->timestamp('order_at')->nullable()->comment('下单时间');
|
||||
$table->text('remark')->nullable()->comment('订单备注');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->index('type');
|
||||
$table->index('company_id');
|
||||
$table->index('order_at');
|
||||
|
||||
$table->comment("RD增值包订单");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('real_added_orders');
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateRealAddedOrderCardsTables extends Migration
|
||||
{
|
||||
protected $tables = [
|
||||
'real_added_order_renewal_cards' => 'RD卡关联基础订单',
|
||||
'real_added_order_renewal_package_cards' => 'RD卡关联续费包订单',
|
||||
'real_added_order_flows_package_cards' => 'RD卡关联加油包订单',
|
||||
'real_added_order_optional_package_cards' => 'RD卡关联可选包订单',
|
||||
'real_added_order_additional_package_cards' => 'RD卡关联附加包订单',
|
||||
];
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
foreach ($this->tables as $table_name => $table_comment) {
|
||||
if (Schema::hasTable($table_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Schema::create($table_name, function (Blueprint $table) use ($table_comment) {
|
||||
$table->integer('order_id')->unsigned()->default(0)->comment('订单ID');
|
||||
$table->bigInteger('sim')->unsigned()->default(0)->comment('SIM卡号');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
|
||||
$table->integer('package_id')->unsigned()->default(0)->comment('套餐ID');
|
||||
$table->integer('counts')->unsigned()->default(1)->comment('数量');
|
||||
$table->integer('unit_price')->unsigned()->default(0)->comment('单价');
|
||||
$table->primary(['order_id', 'sim']);
|
||||
$table->comment($table_comment);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
foreach ($this->tables as $table_name => $table_comment) {
|
||||
Schema::dropIfExists($table_name);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVirtualCompaniesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('virtual_companies')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('virtual_companies', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('企业ID');
|
||||
$table->string('sn', 32)->comment('企业编号');
|
||||
$table->string('name', 32)->default('')->comment('企业名称');
|
||||
$table->string('contacts', 20)->default('')->comment('联系人');
|
||||
$table->string('mobile', 20)->default('')->comment('手机号');
|
||||
$table->string('address')->default('')->comment('地址');
|
||||
$table->text('remark')->nullable()->comment('订单备注');
|
||||
$table->text('extends')->nullable()->comment('扩展信息');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->comment("VD企业");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('virtual_companies');
|
||||
}
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVirtualPackagesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('virtual_packages')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('virtual_packages', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('企业ID');
|
||||
$table->integer('parent_id')->unsigned()->default(0)->comment('父级ID');
|
||||
$table->string('sn', 20)->comment('套餐编号');
|
||||
$table->string('name', 32)->comment('套餐名称');
|
||||
$table->tinyInteger('type')->unsigned()->default(255)->comment('套餐类型(0:基础套餐 1:续费包 2:加油包 3:可选包 4:附加包)');
|
||||
$table->tinyInteger('carrier_operator')->unsigned()->default(255)->comment('运营商(0:联通 1:移动 2:电信)');
|
||||
$table->integer('cost_price')->unsigned()->default(0)->comment('成本价格');
|
||||
$table->integer('guide_price')->unsigned()->default(0)->comment('指导价格');
|
||||
$table->integer('renewal_cost_price')->unsigned()->default(0)->comment('续费成本价格');
|
||||
$table->integer('renewal_guide_price')->unsigned()->default(0)->comment('续费指导价格');
|
||||
$table->integer('flows')->unsigned()->default(0)->comment('套餐流量(M)');
|
||||
$table->integer('voices')->unsigned()->default(0)->comment('套餐语音(分钟)');
|
||||
$table->integer('messages')->unsigned()->default(0)->comment('套餐短信(条)');
|
||||
$table->tinyInteger('has_messages')->unsigned()->default(255)->comment('是否开通短信服务(0:无 1:有)');
|
||||
$table->tinyInteger('has_lbs')->unsigned()->default(255)->comment('是否开通LBS服务(0:无 1:有)');
|
||||
$table->tinyInteger('reset_months')->unsigned()->default(0)->comment('重置周期(月)');
|
||||
$table->tinyInteger('service_months')->unsigned()->default(0)->comment('套餐周期(月)');
|
||||
$table->tinyInteger('effect_months')->unsigned()->default(0)->comment('生效延迟周期(月)');
|
||||
$table->tinyInteger('delay_months')->unsigned()->default(0)->comment('服务延长周期(月)');
|
||||
$table->text('description')->nullable()->comment('描述');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->index('name');
|
||||
$table->index('parent_id');
|
||||
$table->index('type');
|
||||
$table->index('carrier_operator');
|
||||
|
||||
$table->comment("VD套餐");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('virtual_packages');
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVirtualCompanyAccountsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('virtual_company_accounts')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('virtual_company_accounts', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('自增ID');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
|
||||
$table->string('nickname', 32)->default('')->comment('昵称');
|
||||
$table->string('mobile', 20)->default('')->comment('手机号');
|
||||
$table->string('username', 32)->default('')->comment('登录名');
|
||||
$table->string('password', 32)->default('')->comment('密码');
|
||||
$table->string('salt', 6)->default('')->comment('盐');
|
||||
$table->tinyInteger('status')->unsigned()->default(0)->comment('状态 0未激活 1正常 2禁用');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['mobile', 'deleted_at']);
|
||||
$table->comment('VD企业账号表');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('virtual_company_accounts');
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVirtualCompanyAddressesTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('virtual_company_addresses')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('virtual_company_addresses', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('自增ID');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
|
||||
$table->string('contacts', 20)->default('')->comment('联系人');
|
||||
$table->string('mobile', 20)->default('')->comment('手机号');
|
||||
$table->string('area')->default('')->comment('区域');
|
||||
$table->string('address')->default('')->comment('地址');
|
||||
$table->tinyInteger('default')->unsigned()->default(0)->comment('是否默认 0:不是 1:是');
|
||||
$table->tinyInteger('status')->unsigned()->default(0)->comment('状态 0:正常 1:禁用');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->comment('VD企业收货地址表');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('virtual_company_addresses');
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVirtualProductsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('virtual_products')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('virtual_products', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('自增ID');
|
||||
$table->string('sn', 32)->comment('产品编码');
|
||||
$table->string('name', 32)->comment('产品名称');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
|
||||
$table->integer('package_id')->unsigned()->default(0)->comment('套餐ID');
|
||||
$table->integer('base_price')->unsigned()->default(0)->comment('基础价格');
|
||||
$table->integer('renewal_price')->unsigned()->default(0)->comment('续费价格');
|
||||
$table->text('remark')->nullable()->comment('备注');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
|
||||
$table->comment('VD企业定价表');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('virtual_products');
|
||||
}
|
||||
}
|
@ -13,19 +13,23 @@ class CreateVirtualOrdersTable extends Migration
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('virtual_orders')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create("virtual_orders", function (Blueprint $table) {
|
||||
$table->increments('id')->comment('订单ID');
|
||||
$table->string('sn', 32)->comment('订单编号');
|
||||
$table->tinyInteger('type')->unsigned()->default(0)->comment('订单类型(0:基础套餐)');
|
||||
$table->tinyInteger('type')->unsigned()->default(0)->comment('订单类型(0:用户订单 1:后台订单)');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment("企业ID");
|
||||
$table->integer('package_id')->unsigned()->default(0)->after('company_id')->comment('套餐ID');
|
||||
$table->integer('product_id')->unsigned()->default(0)->after('package_id')->comment('定价ID');
|
||||
$table->integer('package_id')->unsigned()->default(0)->comment('套餐ID');
|
||||
$table->integer('product_id')->unsigned()->default(0)->comment('定价ID');
|
||||
$table->string('transaction_no', 64)->default('')->comment('交易流水号');
|
||||
$table->string('pay_channel', 20)->default('')->comment('支付频道');
|
||||
$table->integer('unit_price')->unsigned()->default(0)->comment('单价');
|
||||
$table->integer('counts')->unsigned()->default(0)->comment('数量');
|
||||
$table->integer('total_price')->unsigned()->default(0)->comment('总价');
|
||||
$table->integer('custom_price')->unsigned()->default(0)->after('total_price')->comment('自定义总价');
|
||||
$table->integer('custom_price')->unsigned()->default(0)->comment('自定义总价');
|
||||
$table->timestamp('order_at')->nullable()->comment('下单时间');
|
||||
$table->string('area')->default('')->comment('区域');
|
||||
$table->string('address')->default('')->comment('收货地址');
|
||||
@ -33,8 +37,8 @@ class CreateVirtualOrdersTable extends Migration
|
||||
$table->string('mobile')->default('')->comment('电话');
|
||||
$table->string('logistics_company', '20')->default('')->comment('物流公司');
|
||||
$table->string('logistics_no', 64)->default('')->comment('物流单号');
|
||||
$table->tinyInteger('order_status')->unsigned()->default(0)->after('mobile')->comment('订单状态(0:已下单 1:已取消 2:已出库 3:已发货 4:已签收)');
|
||||
$table->tinyInteger('transaction_status')->unsigned()->default(0)->after('order_status')->comment('收款状态(0:未收款 1:已收款 2:已退款)');
|
||||
$table->tinyInteger('order_status')->unsigned()->default(0)->comment('订单状态(0:已下单 1:已取消 2:已出库 3:已发货 4:已签收)');
|
||||
$table->tinyInteger('transaction_status')->unsigned()->default(0)->comment('收款状态(0:未收款 1:已收款 2:已退款)');
|
||||
$table->text('logistics_remark')->nullable()->comment('物流备注');
|
||||
$table->text('remark')->nullable()->comment('订单备注');
|
||||
$table->text('extends')->nullable()->comment('扩展信息(cancel_remark:取消备注 refund_channel:退款频道 refund_account:退款账号 refund_remark:退款备注)');
|
||||
@ -47,6 +51,8 @@ class CreateVirtualOrdersTable extends Migration
|
||||
$table->index('order_at');
|
||||
$table->comment('VD订单');
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVirtualOrderCardsTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('virtual_order_cards')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('virtual_order_cards', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('关联表ID');
|
||||
$table->bigInteger('sim')->unsigned()->default(0)->comment('sim号');
|
||||
$table->integer('order_id')->unsigned()->default(0)->comment('订单ID');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
|
||||
$table->integer('package_id')->unsigned()->default(0)->comment('套餐ID');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sim', 'order_id']);
|
||||
$table->unique(['sim', 'deleted_at']);
|
||||
|
||||
$table->comment("VD订单企业套餐卡关联表");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('virtual_order_cards');
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVirtualAddedOrdersTable extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
if (Schema::hasTable('virtual_added_orders')) {
|
||||
return;
|
||||
}
|
||||
|
||||
Schema::create('virtual_added_orders', function (Blueprint $table) {
|
||||
$table->increments('id')->comment('订单ID');
|
||||
$table->string('sn', 32)->comment('订单编号');
|
||||
$table->tinyInteger('type')->unsigned()->default(0)->comment('订单类型(1:套餐续费 2:续费包 3:加油包 4:可选包 5:附加包)');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
|
||||
$table->string('transaction_no', 64)->comment('交易流水号');
|
||||
$table->string('pay_channel', 20)->default('')->comment('支付频道');
|
||||
$table->integer('unit_price')->unsigned()->default(0)->comment('单价');
|
||||
$table->integer('counts')->unsigned()->default(0)->comment('数量');
|
||||
$table->integer('total_price')->unsigned()->default(0)->comment('总价');
|
||||
$table->integer('custom_price')->unsigned()->default(0)->comment('自定义总价');
|
||||
$table->timestamp('order_at')->nullable()->comment('下单时间');
|
||||
$table->text('remark')->nullable()->comment('订单备注');
|
||||
$table->timestamps();
|
||||
$table->softDeletes();
|
||||
|
||||
$table->unique(['sn', 'deleted_at']);
|
||||
$table->index('type');
|
||||
$table->index('company_id');
|
||||
$table->index('order_at');
|
||||
|
||||
$table->comment("VD增值包订单");
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::dropIfExists('virtual_added_orders');
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
|
||||
class CreateVirtualAddedOrderCardsTables extends Migration
|
||||
{
|
||||
protected $tables = [
|
||||
'virtual_added_order_renewal_cards' => 'VD卡关联基础订单',
|
||||
'virtual_added_order_renewal_package_cards' => 'VD卡关联续费包订单',
|
||||
'virtual_added_order_flows_package_cards' => 'VD卡关联加油包订单',
|
||||
'virtual_added_order_optional_package_cards' => 'VD卡关联可选包订单',
|
||||
'virtual_added_order_additional_package_cards' => 'VD卡关联附加包订单',
|
||||
];
|
||||
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
foreach ($this->tables as $table_name => $table_comment) {
|
||||
if (Schema::hasTable($table_name)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Schema::create($table_name, function (Blueprint $table) use ($table_comment) {
|
||||
$table->integer('order_id')->unsigned()->default(0)->comment('订单ID');
|
||||
$table->bigInteger('sim')->unsigned()->default(0)->comment('SIM卡号');
|
||||
$table->integer('company_id')->unsigned()->default(0)->comment('企业ID');
|
||||
$table->integer('package_id')->unsigned()->default(0)->comment('套餐ID');
|
||||
$table->integer('counts')->unsigned()->default(1)->comment('数量');
|
||||
$table->integer('unit_price')->unsigned()->default(0)->comment('单价');
|
||||
$table->primary(['order_id', 'sim']);
|
||||
$table->comment($table_comment);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
foreach ($this->tables as $table_name => $table_comment) {
|
||||
Schema::dropIfExists($table_name);
|
||||
}
|
||||
}
|
||||
}
|
23
vendor/composer/autoload_classmap.php
vendored
23
vendor/composer/autoload_classmap.php
vendored
@ -10,12 +10,25 @@ return array(
|
||||
'ArithmeticError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php',
|
||||
'AssertionError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/AssertionError.php',
|
||||
'CompanyAccountSeeder' => $baseDir . '/database/seeds/CompanyAccountSeeder.php',
|
||||
'CreateBaseTables' => $baseDir . '/database/migrations/2018_11_27_175137_create_base_tables.php',
|
||||
'CreateBlocsTable' => $baseDir . '/database/migrations/2018_12_24_164210_create_blocs_table.php',
|
||||
'CreateCardsTable' => $baseDir . '/database/migrations/2018_12_24_164218_create_cards_table.php',
|
||||
'CreateFailedJobsTable' => $baseDir . '/database/migrations/2018_11_16_190020_create_failed_jobs_table.php',
|
||||
'CreateOrderTables' => $baseDir . '/database/migrations/2018_11_27_175146_create_order_tables.php',
|
||||
'CreatePackageTables' => $baseDir . '/database/migrations/2018_11_27_175152_create_package_tables.php',
|
||||
'CreateTestsTable' => $baseDir . '/database/migrations/2018_12_21_134548_create_tests_table.php',
|
||||
'CreateVirtualOrdersTable' => $baseDir . '/database/migrations/2018_12_12_170419_create_virtual_orders_table.php',
|
||||
'CreateRealAddedOrderCardsTables' => $baseDir . '/database/migrations/2018_12_24_164459_create_real_added_order_cards_tables.php',
|
||||
'CreateRealAddedOrdersTable' => $baseDir . '/database/migrations/2018_12_24_164457_create_real_added_orders_table.php',
|
||||
'CreateRealCompaniesTable' => $baseDir . '/database/migrations/2018_12_24_164318_create_real_companies_table.php',
|
||||
'CreateRealOrderCardsTable' => $baseDir . '/database/migrations/2018_12_24_164434_create_real_order_cards_table.php',
|
||||
'CreateRealOrdersTable' => $baseDir . '/database/migrations/2018_12_24_164430_create_real_orders_table.php',
|
||||
'CreateRealPackageCardsTables' => $baseDir . '/database/migrations/2018_12_24_164462_create_real_package_cards_tables.php',
|
||||
'CreateRealPackagesTable' => $baseDir . '/database/migrations/2018_12_24_164423_create_real_packages_table.php',
|
||||
'CreateVirtualAddedOrderCardsTables' => $baseDir . '/database/migrations/2018_12_24_170946_create_virtual_added_order_cards_tables.php',
|
||||
'CreateVirtualAddedOrdersTable' => $baseDir . '/database/migrations/2018_12_24_170936_create_virtual_added_orders_table.php',
|
||||
'CreateVirtualCompaniesTable' => $baseDir . '/database/migrations/2018_12_24_164716_create_virtual_companies_table.php',
|
||||
'CreateVirtualCompanyAccountsTable' => $baseDir . '/database/migrations/2018_12_24_164728_create_virtual_company_accounts_table.php',
|
||||
'CreateVirtualCompanyAddressesTable' => $baseDir . '/database/migrations/2018_12_24_164735_create_virtual_company_addresses_table.php',
|
||||
'CreateVirtualOrderCardsTable' => $baseDir . '/database/migrations/2018_12_24_165555_create_virtual_order_cards_table.php',
|
||||
'CreateVirtualOrdersTable' => $baseDir . '/database/migrations/2018_12_24_164779_create_virtual_orders_table.php',
|
||||
'CreateVirtualPackagesTable' => $baseDir . '/database/migrations/2018_12_24_164722_create_virtual_packages_table.php',
|
||||
'CreateVirtualProductsTable' => $baseDir . '/database/migrations/2018_12_24_164742_create_virtual_products_table.php',
|
||||
'DatabaseSeeder' => $baseDir . '/database/seeds/DatabaseSeeder.php',
|
||||
'DivisionByZeroError' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php',
|
||||
'Error' => $vendorDir . '/symfony/polyfill-php70/Resources/stubs/Error.php',
|
||||
|
23
vendor/composer/autoload_static.php
vendored
23
vendor/composer/autoload_static.php
vendored
@ -713,12 +713,25 @@ class ComposerStaticInite79258a3e34ad3e251999111d9f334d9
|
||||
'ArithmeticError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/ArithmeticError.php',
|
||||
'AssertionError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/AssertionError.php',
|
||||
'CompanyAccountSeeder' => __DIR__ . '/../..' . '/database/seeds/CompanyAccountSeeder.php',
|
||||
'CreateBaseTables' => __DIR__ . '/../..' . '/database/migrations/2018_11_27_175137_create_base_tables.php',
|
||||
'CreateBlocsTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164210_create_blocs_table.php',
|
||||
'CreateCardsTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164218_create_cards_table.php',
|
||||
'CreateFailedJobsTable' => __DIR__ . '/../..' . '/database/migrations/2018_11_16_190020_create_failed_jobs_table.php',
|
||||
'CreateOrderTables' => __DIR__ . '/../..' . '/database/migrations/2018_11_27_175146_create_order_tables.php',
|
||||
'CreatePackageTables' => __DIR__ . '/../..' . '/database/migrations/2018_11_27_175152_create_package_tables.php',
|
||||
'CreateTestsTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_21_134548_create_tests_table.php',
|
||||
'CreateVirtualOrdersTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_12_170419_create_virtual_orders_table.php',
|
||||
'CreateRealAddedOrderCardsTables' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164459_create_real_added_order_cards_tables.php',
|
||||
'CreateRealAddedOrdersTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164457_create_real_added_orders_table.php',
|
||||
'CreateRealCompaniesTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164318_create_real_companies_table.php',
|
||||
'CreateRealOrderCardsTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164434_create_real_order_cards_table.php',
|
||||
'CreateRealOrdersTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164430_create_real_orders_table.php',
|
||||
'CreateRealPackageCardsTables' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164462_create_real_package_cards_tables.php',
|
||||
'CreateRealPackagesTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164423_create_real_packages_table.php',
|
||||
'CreateVirtualAddedOrderCardsTables' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_170946_create_virtual_added_order_cards_tables.php',
|
||||
'CreateVirtualAddedOrdersTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_170936_create_virtual_added_orders_table.php',
|
||||
'CreateVirtualCompaniesTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164716_create_virtual_companies_table.php',
|
||||
'CreateVirtualCompanyAccountsTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164728_create_virtual_company_accounts_table.php',
|
||||
'CreateVirtualCompanyAddressesTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164735_create_virtual_company_addresses_table.php',
|
||||
'CreateVirtualOrderCardsTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_165555_create_virtual_order_cards_table.php',
|
||||
'CreateVirtualOrdersTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164779_create_virtual_orders_table.php',
|
||||
'CreateVirtualPackagesTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164722_create_virtual_packages_table.php',
|
||||
'CreateVirtualProductsTable' => __DIR__ . '/../..' . '/database/migrations/2018_12_24_164742_create_virtual_products_table.php',
|
||||
'DatabaseSeeder' => __DIR__ . '/../..' . '/database/seeds/DatabaseSeeder.php',
|
||||
'DivisionByZeroError' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/DivisionByZeroError.php',
|
||||
'Error' => __DIR__ . '/..' . '/symfony/polyfill-php70/Resources/stubs/Error.php',
|
||||
|
14
vendor/composer/installed.json
vendored
14
vendor/composer/installed.json
vendored
@ -641,18 +641,18 @@
|
||||
},
|
||||
{
|
||||
"name": "dipper/foundation",
|
||||
"version": "1.1.9",
|
||||
"version_normalized": "1.1.9.0",
|
||||
"version": "1.1.13",
|
||||
"version_normalized": "1.1.13.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "ssh://gogs@git.fxft.net:2222/composer/foundation.git",
|
||||
"reference": "94efaf5b1e21d1bc4f7bae4fc6c4d3f741b399d0"
|
||||
"reference": "7fa8390645a5cd52bc68666a9af9d8b008860200"
|
||||
},
|
||||
"dist": {
|
||||
"type": "tar",
|
||||
"url": "https://composer.fxft.online/dist/dipper/foundation/dipper-foundation-1.1.9-51f1b8.tar",
|
||||
"reference": "94efaf5b1e21d1bc4f7bae4fc6c4d3f741b399d0",
|
||||
"shasum": "b17959dd9990df31f7e6c3cff53749afe151f670"
|
||||
"url": "https://composer.fxft.online/dist/dipper/foundation/dipper-foundation-1.1.13-c3e049.tar",
|
||||
"reference": "7fa8390645a5cd52bc68666a9af9d8b008860200",
|
||||
"shasum": "e8c31e9bf07ea46e491c969a83465fc969f7e96e"
|
||||
},
|
||||
"require": {
|
||||
"barryvdh/laravel-cors": "~0.11",
|
||||
@ -667,7 +667,7 @@
|
||||
"league/flysystem": "~1.0",
|
||||
"nesbot/carbon": "~1.21"
|
||||
},
|
||||
"time": "2018-12-21T07:43:51+00:00",
|
||||
"time": "2018-12-24T06:42:58+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
|
@ -177,7 +177,7 @@ class DatabaseServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function macroUpsert()
|
||||
{
|
||||
return function (array $values, $filed = 'id') {
|
||||
return function (array $values, $fields = ['id'], $doNoting = false) {
|
||||
if (empty($values)) {
|
||||
return false;
|
||||
}
|
||||
@ -191,7 +191,7 @@ class DatabaseServiceProvider extends ServiceProvider
|
||||
}
|
||||
|
||||
return $this->connection->affectingStatement(
|
||||
$this->grammar->compileUpsert($this, $values, $filed),
|
||||
$this->grammar->compileUpsert($this, $values, $fields, $doNoting),
|
||||
$this->cleanBindings(Arr::flatten($values, 1))
|
||||
);
|
||||
};
|
||||
|
@ -210,8 +210,12 @@ class MySqlGrammar extends Grammar
|
||||
* @param array|string $unique
|
||||
* @return string
|
||||
*/
|
||||
public function compileUpsert(QueryBuilder $query, array $values, $filed = ['id'])
|
||||
public function compileUpsert(QueryBuilder $query, array $values, $filed = ['id'], $doNothing = false)
|
||||
{
|
||||
if ($doNothing) {
|
||||
return $this->compileCreateOrIgnore($query, $values);
|
||||
}
|
||||
|
||||
return $this->compileInsertUpdate($query, $values);
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class PostgresGrammar extends Grammar
|
||||
* @param array|string $unique
|
||||
* @return string
|
||||
*/
|
||||
public function compileUpsert(QueryBuilder $query, array $values, $fields = ['id'])
|
||||
public function compileUpsert(QueryBuilder $query, array $values, $fields = ['id'], $doNothing = false)
|
||||
{
|
||||
$insert = $this->compileInsert($query, $values);
|
||||
|
||||
@ -98,6 +98,10 @@ class PostgresGrammar extends Grammar
|
||||
return "$insert on conflict ($reference) do nothing";
|
||||
}
|
||||
|
||||
if ($doNothing) {
|
||||
return "$insert on conflict ($reference) do nothing";
|
||||
}
|
||||
|
||||
$update = join(', ', array_map(function ($e) {
|
||||
return "\"$e\" = \"excluded\".\"$e\"";
|
||||
}, $excluded));
|
||||
|
@ -140,6 +140,12 @@ class ServiceProvider extends BaseServiceProvider
|
||||
public function bootMacro()
|
||||
{
|
||||
Request::mixin(app(\Dipper\Foundation\Http\RequestMixin::class));
|
||||
|
||||
Collection::macro('collect', function () {
|
||||
return $this->map(function ($value) {
|
||||
return collect((array) $value);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user