xubh 4 лет назад
Родитель
Сommit
7ad92c9a52

+ 6 - 3
src/main/java/com/minpay/common/pay/ShouhuoPay.java

@@ -353,7 +353,10 @@ public class ShouhuoPay implements IMINAction{
 		perPay.put("signtype",signtype);//加密类型
 		perPay.put("sign",sign);//加密后字符串
 		perPay.put("payOrderno",payOrderno);//支付平台微信、支付宝订单号或推送的机器型号
-		// 签名验证
+
+        //调用真实回调
+        backEx(orderno, sysorderno, stt, amt,payOrderno, "", "");
+		/*// 签名验证
 		boolean isSign = PayCommonUtil.isTenpaySign("UTF-8", perPay, appSecret);
 		if(isSign){
 			// 00:交易成功
@@ -362,7 +365,7 @@ public class ShouhuoPay implements IMINAction{
 			}
 			//调用真实回调
 			backEx(orderno, sysorderno, stt, amt,payOrderno, "", "");
-		}
+		}*/
 		
 		return res;
 	}
@@ -454,7 +457,7 @@ public class ShouhuoPay implements IMINAction{
 				drawAction.editOrderDraw(orderInf,sysorderno);
 			}else if("00".equals(orderInf.getProType())){
 				//购买商品走这里
-				DeliveryAction.createDeliveryInfo(orderno,"");
+				DeliveryAction.purchaseCreateDeliveryInfo(orderno,"");
 				//执行推货
 //				toMachine(orderInf.getChannel(), orderno);
 			}

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

@@ -2,6 +2,9 @@ package com.minpay.common.service;
 
 import com.minpay.common.bean.DrawDto;
 import com.minpay.common.exception.BusinessCodeException;
+import com.minpay.db.table.model.VmOrderDetails;
+import com.minpay.db.table.model.VmOrderInf;
+import com.minpay.db.table.model.VmProEquRel;
 import com.startup.minpay.frame.exception.MINBusinessException;
 import com.startup.minpay.frame.service.base.IMINLocalService;
 
@@ -30,4 +33,8 @@ public interface IDrawService extends IMINLocalService {
 	public List<DrawDto> xingyunDraw(String payAmt, String orderId, String payOrderId, String shouhuojiNo,
 							   List<DrawDto> drawDto) throws BusinessCodeException, MINBusinessException;
 
+
+	public List<DrawDto> orderDrawGame(VmOrderInf orderInf, VmProEquRel proEquRel, VmOrderDetails vmOrderDetails
+									 ) throws BusinessCodeException, MINBusinessException;
+
 }

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

@@ -5,12 +5,8 @@ import com.minpay.common.exception.BusinessCodeException;
 import com.minpay.common.service.IDrawService;
 import com.minpay.common.service.IPublicService;
 import com.minpay.common.util.CommonUtil;
-import com.minpay.db.table.mapper.VmOrderInfMapper;
-import com.minpay.db.table.mapper.VmProEquRelMapper;
-import com.minpay.db.table.model.VmOrderDetails;
-import com.minpay.db.table.model.VmOrderInf;
-import com.minpay.db.table.model.VmProEquRel;
-import com.minpay.shouhuo.deliveryaction.DeliveryAction;
+import com.minpay.db.table.mapper.*;
+import com.minpay.db.table.model.*;
 import com.startup.minpay.frame.exception.MINBusinessException;
 import com.startup.minpay.frame.service.base.IMINDataBaseService;
 import com.startup.minpay.frame.service.base.Service;
@@ -43,19 +39,35 @@ public class DrawServiceImpl implements IDrawService {
         String amtFen = CommonUtil.multiply(payAmt, "100");
         BigDecimal big2 = new BigDecimal(amtFen);
         amtFen = big2.setScale(0, BigDecimal.ROUND_HALF_DOWN).toString();
+
+        //查询售货机汇率
+        VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class).getMybatisMapper(VmEquipmentInfMapper.class).selectByPrimaryKey(shouhuojiNo);
+        if(equipmentInf == null) {
+            throw new MINBusinessException("没有找到此售货机");
+        }
         // 参与计算的随机数
         String useOrderId = orderId;
         // 第三方支付订单号不为空
         if(CommonUtil.isNotEmpty(payOrderId)) {
             // 支付宝的支付订单号,取后10位+34  进行计算。(加的这个数字,总后台可以更改,或者在系统里面每次随机从1-99选择一个数字加进去)
-            String suijishu = Service.lookup(IPublicService.class).getSysParValue("ZHONGJIANG_SUIJISHU");
+            //String suijishu = Service.lookup(IPublicService.class).getSysParValue("ZHONGJIANG_SUIJISHU");
+            VmGameRuleExample vmGameRuleExample = new VmGameRuleExample();
+            vmGameRuleExample.createCriteria().andTypeEqualTo("1").andMechanismEqualTo(equipmentInf.getBranchid());
+            List<VmGameRule> vmGameRuleList = Service.lookup(IMINDataBaseService.class)
+                                                    .getMybatisMapper(VmGameRuleMapper.class)
+                                                    .selectByExample(vmGameRuleExample);
+            if(vmGameRuleList.size() != 1){
+                throw new MINBusinessException("售货机没有设置汇率");
+            }
+            String suijishu  = vmGameRuleList.get(0).getAlipayid();
+
             useOrderId = CommonUtil.add(payOrderId, suijishu);
             BigDecimal bigUse = new BigDecimal(useOrderId);
             useOrderId = bigUse.setScale(0, BigDecimal.ROUND_HALF_DOWN).toString();
         }
 
-        // TODO 汇率,获取机器的汇率
-        String huilv = "40";
+        String huilv = equipmentInf.getExchangeRate();
+
         // 汇率百分比
         String huilvBaiFenBi = CommonUtil.divide(huilv, "100");
         String mu = CommonUtil.multiply(amtFen, huilvBaiFenBi);
