This commit is contained in:
邓皓元 2019-04-09 17:40:00 +08:00
parent 3c3a456393
commit 429835252b
5 changed files with 51 additions and 11 deletions

View File

@ -88,7 +88,7 @@ class AddedOrderSync extends Command
$starttime = $this->datetime->copy()->startOfMonth()->startOfDay();
$endtime = $this->datetime->copy()->endOfMonth()->endOfDay();
$orders = DB::table($virtualTable)->selectRaw('sim,MAX(order_id)')
$orders = DB::table($virtualTable)->selectRaw('sim, MAX(order_id)')
->where('created_at', '>=', $starttime->format('Y-m-d H:i:s'))
->where('created_at', '<=', $endtime->format('Y-m-d H:i:s'))
->whereIn('sim', array_pluck($data, 'sim'))
@ -101,7 +101,9 @@ class AddedOrderSync extends Command
MongoCardJob::dispatch(array_pluck($data, 'sim'));
DB::table($table)->upsert($data, ['sim', 'order_id']);
$only = ['company_id', 'package_id', 'counts', 'unit_price'];
DB::table($table)->upsert($data, ['sim', 'order_id', 'deleted_at'], $only);
}
}

View File

@ -56,8 +56,11 @@ class OrderBaseSync extends Command
MongoCardJob::dispatch(array_pluck($data, 'sim'));
DB::table('real_order_cards')->upsert($data, ['sim', 'deleted_at']);
$only = [ 'order_id', 'company_id', 'package_id', 'counts', 'unit_price'];
DB::table('real_order_cards')->upsert($data, ['sim', 'deleted_at'], $only);
}
app(OrderCardPartitionRepository::class)->forgetCached();
$this->line('插入订单关联数据成功');
});
@ -122,7 +125,7 @@ class OrderBaseSync extends Command
'order_at' => Carbon::parse($item['o_create_date'])->format('Y-m-d H:i:s'),
'address' => $item['o_address'],
'contacts' => $item['o_contacts'],
'mobile' => $item['o_contact_number'],
'mobile' => substr(preg_replace('/[^0-9]+/', '', single_case($item['o_contact_number'])), 0, 11),
'remark' => $item['o_remark'],
'logistics_remark' => $item['o_logistics_content'],
'created_at' => date('Y-m-d H:i:s', $item['o_create_time']),

View File

@ -244,3 +244,40 @@ if (! function_exists('range_compare')) {
return -1;
}
}
if (! function_exists('single_case')) {
/**
* 将一个字串中含有全角的数字字符、字母、空格或'%+-()'字符转换为相应半角字符
*
* @access public
* @param string $str 待转换字串
* @return string
*/
function single_case($str)
{
$arr = array('' => '0', '' => '1', '' => '2', '' => '3', '' => '4',
'' => '5', '' => '6', '' => '7', '' => '8', '' => '9',
'' => 'A', '' => 'B', '' => 'C', '' => 'D', '' => 'E',
'' => 'F', '' => 'G', '' => 'H', '' => 'I', '' => 'J',
'' => 'K', '' => 'L', '' => 'M', '' => 'N', '' => 'O',
'' => 'P', '' => 'Q', '' => 'R', '' => 'S', '' => 'T',
'' => 'U', '' => 'V', '' => 'W', '' => 'X', '' => 'Y',
'' => 'Z', '' => 'a', '' => 'b', '' => 'c', '' => 'd',
'' => 'e', '' => 'f', '' => 'g', '' => 'h', '' => 'i',
'' => 'j', '' => 'k', '' => 'l', '' => 'm', '' => 'n',
'' => 'o', '' => 'p', '' => 'q', '' => 'r', '' => 's',
'' => 't', '' => 'u', '' => 'v', '' => 'w', '' => 'x',
'' => 'y', '' => 'z',
'' => '(', '' => ')', '' => '[', '' => ']', '【' => '[',
'】' => ']', '〖' => '[', '〗' => ']', '“' => '[', '”' => ']',
'' => '[', '' => ']', '' => '{', '' => '}', '《' => '<',
'》' => '>',
'' => '%', '' => '+', '—' => '-', '' => '-', '' => '-',
'' => ':', '。' => '.', '、' => ',', '' => '.', '、' => '.',
'' => ',', '' => '?', '' => '!', '…' => '-', '‖' => '|',
'”' => '"', '' => '`', '' => '`', '' => '|', '〃' => '"',
' ' => ' ');
return strtr($str, $arr);
}
}

View File

@ -48,23 +48,23 @@ class CreateRealOrderCardsTable extends Migration
});
Schema::table('real_order_renewal_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id']);
$table->unique(['sim', 'order_id', 'deleted_at']);
});
Schema::table('real_order_renewal_package_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id']);
$table->unique(['sim', 'order_id', 'deleted_at']);
});
Schema::table('real_order_flows_package_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id']);
$table->unique(['sim', 'order_id', 'deleted_at']);
});
Schema::table('real_order_optional_package_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id']);
$table->unique(['sim', 'order_id', 'deleted_at']);
});
Schema::table('real_order_additional_package_cards', function (Blueprint $table) {
$table->unique(['sim', 'order_id']);
$table->unique(['sim', 'order_id', 'deleted_at']);
});
}

View File

@ -7,5 +7,3 @@ use Illuminate\Database\Schema\Blueprint;
use App\Domains\Virtual\Services\OrderService;
require_once realpath(dirname(__FILE__) . '/TestCase.php');
app(OrderService::class);