qin 1 год назад
Родитель
Сommit
c69ed66afb

+ 5 - 1
pom.xml

@@ -213,6 +213,11 @@
             <artifactId>imageio-tiff</artifactId>
             <version>3.8.1</version>
         </dependency>
+        <dependency>
+            <groupId>com.drewnoakes</groupId>
+            <artifactId>metadata-extractor</artifactId>
+            <version>2.15.0</version>
+        </dependency>
     </dependencies>
 
     <dependencyManagement>
@@ -241,7 +246,6 @@
                 <artifactId>knife4j-spring-boot-starter</artifactId>
                 <version>${knife4j.version}</version>
             </dependency>
-
         </dependencies>
     </dependencyManagement>
 

+ 39 - 1
src/main/java/com/poteviohealth/cgp/statistics/controller/OrderController.java

@@ -12,6 +12,7 @@ import com.poteviohealth.cgp.common.facade.log.OperationLog;
 import com.poteviohealth.cgp.common.facade.time.MethodTime;
 import com.poteviohealth.cgp.common.filter.TokenContext;
 import com.poteviohealth.cgp.common.filter.repeatSubmit.RepeatSubmit;
+import com.poteviohealth.cgp.common.integrated.finance.model.CardAccTransRecharge;
 import com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanDTO;
 import com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanPageDTO;
 import com.poteviohealth.cgp.common.model.VaultsResponse;
@@ -235,7 +236,7 @@ public class OrderController extends BaseWebController {
         try{
             if ("".equals(error)) {
                 String templateLocation = "classpath:excel/pageCard.xlsx";
-                String filename = "消费卡账户.xlsx";
+                String filename = "客户账户.xlsx";
                 Map<String, Object> data = Maps.newHashMap();
                 orgConstrainService.fillOrgParams(dto);
                 List<MemberPlanDTO> list = orderService.pageCardExcel(dto);
@@ -254,4 +255,41 @@ public class OrderController extends BaseWebController {
             }
         }
     }
+
+
+    @PostMapping(value = "/transRechargeExcel")
+    @ApiOperation(httpMethod = "POST", value = "账户充值Excel导出")
+    @RepeatSubmit
+    @MethodTime
+    public void transRechargeExcel(HttpServletResponse resp, @RequestBody CardWebInDTO dto){
+        String key ="transRechargeExcel";
+        String error =  this.checkExcelExport(key);
+        try{
+            if ("".equals(error)) {
+                orgConstrainService.fillOrgParams(dto);
+                Map<String,Object> maps = Maps.newHashMap();
+                String start = DateFormatUtils.format(dto.getStartDate(), "yyyy-MM");
+                String end = DateFormatUtils.format(dto.getEndDate(), "yyyy-MM");
+                if(start.equals(end)){
+                    maps.put("title", start+"充值记录");
+                }else{
+                    maps.put("title", start+"到"+end+"充值记录");
+                }
+
+                List<CardAccTransRecharge> list = orderService.transRechargeExcel(dto);
+                ExcelUtils2.easyDownload("classpath:excel/trans_recharge.xlsx",maps, list,  "", resp);
+            }else{
+                throw new BusinessException(error);
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+            throw new BusinessException(e.getMessage());
+        }finally {
+            if(cacheService.exists(key)){
+                if(cacheService.get(key).equals(TokenContext.cureWebUser().getUserId().toString())){
+                    cacheService.del(key);
+                }
+            }
+        }
+    }
 }

+ 13 - 0
src/main/java/com/poteviohealth/cgp/statistics/mapper/OrderMapper.java

@@ -7,10 +7,12 @@ import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.poteviohealth.cgp.common.integrated.ListParams;
 import com.poteviohealth.cgp.common.integrated.customer.model.CustomerServiceParams;
 import com.poteviohealth.cgp.common.integrated.customer.model.CustomerSubsidyDTO;
+import com.poteviohealth.cgp.common.integrated.finance.model.CardAccTransRecharge;
 import com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanDTO;
 import com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanPageDTO;
 import com.poteviohealth.cgp.common.integrated.partner.model.AreaDTO;
 import com.poteviohealth.cgp.statistics.model.Order;
+import com.poteviohealth.cgp.statistics.model.indto.CardWebInDTO;
 import com.poteviohealth.cgp.statistics.model.outdto.*;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -223,6 +225,17 @@ public interface OrderMapper extends BaseMapper<Order>{
     LinkedList<MemberPlanDTO> pageCardList(@Param("queryParam") MemberPlanPageDTO dto, @Param(Constants.WRAPPER) Wrapper wrapper,@Param("dbName") String dbName, @Param("start")Integer start);
 
 
+    @SqlParser(filter = true)
+    int transRechargeExcelListAllSize(@Param(Constants.WRAPPER) Wrapper wrapper, @Param("queryParam") CardWebInDTO var2, @Param("dbName")String dbName);
+
+    /**
+     * excel
+     * @param wrapper
+     * @return
+     */
+    @SqlParser(filter=true)
+    LinkedList<CardAccTransRecharge> transRechargeExcel(@Param(Constants.WRAPPER) Wrapper wrapper,@Param("queryParam") CardWebInDTO var2, @Param("dbName")String dbName, @Param("start")Integer start);
+
 
 
 }

+ 33 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/indto/CardWebInDTO.java

@@ -0,0 +1,33 @@
+package com.poteviohealth.cgp.statistics.model.indto;
+
+import com.poteviohealth.cgp.common.model.OrgPageQuery;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+import java.util.Date;
+
+/**
+ * 充值记录
+ * @Author Qin
+ * @Date 2019/7/26 18:46
+ **/
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="充值记录")
+public class CardWebInDTO extends OrgPageQuery {
+
+    @ApiModelProperty(value = "起始时间")
+    private Date startDate;
+
+    @ApiModelProperty(value = "结束时间")
+    private Date endDate;
+
+    @ApiModelProperty(value = "类型Id")
+    private Integer typeId;
+}

