diff --git a/v1/src/main/java/com/v1/controller/HighOrderController.java b/v1/src/main/java/com/v1/controller/HighOrderController.java index d74461af..a96b839a 100644 --- a/v1/src/main/java/com/v1/controller/HighOrderController.java +++ b/v1/src/main/java/com/v1/controller/HighOrderController.java @@ -5,7 +5,8 @@ import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.utils.ResponseMsgUtil; -import com.hai.entity.ApiMerchants; +import com.hai.entity.*; +import com.hai.model.HighMerchantStoreModel; import com.hai.model.ResponseData; import com.hai.service.*; import com.v1.config.ToolConfig; @@ -15,15 +16,14 @@ import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.text.SimpleDateFormat; +import java.util.Date; import java.util.HashMap; +import java.util.List; import java.util.Map; /** @@ -49,9 +49,24 @@ public class HighOrderController { @Resource private OutRechargeOrderService outRechargeOrderService; + @Resource + private HighDiscountPackageActualService discountPackageActualService; + + @Resource + private HighDiscountPackageService discountPackageService; + @Resource private HighOrderService highOrderService; + @Resource + private HighDiscountPackageRecordService discountPackageRecordService; + + @Resource + private HighDiscountUserRelService highDiscountUserRelService; + + @Resource + private HighDiscountPackageDiscountActualService discountPackageDiscountActualService; + @RequestMapping(value = "/getCallOrderList", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "获取话费订单列表") @@ -188,4 +203,47 @@ public class HighOrderController { return ResponseMsgUtil.exception(e); } } + + @RequestMapping(value = "/getDiscountPackage", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "getDiscountPackage") + public ResponseData getDiscountPackage(@RequestParam(name = "orderId", required = true) Long orderId) { + try { + HighOrder order = highOrderService.getOrderById(orderId); + + for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { + highChildOrder.setChildOrdeStatus(2); + HighDiscountPackageActual actual = discountPackageActualService.getDetailByChildOrderId(highChildOrder.getId()); + if (actual != null) { + List discountList = discountPackageDiscountActualService.getHighDiscountPackageDiscountActualList(actual.getId()); + for (HighDiscountPackageDiscountActual discount : discountList) { + highDiscountUserRelService.receiveDiscount(order.getMemId(), discount.getAgentDiscountCodeId()); + } + HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(actual.getDiscountPackageId()); + HighDiscountPackageRecord record = new HighDiscountPackageRecord(); + record.setDiscountPackageId(discountPackage.getId()); + record.setDiscountPackageTitle(discountPackage.getTitle()); + record.setUsingAttribution(discountPackage.getUsingAttribution()); + record.setCompanyId(discountPackage.getCompanyId()); + record.setOrderId(order.getId().intValue()); + record.setChildOrderId(highChildOrder.getId().intValue()); + record.setRecordNo(System.currentTimeMillis() + ""); + record.setSalesType(1); + record.setPrice(order.getPayPrice()); + record.setUserId(order.getMemId().intValue()); + discountPackageRecordService.insertRecord(record); + actual.setAllocationTime(new Date()); + actual.setStatus(3); // 状态: 1: 待分配 2:预分配(售卖)3:已分配 + discountPackageActualService.updateHighDiscountPackageActual(actual); + } + } + + return ResponseMsgUtil.success(null); + + } catch (Exception e) { + log.error("HighOrderController --> gasPageQueryAllStation() error!", e); + return ResponseMsgUtil.exception(e); + } + } + }