123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- 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<VmOrderDetails> list = Service.lookup(IMINDataBaseService.class)
- .getMybatisMapper(VmOrderDetailsMapper.class)
- .selectByExample(detailsExample);
- String gameId = orderInf.getGameRule();
- IDrawService drawService = new DrawServiceImpl();
- List<DrawDto> drawDtoList1 = new ArrayList<>();
- for (int i = 0; i < list.size(); i++) {
- List<DrawDto> 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<DrawDto> 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<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);
- }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;
- }
- }
|