java 商品评价计算算法

  

import java.io.Serializable;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
import java.math.BigDecimal;
import java.math.RoundingMode;/*** 商品评价算法* * @project  icomment* @fileName ProductScore.java* @Description* @author light-zhang* @date 2018年1月15日下午4:44:40* @version 1.0.0*/
public abstract class CommentUtils implements Serializable {private static final long serialVersionUID = 8143504152635422263L;/*************************** 方案一 *******************************************/private static final double baby_ratio = 0.837;// 宝贝评价计算占比(0.837/千)private static final double merchant_ratio = 0.113;// 卖家态度计算占比(0.113/千)private static final double logistics_ratio = 0.0278;// 物流评价计算占比(0.0278/万)private static final double aplatfrom_ration = 0.0037;// 平台影响分A(0.0037/万)private static final double bplatfrom_ration = 0.0185; // 平台影响分B (0.0185/万)private static final double basic_score = 4.7463;// 最高分 /**************************************************************************//*** 方案一 宝贝占比较高,防止卖假货 宝贝评价 0.837(千分比) 5 卖家态度 0.113(千分比) 4 物流服务 0.0278(万分比) 3 平台影响* 0.0037(万分比) 2 平台影响 0.0185(万分比) 1* * @return*/public static BigDecimal babyScore(int baby, int merchant, int logistics) {double value = baby * baby_ratio + (merchant - 1) * merchant_ratio + (logistics - 2) * logistics_ratio+ (2 * aplatfrom_ration) + (1 * bplatfrom_ration);final BigDecimal result = getTemp(new BigDecimal(value));if (result.doubleValue() == basic_score) {return result.setScale(0, RoundingMode.HALF_UP);}return result.setScale(1, RoundingMode.HALF_UP);}/*************************** 方案二************************************************/private static final double syn_baby_ratio = 0.35;private static final double syn_merchant_ratio = 0.25;private static final double syn_logistics_ratio = 0.35;private static final double syn_aplatfrom_ration = 0.3;private static final double syn_bplatfrom_ration = 0.2;private static final double syn_basic_score = 4.6;/**************************************************************************//*** 综合占比率 * @param baby* @param merchant* @param logistics* @return*/public static BigDecimal synthetical(int baby, int merchant, int logistics) {double value = baby * syn_baby_ratio + (merchant - 1) * syn_merchant_ratio+ (logistics - 2) * syn_logistics_ratio + 2 * syn_aplatfrom_ration + 1 * syn_bplatfrom_ration;final BigDecimal result = getTemp(new BigDecimal(value));if (result.doubleValue() == syn_basic_score) {return result.setScale(0, RoundingMode.HALF_UP);}return result.setScale(1, RoundingMode.HALF_UP);}/*** 宝贝梯度 梯度 0失望 1不满意 2一般 3满意 4惊喜 默认返回3满意* * @param avgf* @return*/public static int grads(double avgf) {return (avgf <= 1.5) ? 0: (avgf > 1.5 && avgf <= 2.3) ? 1: (avgf > 2.3 && avgf <= 3.1) ? 2: (avgf > 3.1 && avgf <= 4.0) ? 3 : (avgf > 4.0 && avgf <= 5.0) ? 4 : 3;}private static <T> T getTemp(T classOfType) {ReferenceQueue<T> queue = new ReferenceQueue<T>();WeakReference<T> weakRef = new WeakReference<T>(classOfType, queue);if (null == weakRef.get()) {weakRef = new WeakReference<T>(classOfType);}return weakRef.get();}  public static void main(String[] args) {int baby = 2;int merchant = 2;int logistics = 5;System.out.println("评测1 " + babyScore(baby, merchant, logistics));// 方案一 防止卖假货采用方案System.out.println("梯度1 >>>>> " + grads(babyScore(baby, merchant, logistics).doubleValue()));System.out.println("评测2 " + synthetical(baby, merchant, logistics));// 方案二 综合商家,宝贝,物流采用方案System.out.println("梯度2 >>>>>  " + grads(synthetical(baby, merchant, logistics).doubleValue()));} 
}

 

 

 

 

