Pārlūkot izejas kodu

调整下单金额

xubh 5 gadi atpakaļ
vecāks
revīzija
a73f752257

+ 20 - 9
src/main/java/com/minpay/common/service/impl/OrderServiceImpl.java

@@ -165,15 +165,13 @@ public class OrderServiceImpl implements IOrderService {
 
 							if("00".equals(paymentType)){//随机
 								Random aa = new Random();
-								int randomNum = aa.nextInt(100);
-								Log.info("=============详情编号:"+detailId+"随机数:"+randomNum);
-								if(randomNum > 50){
-									proPrice = CommonUtil.multiply(paymentAmt,"1.15");
-								}else{
-									proPrice = CommonUtil.multiply(paymentAmt,"0.85");
-								}
+								int randomNum = getRandom(85,115);
+								Log.info("=============详情编号:"+detailId+"随机数(比例):"+randomNum);
+								String bili = CommonUtil.divide(String.valueOf(randomNum),"100");
+								proPrice = CommonUtil.multiply(payType,bili);
+
 							}else if("01".equals(paymentType)){ //固定
-								proPrice = paymentAmt;
+								proPrice = payType;
 							}
 
 						}
@@ -226,7 +224,20 @@ public class OrderServiceImpl implements IOrderService {
 				.getMybatisMapper(VmOrderInfMapper.class).insertSelective(ordInf);
 		return ordId;
 	}
-
+	private static int getRandom(int x, int y) {
+		int num = -1;
+		//说明:两个数在合法范围内,并不限制输入的数哪个更大一些
+		if (x < 0 || y < 0) {
+			return num;
+		} else {
+			int max = Math.max(x, y);
+			int min = Math.min(x, y);
+			int mid = max - min;//求差
+			//产生随机数
+			num = (int) (Math.random() * (mid + 1)) + min;
+		}
+		return num;
+	}
 
 
 }