npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ppd-calc

v0.0.0

Published

library-rollup-template 称为 库构建模板,又称 公共代码构建模板 ,是专门用于构建 公共代码(如:封装的库、工具等) 的 rollup 配置模板,当需要开发和构建公共代码时,直接克隆本项目即可,并默认在的 src 目录下开发即可;

Downloads

4

Readme

  • 单标单权益券(优惠券)

  • 单标多权益券/单标多优惠券/单标权益券&优惠券组合

  • 多标权益券(优惠券)

  • 多标多权益券/单标多优惠券/单标权益券&优惠券组合

/**
 * listing: 标的信息
 */
funtion calc( listingInfo1: ListingInfoType, listingInfo2: ListingInfoType, ......) {}

// 标的信息
type ListingInfoType =  {
    listingId: string | number, // 标的ID
    listingFee: number, // 标的总金额
    listingUnPaidInterest: number, // 标的代还利息
    listingUnPaidFee: number, // 标的待还费用
    istingOtherUnPaidFee: number, // 标的其他已优惠金额之和
    promotionList: Array<PromotionListType>, // 权益信息列表
    couponList: Array<couponListType>, // 优惠券信息列表
    calculationDebtsList: Array<calculationDebtsListType>, // 还款计划列表
}

// 权益信息列表
type PromotionListType = {
    batchNo: '7a229aced09a4b1890481cae7a03c96a', // 批次号
    promotionType: 101, // 权益类型
    promotionRule: { // 优惠规则
        totalAmountLimit: 50, // 优惠金额上限
        dealReduceType: 2, // 
        oneUserNumLimit: -1,
        oneUserOneDayNumLimit: -1,
        calRuleType: 'AMOUNT_SPLIT',
        calRule: {
            amountSplitRule: {
                split: 'PER_PERIOD'
            }
        },
        periodLimit: [1, 2, 3, 6, 9, 12, 18, 24, 36]
    },

    // 暂时不用
    promotionTitle: '拍金卡会员专享',
    promotionTypeName: '会员权益',
    productIds: [100000, 100001, 100002, 200001, 200002],
    promotionScenes: 'REPAYMENT',
    startTime: '2024-06-19 00:00:00',
    promotionDesc: '具体优惠形式(还款后返现)以还款时的优惠说明为准.返现将在7个工作日内到账。',
    validateDate: '2025-01-01 00:00:00',
    status: 0
}

// 券信息列表
type CouponList = { ... }

// 还款计划列表
type CalculationDebtsList = {
  periodId: '', // 借款期数ID
  unPaidInterest: number, // 本期待还利息
  unPaidFee: number, // 本期待还费用
  otherUnPaidFee: number, // 本期其他已优惠金额之和
}
// 单标计算

/**
 * promotionMaxReduceAmount - 权益可减免最高总金额
 * listingInterestAndFeeSum - 本标息费之和
 * perPeriodReduceAmount - 每期免息权益可减免金额
 */

- 1. promotionMaxReduceAmount(权益可减免最高总金额) = min(本标息费之和 - 本标其他已优惠金额之和, 优惠金额上限)
    // 本标息费之和 - 本标其他已优惠金额之和 会小于0吗???


- 2. 当上步骤计算结果 promotionMaxReduceAmount大于0时:

  perPeriodReduceAmount(每期免息权益可减免金额) = min(权益可减免最高金额(promotionMaxReduceAmount) / 减免期数, 当期息费 - 当期其他优惠) 
    - 最多只能全免利息
    - 权益可减免最高金额(promotionMaxReduceAmount) / 减免期数 非整数情况向下取整
  
 【权益可减免最高金额/减免期次】最后一期取尾差: 权益可减免最高总金额(promotionMaxReduceAmount) - 前几期减免之和 // 保证减免金额可以减完


- 数据精度:和展示js精度保持一致(暂定每次小数点后两位,向下截取)
// 计算输出 - calcResult:CalcResultType

type CalcResultType = Array<calcResultItemType>

type calcResultItemType = {
  [batchNo]: perPeriodReduceAmount
}
 // 多标计算

/**
 * 权益可减免最高总金额: promotionMaxReduceAmount
 * 本标息费之和: listingInterestAndFeeSum
 * 每期免息权益可减免金额: perPeriodReduceAmount
 * 权益减免比例: reduceRatio
 */

- 1. 根据标的计算每笔标的减免比例:reduceRatio

- 2. promotionMaxReduceAmount(权益可减免最高总金额) = min(本标息费之和 - 本标其他已优惠金额之和, 优惠金额上限)
    > 本标息费之和 - 本标其他已优惠金额之和 会小于0吗???

- 2. 当上步骤计算结果 promotionMaxReduceAmount大于0时:
  > perPeriodReduceAmount(每期免息权益可减免金额) = min(权益可减免最高金额(promotionMaxReduceAmount) / 减免期数, 当期息费 - 当期其他优惠) 
    - 最多只能全免利息
    - 权益可减免最高金额(promotionMaxReduceAmount) / 减免期数 非整数情况向下取整
  
  >【权益可减免最高金额/减免期次】最后一期取尾差: 权益可减免最高总金额(promotionMaxReduceAmount) - 前几期减免之和 // 保证减免金额可以减完


- 数据精度:和展示js精度保持一致(暂定每次小数点后两位,向下截取)