Browse Source

优惠券订单列表增加导出

liyuan 3 days ago
parent
commit
65c45ef65e

+ 66 - 0
blade-service-api/blade-sales-part-api/src/main/java/org/springblade/salesPart/coupon/excel/CouponReportExcel.java

@@ -0,0 +1,66 @@
+package org.springblade.salesPart.coupon.excel;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * @author Rain
+ */
+@Data
+public class CouponReportExcel {
+
+
+	@ExcelProperty(value = "销售单号")
+	private String orderNo;
+
+	/**
+	 * 客户名称
+	 */
+	@ExcelProperty(value = "客户名称")
+	private String customerName;
+
+	/**
+	 * 商品名称
+	 */
+	@ExcelProperty(value = "商品名称")
+	private String goodsNameJoin;
+
+	/**
+	 * 行数
+	 */
+	@ExcelProperty(value = "行数")
+	private Integer numberRows;
+	/**
+	 * 数量
+	 */
+	@ExcelProperty(value = "总数量")
+	private BigDecimal goodsTotalNum;
+
+	/**
+	 * 总金额
+	 */
+	@ExcelProperty(value = "总金额")
+	private BigDecimal totalMoney;
+
+	/**
+	 * 红包金额
+	 */
+	@ExcelProperty(value = "红包金额")
+	private BigDecimal redPacketAmount;
+
+	/**
+	 * 业务日期
+	 */
+	@ExcelProperty(value = "业务日期")
+	private Date businessDate;
+
+	/**
+	 * 状态
+	 */
+	@ExcelProperty(value = "状态")
+	private String status;
+
+}

+ 9 - 0
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/coupon/controller/TireCouponController.java

@@ -2,14 +2,17 @@ package org.springblade.salesPart.coupon.controller;
 
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import lombok.AllArgsConstructor;
 import lombok.AllArgsConstructor;
+import org.springblade.core.excel.util.ExcelUtil;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.api.R;
 import org.springblade.salesPart.coupon.dto.CouponReportDto;
 import org.springblade.salesPart.coupon.dto.CouponReportDto;
 import org.springblade.salesPart.coupon.dto.CouponReportOrderDto;
 import org.springblade.salesPart.coupon.dto.CouponReportOrderDto;
+import org.springblade.salesPart.coupon.excel.CouponReportExcel;
 import org.springblade.salesPart.coupon.service.ITireCouponService;
 import org.springblade.salesPart.coupon.service.ITireCouponService;
 import org.springblade.salesPart.coupon.vo.CouponReportVo;
 import org.springblade.salesPart.coupon.vo.CouponReportVo;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.*;
 
 
+import javax.servlet.http.HttpServletResponse;
 import java.util.List;
 import java.util.List;
 
 
 /**
 /**
@@ -72,4 +75,10 @@ public class TireCouponController {
 	}
 	}
 
 
 
 
+	@GetMapping("/exportCouponReportData")
+	public void exportCouponReportData(CouponReportVo couponReportVo, HttpServletResponse response) {
+		List<CouponReportExcel> couponReportExcelList = tireCouponService.getExportCouponReportData(couponReportVo);
+		ExcelUtil.export(response, "红包订单数据", "订单数据", couponReportExcelList, CouponReportExcel.class);
+	}
+
 }
 }

+ 10 - 0
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/coupon/mapper/TireUserCouponMapper.java

@@ -8,6 +8,7 @@ import org.springblade.salesPart.coupon.dto.CouponReportOrderDto;
 import org.springblade.salesPart.coupon.dto.CouponReturnsItemDto;
 import org.springblade.salesPart.coupon.dto.CouponReturnsItemDto;
 import org.springblade.salesPart.coupon.dto.TireUserCouponDto;
 import org.springblade.salesPart.coupon.dto.TireUserCouponDto;
 import org.springblade.salesPart.coupon.entity.TireUserCoupon;
 import org.springblade.salesPart.coupon.entity.TireUserCoupon;
+import org.springblade.salesPart.coupon.excel.CouponReportExcel;
 import org.springblade.salesPart.coupon.vo.CouponReportVo;
 import org.springblade.salesPart.coupon.vo.CouponReportVo;
 
 
 import java.util.List;
 import java.util.List;
@@ -84,4 +85,13 @@ public interface TireUserCouponMapper extends BaseMapper<TireUserCoupon> {
 	 */
 	 */
 	@TenantIgnore
 	@TenantIgnore
 	List<CouponReportOrderDto> getCouponReportOrderList(@Param("customerId") Long customerId, @Param("tenantId") String tenantId, @Param("checkType") Integer checkType);
 	List<CouponReportOrderDto> getCouponReportOrderList(@Param("customerId") Long customerId, @Param("tenantId") String tenantId, @Param("checkType") Integer checkType);
+
+	/**
+	 * 获取导出优惠券报表列表
+	 *
+	 * @param couponReportVo 优惠券报表参数
+	 * @return 优惠券报表列表
+	 */
+	@TenantIgnore
+	List<CouponReportExcel> getExportCouponReportData(CouponReportVo couponReportVo);
 }
 }

+ 43 - 0
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/coupon/mapper/TireUserCouponMapper.xml

@@ -35,6 +35,18 @@
         <result property="goodsNameJoin" column="goods_name_join"/>
         <result property="goodsNameJoin" column="goods_name_join"/>
     </resultMap>
     </resultMap>
 
 
+    <resultMap id="CouponReportExcelMap" type="org.springblade.salesPart.coupon.excel.CouponReportExcel">
+        <result property="orderNo" column="ord_no"/>
+        <result property="customerName" column="customer_name"/>
+        <result property="numberRows" column="number_rows"/>
+        <result property="goodsTotalNum" column="goods_total_num"/>
+        <result property="totalMoney" column="total_money"/>
+        <result property="redPacketAmount" column="red_packet_amount"/>
+        <result property="businessDate" column="busines_date"/>
+        <result property="status" column="status"/>
+        <result property="goodsNameJoin" column="goods_name_join"/>
+    </resultMap>
+
 
 
     <insert id="saveBatch">
     <insert id="saveBatch">
         INSERT INTO tire_user_coupon (
         INSERT INTO tire_user_coupon (
@@ -192,4 +204,35 @@
         and u.corps_id = #{customerId}
         and u.corps_id = #{customerId}
         group by po.id
         group by po.id
     </select>
     </select>
+    <select id="getExportCouponReportData" resultMap="CouponReportExcelMap"
+            parameterType="org.springblade.salesPart.coupon.vo.CouponReportVo">
+        SELECT DISTINCT po.ord_no,
+                        po.customer_name,
+                        po.number_rows,
+                        po.goods_total_num,
+                        po.total_money,
+                        po.busines_date,
+                        po.goods_name_join,
+                        po.status,
+                        sum(tc.value) as red_packet_amount
+        FROM tire_user_coupon u
+                 INNER JOIN pjpf_order po ON u.order_id = po.id
+                 inner join tire_coupon tc on u.coupon_id = tc.id
+        WHERE u.acquire_time IS NOT NULL
+          AND u.STATUS = 1
+          and po.status != '录入'
+        AND po.returns_status = '无'
+        and u.tenant_id = #{tenantId}
+          and po.tenant_id = #{tenantId}
+        <if test="storeName != null and storeName != ''">
+            AND po.customer_name LIKE CONCAT('%', #{storeName}, '%')
+        </if>
+        <if test="startDate != null">
+            AND DATE(u.acquire_time) >= #{startDate}
+        </if>
+        <if test="endDate != null">
+            AND DATE(u.acquire_time) &lt;= #{endDate}
+        </if>
+        group by po.id
+    </select>
 </mapper>
 </mapper>

+ 10 - 1
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/coupon/service/ITireCouponService.java

@@ -7,6 +7,7 @@ import org.springblade.core.tool.api.R;
 import org.springblade.salesPart.coupon.dto.CouponReportDto;
 import org.springblade.salesPart.coupon.dto.CouponReportDto;
 import org.springblade.salesPart.coupon.dto.CouponReportOrderDto;
 import org.springblade.salesPart.coupon.dto.CouponReportOrderDto;
 import org.springblade.salesPart.coupon.entity.TireCoupon;
 import org.springblade.salesPart.coupon.entity.TireCoupon;
+import org.springblade.salesPart.coupon.excel.CouponReportExcel;
 import org.springblade.salesPart.coupon.vo.CouponReportVo;
 import org.springblade.salesPart.coupon.vo.CouponReportVo;
 
 
 import java.util.List;
 import java.util.List;
@@ -72,8 +73,16 @@ public interface ITireCouponService extends IService<TireCoupon> {
 	 * 获取使用优惠券的订单列表
 	 * 获取使用优惠券的订单列表
 	 *
 	 *
 	 * @param customerId 门店id
 	 * @param customerId 门店id
-	 * @param checkType 查看类型
+	 * @param checkType  查看类型
 	 * @return 结果
 	 * @return 结果
 	 */
 	 */
 	List<CouponReportOrderDto> getCouponReportOrderList(Long customerId, Integer checkType);
 	List<CouponReportOrderDto> getCouponReportOrderList(Long customerId, Integer checkType);
+
+	/**
+	 * 导出优惠券报表数据
+	 *
+	 * @param couponReportVo 优惠券报表参数
+	 * @return 结果
+	 */
+	List<CouponReportExcel> getExportCouponReportData(CouponReportVo couponReportVo);
 }
 }

+ 7 - 0
blade-service/blade-sales-part/src/main/java/org/springblade/salesPart/coupon/service/impl/TireCouponServiceImpl.java

@@ -20,6 +20,7 @@ import org.springblade.salesPart.coupon.entity.TireCoupon;
 import org.springblade.salesPart.coupon.entity.TireCouponRule;
 import org.springblade.salesPart.coupon.entity.TireCouponRule;
 import org.springblade.salesPart.coupon.entity.TireCouponViewLog;
 import org.springblade.salesPart.coupon.entity.TireCouponViewLog;
 import org.springblade.salesPart.coupon.entity.TireUserCoupon;
 import org.springblade.salesPart.coupon.entity.TireUserCoupon;
+import org.springblade.salesPart.coupon.excel.CouponReportExcel;
 import org.springblade.salesPart.coupon.mapper.TireCouponMapper;
 import org.springblade.salesPart.coupon.mapper.TireCouponMapper;
 import org.springblade.salesPart.coupon.mapper.TireCouponRuleMapper;
 import org.springblade.salesPart.coupon.mapper.TireCouponRuleMapper;
 import org.springblade.salesPart.coupon.mapper.TireCouponViewLogMapper;
 import org.springblade.salesPart.coupon.mapper.TireCouponViewLogMapper;
@@ -319,4 +320,10 @@ public class TireCouponServiceImpl extends ServiceImpl<TireCouponMapper, TireCou
 	public List<CouponReportOrderDto> getCouponReportOrderList(Long customerId, Integer checkType) {
 	public List<CouponReportOrderDto> getCouponReportOrderList(Long customerId, Integer checkType) {
 		return tireUserCouponMapper.getCouponReportOrderList(customerId, AuthUtil.getTenantId(), checkType);
 		return tireUserCouponMapper.getCouponReportOrderList(customerId, AuthUtil.getTenantId(), checkType);
 	}
 	}
+
+	@Override
+	public List<CouponReportExcel> getExportCouponReportData(CouponReportVo couponReportVo) {
+		couponReportVo.setTenantId(AuthUtil.getTenantId());
+		return tireUserCouponMapper.getExportCouponReportData(couponReportVo);
+	}
 }
 }