ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 组件源码 ``` /** * <b>方法描述:</b> 乘 <br/> * <b>创建者:</b> admin <br/> * <b>创建时间:</b> 2018-05-11 11:50:03 <br/> * * @param amt1 * 入参|金额1|{@link Object} * @param amt2 * 入参|金额2|{@link Object} * @param scale * 入参|小数精度(默认2)|{@link java.lang.Integer} * @param round * 入参|舍入(默认四舍五入)|{@link java.lang.Integer} * @param amt3 * 出参|积|{@link java.lang.String} * @return 0 失败<br/> * 1 成功<br/> */ @Component(label = "乘", style = "判断型", type = "同步组件", comment = "乘法运算。除非指定,否则小数默认保留两位,舍入模式使用四舍五入;0->ROUND_UP(入);1->ROUND_DOWN(舍);2->ROUND_CEILING(正入负舍);3->ROUND_FLOOR(正舍负入);4->ROUND_HALF_UP(四舍五入);5->ROUND_HALF_DOWN(五舍六入);6->ROUND_HALF_EVEN(银行家舍入)", version = "1.0.0", deprecated = false, author = "admin", date = "2018-05-11 11:50:03") @InParams(param = {@Param(name = "amt1", comment = "金额1", type = Object.class), @Param(name = "amt2", comment = "金额2", type = Object.class), @Param(name = "scale", comment = "小数精度(默认2)", type = java.lang.Integer.class), @Param(name = "round", comment = "舍入(默认四舍五入)", type = java.lang.Integer.class)}) @OutParams(param = {@Param(name = "amt3", comment = "积", type = java.lang.String.class)}) @Returns(returns = {@Return(id = "0", desp = "失败"), @Return(id = "1", desp = "成功")}) public static ResultBase P_multiply(Object amt1, Object amt2, Integer scale, Integer round) { if (scale == null) scale = 2; if (round == null) round = BigDecimal.ROUND_HALF_UP; BigDecimal d1 = transform(amt1); BigDecimal d2 = transform(amt2); if (d1 != null && d2 != null) { BigDecimal d3 = d1.multiply(d2); d3 = d3.setScale(scale, round); return ResultBase.newSuccessResult(d3.toString()); } return ResultBase.newFailureResult("TPTA0011", "输入计算金额数据不是合法数据,输入值1=" + amt1 + ",值2=" + amt2); } ``` # 交易中组件使用方式 ![](https://img.kancloud.cn/d8/f6/d8f6e1c6603a9eb1ebda5aa4c8d29c12_1868x885.png) # 参数说明及示例 ## 入口参数 金额1:传入数值型参数,示例: `__REQ__["amount1"]` 金额2:传入数值型参数,示例: `__REQ__["amount2"]` 小数精度(默认2):设置保留几位小数,不传此参数时,默认保留2位,示例: `__REQ__["scale"]` 舍入(默认四舍五入):设置小数保留条件,不传此参数,默认四舍五入,详细信息在组件注释中查看,示例: `__REQ__["round"]` ## 出口参数 积:金额1乘以金额2,并根据舍入和小数位数得出的结果,示例: `__INNER__["product"]`