同步增值包
This commit is contained in:
parent
b551c5bad8
commit
dc5d701299
@ -20,6 +20,8 @@ class AddedOrderSync extends Command
|
||||
|
||||
protected $chunks = 1000;
|
||||
|
||||
protected $types;
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->datetime = $this->getDateTime();
|
||||
@ -29,6 +31,10 @@ class AddedOrderSync extends Command
|
||||
$orders = $this->getOrders();
|
||||
$orderItems = $this->getOrderItems($orders);
|
||||
|
||||
foreach ($orders as &$item) {
|
||||
$item['type'] = $this->types[$item['sn']] ?? 255;
|
||||
}
|
||||
|
||||
$dataOrderCards = [];
|
||||
$dataPackageCards = [];
|
||||
|
||||
@ -36,8 +42,8 @@ class AddedOrderSync extends Command
|
||||
$dataOrderCards[$value['type']][] = [
|
||||
'sim' => $value['sim'],
|
||||
'order_id' => $value['order_id'],
|
||||
'counts' => $value['item_counts'],
|
||||
'unit_price' => $value['item_unit_price'],
|
||||
'counts' => $value['counts'],
|
||||
'unit_price' => $value['unit_price'],
|
||||
];
|
||||
|
||||
$dataPackageCards[$value['type']][] = [
|
||||
@ -53,7 +59,6 @@ class AddedOrderSync extends Command
|
||||
}
|
||||
app(AddedOrderRepository::class)->forgetCached();
|
||||
|
||||
|
||||
$this->line('插入订单关联数据,条数:'.count(array_collapse($dataOrderCards)));
|
||||
$tables = [
|
||||
'',
|
||||
@ -112,6 +117,7 @@ class AddedOrderSync extends Command
|
||||
];
|
||||
|
||||
$orders = DB::connection('real')->table('jxc_custom_order')->select($select)->where('status', 3)
|
||||
->whereIn('custom_no', $this->companies->keys())
|
||||
->where('create_time', '>=', $starttime->timestamp)
|
||||
->where('create_time', '<=', $endtime->timestamp)
|
||||
->orderBy('create_time')->get()->toArray();
|
||||
@ -122,7 +128,7 @@ class AddedOrderSync extends Command
|
||||
foreach ($orders as &$item) {
|
||||
$item = (array)$item;
|
||||
$item['company_id'] = $this->companies[$item['company_id']]['id'] ?? 0;
|
||||
$item['total_price'] = intval($item['total_price'] * 100);
|
||||
$item['total_price'] = floatval($item['total_price']) * 100;
|
||||
$item['counts'] = !empty($item['counts']) ? $item['counts'] : 1;
|
||||
$item['pay_channel'] = 0;
|
||||
|
||||
@ -132,7 +138,7 @@ class AddedOrderSync extends Command
|
||||
}
|
||||
}
|
||||
|
||||
$item['unit_price'] = intval($total_price/$item['counts']);
|
||||
$item['unit_price'] = intval($item['total_price']/$item['counts']);
|
||||
$item['order_at'] = date('Y-m-d H:i:s', $item['order_at']);
|
||||
$item['created_at'] = $item['order_at'];
|
||||
$item['updated_at'] = ($item['updated_at'] == '0000-00-00 00:00:00') ? $item['order_at'] : $item['updated_at'];
|
||||
@ -153,8 +159,8 @@ class AddedOrderSync extends Command
|
||||
'sim',
|
||||
'goods_no as package_id',
|
||||
'goods_type as type',
|
||||
'unit_price as item_unit_price',
|
||||
'quantity as item_counts',
|
||||
'unit_price as unit_price',
|
||||
'quantity as counts',
|
||||
];
|
||||
|
||||
$orderItems = DB::connection('real')->table('jxc_custom_order_item')->select($select)
|
||||
@ -164,9 +170,11 @@ class AddedOrderSync extends Command
|
||||
$item = (array)$item;
|
||||
$item['order_id'] = $orders[$item['order_sn']]['id'] ?? 0;
|
||||
$item['package_id'] = $this->packages[$item['package_id']]['id'] ?? 0;
|
||||
$item['unit_price'] = intval($item['item_unit_price'] * 100);
|
||||
$item['unit_price'] = floatval($item['unit_price']) * 100;
|
||||
}
|
||||
|
||||
$this->types = array_pluck($orderItems, 'type', 'order_sn');
|
||||
|
||||
return $orderItems;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Virtual\Repositories;
|
||||
|
||||
use App\Core\Repository;
|
||||
use App\Models\Virtual\CompanyAccount as Model;
|
||||
|
||||
class CompanyAccountRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* 是否关闭缓存
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $cacheSkip = false;
|
||||
|
||||
/**
|
||||
* 是否开启数据转化
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $needTransform = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $fieldSearchable = [
|
||||
'id' => '=',
|
||||
'created_at' => 'like',
|
||||
];
|
||||
|
||||
public function model() {
|
||||
return Model::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param mixed $result
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function transform($model)
|
||||
{
|
||||
return $model->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询条件
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function withConditions(array $conditions = [])
|
||||
{
|
||||
if (isset($conditions['id'])) {
|
||||
$conditions['id'] = array_wrap($conditions['id']);
|
||||
$this->model = $this->model->whereIn('id', $conditions['id']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Virtual\Repositories;
|
||||
|
||||
use App\Core\Repository;
|
||||
use App\Models\Virtual\CompanyAddress as Model;
|
||||
|
||||
class CompanyAddressRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* 是否关闭缓存
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $cacheSkip = false;
|
||||
|
||||
/**
|
||||
* 是否开启数据转化
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $needTransform = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $fieldSearchable = [
|
||||
'id' => '=',
|
||||
'created_at' => 'like',
|
||||
];
|
||||
|
||||
public function model() {
|
||||
return Model::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param mixed $result
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function transform($model)
|
||||
{
|
||||
return $model->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询条件
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function withConditions(array $conditions = [])
|
||||
{
|
||||
if (isset($conditions['id'])) {
|
||||
$conditions['id'] = array_wrap($conditions['id']);
|
||||
$this->model = $this->model->whereIn('id', $conditions['id']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
62
app/Domains/Virtual/Repositories/ProductRepository.php
Normal file
62
app/Domains/Virtual/Repositories/ProductRepository.php
Normal file
@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Domains\Virtual\Repositories;
|
||||
|
||||
use App\Core\Repository;
|
||||
use App\Models\Virtual\Product as Model;
|
||||
|
||||
class ProductRepository extends Repository
|
||||
{
|
||||
/**
|
||||
* 是否关闭缓存
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
protected $cacheSkip = false;
|
||||
|
||||
/**
|
||||
* 是否开启数据转化
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
protected $needTransform = false;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $fieldSearchable = [
|
||||
'id' => '=',
|
||||
'created_at' => 'like',
|
||||
];
|
||||
|
||||
public function model() {
|
||||
return Model::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* 数据格式化
|
||||
*
|
||||
* @param mixed $result
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function transform($model)
|
||||
{
|
||||
return $model->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询条件
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function withConditions(array $conditions = [])
|
||||
{
|
||||
if (isset($conditions['id'])) {
|
||||
$conditions['id'] = array_wrap($conditions['id']);
|
||||
$this->model = $this->model->whereIn('id', $conditions['id']);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
10
app/Models/Virtual/CompanyAccount.php
Normal file
10
app/Models/Virtual/CompanyAccount.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Virtual;
|
||||
|
||||
use App\Core\Model;
|
||||
|
||||
class CompanyAccount extends Model
|
||||
{
|
||||
protected $table = 'virtual_company_accounts';
|
||||
}
|
10
app/Models/Virtual/CompanyAddress.php
Normal file
10
app/Models/Virtual/CompanyAddress.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Virtual;
|
||||
|
||||
use App\Core\Model;
|
||||
|
||||
class CompanyAddress extends Model
|
||||
{
|
||||
protected $table = 'virtual_company_addresses';
|
||||
}
|
10
app/Models/Virtual/Product.php
Normal file
10
app/Models/Virtual/Product.php
Normal file
@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Virtual;
|
||||
|
||||
use App\Core\Model;
|
||||
|
||||
class Product extends Model
|
||||
{
|
||||
protected $table = 'virtual_products';
|
||||
}
|
@ -173,7 +173,7 @@ class CreateBaseTables extends Migration
|
||||
$table->unique('phone');
|
||||
});
|
||||
|
||||
Schema::create("virtual_company_address", function (Blueprint $table) {
|
||||
Schema::create("virtual_company_addresses", function (Blueprint $table) {
|
||||
$table->increments('id')->comment('自增ID');
|
||||
$table->string('company_id', 32)->comment('企业ID');
|
||||
$table->string('contacts', 20)->default('')->comment('联系人');
|
||||
@ -219,7 +219,7 @@ class CreateBaseTables extends Migration
|
||||
Schema::dropIfExists("cards");
|
||||
Schema::dropIfExists("blocs");
|
||||
Schema::dropIfExists("virtual_products");
|
||||
Schema::dropIfExists("virtual_company_address");
|
||||
Schema::dropIfExists("virtual_company_addresses");
|
||||
Schema::dropIfExists("virtual_company_accounts");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user