Explorar el Código

下单金额,游戏计算金额处理

xubh hace 5 años
padre
commit
bba1b12624

+ 1 - 1
src/main/java/com/minpay/common/service/IDrawService.java

@@ -34,7 +34,7 @@ public interface IDrawService extends IMINLocalService {
 							   List<DrawDto> drawDto) throws BusinessCodeException, MINBusinessException;
 
 
-	public List<DrawDto> orderDrawGame(VmOrderInf orderInf, VmProEquRel proEquRel, VmOrderDetails vmOrderDetails
+	public List<DrawDto> orderDrawGame(VmOrderInf orderInf, VmProEquRel proEquRel, VmOrderDetails vmOrderDetails,String detailsAmt
 									 ) throws BusinessCodeException, MINBusinessException;
 
 

+ 2 - 2
src/main/java/com/minpay/common/service/impl/DrawServiceImpl.java

@@ -97,14 +97,14 @@ public class DrawServiceImpl implements IDrawService {
         return drawDtoList;
     }
 
-    public List<DrawDto> orderDrawGame(VmOrderInf orderInf, VmProEquRel proEquRel, VmOrderDetails vmOrderDetails) throws BusinessCodeException, MINBusinessException {
+    public List<DrawDto> orderDrawGame(VmOrderInf orderInf, VmProEquRel proEquRel, VmOrderDetails vmOrderDetails,String detailsAmt) throws BusinessCodeException, MINBusinessException {
 
         //获取累计金额
         String accumulatedAmount = proEquRel.getAccumulatedAmount();
         //获取中奖范围
         String drawAmount = proEquRel.getDrawAmount();
         //订单金额
-        String orderAmt = orderInf.getOrderAmt();
+        String orderAmt = detailsAmt;
         //计算当前累计金额
         String amt = CommonUtil.add(accumulatedAmount,orderAmt);
         String[] drawAmountStr = drawAmount.split("-");

+ 28 - 4
src/main/java/com/minpay/common/service/impl/OrderServiceImpl.java

@@ -1,6 +1,7 @@
 package com.minpay.common.service.impl;
 
 import java.util.Map;
+import java.util.Random;
 
 import com.min.util.CommonUtil;
 import com.minpay.common.bean.User;
@@ -16,6 +17,7 @@ import com.startup.minpay.frame.service.base.Service;
 import com.startup.minpay.frame.session.MINSession;
 import com.startup.minpay.frame.target.MINComponent;
 
+import com.startup.minpay.util.Log;
 import net.sf.json.JSONArray;
 
 /**
@@ -146,13 +148,34 @@ public class OrderServiceImpl implements IOrderService {
 							proPrice = String.valueOf(proInf.getSallPrice());
 						}else if("01".equals(proType)){
 							//proNumsAndPayNum = CommonUtil.multiply(proNumsAndPayNum, payNumber);
-							if(!CommonUtil.isEmpty(map.get("proPrice"))){
+
+							/*if(!commonutil.isempty(map.get("proprice"))){
 								//抽奖价格不为空的用抽奖价
-								proPrice = String.valueOf(map.get("proPrice"));
+								proprice = string.valueof(map.get("proprice"));
 							}else{
 								//抽奖商品用游戏价
-								proPrice = String.valueOf(proInf.getGamePrice());
+								proprice = string.valueof(proinf.getgameprice());
+							}*/
+
+							String paymentType = equInf.getPaymentType();
+							String paymentAmt = equInf.getPayment();
+							if(CommonUtil.isEmpty(paymentType) || CommonUtil.isEmpty(paymentAmt) ){
+								throw new MINBusinessException("机器未设置游戏金额,请联系商户");
+							}
+
+							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");
+								}
+							}else if("01".equals(paymentType)){ //固定
+								proPrice = paymentAmt;
 							}
+
 						}
 						//查询商品详情
 						VmProductInf vmProductInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmProductInfMapper.class).selectByPrimaryKey(proInf.getProductId());
@@ -160,7 +183,6 @@ public class OrderServiceImpl implements IOrderService {
 							throw new MINBusinessException("无此货");
 						}
 
-
 						// 计算总金额
 						String amount = CommonUtil.multiply(proPrice, proNumsAndPayNum);
 						//初始化订单详情信息
@@ -205,4 +227,6 @@ public class OrderServiceImpl implements IOrderService {
 		return ordId;
 	}
 
+
+
 }

+ 7 - 2
src/main/java/com/minpay/shouhuo/orderdrawaction/OrderDrawAction.java

@@ -80,8 +80,12 @@ public class OrderDrawAction implements IMINAction{
 												.getMybatisMapper(VmProEquRelMapper.class)
 												.selectByPrimaryKey(vmOrderDetails.getProEquRelId());
 				String gameType = vmProEquRel.getGameType();
+				//计算平均到每一个商品的金额
+				String orderAmt = orderInf.getOrderAmt();
+				String detailsAmt = CommonUtil.divide(orderAmt,String.valueOf(list.size()),2);
+
 				if(gameType.equals("10")){ //游戏购
-					drawDtoList2 = drawService.orderDrawGame( orderInf,  vmProEquRel,  list.get(0));
+					drawDtoList2 = drawService.orderDrawGame( orderInf,  vmProEquRel,  vmOrderDetails,detailsAmt);
 
 				}else if(gameType.equals("20")){ //幸运购
 					List<DrawDto> drawDtoList = new ArrayList<>();
@@ -91,7 +95,8 @@ public class OrderDrawAction implements IMINAction{
 					drawDto.setHuodaoNo(vmOrderDetails.getProEquRelId());
 					drawDto.setChouJiangAmt(orderInf.getOrderAmt());
 					drawDtoList.add(drawDto);
-					drawDtoList2 = drawService.xingyunDraw( orderInf.getOrderAmt(),  orderInf.getId(),  sysorderno,
+
+					drawDtoList2 = drawService.xingyunDraw( detailsAmt,  orderInf.getId(),  sysorderno,
 							orderInf.getEquipmentId(), drawDtoList);
 
 				}