@@ -8,6 +8,7 @@ import * as wakachigaki from 'wakachigaki';
88import * as TypesApiEndpoint from '../types/ApiEndpoint.js' ;
99import * as TypesApiFiles from '../types/ApiFiles.js' ;
1010import appConfig from './config.js' ;
11+ import configReadOnly from './configReadOnly.js' ;
1112import mathUtils from './math.js' ;
1213import stringUtils from './string.js' ;
1314
@@ -158,15 +159,43 @@ function printWorkInfo(workApiRsp: {
158159 const availableMaxTextWidth = Math . min ( 54 , process . stdout . columns - 20 ) ;
159160
160161 const tmpObj = {
161- dlCount : workApiRsp . info . dl_count . toLocaleString ( ) ,
162- price : workApiRsp . info . price . toLocaleString ( ) ,
163- totalSales : ( workApiRsp . info . price * workApiRsp . info . dl_count ) . toLocaleString ( ) ,
162+ dlCount : workApiRsp . infoOrig . dl_count . toLocaleString ( ) ,
163+ price : workApiRsp . infoOrig . price . toLocaleString ( ) ,
164+ ...( ( ) => {
165+ const outPrice : number = ( workApiRsp . infoOrig . price * 100 ) / ( 100 + configReadOnly . jpyTax ) ;
166+ const inputPrice : number =
167+ outPrice > configReadOnly . dlsitePriceTable . at ( - 1 ) ?. output !
168+ ? outPrice * 0.8
169+ : configReadOnly . dlsitePriceTable . find ( ( e ) => e . output === outPrice ) ! . input ;
170+ const dlsiteFeePrice : number = outPrice - inputPrice ;
171+ return {
172+ creatorEarn : ( inputPrice * workApiRsp . infoOrig . dl_count ) . toLocaleString ( ) ,
173+ bizEarn : ( dlsiteFeePrice * workApiRsp . infoOrig . dl_count ) . toLocaleString ( ) ,
174+ feePcnt : mathUtils . rounder ( 'round' , ( dlsiteFeePrice / inputPrice ) * 100 , 1 ) . orig . toString ( ) + '%' ,
175+ } ;
176+ } ) ( ) ,
164177 totalSize : mathUtils . formatFileSize (
165178 mathUtils . arrayTotal ( workApiRsp . fileEntry . transformed . map ( ( e ) => e . size ) ) ,
166179 fmtFileSizeDefaultCfg ,
167180 ) ,
168181 } ;
169182
183+ // (() => {
184+ // const table2 = new CliTable3(cliTableConfig.rounded);
185+ // table2.push(
186+ // ['Input', 'Output', 'Fee', 'Fee%'].map((e) => chalk.dim(e)),
187+ // ...configReadOnly.dlsitePriceTable.map((e) =>
188+ // [
189+ // e.input.toLocaleString(),
190+ // e.output.toLocaleString(),
191+ // (e.output - e.input).toLocaleString(),
192+ // mathUtils.rounder('round', ((e.output - e.input) / e.input) * 100, 1).padded + '%',
193+ // ].map((f) => ({ hAlign: 'right' as const, content: f })),
194+ // ),
195+ // );
196+ // console.log(table2.toString());
197+ // })();
198+
170199 table . push (
171200 ...[
172201 [ 'ID' , workApiRsp . info . source_id ] ,
@@ -200,8 +229,6 @@ function printWorkInfo(workApiRsp: {
200229 availableMaxTextWidth ,
201230 ) . join ( '\n' ) ,
202231 ] ,
203- [ 'Release Date' , DateTime . fromISO ( workApiRsp . info . release ) . toFormat ( 'yyyy/MM/dd' ) ] ,
204- [ 'Created Date' , DateTime . fromISO ( workApiRsp . info . create_date ) . toFormat ( 'yyyy/MM/dd' ) ] ,
205232 [
206233 'Age Category' ,
207234 stringUtils . replaceMultiPatterns (
@@ -213,11 +240,20 @@ function printWorkInfo(workApiRsp: {
213240 workApiRsp . info . age_category_string ,
214241 ) ,
215242 ] ,
243+ [ 'Release Date' , DateTime . fromISO ( workApiRsp . info . release ) . toFormat ( 'yyyy/MM/dd' ) ] ,
244+ [ 'Created Date' , DateTime . fromISO ( workApiRsp . info . create_date ) . toFormat ( 'yyyy/MM/dd' ) ] ,
216245 [ 'DL Count' , tmpObj . dlCount . padStart ( mathUtils . arrayMax ( Object . values ( tmpObj ) . map ( ( e ) => e . length ) ) , ' ' ) ] ,
217246 [ 'Price' , tmpObj . price . padStart ( mathUtils . arrayMax ( Object . values ( tmpObj ) . map ( ( e ) => e . length ) ) , ' ' ) + ' JPY' ] ,
218247 [
219- 'Total Sales' ,
220- tmpObj . totalSales . padStart ( mathUtils . arrayMax ( Object . values ( tmpObj ) . map ( ( e ) => e . length ) ) , ' ' ) + ' JPY' ,
248+ 'Creator Earn' ,
249+ tmpObj . creatorEarn . padStart ( mathUtils . arrayMax ( Object . values ( tmpObj ) . map ( ( e ) => e . length ) ) , ' ' ) + ' JPY' ,
250+ ] ,
251+ [
252+ 'DLsite Earn' ,
253+ tmpObj . bizEarn . padStart ( mathUtils . arrayMax ( Object . values ( tmpObj ) . map ( ( e ) => e . length ) ) , ' ' ) +
254+ ' JPY (' +
255+ tmpObj . feePcnt +
256+ ' fee)' ,
221257 ] ,
222258 [
223259 'Total Size' ,
@@ -276,10 +312,11 @@ function generateProgBarBox(current: number, total: number, width: number, useSh
276312 const remainingChars = width - usedChars ;
277313
278314 // generate empty area (LIGHT SHADE or space)
279- const emptyChar = useShade ? '\u2591' : ' ' ;
315+ // const emptyChar = useShade ? '\u2591' : ' ';
316+ const emptyChar = ' ' ;
280317 bar += emptyChar . repeat ( remainingChars ) ;
281318
282- return bar ;
319+ return useShade ? chalk . bgHex ( '#404040' ) ( bar ) : bar ;
283320}
284321
285322function detectUseFancyProgBarBox ( ) : Record < 'fancy' | 'shade' , boolean > {
0 commit comments