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.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.VmOrderDetails; import com.minpay.db.table.model.VmOrderDetailsExample; import com.minpay.db.table.model.VmOrderDrawDetail; import com.minpay.db.table.model.VmOrderInf; import com.minpay.db.table.model.VmProEquRel; import com.minpay.db.table.own.mapper.OrderDrawMapper; import com.minpay.shouhuo.deliveryaction.DeliveryAction; import com.startup.minpay.frame.business.IMINAction; import com.startup.minpay.frame.business.res.MINActionResult; import com.startup.minpay.frame.exception.MINBusinessException; import com.startup.minpay.frame.service.base.IMINDataBaseService; import com.startup.minpay.frame.service.base.Service; import com.startup.minpay.frame.target.MINAction; import com.startup.minpay.frame.target.MINComponent; /** * 订单成功回调接口 * @author dudm@minpay.cc * */ @MINComponent public class OrderDrawAction implements IMINAction{ /**订单成功回调接口*/ public static final String EDIT_ORDER_DRAW = "editOrderDraw"; /**幸运购*/ public static final String ORDER_DRAW_LUCKY = "orderDrawLucky"; /**游戏购*/ public static final String ORDER_DRAW_GAME = "orderDrawGame"; /**二游戏购*/ public static final String TWO_ORDER_DRAW_GAME = "twoOrderDrawGame"; /** * 订单成功回调接口 * @param orderInf 付款订单 * @return * @throws MINBusinessException */ @MINAction(value = EDIT_ORDER_DRAW) public MINActionResult editOrderDraw(VmOrderInf orderInf,String sysorderno) throws MINBusinessException{ MINActionResult res = new MINActionResult(); //是抽奖商品 if("01".equals(orderInf.getProType())){ //通过订单id获取商品设备关联表id VmOrderDetailsExample detailsExample = new VmOrderDetailsExample(); detailsExample.createCriteria().andOrderIdEqualTo(orderInf.getId()) .andChannelEqualTo(orderInf.getChannel()); List list = Service.lookup(IMINDataBaseService.class) .getMybatisMapper(VmOrderDetailsMapper.class) .selectByExample(detailsExample); String gameId = orderInf.getGameRule(); IDrawService drawService = new DrawServiceImpl(); List drawDtoList1 = new ArrayList<>(); for (int i = 0; i < list.size(); i++) { List drawDtoList2 = new ArrayList<>(); //查询订单详情关联货到 VmOrderDetails vmOrderDetails = list.get(i); VmProEquRel vmProEquRel = Service.lookup(IMINDataBaseService.class) .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("01")){ //幸运购 List drawDtoList = new ArrayList<>(); DrawDto drawDto = new DrawDto(); drawDto.setOrderId(vmOrderDetails.getOrderId()); drawDto.setOrderDetailsId(vmOrderDetails.getDetailsId()); drawDto.setHuodaoNo(vmOrderDetails.getProEquRelId()); drawDto.setChouJiangAmt(orderInf.getOrderAmt()); drawDtoList.add(drawDto); drawDtoList2 = drawService.xingyunDraw( detailsAmt, orderInf.getId(), sysorderno, orderInf.getEquipmentId(), drawDtoList); }else if(gameType.equals("02")){ //游戏购 drawDtoList2 = drawService.orderDrawGame( orderInf, vmProEquRel, vmOrderDetails,detailsAmt); } drawDtoList1.addAll(drawDtoList2); } /*if("0".equals(gameId)) {//幸运购 //查询当前机构的幸运够 List 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); }else if("1".equals(gameId)){//游戏购 //获取设备商品信息 VmProEquRel proEquRel = Service.lookup(IMINDataBaseService.class) .getMybatisMapper(VmProEquRelMapper.class) .selectByPrimaryKey(list.get(0).getProEquRelId()); drawDtoList1 = drawService.orderDrawGame( orderInf, proEquRel, list.get(0)); }*/ //更新 订单表, 订单详情表,提货表 DeliveryAction.createDeliveryInfo(drawDtoList1); } return res; } }