/**  * 淘宝商品评价  *  * @project icomment  * @fileName ProductScore.java  * @Description  * @author light-zhang  * @date 2018年1月15日下午4:44:40  * @version 1.0.0  */ public abstract class CommentUtils implements Serializable {     private static final long serialVersionUID = 8143504152635422263L;     private static final double BABY_MAKE_UP = 0.837;// 宝贝评价计算占比(0.837/千) private static final double SELLER_MAKE_UP = 0.113;// 卖家态度计算占比(0.113/千) private static final double LOGISTICS_MAKE_UP = 0.0278;//物流评价计算占比(0.0278/万) private static final double PLATFROM_CASHA = 0.0037;// 平台影响分A(0.0037/万) private static final double PLATFROM_CASHB = 0.0185; // 平台影响分B (0.0185/万) private staticfinal double PLATFROM_BASIC = 4.7463;// 最高分/**      * 评价分计算公式 宝贝评价 0.837(千分比) 5 卖家态度 0.113(千分比) 4 物流服务 0.0278(万分比) 3 平台影响      * 0.0037(万分比) 2 平台影响 0.0185(万分比) 1      *      * @param babyMark 宝贝描述      * @param sellerMark 商家态度      * @param logisticsMark 物流服务      * @return 5分×0.837+4分×0.113+3分×0.0278+2分×0.0037+1分×0.0185 =4.7463      */ public static BigDecimal avgProductScore(int babyMark, int sellerMark, int logisticsMark) {         double value = babyMark * BABY_MAKE_UP + (sellerMark - 1) * SELLER_MAKE_UP                 + (logisticsMark - 2) * LOGISTICS_MAKE_UP + (2 * PLATFROM_CASHA) + (1 * PLATFROM_CASHB);         final BigDecimal result = new BigDecimal(value);         if (result.doubleValue() == PLATFROM_BASIC) {// 最高分 return result.setScale(0, RoundingMode.HALF_UP);         }         return result.setScale(1, RoundingMode.HALF_UP);     }     /**      * 梯度 0失望 1不满意 2一般 3满意 4惊喜 默认返回3满意      *      * @return */ public static int grads(double avgf) {         return (avgf <= 1.5) ? 0                 : (avgf > 1.5 && avgf <= 2.3) ? 1                         : (avgf > 2.3 && avgf <= 3.1) ? 2                                 : (avgf > 3.1 && avgf <= 4.0) ? 3                                         : (avgf > 4.0 && avgf <= 5.0) ? 4 : 3;     }     public static void main(String[] args) {         System.out.println(CommentUtils.avgProductScore(5, 3, 4).doubleValue());         System.out.println(CommentUtils.grads(4.5));     } }
[/** * Táobǎo shāngpǐn píngjià * * @project icomment * @fileName ProductScore.Java * @Description * @author light-zhang * @date 2018 nián 1 yuè 15 rì xiàwǔ 4:44:40 * @Version 1.0.0 */ Public abstract class CommentUtils implements Serializable { private static final long serialVersionUID = 8143504152635422263L; private static final double BABY_MAKE_UP = 0.837;// Bǎobèi píngjià jìsuàn zhàn bǐ (0.837/Qiān) private static final double SELLER_MAKE_UP = 0.113;// Màijiā tàidù jìsuàn zhàn bǐ (0.113/Qiān) private static final double LOGISTICS_MAKE_UP = 0.0278;// Wùliú píngjià jìsuàn zhàn bǐ (0.0278/Wàn) private static final double PLATFROM_CASHA = 0.0037;// Píngtái yǐngxiǎng fēn A(0.0037/Wàn) private static final double PLATFROM_CASHB = 0.0185; // Píngtái yǐngxiǎng fēn B (0.0185/Wàn) private static final double PLATFROM_BASIC = 4.7463;// Zuìgāo fēn/** * píngjià fēn jìsuàn gōngshì bǎobèi píngjià 0.837(Qiānfēnbǐ) 5 màijiā tàidù 0.113(Qiānfēnbǐ) 4 wùliú fúwù 0.0278(Wànfēn bǐ) 3 píngtái yǐngxiǎng * 0.0037(Wànfēn bǐ) 2 píngtái yǐngxiǎng 0.0185(Wànfēn bǐ) 1 * * @param babyMark bǎobèi miáoshù * @param sellerMark shāngjiā tàidù * @param logisticsMark wùliú fúwù * @return 5 fēn ×0.837+4 Fēn ×0.113+3 Fēn ×0.0278+2 Fēn ×0.0037+1 Fēn ×0.0185 =4.7463 */ Public static BigDecimal avgProductScore(int babyMark, int sellerMark, int logisticsMark) { double value = babyMark* BABY_MAKE_UP + (sellerMark - 1)* SELLER_MAKE_UP + (logisticsMark - 2)* LOGISTICS_MAKE_UP + (2* PLATFROM_CASHA) + (1* PLATFROM_CASHB); final BigDecimal result = new BigDecimal(value); if (result.DoubleValue() == PLATFROM_BASIC) {// zuìgāo fēn return result.SetScale(0, RoundingMode.HALF_UP); } return result.SetScale(1, RoundingMode.HALF_UP); } /** * tīdù 0 shīwàng 1 bù mǎnyì 2 yībān 3 mǎnyì 4 jīngxǐ mòrèn fǎnhuí 3 mǎnyì * * @return*/ public static int grads(double avgf) { return (avgf <= 1.5)? 0 : (Avgf > 1.5&& Avgf <= 2.3)? 1 : (Avgf > 2.3&& Avgf <= 3.1)? 2 : (Avgf > 3.1&& Avgf <= 4.0)? 3 : (Avgf > 4.0&& Avgf <= 5.0)? 4: 3; } Public static void main(String[] args) { System.Out.Println(CommentUtils.AvgProductScore(5, 3, 4).DoubleValue()); System.Out.Println(CommentUtils.Grads(4.5)); } }]
/**
 * Taobao product evaluation
 *
 * @project icomment
 * @fileName ProductScore.java
 * @Description
 * @author light-zhang
 * @date January 15, 2018, 4:44:40 PM
 * @version 1.0.0
 */ public abstract class CommentUtils implements Serializable {

    Private static final long serialVersionUID = 8143504152635422263L;

    Private static final double BABY_MAKE_UP = 0.837;// Baby evaluation calculation ratio (0.837/th) private static final double SELLER_MAKE_UP = 0.113;// Seller attitude calculation ratio (0.113/th) private static final double LOGISTICS_MAKE_UP = 0.0278;// Logistics evaluation calculation ratio (0.0278/Million) private static final double PLATFROM_CASHA = 0.0037;// Platform impact points A (0.0037/Million) private static final double PLATFROM_CASHB = 0.0185; // Platform impact points B (0.0185/Million) private static Final double PLATFROM_BASIC = 4.7463;// highest score /**
     * Evaluation score calculation formula Baby evaluation 0.837 (thousands ratio) 5 Seller attitude 0.113 (thousands ratio) 4 Logistics service 0.0278 (10,000 ratio) 3 Platform impact
     * 0.0037 (parts ratio) 2 Platform impact 0.0185 (10,000 ratio) 1
     *
     * @param babyMark baby description
     * @param sellerMark Business attitude
     * @param logisticsMark Logistics Services
     * @return 5 points × 0.837 + 4 points × 0.113 + 3 points × 0.0278 + 2 points × 0.0037 + 1 points × 0.015 = 4.7463
     */ public static BigDecimal avgProductScore(int babyMark, int sellerMark, int logisticsMark) {
        Double value = babyMark * BABY_MAKE_UP + (sellerMark - 1) * SELLER_MAKE_UP
                + (logisticsMark - 2) * LOGISTICS_MAKE_UP + (2 * PLATFROM_CASHA) + (1 * PLATFROM_CASHB);
        Final BigDecimal result = new BigDecimal(value);
        If (result.doubleValue() == PLATFROM_BASIC) {// highest score return result.setScale(0, RoundingMode.HALF_UP);
        }
        Return result.setScale(1, RoundingMode.HALF_UP);
    }

    /**
     * Gradient 0 Disappointment 1 Dissatisfied 2 General 3 Satisfied 4 Surprise Default 3 Satisfied
     *
     * @return */ public static int grads(double avgf) {
        Return (avgf <= 1.5) ? 0
                : (avgf > 1.5 && avgf <= 2.3) ? 1
                        : (avgf > 2.3 && avgf <= 3.1) ? 2
                                : (avgf > 3.1 && avgf <= 4.0) ? 3
                                        : (avgf > 4.0 && avgf <= 5.0) ? 4 : 3;
    }

    Public static void main(String[] args) {
        System.out.println(CommentUtils.avgProductScore(5, 3, 4).doubleValue());
        System.out.println(CommentUtils.grads(4.5));
    }
}

转载于:https://www.cnblogs.com/light-zhang/p/8349576.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/278536.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

rainmeter使用教程_如何使用Rainmeter在桌面上显示报价

rainmeter使用教程I’ve never really been a desktop gadgets and widgets type of person, but I often put an inspirational quote on my desktop wallpaper. Today we’ll show you how to do this using Rainmeter, no matter what wallpaper you switch to. 我从来没有真…

Some code changes cannot be hot swapped into a running virtual machine

java运行中修改代码不能改变立刻应用到本次运行中转载于:https://www.cnblogs.com/Pusteblume/p/10211110.html

自定义v-drag指令(横向拖拽滚动)

指令 Vue.directive(drag, {// 钩子函数&#xff0c;被绑定元素插入父节点时调用 (父节点存在即可调用&#xff0c;不必存在于 document 中)。inserted: (el, binding, vnode, oldVnode) > {console.log(el, binding, vnode, oldVnode)let drag el; // 要拖拽的元素// let …

javascript获取时间差

function GetDateDiff(startTime, endTime, diffType) {//将xxxx-xx-xx的时间格式&#xff0c;转换为 xxxx/xx/xx的格式 startTime startTime.replace(/\-/g, "/");endTime endTime.replace(/\-/g, "/");//将计算间隔类性字符转换为小写diffType diffTy…

JMeter扩展JMeter插件获取更多监听器

为了获取更多监听器&#xff0c;方便的监控系统及应用&#xff0c;有必要安装第三方插件 插件下载地址&#xff1a; https://jmeter-plugins.org/downloads/old/ http://pan.baidu.com/s/1gfC11yN 注&#xff1a;如果插件和软件版本不兼容&#xff0c;可能在开启Jmeter时会报错…

如何阻止Chrome(或Edge)接管媒体密钥

Google Chrome now has built-in support for media keys. Unfortunately, Chrome will take over your media keys and prevent them from controlling apps like Spotify when you’re watching YouTube, for example. Here’s how to make Chrome ignore your media keys. G…

js滚动条滚动到指定元素

let item document.getElementById("item"); // 指定的元素 let wrapper document.getElementById("wrapper"); // 其父元素 - 必须是产生滚动条的元素// 元素聚焦法定位 // item.focus(); // 可用 outline:none; 除去聚焦产生的框; 对于默认没有聚焦的…

开源性能测试工具JMeter快速入门(一)

目录一、JMeter简介二、JMeter功能介绍三、JMeter脚本四、关于JMeter小提示一、JMeter简介1.定义JMeter是Apache组织开发的基于Java的压力测试工具。用于对软件做压力测试&#xff0c;它最初被设计用于Web应用测试&#xff0c;但后来扩展到其他测试领域。 1&#xff09;它可以用…

八重州8900如何解锁_八重贵族怪胎之路

八重州8900如何解锁Dealing with computers day in and day out can be a harrowing experience. In difficult times, or even when things are idle, finding some spirituality can help cope with the experience—Techies: I give you the Eightfold Noble Geek Path. 日…

mysql 5.7.18 winx64安装配置方法

在mysql-5.7.18-winx64文件夹下新建my.ini文件[mysql] # 设置mysql客户端默认字符集 default-character-setutf8 [mysqld] #设置3306端口 port 3306 # 设置mysql的安装目录 basedirD:\Program Files\mysql-5.7.18-winx64 # 设置mysql数据库的数据的存放目录 datadirD:\Prog…

js 实现拖拽滚动、滚轮缩放元素函数和案例

文章目录一、拖拽滚动1、封装函数2、示例&#xff1a;二、滚轮缩放1、封装函数2、结合拖拽滚动示例一、拖拽滚动 1、封装函数 /*** description 使用鼠标拖拽div&#xff0c;实现横向、纵向滚动* param el 被拖拽滚动的元素&#xff08;产生滚动条的元素&#xff09;*/functio…

怎么解决input中readonly属性的iOS一直存在光标问题

用css中的pointer-events:none转载于:https://www.cnblogs.com/studyh5/p/8352061.html

赠与大学毕业生_出售,赠与或交易iPhone之前应该做什么

赠与大学毕业生A factory reset of your iPhone erases all of your content and settings, reverting it to a like-new state. However, there are a few extra steps you should take if you plan to get rid of your iPhone. iPhone的恢复出厂设置将删除所有内容和设置&…

layui radio 根据获取的到值选中

<input type"radio" name"lwkg" value"1" title"开" lay-filter"lwkg"> <input type"radio" name"lwkg" value"0" title"关" lay-filter"lwkg"> layui.use(…

设置Mac自动显示和隐藏 Dock 栏的速度

Dock 显示和隐藏&#xff0c;系统默认设置成了1秒 通过终端.APP修改显示和隐藏的时间 &#xff08;单位&#xff1a;秒&#xff09; 默认的&#xff1a;defaults write com.apple.dock autohide-delay -int 1 优化的&#xff1a;defaults write com.apple.dock autohide-del…

powerpoint预览_如何放大和缩小PowerPoint演示文稿的一部分

powerpoint预览Microsoft PowerPoint lets you zoom in and out on a specific part of your PowerPoint slideshow, which can be handy both while editing and for drawing attention to important objects or ideas during the presentation. Here’s how to do it. Micros…

GitGitHub语法大全

目录 1. GitHub与Git万用语法1&#xff09;创建库2&#xff09;添加和提交到仓库3&#xff09;版本回退4&#xff09;缓存区和暂存区5&#xff09;撤销和删除文件6)远程仓库7)创建和合并分支2. 更多Git语法1. GitHub与Git万用语法 1&#xff09;创建库 git init 2&#xff09;添…

从Firefox控制您喜欢的音乐播放器

Do you love listening to music while you browse? Now you can access and control your favorite music player directly from Firefox with the FoxyTunes extension. 您喜欢在浏览时听音乐吗&#xff1f; 现在&#xff0c;您可以直接使用FoxyTunes扩展程序从Firefox访问和…

富文本编辑器初探

长期以来&#xff0c;作为用户我是富文本编辑器的使用者&#xff0c;作为前端开发&#xff0c;我也只是富文本插件的使用者&#xff0c;对内部实现细节不甚了解&#xff0c;使用上也只停留在调用插件提供的API&#xff0c;实现一些业务逻辑。最近的项目&#xff0c;需要开发一个…

特殊的求和(函数和循环)

【问题描述】 编写函数int fun(int a,int n)求Sn a aa aaa … aa…a 的值&#xff08;最后一个数中 a 的个数为 n &#xff09;&#xff0c;其中 a 是一个1~9的数字&#xff0c;例如&#xff1a;2 22 222 2222 22222 &#xff08;此时 a2 n5 &#xff09; 。参数由主函…