@@ -121,11 +133,9 @@ public class DrawServiceImpl implements IDrawService {
                 .getMybatisMapper(VmProEquRelMapper.class)
                 .updateByPrimaryKeySelective(proEquRel);
 
-        //todo 更新 订单表, 订单详情表,提货表
 
         return drawDtoList;
     }
 
 
-
 }

+ 10 - 10
src/main/java/com/minpay/db/table/model/VmOrderInf.java

@@ -213,11 +213,11 @@ public class VmOrderInf extends AbstractMINBean {
 
     /**
      * This field was generated by MyBatis Generator.
-     * This field corresponds to the database column vm_order_inf.VOI_GAME_ID
+     * This field corresponds to the database column vm_order_inf.VOI_GAME_RULE
      *
      * @mbggenerated
      */
-    private String gameId;
+    private String gameRule;
 
     /**
      * This method was generated by MyBatis Generator.
@@ -845,25 +845,25 @@ public class VmOrderInf extends AbstractMINBean {
 
     /**
      * This method was generated by MyBatis Generator.
-     * This method returns the value of the database column vm_order_inf.VOI_GAME_ID
+     * This method returns the value of the database column vm_order_inf.VOI_GAME_RULE
      *
-     * @return the value of vm_order_inf.VOI_GAME_ID
+     * @return the value of vm_order_inf.VOI_GAME_RULE
      *
      * @mbggenerated
      */
-    public String getGameId() {
-        return gameId;
+    public String getGameRule() {
+        return gameRule;
     }
 
     /**
      * This method was generated by MyBatis Generator.
-     * This method sets the value of the database column vm_order_inf.VOI_GAME_ID
+     * This method sets the value of the database column vm_order_inf.VOI_GAME_RULE
      *
-     * @param gameId the value for vm_order_inf.VOI_GAME_ID
+     * @param gameRule the value for vm_order_inf.VOI_GAME_RULE
      *
      * @mbggenerated
      */
-    public void setGameId(String gameId) {
-        this.gameId = gameId == null ? null : gameId.trim();
+    public void setGameRule(String gameRule) {
+        this.gameRule = gameRule == null ? null : gameRule.trim();
     }
 }

+ 30 - 30
src/main/java/com/minpay/db/table/model/VmOrderInfExample.java

@@ -2218,81 +2218,81 @@ public class VmOrderInfExample {
             return (Criteria) this;
         }
 
-        public Criteria andGameIdIsNull() {
-            addCriterion("VOI_GAME_ID is null");
+        public Criteria andGameRuleIsNull() {
+            addCriterion("VOI_GAME_RULE is null");
             return (Criteria) this;
         }
 
-        public Criteria andGameIdIsNotNull() {
-            addCriterion("VOI_GAME_ID is not null");
+        public Criteria andGameRuleIsNotNull() {
+            addCriterion("VOI_GAME_RULE is not null");
             return (Criteria) this;
         }
 
-        public Criteria andGameIdEqualTo(String value) {
+        public Criteria andGameRuleEqualTo(String value) {
             if(value == null ){
-                andGameIdIsNull();
+                andGameRuleIsNull();
             } else {
-                addCriterion("VOI_GAME_ID =", value, "gameId");
+                addCriterion("VOI_GAME_RULE =", value, "gameRule");
             }
             return (Criteria) this;
         }
 
-        public Criteria andGameIdNotEqualTo(String value) {
+        public Criteria andGameRuleNotEqualTo(String value) {
             if(value == null ){
-                andGameIdIsNotNull();
+                andGameRuleIsNotNull();
             } else {
-                addCriterion("VOI_GAME_ID <>", value, "gameId");
+                addCriterion("VOI_GAME_RULE <>", value, "gameRule");
             }
             return (Criteria) this;
         }
 
-        public Criteria andGameIdGreaterThan(String value) {
-            addCriterion("VOI_GAME_ID >", value, "gameId");
+        public Criteria andGameRuleGreaterThan(String value) {
+            addCriterion("VOI_GAME_RULE >", value, "gameRule");
             return (Criteria) this;
         }
 
-        public Criteria andGameIdGreaterThanOrEqualTo(String value) {
-            addCriterion("VOI_GAME_ID >=", value, "gameId");
+        public Criteria andGameRuleGreaterThanOrEqualTo(String value) {
+            addCriterion("VOI_GAME_RULE >=", value, "gameRule");
             return (Criteria) this;
         }
 
-        public Criteria andGameIdLessThan(String value) {
-            addCriterion("VOI_GAME_ID <", value, "gameId");
+        public Criteria andGameRuleLessThan(String value) {
+            addCriterion("VOI_GAME_RULE <", value, "gameRule");
             return (Criteria) this;
         }
 
-        public Criteria andGameIdLessThanOrEqualTo(String value) {
-            addCriterion("VOI_GAME_ID <=", value, "gameId");
+        public Criteria andGameRuleLessThanOrEqualTo(String value) {
+            addCriterion("VOI_GAME_RULE <=", value, "gameRule");
             return (Criteria) this;
         }
 
-        public Criteria andGameIdLike(String value) {
-            addCriterion("VOI_GAME_ID like", value, "gameId");
+        public Criteria andGameRuleLike(String value) {
+            addCriterion("VOI_GAME_RULE like", value, "gameRule");
             return (Criteria) this;
         }
 
-        public Criteria andGameIdNotLike(String value) {
-            addCriterion("VOI_GAME_ID not like", value, "gameId");
+        public Criteria andGameRuleNotLike(String value) {
+            addCriterion("VOI_GAME_RULE not like", value, "gameRule");
             return (Criteria) this;
         }
 
-        public Criteria andGameIdIn(List<String> values) {
-            addCriterion("VOI_GAME_ID in", values, "gameId");
+        public Criteria andGameRuleIn(List<String> values) {
+            addCriterion("VOI_GAME_RULE in", values, "gameRule");
             return (Criteria) this;
         }
 
-        public Criteria andGameIdNotIn(List<String> values) {
-            addCriterion("VOI_GAME_ID not in", values, "gameId");
+        public Criteria andGameRuleNotIn(List<String> values) {
+            addCriterion("VOI_GAME_RULE not in", values, "gameRule");
             return (Criteria) this;
         }
 
-        public Criteria andGameIdBetween(String value1, String value2) {
-            addCriterion("VOI_GAME_ID between", value1, value2, "gameId");
+        public Criteria andGameRuleBetween(String value1, String value2) {
+            addCriterion("VOI_GAME_RULE between", value1, value2, "gameRule");
             return (Criteria) this;
         }
 
-        public Criteria andGameIdNotBetween(String value1, String value2) {
-            addCriterion("VOI_GAME_ID not between", value1, value2, "gameId");
+        public Criteria andGameRuleNotBetween(String value1, String value2) {
+            addCriterion("VOI_GAME_RULE not between", value1, value2, "gameRule");
             return (Criteria) this;
         }
     }

+ 97 - 22
src/main/java/com/minpay/shouhuo/deliveryaction/DeliveryAction.java

@@ -10,6 +10,7 @@ import javax.servlet.http.HttpServletResponse;
 import com.min.base64.Base64;
 import com.min.des.DesUtils;
 import com.min.util.OffSetUtil;
+import com.minpay.common.bean.DrawDto;
 import com.minpay.common.bean.User;
 import com.minpay.common.exception.BusinessCodeException;
 import com.minpay.common.format.IFormatService;
@@ -356,16 +357,91 @@ public class DeliveryAction implements IMINAction{
 	
 	/**
 	 * 创建提货信息
-	 * @param orderNo		订单编号
 	 * @return
 	 * @throws BusinessCodeException
 	 * @throws MINBusinessException
 	 */
 	//@MINAction(value = "createDeliveryInfo",session = false)
 	public static void createDeliveryInfo(
+			List<DrawDto> drawDtoList
+			 ) throws BusinessCodeException, MINBusinessException{
+		String nowTime = DateUtil.getCurrentDateTimeString();
+
+		for (int i = 0; i < drawDtoList.size(); i++) {
+			DrawDto drawDto = drawDtoList.get(i);
+			if(drawDto.isDraw()){ //中奖的
+				String orderId = drawDto.getOrderId();
+				String orderDetailsId = drawDto.getOrderDetailsId();
+				//获取订单信息
+				VmOrderInf ordInf = Service.lookup(IMINDataBaseService.class)
+						.getMybatisMapper(VmOrderInfMapper.class)
+						.selectByPrimaryKey(orderId);
+
+				if(ordInf == null){
+					throw new BusinessCodeException("JINM0114");//订单信息不存在
+				}else{
+					if(!"00".equals(ordInf.getState())){
+						throw new BusinessCodeException("JINM1105");//当前商品未支付,请支付后才可以提货
+					}
+				}
+
+				VmOrderDetails detInf = Service.lookup(IMINDataBaseService.class)
+						.getMybatisMapper(VmOrderDetailsMapper.class)
+						.selectByPrimaryKey(orderDetailsId);
+
+				//创建提货对象
+				VmDeliveryInf dlInf = new VmDeliveryInf();
+				//获取提货表主键
+				String dlId = Service.lookup(IPublicService.class).getSequence("VM_DELIVERY_INF_ID");
+				dlInf.setDeliveryId(dlId);					//提货编号
+				dlInf.setChannel(ordInf.getChannel());		//渠道
+				dlInf.setEquipmentId(ordInf.getEquipmentId());//售货机编号
+				dlInf.setPersonId(ordInf.getPersonId());		//会员编号
+				dlInf.setOrdDetId(detInf.getDetailsId());	//订单详情编号
+				dlInf.setProType(detInf.getProType());		//商品交易类别:00正常商品01抽奖商品
+				dlInf.setProName(detInf.getProName());		//商品名称
+				dlInf.setProPrice(detInf.getProPrice());	//单价
+				dlInf.setProNums(detInf.getProNums());	//为空取订单中的数量
+				dlInf.setAmount(detInf.getAmount());		//金额
+				dlInf.setStatus("0");						//0未提货1部分提货2已提货3卡货4清零
+				dlInf.setDeliveryNums("0");					//默认未提货/提货数量为0
+				dlInf.setCargoWay(detInf.getCargoWay());	//商品所在货道
+				dlInf.setRemarks("会员下单,售货机编号:"+ordInf.getEquipmentId());//备注
+				dlInf.setCreateUser(ordInf.getPersonId());	//创建人
+				dlInf.setCreateTime(nowTime);				//创建时间
+				dlInf.setModifyUser(ordInf.getPersonId());	//修改人
+				dlInf.setModifyTime(nowTime);				//修改时间
+				//执行新增提货信息
+				Service.lookup(IMINDataBaseService.class)
+						.getMybatisMapper(VmDeliveryInfMapper.class)
+						.insert(dlInf);
+				//更新订单详情
+				if(ordInf.getIsDraw().equals("00")){
+					ordInf.setIsDraw("01");
+					Service.lookup(IMINDataBaseService.class)
+							.getMybatisMapper(VmOrderDetailsMapper.class)
+							.updateByPrimaryKeySelective(detInf);
+				}
+
+			}
+
+		}
+
+	}
+	
+	/**
+	 * 创建提货信息
+	 * @param orderNo		订单编号
+	 * @return
+	 * @throws BusinessCodeException
+	 * @throws MINBusinessException
+	 */
+	//@MINAction(value = "createDeliveryInfo",session = false)
+	public MINActionResult createDeliveryInfoTwo(
 			// @MINParam(key = "orderNo")
-			String orderNo,String drawNumber
+			String orderNo
 			 ) throws BusinessCodeException, MINBusinessException{
+		MINActionResult res = new MINActionResult();
 		String nowTime = DateUtil.getCurrentDateTimeString();
 		//获取订单信息
 		VmOrderInf ordInf = Service.lookup(IMINDataBaseService.class)
@@ -391,6 +467,7 @@ public class DeliveryAction implements IMINAction{
 				VmDeliveryInf dlInf = new VmDeliveryInf();
 				//获取提货表主键
 				String dlId = Service.lookup(IPublicService.class).getSequence("VM_DELIVERY_INF_ID");
+				res.set("dlId", dlId);
 				dlInf.setDeliveryId(dlId);					//提货编号
 				dlInf.setChannel(ordInf.getChannel());		//渠道
 				dlInf.setEquipmentId(ordInf.getEquipmentId());//售货机编号
@@ -399,11 +476,7 @@ public class DeliveryAction implements IMINAction{
 				dlInf.setProType(detInf.getProType());		//商品交易类别:00正常商品01抽奖商品
 				dlInf.setProName(detInf.getProName());		//商品名称
 				dlInf.setProPrice(detInf.getProPrice());	//单价
-				if(!CommonUtil.isEmpty(drawNumber)){
-					dlInf.setProNums(drawNumber);			//数量
-				}else{
-					dlInf.setProNums(detInf.getProNums());	//为空取订单中的数量
-				}
+				dlInf.setProNums(detInf.getProNums());		//数量
 				dlInf.setAmount(detInf.getAmount());		//金额
 				dlInf.setStatus("0");						//0未提货1部分提货2已提货3卡货4清零
 				dlInf.setDeliveryNums("0");					//默认未提货/提货数量为0
@@ -419,8 +492,8 @@ public class DeliveryAction implements IMINAction{
 								.insert(dlInf);
 			}
 		}
+		return res;
 	}
-	
 	/**
 	 * 创建提货信息
 	 * @param orderNo		订单编号
@@ -429,16 +502,14 @@ public class DeliveryAction implements IMINAction{
 	 * @throws MINBusinessException
 	 */
 	//@MINAction(value = "createDeliveryInfo",session = false)
-	public MINActionResult createDeliveryInfoTwo(
-			// @MINParam(key = "orderNo")
-			String orderNo
-			 ) throws BusinessCodeException, MINBusinessException{
-		MINActionResult res = new MINActionResult();
+	public static void purchaseCreateDeliveryInfo(
+			String orderNo,String drawNumber
+	) throws BusinessCodeException, MINBusinessException{
 		String nowTime = DateUtil.getCurrentDateTimeString();
 		//获取订单信息
 		VmOrderInf ordInf = Service.lookup(IMINDataBaseService.class)
-									.getMybatisMapper(VmOrderInfMapper.class)
-									.selectByPrimaryKey(orderNo);
+				.getMybatisMapper(VmOrderInfMapper.class)
+				.selectByPrimaryKey(orderNo);
 		if(ordInf == null){
 			throw new BusinessCodeException("JINM0114");//订单信息不存在
 		}else{
@@ -450,8 +521,8 @@ public class DeliveryAction implements IMINAction{
 		VmOrderDetailsExample examp = new VmOrderDetailsExample();
 		examp.createCriteria().andChannelEqualTo(ordInf.getChannel()).andOrderIdEqualTo(orderNo);
 		List<VmOrderDetails> ordetList = Service.lookup(IMINDataBaseService.class)
-												.getMybatisMapper(VmOrderDetailsMapper.class)
-												.selectByExample(examp);
+				.getMybatisMapper(VmOrderDetailsMapper.class)
+				.selectByExample(examp);
 		for (int i = 0; i < ordetList.size(); i++) {
 			VmOrderDetails detInf = ordetList.get(i);
 			if(detInf != null){
@@ -459,7 +530,6 @@ public class DeliveryAction implements IMINAction{
 				VmDeliveryInf dlInf = new VmDeliveryInf();
 				//获取提货表主键
 				String dlId = Service.lookup(IPublicService.class).getSequence("VM_DELIVERY_INF_ID");
-				res.set("dlId", dlId);
 				dlInf.setDeliveryId(dlId);					//提货编号
 				dlInf.setChannel(ordInf.getChannel());		//渠道
 				dlInf.setEquipmentId(ordInf.getEquipmentId());//售货机编号
@@ -468,7 +538,11 @@ public class DeliveryAction implements IMINAction{
 				dlInf.setProType(detInf.getProType());		//商品交易类别:00正常商品01抽奖商品
 				dlInf.setProName(detInf.getProName());		//商品名称
 				dlInf.setProPrice(detInf.getProPrice());	//单价
-				dlInf.setProNums(detInf.getProNums());		//数量
+				if(!CommonUtil.isEmpty(drawNumber)){
+					dlInf.setProNums(drawNumber);			//数量
+				}else{
+					dlInf.setProNums(detInf.getProNums());	//为空取订单中的数量
+				}
 				dlInf.setAmount(detInf.getAmount());		//金额
 				dlInf.setStatus("0");						//0未提货1部分提货2已提货3卡货4清零
 				dlInf.setDeliveryNums("0");					//默认未提货/提货数量为0
@@ -480,11 +554,12 @@ public class DeliveryAction implements IMINAction{
 				dlInf.setModifyTime(nowTime);				//修改时间
 				//执行新增提货信息
 				Service.lookup(IMINDataBaseService.class)
-								.getMybatisMapper(VmDeliveryInfMapper.class)
-								.insert(dlInf);
+						.getMybatisMapper(VmDeliveryInfMapper.class)
+						.insert(dlInf);
 			}
 		}
-		return res;
 	}
+
+
 }
 

+ 30 - 280
src/main/java/com/minpay/shouhuo/orderdrawaction/OrderDrawAction.java

@@ -1,19 +1,21 @@
 package com.minpay.shouhuo.orderdrawaction;
 
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.minpay.common.bean.DrawDto;
+import com.minpay.common.service.IDrawService;
 import com.minpay.common.service.IPropertiesService;
 import com.minpay.common.service.IPublicService;
+import com.minpay.common.service.impl.DrawServiceImpl;
 import com.minpay.common.util.CommonUtil;
 import com.minpay.common.util.DateUtil;
-import com.minpay.db.table.mapper.VmEquipmentInfMapper;
 import com.minpay.db.table.mapper.VmOrderDetailsMapper;
 import com.minpay.db.table.mapper.VmOrderDrawDetailMapper;
 import com.minpay.db.table.mapper.VmOrderInfMapper;
 import com.minpay.db.table.mapper.VmProEquRelMapper;
-import com.minpay.db.table.model.VmEquipmentInf;
 import com.minpay.db.table.model.VmOrderDetails;
 import com.minpay.db.table.model.VmOrderDetailsExample;
 import com.minpay.db.table.model.VmOrderDrawDetail;
@@ -55,7 +57,7 @@ public class OrderDrawAction implements IMINAction{
 	 * @throws MINBusinessException
 	 */
 	@MINAction(value = EDIT_ORDER_DRAW)
-	public MINActionResult editOrderDraw(VmOrderInf orderInf) throws MINBusinessException{
+	public MINActionResult editOrderDraw(VmOrderInf orderInf,String sysorderno) throws MINBusinessException{
 		MINActionResult res = new MINActionResult();
 
 		//是抽奖商品
@@ -67,292 +69,40 @@ public class OrderDrawAction implements IMINAction{
 			List<VmOrderDetails> list = Service.lookup(IMINDataBaseService.class)
 												.getMybatisMapper(VmOrderDetailsMapper.class)
 												.selectByExample(detailsExample);
-			String gameId = orderInf.getGameId();
-
+			String gameId = orderInf.getGameRule();
+			IDrawService drawService = new DrawServiceImpl();
+			List<DrawDto> drawDtoList1 = new ArrayList<>();
+			if("0".equals(gameId)) {//幸运购
+				//查询当前机构的幸运够
+				List<DrawDto> drawDtoList = new ArrayList<>();
+				for (int i = 0; i < list.size(); i++) {
+					VmOrderDetails  vmOrderDetails = list.get(i);
+					DrawDto drawDto = new DrawDto();
+					drawDto.setOrderId(vmOrderDetails.getOrderId());
+					drawDto.setOrderDetailsId(vmOrderDetails.getDetailsId());
+					drawDto.setHuodaoNo(vmOrderDetails.getProEquRelId());
+					drawDto.setChouJiangAmt(orderInf.getOrderAmt());
+					drawDtoList.add(drawDto);
+				}
 
+				 drawDtoList1 = drawService.xingyunDraw( orderInf.getOrderAmt(),  orderInf.getId(),  sysorderno,
+												orderInf.getEquipmentId(), drawDtoList);
 
-			if(list.size() != 0){
+			}else if("1".equals(gameId)){//游戏购
 				//获取设备商品信息
 				VmProEquRel proEquRel = Service.lookup(IMINDataBaseService.class)
-												.getMybatisMapper(VmProEquRelMapper.class)
-												.selectByPrimaryKey(list.get(0).getProEquRelId());
-				// 游戏类型(GAME_TYEP:00:不参与,10:游戏购 20:幸运购)
-				/*if("00".equals(proEquRel.getGameType())) {
-					return res;
-				}else if("20".equals(proEquRel.getGameType())) {//幸运购
-					orderDrawLucky(orderInf,proEquRel);
-				}else if("10".equals(proEquRel.getGameType())){//游戏购
-					orderDrawGame(orderInf,proEquRel);
-				}else if("30".equals(proEquRel.getGameType())){//幸运游戏购
-					twoOrderDrawGame(orderInf,proEquRel);
-				}*/
+						.getMybatisMapper(VmProEquRelMapper.class)
+						.selectByPrimaryKey(list.get(0).getProEquRelId());
+				drawDtoList1 = drawService.orderDrawGame( orderInf,  proEquRel,  list.get(0));
 
-				if("100001".equals(gameId)) {//幸运购
-					orderDrawLucky(orderInf,proEquRel);
-				}else if("100002".equals(gameId)){//游戏购
-					orderDrawGame(orderInf,proEquRel);
-				}
-				
-				// 获取最终游戏类型
-				/*if(CommonUtil.isEmpty(proEquRel.getGameType())) {
-					// 获取设备信息
-					VmEquipmentInf eqInf = Service.lookup(IMINDataBaseService.class)
-													.getMybatisMapper(VmEquipmentInfMapper.class)
-													.selectByPrimaryKey(proEquRel.getEquipmentId());
-					
-					if("20".equals(eqInf.getGameType())) {//幸运购
-						orderDrawLucky(orderInf,proEquRel);
-					}else if("10".equals(eqInf.getGameType())){//游戏购
-						orderDrawGame(orderInf,proEquRel);
-					}else if("30".equals(eqInf.getGameType())){//幸运游戏购
-						twoOrderDrawGame(orderInf,proEquRel);
-					}
-				}*/
 			}
-		}
-		
-		return res;
-	}
-	
-	/**
-	 * 幸运购判断
-	 * @return
-	 * @throws MINBusinessException
-	 */
-	@MINAction(value = ORDER_DRAW_LUCKY)
-	public void orderDrawLucky(VmOrderInf orderInf,VmProEquRel proEquRel) throws MINBusinessException{
-		String payOrderNo 	= orderInf.getPayOrderno();		//支付订单号
-		String orderAmt 	= orderInf.getOrderAmt();		//付款金额
-		String sallPrice 	= proEquRel.getSallPrice();		//售货价
-		//订单号除去金额*100的余数
-		int remainder = CommonUtil.objToint((payOrderNo)) % CommonUtil.objToint((CommonUtil.multiply(sallPrice,"100")));
-		//支付金额*100
-		int luckyNum = CommonUtil.objToint(CommonUtil.multiply(orderAmt,"100"));
-		//中奖
-		if(luckyNum >= remainder){
-			orderInf.setIsDraw("01");
-			//中奖后生成提货信息
-			DeliveryAction.createDeliveryInfo(orderInf.getId(),"");
-		}
-		orderInf.setIsUsed("00");
-		Service.lookup(IMINDataBaseService.class)
-				.getMybatisMapper(VmOrderInfMapper.class)
-				.updateByPrimaryKey(orderInf);
-	}
-	
-	/**
-	 * 游戏购判断
-	 * @return
-	 * @throws MINBusinessException
-	 */
-	@MINAction(value = ORDER_DRAW_GAME)
-	public void orderDrawGame(VmOrderInf orderInf,VmProEquRel proEquRel) throws MINBusinessException{
-		VmOrderDetailsExample detailsExample = new VmOrderDetailsExample();
-		detailsExample.createCriteria().andOrderIdEqualTo(orderInf.getId())
-										.andChannelEqualTo(orderInf.getChannel());
-		List<VmOrderDetails> list = Service.lookup(IMINDataBaseService.class)
-											.getMybatisMapper(VmOrderDetailsMapper.class)
-											.selectByExample(detailsExample);
-		if(list.size()!=1){
-			throw new MINBusinessException("订单信息错误!");
-		}
+			//更新 订单表, 订单详情表,提货表
+			DeliveryAction.createDeliveryInfo(drawDtoList1);
 
-		String sallPrice 	= proEquRel.getSallPrice();		//售货价
-		String costPrice 	= proEquRel.getCostPrice();		//成本价
-		String promotionPrice 	= "0";
-		if(proEquRel.getIsPromotion().equals("0")){//促销价
-			promotionPrice 	= proEquRel.getPromotionPrice();
-		}
-		Map<String,String> map = new HashMap<String,String>();
-		map.put("channel", orderInf.getChannel());
-		map.put("perId", list.get(0).getProEquRelId());
-		//查询所有未使用的购买此货道订单
-		List<Map<String, String>> drawGame = Service.lookup(IMINDataBaseService.class)
-													.getMybatisMapper(OrderDrawMapper.class)
-													.queryDrawGame(map);
-		String allPrice = "0";		//所有订单总金额
-		for (Map<String, String> map2 : drawGame) {
-			allPrice = CommonUtil.add(map2.get("ordetAmt"),allPrice);
-		}
-		//总金额与价格比较
-		int i = CommonUtil.compare(allPrice, CommonUtil.add(CommonUtil.add(sallPrice,costPrice),promotionPrice));
-		//中奖
-		if(i>=0){
-			for (Map<String, String> map2 : drawGame) {
-				VmOrderInf vmOrderInf = new VmOrderInf();
-				vmOrderInf.setId(map2.get("ordNo"));
-				vmOrderInf.setIsUsed("00");
-				//修改所有购买此货道订单为已使用
-				Service.lookup(IMINDataBaseService.class)
-						.getMybatisMapper(VmOrderInfMapper.class)
-						.updateByPrimaryKeySelective(vmOrderInf);
-			}
-			//修改本订单中奖
-			orderInf.setIsDraw("01");
-			Service.lookup(IMINDataBaseService.class)
-					.getMybatisMapper(VmOrderInfMapper.class)
-					.updateByPrimaryKey(orderInf);
-			//中奖后生成提货信息
-			DeliveryAction.createDeliveryInfo(orderInf.getId(),"");
-		}
-	}
-	/**
-	 * 幸运游戏购
-	 * @return
-	 * @throws MINBusinessException
-	 */
-	@MINAction(value = TWO_ORDER_DRAW_GAME)
-	public void twoOrderDrawGame(VmOrderInf orderInf,VmProEquRel proEquRel) throws MINBusinessException{
-		//获取当前时间
-		String dateTime = DateUtil.getCurrentDateTimeString();
-		//获取当前日期
-		String nowDate = DateUtil.getCurrentDateString();
-		//开始时间
-		String startTime = nowDate.concat("000000");
-		//结束时间
-		String endTime = nowDate.concat("999999");
-		VmOrderDetailsExample detailsExample = new VmOrderDetailsExample();
-		detailsExample.createCriteria().andOrderIdEqualTo(orderInf.getId())
-										.andChannelEqualTo(orderInf.getChannel());
-		List<VmOrderDetails> list = Service.lookup(IMINDataBaseService.class)
-											.getMybatisMapper(VmOrderDetailsMapper.class)
-											.selectByExample(detailsExample);
-		if(list.size()!=1){
-			throw new MINBusinessException("订单信息错误!");
-		}
-		//查询金额条件
-		Map<String,String> map = new HashMap<String,String>();
-		map.put("channel", orderInf.getChannel());
-		map.put("relId", proEquRel.getId());
-		map.put("startTime", startTime);
-		map.put("endTime", endTime);
-		//查询所有订单金额
-		List<Map<String, String>> drawGame = Service.lookup(IMINDataBaseService.class)
-													.getMybatisMapper(OrderDrawMapper.class)
-													.queryall(map);
-		//幸运值幅度范围
-		String rang = Service.lookup(IPropertiesService.class)
-								.getSystemProperties()
-								.get(orderInf.getChannel() + "_RANG")
-								.getKey();
-		//商品售货价
-		String sallPrice 	= proEquRel.getSallPrice();	
-		System.out.println("===============================商品售货价"+sallPrice);
-		//商品购买数量
-		String buyNumber 	= list.get(0).getProNums();	
-		System.out.println("===============================商品购买数量"+buyNumber);
-		//幸运值
-		String luckNo = proEquRel.getLuck();
-		/*if(CommonUtil.isEmpty(proEquRel.getLuck())){
-			VmEquipmentInf equipmentInf = Service.lookup(IMINDataBaseService.class)
-													.getMybatisMapper(VmEquipmentInfMapper.class)
-													.selectByPrimaryKey(proEquRel.getEquipmentId());
-			luckNo = equipmentInf.getLuck();
-		}*/
-		//幸运值区间最大值
-		String max = CommonUtil.add(luckNo, rang);
-		System.out.println("===============================幸运值区间最大值"+max);
-		//幸运值区间最小值
-		String min = CommonUtil.subtract(luckNo,rang);
-		System.out.println("===============================幸运值区间最小值"+min);
-		//支付类型 1:1倍支付 3:3倍支付 5:5倍支付
-		String payType = orderInf.getPayType();
-		System.out.println("===============================支付倍数"+payType);
-		//本订单中奖金额
-		String drawMoneys = orderInf.getDrawPrice();
-		//抽奖次数
-		int number = Integer.parseInt(orderInf.getNumber());
-		System.out.println("===============================抽奖次数"+number);	
-		//正常商品购买总价格
-		String buyAmount = drawGame.get(0).get("buyAmount");
-		//抽奖商品购买总金额
-		String drawAmount = drawGame.get(0).get("drawAmount");
-		System.out.println("===============================货道今日总收入"+buyAmount+"+"+drawAmount);	
-		//抽奖商品支出总金额
-		String drawPrice = drawGame.get(0).get("drawPrice");
-		// 商品已经抽奖价格+商品价格本身/2
-		drawPrice = CommonUtil.add(drawPrice, CommonUtil.divide(proEquRel.getSallPrice(), "2"));
-		System.out.println("===============================货道今日中奖金额"+drawPrice);	
-		String drawNumber = "0";
-		for (int i = 0; i < number; i++) {
-			//准备中奖详情数据
-			VmOrderDrawDetail detail = new VmOrderDrawDetail();
-			//获取中奖详情表主键
-			String id = Service.lookup(IPublicService.class).getSequence("VM_ORDER_DRAW_ID");
-			detail.setId(id);								//中奖详情id
-			detail.setNumber(String.valueOf(i+1));		//抽奖第几次
-			detail.setOrderId(orderInf.getId());			//订单id
-			detail.setChannel(orderInf.getChannel());		//渠道
-			detail.setIsDraw("00");							//未中奖
-			detail.setCreateUser(orderInf.getCreateUser());	//创建人
-			detail.setCreateTime(dateTime);					//创建时间
-			detail.setModifyUser(orderInf.getCreateUser());	//修改人
-			detail.setModifyTime(dateTime);					//修改时间
-			//抽奖商品购买总金额增加
-			drawAmount= CommonUtil.add(drawAmount, payType);
-			
-			//计算抽奖过程
-			//利润比
-			String divide = CommonUtil.multiply(CommonUtil.divide(CommonUtil.subtract(CommonUtil.add(buyAmount, drawAmount), drawPrice),
-					CommonUtil.add(buyAmount, drawAmount)),"100");
-			System.out.println("===============================利润比乘100"+divide);	
-			//利润比和最大值相比
-			int divMax = CommonUtil.compare(divide, max);
-			//利润比和最小值相比
-			int divMin = CommonUtil.compare(divide, min);
-			//声明本次概率
-			String probability = Service.lookup(IPropertiesService.class)
-										.getSystemProperties()
-										.get(orderInf.getChannel() + "_PROBABILITY")
-										.getKey();
-			if(divMax == 1){
-				//比幸运值大需要提升概率将利润比降低下来
-				probability = Service.lookup(IPropertiesService.class)
-										.getSystemProperties()
-										.get(orderInf.getChannel() + "_PROBABILITY_UP")
-										.getKey();
-			}
-			if(divMin == -1){
-				//比幸运值小需要降低概率将利润比提升回来
-				probability = Service.lookup(IPropertiesService.class)
-										.getSystemProperties()
-										.get(orderInf.getChannel() + "_PROBABILITY_DOWN")
-										.getKey();
-			}
 
-			System.out.println("===============================中奖率"+probability);	
-			//获取1到100内的随机数
-			double num = Math.random() * 100;
-			String randNum = String.valueOf(num);
-			System.out.println("===============================随机数"+randNum);	
-			int compare = CommonUtil.compare(probability, randNum);
-			//如果中奖
-			if(compare != -1){
-				drawNumber = CommonUtil.add(drawNumber, buyNumber);
-				//中奖后生成提货信息
-				DeliveryAction.createDeliveryInfo(orderInf.getId(),drawNumber);
-				//如果中奖 支出总金额增加
-				drawPrice= CommonUtil.add(drawPrice, CommonUtil.multiply(sallPrice, buyNumber));
-				//如果中奖 本订单中奖金额增加
-				drawMoneys= CommonUtil.add(drawMoneys, CommonUtil.multiply(sallPrice, buyNumber));
-				//将本订单中奖金额修改
-				orderInf.setDrawPrice(drawMoneys);
-				//将订单定为中奖状态
-				orderInf.setIsDraw("01");
-				//将中奖详情定为中奖状态
-				detail.setIsDraw("01");
-				System.out.println("===============================中奖"+",货道中奖金额为"+drawPrice);	
-				System.out.println("===============================中奖金额为"+drawMoneys);	
-			}
-			Service.lookup(IMINDataBaseService.class)
-					.getMybatisMapper(VmOrderDrawDetailMapper.class)
-					.insertSelective(detail);
 		}
-		orderInf.setModifyTime(dateTime);		//订单修改时间
-		//修改订单
-		Service.lookup(IMINDataBaseService.class)
-				.getMybatisMapper(VmOrderInfMapper.class)
-				.updateByPrimaryKeySelective(orderInf);
 		
+		return res;
 	}
+
 }

+ 14 - 14
src/main/resources/com/minpay/db/table/mapper/VmOrderInfMapper.xml

@@ -32,7 +32,7 @@
     <result column="VOI_BRANCHID" jdbcType="VARCHAR" property="branchid" />
     <result column="VOI_PAY_MODE" jdbcType="VARCHAR" property="payMode" />
     <result column="VOI_OPERATION" jdbcType="VARCHAR" property="operation" />
-    <result column="VOI_GAME_ID" jdbcType="VARCHAR" property="gameId" />
+    <result column="VOI_GAME_RULE" jdbcType="VARCHAR" property="gameRule" />
   </resultMap>
   <sql id="Example_Where_Clause">
     <!--
@@ -109,7 +109,7 @@
     VOI_PAY_ORDERNO, VOI_REMARKS, VOI_PAY_TYPE, VOI_NUMBER, VOI_PRO_TYPE, VOI_IS_DRAW, 
     VOI_IS_USED, VOI_PRO_STATE, VOI_DRAW_PRICE, VOI_CREATE_USER, VOI_CREATE_TIME, VOI_MODIFY_USER, 
     VOI_MODIFY_TIME, VOI_PICKUP_NO, VOI_PICKUP_STT, VOI_PICKUP_TIME, VOI_BRANCHID, VOI_PAY_MODE, 
-    VOI_OPERATION, VOI_GAME_ID
+    VOI_OPERATION, VOI_GAME_RULE
   </sql>
   <select id="selectByExample" parameterType="com.minpay.db.table.model.VmOrderInfExample" resultMap="BaseResultMap">
     <!--
@@ -170,7 +170,7 @@
       VOI_DRAW_PRICE, VOI_CREATE_USER, VOI_CREATE_TIME, 
       VOI_MODIFY_USER, VOI_MODIFY_TIME, VOI_PICKUP_NO, 
       VOI_PICKUP_STT, VOI_PICKUP_TIME, VOI_BRANCHID, 
-      VOI_PAY_MODE, VOI_OPERATION, VOI_GAME_ID
+      VOI_PAY_MODE, VOI_OPERATION, VOI_GAME_RULE
       )
     values (#{id,jdbcType=VARCHAR}, #{channel,jdbcType=VARCHAR}, #{personId,jdbcType=VARCHAR}, 
       #{equipmentId,jdbcType=VARCHAR}, #{orderAmt,jdbcType=VARCHAR}, #{state,jdbcType=VARCHAR}, 
@@ -180,7 +180,7 @@
       #{drawPrice,jdbcType=VARCHAR}, #{createUser,jdbcType=VARCHAR}, #{createTime,jdbcType=VARCHAR}, 
       #{modifyUser,jdbcType=VARCHAR}, #{modifyTime,jdbcType=VARCHAR}, #{pickupNo,jdbcType=VARCHAR}, 
       #{pickupStt,jdbcType=VARCHAR}, #{pickupTime,jdbcType=VARCHAR}, #{branchid,jdbcType=VARCHAR}, 
-      #{payMode,jdbcType=VARCHAR}, #{operation,jdbcType=VARCHAR}, #{gameId,jdbcType=VARCHAR}
+      #{payMode,jdbcType=VARCHAR}, #{operation,jdbcType=VARCHAR}, #{gameRule,jdbcType=VARCHAR}
       )
   </insert>
   <insert id="insertSelective" parameterType="com.minpay.db.table.model.VmOrderInf">
@@ -268,8 +268,8 @@
       <if test="operation != null">
         VOI_OPERATION,
       </if>
-      <if test="gameId != null">
-        VOI_GAME_ID,
+      <if test="gameRule != null">
+        VOI_GAME_RULE,
       </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -351,8 +351,8 @@
       <if test="operation != null">
         #{operation,jdbcType=VARCHAR},
       </if>
-      <if test="gameId != null">
-        #{gameId,jdbcType=VARCHAR},
+      <if test="gameRule != null">
+        #{gameRule,jdbcType=VARCHAR},
       </if>
     </trim>
   </insert>
@@ -451,8 +451,8 @@
       <if test="record.operation != null">
         VOI_OPERATION = #{record.operation,jdbcType=VARCHAR},
       </if>
-      <if test="record.gameId != null">
-        VOI_GAME_ID = #{record.gameId,jdbcType=VARCHAR},
+      <if test="record.gameRule != null">
+        VOI_GAME_RULE = #{record.gameRule,jdbcType=VARCHAR},
       </if>
     </set>
     <if test="_parameter != null">
@@ -491,7 +491,7 @@
       VOI_BRANCHID = #{record.branchid,jdbcType=VARCHAR},
       VOI_PAY_MODE = #{record.payMode,jdbcType=VARCHAR},
       VOI_OPERATION = #{record.operation,jdbcType=VARCHAR},
-      VOI_GAME_ID = #{record.gameId,jdbcType=VARCHAR}
+      VOI_GAME_RULE = #{record.gameRule,jdbcType=VARCHAR}
     <if test="_parameter != null">
       <include refid="Update_By_Example_Where_Clause" />
     </if>
@@ -578,8 +578,8 @@
       <if test="operation != null">
         VOI_OPERATION = #{operation,jdbcType=VARCHAR},
       </if>
-      <if test="gameId != null">
-        VOI_GAME_ID = #{gameId,jdbcType=VARCHAR},
+      <if test="gameRule != null">
+        VOI_GAME_RULE = #{gameRule,jdbcType=VARCHAR},
       </if>
     </set>
     where VOI_ID = #{id,jdbcType=VARCHAR}
@@ -615,7 +615,7 @@
       VOI_BRANCHID = #{branchid,jdbcType=VARCHAR},
       VOI_PAY_MODE = #{payMode,jdbcType=VARCHAR},
       VOI_OPERATION = #{operation,jdbcType=VARCHAR},
-      VOI_GAME_ID = #{gameId,jdbcType=VARCHAR}
+      VOI_GAME_RULE = #{gameRule,jdbcType=VARCHAR}
     where VOI_ID = #{id,jdbcType=VARCHAR}
   </update>
 </mapper>