Commit c384929a by banice

修改定时任务订单充电时间从redis缓存中计算

parent 8641d689
No preview for this file type
...@@ -1455,7 +1455,7 @@ namespace Illuminate\Support\Facades { ...@@ -1455,7 +1455,7 @@ namespace Illuminate\Support\Facades {
} }
/** /**
* Run an update statement against the database. * Run an Update statement against the database.
* *
* @param string $query * @param string $query
* @param array $bindings * @param array $bindings
......
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/10/9
* Time: 下午7:00
*/
namespace App\Console\Commands\sync;
use Illuminate\Console\Command;
use DB;
class SyncPortFromStaging extends Command
{
protected $signature = 'sync:port_staging';
protected $description = '从staging环境同步网管口子';
/**
*
*/
public function handle()
{
$devices = DB::connection('old_cdz')->table('devices')->where('gateway_id', 1)->get()->toArray();
dd($devices);
return;
foreach ($devices as $device) {
if (DB::table('devices')->where('device_mac', $device['device_mac'])->exists() === false) {
DB::table('devices')->insert([
'device_mac' => $device['device_mac'],
'name' => $device['name'],
'gateway_id' => 9,
'station_id' => 5,
'created_at' => date('Y-m-d H:i:s'),
'type' => 1,
]);
}
}
}
}
\ No newline at end of file
...@@ -10,9 +10,9 @@ namespace App\Console\Commands\timer; ...@@ -10,9 +10,9 @@ namespace App\Console\Commands\timer;
use App\Model\LogGatewayModel; use App\Model\LogGatewayModel;
use Carbon\Carbon;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use DB; use DB;
use Lib\cdz_order\Order;
use Lib\redis\RedisSingle; use Lib\redis\RedisSingle;
use Log; use Log;
...@@ -26,14 +26,73 @@ class ScanOrderFinish extends Command ...@@ -26,14 +26,73 @@ class ScanOrderFinish extends Command
*/ */
protected $description = '定时器扫描订单是否已过时'; protected $description = '定时器扫描订单是否已过时';
private function scanf()
{
$date = date('Y-m-d H:i:s');
$expireOrders = DB::table('wx_charger_orders')->where('state', -1)->get(['start_time', 'charger_time', 'id', 'port_id', 'station_id', 'gateway_id']);
$redis = RedisSingle::getRedis();
$time = time();
$redis->multi(2);
$redis = RedisSingle::getRedis();
$order = new Order();
foreach ($expireOrders as $expireOrder) {
echo $expireOrder->id . PHP_EOL;
$order->setId($expireOrder->id);
$cache = $order->getOrderCache($redis);
if ($cache === false) {
$startTime = strtotime($expireOrder->start_time);
} else {
$startTime = $cache['startTime'];
}
if (($time - $startTime) > ($expireOrder->charger_time * 60 + 60 * 5)) {
Log::debug($expireOrder->id);
Log::debug($startTime);
$result = DB::table('wx_charger_orders')->where('id', $expireOrder->id)->update([
'end_time' => date('Y-m-d H:i:s', strtotime($expireOrder->start_time) + $expireOrder->charger_time * 60),
'updated_at' => $date,
'state' => 3,
'is_stop' => 46,
]);
DB::table('gateway_log')->insert([
'gateway_id' => $expireOrder->gateway_id,
'station_id' => $expireOrder->station_id,
'port_id' => $expireOrder->port_id,
'order_id' => $expireOrder->id,
'type' => 1,
'desc' => '系统自动结束订单',
'command' => 'ff'
]);
$redis->hDel('cdz:port:using:order_id:hash', $expireOrder->port_id);
$redis->zRem('cdz:port:using:user_id:zset', $expireOrder->port_id);
$redis->del('cdz:order:state:' . $expireOrder->id);
}
}
$redis->exec();
}
public function handle() public function handle()
{ {
$date = date('Y-m-d H:i:s'); $date = date('Y-m-d H:i:s');
$this->info($date);
$expireOrders = DB::table('wx_charger_orders')->where([ $expireOrders = DB::table('wx_charger_orders')->where([
['is_charger', '12'],//开始充电 ['is_charger', '12'],//开始充电
['end_time', null],//没有结束时间 ['end_time', null],//没有结束时间
...@@ -46,28 +105,38 @@ class ScanOrderFinish extends Command ...@@ -46,28 +105,38 @@ class ScanOrderFinish extends Command
$redis = RedisSingle::getRedis(); $redis = RedisSingle::getRedis();
$redis->multi(2); // $redis->multi(2);
$order = new Order();
foreach ($expireOrders as $expireOrder) { foreach ($expireOrders as $expireOrder) {
echo $expireOrder->id . PHP_EOL;
$order->setId($expireOrder->id);
$cache = $order->getOrderCache($redis);
if ($cache === false) {
$startTime = strtotime($expireOrder->start_time);
} else {
$startTime = $cache['startTime'];
if ($time > strtotime($expireOrder->start_time) + $expireOrder->charger_time * 60 + 60 * 5) { }
Log::debug('startTime' . $startTime);
if (($time - $startTime) > ($expireOrder->charger_time * 60 + 60 * 5)) {
$result = DB::table('wx_charger_orders')->where('id', $expireOrder->id)->update([ $result = DB::table('wx_charger_orders')->where('id', $expireOrder->id)->update([
'end_time' => date('Y-m-d H:i:s', strtotime($expireOrder->start_time) + $expireOrder->charger_time * 60), 'end_time' => date('Y-m-d H:i:s', strtotime($expireOrder->start_time) + $expireOrder->charger_time * 60),
'updated_at' => $date, 'updated_at' => $date,
'state' => 3, 'state' => 4,
'is_stop' => 46, 'is_stop' => 46,
]); ]);
DB::table('gateway_log')->insert([ DB::table('gateway_log')->insert([
'gateway_id' => $expireOrder->gateway_id, 'gateway_id' => $expireOrder->gateway_id,
'station_id' => $expireOrder->station_id, 'station_id' => $expireOrder->station_id,
'port_id' => $expireOrder->port_id, 'port_id' => $expireOrder->port_id,
'order_id' => $expireOrder->id, 'order_id' => $expireOrder->id,
'type' => 1, 'type' => 1,
'desc' => '系统自动结束订单', 'desc' => '系统自动结束订单',
'command' => 'ff' 'command' => 'ff'
]); ]);
$redis->hDel('cdz:port:using:order_id:hash', $expireOrder->port_id); $redis->hDel('cdz:port:using:order_id:hash', $expireOrder->port_id);
...@@ -81,10 +150,10 @@ class ScanOrderFinish extends Command ...@@ -81,10 +150,10 @@ class ScanOrderFinish extends Command
} }
$redis->exec(); // $redis->exec();
Log::info('update expired orders'); Log::info('Update expired orders');
} }
......
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/9/28
* Time: 下午1:58
*/
namespace App\Console\Commands\update;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
class Sign extends Command
{
protected $signature = 'Update:sign';
protected $description = 'ota文件md5签名';
public function handle()
{
$updateFiles = DB::table('gateway_update')->get(['hardware_version', 'software_version', 'id']);
foreach ($updateFiles as $file) {
// $fileName = $file['hardware_version'] . $file['software_version'];
$fileName = $file->hardware_version . $file->software_version;
$sign = md5_file(base_path() . '/public/Update/' . $fileName . '.bin');
DB::table('gateway_update')->where('id', $file->id)->update([
'sign' => strtoupper($sign)
]);
}
}
}
\ No newline at end of file
...@@ -9,10 +9,12 @@ use App\Console\Commands\MenuSetting; ...@@ -9,10 +9,12 @@ use App\Console\Commands\MenuSetting;
use App\Console\Commands\RedisCommand; use App\Console\Commands\RedisCommand;
use App\Console\Commands\sync\Port; use App\Console\Commands\sync\Port;
use App\Console\Commands\sync\Station; use App\Console\Commands\sync\Station;
use App\Console\Commands\sync\SyncPortFromStaging;
use App\Console\Commands\sync\SyncWxUserOpenIdCommand; use App\Console\Commands\sync\SyncWxUserOpenIdCommand;
use App\Console\Commands\SyncStationFrequency; use App\Console\Commands\SyncStationFrequency;
use App\Console\Commands\TestPortCommand; use App\Console\Commands\TestPortCommand;
use App\Console\Commands\timer\ScanOrderFinish; use App\Console\Commands\timer\ScanOrderFinish;
use App\Console\Commands\update\Sign;
use Illuminate\Console\Scheduling\Schedule; use Illuminate\Console\Scheduling\Schedule;
use Laravel\Lumen\Console\Kernel as ConsoleKernel; use Laravel\Lumen\Console\Kernel as ConsoleKernel;
...@@ -36,6 +38,8 @@ class Kernel extends ConsoleKernel ...@@ -36,6 +38,8 @@ class Kernel extends ConsoleKernel
AddImg::class, AddImg::class,
ScanOrderFinish::class, ScanOrderFinish::class,
Create::class, Create::class,
Sign::class,
SyncPortFromStaging::class
]; ];
/** /**
......
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/9/29
* Time: 下午3:41
*/
namespace App\Http\Controllers\V1\Update;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Lib\send\command\UpdateCommand;
use Lib\send\Send;
use Validator;
use DB;
use Log;
class UpdateController extends Controller
{
public function noticeUpdate(Request $request)
{
$validator = Validator::make($request->all(), [
'gateway_mac' => 'required|exists|gateways,mac_address',
'download_url' => 'required',
'hardware' => 'required',
'software' => 'required',
'time' => 'required',
]);
if ($validator->fails() === true) {
abort(400, $validator->errors()->first());
}
$updateTime = $request->get('time');
$gatewayMac = $request->get('gateway_mac');
$downloadUrl = $request->get('download_url');
$hardwareVersion = $request->get('hardware');
$softwareVersion = $request->get('software');
$updateCommand = new UpdateCommand($gatewayMac);
$updateCommand->setSoftware($softwareVersion);
$updateCommand->setHardware($hardwareVersion);
$updateCommand->setDownloadUrl($downloadUrl);
$updateCommand->setUpdateTime($updateTime);
$send = new Send($updateCommand);
if ($send->send() === true) {
return $this->response->array($this->getResponseCode());
} else {
$this->resultCode = 'FAIL';
$this->resultMessage = '发送失败或设备不在线';
return $this->response->array($this->getResponseCode());
}
}
public function upload(Request $request)
{
Log::debug($request->all());
$validator = Validator::make($request->all(), [
'hardware' => 'required',
'software' => 'required',
'type' => 'required|exists:gateway_types,id',
]);
if ($validator->fails() === true) {
Log::debug('error');
return $this->response->array(['msg' => $validator->errors()->first(), 'code' => 'FAIL']);
}
if ($request->file('firmware')->isValid() === false) {
return $this->response->array(['msg' => 'miss file', 'code' => 'FAIL']);
}
$hardware = $request->get('hardware');
$software = $request->get('software');
$fileName = $hardware . $software . '.bin';
$gatewayType = $request->get('type');
$date = date('Y-m-d H:i:s');
$file = $request->file('firmware')->move(base_path() . '/public/update', $fileName);
Log::debug(base_path('/public/update/' . $fileName));
$sign = md5_file(base_path('/public/update/' . $fileName));
if (DB::table('gateway_update')->where(['gateway_type' => $gatewayType])->exists() === true) {
DB::table('gateway_update')->where(['gateway_type' => $gatewayType])->update([
'hardware_version' => strtoupper($hardware),
'software_version' => strtoupper($software),
'updated_at' => $date,
'sign' => strtoupper($sign),
]);
} else {
DB::table('gateway_update')->insert([
'hardware_version' => strtoupper($hardware),
'software_version' => strtoupper($software),
'updated_at' => $date,
'sign' => strtoupper($sign),
'created_at' => $date,
'gateway_type' => $gatewayType,
]);
}
return $this->response->array(['code' => 'SUCCESS']);
}
}
\ No newline at end of file
...@@ -63,12 +63,8 @@ class StatisticController extends Controller ...@@ -63,12 +63,8 @@ class StatisticController extends Controller
$portsId = $userUsingOrder->getUserUsingPortId();//获取用户正在使用的口子id $portsId = $userUsingOrder->getUserUsingPortId();//获取用户正在使用的口子id
Log::debug($portsId);
$orderIds = $userUsingOrder->getPortsOrderId($portsId); $orderIds = $userUsingOrder->getPortsOrderId($portsId);
Log::debug($orderIds);
if ($orderIds === false) { if ($orderIds === false) {
$orderIds = []; $orderIds = [];
...@@ -86,8 +82,7 @@ class StatisticController extends Controller ...@@ -86,8 +82,7 @@ class StatisticController extends Controller
$tmp = $adaptor->adaptor(); $tmp = $adaptor->adaptor();
if($tmp !== false) if ($tmp !== false) {
{
array_push($ordersState, $tmp); array_push($ordersState, $tmp);
} }
...@@ -104,7 +99,7 @@ class StatisticController extends Controller ...@@ -104,7 +99,7 @@ class StatisticController extends Controller
$createdAt = strtotime($value['created_at']); $createdAt = strtotime($value['created_at']);
return $createdAt + $chargerTime * 60 > time(); return $createdAt + $chargerTime * 60 + 1 * 60 > time();
});//剔除充电结束的订单 });//剔除充电结束的订单
......
...@@ -78,6 +78,8 @@ class AccessController extends Controller ...@@ -78,6 +78,8 @@ class AccessController extends Controller
if (!$wxUserModel->addUser($wxUser)) { if (!$wxUserModel->addUser($wxUser)) {
Log::error('add user fail');
abort(500, 'database store error'); abort(500, 'database store error');
} }
...@@ -103,7 +105,8 @@ class AccessController extends Controller ...@@ -103,7 +105,8 @@ class AccessController extends Controller
return $this->response->array($this->getResponseCode() + ['data' => [ return $this->response->array($this->getResponseCode() + ['data' => [
'token' => $token, 'token' => $token,
]]); ]
]);
} catch (\Exception $exception) { } catch (\Exception $exception) {
Log::error($exception->getMessage()); Log::error($exception->getMessage());
......
...@@ -1504,7 +1504,7 @@ class Connection ...@@ -1504,7 +1504,7 @@ class Connection
$this->indentCsv(array_values($this->col_values)) . ')'; $this->indentCsv(array_values($this->col_values)) . ')';
} }
// ------update------- // ------Update-------
/** /**
* 更新哪个表 * 更新哪个表
* *
...@@ -1835,7 +1835,7 @@ class Connection ...@@ -1835,7 +1835,7 @@ class Connection
$statement = strtolower(trim($rawStatement[0])); $statement = strtolower(trim($rawStatement[0]));
if ($statement === 'select' || $statement === 'show') { if ($statement === 'select' || $statement === 'show') {
return $this->sQuery->fetchAll($fetchmode); return $this->sQuery->fetchAll($fetchmode);
} elseif ($statement === 'update' || $statement === 'delete') { } elseif ($statement === 'Update' || $statement === 'delete') {
return $this->sQuery->rowCount(); return $this->sQuery->rowCount();
} elseif ($statement === 'insert') { } elseif ($statement === 'insert') {
if ($this->sQuery->rowCount() > 0) { if ($this->sQuery->rowCount() > 0) {
......
...@@ -1070,7 +1070,7 @@ class YourClient extends \Guzzle\Service\Client ...@@ -1070,7 +1070,7 @@ class YourClient extends \Guzzle\Service\Client
"parameters":{ "parameters":{
"id": { "id": {
"location": "uri", "location": "uri",
"description":"Group to update by ID", "description":Update,
"type": "integer", "type": "integer",
"required": true "required": true
}, },
......
...@@ -412,7 +412,7 @@ class Connection implements ConnectionInterface ...@@ -412,7 +412,7 @@ class Connection implements ConnectionInterface
} }
/** /**
* Run an update statement against the database. * Run an Update statement against the database.
* *
* @param string $query * @param string $query
* @param array $bindings * @param array $bindings
...@@ -473,7 +473,7 @@ class Connection implements ConnectionInterface ...@@ -473,7 +473,7 @@ class Connection implements ConnectionInterface
return 0; return 0;
} }
// For update or delete statements, we want to get the number of rows affected // For Update or delete statements, we want to get the number of rows affected
// by the statement and return that back to the developer. We'll first need // by the statement and return that back to the developer. We'll first need
// to execute the statement and then we'll use PDO to fetch the affected. // to execute the statement and then we'll use PDO to fetch the affected.
$statement = $this->getPdo()->prepare($query); $statement = $this->getPdo()->prepare($query);
......
...@@ -50,7 +50,7 @@ interface ConnectionInterface ...@@ -50,7 +50,7 @@ interface ConnectionInterface
public function insert($query, $bindings = []); public function insert($query, $bindings = []);
/** /**
* Run an update statement against the database. * Run an Update statement against the database.
* *
* @param string $query * @param string $query
* @param array $bindings * @param array $bindings
......
...@@ -384,7 +384,7 @@ class Builder ...@@ -384,7 +384,7 @@ class Builder
} }
/** /**
* Create or update a record matching the attributes, and fill it with values. * Create or Update a record matching the attributes, and fill it with values.
* *
* @param array $attributes * @param array $attributes
* @param array $values * @param array $values
......
...@@ -14,7 +14,7 @@ trait HasTimestamps ...@@ -14,7 +14,7 @@ trait HasTimestamps
public $timestamps = true; public $timestamps = true;
/** /**
* Update the model's update timestamp. * Update the model's Update timestamp.
* *
* @return bool * @return bool
*/ */
...@@ -30,7 +30,7 @@ trait HasTimestamps ...@@ -30,7 +30,7 @@ trait HasTimestamps
} }
/** /**
* Update the creation and update timestamps. * Update the creation and Update timestamps.
* *
* @return void * @return void
*/ */
......
...@@ -539,9 +539,9 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab ...@@ -539,9 +539,9 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
return false; return false;
} }
// If the model already exists in the database we can just update our record // If the model already exists in the database we can just Update our record
// that is already in this database using the current IDs in this "where" // that is already in this database using the current IDs in this "where"
// clause to only update this model. Otherwise, we'll just insert them. // clause to only Update this model. Otherwise, we'll just insert them.
if ($this->exists) { if ($this->exists) {
$saved = $this->isDirty() ? $saved = $this->isDirty() ?
$this->performUpdate($query) : true; $this->performUpdate($query) : true;
...@@ -602,28 +602,28 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab ...@@ -602,28 +602,28 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
} }
/** /**
* Perform a model update operation. * Perform a model Update operation.
* *
* @param \Illuminate\Database\Eloquent\Builder $query * @param \Illuminate\Database\Eloquent\Builder $query
* @return bool * @return bool
*/ */
protected function performUpdate(Builder $query) protected function performUpdate(Builder $query)
{ {
// If the updating event returns false, we will cancel the update operation so // If the updating event returns false, we will cancel the Update operation so
// developers can hook Validation systems into their models and cancel this // developers can hook Validation systems into their models and cancel this
// operation if the model does not pass validation. Otherwise, we update. // operation if the model does not pass validation. Otherwise, we Update.
if ($this->fireModelEvent('updating') === false) { if ($this->fireModelEvent('updating') === false) {
return false; return false;
} }
// First we need to create a fresh query instance and touch the creation and // First we need to create a fresh query instance and touch the creation and
// update timestamp on the model which are maintained by us for developer // Update timestamp on the model which are maintained by us for developer
// convenience. Then we will just continue saving the model instances. // convenience. Then we will just continue saving the model instances.
if ($this->usesTimestamps()) { if ($this->usesTimestamps()) {
$this->updateTimestamps(); $this->updateTimestamps();
} }
// Once we have run the update operation, we will fire the "updated" event for // Once we have run the Update operation, we will fire the "updated" event for
// this model instance. This will allow developers to hook into these after // this model instance. This will allow developers to hook into these after
// models are updated, giving them a chance to do any special processing. // models are updated, giving them a chance to do any special processing.
$dirty = $this->getDirty(); $dirty = $this->getDirty();
...@@ -640,7 +640,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab ...@@ -640,7 +640,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
} }
/** /**
* Set the keys for a save update query. * Set the keys for a save Update query.
* *
* @param \Illuminate\Database\Eloquent\Builder $query * @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder * @return \Illuminate\Database\Eloquent\Builder
...@@ -676,7 +676,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab ...@@ -676,7 +676,7 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
} }
// First we'll need to create a fresh query instance and touch the creation and // First we'll need to create a fresh query instance and touch the creation and
// update timestamps on this model, which are maintained by us for developer // Update timestamps on this model, which are maintained by us for developer
// convenience. After, we will just continue saving these model instances. // convenience. After, we will just continue saving these model instances.
if ($this->usesTimestamps()) { if ($this->usesTimestamps()) {
$this->updateTimestamps(); $this->updateTimestamps();
...@@ -703,8 +703,8 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab ...@@ -703,8 +703,8 @@ abstract class Model implements ArrayAccess, Arrayable, Jsonable, JsonSerializab
} }
// We will go ahead and set the exists property to true, so that it is set when // We will go ahead and set the exists property to true, so that it is set when
// the created event is fired, just in case the developer tries to update it // the created event is fired, just in case the developer tries to Update it
// during the event. This will allow them to do so and run an update here. // during the event. This will allow them to do so and run an Update here.
$this->exists = true; $this->exists = true;
$this->wasRecentlyCreated = true; $this->wasRecentlyCreated = true;
......
...@@ -444,7 +444,7 @@ class BelongsToMany extends Relation ...@@ -444,7 +444,7 @@ class BelongsToMany extends Relation
} }
/** /**
* Create or update a related record matching the attributes, and fill it with values. * Create or Update a related record matching the attributes, and fill it with values.
* *
* @param array $attributes * @param array $attributes
* @param array $values * @param array $values
...@@ -766,7 +766,7 @@ class BelongsToMany extends Relation ...@@ -766,7 +766,7 @@ class BelongsToMany extends Relation
$this->related->getUpdatedAtColumn() => $this->related->freshTimestampString(), $this->related->getUpdatedAtColumn() => $this->related->freshTimestampString(),
]; ];
// If we actually have IDs for the relation, we will run the query to update all // If we actually have IDs for the relation, we will run the query to Update all
// the related model's timestamps, to make sure these all reflect the changes // the related model's timestamps, to make sure these all reflect the changes
// to the parent models. This will help us keep any caching synced up here. // to the parent models. This will help us keep any caching synced up here.
if (count($ids = $this->allRelatedIds()) > 0) { if (count($ids = $this->allRelatedIds()) > 0) {
...@@ -922,7 +922,7 @@ class BelongsToMany extends Relation ...@@ -922,7 +922,7 @@ class BelongsToMany extends Relation
} }
/** /**
* Specify that the pivot table has creation and update timestamps. * Specify that the pivot table has creation and Update timestamps.
* *
* @param mixed $createdAt * @param mixed $createdAt
* @param mixed $updatedAt * @param mixed $updatedAt
......
...@@ -154,15 +154,15 @@ trait InteractsWithPivotTable ...@@ -154,15 +154,15 @@ trait InteractsWithPivotTable
foreach ($records as $id => $attributes) { foreach ($records as $id => $attributes) {
// If the ID is not in the list of existing pivot IDs, we will insert a new pivot // If the ID is not in the list of existing pivot IDs, we will insert a new pivot
// record, otherwise, we will just update this existing record on this joining // record, otherwise, we will just Update this existing record on this joining
// table, so that the developers will easily update these records pain free. // table, so that the developers will easily Update these records pain free.
if (! in_array($id, $current)) { if (! in_array($id, $current)) {
$this->attach($id, $attributes, $touch); $this->attach($id, $attributes, $touch);
$changes['attached'][] = $this->castKey($id); $changes['attached'][] = $this->castKey($id);
} }
// Now we'll try to update an existing pivot record with the attributes that were // Now we'll try to Update an existing pivot record with the attributes that were
// given to the method. If the model is actually updated we will add it to the // given to the method. If the model is actually updated we will add it to the
// list of updated pivot records so we return them back out to the consumer. // list of updated pivot records so we return them back out to the consumer.
elseif (count($attributes) > 0 && elseif (count($attributes) > 0 &&
...@@ -293,7 +293,7 @@ trait InteractsWithPivotTable ...@@ -293,7 +293,7 @@ trait InteractsWithPivotTable
$record[$this->foreignPivotKey] = $this->parent->{$this->parentKey}; $record[$this->foreignPivotKey] = $this->parent->{$this->parentKey};
// If the record needs to have creation and update timestamps, we will make // If the record needs to have creation and Update timestamps, we will make
// them by calling the parent model's "freshTimestamp" method which will // them by calling the parent model's "freshTimestamp" method which will
// provide us with a fresh timestamp in this model's preferred format. // provide us with a fresh timestamp in this model's preferred format.
if ($timed) { if ($timed) {
...@@ -308,7 +308,7 @@ trait InteractsWithPivotTable ...@@ -308,7 +308,7 @@ trait InteractsWithPivotTable
} }
/** /**
* Set the creation and update timestamps on an attach record. * Set the creation and Update timestamps on an attach record.
* *
* @param array $record * @param array $record
* @param bool $exists * @param bool $exists
......
...@@ -231,7 +231,7 @@ class HasManyThrough extends Relation ...@@ -231,7 +231,7 @@ class HasManyThrough extends Relation
} }
/** /**
* Create or update a related record matching the attributes, and fill it with values. * Create or Update a related record matching the attributes, and fill it with values.
* *
* @param array $attributes * @param array $attributes
* @param array $values * @param array $values
......
...@@ -222,7 +222,7 @@ abstract class HasOneOrMany extends Relation ...@@ -222,7 +222,7 @@ abstract class HasOneOrMany extends Relation
} }
/** /**
* Create or update a related record matching the attributes, and fill it with values. * Create or Update a related record matching the attributes, and fill it with values.
* *
* @param array $attributes * @param array $attributes
* @param array $values * @param array $values
...@@ -309,7 +309,7 @@ abstract class HasOneOrMany extends Relation ...@@ -309,7 +309,7 @@ abstract class HasOneOrMany extends Relation
} }
/** /**
* Perform an update on all the related models. * Perform an Update on all the related models.
* *
* @param array $attributes * @param array $attributes
* @return int * @return int
......
...@@ -26,7 +26,7 @@ class MorphPivot extends Pivot ...@@ -26,7 +26,7 @@ class MorphPivot extends Pivot
protected $morphClass; protected $morphClass;
/** /**
* Set the keys for a save update query. * Set the keys for a save Update query.
* *
* @param \Illuminate\Database\Eloquent\Builder $query * @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder * @return \Illuminate\Database\Eloquent\Builder
......
...@@ -90,7 +90,7 @@ class Pivot extends Model ...@@ -90,7 +90,7 @@ class Pivot extends Model
} }
/** /**
* Set the keys for a save update query. * Set the keys for a save Update query.
* *
* @param \Illuminate\Database\Eloquent\Builder $query * @param \Illuminate\Database\Eloquent\Builder $query
* @return \Illuminate\Database\Eloquent\Builder * @return \Illuminate\Database\Eloquent\Builder
......
...@@ -167,7 +167,7 @@ abstract class Relation ...@@ -167,7 +167,7 @@ abstract class Relation
} }
/** /**
* Run a raw update against the base query. * Run a raw Update against the base query.
* *
* @param array $attributes * @param array $attributes
* @return int * @return int
......
...@@ -97,7 +97,7 @@ class MigrationCreator ...@@ -97,7 +97,7 @@ class MigrationCreator
// We also have stubs for creating new tables and modifying existing tables // We also have stubs for creating new tables and modifying existing tables
// to save the developer some typing when they are creating a new tables // to save the developer some typing when they are creating a new tables
// or modifying existing tables. We'll grab the appropriate stub here. // or modifying existing tables. We'll grab the appropriate stub here.
$stub = $create ? 'create.stub' : 'update.stub'; $stub = $create ? 'create.stub' : 'Update.stub';
return $this->files->get($this->stubPath()."/{$stub}"); return $this->files->get($this->stubPath()."/{$stub}");
} }
...@@ -116,7 +116,7 @@ class MigrationCreator ...@@ -116,7 +116,7 @@ class MigrationCreator
// Here we will replace the table place-holders with the table specified by // Here we will replace the table place-holders with the table specified by
// the developer, which is useful for quickly creating a tables creation // the developer, which is useful for quickly creating a tables creation
// or update migration from the console instead of typing it manually. // or Update migration from the console instead of typing it manually.
if (! is_null($table)) { if (! is_null($table)) {
$stub = str_replace('DummyTable', $table, $stub); $stub = str_replace('DummyTable', $table, $stub);
} }
......
...@@ -2365,7 +2365,7 @@ class Builder ...@@ -2365,7 +2365,7 @@ class Builder
} }
/** /**
* Insert or update a record matching the attributes, and fill it with values. * Insert or Update a record matching the attributes, and fill it with values.
* *
* @param array $attributes * @param array $attributes
* @param array $values * @param array $values
......
...@@ -714,7 +714,7 @@ class Grammar extends BaseGrammar ...@@ -714,7 +714,7 @@ class Grammar extends BaseGrammar
} }
/** /**
* Compile an update statement into SQL. * Compile an Update statement into SQL.
* *
* @param \Illuminate\Database\Query\Builder $query * @param \Illuminate\Database\Query\Builder $query
* @param array $values * @param array $values
...@@ -724,7 +724,7 @@ class Grammar extends BaseGrammar ...@@ -724,7 +724,7 @@ class Grammar extends BaseGrammar
{ {
$table = $this->wrapTable($query->from); $table = $this->wrapTable($query->from);
// Each one of the columns in the update statements needs to be wrapped in the // Each one of the columns in the Update statements needs to be wrapped in the
// keyword identifiers, also a place-holder needs to be created for each of // keyword identifiers, also a place-holder needs to be created for each of
// the values in the list of bindings so we can make the sets statements. // the values in the list of bindings so we can make the sets statements.
$columns = collect($values)->map(function ($value, $key) { $columns = collect($values)->map(function ($value, $key) {
...@@ -732,7 +732,7 @@ class Grammar extends BaseGrammar ...@@ -732,7 +732,7 @@ class Grammar extends BaseGrammar
})->implode(', '); })->implode(', ');
// If the query has any "join" clauses, we will setup the joins on the builder // If the query has any "join" clauses, we will setup the joins on the builder
// and compile them so we can attach them to this update, as update queries // and compile them so we can attach them to this Update, as Update queries
// can get join statements to attach to other tables when they're needed. // can get join statements to attach to other tables when they're needed.
$joins = ''; $joins = '';
...@@ -740,16 +740,16 @@ class Grammar extends BaseGrammar ...@@ -740,16 +740,16 @@ class Grammar extends BaseGrammar
$joins = ' '.$this->compileJoins($query, $query->joins); $joins = ' '.$this->compileJoins($query, $query->joins);
} }
// Of course, update queries may also be constrained by where clauses so we'll // Of course, Update queries may also be constrained by where clauses so we'll
// need to compile the where clauses and attach it to the query so only the // need to compile the where clauses and attach it to the query so only the
// intended records are updated by the SQL statements we generate to run. // intended records are updated by the SQL statements we generate to run.
$wheres = $this->compileWheres($query); $wheres = $this->compileWheres($query);
return trim("update {$table}{$joins} set $columns $wheres"); return trim("Update {$table}{$joins} set $columns $wheres");
} }
/** /**
* Prepare the bindings for an update statement. * Prepare the bindings for an Update statement.
* *
* @param array $bindings * @param array $bindings
* @param array $values * @param array $values
......
...@@ -86,14 +86,14 @@ class MySqlGrammar extends Grammar ...@@ -86,14 +86,14 @@ class MySqlGrammar extends Grammar
protected function compileLock(Builder $query, $value) protected function compileLock(Builder $query, $value)
{ {
if (! is_string($value)) { if (! is_string($value)) {
return $value ? 'for update' : 'lock in share mode'; return $value ? 'for Update' : 'lock in share mode';
} }
return $value; return $value;
} }
/** /**
* Compile an update statement into SQL. * Compile an Update statement into SQL.
* *
* @param \Illuminate\Database\Query\Builder $query * @param \Illuminate\Database\Query\Builder $query
* @param array $values * @param array $values
...@@ -103,13 +103,13 @@ class MySqlGrammar extends Grammar ...@@ -103,13 +103,13 @@ class MySqlGrammar extends Grammar
{ {
$table = $this->wrapTable($query->from); $table = $this->wrapTable($query->from);
// Each one of the columns in the update statements needs to be wrapped in the // Each one of the columns in the Update statements needs to be wrapped in the
// keyword identifiers, also a place-holder needs to be created for each of // keyword identifiers, also a place-holder needs to be created for each of
// the values in the list of bindings so we can make the sets statements. // the values in the list of bindings so we can make the sets statements.
$columns = $this->compileUpdateColumns($values); $columns = $this->compileUpdateColumns($values);
// If the query has any "join" clauses, we will setup the joins on the builder // If the query has any "join" clauses, we will setup the joins on the builder
// and compile them so we can attach them to this update, as update queries // and compile them so we can attach them to this Update, as Update queries
// can get join statements to attach to other tables when they're needed. // can get join statements to attach to other tables when they're needed.
$joins = ''; $joins = '';
...@@ -117,23 +117,23 @@ class MySqlGrammar extends Grammar ...@@ -117,23 +117,23 @@ class MySqlGrammar extends Grammar
$joins = ' '.$this->compileJoins($query, $query->joins); $joins = ' '.$this->compileJoins($query, $query->joins);
} }
// Of course, update queries may also be constrained by where clauses so we'll // Of course, Update queries may also be constrained by where clauses so we'll
// need to compile the where clauses and attach it to the query so only the // need to compile the where clauses and attach it to the query so only the
// intended records are updated by the SQL statements we generate to run. // intended records are updated by the SQL statements we generate to run.
$where = $this->compileWheres($query); $where = $this->compileWheres($query);
$sql = rtrim("update {$table}{$joins} set $columns $where"); $sql = rtrim("Update {$table}{$joins} set $columns $where");
// If the query has an order by clause we will compile it since MySQL supports // If the query has an order by clause we will compile it since MySQL supports
// order bys on update statements. We'll compile them using the typical way // order bys on Update statements. We'll compile them using the typical way
// of compiling order bys. Then they will be appended to the SQL queries. // of compiling order bys. Then they will be appended to the SQL queries.
if (! empty($query->orders)) { if (! empty($query->orders)) {
$sql .= ' '.$this->compileOrders($query, $query->orders); $sql .= ' '.$this->compileOrders($query, $query->orders);
} }
// Updates on MySQL also supports "limits", which allow you to easily update a // Updates on MySQL also supports "limits", which allow you to easily Update a
// single record very easily. This is not supported by all database engines // single record very easily. This is not supported by all database engines
// so we have customized this update compiler here in order to add it in. // so we have customized this Update compiler here in order to add it in.
if (isset($query->limit)) { if (isset($query->limit)) {
$sql .= ' '.$this->compileLimit($query, $query->limit); $sql .= ' '.$this->compileLimit($query, $query->limit);
} }
...@@ -142,7 +142,7 @@ class MySqlGrammar extends Grammar ...@@ -142,7 +142,7 @@ class MySqlGrammar extends Grammar
} }
/** /**
* Compile all of the columns for an update statement. * Compile all of the columns for an Update statement.
* *
* @param array $values * @param array $values
* @return string * @return string
...@@ -177,7 +177,7 @@ class MySqlGrammar extends Grammar ...@@ -177,7 +177,7 @@ class MySqlGrammar extends Grammar
} }
/** /**
* Prepare the bindings for an update statement. * Prepare the bindings for an Update statement.
* *
* Booleans, integers, and doubles are inserted into JSON updates as raw values. * Booleans, integers, and doubles are inserted into JSON updates as raw values.
* *
......
...@@ -74,7 +74,7 @@ class PostgresGrammar extends Grammar ...@@ -74,7 +74,7 @@ class PostgresGrammar extends Grammar
protected function compileLock(Builder $query, $value) protected function compileLock(Builder $query, $value)
{ {
if (! is_string($value)) { if (! is_string($value)) {
return $value ? 'for update' : 'for share'; return $value ? 'for Update' : 'for share';
} }
return $value; return $value;
...@@ -110,7 +110,7 @@ class PostgresGrammar extends Grammar ...@@ -110,7 +110,7 @@ class PostgresGrammar extends Grammar
} }
/** /**
* Compile an update statement into SQL. * Compile an Update statement into SQL.
* *
* @param \Illuminate\Database\Query\Builder $query * @param \Illuminate\Database\Query\Builder $query
* @param array $values * @param array $values
...@@ -120,7 +120,7 @@ class PostgresGrammar extends Grammar ...@@ -120,7 +120,7 @@ class PostgresGrammar extends Grammar
{ {
$table = $this->wrapTable($query->from); $table = $this->wrapTable($query->from);
// Each one of the columns in the update statements needs to be wrapped in the // Each one of the columns in the Update statements needs to be wrapped in the
// keyword identifiers, also a place-holder needs to be created for each of // keyword identifiers, also a place-holder needs to be created for each of
// the values in the list of bindings so we can make the sets statements. // the values in the list of bindings so we can make the sets statements.
$columns = $this->compileUpdateColumns($values); $columns = $this->compileUpdateColumns($values);
...@@ -129,27 +129,27 @@ class PostgresGrammar extends Grammar ...@@ -129,27 +129,27 @@ class PostgresGrammar extends Grammar
$where = $this->compileUpdateWheres($query); $where = $this->compileUpdateWheres($query);
return trim("update {$table} set {$columns}{$from} {$where}"); return trim("Update {$table} set {$columns}{$from} {$where}");
} }
/** /**
* Compile the columns for the update statement. * Compile the columns for the Update statement.
* *
* @param array $values * @param array $values
* @return string * @return string
*/ */
protected function compileUpdateColumns($values) protected function compileUpdateColumns($values)
{ {
// When gathering the columns for an update statement, we'll wrap each of the // When gathering the columns for an Update statement, we'll wrap each of the
// columns and convert it to a parameter value. Then we will concatenate a // columns and convert it to a parameter value. Then we will concatenate a
// list of the columns that can be added into this update query clauses. // list of the columns that can be added into this Update query clauses.
return collect($values)->map(function ($value, $key) { return collect($values)->map(function ($value, $key) {
return $this->wrap($key).' = '.$this->parameter($value); return $this->wrap($key).' = '.$this->parameter($value);
})->implode(', '); })->implode(', ');
} }
/** /**
* Compile the "from" clause for an update with a join. * Compile the "from" clause for an Update with a join.
* *
* @param \Illuminate\Database\Query\Builder $query * @param \Illuminate\Database\Query\Builder $query
* @return string|null * @return string|null
...@@ -199,7 +199,7 @@ class PostgresGrammar extends Grammar ...@@ -199,7 +199,7 @@ class PostgresGrammar extends Grammar
} }
/** /**
* Compile the "join" clause where clauses for an update. * Compile the "join" clause where clauses for an Update.
* *
* @param \Illuminate\Database\Query\Builder $query * @param \Illuminate\Database\Query\Builder $query
* @return string * @return string
...@@ -223,7 +223,7 @@ class PostgresGrammar extends Grammar ...@@ -223,7 +223,7 @@ class PostgresGrammar extends Grammar
} }
/** /**
* Prepare the bindings for an update statement. * Prepare the bindings for an Update statement.
* *
* @param array $bindings * @param array $bindings
* @param array $values * @param array $values
......
...@@ -187,7 +187,7 @@ class SQLiteGrammar extends Grammar ...@@ -187,7 +187,7 @@ class SQLiteGrammar extends Grammar
} }
/** /**
* Compile an update statement into SQL. * Compile an Update statement into SQL.
* *
* @param \Illuminate\Database\Query\Builder $query * @param \Illuminate\Database\Query\Builder $query
* @param array $values * @param array $values
...@@ -204,14 +204,14 @@ class SQLiteGrammar extends Grammar ...@@ -204,14 +204,14 @@ class SQLiteGrammar extends Grammar
if (isset($query->joins) || isset($query->limit)) { if (isset($query->joins) || isset($query->limit)) {
$selectSql = parent::compileSelect($query->select("{$query->from}.rowid")); $selectSql = parent::compileSelect($query->select("{$query->from}.rowid"));
return "update {$table} set $columns where {$this->wrap('rowid')} in ({$selectSql})"; return "Update {$table} set $columns where {$this->wrap('rowid')} in ({$selectSql})";
} }
return trim("update {$table} set {$columns} {$this->compileWheres($query)}"); return trim("Update {$table} set {$columns} {$this->compileWheres($query)}");
} }
/** /**
* Prepare the bindings for an update statement. * Prepare the bindings for an Update statement.
* *
* @param array $bindings * @param array $bindings
* @param array $values * @param array $values
......
...@@ -287,7 +287,7 @@ class SqlServerGrammar extends Grammar ...@@ -287,7 +287,7 @@ class SqlServerGrammar extends Grammar
} }
/** /**
* Compile an update statement into SQL. * Compile an Update statement into SQL.
* *
* @param \Illuminate\Database\Query\Builder $query * @param \Illuminate\Database\Query\Builder $query
* @param array $values * @param array $values
...@@ -297,7 +297,7 @@ class SqlServerGrammar extends Grammar ...@@ -297,7 +297,7 @@ class SqlServerGrammar extends Grammar
{ {
list($table, $alias) = $this->parseUpdateTable($query->from); list($table, $alias) = $this->parseUpdateTable($query->from);
// Each one of the columns in the update statements needs to be wrapped in the // Each one of the columns in the Update statements needs to be wrapped in the
// keyword identifiers, also a place-holder needs to be created for each of // keyword identifiers, also a place-holder needs to be created for each of
// the values in the list of bindings so we can make the sets statements. // the values in the list of bindings so we can make the sets statements.
$columns = collect($values)->map(function ($value, $key) { $columns = collect($values)->map(function ($value, $key) {
...@@ -305,7 +305,7 @@ class SqlServerGrammar extends Grammar ...@@ -305,7 +305,7 @@ class SqlServerGrammar extends Grammar
})->implode(', '); })->implode(', ');
// If the query has any "join" clauses, we will setup the joins on the builder // If the query has any "join" clauses, we will setup the joins on the builder
// and compile them so we can attach them to this update, as update queries // and compile them so we can attach them to this Update, as Update queries
// can get join statements to attach to other tables when they're needed. // can get join statements to attach to other tables when they're needed.
$joins = ''; $joins = '';
...@@ -313,16 +313,16 @@ class SqlServerGrammar extends Grammar ...@@ -313,16 +313,16 @@ class SqlServerGrammar extends Grammar
$joins = ' '.$this->compileJoins($query, $query->joins); $joins = ' '.$this->compileJoins($query, $query->joins);
} }
// Of course, update queries may also be constrained by where clauses so we'll // Of course, Update queries may also be constrained by where clauses so we'll
// need to compile the where clauses and attach it to the query so only the // need to compile the where clauses and attach it to the query so only the
// intended records are updated by the SQL statements we generate to run. // intended records are updated by the SQL statements we generate to run.
$where = $this->compileWheres($query); $where = $this->compileWheres($query);
if (! empty($joins)) { if (! empty($joins)) {
return trim("update {$alias} set {$columns} from {$table}{$joins} {$where}"); return trim("Update {$alias} set {$columns} from {$table}{$joins} {$where}");
} }
return trim("update {$table}{$joins} set $columns $where"); return trim("Update {$table}{$joins} set $columns $where");
} }
/** /**
...@@ -343,7 +343,7 @@ class SqlServerGrammar extends Grammar ...@@ -343,7 +343,7 @@ class SqlServerGrammar extends Grammar
} }
/** /**
* Prepare the bindings for an update statement. * Prepare the bindings for an Update statement.
* *
* @param array $bindings * @param array $bindings
* @param array $values * @param array $values
......
...@@ -931,7 +931,7 @@ class Blueprint ...@@ -931,7 +931,7 @@ class Blueprint
} }
/** /**
* Add nullable creation and update timestamps to the table. * Add nullable creation and Update timestamps to the table.
* *
* @param int $precision * @param int $precision
* @return void * @return void
...@@ -944,7 +944,7 @@ class Blueprint ...@@ -944,7 +944,7 @@ class Blueprint
} }
/** /**
* Add nullable creation and update timestamps to the table. * Add nullable creation and Update timestamps to the table.
* *
* Alias for self::timestamps(). * Alias for self::timestamps().
* *
...@@ -957,7 +957,7 @@ class Blueprint ...@@ -957,7 +957,7 @@ class Blueprint
} }
/** /**
* Add creation and update timestampTz columns to the table. * Add creation and Update timestampTz columns to the table.
* *
* @param int $precision * @param int $precision
* @return void * @return void
......
...@@ -81,14 +81,14 @@ abstract class Grammar extends BaseGrammar ...@@ -81,14 +81,14 @@ abstract class Grammar extends BaseGrammar
); );
// Once we have the basic foreign key creation statement constructed we can // Once we have the basic foreign key creation statement constructed we can
// build out the syntax for what should happen on an update or delete of // build out the syntax for what should happen on an Update or delete of
// the affected columns, which will get something like "cascade", etc. // the affected columns, which will get something like "cascade", etc.
if (! is_null($command->onDelete)) { if (! is_null($command->onDelete)) {
$sql .= " on delete {$command->onDelete}"; $sql .= " on delete {$command->onDelete}";
} }
if (! is_null($command->onUpdate)) { if (! is_null($command->onUpdate)) {
$sql .= " on update {$command->onUpdate}"; $sql .= " on Update {$command->onUpdate}";
} }
return $sql; return $sql;
......
...@@ -83,11 +83,11 @@ class SQLiteGrammar extends Grammar ...@@ -83,11 +83,11 @@ class SQLiteGrammar extends Grammar
$sql .= " on delete {$foreign->onDelete}"; $sql .= " on delete {$foreign->onDelete}";
} }
// If this foreign key specifies the action to be taken on update we will add // If this foreign key specifies the action to be taken on Update we will add
// that to the statement here. We'll append it to this SQL and then return // that to the statement here. We'll append it to this SQL and then return
// the SQL so we can keep adding any other foreign constraints onto this. // the SQL so we can keep adding any other foreign constraints onto this.
if (! is_null($foreign->onUpdate)) { if (! is_null($foreign->onUpdate)) {
$sql .= " on update {$foreign->onUpdate}"; $sql .= " on Update {$foreign->onUpdate}";
} }
return $sql; return $sql;
......
...@@ -11,7 +11,7 @@ namespace Illuminate\Support\Facades; ...@@ -11,7 +11,7 @@ namespace Illuminate\Support\Facades;
* @method static mixed selectOne(string $query, array $bindings = []) * @method static mixed selectOne(string $query, array $bindings = [])
* @method static array select(string $query, array $bindings = []) * @method static array select(string $query, array $bindings = [])
* @method static bool insert(string $query, array $bindings = []) * @method static bool insert(string $query, array $bindings = [])
* @method static int update(string $query, array $bindings = []) * @method static int Update(string $query, array $bindings = [])
* @method static int delete(string $query, array $bindings = []) * @method static int delete(string $query, array $bindings = [])
* @method static bool statement(string $query, array $bindings = []) * @method static bool statement(string $query, array $bindings = [])
* @method static int affectingStatement(string $query, array $bindings = []) * @method static int affectingStatement(string $query, array $bindings = [])
......
...@@ -112,7 +112,7 @@ class RotatingFileHandler extends StreamHandler ...@@ -112,7 +112,7 @@ class RotatingFileHandler extends StreamHandler
*/ */
protected function rotate() protected function rotate()
{ {
// update filename // Update filename
$this->url = $this->getTimedFilename(); $this->url = $this->getTimedFilename();
$this->nextRotation = new \DateTime('tomorrow'); $this->nextRotation = new \DateTime('tomorrow');
......
...@@ -28,7 +28,7 @@ class AmqpHandlerTest extends TestCase ...@@ -28,7 +28,7 @@ class AmqpHandlerTest extends TestCase
} }
if (!class_exists('AMQPChannel')) { if (!class_exists('AMQPChannel')) {
$this->markTestSkipped("Please update AMQP to version >= 1.0"); $this->markTestSkipped("Please Update AMQP to version >= 1.0");
} }
$messages = array(); $messages = array();
......
...@@ -14,13 +14,13 @@ env: ...@@ -14,13 +14,13 @@ env:
sudo: false sudo: false
before_install: before_install:
- sudo apt-get update && sudo apt-get --reinstall install -qq language-pack-fr - sudo apt-get Update && sudo apt-get --reinstall install -qq language-pack-fr
- if [[ $coverage = 'false' ]]; then phpenv config-rm xdebug.ini; fi - if [[ $coverage = 'false' ]]; then phpenv config-rm xdebug.ini; fi
install: install:
- if [[ $phpstan = 'true' ]]; then travis_retry composer require --dev phpstan/phpstan; fi - if [[ $phpstan = 'true' ]]; then travis_retry composer require --dev phpstan/phpstan; fi
- if [[ $setup = 'basic' ]]; then travis_retry composer update --prefer-dist --no-interaction --no-suggest; fi - if [[ $setup = 'basic' ]]; then travis_retry composer Update --prefer-dist --no-interaction --no-suggest; fi
- if [[ $setup = 'stable' ]]; then travis_retry composer update --prefer-dist --no-interaction --no-suggest --prefer-stable; fi - if [[ $setup = 'stable' ]]; then travis_retry composer Update --prefer-dist --no-interaction --no-suggest --prefer-stable; fi
- | - |
if [[ $setup = 'lowest' ]]; then if [[ $setup = 'lowest' ]]; then
composer require sebastian/comparator:"~1.2.4" --no-update --dev composer require sebastian/comparator:"~1.2.4" --no-update --dev
......
...@@ -46,7 +46,7 @@ foreach ($tags as $tag) { ...@@ -46,7 +46,7 @@ foreach ($tags as $tag) {
shell_exec("git branch -d $branch"); shell_exec("git branch -d $branch");
shell_exec("git checkout tags/$tag -b $branch"); shell_exec("git checkout tags/$tag -b $branch");
shell_exec('composer config platform.php 5.3.9'); shell_exec('composer config platform.php 5.3.9');
shell_exec('composer update --no-interaction --no-dev --optimize-autoloader'); shell_exec('composer Update --no-interaction --no-dev --optimize-autoloader');
$zip = new ZipArchive(); $zip = new ZipArchive();
$zip->open($archive, ZipArchive::CREATE | ZipArchive::OVERWRITE); $zip->open($archive, ZipArchive::CREATE | ZipArchive::OVERWRITE);
...@@ -81,7 +81,7 @@ foreach ($tags as $tag) { ...@@ -81,7 +81,7 @@ foreach ($tags as $tag) {
shell_exec("git checkout $currentBranch"); shell_exec("git checkout $currentBranch");
shell_exec("git branch -d $branch"); shell_exec("git branch -d $branch");
shell_exec('git stash pop'); shell_exec('git stash pop');
shell_exec('composer update --no-interaction'); shell_exec('composer Update --no-interaction');
} }
exit(0); exit(0);
...@@ -98,7 +98,7 @@ interface RequestInterface extends MessageInterface ...@@ -98,7 +98,7 @@ interface RequestInterface extends MessageInterface
/** /**
* Returns an instance with the provided URI. * Returns an instance with the provided URI.
* *
* This method MUST update the Host header of the returned request by * This method MUST Update the Host header of the returned request by
* default if the URI contains a host component. If the URI does not * default if the URI contains a host component. If the URI does not
* contain a host component, any pre-existing Host header MUST be carried * contain a host component, any pre-existing Host header MUST be carried
* over to the returned request. * over to the returned request.
...@@ -108,12 +108,12 @@ interface RequestInterface extends MessageInterface ...@@ -108,12 +108,12 @@ interface RequestInterface extends MessageInterface
* `true`, this method interacts with the Host header in the following ways: * `true`, this method interacts with the Host header in the following ways:
* *
* - If the Host header is missing or empty, and the new URI contains * - If the Host header is missing or empty, and the new URI contains
* a host component, this method MUST update the Host header in the returned * a host component, this method MUST Update the Host header in the returned
* request. * request.
* - If the Host header is missing or empty, and the new URI does not contain a * - If the Host header is missing or empty, and the new URI does not contain a
* host component, this method MUST NOT update the Host header in the returned * host component, this method MUST NOT Update the Host header in the returned
* request. * request.
* - If a Host header is present and non-empty, this method MUST NOT update * - If a Host header is present and non-empty, this method MUST NOT Update
* the Host header in the returned request. * the Host header in the returned request.
* *
* This method MUST be implemented in such a way as to retain the * This method MUST be implemented in such a way as to retain the
......
...@@ -72,7 +72,7 @@ interface ServerRequestInterface extends RequestInterface ...@@ -72,7 +72,7 @@ interface ServerRequestInterface extends RequestInterface
* be compatible with the structure of $_COOKIE. Typically, this data will * be compatible with the structure of $_COOKIE. Typically, this data will
* be injected at instantiation. * be injected at instantiation.
* *
* This method MUST NOT update the related Cookie header of the request * This method MUST NOT Update the related Cookie header of the request
* instance, nor related values in the server params. * instance, nor related values in the server params.
* *
* This method MUST be implemented in such a way as to retain the * This method MUST be implemented in such a way as to retain the
......
{
"kind": "ConfigMap",
"apiVersion": "v1",
"metadata": {
"name": "cdzpay",
"namespace": "default",
"selfLink": "/api/v1/namespaces/default/configmaps/cdzpay",
"uid": "56609fea-99f6-11e8-a154-02fba74a71a4",
"resourceVersion": "57326041",
"creationTimestamp": "2018-08-07T03:59:52Z"
},
"data": {
"API_CONDITIONAL_REQUEST": "false",
"API_DEBUG": "true",
"API_DOMAIN": "cdzpay.staging.senthink.com",
"API_NAME": "cdz",
"API_PREFIX": "api",
"API_STANDARDS_TREE": "x",
"API_STRICT": "false",
"API_SUBTYPE": "cdz",
"API_VERSION": "v1",
"APP_DEBUG": "true",
"APP_ENV": "local",
"APP_KEY": "base64:eT7rjn+lf0GHA73E06rxhri1iVDYCRN70RhWxXEo7IM=",
"APP_LOCALE": "zh-CN",
"APP_LOG": "daily",
"APP_TIMEZONE": "PRC",
"CACHE_DRIVER": "file",
"DB_CONNECTION": "mysql",
"DB_DATABASE": "cdzpay",
"DB_HOST": "db.staging.senthink.com",
"DB_PASSWORD": "RRryCfWBXq2Whdq",
"DB_PORT": "3306",
"DB_USERNAME": "senthink",
"GATEWAY_REGISTER": "cdzregister.default.svc.cluster.local:1239",
"JWT_SECRET": "hISaT0VHD8tPvkr9siK2SY21FYtlyH2a",
"LOG_CHANNEL": "daily",
"MANAGE_HOST": "https://cdzback2.staging.senthink.com",
"PRE_DB_DATABASE": "stagingrevealcdz",
"PRE_DB_HOST": "db.staging.senthink.com",
"PRE_DB_PASSWORD": "RRryCfWBXq2Whdq",
"PRE_DB_PORT": "3306",
"PRE_DB_USERNAME": "senthink",
"QUEUE_DRIVER": "sync",
"RABBIT_HOST": "rabbitmq.default.svc.cluster.local",
"RABBIT_LOGIN": "rabbitmq",
"RABBIT_PASSWORD": "senthink123!",
"RABBIT_PORT": "5672",
"RABBIT_VHOST": "cdz_gateway",
"REDIS_HOST": "redis.default.svc.cluster.local",
"REDIS_PORT": "6379",
"WX_APP_ID": "wx5a234043195ec484",
"WX_APP_KEY": "shengpeng2017shengpeng2017shengp",
"WX_APP_SECRET": "74af342df5f80ed48e32deffe893de56",
"WX_MCH_ID": "1426979702",
"WX_TOKEN": "hahaha"
}
}
\ No newline at end of file
...@@ -14,7 +14,6 @@ use Log; ...@@ -14,7 +14,6 @@ use Log;
class Order class Order
{ {
/** /**
* @var int * @var int
*/ */
...@@ -145,7 +144,6 @@ class Order ...@@ -145,7 +144,6 @@ class Order
} }
return $this->orderCache; return $this->orderCache;
} }
...@@ -434,5 +432,4 @@ class Order ...@@ -434,5 +432,4 @@ class Order
} }
} }
\ No newline at end of file
...@@ -45,6 +45,7 @@ class UsingOrderAdaptor ...@@ -45,6 +45,7 @@ class UsingOrderAdaptor
} }
return [ return [
'port_id' => $orderCache['portId'], 'port_id' => $orderCache['portId'],
...@@ -52,7 +53,7 @@ class UsingOrderAdaptor ...@@ -52,7 +53,7 @@ class UsingOrderAdaptor
'state' => $orderCache['stateCode'], 'state' => $orderCache['stateCode'],
'order_id' => $orderCache['id'], 'order_id' => $orderCache['id'],
'charger_time' => $orderCache['purchaseTime'], 'charger_time' => $orderCache['purchaseTime'],
'created_at' => date('Y-m-d H:i:s', $orderCache['createdTime']), 'created_at' => date('Y-m-d H:i:s', isset($orderCache['startTime']) ? $orderCache['startTime'] : $orderCache['createdTime']),
'port_name' => $orderCache['portName'], 'port_name' => $orderCache['portName'],
'order_amount' => number_format($orderCache['payAmount'] / 100, 2), 'order_amount' => number_format($orderCache['payAmount'] / 100, 2),
'start_time' => isset($orderCache['startTime']) ? date('Y-m-d H:i:s', $orderCache['startTime']) : null, 'start_time' => isset($orderCache['startTime']) ? date('Y-m-d H:i:s', $orderCache['startTime']) : null,
......
...@@ -37,7 +37,6 @@ $queueKeyWorker = 'queue_worker_check_port_charger_state'; ...@@ -37,7 +37,6 @@ $queueKeyWorker = 'queue_worker_check_port_charger_state';
$exchange = $myRabbitMq->getExchange(); $exchange = $myRabbitMq->getExchange();
$exchange->setName($myRabbitMq->getExchangeKey()); $exchange->setName($myRabbitMq->getExchangeKey());
$exchange->setType(AMQP_EX_TYPE_DIRECT); $exchange->setType(AMQP_EX_TYPE_DIRECT);
......
<?php
/**
* Created by PhpStorm.
* User: banice
* Date: 2018/10/16
* Time: 上午10:26
*/
namespace Lib\send\command;
use Lib\send\Command;
class UpdateCommand extends Command
{
protected $headerCtrl = 'd2';
private $software = '';
private $hardware = '';
private $updateTime = '';
private $downloadUrl = '';
public function __construct(string $gatewayMac)
{
$this->clientUid = $gatewayMac;
}
public function getMessageBody(): string
{
$updateTime = sprintf('%08x', $this->updateTime);
$urlHex = '';
for ($i = 0; $i < strlen($this->downloadUrl); $i++) {
$hex = sprintf('%02x', ord($this->downloadUrl[$i]));
$urlHex .= $hex;
}
return $updateTime . $this->hardware . $this->software . $urlHex;
}
public function getClientId(): string
{
// TODO: Implement getClientId() method.
}
public function getClientUid(): string
{
return $this->clientUid;
}
/**
* @return string
*/
public function getSoftware(): string
{
return $this->software;
}
/**
* @param string $software
*/
public function setSoftware(string $software): void
{
$this->software = $software;
}
/**
* @return string
*/
public function getHardware(): string
{
return $this->hardware;
}
/**
* @param string $hardware
*/
public function setHardware(string $hardware): void
{
$this->hardware = $hardware;
}
/**
* @return string
*/
public function getUpdateTime(): string
{
return $this->updateTime;
}
/**
* @param string $updateTime
*/
public function setUpdateTime(string $updateTime): void
{
$this->updateTime = $updateTime;
}
/**
* @return string
*/
public function getDownloadUrl(): string
{
return $this->downloadUrl;
}
/**
* @param string $downloadUrl
*/
public function setDownloadUrl(string $downloadUrl): void
{
$this->downloadUrl = $downloadUrl;
}
}
\ No newline at end of file
...@@ -16,29 +16,29 @@ ...@@ -16,29 +16,29 @@
//}); //});
$router->get('/', function () use ($router) { $router->get('/', function () use ($router) {
echo str_random(32);
dd(phpinfo());
dd(\Lib\Gateway::getAllClientSessions()); dd(\Lib\Gateway::getAllClientSessions());
return $router->app->version(); return $router->app->version();
}); });
$router->group(['namespace' => '\Rap2hpoutre\LaravelLogViewer'],function () use ($router){ $router->group(['namespace' => '\Rap2hpoutre\LaravelLogViewer'], function () use ($router) {
$router->get('logs','LogViewerController@index'); $router->get('logs', 'LogViewerController@index');
}); });
$api = app('Dingo\Api\Routing\Router'); $api = app('Dingo\Api\Routing\Router');
$api->version('v1', ['namespace' => 'App\Http\Controllers\V1', 'prefix' => 'api/wx'], function ($api) { $api->version('v1', ['namespace' => 'App\Http\Controllers\V1', 'prefix' => 'api/wx'], function ($api) {
$api->post('notice/update', 'Update\UpdateController@noticeUpdate');
$api->post('firmware', 'Update\UpdateController@upload');
$api->post('user', ['as' => 'wx.token', 'uses' => 'Wx\AccessController@getUserInfo']); $api->post('user', ['as' => 'wx.token', 'uses' => 'Wx\AccessController@getUserInfo']);
//微信网页授权getcode //微信网页授权getcode
...@@ -98,18 +98,17 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\V1', 'prefix' => 'api/ ...@@ -98,18 +98,17 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\V1', 'prefix' => 'api/
$api->get('user/order/using', ['uses' => 'User\StatisticController@getUserUsingOrder']); $api->get('user/order/using', ['uses' => 'User\StatisticController@getUserUsingOrder']);
//token解析 //token解析
$api->post('token/parse',['uses' => 'Tool\TokenController@parse']); $api->post('token/parse', ['uses' => 'Tool\TokenController@parse']);
//更换口子 //更换口子
$api->post('port/change', ['uses' => 'Charger\ChangePortController@change']); $api->post('port/change', ['uses' => 'Charger\ChangePortController@change']);
$api->get('user/recharge/orders',['uses' =>'User\OrderController@getRechargeOrder']); $api->get('user/recharge/orders', ['uses' => 'User\OrderController@getRechargeOrder']);
$api->post('user/withdraw',['uses' => 'User\WithDrawController@withDraw']); $api->post('user/withdraw', ['uses' => 'User\WithDrawController@withDraw']);
$api->get('user/code/withdraw', ['uses' => 'User\WithDrawController@getCode']);
$api->get('user/code/withdraw',['uses' => 'User\WithDrawController@getCode']);
// 查找附近的站点 // 查找附近的站点
...@@ -126,8 +125,7 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\V1', 'prefix' => 'api/ ...@@ -126,8 +125,7 @@ $api->version('v1', ['namespace' => 'App\Http\Controllers\V1', 'prefix' => 'api/
$api->get('send', 'TestController@send'); $api->get('send', 'TestController@send');
$api->any('receiver','Wx\ReceiverController@index'); $api->any('receiver', 'Wx\ReceiverController@index');
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment