提交代码

new-dev
胡锐 1 year ago
parent e6f1881ebd
commit 76a03b94f5
  1. 16
      hai-bweb/src/main/java/com/bweb/controller/HighCouponController.java
  2. 93
      hai-bweb/src/main/java/com/bweb/controller/OrderStatistics/CouponStatisticsController.java
  3. 5
      hai-service/src/main/java/com/hai/config/HuiLianTongUnionCardConfig.java
  4. 19
      hai-service/src/main/java/com/hai/dao/HighCouponMapperExt.java
  5. 4
      hai-service/src/main/java/com/hai/service/HighCouponService.java
  6. 19
      hai-service/src/main/java/com/hai/service/impl/HighCouponServiceImpl.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);
}
}
}

@ -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<Map<String, Object>> couponStatistics = couponService.getUseCouponStatistics(param);
Map<String, Object> returnMap = new HashMap<>();
List<Map<String, Object>> couponMapList = new ArrayList<>();
Map<String, Object> couponMap;
for (Map<String,Object> 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);
}
}
}

@ -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));

@ -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("<script>" +
" select a.sales_price,sum(notUseCount) notUseCount,sum(a.useCount) useCount from " +
"(select a.sales_price, (select count(1) FROM high_coupon_code_other WHERE cou_type_code = a.coupon_key and `status` = 20 <if test='param.salesTimeS != null'> and create_time BETWEEN #{param.salesTimeS} and #{param.salesTimeE} </if> ) notUseCount, " +
"(select count(1) FROM high_coupon_code_other WHERE cou_type_code = a.coupon_key and `status` = 40 <if test='param.salesTimeS != null'> and create_time BETWEEN #{param.salesTimeS} and #{param.salesTimeE} </if> ) useCount " +
" FROM high_coupon a" +
" WHERE a.coupon_source = #{param.couponSource} GROUP BY coupon_key ORDER BY a.sales_price) a where 1 = 1 " +
" <if test='param.salesPrice != null'> and a.sales_price = #{param.salesPrice} </if>" +
" GROUP BY a.sales_price" +
" </script>")
List<Map<String, Object>> getUseCouponStatistics(@Param("param") Map<String, Object> param);
@Select("select sales_price from high_coupon where coupon_source = #{couponSource} GROUP BY sales_price ORDER BY sales_price")
List<BigDecimal> getCouponSalesPrice(@Param("couponSource") Integer couponSource);
}

@ -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<Map<String, Object>> getUseCouponStatistics(Map<String, Object> param) throws Exception;
List<BigDecimal> getCouponSalesPrice(Integer couponSource);
}

@ -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<Map<String, Object>> getUseCouponStatistics(Map<String, Object> 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<BigDecimal> getCouponSalesPrice(Integer couponSource) {
return highCouponMapper.getCouponSalesPrice(couponSource);
}
}

Loading…
Cancel
Save