phi_platform_common/src/main/java/com/hx/phip/tool/order/OrderTool.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
phi_platform_common/src/main/java/com/hx/phip/tool/user/UserCardTool.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
phi_platform_common/src/main/java/com/hx/phip/tool/order/OrderTool.java
New file @@ -0,0 +1,31 @@ package com.hx.phip.tool.order; import com.hx.common.service.CommonService; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.model.consume.ConsumePayItem; import com.hx.phip.dao.mapper.ConsumePayItemMapper; import java.util.HashMap; import java.util.List; import java.util.Map; /**订单工具类*/ public class OrderTool { /**获取一级子单的支付方式 * @param orderOneId 子单标识 * @param commonService 医生 * @return 支付方式集合 */ public static List<ConsumePayItem> getOrderOnePay(String orderOneId, CommonService commonService){ SqlSentence sqlSentence = new SqlSentence(); Map<String,Object> values = new HashMap<>(); values.put("typeId",orderOneId); sqlSentence.sqlSentence("SELECT * FROM consume_pay_item WHERE isDel = 0 AND typeId = #{m.typeId}",values); return commonService.selectList(ConsumePayItemMapper.class,sqlSentence); } } phi_platform_common/src/main/java/com/hx/phip/tool/user/UserCardTool.java
@@ -1,15 +1,25 @@ package com.hx.phip.tool.user; import com.hx.common.service.CommonService; import com.hx.exception.TipsException; import com.hx.mybatisTool.SqlSentence; import com.hx.phiappt.model.cardItem.CardEquity; import com.hx.phiappt.model.cardItem.CardItemInfo; import com.hx.phiappt.model.consume.ConsumePayItem; import com.hx.phiappt.model.order.OrderItem; import com.hx.phiappt.model.order.OrdersTotal; import com.hx.phiappt.model.user.UserCard; import com.hx.phiappt.model.user.UserCardUsed; import com.hx.phip.dao.mapper.OrderItemMapper; import com.hx.phip.dao.mapper.OrdersTotalMapper; import com.hx.phip.dao.mapper.UserCardUsedMapper; import com.hx.phip.tool.order.OrderTool; import com.hx.phip.vo.user.UserCardItemInfoVo; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; import java.util.stream.Collectors; /** *用户卡包处理工具 @@ -163,4 +173,44 @@ return userCardUsed; } /**计算用户卡包购买时候的金额分摊方式-订单*/ public static void userCardPay(UserCard userCard,CommonService commonService){ //不是订单购买的卡包,跳出循环 if(UserCard.SOURCE_TYPE_ORDER_ONE != userCard.getSourceType()){ return; } //通过购买这个卡项的订单来算单卡的钱是多少 //查询已经退了多少钱,避免退超了支付方式金额 OrderItem orderItem = commonService.selectOneByKey(OrderItemMapper.class,userCard.getSourceId()); if(orderItem == null){ throw new TipsException("获取订单子信息失败[895]"); } if(orderItem.getBuyNum().compareTo(0) < 1){ throw new TipsException("获取订单子信息购买数量错误!"); } //求单个金额 BigDecimal total = orderItem.getActualTotal().divide(new BigDecimal(orderItem.getBuyNum()),2, RoundingMode.UP); //金额不是0元以上,不处理 if(total.compareTo(BigDecimal.ZERO) <= 0){ return; } /**获取订单支付方式*/ List<ConsumePayItem> consumePayItemList = OrderTool.getOrderOnePay(userCard.getSourceId(),commonService); consumePayItemList = consumePayItemList.stream().sorted(Comparator.comparing(ConsumePayItem::getpTotal)) .collect(Collectors.toList()); //求比率 BigDecimal proportion = total.divide(orderItem.getActualTotal(),20,RoundingMode.HALF_UP); for(ConsumePayItem consumePayItem:consumePayItemList){ } } } phi_platform_user/src/main/java/com/hx/phip/util/api/OrderCreateUtil.java
@@ -868,7 +868,7 @@ //计算订单卡项金额信息 //一级子订单:售价=卡项售价*折扣 BigDecimal actualTotal = cardItem.getTotal().multiply(vo.getDiscount().divide(new BigDecimal(100))); BigDecimal actualTotal = cardItem.getTotal().multiply(vo.getDiscount().divide(new BigDecimal(100))).setScale(2,RoundingMode.HALF_UP); //总订单:订单优惠金额=商品的售价*数量 减去 一级子订单售价*购买数量; discountTotal=discountTotal.add(cardItem.getTotal().multiply(buyNum).subtract(actualTotal.multiply(buyNum)));