OrderDrawAction.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. package com.minpay.shouhuo.orderdrawaction;
  2. import java.util.ArrayList;
  3. import java.util.HashMap;
  4. import java.util.List;
  5. import java.util.Map;
  6. import com.minpay.common.bean.DrawDto;
  7. import com.minpay.common.service.IDrawService;
  8. import com.minpay.common.service.IPropertiesService;
  9. import com.minpay.common.service.IPublicService;
  10. import com.minpay.common.service.impl.DrawServiceImpl;
  11. import com.minpay.common.util.CommonUtil;
  12. import com.minpay.common.util.DateUtil;
  13. import com.minpay.db.table.mapper.VmOrderDetailsMapper;
  14. import com.minpay.db.table.mapper.VmOrderDrawDetailMapper;
  15. import com.minpay.db.table.mapper.VmOrderInfMapper;
  16. import com.minpay.db.table.mapper.VmProEquRelMapper;
  17. import com.minpay.db.table.model.VmOrderDetails;
  18. import com.minpay.db.table.model.VmOrderDetailsExample;
  19. import com.minpay.db.table.model.VmOrderDrawDetail;
  20. import com.minpay.db.table.model.VmOrderInf;
  21. import com.minpay.db.table.model.VmProEquRel;
  22. import com.minpay.db.table.own.mapper.OrderDrawMapper;
  23. import com.minpay.shouhuo.deliveryaction.DeliveryAction;
  24. import com.startup.minpay.frame.business.IMINAction;
  25. import com.startup.minpay.frame.business.res.MINActionResult;
  26. import com.startup.minpay.frame.exception.MINBusinessException;
  27. import com.startup.minpay.frame.service.base.IMINDataBaseService;
  28. import com.startup.minpay.frame.service.base.Service;
  29. import com.startup.minpay.frame.target.MINAction;
  30. import com.startup.minpay.frame.target.MINComponent;
  31. /**
  32. * 订单成功回调接口
  33. * @author dudm@minpay.cc
  34. *
  35. */
  36. @MINComponent
  37. public class OrderDrawAction implements IMINAction{
  38. /**订单成功回调接口*/
  39. public static final String EDIT_ORDER_DRAW = "editOrderDraw";
  40. /**幸运购*/
  41. public static final String ORDER_DRAW_LUCKY = "orderDrawLucky";
  42. /**游戏购*/
  43. public static final String ORDER_DRAW_GAME = "orderDrawGame";
  44. /**二游戏购*/
  45. public static final String TWO_ORDER_DRAW_GAME = "twoOrderDrawGame";
  46. /**
  47. * 订单成功回调接口
  48. * @param orderInf 付款订单
  49. * @return
  50. * @throws MINBusinessException
  51. */
  52. @MINAction(value = EDIT_ORDER_DRAW)
  53. public MINActionResult editOrderDraw(VmOrderInf orderInf,String sysorderno) throws MINBusinessException{
  54. MINActionResult res = new MINActionResult();
  55. //是抽奖商品
  56. if("01".equals(orderInf.getProType())){
  57. //通过订单id获取商品设备关联表id
  58. VmOrderDetailsExample detailsExample = new VmOrderDetailsExample();
  59. detailsExample.createCriteria().andOrderIdEqualTo(orderInf.getId())
  60. .andChannelEqualTo(orderInf.getChannel());
  61. List<VmOrderDetails> list = Service.lookup(IMINDataBaseService.class)
  62. .getMybatisMapper(VmOrderDetailsMapper.class)
  63. .selectByExample(detailsExample);
  64. String gameId = orderInf.getGameRule();
  65. IDrawService drawService = new DrawServiceImpl();
  66. List<DrawDto> drawDtoList1 = new ArrayList<>();
  67. for (int i = 0; i < list.size(); i++) {
  68. List<DrawDto> drawDtoList2 = new ArrayList<>();
  69. //查询订单详情关联货到
  70. VmOrderDetails vmOrderDetails = list.get(i);
  71. VmProEquRel vmProEquRel = Service.lookup(IMINDataBaseService.class)
  72. .getMybatisMapper(VmProEquRelMapper.class)
  73. .selectByPrimaryKey(vmOrderDetails.getProEquRelId());
  74. String gameType = vmProEquRel.getGameType();
  75. //计算平均到每一个商品的金额
  76. String orderAmt = orderInf.getOrderAmt();
  77. String detailsAmt = CommonUtil.divide(orderAmt,String.valueOf(list.size()),2);
  78. if(gameType.equals("01")){ //幸运购
  79. List<DrawDto> drawDtoList = new ArrayList<>();
  80. DrawDto drawDto = new DrawDto();
  81. drawDto.setOrderId(vmOrderDetails.getOrderId());
  82. drawDto.setOrderDetailsId(vmOrderDetails.getDetailsId());
  83. drawDto.setHuodaoNo(vmOrderDetails.getProEquRelId());
  84. drawDto.setChouJiangAmt(orderInf.getOrderAmt());
  85. drawDtoList.add(drawDto);
  86. drawDtoList2 = drawService.xingyunDraw( detailsAmt, orderInf.getId(), sysorderno,
  87. orderInf.getEquipmentId(), drawDtoList);
  88. }else if(gameType.equals("02")){ //游戏购
  89. drawDtoList2 = drawService.orderDrawGame( orderInf, vmProEquRel, vmOrderDetails,detailsAmt);
  90. }
  91. drawDtoList1.addAll(drawDtoList2);
  92. }
  93. /*if("0".equals(gameId)) {//幸运购
  94. //查询当前机构的幸运够
  95. List<DrawDto> drawDtoList = new ArrayList<>();
  96. for (int i = 0; i < list.size(); i++) {
  97. VmOrderDetails vmOrderDetails = list.get(i);
  98. DrawDto drawDto = new DrawDto();
  99. drawDto.setOrderId(vmOrderDetails.getOrderId());
  100. drawDto.setOrderDetailsId(vmOrderDetails.getDetailsId());
  101. drawDto.setHuodaoNo(vmOrderDetails.getProEquRelId());
  102. drawDto.setChouJiangAmt(orderInf.getOrderAmt());
  103. drawDtoList.add(drawDto);
  104. }
  105. drawDtoList1 = drawService.xingyunDraw( orderInf.getOrderAmt(), orderInf.getId(), sysorderno,
  106. orderInf.getEquipmentId(), drawDtoList);
  107. }else if("1".equals(gameId)){//游戏购
  108. //获取设备商品信息
  109. VmProEquRel proEquRel = Service.lookup(IMINDataBaseService.class)
  110. .getMybatisMapper(VmProEquRelMapper.class)
  111. .selectByPrimaryKey(list.get(0).getProEquRelId());
  112. drawDtoList1 = drawService.orderDrawGame( orderInf, proEquRel, list.get(0));
  113. }*/
  114. //更新 订单表, 订单详情表,提货表
  115. DeliveryAction.createDeliveryInfo(drawDtoList1);
  116. }
  117. return res;
  118. }
  119. }