+ 15 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/indto/DishesOrderWebInDTO.java

@@ -39,4 +39,19 @@ public class DishesOrderWebInDTO extends OrgPageQuery {
 
     @ApiModelProperty(value = "支付方式")
     private Integer payStyle;
+
+    @ApiModelProperty(value = "区")
+    private Integer districtid;
+
+    @ApiModelProperty(value = "街道")
+    private Integer streetid;
+
+    @ApiModelProperty(value = "身份证")
+    private String idCard;
+
+    @ApiModelProperty(value = "来源:1.刷脸,2.手机号")
+    private Integer sourceId;
+
+    @ApiModelProperty(value = "堂食标志:0.非,1.是")
+    private Integer eatIn;
 }

+ 16 - 0
src/main/java/com/poteviohealth/cgp/statistics/model/outdto/DishesOrderWebOutDTO.java

@@ -46,6 +46,9 @@ public class DishesOrderWebOutDTO {
     @ApiModelProperty(value = "客户电话")
     private String customerPhone;
 
+    @ApiModelProperty(value = "身份证")
+    private String idCard;
+
     @ApiModelProperty(value = "商品相关信息")
     private String productString;
 
@@ -54,4 +57,17 @@ public class DishesOrderWebOutDTO {
 
     @ApiModelProperty(value = "支付账户:1.助餐;2.积分;3.市场化;4.现金;")
     private String payAccountStr;
+
+    @ApiModelProperty(value = "街道名")
+    private String streetName;
+
+    @ApiModelProperty(value = "区名")
+    private String countryName;
+
+    @ApiModelProperty(value = "来源:1.刷脸,2.手机号")
+    private String sourceStr;
+
+
+    @ApiModelProperty(value = "堂食标志:0.非,1.是")
+    private String eatInStr;
 }

+ 8 - 4
src/main/java/com/poteviohealth/cgp/statistics/service/IOrderService.java

@@ -1,13 +1,11 @@
 package com.poteviohealth.cgp.statistics.service;
 
+import com.poteviohealth.cgp.common.integrated.finance.model.CardAccTransRecharge;
 import com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanDTO;
 import com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanPageDTO;
 import com.poteviohealth.cgp.common.service.IBaseService;
 import com.poteviohealth.cgp.statistics.model.Order;
-import com.poteviohealth.cgp.statistics.model.indto.DishesOrderWebInDTO;
-import com.poteviohealth.cgp.statistics.model.indto.OrderCostWebInDTO;
-import com.poteviohealth.cgp.statistics.model.indto.OrderServiceWebInDTO;
-import com.poteviohealth.cgp.statistics.model.indto.OrderWebInDTO;
+import com.poteviohealth.cgp.statistics.model.indto.*;
 import com.poteviohealth.cgp.statistics.model.outdto.DishesOrderWebOutDTO;
 import com.poteviohealth.cgp.statistics.model.outdto.OrderCostWebOutDTO;
 import com.poteviohealth.cgp.statistics.model.outdto.OrderExcelDTO;
@@ -39,6 +37,12 @@ public interface IOrderService extends IBaseService<Order> {
      */
     List<DishesOrderWebOutDTO> orderDishes(DishesOrderWebInDTO dto);
 
+    /**
+     * excel
+     * @return
+     */
+    List<CardAccTransRecharge> transRechargeExcel(CardWebInDTO dto);
+
     List<OrderCostWebOutDTO> OrderCostList(OrderCostWebInDTO orderCostWebInDTO);
 
     /**

+ 43 - 12
src/main/java/com/poteviohealth/cgp/statistics/service/impl/OrderServiceImpl.java

@@ -12,10 +12,7 @@ import com.poteviohealth.cgp.common.integrated.customer.model.CustomerServicePar
 import com.poteviohealth.cgp.common.integrated.customer.model.CustomerSubsidyDTO;
 import com.poteviohealth.cgp.common.integrated.customer.model.SubsidyCustomerFace;
 import com.poteviohealth.cgp.common.integrated.customer.model.SubsidyCustomerJsonFace;
-import com.poteviohealth.cgp.common.integrated.finance.model.MemberListData;
-import com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanDTO;
-import com.poteviohealth.cgp.common.integrated.finance.model.MemberPlanPageDTO;
-import com.poteviohealth.cgp.common.integrated.finance.model.MonthData;
+import com.poteviohealth.cgp.common.integrated.finance.model.*;
 import com.poteviohealth.cgp.common.integrated.order.model.OrderStatisticsData;
 import com.poteviohealth.cgp.common.integrated.order.model.PayAccount;
 import com.poteviohealth.cgp.common.integrated.partner.model.AreaDTO;
@@ -26,10 +23,7 @@ import com.poteviohealth.cgp.statistics.constant.enums.OrderConstantEnum;
 import com.poteviohealth.cgp.statistics.mapper.OrderMapper;
 import com.poteviohealth.cgp.statistics.model.Order;
 import com.poteviohealth.cgp.statistics.model.WatermarkImg;
-import com.poteviohealth.cgp.statistics.model.indto.DishesOrderWebInDTO;
-import com.poteviohealth.cgp.statistics.model.indto.OrderCostWebInDTO;
-import com.poteviohealth.cgp.statistics.model.indto.OrderServiceWebInDTO;
-import com.poteviohealth.cgp.statistics.model.indto.OrderWebInDTO;
+import com.poteviohealth.cgp.statistics.model.indto.*;
 import com.poteviohealth.cgp.statistics.model.outdto.*;
 import com.poteviohealth.cgp.statistics.service.IOrderService;
 import lombok.extern.log4j.Log4j2;
@@ -389,13 +383,13 @@ public class OrderServiceImpl extends BaseServiceImpl<OrderMapper, Order> implem
             String val = "";
             for (String s : dto.getPayAccountStr().split(",")) {
                 if("1".equals(s)){
-                    val+="助餐账户,";
+                    val+="补贴,";
                 }else if("2".equals(s)){
-                    val+="积分账户,";
+                    val+="积分,";
                 }else if("3".equals(s)){
-                    val+="储值账户,";
+                    val+="账户,";
                 }else if("4".equals(s)){
-                    val+="现金支付,";
+                    val+="现金,";
                 }
             }
             if(val != ""){
@@ -423,6 +417,28 @@ public class OrderServiceImpl extends BaseServiceImpl<OrderMapper, Order> implem
         return list;*/
     }
 
+    @Override
+    public List<CardAccTransRecharge> transRechargeExcel(CardWebInDTO dto) {
+
+        QueryWrapper queryWrapper = new QueryWrapper();
+        queryWrapper.eq("d.card_id",dto.getTypeId());
+        queryWrapper.eq("d.operator_id", TokenContext.cureOperatorId());
+        queryWrapper.in(!dto.getSupplierIds().isEmpty(),"d.supplier_id", dto.getSupplierIds());
+        int count = baseMapper.transRechargeExcelListAllSize(queryWrapper,dto,dbName);
+        //每页1000条,计算总页数
+        int maxPage = (int) Math.ceil(count/10000.0);
+
+        int start = 0;
+        LinkedList<CardAccTransRecharge> list = Lists.newLinkedList();
+        for (int i = 0; i < maxPage; i++) {
+            LinkedList<CardAccTransRecharge> findList = baseMapper.transRechargeExcel(queryWrapper,dto,dbName,start);
+            start = findList.getLast().getId();
+            list.addAll(findList);
+        }
+
+        return list;
+    }
+
     @Override
     public List<OrderCostWebOutDTO> OrderCostList(OrderCostWebInDTO orderCostWebInDTO) {
         Integer operatorId = TokenContext.cureOperatorId();
@@ -571,6 +587,21 @@ public class OrderServiceImpl extends BaseServiceImpl<OrderMapper, Order> implem
         if (!org.springframework.util.CollectionUtils.isEmpty(orderWebInDTO.getStationIds())) {
             orderQueryWrapper.in("o.service_station_id", orderWebInDTO.getStationIds());
         }
+        if (StringUtils.isNotBlank(orderWebInDTO.getIdCard())) {
+            orderQueryWrapper.like( "id_card", orderWebInDTO.getIdCard());
+        }
+        if (orderWebInDTO.getSourceId() != null) {
+            orderQueryWrapper.eq("source_id", orderWebInDTO.getSourceId());
+        }
+        if (orderWebInDTO.getEatIn() != null) {
+            orderQueryWrapper.eq("eat_in", orderWebInDTO.getEatIn());
+        }
+        if (orderWebInDTO.getDistrictid() >0) {
+            orderQueryWrapper.eq("country", orderWebInDTO.getDistrictid());
+        }
+        if (orderWebInDTO.getStreetid() >0) {
+            orderQueryWrapper.eq("street", orderWebInDTO.getStreetid());
+        }
         orderQueryWrapper.eq("o.pay_status",3);
         //orderQueryWrapper.orderByDesc("o.id");
         return orderQueryWrapper;

BIN
src/main/resources/excel/order_dishes.xlsx


BIN
src/main/resources/excel/pageCard.xlsx


BIN
src/main/resources/excel/trans_recharge.xlsx


+ 74 - 1
src/main/resources/mapper/statistics/OrderMapper.xml

@@ -324,6 +324,7 @@
             sn,
             customer_phone,
             product_string,
+            id_card as idCard,
             DATE_FORMAT(order_time,'%Y-%m-%d %H:%i') AS orderTime,
             TRUNCATE ( sum_price/ 100.0, 2 ) AS sumPrice,
             TRUNCATE ( card_price/ 100.0, 2 ) AS cardPrice,
@@ -332,7 +333,11 @@
             fund_price,
             '已支付' as payStatusStr,
             pay_account as payAccountStr,
-            service_station_name
+            service_station_name,
+            street_name as streetName,
+            country_name as countryName,
+            case when source_id = 1 then '刷脸' when source_id = 2 then '手机号' else '' end as sourceStr,
+            case when eat_in = 0 then '否' when eat_in = 1 then '是' else '' end as eatInStr
         FROM
             ${dbName}_order.o_dishes_order_${operatorId} o
         WHERE o.yn = 0
@@ -392,6 +397,7 @@
         select count(*) from (
         select count(d.id)
         from ${dbName}_finance.c_card_acc_detail d
+        <if test="queryParam.stationIds.size()>0">
         left join (SELECT d.id,
         SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
         FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN t_number b ON b.id &lt;(
@@ -399,6 +405,7 @@
         )
         where d.yn = 0 and d.type = 1 and d.station_ids != '' and  ${ew.sqlSegment}  ) a
         on d.id = a.id
+        </if>
         where d.yn = 0 and d.type = 1 and d.station_ids != ''
         <if test="queryParam.stationIds.size()>0">
             and a.stationId in
@@ -413,6 +420,7 @@
         select d.id,d.name,d.phone,d.id_number,d.category_name,d.type_name,d.customer_address,d.customer_type_name,
         case when d.enable =1 then '启用' else '停用' end as enabled,TRUNCATE(d.balance/100,2) as balance
         from ${dbName}_finance.c_card_acc_detail d
+        <if test="queryParam.stationIds.size()>0">
         left join (SELECT d.id,
         SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
         FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN t_number b ON b.id &lt;(
@@ -420,6 +428,7 @@
         )
         where d.yn = 0 and d.type = 1 and d.station_ids != '' and  ${ew.sqlSegment}  ) a
         on d.id = a.id
+        </if>
         where d.yn = 0 and d.type = 1 and d.station_ids != ''
         and d.id > #{start}
         <if test="queryParam.stationIds.size()>0">
@@ -433,4 +442,68 @@
         order by d.id
         limit 10000
     </select>
+
+    <select id="transRechargeExcelListAllSize" resultType="int">
+        select count(*)
+        from ${dbName}_finance.c_card_acc_detail d
+        <if test="queryParam.stationIds.size()>0">
+            left join (SELECT d.id,
+            SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
+            FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN ${dbName}_finance.t_number b ON b.id &lt;(
+            LENGTH( d.station_ids ) - LENGTH( REPLACE(d.station_ids,',','') )  +  1
+            )
+            where d.yn = 0 and d.type = 1 and d.station_ids != '' and  ${ew.sqlSegment}  ) a
+            on d.id = a.id
+        </if>
+        left join ${dbName}_finance.c_card_acc_trans t on t.detail_id = d.id
+        where d.yn = 0 and t.yn = 0 and d.type = 1
+        and t.trans_type = 0
+        <if test="queryParam.startDate != null">
+            and t.build_time between #{queryParam.startDate} and #{queryParam.endDate}
+        </if>
+        and d.station_ids != ''
+        <if test="queryParam.stationIds.size()>0">
+            and a.stationId in
+            <foreach collection="queryParam.stationIds" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        and  ${ew.sqlSegment}
+    </select>
+
+    <select id="transRechargeExcel"
+            resultType="com.poteviohealth.cgp.common.integrated.finance.model.CardAccTransRecharge">
+        select t.id, t.build_time,
+        d.name,
+        d.id_number,
+        TRUNCATE(t.amount/100,2) as amount,
+        d.type_name
+        from ${dbName}_finance.c_card_acc_detail d
+        <if test="queryParam.stationIds.size()>0">
+            left join (SELECT d.id,
+            SUBSTRING_INDEX( SUBSTRING_INDEX( d.station_ids, ',', b.id + 1 ), ',', -1 ) AS stationId
+            FROM ${dbName}_finance.c_card_acc_detail d INNER JOIN ${dbName}_finance.t_number b ON b.id &lt;(
+            LENGTH( d.station_ids ) - LENGTH( REPLACE(d.station_ids,',','') )  +  1
+            )
+            where d.yn = 0 and d.type = 1 and d.station_ids != '' and  ${ew.sqlSegment}  ) a
+            on d.id = a.id
+        </if>
+        left join ${dbName}_finance.c_card_acc_trans t on t.detail_id = d.id
+        where d.yn = 0 and t.yn = 0 and d.type = 1
+        and t.trans_type = 0
+        and t.id > #{start}
+        <if test="queryParam.startDate != null">
+            and t.build_time between #{queryParam.startDate} and #{queryParam.endDate}
+        </if>
+        and d.station_ids != ''
+        <if test="queryParam.stationIds.size()>0">
+            and a.stationId in
+            <foreach collection="queryParam.stationIds" item="item" separator="," open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        and  ${ew.sqlSegment}
+        order by t.id
+        limit 10000
+    </select>
 </mapper>