diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java index 5c6e70aa..82e3710a 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java @@ -41,6 +41,7 @@ import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.io.File; +import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -801,4 +802,19 @@ public class HighCouponController { } } + @RequestMapping(value="/getCouponSalesPrice",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询卡券销售面值") + public ResponseData getCouponSalesPrice(@RequestParam(name = "couponSource", required = true) Integer couponSource) { + try { + + return ResponseMsgUtil.success(highCouponService.getCouponSalesPrice(couponSource)); + + } catch (Exception e) { + log.error("HighCouponController -> getCouponList() error!",e); + return ResponseMsgUtil.exception(e); + } + } + + } diff --git a/hai-bweb/src/main/java/com/bweb/controller/OrderStatistics/CouponStatisticsController.java b/hai-bweb/src/main/java/com/bweb/controller/OrderStatistics/CouponStatisticsController.java new file mode 100644 index 00000000..1344be76 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/OrderStatistics/CouponStatisticsController.java @@ -0,0 +1,93 @@ +package com.bweb.controller.OrderStatistics; + +import com.alibaba.fastjson.JSONObject; +import com.bweb.controller.ApiProductController; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.SessionObject; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.HighCoupon; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.HighCouponService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.collections4.MapUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * @className: CouponController + * @author: HuRui + * @date: 2023/7/12 + **/ +@Controller +@RequestMapping(value = "/couponStatistics") +@Api(value = "卡券统计") +public class CouponStatisticsController { + Logger log = LoggerFactory.getLogger(CouponStatisticsController.class); + + @Resource + private HighCouponService couponService; + + @RequestMapping(value = "/useCouponStatistics", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "卡券使用统计") + public ResponseData useCouponStatistics(@RequestParam(name = "couponSource", required = false) Integer couponSource, + @RequestParam(name = "salesPrice", required = false) BigDecimal salesPrice, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "salesTimeS", required = false) Long salesTimeS, + @RequestParam(name = "salesTimeE", required = false) Long salesTimeE) { + try { + JSONObject param = new JSONObject(); + param.put("couponSource" , couponSource); + param.put("salesPrice" , salesPrice); + param.put("salesTimeS" , salesTimeS); + param.put("salesTimeE" , salesTimeE); + List> couponStatistics = couponService.getUseCouponStatistics(param); + + Map returnMap = new HashMap<>(); + List> couponMapList = new ArrayList<>(); + Map couponMap; + + for (Map map : couponStatistics) { + couponMap = new HashMap<>(); + couponMap.put("salesPrice", map.get("sales_price")); + couponMap.put("status", 20); + couponMap.put("count", map.get("notUseCount")); + couponMapList.add(couponMap); + + couponMap = new HashMap<>(); + couponMap.put("salesPrice", map.get("sales_price")); + couponMap.put("status", 40); + couponMap.put("count", map.get("useCount")); + couponMapList.add(couponMap); + } + if (status != null) { + couponMapList = couponMapList.stream().filter(o -> MapUtils.getInteger(o, "status").equals(status)).collect(Collectors.toList()); + } + returnMap.put("salesPriceList", couponMapList); + return ResponseMsgUtil.success(returnMap); + + } catch (Exception e) { + log.error("CouponStatisticsController --> useCouponStatistics() error!", e); + return ResponseMsgUtil.exception(e); + } + } + +} diff --git a/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java b/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java index 35c13939..9c0d2fcc 100644 --- a/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java +++ b/hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java @@ -335,7 +335,10 @@ public class HuiLianTongUnionCardConfig { public static void main(String[] args) { // {"respMessage":"ok","data":"Gbkl57c3fEBg+E3HfPuQ580JLkHaQPyf1P7My1oYOyJSIG4i8jYxovGVk4V8Rk58mjDswB8Vpy4E\nyj/wi/UNr8TDne094+yu","sign":"47186141FD8B3FB6CCB590F58321D9C6","respCode":"0000","responseId":"1669202185936"} - String data = "Gbkl57c3fEBg+E3HfPuQ580JLkHaQPyf1P7My1oYOyJSIG4i8jYxovGVk4V8Rk58mjDswB8Vpy4E\nyj/wi/UNr8TDne094+yu".replace("\\n", ""); + String data = "Gbkl57c3fEBg+E3HfPuQ55SDLVyAf2Ys3VN1cifAfXIoT1gnbFR0NaiH/z1OIZZiuqlFwDLLu6n4\n" + + "VBkM8fF5jVEekFNLY57NgRfRr4BghKXdIr8hdPJnbfOO0VtjITPrrZWwMDwfYzJulYhBsNGCubov\n" + + "9ruAA0DN0ESoH765nvlH0lI/wdIOvRE7GyTfQzzT68i5p+Qf/k7yjQk22l4KUfuUVM+jMeW95xkd\n" + + "+gVJvWctjBC0DN3zi3CwsVgQwVmj".replace("\\n", ""); String decodeData = DesUtil.decode("F8E91A3C", data, Charset.forName("UTF-8")); System.out.println(JSONObject.parseObject(decodeData)); diff --git a/hai-service/src/main/java/com/hai/dao/HighCouponMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighCouponMapperExt.java index 742c2538..3d09da8c 100644 --- a/hai-service/src/main/java/com/hai/dao/HighCouponMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighCouponMapperExt.java @@ -3,6 +3,10 @@ package com.hai.dao; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; +import java.math.BigDecimal; +import java.util.List; +import java.util.Map; + /** * mapper扩展类 */ @@ -15,4 +19,19 @@ public interface HighCouponMapperExt { @Select({"SELECT count(1) FROM `high_child_order` " + " where goods_type = 1 and goods_id = #{couponId} and child_order_status in (2,3,6,7) and DATE_FORMAT(pay_time,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')"}) int getMonthlySales(@Param("couponId") Long couponId); + + + @Select("") + List> getUseCouponStatistics(@Param("param") Map param); + + @Select("select sales_price from high_coupon where coupon_source = #{couponSource} GROUP BY sales_price ORDER BY sales_price") + List getCouponSalesPrice(@Param("couponSource") Integer couponSource); } diff --git a/hai-service/src/main/java/com/hai/service/HighCouponService.java b/hai-service/src/main/java/com/hai/service/HighCouponService.java index 8b434316..af48be43 100644 --- a/hai-service/src/main/java/com/hai/service/HighCouponService.java +++ b/hai-service/src/main/java/com/hai/service/HighCouponService.java @@ -3,6 +3,7 @@ package com.hai.service; import com.hai.entity.*; import com.hai.model.HighCouponModel; +import java.math.BigDecimal; import java.util.List; import java.util.Map; @@ -164,6 +165,7 @@ public interface HighCouponService { */ int getMonthlySales(Long couponId); + List> getUseCouponStatistics(Map param) throws Exception; - + List getCouponSalesPrice(Integer couponSource); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java index e97e7a09..f0d8696e 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.java @@ -7,6 +7,7 @@ import com.alibaba.fastjson.JSONObject; import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; +import com.hai.common.utils.DateUtil; import com.hai.dao.HighCouponHandselMapper; import com.hai.dao.HighCouponMapper; import com.hai.entity.*; @@ -24,6 +25,7 @@ import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; @@ -598,5 +600,22 @@ public class HighCouponServiceImpl implements HighCouponService { return highCouponMapper.getMonthlySales(couponId); } + @Override + public List> getUseCouponStatistics(Map param) throws Exception { + if (MapUtils.getLong(param, "salesTimeS") != null) { + param.put("salesTimeS", DateUtil.date2String(new Date(MapUtils.getLong(param, "salesTimeS")), "yyyy-MM-dd HH:mm:ss")); + } + + if (MapUtils.getLong(param, "salesTimeE") != null) { + param.put("salesTimeE", DateUtil.date2String(new Date(MapUtils.getLong(param, "salesTimeE")), "yyyy-MM-dd HH:mm:ss")); + } + return highCouponMapper.getUseCouponStatistics(param); + } + + @Override + public List getCouponSalesPrice(Integer couponSource) { + return highCouponMapper.getCouponSalesPrice(couponSource); + } + }