|
|
|
@@ -0,0 +1,74 @@ |
|
|
|
<?php |
|
|
|
|
|
|
|
namespace App\Repositories; |
|
|
|
|
|
|
|
use App\Exceptions\AppCommonException; |
|
|
|
use App\Models\ColumnName; |
|
|
|
use App\Models\HtpmsCustomer\Deposit\DepositTransfer; |
|
|
|
use App\Repositories\BaseRepository; |
|
|
|
use Illuminate\Support\Collection; |
|
|
|
use Illuminate\Support\Facades\DB; |
|
|
|
|
|
|
|
class DepositTransferRepository extends BaseRepository |
|
|
|
{ |
|
|
|
|
|
|
|
const CONDITION_ID = 'id'; |
|
|
|
const CONDITION_SHOP_ID = ColumnName::SHOP_ID; |
|
|
|
|
|
|
|
const TABLE_TRANSFER = "transfer"; |
|
|
|
|
|
|
|
/** |
|
|
|
* コレクションを取得する |
|
|
|
* |
|
|
|
* @param array $condition |
|
|
|
* @return Collection<int,DepositTransferRepositoryData> |
|
|
|
*/ |
|
|
|
public function get(array $condition): Collection |
|
|
|
{ |
|
|
|
|
|
|
|
$table = DepositTransfer::getBuilder(static::TABLE_TRANSFER); |
|
|
|
// -----検索条件 |
|
|
|
|
|
|
|
// SHOP_ID 必須項目 |
|
|
|
$shopId = data_get($condition, self::CONDITION_SHOP_ID); |
|
|
|
if ($shopId) { |
|
|
|
$this->where($table, $condition, static::CONDITION_SHOP_ID, $this->makeColumnName([static::TABLE_TRANSFER, DepositTransfer::COL_NAME_SHOP_ID])); |
|
|
|
} else { |
|
|
|
throw new AppCommonException("SHOP_ID不正"); |
|
|
|
} |
|
|
|
|
|
|
|
// ID |
|
|
|
$this->where($table, $condition, static::CONDITION_ID, $this->makeColumnName([static::TABLE_TRANSFER, DepositTransfer::COL_NAME_ID])); |
|
|
|
|
|
|
|
$table->select($this->columns()); |
|
|
|
|
|
|
|
$main = DB::connection("htpms_customer")->table($table, "main"); |
|
|
|
|
|
|
|
// ソート |
|
|
|
$this->sort($main, $condition); |
|
|
|
$main->orderByDesc($this->makeColumnName([DepositTransfer::COL_NAME_TRANSFER_DATETIME])); |
|
|
|
|
|
|
|
// リミット |
|
|
|
$this->limit($main, $condition); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return LoginUserRepositoryData::makeList($main->get()); |
|
|
|
} |
|
|
|
|
|
|
|
private function columns() |
|
|
|
{ |
|
|
|
$transfer = static::TABLE_TRANSFER; |
|
|
|
$columns = [ |
|
|
|
$this->makeColumnNameForSelect([$transfer, DepositTransfer::COL_NAME_ID]), |
|
|
|
$this->makeColumnNameForSelect([$transfer, DepositTransfer::COL_NAME_TRANSFER_DATETIME]), |
|
|
|
$this->makeColumnNameForSelect([$transfer, DepositTransfer::COL_NAME_TRANSFER_AMOUNT]), |
|
|
|
$this->makeColumnNameForSelect([$transfer, DepositTransfer::COL_NAME_TRANSFER_REASON]), |
|
|
|
$this->makeColumnNameForSelect([$transfer, DepositTransfer::COL_NAME_AFTER_AMOUNT]), |
|
|
|
$this->makeColumnNameForSelect([$transfer, DepositTransfer::COL_NAME_BEFORE_AMOUNT]), |
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
return $columns; |
|
|
|
} |
|
|
|
} |