Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * バッチ
- * 開発:env APPLICATION_ENV=devel3004 sudo php batch.php [provider_id]
- * 本番:env APPLICATION_ENV=production sudo php batch.php [provider_id]
- *
- */
- // プラットフォームを設定
- //$provider_id = $argv[1];
- ini_set( "memory_limit", "-1" );
- defined( 'APPLICATION_ENV' )
- || define( 'APPLICATION_ENV', ( getenv( 'APPLICATION_ENV' ) ? getenv( 'APPLICATION_ENV' ) : 'devel' ) );
- define( 'PROVIDER_ID', 'gree' );
- $sy_home = getenv( 'SYNPHONIE_HOME' ) ? getenv( 'SYNPHONIE_HOME' ) : '/home/sy';
- require_once $sy_home . '/bin/drpr/autoload.php';
- if ( APPLICATION_ENV == 'devel' ) {
- S::setLogLevel('debug');
- } else {
- S::setLogLevel('info');
- }
- S::setLogDir( '/logs/' . APP_NAME . '/' . PROVIDER_ID . '/zend' );
- $db = new Synphonie_Framework_Model_Db();
- $csv_file = isset($argv[1]) ? $argv[1] : 'drpr20190312.csv';
- $dryrun_mode = isset( $argv[ 2 ] ) ? $argv[2] : 0;
- if(!file_exists($csv_file)) die($csv_file.' is not exists');
- $path_info = pathinfo( __FILE__ );
- $log_file = realpath( dirname( __FILE__ ) ) . '/' . $path_info['filename'] . '.log';
- $fp_log = fopen( $log_file, "a");
- $f = file($csv_file);
- $header = true;
- $result = array();
- foreach($f as $v){
- if ($header) {
- $header = false;
- continue;
- }
- if(trim($v)){
- list($pf, $ins_date, $uid, $card_id, $level, $bexp, $aexp) = $separate = explode(',',trim($v));
- $ins_date = substr($ins_date, 1, -5);
- $pf = str_replace('"', '', $pf);
- $uid = str_replace('"', '', $uid);
- $card_id = str_replace('"', '', $card_id);
- $material_ids = array();
- for ($i = 7; $i <= count($separate) - 1; $i++) {
- $material_id = $separate[$i];
- $material_id = str_replace('"', '', $material_id);
- $material_id = str_replace('[', '', $material_id);
- $material_id = str_replace(']', '', $material_id);
- $material_ids[] = $material_id;
- }
- $base_card = new App_Master_Card($card_id, $level, $bexp);
- $material_cards = null;
- foreach ($material_ids as $material_id) {
- $material_cards[] = App_Master_Card::getInstance($material_id);
- }
- $cost = 0;
- foreach ($material_cards as $material_card) {
- $add_cost = ($bexp * 10) + ($material_card->getExp() * 15);
- if (strtotime($ins_date) >= strtotime('2019-03-11 16:00:00')) {
- $add_cost = floor( $add_cost * App_Enhancement::ENHANCEMENT_COST_RATE );
- }
- $cost += $add_cost;
- }
- if (isset($result[$pf][$uid])) {
- $result[$pf][$uid] = array(
- 'cost' => $result[$pf][$uid]['cost'] + $cost,
- 'mate' => array_merge($result[$pf][$uid]['mate'], $material_ids),
- );
- } else {
- $result[$pf][$uid] = array(
- 'cost' => $cost,
- 'mate' => $material_ids,
- );
- }
- }
- }
- foreach ($result as $pf => $pf_list) {
- foreach ($pf_list as $uid => $value) {
- echo $pf . 'tab' . $uid . 'tab' . $value['cost'] . 'tab' . json_encode($value['mate']) . PHP_EOL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement