From e700cf359eae10826ecf37430c0d8fc6018e448d Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 11 May 2021 22:38:18 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighCouponAgentController.java | 51 ++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java index 5a349f27..343f6e8e 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponAgentController.java @@ -28,6 +28,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -85,7 +86,7 @@ public class HighCouponAgentController { @RequestMapping(value = "/getAgentSalesCodeList", method = RequestMethod.GET) @ResponseBody - @ApiOperation(value = "查询今天 代理商已销售的卡券") + @ApiOperation(value = "查询代理商已销售的卡券") public ResponseData getAgentSalesCodeList(HttpServletRequest request, @RequestParam(name = "consumeTimeS", required = false) Long consumeTimeS, @RequestParam(name = "consumeTimeE", required = false) Long consumeTimeE, @@ -129,6 +130,54 @@ public class HighCouponAgentController { } } + @RequestMapping(value = "/getAgentSalesPriceCount", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询代理商销售总价格") + public ResponseData getAgentSalesPriceCount(HttpServletRequest request, + @RequestParam(name = "consumeTimeS", required = false) Long consumeTimeS, + @RequestParam(name = "consumeTimeE", required = false) Long consumeTimeE) { + try { + SessionObject sessionObject = userCenter.getSessionObject(request); + UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); + + if (userInfoModel.getHighAgent() == null) { + log.error("HighCouponAgentController -> assignCouponAgent() error!","该主角色没有权限"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.MENU_TREE_HAS_NOT_ERROR, ""); + } + // 如果为空查当前时间 + Calendar timeS = Calendar.getInstance(); + if (consumeTimeS != null) { + timeS.setTime(new Date(consumeTimeS)); + } else { + timeS.setTime(new Date()); + } + timeS.set(Calendar.HOUR_OF_DAY, 00); + timeS.set(Calendar.MINUTE, 00); + timeS.set(Calendar.SECOND, 00); + + Calendar timeE = Calendar.getInstance(); + if (consumeTimeE != null) { + timeE.setTime(new Date(consumeTimeE)); + } else { + timeE.setTime(new Date()); + } + timeE.set(Calendar.HOUR_OF_DAY, 23); + timeE.set(Calendar.MINUTE, 59); + timeE.set(Calendar.SECOND, 59); + + BigDecimal totalPrice = new BigDecimal("0.00"); + List list = highCouponAgentService.getAgentSalesCodeList(userInfoModel.getHighAgent().getId(), DateUtil.date2String(timeS.getTime(), "yyyy-MM-dd HH:mm:ss"), DateUtil.date2String(timeE.getTime(), "yyyy-MM-dd HH:mm:ss")); + for (HighCouponAgentCode code: list) { + totalPrice = totalPrice.add(code.getHighCoupon().getSalesPrice()); + } + return ResponseMsgUtil.success(totalPrice); + + } catch (Exception e) { + log.error("HighCouponAgentController --> getAgentSalesCodeList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value = "/assignCouponAgent", method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "分配卡券给代理商")