夏文涛 1 год назад
Родитель
Сommit
cf4bf300a6
42 измененных файлов с 2052 добавлено и 129 удалено
  1. 30 1
      pom.xml
  2. 230 0
      src/main/java/com/sqx/common/utils/SftpUtil.java
  3. 26 0
      src/main/java/com/sqx/config/MinioClientConfig.java
  4. 38 0
      src/main/java/com/sqx/config/MinioConfig.java
  5. 11 5
      src/main/java/com/sqx/datasource/config/DynamicDataSourceConfig.java
  6. 15 15
      src/main/java/com/sqx/datasource/properties/DynamicDataSourceProperties.java
  7. 17 3
      src/main/java/com/sqx/modules/app/dao/UserMoneyDetailsDao.java
  8. 56 0
      src/main/java/com/sqx/modules/app/entity/UserMoneyDetails.java
  9. 25 0
      src/main/java/com/sqx/modules/app/service/UserMoneyDetailsService.java
  10. 77 6
      src/main/java/com/sqx/modules/app/service/impl/UserMoneyDetailsServiceImpl.java
  11. 4 2
      src/main/java/com/sqx/modules/datacentre/controller/DataCentreController.java
  12. 5 2
      src/main/java/com/sqx/modules/datacentre/dao/DataCentreDao.java
  13. 22 0
      src/main/java/com/sqx/modules/datacentre/query/DataCenterQuery.java
  14. 43 0
      src/main/java/com/sqx/modules/datacentre/query/ShopCenterQuery.java
  15. 6 1
      src/main/java/com/sqx/modules/datacentre/service/DataCentreService.java
  16. 39 9
      src/main/java/com/sqx/modules/datacentre/service/impl/DataCentreServiceImpl.java
  17. 271 0
      src/main/java/com/sqx/modules/exportExecl/controller/ExportExeclController.java
  18. 18 0
      src/main/java/com/sqx/modules/exportExecl/mapper/ExportJobMapper.java
  19. 66 0
      src/main/java/com/sqx/modules/exportExecl/model/ExportJob.java
  20. 118 0
      src/main/java/com/sqx/modules/exportExecl/model/ExportOrderVo.java
  21. 16 0
      src/main/java/com/sqx/modules/exportExecl/service/ExportJobService.java
  22. 20 0
      src/main/java/com/sqx/modules/exportExecl/service/impl/ExportJobServiceImpl.java
  23. 34 11
      src/main/java/com/sqx/modules/file/AliFileUploadController.java
  24. 1 0
      src/main/java/com/sqx/modules/goods/controller/GoodsShopController.java
  25. 2 0
      src/main/java/com/sqx/modules/goods/service/impl/GoodsShopServiceImpl.java
  26. 11 0
      src/main/java/com/sqx/modules/order/controller/OrderController.java
  27. 10 3
      src/main/java/com/sqx/modules/order/dao/AppOrderDao.java
  28. 16 0
      src/main/java/com/sqx/modules/order/entity/TbOrder.java
  29. 1 1
      src/main/java/com/sqx/modules/order/service/AppOrderService.java
  30. 25 22
      src/main/java/com/sqx/modules/order/service/impl/AppAppOrderServiceImpl.java
  31. 47 0
      src/main/java/com/sqx/modules/pay/controller/query/CashOutQueryDTO.java
  32. 35 2
      src/main/java/com/sqx/modules/pay/controller/query/WalletDetailQuery.java
  33. 1 1
      src/main/java/com/sqx/modules/pay/vo/WalletDetailVO.java
  34. 7 0
      src/main/java/com/sqx/modules/shop/controller/app/ShopMoneyController.java
  35. 32 2
      src/main/java/com/sqx/modules/utils/excel/ExportExcelUtils.java
  36. 5 0
      src/main/java/com/sqx/scheduler/config/SchedulerLock.java
  37. 279 0
      src/main/java/com/sqx/scheduler/export/ExportScheduler.java
  38. 46 0
      src/main/resources/application-dev.yml
  39. 46 0
      src/main/resources/application-prod.yml
  40. 52 13
      src/main/resources/mapper/dataCentre/dataCenterMapper.xml
  41. 59 2
      src/main/resources/mapper/order/OrderMapper.xml
  42. 190 28
      src/main/resources/mapper/userMoney/UserMoneyDetailsMapper.xml

+ 30 - 1
pom.xml

@@ -41,7 +41,7 @@
         <fastjson.version>1.2.83</fastjson.version>
         <hutool.version>4.1.1</hutool.version>
         <lombok.version>1.18.4</lombok.version>
-
+        <okhttp3.version>4.11.0</okhttp3.version>
 
         <!--wagon plugin 配置-->
         <!--<service-path>/work/sz</service-path>
@@ -416,13 +416,42 @@
             <version>2.1.6</version>
         </dependency>
 
+        <!-- excel操作 -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>3.1.1</version>
+            <scope>compile</scope>
+        </dependency>
+        <dependency>
+            <groupId>com.jcraft</groupId>
+            <artifactId>jsch</artifactId>
+            <version>0.1.54</version>
+        </dependency>
+
         <!--<dependency>-->
         <!--<groupId>com.baidu.aip</groupId>-->
         <!--            <artifactId>java-sdk</artifactId>-->
         <!--            <version>4.11.3</version>-->
         <!--</dependency>-->
+        <!-- minio -->
+        <dependency>
+            <groupId>io.minio</groupId>
+            <artifactId>minio</artifactId>
+            <version>8.5.9</version>
+        </dependency>
     </dependencies>
 
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>com.squareup.okhttp3</groupId>
+                <artifactId>okhttp</artifactId>
+                <version>${okhttp3.version}</version>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
     <build>
         <finalName>${project.artifactId}</finalName>
         <extensions>

+ 230 - 0
src/main/java/com/sqx/common/utils/SftpUtil.java

@@ -0,0 +1,230 @@
+package com.sqx.common.utils;
+
+import org.apache.commons.io.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import com.jcraft.jsch.*;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import java.io.*;
+import java.util.Properties;
+
+/**
+ * 类说明 sftp工具类
+ */
+@Component
+public class SftpUtil {
+    private transient Logger log = LoggerFactory.getLogger(this.getClass());
+
+    private ChannelSftp sftp;
+
+    private Session session;
+    /** SFTP 登录用户名*/
+    @Value("${sftp.username}")
+    private String username;
+    /** SFTP 登录密码*/
+    @Value("${sftp.password}")
+    private String password;
+    /** 私钥 */
+    private String privateKey;
+    /** SFTP 服务器地址IP地址*/
+    @Value("${sftp.host}")
+    private String host;
+    /** SFTP 端口*/
+    @Value("${sftp.port}")
+    private int port;
+
+
+    /**
+     * 构造基于密码认证的sftp对象
+     */
+    public SftpUtil(String username, String password, String host, int port) {
+        this.username = username;
+        this.password = password;
+        this.host = host;
+        this.port = port;
+    }
+
+    /**
+     * 构造基于秘钥认证的sftp对象
+     */
+    public SftpUtil(String username, String host, int port, String privateKey) {
+        this.username = username;
+        this.host = host;
+        this.port = port;
+        this.privateKey = privateKey;
+    }
+
+    public SftpUtil(){}
+
+
+    /**
+     * 连接sftp服务器
+     */
+    public void login(){
+        try {
+            JSch jsch = new JSch();
+            if (privateKey != null) {
+                jsch.addIdentity(privateKey);// 设置私钥
+            }
+
+            session = jsch.getSession(username, host, port);
+
+            if (password != null) {
+                session.setPassword(password);
+            }
+            Properties config = new Properties();
+            config.put("StrictHostKeyChecking", "no");
+
+            session.setConfig(config);
+            session.connect();
+
+            Channel channel = session.openChannel("sftp");
+            channel.connect();
+
+            sftp = (ChannelSftp) channel;
+        } catch (JSchException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 关闭连接 server
+     */
+    public void logout(){
+        try{
+            if (sftp != null) {
+                if (sftp.isConnected()) {
+                    sftp.disconnect();
+                }
+            }
+            if (session != null) {
+                if (session.isConnected()) {
+                    session.disconnect();
+                }
+            }
+        }catch (Exception e){
+            log.error("sftp登出失败", e);
+        }
+    }
+
+
+    /**
+     * 将输入流的数据上传到sftp作为文件。文件完整路径=basePath+directory
+     * @param directory  上传到该目录
+     * @param sftpFileName  sftp端文件名
+     * @param input   输入流
+     */
+    public void upload(String directory, String sftpFileName, InputStream input) throws SftpException{
+        try {
+            String home = sftp.getHome();
+            sftp.cd(home);
+            //sftp.cd(basePath);
+            sftp.cd(directory);
+        } catch (SftpException e) {
+            //目录不存在,则创建文件夹
+            String [] dirs=directory.split("/");
+            String tempPath=sftp.getHome();
+            for(String dir:dirs){
+                if(null== dir || "".equals(dir)) continue;
+                tempPath+="/"+dir;
+                try{
+                    sftp.cd(tempPath);
+                }catch(SftpException ex){
+                    sftp.mkdir(tempPath);
+                    sftp.cd(tempPath);
+                }
+            }
+        }
+        sftp.put(input, sftpFileName);  //上传文件
+    }
+
+
+    /**
+     * 下载文件。
+     * @param directory 下载目录
+     * @param downloadFile 下载的文件
+     * @param saveFile 存在本地的路径
+     */
+    public void download(String directory, String downloadFile, File saveFile) throws SftpException, FileNotFoundException{
+        String home = sftp.getHome();
+        sftp.cd(home);
+        if (directory != null && !"".equals(directory)) {
+            sftp.cd(directory);
+        }
+        sftp.get(downloadFile, new FileOutputStream(saveFile));
+    }
+    /**
+     * 下载文件。
+     * @param directory 下载目录
+     * @param downloadFile 下载的文件
+     * @param outputStream 输出流
+     */
+    public void downloadStream(String directory, String downloadFile,OutputStream outputStream) throws SftpException, FileNotFoundException{
+        String home = sftp.getHome();
+        sftp.cd(home);
+        if (directory != null && !"".equals(directory)) {
+            sftp.cd(directory);
+        }
+        sftp.get(downloadFile,outputStream);
+    }
+
+    /**
+     * 下载文件
+     * @param directory 下载目录
+     * @param downloadFile 下载的文件名
+     * @return 字节数组
+     */
+    public byte[] download(String directory, String downloadFile) throws SftpException, IOException{
+        if (directory != null && !"".equals(directory)) {
+            sftp.cd(directory);
+        }
+        InputStream is = sftp.get(downloadFile);
+
+        byte[] fileData = IOUtils.toByteArray(is);
+
+        return fileData;
+    }
+
+
+    /**
+     * 删除文件
+     * @param directory 要删除文件所在目录
+     * @param deleteFile 要删除的文件
+     */
+    public void delete(String directory, String deleteFile) throws SftpException{
+        sftp.cd(directory);
+        sftp.rm(deleteFile);
+    }
+
+    public ChannelSftp getSftp() {
+        return sftp;
+    }
+
+    public boolean isConnected(){
+        return sftp.isConnected();
+    }
+
+    public boolean mkdir(String dir){
+        try{
+            sftp.mkdir(dir);
+            return true;
+        }catch (Exception e){
+            log.error("目录创建失败: ", e);
+            return false;
+        }
+    }
+
+    //上传文件测试
+    public static void main(String[] args) throws SftpException, IOException {
+        SftpUtil sftp = new SftpUtil("export", "Waimai2024#", "172.16.20.108", 22);
+        sftp.login();
+        File file = new File("E:\\chen\\Desktop\\fsdownload\\text.log");
+        InputStream is = new FileInputStream(file);
+
+        sftp.upload("/", "text.log", is);
+        sftp.download("/","test_sftp.jpg",file);
+        sftp.logout();
+    }
+}

+ 26 - 0
src/main/java/com/sqx/config/MinioClientConfig.java

@@ -0,0 +1,26 @@
+package com.sqx.config;
+
+import io.minio.MinioClient;
+import lombok.RequiredArgsConstructor;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * minio客户端自动注入
+ *
+ * @author : codingliang
+ * @date : 2024-09-29 18:35
+ */
+@Configuration
+@RequiredArgsConstructor
+public class MinioClientConfig {
+    private final MinioConfig minioConfig;
+
+    @Bean
+    public MinioClient minioClient() {
+        return MinioClient.builder()
+                .endpoint(minioConfig.getEndpoint())
+                .credentials(minioConfig.getAccessKey(), minioConfig.getSecretKey())
+                .build();
+    }
+}

+ 38 - 0
src/main/java/com/sqx/config/MinioConfig.java

@@ -0,0 +1,38 @@
+package com.sqx.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.stereotype.Component;
+
+/**
+ * minio配置
+ *
+ * @author : codingliang
+ * @date : 2024-09-29 18:32
+ */
+@Data
+@Component
+@ConfigurationProperties(prefix = "minio")
+public class MinioConfig {
+
+    /**
+     * endpoint
+     */
+    private String endpoint;
+
+    /**
+     * key
+     */
+    private String accessKey;
+
+    /**
+     * secret
+     */
+    private String secretKey;
+
+    /**
+     * bucket名称
+     */
+    private String bucket;
+
+}

+ 11 - 5
src/main/java/com/sqx/datasource/config/DynamicDataSourceConfig.java

@@ -2,7 +2,7 @@ package com.sqx.datasource.config;
 
 import com.alibaba.druid.pool.DruidDataSource;
 import com.sqx.datasource.properties.DataSourceProperties;
-import com.sqx.datasource.properties.DynamicDataSourceProperties;
+//import com.sqx.datasource.properties.DynamicDataSourceProperties;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.boot.context.properties.EnableConfigurationProperties;
@@ -16,16 +16,21 @@ import java.util.Map;
  * 配置多数据源
  */
 @Configuration
-@EnableConfigurationProperties(DynamicDataSourceProperties.class)
+//@EnableConfigurationProperties(DynamicDataSourceProperties.class)
 public class DynamicDataSourceConfig {
-    @Autowired
-    private DynamicDataSourceProperties properties;
+//    @Autowired
+//    private DynamicDataSourceProperties properties;
 
     @Bean
     @ConfigurationProperties(prefix = "spring.datasource.druid")
     public DataSourceProperties dataSourceProperties() {
         return new DataSourceProperties();
     }
+    @Bean
+    @ConfigurationProperties(prefix = "dynamic")
+    public DataSourceProperties getDatasource() {
+        return new DataSourceProperties();
+    }
 
     @Bean
     public DynamicDataSource dynamicDataSource(DataSourceProperties dataSourceProperties) {
@@ -40,7 +45,8 @@ public class DynamicDataSourceConfig {
     }
 
     private Map<Object, Object> getDynamicDataSource(){
-        Map<String, DataSourceProperties> dataSourcePropertiesMap = properties.getDatasource();
+        Map<String, DataSourceProperties> dataSourcePropertiesMap = new HashMap<>();
+        dataSourcePropertiesMap.put("dynamic",this.getDatasource());
         Map<Object, Object> targetDataSources = new HashMap<>(dataSourcePropertiesMap.size());
         dataSourcePropertiesMap.forEach((k, v) -> {
             DruidDataSource druidDataSource = DynamicDataSourceFactory.buildDruidDataSource(v);

+ 15 - 15
src/main/java/com/sqx/datasource/properties/DynamicDataSourceProperties.java

@@ -5,18 +5,18 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
-/**
- * 多数据源属性
- */
-@ConfigurationProperties(prefix = "dynamic")
-public class DynamicDataSourceProperties {
-    private Map<String, DataSourceProperties> datasource = new LinkedHashMap<>();
-
-    public Map<String, DataSourceProperties> getDatasource() {
-        return datasource;
-    }
-
-    public void setDatasource(Map<String, DataSourceProperties> datasource) {
-        this.datasource = datasource;
-    }
-}
+///**
+// * 多数据源属性
+// */
+//@ConfigurationProperties(prefix = "dynamic")
+//public class DynamicDataSourceProperties {
+//    private Map<String, DataSourceProperties> datasource = new LinkedHashMap<>();
+//
+//    public Map<String, DataSourceProperties> getDatasource() {
+//        return datasource;
+//    }
+//
+//    public void setDatasource(Map<String, DataSourceProperties> datasource) {
+//        this.datasource = datasource;
+//    }
+//}

+ 17 - 3
src/main/java/com/sqx/modules/app/dao/UserMoneyDetailsDao.java

@@ -3,24 +3,27 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.sqx.modules.app.entity.UserMoneyDetails;
+import com.sqx.modules.pay.controller.query.CashOutQueryDTO;
 import com.sqx.modules.pay.controller.query.WalletDetailQuery;
+import com.sqx.modules.pay.vo.CashOutVO;
 import com.sqx.modules.pay.vo.WalletDetailVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 @Mapper
 public interface UserMoneyDetailsDao extends BaseMapper<UserMoneyDetails> {
 
-    Double monthIncome(@Param("date") String date,@Param("userId") Long userId);
+    Double monthIncome(@Param("date") String date, @Param("userId") Long userId);
 
     Double selectMyProfit(Long userId);
 
-    IPage<UserMoneyDetails> selectUserMoneyDetails(Page<UserMoneyDetails> pages,@Param("userId") Long userId, @Param("classify") Integer classify);
+    IPage<UserMoneyDetails> selectUserMoneyDetails(Page<UserMoneyDetails> pages, @Param("userId") Long userId, @Param("classify") Integer classify);
 
     IPage<UserMoneyDetails> selectPwCashDetails(Page<UserMoneyDetails> pages, @Param("userName") String userName, @Param("date") String date,
-                                                @Param("dateType") String dateType,@Param("zhifubao") String zhifubao, @Param("zhifubaoName") String zhifubaoName,
+                                                @Param("dateType") String dateType, @Param("zhifubao") String zhifubao, @Param("zhifubaoName") String zhifubaoName,
                                                 @Param("userId") Long userId);
 
     IPage<UserMoneyDetails> selectShopCashDeposit(Page<UserMoneyDetails> pages, Long shopId, Integer classify);
@@ -30,4 +33,15 @@ public interface UserMoneyDetailsDao extends BaseMapper<UserMoneyDetails> {
     IPage<WalletDetailVO> walletDetailList(@Param("page") Page<UserMoneyDetails> pages, @Param("query") WalletDetailQuery query);
 
     BigDecimal walletDetailStatistics(@Param("query") WalletDetailQuery query);
+
+    List<WalletDetailVO> excelWalletDetails(@Param("query") WalletDetailQuery query);
+
+    List<UserMoneyDetails> accountEntryManagementDetailsList(@Param("row") Integer row, @Param("limit") Integer limit, @Param("shopName") String shopName, @Param("shopPhone") String shopPhone,
+                                                             @Param("userPhone") String userPhone, @Param("couponName") String couponName,
+                                                             @Param("orderNumber") String orderNumber, @Param("startTime") String startTime, @Param("endTime") String endTime);
+
+    int accountEntryManagementDetailsCount(@Param("shopName") String shopName, @Param("shopPhone") String shopPhone,
+                                           @Param("userPhone") String userPhone, @Param("couponName") String couponName,
+                                           @Param("orderNumber") String orderNumber, @Param("startTime") String startTime, @Param("endTime") String endTime);
+
 }

+ 56 - 0
src/main/java/com/sqx/modules/app/entity/UserMoneyDetails.java

@@ -78,5 +78,61 @@ public class UserMoneyDetails implements Serializable {
     @TableField(exist = false)
     private String userName;
 
+    /**
+     * 店铺名称
+     */
+    @TableField(exist = false)
+    private String shopName;
+
+    /**
+     * 店铺手机号
+     */
+    @TableField(exist = false)
+    private String shopPhone;
+
+    /**
+     * 下单手机号
+     */
+    @TableField(exist = false)
+    private String userPhone;
+
+    /**
+     * 优惠活动名称
+     */
+    @TableField(exist = false)
+    private String couponName;
+
+    /**
+     * 活动优惠金额
+     */
+    @TableField(exist = false)
+    private BigDecimal activityDiscountAmount;
 
+
+    /**
+     * 优惠券优惠金额
+     */
+    @TableField(exist = false)
+    private BigDecimal couponMoney;
+
+    /**
+     * 跑腿费
+     */
+    @TableField(exist = false)
+    private BigDecimal errandMoney;
+
+    /**
+     * 订单号
+     */
+    @TableField(exist = false)
+    private BigDecimal orderNumber;
+
+    /**
+     * 订单id
+     */
+    /**
+     * 订单号
+     */
+    @TableField(exist = false)
+    private BigDecimal orderId;
 }

+ 25 - 0
src/main/java/com/sqx/modules/app/service/UserMoneyDetailsService.java

@@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.sqx.common.utils.PageUtils;
 import com.sqx.common.utils.Result;
 import com.sqx.modules.app.entity.UserMoneyDetails;
+import com.sqx.modules.pay.controller.query.CashOutQueryDTO;
 import com.sqx.modules.pay.controller.query.WalletDetailQuery;
+import com.sqx.modules.utils.excel.ExcelData;
 
 import java.math.BigDecimal;
 
@@ -29,4 +31,27 @@ public interface UserMoneyDetailsService extends IService<UserMoneyDetails> {
      * @return
      */
     BigDecimal walletDetailStatistics(WalletDetailQuery query);
+
+    /**
+     * 钱包明细导出
+     * @param query
+     * @return
+     */
+    ExcelData excelWalletDetails(WalletDetailQuery query);
+
+    /**
+     * 入账管理
+     * @param page
+     * @param limit
+     * @param shopName
+     * @param shopPhone
+     * @param userPhone
+     * @param couponName
+     * @param orderNumber
+     * @param startTime
+     * @param endTime
+     * @return
+     */
+    PageUtils accountEntryManagementDetails(Integer page, Integer limit, String shopName, String shopPhone, String userPhone, String couponName, String orderNumber, String startTime, String endTime);
+
 }

+ 77 - 6
src/main/java/com/sqx/modules/app/service/impl/UserMoneyDetailsServiceImpl.java

@@ -9,24 +9,33 @@ import com.sqx.common.utils.Result;
 import com.sqx.modules.app.dao.UserMoneyDetailsDao;
 import com.sqx.modules.app.entity.UserMoneyDetails;
 import com.sqx.modules.app.service.UserMoneyDetailsService;
+import com.sqx.modules.pay.controller.query.CashOutQueryDTO;
 import com.sqx.modules.pay.controller.query.WalletDetailQuery;
+import com.sqx.modules.pay.vo.CashOutVO;
 import com.sqx.modules.pay.vo.WalletDetailVO;
+import org.checkerframework.checker.units.qual.A;
+import org.springframework.beans.factory.annotation.Autowired;
+import com.sqx.modules.utils.excel.ExcelData;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
 
 @Service
 public class UserMoneyDetailsServiceImpl extends ServiceImpl<UserMoneyDetailsDao, UserMoneyDetails> implements UserMoneyDetailsService {
 
     @Override
-    public Result queryUserMoneyDetails(Integer page, Integer limit, Long userId,Integer classify,Integer type) {
+    public Result queryUserMoneyDetails(Integer page, Integer limit, Long userId, Integer classify, Integer type) {
         IPage<UserMoneyDetails> page1 = new Page(page, limit);
         QueryWrapper<UserMoneyDetails> queryWrapper = new QueryWrapper();
         queryWrapper.eq("user_id", userId);
-        if(classify!=null){
+        if (classify != null) {
             queryWrapper.eq("classify", classify);
         }
-        if(type!=null){
+        if (type != null) {
             queryWrapper.eq("type", type);
         }
         queryWrapper.eq("state", 2);
@@ -36,7 +45,7 @@ public class UserMoneyDetailsServiceImpl extends ServiceImpl<UserMoneyDetailsDao
 
     @Override
     public Double monthIncome(String date, Long userId) {
-        return baseMapper.monthIncome(date,userId);
+        return baseMapper.monthIncome(date, userId);
     }
 
     @Override
@@ -44,10 +53,10 @@ public class UserMoneyDetailsServiceImpl extends ServiceImpl<UserMoneyDetailsDao
         IPage<UserMoneyDetails> page1 = new Page(page, limit);
         QueryWrapper<UserMoneyDetails> queryWrapper = new QueryWrapper();
         queryWrapper.eq("shop_id", shopId);
-        if(classify!=null){
+        if (classify != null) {
             queryWrapper.eq("classify", classify);
         }
-        if(type!=null){
+        if (type != null) {
             queryWrapper.eq("type", type);
         }
         queryWrapper.eq("state", 2);
@@ -77,4 +86,66 @@ public class UserMoneyDetailsServiceImpl extends ServiceImpl<UserMoneyDetailsDao
         BigDecimal result = baseMapper.walletDetailStatistics(query);
         return result;
     }
+
+    @Override
+    public ExcelData excelWalletDetails(WalletDetailQuery query) {
+        List<WalletDetailVO> walletDetailVOS = baseMapper.excelWalletDetails(query);
+        ExcelData data = new ExcelData();
+        data.setName("保证金记录");
+        data.setTitles(WalletDetailExportTitle());
+        List<List<Object>> rows = new ArrayList<>();
+        for (WalletDetailVO walletDetailVO:walletDetailVOS ){
+            List<Object> row = new ArrayList<>();
+            row.add(walletDetailVO.getId());
+            row.add(walletDetailVO.getShopName());
+            row.add(walletDetailVO.getContent());
+            if ("1".equals(walletDetailVO.getType())){
+                row.add("充值");
+            }else if("2".equals(walletDetailVO.getType())){
+                row.add("提现");
+            }else{
+                row.add("");
+            }
+            row.add(walletDetailVO.getCreateTime());
+            row.add(walletDetailVO.getMoney());
+            rows.add(row);
+        }
+        data.setRows(rows);
+        return data;
+    }
+
+    private List<String> WalletDetailExportTitle() {
+        return Arrays.asList(
+                "编号",
+                "店铺名称",
+                "保证金金额",
+                "类别",
+                "提现时间",
+                "金额");
+    }
+
+
+    @Override
+    public PageUtils accountEntryManagementDetails(Integer page, Integer limit, String shopName, String shopPhone, String userPhone, String couponName, String orderNumber, String startTime, String endTime) {
+        IPage<UserMoneyDetails> iPage = new Page<>();
+        Integer row=(page-1)*limit;
+        List<UserMoneyDetails> userMoneyDetailsList = baseMapper.accountEntryManagementDetailsList(row,limit, shopName, shopPhone, userPhone, couponName, orderNumber, startTime, endTime);
+        int total = baseMapper.accountEntryManagementDetailsCount(shopName, shopPhone, userPhone, couponName, orderNumber, startTime, endTime);
+
+//        当前页数
+        iPage.setCurrent(page);
+//        每页显示数
+        iPage.setSize(limit);
+//        数据
+        iPage.setRecords(userMoneyDetailsList);
+//        总页数
+
+        iPage.setPages((int)Math.ceil((double)total/limit));
+//        总数
+        iPage.setTotal(total);
+        PageUtils pageUtils = new PageUtils(iPage);
+        List<?> list = pageUtils.getList();
+        System.out.println("list = " + list);
+        return pageUtils;
+    }
 }

+ 4 - 2
src/main/java/com/sqx/modules/datacentre/controller/DataCentreController.java

@@ -7,6 +7,7 @@ import com.sqx.modules.app.service.UserMoneyService;
 import com.sqx.modules.coupon.entity.TbCouponUser;
 import com.sqx.modules.coupon.service.TbCouponService;
 import com.sqx.modules.coupon.service.TbCouponUserService;
+import com.sqx.modules.datacentre.query.ShopCenterQuery;
 import com.sqx.modules.datacentre.service.DataCentreService;
 import com.sqx.modules.errand.service.ErrandComplaintService;
 import com.sqx.modules.integral.dao.UserIntegralDetailsDao;
@@ -17,6 +18,7 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import javax.validation.Valid;
 import java.math.BigDecimal;
 
 @RestController
@@ -172,9 +174,9 @@ public class DataCentreController {
 
     @ApiOperation("门店统计")
     @GetMapping(value = "selectShopCenter")
-    public Result selectShopCenter(String date, String dateType, Integer page, Integer limit) {
+    public Result selectShopCenter(@Valid ShopCenterQuery query) {
 
-        return dataCentreService.selectShopCenter(date, dateType, page, limit);
+        return dataCentreService.selectShopCenter(query);
     }
 
     @ApiOperation("用户统计")

+ 5 - 2
src/main/java/com/sqx/modules/datacentre/dao/DataCentreDao.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.sqx.modules.app.entity.UserEntity;
 import com.sqx.modules.app.entity.UserMoneyDetails;
+import com.sqx.modules.datacentre.query.ShopCenterQuery;
 import com.sqx.modules.errand.entity.Feedback;
 import com.sqx.modules.errand.entity.TbIndent;
 import com.sqx.modules.order.entity.TbOrder;
@@ -13,6 +14,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.math.BigDecimal;
+import java.util.List;
 
 @Mapper
 public interface DataCentreDao {
@@ -49,9 +51,9 @@ public interface DataCentreDao {
 
     IPage<TbIndent> rankingList(Page<TbIndent> pages, String address, String date, String dateType);
 
-    int selectNewShopCount(String date, String dateType);
+    int selectNewShopCount(@Param("query")ShopCenterQuery query);
 
-    IPage<TbOrder> selectRankingList(Page<TbOrder> pages, String date, String dateType);
+    IPage<TbOrder> selectRankingList(Page<TbOrder> pages, @Param("query")ShopCenterQuery query);
 
     int allUserCount(String date, String dateType);
 
@@ -95,4 +97,5 @@ public interface DataCentreDao {
 
     BigDecimal cancelOrderMoney(Long shopId, String date, String dateType);
 
+    List<TbOrder> excelShopCenter(@Param("query")ShopCenterQuery query);
 }

+ 22 - 0
src/main/java/com/sqx/modules/datacentre/query/DataCenterQuery.java

@@ -0,0 +1,22 @@
+package com.sqx.modules.datacentre.query;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import com.sqx.common.query.PageQuery;
+
+@Data
+public class DataCenterQuery extends PageQuery {
+
+    @ApiModelProperty(value = "起始时间")
+    private String startTime;
+
+    @ApiModelProperty(value = "结束时间")
+    private String endTime;
+
+    @ApiModelProperty(value = "日期")
+    private String date;
+
+    @ApiModelProperty(value = "类型")
+    private String dateType;
+}
+

+ 43 - 0
src/main/java/com/sqx/modules/datacentre/query/ShopCenterQuery.java

@@ -0,0 +1,43 @@
+package com.sqx.modules.datacentre.query;
+
+import com.sqx.common.query.PageQuery;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.util.StringUtils;
+
+import javax.validation.constraints.Pattern;
+
+@Data
+public class ShopCenterQuery extends DataCenterQuery {
+
+    @ApiModelProperty(value = "商铺主营类型id")
+    @Pattern(regexp = "^[0-9]*$", message = "商铺类型只能为数字")
+    private String shopType;
+
+    @ApiModelProperty(value = "商铺主营类型名称")
+    private String shopTypeName;
+
+    @ApiModelProperty(value = "登录人id")
+    private String userId;
+
+    public String toStrMessage() {
+        StringBuilder stringBuilder=new StringBuilder();
+        stringBuilder
+                .append(StringUtils.hasText(getStartTime())?"开始时间:"+getStartTime()+";":"")
+                .append(StringUtils.hasText(getEndTime())?"结束时间:"+getEndTime()+";":"")
+                .append(StringUtils.hasText(shopType)?"商铺类型编号:"+shopType+";":"")
+                .append(StringUtils.hasText(getDate())?"日期:"+getDate()+";":"")
+                .append(StringUtils.hasText(getDateType())?"查询类型:"+getDateType()+";":"");
+        return stringBuilder.toString();
+    }
+
+    public String toStrCode() {
+        return
+                ","+(getStartTime()==null?"":getStartTime())
+                +","+(getEndTime()==null?"":getEndTime())
+                +","+(shopType==null?"":shopType)
+                +","+(getDate()==null?"":getDate())
+                +","+(getDateType()==null?"":getDateType())
+                +",";
+    }
+}

+ 6 - 1
src/main/java/com/sqx/modules/datacentre/service/DataCentreService.java

@@ -1,6 +1,9 @@
 package com.sqx.modules.datacentre.service;
 
 import com.sqx.common.utils.Result;
+import com.sqx.modules.datacentre.query.ShopCenterQuery;
+import com.sqx.modules.pay.controller.query.CashOutQueryDTO;
+import com.sqx.modules.utils.excel.ExcelData;
 
 public interface DataCentreService {
 
@@ -24,7 +27,9 @@ public interface DataCentreService {
 
     Result rankingList(Integer page, Integer limit, String address, String date, String dateType);
 
-    Result selectShopCenter(String date, String dateType, Integer page, Integer limit);
+    Result selectShopCenter(ShopCenterQuery query);
+
+    ExcelData excelShopCenter(ShopCenterQuery queryDTO);
 
     Result selectUserCenter(String date, String dateType);
 

+ 39 - 9
src/main/java/com/sqx/modules/datacentre/service/impl/DataCentreServiceImpl.java

@@ -16,16 +16,20 @@ import com.sqx.modules.common.service.CommonInfoService;
 import com.sqx.modules.coupon.dao.TbCouponUserDao;
 import com.sqx.modules.coupon.entity.TbCouponUser;
 import com.sqx.modules.datacentre.dao.DataCentreDao;
+import com.sqx.modules.datacentre.query.ShopCenterQuery;
 import com.sqx.modules.datacentre.service.DataCentreService;
 import com.sqx.modules.errand.entity.Feedback;
 import com.sqx.modules.errand.entity.TbIndent;
 import com.sqx.modules.order.dao.AppOrderDao;
 import com.sqx.modules.order.entity.TbOrder;
 import com.sqx.modules.pay.controller.app.AliPayController;
+import com.sqx.modules.pay.controller.query.WalletDetailQuery;
 import com.sqx.modules.pay.dao.PayDetailsDao;
 import com.sqx.modules.pay.entity.CashOut;
 import com.sqx.modules.pay.entity.PayDetails;
 import com.sqx.modules.pay.service.WxErrRiderService;
+import com.sqx.modules.pay.vo.WalletDetailVO;
+import com.sqx.modules.utils.excel.ExcelData;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,9 +38,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
+import java.util.*;
 
 @Service
 @Slf4j
@@ -231,15 +233,15 @@ public class DataCentreServiceImpl implements DataCentreService {
     }
 
     @Override
-    public Result selectShopCenter(String date, String dateType, Integer page, Integer limit) {
+    public Result selectShopCenter(ShopCenterQuery query) {
         HashMap hashMap = new HashMap();
         //新增门店数量
-        int newShopCount = dataCentreDao.selectNewShopCount(date, dateType);
+        int newShopCount = dataCentreDao.selectNewShopCount(query);
         //门店收益排行榜
-        Page<TbOrder> pages=new Page<>(page,limit);
-        IPage<TbOrder> tbOrderIPage = dataCentreDao.selectRankingList(pages, date, dateType);
-        for(int i = 0;i<limit;i++){
-            Integer a = ((page-1)*limit)+i+1;
+        Page<TbOrder> pages=new Page<>(query.getPage(),query.getLimit());
+        IPage<TbOrder> tbOrderIPage = dataCentreDao.selectRankingList(pages, query);
+        for(int i = 0;i<query.getLimit();i++){
+            Integer a = ((query.getPage()-1)*query.getLimit())+i+1;
             if(tbOrderIPage.getRecords().size()>i){
                 tbOrderIPage.getRecords().get(i).setRank(a);
             }
@@ -251,6 +253,34 @@ public class DataCentreServiceImpl implements DataCentreService {
     }
 
     @Override
+    public ExcelData excelShopCenter(ShopCenterQuery query) {
+        List<TbOrder> tbOrderList = dataCentreDao.excelShopCenter(query);
+        ExcelData data = new ExcelData();
+        data.setName("商家收益排行");
+        data.setTitles(WalletDetailExportTitle());
+        List<List<Object>> rows = new ArrayList<>();
+        for (TbOrder tbOrder:tbOrderList ){
+            List<Object> row = new ArrayList<>();
+            row.add(tbOrder.getShopId());
+            row.add(tbOrder.getShopName());
+            row.add(tbOrder.getShopTypeName());
+            row.add(tbOrder.getRank());
+            row.add(tbOrder.getShopMoney());
+            rows.add(row);
+        }
+        data.setRows(rows);
+        return data;
+    }
+
+    private List<String> WalletDetailExportTitle() {
+        return Arrays.asList(
+                "编号",
+                "店铺名称",
+                "商铺类型",
+                "排名",
+                "收益");
+    }
+    @Override
     public Result selectUserCenter(String date, String dateType) {
         HashMap hashMap = new HashMap();
         int userCount = dataCentreDao.allUserCount(date, dateType);

+ 271 - 0
src/main/java/com/sqx/modules/exportExecl/controller/ExportExeclController.java

@@ -0,0 +1,271 @@
+package com.sqx.modules.exportExecl.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.jcraft.jsch.SftpException;
+import com.sqx.common.utils.PageUtils;
+import com.sqx.common.utils.Result;
+import com.sqx.common.utils.SftpUtil;
+import com.sqx.modules.common.service.CommonInfoService;
+import com.sqx.modules.datacentre.query.ShopCenterQuery;
+import com.sqx.modules.exportExecl.mapper.ExportJobMapper;
+import com.sqx.modules.exportExecl.model.ExportJob;
+import com.sqx.modules.exportExecl.service.ExportJobService;
+import com.sqx.modules.order.dao.AppOrderDao;
+import com.sqx.modules.pay.controller.query.CashOutQueryDTO;
+import com.sqx.modules.pay.controller.query.WalletDetailQuery;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.util.IOUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URLEncoder;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+
+@Slf4j
+@Api(tags={"管理端-导出"})
+@RestController
+@RequestMapping("/admin/export")
+@RequiredArgsConstructor
+public class ExportExeclController {
+
+    private final AppOrderDao appOrderDao;
+
+    private final ExportJobMapper exportJobMapper;
+
+    private final ExportJobService exportJobService;
+
+    private final CommonInfoService commonInfoService;
+
+    private final SftpUtil sftpUtil;
+
+    @GetMapping("excelOrder")
+    @ApiOperation("导出订单列表")
+    public Result excelOrder(Integer status, String phone, Long shopId, String userName,
+                             String orderNumber, Integer orderType, String shopName, String riderPhone,
+                             String startTime, String endTime, String userId, String payStartTime, String payEndTime) throws Exception{
+        Integer size = appOrderDao.excelAllOrderAdminCount( status, phone, shopId, userName, orderNumber, orderType,
+                shopName, riderPhone,startTime,endTime,payStartTime,payEndTime);
+        //可导出最大数量
+        String count=commonInfoService.findOne(431).getValue();
+        if(size>Integer.parseInt(count)){
+            return Result.error("导出总数不能超过"+Integer.parseInt(count)+",请添加筛选条件");
+        }
+        if(!StringUtils.hasText(userId)){
+            return Result.error("用户id不能为空");
+        }
+        StringBuffer stringBuffer=new StringBuffer();
+        if(status!=null){stringBuffer.append("状态:"+getState(status)+";");}
+        if(phone!=null&&!phone.trim().equals("")){stringBuffer.append("手机号:"+phone+";");}
+//        if(shopId!=null){stringBuffer.append(":"+shopId+";");}
+        if(userName!=null&&!userName.trim().equals("")){stringBuffer.append("昵称:"+userName+";");}
+        if(orderNumber!=null&&!orderNumber.trim().equals("")){stringBuffer.append("订单号:"+orderNumber+";");}
+        if(orderType!=null){stringBuffer.append("订单类型:"+(orderType==1?"到店取餐":(orderType==2?"骑手配送":"商家配送"))+";");}
+        if(shopName!=null&&!shopName.trim().equals("")){stringBuffer.append("商铺名称:"+shopName+";");}
+        if(riderPhone!=null&&!riderPhone.trim().equals("")){stringBuffer.append("骑手手机号:"+riderPhone+";");}
+        if(startTime!=null&&!startTime.trim().equals("")){stringBuffer.append("开始时间:"+startTime+";");}
+        if(endTime!=null&&!endTime.trim().equals("")){stringBuffer.append("结束时间:"+endTime+";");}
+        if(payStartTime!=null&&!payStartTime.trim().equals("")){stringBuffer.append("支付开始时间:"+payStartTime+";");}
+        if(payEndTime!=null&&!payEndTime.trim().equals("")){stringBuffer.append("支付结束时间:"+payEndTime+";");}
+
+        ExportJob exportJob =new ExportJob();
+        exportJob.setFlag(0);
+        exportJob.setFileType("order");
+        exportJob.setConditionDetail(stringBuffer.toString());
+        exportJob.setConditions(","+(status==null?"":status)+","+phone+","+(shopId==null?"":shopId)+","+userName+","+orderNumber+","
+                +(orderType==null?"":orderType)+","+shopName+","
+                +riderPhone+","+startTime+","+endTime+","+payStartTime+","+payEndTime);
+        LocalDateTime localDateTime = LocalDateTime.now();
+        String time=localDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
+        exportJob.setFileName((int) (Math.random() * 100) +time+"订单列表.xlsx");
+        exportJob.setUserId(userId);
+        exportJob.setCreateTime(new Date());
+        exportJob.setUpdateTime(new Date());
+        int a=exportJobMapper.insert(exportJob);
+        if (a==1){
+            return Result.success("新增导出计划成功");
+        }else{
+            return Result.error("新增导出计划失败");
+        }
+    }
+    @GetMapping("excelRecharge")
+    @ApiOperation("导出充值记录")
+    public Result excelRecharge(String rechargeOrder, String acount,String userId) throws Exception{
+        if(!StringUtils.hasText(userId)){
+            return Result.error("用户id不能为空");
+        }
+        StringBuffer stringBuffer=new StringBuffer();
+        if(rechargeOrder!=null&&rechargeOrder!=""){stringBuffer.append("充值订单号:"+rechargeOrder+";");}
+        if(acount!=null&&acount!=""){stringBuffer.append("被充值账号:"+acount+";");}
+
+        ExportJob exportJob =new ExportJob();
+        exportJob.setFlag(0);
+        exportJob.setFileType("recharge");
+        exportJob.setConditionDetail(stringBuffer.toString());
+        exportJob.setConditions(","+rechargeOrder+","+acount);
+        LocalDateTime localDateTime = LocalDateTime.now();
+        String time=localDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
+        exportJob.setFileName(time+"充值记录.xlsx");
+        exportJob.setCreateTime(new Date());
+        exportJob.setUpdateTime(new Date());
+        exportJob.setUserId(userId);
+        int a=exportJobMapper.insert(exportJob);
+        if (a==1){
+            return Result.success("新增导出计划成功");
+        }else{
+            return Result.error("新增导出计划失败");
+        }
+    }
+
+    @GetMapping("excelPayouts")
+    @ApiOperation("提现管理导出")
+    public Result excelPayouts(CashOutQueryDTO queryDTO) throws Exception{
+        if(queryDTO.getUserId()==null){
+            return Result.error("用户id不能为空");
+        }
+        ExportJob exportJob =new ExportJob();
+        exportJob.setFlag(0);
+        exportJob.setFileType("payouts");
+        exportJob.setConditionDetail(queryDTO.toStrMessage());
+        exportJob.setConditions(queryDTO.toStrCode());
+        LocalDateTime localDateTime = LocalDateTime.now();
+        String time=localDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
+        exportJob.setFileName(time+"提现管理.xlsx");
+        exportJob.setCreateTime(new Date());
+        exportJob.setUpdateTime(new Date());
+        exportJob.setUserId(queryDTO.getUserId()+"");
+        int a=exportJobMapper.insert(exportJob);
+        if (a==1){
+            return Result.success("新增提现管理导出计划成功");
+        }else{
+            return Result.error("新增提现管理导出计划失败");
+        }
+    }
+
+    @GetMapping("excelDeposit")
+    @ApiOperation("导出保证金记录")
+    public Result excelDeposit(WalletDetailQuery queryDTO) throws Exception{
+        if(!StringUtils.hasText(queryDTO.getUserId())){
+            return Result.error("用户id不能为空");
+        }
+        ExportJob exportJob =new ExportJob();
+        exportJob.setFlag(0);
+        exportJob.setFileType("deposit");
+        exportJob.setConditionDetail(queryDTO.toStrMessage());
+        exportJob.setConditions(queryDTO.toStrCode());
+        LocalDateTime localDateTime = LocalDateTime.now();
+        String time=localDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
+        exportJob.setFileName(time+"保证金记录.xlsx");
+        exportJob.setCreateTime(new Date());
+        exportJob.setUpdateTime(new Date());
+        exportJob.setUserId(queryDTO.getUserId()+"");
+        int a=exportJobMapper.insert(exportJob);
+        if (a==1){
+            return Result.success("新增保证金记录导出计划成功");
+        }else{
+            return Result.error("新增保证金记录导出计划失败");
+        }
+    }
+    //    任意文件读取/下载
+    @ApiOperation(value = "查询下载列表")
+    @GetMapping("listByUser")
+    public Result List(String userId,String state,String startTime,String endTime,Integer curretPage,Integer pageSize) throws IOException {
+
+        QueryWrapper queryWrapper=new QueryWrapper<ExportJob>();
+
+        queryWrapper.eq("user_id",userId);
+        if(StringUtils.hasText(state)){
+            queryWrapper.eq("flag",state);
+        }
+        if(StringUtils.hasText(startTime)){
+            queryWrapper.ge("create_time",startTime);
+        }
+        if(StringUtils.hasText(endTime)){
+            queryWrapper.le("create_time",endTime);
+        }
+        queryWrapper.orderByDesc("create_time");
+        IPage<ExportJob> iPage=exportJobService.page(new Page<>(curretPage,pageSize),queryWrapper);
+        PageUtils pageUtils = new PageUtils(iPage);
+        return Result.success().put("data", pageUtils);
+    }
+
+    //    任意文件读取/下载
+    @ApiOperation(value = "文件下载")
+    @GetMapping("readBuffer")
+    public void readbuffer(String filename,HttpServletResponse response) throws IOException {
+        if(filename.contains("..") || filename.contains("/")){
+            throw new IOException("文件名异常");
+        }
+        String value=commonInfoService.findOne(430).getValue()==null?"":commonInfoService.findOne(430).getValue();
+        sftpUtil.login();
+        try {
+            response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+            // 下载文件的默认名称
+            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "utf-8"));
+            sftpUtil.downloadStream(value,filename,response.getOutputStream());
+            log.info("文件下载成功");
+        }catch (IOException | SftpException e){
+            log.error(e.getMessage());
+            log.error("文件下载失败");
+        }finally {
+            if (sftpUtil.isConnected()){
+                sftpUtil.logout();
+            }
+        }
+    }
+
+    // '订单状态 0待结算 1待支付 2直接购买(未支付) 7商家待接单 8商家拒绝接单 6制作中  3待取餐/派送中 4已完成 5已取消 ',
+    private String getState(Integer state){
+        switch (state){
+            case 1: return "待支付";
+            case 2: return "未支付";
+            case 3: return "待取餐";
+            case 4: return "已完成";
+            case 5: return "已取消";
+            case 6: return "制作中";
+            case 7: return "商家待接单";
+            case 8: return "商家拒绝接单";
+            case 0: return "待结算";
+            default: return state+"";
+        }
+    }
+
+    @GetMapping("excelShopCenter")
+    @ApiOperation("导出商户收益统计")
+    public Result excelShopCenter(ShopCenterQuery queryDTO) throws Exception{
+        if(!StringUtils.hasText(queryDTO.getUserId())){
+            return Result.error("用户id不能为空");
+        }
+        ExportJob exportJob =new ExportJob();
+        exportJob.setFlag(0);
+        exportJob.setFileType("shopCenter");
+        exportJob.setConditionDetail(queryDTO.toStrMessage());
+        exportJob.setConditions(queryDTO.toStrCode());
+        LocalDateTime localDateTime = LocalDateTime.now();
+        String time=localDateTime.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS"));
+        exportJob.setFileName(time+"商铺收益排行.xlsx");
+        exportJob.setCreateTime(new Date());
+        exportJob.setUpdateTime(new Date());
+        exportJob.setUserId(queryDTO.getUserId()+"");
+        int a=exportJobMapper.insert(exportJob);
+        if (a==1){
+            return Result.success("新增商铺收益排行导出计划成功");
+        }else{
+            return Result.error("新增商铺收益排行导出计划失败");
+        }
+    }
+}

+ 18 - 0
src/main/java/com/sqx/modules/exportExecl/mapper/ExportJobMapper.java

@@ -0,0 +1,18 @@
+package com.sqx.modules.exportExecl.mapper;
+
+import com.sqx.modules.exportExecl.model.ExportJob;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author wan
+ * @since 2024-09-25
+ */
+@Mapper
+public interface ExportJobMapper extends BaseMapper<ExportJob> {
+
+}

+ 66 - 0
src/main/java/com/sqx/modules/exportExecl/model/ExportJob.java

@@ -0,0 +1,66 @@
+package com.sqx.modules.exportExecl.model;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wan
+ * @since 2024-09-25
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ExportJob对象", description="")
+public class ExportJob implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "export_id", type = IdType.AUTO)
+    private Integer exportId;
+
+    @ApiModelProperty(value = "文件名称")
+    private String fileName;
+
+    @ApiModelProperty(value = "文件类型")
+    private String fileType;
+
+    @ApiModelProperty(value = "用户id")
+    private String userId;
+
+    @ApiModelProperty(value = "创建时间")
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
+    private Date createTime;
+
+    @ApiModelProperty(value = "更新时间")
+    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone="GMT+8")
+    private Date updateTime;
+
+    @ApiModelProperty(value = "导出条件描述")
+    private String conditionDetail;
+
+    @ApiModelProperty(value = "导出条件")
+    private String conditions;
+
+    @ApiModelProperty(value = "文件大小")
+    private String fileSize;
+
+    @ApiModelProperty(value = "状态 0待导出 1导出已完成 2导出失败 -1 导出中")
+    private Integer flag;
+
+
+}

+ 118 - 0
src/main/java/com/sqx/modules/exportExecl/model/ExportOrderVo.java

@@ -0,0 +1,118 @@
+package com.sqx.modules.exportExecl.model;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import lombok.Data;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author wan
+ * @since 2024-07-22
+ */
+@Data
+public class ExportOrderVo {
+
+
+    @ColumnWidth(0)
+    @ExcelProperty(value = "编号" , index = 0)
+    private String orderId;
+    @ColumnWidth(1)
+    @ExcelProperty(value = "下单用户" , index = 0)
+    private String userName;
+
+    @ColumnWidth(2)
+    @ExcelProperty(value = "用户头像" , index = 0)
+    private String avatar;
+
+    @ColumnWidth(3)
+    @ExcelProperty(value = "手机号" , index = 0)
+    private String phone;
+
+    @ColumnWidth(4)
+    @ExcelProperty(value = "商铺信息" , index = 0)
+    private String shopDetail;
+
+    @ColumnWidth(5)
+    @ExcelProperty(value = "订单类型" , index = 0)
+    private String orderType;
+
+    @ColumnWidth(6)
+    @ExcelProperty(value = "配送信息" , index = 0)
+    private String identail;
+
+    @ColumnWidth(7)
+    @ExcelProperty(value = "骑手昵称" , index = 0)
+    private String riderNickName;
+
+    @ColumnWidth(8)
+    @ExcelProperty(value = "骑手电话" , index = 0)
+    private String riderPhone;
+
+    @ColumnWidth(9)
+    @ExcelProperty(value = "订单号" , index = 0)
+    private String orderNumber;
+
+    @ColumnWidth(10)
+    @ExcelProperty(value = "内容" , index = 0)
+    private String goodsDetail;
+
+    @ColumnWidth(11)
+    @ExcelProperty(value = "商品总价(元)" , index = 0)
+    private String sumPrice;
+
+    @ColumnWidth(12)
+    @ExcelProperty(value = "优惠金额(元)" , index = 0)
+    private String couponMoney;
+
+    @ColumnWidth(13)
+    @ExcelProperty(value = "参与活动名称" , index = 0)
+    private String activityTitle;
+
+    @ColumnWidth(14)
+    @ExcelProperty(value = "活动优惠金额(元)" , index = 0)
+    private String activityDiscountAmount;
+
+    @ColumnWidth(15)
+    @ExcelProperty(value = "打包费(元/个 具体按照数量计算)" , index = 0)
+    private String packMoney;
+
+    @ColumnWidth(16)
+    @ExcelProperty(value = "跑腿费(元)" , index = 0)
+    private String errandMoney;
+
+    @ColumnWidth(17)
+    @ExcelProperty(value = "支付金额(元)" , index = 0)
+    private String payMoney;
+
+    @ColumnWidth(18)
+    @ExcelProperty(value = "跑腿费说明" , index = 0)
+    private String errandMoneyIsShop;
+
+    @ColumnWidth(19)
+    @ExcelProperty(value = "订单备注" , index = 0)
+    private String remark;
+
+    @ColumnWidth(20)
+    @ExcelProperty(value = "支付时间" , index = 0)
+    private String payTime;
+
+    @ColumnWidth(21)
+    @ExcelProperty(value = "支付方式" , index = 0)
+    private String payType;
+
+    @ColumnWidth(22)
+    @ExcelProperty(value = "取餐号" , index = 0)
+    private String qucanhao;
+
+    @ColumnWidth(23)
+    @ExcelProperty(value = "状态" , index = 0)
+    private String orderCode;
+
+    @ColumnWidth(24)
+    @ExcelProperty(value = "是否转单" , index = 0)
+    private String isRider;
+
+}

+ 16 - 0
src/main/java/com/sqx/modules/exportExecl/service/ExportJobService.java

@@ -0,0 +1,16 @@
+package com.sqx.modules.exportExecl.service;
+
+import com.sqx.modules.exportExecl.model.ExportJob;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author wan
+ * @since 2024-09-25
+ */
+public interface ExportJobService extends IService<ExportJob> {
+
+}

+ 20 - 0
src/main/java/com/sqx/modules/exportExecl/service/impl/ExportJobServiceImpl.java

@@ -0,0 +1,20 @@
+package com.sqx.modules.exportExecl.service.impl;
+
+import com.sqx.modules.exportExecl.model.ExportJob;
+import com.sqx.modules.exportExecl.mapper.ExportJobMapper;
+import com.sqx.modules.exportExecl.service.ExportJobService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author wan
+ * @since 2024-09-25
+ */
+@Service
+public class ExportJobServiceImpl extends ServiceImpl<ExportJobMapper, ExportJob> implements ExportJobService {
+
+}

+ 34 - 11
src/main/java/com/sqx/modules/file/AliFileUploadController.java

@@ -1,19 +1,28 @@
 package com.sqx.modules.file;
 
+import cn.hutool.core.util.StrUtil;
 import com.aliyun.oss.OSS;
 import com.aliyun.oss.OSSClientBuilder;
+import com.sqx.common.exception.SqxException;
 import com.sqx.common.utils.Result;
+import com.sqx.config.MinioConfig;
 import com.sqx.modules.common.service.CommonInfoService;
 import com.sqx.modules.file.utils.FileUploadUtils;
 import icu.xuyijie.secureapi.annotation.DecryptParam;
+import io.minio.MinioClient;
+import io.minio.ObjectWriteResponse;
+import io.minio.PutObjectArgs;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.jaudiotagger.audio.AudioFileIO;
 import org.jaudiotagger.audio.mp3.MP3AudioHeader;
 import org.jaudiotagger.audio.mp3.MP3File;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
 import java.io.ByteArrayInputStream;
@@ -34,19 +43,16 @@ import java.util.UUID;
  * @author fang
  * @date 2020/7/13
  */
-@RestController
+@Slf4j
 @Api(value = "阿里云文件上传", tags = {"阿里云文件上传"})
+@RestController
 @RequestMapping(value = "/alioss")
-@Slf4j
+@RequiredArgsConstructor
 public class AliFileUploadController {
 
-
     private final CommonInfoService commonRepository;
-
-    @Autowired
-    public AliFileUploadController(CommonInfoService commonRepository) {
-        this.commonRepository = commonRepository;
-    }
+    private final MinioClient minioClient;
+    private final MinioConfig minioConfig;
 
     @RequestMapping(value = "/upload", method = RequestMethod.POST)
     @ApiOperation("文件上传")
@@ -71,7 +77,24 @@ public class AliFileUploadController {
             String src = commonRepository.findOne(72).getValue()+"/"+completePath;
             // String src = commonRepository.findOne(19).getValue()+"/img/"+completePath;
             return Result.success().put("data",src);
-        }else{
+        } else if (StrUtil.equals(value, "3")) {
+            // Minio上传
+            String suffix = file.getOriginalFilename().substring(Objects.requireNonNull(file.getOriginalFilename()).lastIndexOf("."));
+            String completePath = getPath(suffix);
+            try {
+                minioClient.putObject(PutObjectArgs.builder()
+                        .bucket(minioConfig.getBucket())
+                        .object(completePath)
+                        .stream(file.getInputStream(), file.getSize(), -1)
+                        .build());
+
+                String src = commonRepository.findOne(72).getValue() + "/" + completePath;
+                return Result.success().put("data", src);
+            } catch (Exception e) {
+                throw new SqxException("文件上传失败!");
+            }
+
+        } else{
             try
             {
                 String http = commonRepository.findOne(19).getValue();

+ 1 - 0
src/main/java/com/sqx/modules/goods/controller/GoodsShopController.java

@@ -124,6 +124,7 @@ public class GoodsShopController {
     @PostMapping("/updateGoodsShop")
     public Result updateGoodsShop(@RequestBody GoodsShop goodsShop){
         goodsShop.setStatus(0);
+        goodsShop.setIsSupplier(1);
         goodsShopService.updateById(goodsShop);
         return Result.success();
     }

+ 2 - 0
src/main/java/com/sqx/modules/goods/service/impl/GoodsShopServiceImpl.java

@@ -467,6 +467,8 @@ public class GoodsShopServiceImpl extends ServiceImpl<GoodsShopDao, GoodsShop> i
         goodsShopVo.setDistributionDistance(3000.00);
         GoodsShop shop = new GoodsShop();
         BeanUtils.copyProperties(goodsShopVo, shop);
+//        默认不是供应商
+        shop.setIsSupplier(1);
         baseMapper.insert(shop);
         CommonInfo name = commonInfoService.findOne(12);
         Msg byPhone = msgDao.findByPhone(goodsShopVo.getPhone());

+ 11 - 0
src/main/java/com/sqx/modules/order/controller/OrderController.java

@@ -51,6 +51,7 @@ public class OrderController extends AbstractController {
         return appOrderService.selectAllOrderAdmin(page, limit, status, phone, shopId, userName, orderNumber, orderType, shopName, riderPhone, indentStatus, reservationFlag, startTime, endTime, payStartTime, payEndTime);
     }
 
+<<<<<<< HEAD
     @GetMapping("excelOrder")
     @ApiOperation("导出卡密列表")
     public void excelOrder(Integer status, String phone, Long shopId, String userName,
@@ -59,6 +60,16 @@ public class OrderController extends AbstractController {
         ExcelData excelData = appOrderService.excelAllOrderAdmin(status, phone, shopId, userName, orderNumber, orderType, shopName, riderPhone, startTime, endTime);
         ExportExcelUtils.exportExcel(response, "订单列表.xlsx", excelData);
     }
+=======
+//    @GetMapping("excelOrder")
+//    @ApiOperation("导出卡密列表")
+//    public void excelOrder(Integer status, String phone, Long shopId, String userName,
+//                           String orderNumber, Integer orderType,String shopName,String riderPhone,
+//                           String startTime, String endTime, HttpServletResponse response) throws Exception{
+//        ExcelData excelData = appOrderService.excelAllOrderAdmin(status, phone, shopId, userName, orderNumber, orderType, shopName, riderPhone, startTime, endTime);
+//        ExportExcelUtils.exportExcel(response,"订单列表.xlsx",excelData);
+//    }
+>>>>>>> 828630e600a93dcf45aee58f07e9447c672db999
 
     @ApiOperation("完成订单")
     @PostMapping(value = "accomplishOrder")

+ 10 - 3
src/main/java/com/sqx/modules/order/dao/AppOrderDao.java

@@ -3,6 +3,7 @@ package com.sqx.modules.order.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.sqx.datasource.annotation.DataSource;
 import com.sqx.modules.order.entity.TbOrder;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -23,17 +24,23 @@ public interface AppOrderDao extends BaseMapper<TbOrder> {
     IPage<TbOrder> selectOrder(Page<TbOrder> pages,@Param("status") Integer status,@Param("phone") String phone, @Param("shopId") Long shopId,
                                @Param("userName") String userName, @Param("orderNumber") String orderNumber,@Param("orderType") Integer orderType,@Param("shopName")String shopName);
 
-
+    @DataSource("dynamic")
     IPage<TbOrder> selectAllOrderAdmin(Page<TbOrder> pages,@Param("status") Integer status,@Param("phone") String phone, @Param("shopId") Long shopId,
                                @Param("userName") String userName, @Param("orderNumber") String orderNumber,@Param("orderType") Integer orderType,
                                        @Param("shopName")String shopName,@Param("riderPhone") String riderPhone, @Param("indentStatus") String indentStatus, @Param("reservationFlag") String reservationFlag,
                                        @Param("startTime") String startTime,@Param("endTime") String endTime, @Param("payStartTime") String payStartTime, @Param("payEndTime") String payEndTime);
-
+    @DataSource("dynamic")
     List<TbOrder> excelAllOrderAdmin(@Param("status") Integer status,@Param("phone") String phone, @Param("shopId") Long shopId,
                                        @Param("userName") String userName, @Param("orderNumber") String orderNumber,
                                      @Param("orderType") Integer orderType,@Param("shopName")String shopName,
                                      @Param("riderPhone") String riderPhone,@Param("startTime") String startTime,
-                                     @Param("endTime") String endTime);
+                                     @Param("endTime") String endTime,@Param("payStartTime") String payStartTime,@Param("payEndTime") String payEndTime);
+    @DataSource("dynamic")
+    Integer excelAllOrderAdminCount(@Param("status") Integer status,@Param("phone") String phone, @Param("shopId") Long shopId,
+                                     @Param("userName") String userName, @Param("orderNumber") String orderNumber,
+                                     @Param("orderType") Integer orderType,@Param("shopName")String shopName,
+                                     @Param("riderPhone") String riderPhone,@Param("startTime") String startTime,
+                                     @Param("endTime") String endTime,@Param("payStartTime") String payStartTime,@Param("payEndTime") String payEndTime);
 
 
     IPage<TbOrder> selectOrderByAdmin(Page<TbOrder> pages,@Param("status") Integer status,@Param("phone") String phone,

+ 16 - 0
src/main/java/com/sqx/modules/order/entity/TbOrder.java

@@ -175,6 +175,14 @@ public class TbOrder implements Serializable {
     @TableField(exist = false)
     private String shopPhone;
 
+    @ApiModelProperty("商铺主营类型")
+    @TableField(exist = false)
+    private String shopType;
+
+    @ApiModelProperty("商铺主营类型名称")
+    @TableField(exist = false)
+    private String shopTypeName;
+
     @TableField(exist = false)
     private List<OrderGoods> orderGoodsList;
 
@@ -255,5 +263,13 @@ public class TbOrder implements Serializable {
     @TableField(exist = false)
     private Integer isRider;
 
+    @TableField(exist = false)
+    @ApiModelProperty("导出商品详情")
+    private String detail;
+
+    @TableField(exist = false)
+    @ApiModelProperty("导出商品总价")
+    private Double sumPrice;
+
     public TbOrder() {}
 }

+ 1 - 1
src/main/java/com/sqx/modules/order/service/AppOrderService.java

@@ -34,7 +34,7 @@ public interface AppOrderService extends IService<TbOrder> {
 
     ExcelData excelAllOrderAdmin(Integer status, String phone, Long shopId,
                                  String userName, String orderNumber, Integer orderType, String shopName,
-                                 String riderPhone, String startTime, String endTime);
+                                 String riderPhone, String startTime, String endTime,String payStartTime, String payEndTime);
 
     Result selectOrderByUserId(Long userId, String date, String dateType);
 

+ 25 - 22
src/main/java/com/sqx/modules/order/service/impl/AppAppOrderServiceImpl.java

@@ -1288,14 +1288,14 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
     @Override
     public ExcelData excelAllOrderAdmin(Integer status, String phone, Long shopId,
                                         String userName, String orderNumber, Integer orderType, String shopName,
-                                        String riderPhone, String startTime, String endTime) {
+                                        String riderPhone, String startTime, String endTime,String payStartTime, String payEndTime) {
         List<TbOrder> tbOrderIPage = appOrderDao.excelAllOrderAdmin( status, phone, shopId, userName, orderNumber, orderType,
-                shopName, riderPhone,startTime,endTime);
-        for (int i = 0; i < tbOrderIPage.size(); i++) {
-            List<OrderGoods> orderGoodsList = orderGoodsDao.selectList(new QueryWrapper<OrderGoods>()
-                    .eq("order_id", tbOrderIPage.get(i).getOrderId()));
-            tbOrderIPage.get(i).setOrderGoodsList(orderGoodsList);
-        }
+                shopName, riderPhone,startTime,endTime,payStartTime,payEndTime);
+//        for (int i = 0; i < tbOrderIPage.size(); i++) {
+//            List<OrderGoods> orderGoodsList = orderGoodsDao.selectList(new QueryWrapper<OrderGoods>()
+//                    .eq("order_id", tbOrderIPage.get(i).getOrderId()));
+//            tbOrderIPage.get(i).setOrderGoodsList(orderGoodsList);
+//        }
         ExcelData data = new ExcelData();
         data.setName("订单列表");
         List<String> titles = new ArrayList();
@@ -1322,10 +1322,12 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
                     .append("\n").append("店铺电话:").append(StringUtils.isNotBlank(order.getShopPhone())?order.getShopPhone():"")
                     .append("\n").append("店铺地址:").append(StringUtils.isNotBlank(order.getDetailedAddress())?order.getDetailedAddress():"");
             row.add(stringBuffer.toString());
-            if(order.getOrderType()!=null && order.getOrderType()==1){
+            if(order.getOrderTypeExtra()!=null && order.getOrderTypeExtra()==1){
                 row.add("到店取餐");
-            }else if(order.getOrderType()!=null && order.getOrderType()==2){
+            }else if(order.getOrderTypeExtra()!=null && order.getOrderTypeExtra()==2){
                 row.add("外卖配送");
+            }else if(order.getOrderTypeExtra()!=null && order.getOrderTypeExtra()==3){
+                row.add("商家配送");
             }else{
                 row.add("");
             }
@@ -1341,19 +1343,19 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
             row.add(order.getRiderNickName());
             row.add(order.getRiderPhone());
             row.add(order.getOrderNumber());
-            stringBuffer=new StringBuffer();
-            BigDecimal sumGoodsPrice=BigDecimal.ZERO;
-            List<OrderGoods> orderGoodsList = order.getOrderGoodsList();
-            for(int i=0;i<orderGoodsList.size();i++){
-                OrderGoods orderGoods = orderGoodsList.get(i);
-                stringBuffer.append(i + 1).append(". 商品名:").append(orderGoods.getGoodsName()).append(",数量:").append(orderGoods.getGoodsNum()).append(",规格:").append(orderGoods.getSkuMessage());
-                if(orderGoods.getGoodsPrice()!=null && orderGoods.getGoodsNum()!=null){
-                    BigDecimal goodsPrice = orderGoods.getGoodsPrice().multiply(BigDecimal.valueOf(orderGoods.getGoodsNum()));
-                    sumGoodsPrice=sumGoodsPrice.add(goodsPrice);
-                }
-            }
-            row.add(stringBuffer.toString());
-            row.add(sumGoodsPrice);
+//            stringBuffer=new StringBuffer();
+//            BigDecimal sumGoodsPrice=BigDecimal.ZERO;
+//            List<OrderGoods> orderGoodsList = order.getOrderGoodsList();
+//            for(int i=0;i<orderGoodsList.size();i++){
+//                OrderGoods orderGoods = orderGoodsList.get(i);
+//                stringBuffer.append(i + 1).append(". 商品名:").append(orderGoods.getGoodsName()).append(",数量:").append(orderGoods.getGoodsNum()).append(",规格:").append(orderGoods.getSkuMessage());
+//                if(orderGoods.getGoodsPrice()!=null && orderGoods.getGoodsNum()!=null){
+//                    BigDecimal goodsPrice = orderGoods.getGoodsPrice().multiply(BigDecimal.valueOf(orderGoods.getGoodsNum()));
+//                    sumGoodsPrice=sumGoodsPrice.add(goodsPrice);
+//                }
+//            }
+            row.add(order.getDetail());
+            row.add(order.getSumPrice());
             row.add(order.getCouponMoney());
             row.add(order.getActivityTitle());
             row.add(order.getActivityDiscountAmount());
@@ -1362,6 +1364,7 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
             row.add(order.getPayMoney());
 
             row.add(order.getErrandMoneyIsShop());
+            row.add(order.getRemark());
             row.add(order.getPayTime());
             //支付方式  1微信支付  2余额支付  3支付宝支付
             if(order.getPayType()!=null && order.getPayType()==1){

+ 47 - 0
src/main/java/com/sqx/modules/pay/controller/query/CashOutQueryDTO.java

@@ -4,6 +4,7 @@ import com.sqx.common.query.PageQuery;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.springframework.util.StringUtils;
 
 /**
  * 提现信息查询dto
@@ -37,4 +38,50 @@ public class CashOutQueryDTO extends PageQuery {
     private String startTime;
     @ApiModelProperty("查询结束时间")
     private String endTime;
+
+    public String toStrCode() {
+        return
+//                ","+bankCardNo+
+//                ","+bankRealName+
+//                ","+openBank+
+                ","+(zhifubaoName==null?"":zhifubaoName)+
+                ","+(zhifubao==null?"":zhifubao)+
+                ","+(shopName==null?"":shopName)+
+//                ","+userId+
+                ","+(state==null?"":state)+
+//                ","+phone+
+                ","+(type==null?"":type)+
+//                ","+classify+
+                ","+(startTime==null?"":startTime)+
+                ","+(endTime==null?"":endTime)+",";
+    }
+    public String toStrMessage() {
+        StringBuffer stringBuffer=new StringBuffer();
+
+        stringBuffer
+//                .append(bankCardNo==null||bankCardNo==""?"":"银行卡号:"+bankCardNo+";")
+//                .append(bankRealName==null||bankRealName==""?"":"银行卡户主名称:"+bankRealName+";")
+//                .append(openBank==null||openBank==""?"":"银行卡开户行:"+openBank+";")
+                .append(zhifubaoName==null||zhifubaoName==""?"":"支付宝名称:"+zhifubaoName+";")
+                .append(zhifubao==null||zhifubao==""?"":"支付宝账号:"+zhifubao+";")
+                .append(shopName==null||shopName==""?"":"店铺名称:"+shopName+";")
+//                .append(phone==null||phone==""?"":"用户手机号:"+phone+";")
+//                .append(classify==null?"":"支付渠道:"+classify+";")
+                .append(startTime==null||startTime==""?"":"开始时间:"+startTime+";")
+                .append(endTime==null||endTime==""?"":"结束时间:"+endTime+";");
+        if(state!=null){
+            switch (state){
+                case 0: stringBuffer.append("状态:待转账;");break;
+                case 1: stringBuffer.append("状态:已转账;");break;
+                case 2: stringBuffer.append("状态:已拒绝;");break;
+            }
+        }
+        if(StringUtils.hasText(type)){
+            switch (type){
+                case "1": stringBuffer.append("状态:用户提现;");break;
+                case "2": stringBuffer.append("状态:退保证金;");break;
+            }
+        }
+        return stringBuffer.toString();
+    }
 }

+ 35 - 2
src/main/java/com/sqx/modules/pay/controller/query/WalletDetailQuery.java

@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.springframework.format.annotation.DateTimeFormat;
+import org.springframework.util.StringUtils;
 
 import java.util.Date;
 
@@ -26,9 +27,41 @@ public class WalletDetailQuery extends PageQuery {
 
     @ApiModelProperty("查询开始时间, 时间格式yyyy-MM-dd")
     @DateTimeFormat(pattern = "yyyy-MM-dd")
-    private Date startTime;
+    private String startTime;
 
     @ApiModelProperty("查询截止时间, 时间格式yyyy-MM-dd")
     @DateTimeFormat(pattern = "yyyy-MM-dd")
-    private Date endTime;
+    private String endTime;
+
+    @ApiModelProperty("登录人id")
+    private String userId;
+
+    public String toStrMessage() {
+        StringBuilder stringBuilder=new StringBuilder();
+        stringBuilder.append(!StringUtils.hasText(shopName)?"":"店铺名称:"+shopName+";")
+                .append(!StringUtils.hasText(startTime)?"":"开始时间:"+startTime+";")
+                .append(!StringUtils.hasText(endTime)?"":"截止时间:"+endTime+";");
+        if(StringUtils.hasText(type)){
+            switch (type){
+                case "1": stringBuilder.append("状态:充值;");break;
+                case "2": stringBuilder.append("状态:提现;");break;
+            }
+        }
+        if(StringUtils.hasText(classify)){
+            switch (classify){
+                case "1": stringBuilder.append("明细类别:骑手保证金;");break;
+                case "2": stringBuilder.append("明细类别:商户保证金;");break;
+                case "3": stringBuilder.append("明细类别:钱包明细;");break;
+            }
+        }
+        return stringBuilder.toString();
+    }
+
+    public String toStrCode() {
+        return ","+(shopName==null?"":shopName)
+                +","+(type==null?"":type)
+                +","+(classify==null?"":classify)
+                +","+(startTime==null?"":startTime)
+                +","+(endTime==null?"":endTime)+",";
+    }
 }

+ 1 - 1
src/main/java/com/sqx/modules/pay/vo/WalletDetailVO.java

@@ -33,5 +33,5 @@ public class WalletDetailVO {
     private BigDecimal money;
 
     @ApiModelProperty("创建时间")
-    private Date createTime;
+    private String createTime;
 }

+ 7 - 0
src/main/java/com/sqx/modules/shop/controller/app/ShopMoneyController.java

@@ -180,4 +180,11 @@ public class ShopMoneyController extends AbstractController {
         return userMoneyDetailsService.selectShopCashDeposit(sysUserShop.getShopId(), page, limit, classify);
     }
 
+    @GetMapping(value = "/accountEntryManagement")
+    @ApiOperation("入账管理")
+    public Result accountEntryManagement(Integer page, Integer limit,String shopName,String shopPhone,String userPhone,String couponName,String orderNumber,String startTime,String endTime){
+        PageUtils pageUtils = userMoneyDetailsService.accountEntryManagementDetails(page, limit, shopName, shopPhone, userPhone, couponName, orderNumber, startTime, endTime);
+        return Result.success().put("data", pageUtils);
+    }
+
 }

+ 32 - 2
src/main/java/com/sqx/modules/utils/excel/ExportExcelUtils.java

@@ -1,13 +1,20 @@
 package com.sqx.modules.utils.excel;
 
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.ExcelWriter;
+import com.alibaba.excel.write.metadata.WriteSheet;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.poi.ss.usermodel.*;
 import org.apache.poi.xssf.usermodel.*;
 import org.apache.poi.xssf.usermodel.extensions.XSSFCellBorder;
 
 import javax.servlet.http.HttpServletResponse;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
 import java.io.OutputStream;
 import java.net.URLEncoder;
+import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -202,8 +209,31 @@ public class ExportExcelUtils {
         return new int[] { r, g, b };
     }
 
+    public static void writeExcel2(ByteArrayOutputStream os,String fileName, ExcelData excelData) throws Exception {
+        // 文件输出位置
 
+        List<List<String>> headList=new ArrayList<>();
+        List<String> list=excelData.getTitles();
+        for (int i = 0; i < list.size(); i++) {
+            List<String> temList=new ArrayList<>();
+            temList.add(list.get(i));
+            headList.add(temList);
+        }
+        ExcelWriter excelWriter =null;
+        try {
 
-
-
+            excelWriter = EasyExcel.write(os).head(headList).build();
+            // 同一个sheet只要创建一次
+            WriteSheet writeSheet = EasyExcel.writerSheet("sheet1").build();
+            // 调用写入
+            excelWriter.write(excelData.getRows(), writeSheet);
+        } catch (Exception e) {
+            System.out.println("下载模板失败"+e.getMessage());
+        } finally {
+            // 关闭流
+            if (excelWriter != null) {
+                excelWriter.finish();
+            }
+        }
+    }
 }

+ 5 - 0
src/main/java/com/sqx/scheduler/config/SchedulerLock.java

@@ -32,4 +32,9 @@ public interface SchedulerLock {
      * 跑腿订单自动推送锁
      */
     String INDENT_AUTO_PUSH_LOCK = "wm:lock:indent:push";
+
+    /**
+     * 导出锁
+     */
+    String EXPORT_LOCK = "export:lock";
 }

+ 279 - 0
src/main/java/com/sqx/scheduler/export/ExportScheduler.java

@@ -0,0 +1,279 @@
+package com.sqx.scheduler.export;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.sqx.common.utils.SftpUtil;
+import com.sqx.modules.app.entity.RechargeRecord;
+import com.sqx.modules.app.service.RechargeRecordService;
+import com.sqx.modules.app.service.UserMoneyDetailsService;
+import com.sqx.modules.common.service.CommonInfoService;
+import com.sqx.modules.datacentre.query.ShopCenterQuery;
+import com.sqx.modules.datacentre.service.DataCentreService;
+import com.sqx.modules.exportExecl.mapper.ExportJobMapper;
+import com.sqx.modules.exportExecl.model.ExportJob;
+import com.sqx.modules.exportExecl.service.ExportJobService;
+import com.sqx.modules.order.service.AppOrderService;
+import com.sqx.modules.pay.controller.query.CashOutQueryDTO;
+import com.sqx.modules.pay.controller.query.WalletDetailQuery;
+import com.sqx.modules.pay.service.CashOutService;
+import com.sqx.modules.utils.excel.ExcelData;
+import com.sqx.modules.utils.excel.ExportExcelUtils;
+import com.sqx.scheduler.config.SchedulerLock;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.redisson.api.RLock;
+import org.redisson.api.RedissonClient;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.InputStream;
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * 优惠券定时任务
+ *
+ * @author : codingliang
+ * @date : 2024-09-09 12:22
+ */
+@Slf4j
+@Component
+@RequiredArgsConstructor
+@RequestMapping("/admin/aaaaaa")
+public class ExportScheduler {
+
+    private final CommonInfoService commonInfoService;
+    private final RedissonClient redissonClient;
+    private final RedisTemplate redisTemplate;
+    private final ExportJobService exportJobService;
+    private final AppOrderService appOrderService;
+    private final RechargeRecordService rechargeRecordService;
+    private final SftpUtil sftpUtil;
+    private final CashOutService cashOutService;
+    private final UserMoneyDetailsService userMoneyDetailsService;
+    private final DataCentreService dataCentreService;
+
+
+    /**
+     * 将所有超过失效时间的优惠券改为失效状态
+     * 每分钟运行一次
+     */
+    @Async
+//    @Scheduled(cron = "18 */1 * * * ?", zone = "Asia/Shanghai")
+    @GetMapping("excelOrder")
+    public void orderExport() throws Exception {
+        List<ExportJob> exportJobList=exportJobService.list(new QueryWrapper<ExportJob>()
+                .eq("flag",3).last("order by create_time limit 10"));
+        log.info("本次导出数据exportJobList==========="+exportJobList);
+        if (null == exportJobList ||exportJobList.isEmpty()){
+            return;
+        }
+        int runningCount =exportJobService.count(new QueryWrapper<ExportJob>().eq("flag",-1));
+        if (runningCount>=4){
+            //同时执行的任务超过4条,不再新增任务
+            return;
+        }
+        for(ExportJob exportJob:exportJobList){
+            long bgTime = System.currentTimeMillis();
+            String jobExecuteKey = SchedulerLock.EXPORT_LOCK + ":" + exportJob.getExportId();
+            String jobExecuteRedisKey = SchedulerLock.EXPORT_LOCK +":R:" + exportJob.getExportId();
+            RLock lock = redissonClient.getLock(jobExecuteKey);
+            if (lock.tryLock(0, 5, TimeUnit.SECONDS)) {
+                boolean isRedisKey = redisTemplate.hasKey(jobExecuteRedisKey);
+                //rediskey避免重复导出
+                if(isRedisKey){
+                    log.info(exportJob.getExportId()+"已执行,跳过");
+                    continue;
+                }
+                redisTemplate.opsForValue().set(jobExecuteRedisKey, "LOCK", 5, TimeUnit.MINUTES);
+                //设置为执行中
+                exportJob.setFlag(-1);
+                exportJob.setUpdateTime(new Date());
+                exportJobService.updateById(exportJob);
+                String fileName=exportJob.getFileName();
+                String fileType=exportJob.getFileType();
+                InputStream inputStream=null;
+                ByteArrayOutputStream os = new ByteArrayOutputStream();
+                try {
+                    ExcelData excelData=new ExcelData();
+                    if("order".equals(fileType)){
+                        excelData=getOrderExcelData(exportJob);
+                    }else if("recharge".equals(fileType)){
+                        excelData=getRechargeOrderExcelData(exportJob);
+                    }else if("payouts".equals(fileType)){
+                        excelData=getPayoutsExcelData(exportJob);
+                    }else if("deposit".equals(fileType)){
+                        excelData=getDepositExcelData(exportJob);
+                    }else if("shopCenter".equals(fileType)){
+                        excelData=getShopCenterExcelData(exportJob);
+                    }else{
+                        continue;
+                    }
+                    String value=commonInfoService.findOne(430).getValue();
+                    ExportExcelUtils.writeExcel2(os,fileName,excelData);
+                    byte[] buffer = os.toByteArray();
+                    inputStream = new ByteArrayInputStream(buffer);
+                    double fileSize = os.size();
+                    double fileSizeKB = new BigDecimal(fileSize/1024).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue(); //转换单位为KB
+                    exportJob.setFileSize(String.valueOf(fileSizeKB));
+                    exportJob.setFlag(1);
+                    exportJob.setUpdateTime(new Date());
+                    sftpUtil.login();
+                    sftpUtil.upload(value,fileName,inputStream);
+                    exportJobService.updateById(exportJob);
+                } catch (Exception e) {
+                    exportJob.setUpdateTime(new Date());
+                    exportJob.setFlag(2);
+                    exportJobService.updateById(exportJob);
+                    log.error(e.toString());
+                } finally {
+                    try {
+                        if (lock.isLocked()) {
+                            lock.unlock();
+                        }
+                        if(os!=null){
+                            os.close();
+                        }
+                        if(inputStream!=null){
+                            inputStream.close();
+                        }
+                        if(sftpUtil.isConnected()){
+                            sftpUtil.logout();
+                        }
+                    } catch (RuntimeException re) {
+                        log.error("报表解锁失败");
+                    }
+                }
+            }
+            long edTime = System.currentTimeMillis();
+            log.info("执行:通用数据导出定时任务"+exportJob.getExportId()+"......执行任务完成,执行时长:{} s", (edTime - bgTime) / 1000);
+        }
+    }
+    //订单导出
+    private ExcelData getOrderExcelData(ExportJob exportJob){
+        String[] conditions=exportJob.getConditions().split(",",-1);
+        Integer status=null;
+        if(!"".equals(conditions[1])){
+            status= Integer.valueOf(conditions[1]);
+        }
+        String phone=conditions[2];
+        Long shopId=null;
+        if(!"".equals(conditions[3])){
+            shopId= Long.valueOf(conditions[3]);
+        }
+        String userName=conditions[4];
+        String orderNumber=conditions[5];
+
+        Integer orderType=null;
+        if(!"".equals(conditions[6])){
+            orderType= Integer.valueOf(conditions[6]);
+        }
+        String shopName=conditions[7];
+        String riderPhone=conditions[8];
+        String startTime=conditions[9];
+        String endTime=conditions[10];
+        String payStartTime=conditions[11];
+        String payEndTime=conditions[12];
+        ExcelData excelData = appOrderService.excelAllOrderAdmin(status, phone, shopId, userName, orderNumber, orderType, shopName, riderPhone, startTime, endTime,payStartTime,payEndTime);
+
+        return excelData;
+    }
+
+    //充值记录导出
+    private ExcelData getRechargeOrderExcelData(ExportJob exportJob){
+        String[] conditions=exportJob.getConditions().split(",",-1);
+        String rechargeOrder=conditions[1];
+        String acount=conditions[2];
+        QueryWrapper qw=new QueryWrapper<RechargeRecord>();
+        if(StringUtils.hasText(rechargeOrder)){
+            qw.eq("order_no",rechargeOrder);
+        }
+        if(StringUtils.hasText(acount)){
+            qw.eq("user_phone",acount);
+        }
+        ExcelData data = new ExcelData();
+        data.setName("订单列表");
+        List<String> titles = new ArrayList();
+        titles.add("用户id");titles.add("编号");titles.add("充值金额");titles.add("充值前余额");
+        titles.add("充值后余额"); titles.add("被充值账号(手机号)");titles.add("被充值名称");titles.add("被充值昵称");
+        titles.add("被充值头像"); titles.add("更新时间");titles.add("充值时间");titles.add("充值人账号");
+        titles.add("备注");
+        data.setTitles(titles);
+        List<RechargeRecord> recordList=rechargeRecordService.list(qw);
+        List<List<Object>> rows = new ArrayList();
+        for (RechargeRecord record:recordList){
+            List<Object> row = new ArrayList();
+            row.add(record.getUserId());
+            row.add(record.getOrderNo());
+            row.add(record.getAmount());
+            row.add(record.getOldMoney());
+            row.add(record.getBalance());
+            row.add(record.getUserPhone());
+            row.add(record.getUserName());
+            row.add(record.getUserNick());
+            row.add(record.getUserAvatar());
+            row.add(record.getUpdateTime());
+            row.add(record.getCreateTime());
+            row.add(record.getAccount());
+            row.add(record.getRemark());
+            rows.add(row);
+        }
+        data.setRows(rows);
+        return data;
+    }
+
+    //提现管理导出
+    private ExcelData getPayoutsExcelData(ExportJob exportJob){
+        String[] conditions=exportJob.getConditions().split(",",-1);
+        CashOutQueryDTO queryDTO =new CashOutQueryDTO();
+        queryDTO.setZhifubaoName(conditions[1]);
+        queryDTO.setZhifubao(conditions[2]);
+        queryDTO.setShopName(conditions[3]);
+        if(!"".equals(conditions[4])){
+            queryDTO.setState(Integer.valueOf(conditions[4]));
+        }
+        queryDTO.setType(conditions[5]);
+        queryDTO.setStartTime(conditions[6]);
+        queryDTO.setEndTime(conditions[7]);
+        ExcelData excelData = cashOutService.excelPayDetails(queryDTO);
+        return excelData;
+    }
+
+    //导出保证金记录
+    private ExcelData getDepositExcelData(ExportJob exportJob){
+        String[] conditions=exportJob.getConditions().split(",",-1);
+        WalletDetailQuery queryDTO =new WalletDetailQuery();
+        queryDTO.setShopName(conditions[1]);
+        queryDTO.setType(conditions[2]);
+        queryDTO.setClassify(conditions[3]);
+        queryDTO.setStartTime(conditions[4]);
+        queryDTO.setEndTime(conditions[5]);
+        ExcelData excelData = userMoneyDetailsService.excelWalletDetails(queryDTO);
+
+        return excelData;
+    }
+
+    //导出商铺收益排行
+    private ExcelData getShopCenterExcelData(ExportJob exportJob){
+        String[] conditions=exportJob.getConditions().split(",",-1);
+        ShopCenterQuery query =new ShopCenterQuery();
+        query.setShopType(conditions[3]);
+        query.setStartTime(conditions[1]);
+        query.setEndTime(conditions[2]);
+        query.setDate(conditions[4]);
+        query.setDateType(conditions[5]);
+        return dataCentreService.excelShopCenter(query);
+    }
+}

+ 46 - 0
src/main/resources/application-dev.yml

@@ -108,3 +108,49 @@ secure-api:
 
 mp:
     temp: true
+sftp:
+    username: export
+    password: Waimai2024#
+    host: 172.16.20.108
+    port: 22
+
+dynamic:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://172.16.20.104:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT
+#    url: jdbc:mysql://172.16.20.108:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT
+    username: root
+    password: ch@2025.wm
+#    password: chuanghai@2024
+    initial-size: 15
+    max-active: 100
+    min-idle: 10
+    max-wait: 60000
+    pool-prepared-statements: true
+    max-pool-prepared-statement-per-connection-size: 20
+    time-between-eviction-runs-millis: 60000
+    min-evictable-idle-time-millis: 300000
+    #Oracle需要打开注释
+    #validation-query: SELECT 1 FROM DUAL
+    test-while-idle: true
+    test-on-borrow: false
+    test-on-return: false
+    stat-view-servlet:
+        enabled: true
+        url-pattern: /druid/*
+        #login-username: admin
+        #login-password: admin
+    filter:
+        stat:
+            log-slow-sql: true
+            slow-sql-millis: 1000
+            merge-sql: false
+        wall:
+            config:
+                multi-statement-allow: true
+
+# minio配置
+minio:
+    endpoint: http://172.16.20.105:9000
+    accessKey: YTDm6Wtjf1q0LbGi2SKK
+    secretKey: MU1KozgxyknGDPwcKuvCEuhZwL37wbryHOFRW5Xt
+    bucket: wmfile

+ 46 - 0
src/main/resources/application-prod.yml

@@ -109,3 +109,49 @@ secure-api:
 
 mp:
     temp: false
+sftp:
+    username: export
+    password: Waimai2024#
+    host: 172.16.20.105
+    port: 22
+#查询备用数据库
+dynamic:
+    driver-class-name: com.mysql.cj.jdbc.Driver
+    url: jdbc:mysql://172.16.20.104:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT
+    #    url: jdbc:mysql://172.16.20.108:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT
+    username: root
+    password: ch@2025.wm
+    #    password: chuanghai@2024
+    initial-size: 15
+    max-active: 100
+    min-idle: 10
+    max-wait: 60000
+    pool-prepared-statements: true
+    max-pool-prepared-statement-per-connection-size: 20
+    time-between-eviction-runs-millis: 60000
+    min-evictable-idle-time-millis: 300000
+    #Oracle需要打开注释
+    #validation-query: SELECT 1 FROM DUAL
+    test-while-idle: true
+    test-on-borrow: false
+    test-on-return: false
+    stat-view-servlet:
+        enabled: true
+        url-pattern: /druid/*
+        #login-username: admin
+        #login-password: admin
+    filter:
+        stat:
+            log-slow-sql: true
+            slow-sql-millis: 1000
+            merge-sql: false
+        wall:
+            config:
+                multi-statement-allow: true
+
+# minio配置
+minio:
+    endpoint: http://172.16.20.105:9000
+    accessKey: YTDm6Wtjf1q0LbGi2SKK
+    secretKey: MU1KozgxyknGDPwcKuvCEuhZwL37wbryHOFRW5Xt
+    bucket: wmfile

+ 52 - 13
src/main/resources/mapper/dataCentre/dataCenterMapper.xml

@@ -186,14 +186,20 @@
 
     <select id="selectNewShopCount" resultType="int">
         select count(*) from goods_shop where 1 = 1
-        <if test="dateType=='day'">
-            and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
+        <if test="query.dateType=='day'">
+            and date_format(create_time,'%Y-%m-%d')=date_format(#{query.date},'%Y-%m-%d')
         </if>
-        <if test="dateType=='month'">
-            and date_format(create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
+        <if test="query.dateType=='month'">
+            and date_format(create_time,'%Y-%m')=date_format(#{query.date},'%Y-%m')
         </if>
-        <if test="dateType=='year'">
-            and date_format(create_time,'%Y')=date_format(#{date},'%Y')
+        <if test="query.dateType=='year'">
+            and date_format(create_time,'%Y')=date_format(#{query.date},'%Y')
+        </if>
+        <if test="query.endTime != null and query.endTime != ''">
+            and create_time <![CDATA[<=]]> #{query.endTime}
+        </if>
+        <if test="query.startTime != null and query.startTime != ''">
+            and create_time >= #{query.startTime}
         </if>
     </select>
 
@@ -203,17 +209,50 @@
         @rank_num := @rank_num + 1 AS rankNum
         FROM
         ( SELECT @rank_num := 0 ) r,
-        ( SELECT ifnull( sum( pay_money ), 0 ) AS shopMoney, tor.shop_id , u.shop_name
+        ( SELECT ifnull( sum( pay_money ), 0 ) AS shopMoney, tor.shop_id , u.shop_name,gp.id as shopType,gp.shop_type_name as shopTypeName
         FROM tb_order tor left join goods_shop u on tor.shop_id = u.shop_id
+        left join shop_type gp on  gp.id=u.shop_type_id
         WHERE tor.shop_id IS NOT NULL and tor.status = 4
-        <if test="dateType=='day'">
-            and date_format(tor.pay_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
+        <if test="query.startTime != null and query.startTime !=''">
+            and tor.pay_time >= #{query.startTime}
         </if>
-        <if test="dateType=='month'">
-            and date_format(tor.pay_time,'%Y-%m')=date_format(#{date},'%Y-%m')
+        <if test="query.endTime != null and query.endTime != ''">
+            and tor.pay_time <![CDATA[<=]]> #{query.endTime}
         </if>
-        <if test="dateType=='year'">
-            and date_format(tor.pay_time,'%Y')=date_format(#{date},'%Y')
+        <if test="query.shopType != null and query.shopType != '' ">
+            and gp.id = #{query.shopType}
+        </if>
+        <if test="query.dateType=='day'">
+            and date_format(tor.pay_time,'%Y-%m-%d')=date_format(#{query.date},'%Y-%m-%d')
+        </if>
+        <if test="query.dateType=='month'">
+            and date_format(tor.pay_time,'%Y-%m')=date_format(#{query.date},'%Y-%m')
+        </if>
+        <if test="query.dateType=='year'">
+            and date_format(tor.pay_time,'%Y')=date_format(#{query.date},'%Y')
+        </if>
+        GROUP BY tor.shop_id ) a
+        ORDER BY shopMoney DESC
+    </select>
+
+    <select id="excelShopCenter" resultType="com.sqx.modules.order.entity.TbOrder">
+        SELECT
+        *,
+        @rank_num := @rank_num + 1 AS Rank
+        FROM
+        ( SELECT @rank_num := 0 ) r,
+        ( SELECT ifnull( sum( pay_money ), 0 ) AS shopMoney, tor.shop_id , u.shop_name,gp.id as shopType,gp.shop_type_name as shopTypeName
+        FROM tb_order tor left join goods_shop u on tor.shop_id = u.shop_id
+        left join shop_type gp on  gp.id=u.shop_type_id
+        WHERE tor.shop_id IS NOT NULL and tor.status = 4
+        <if test="query.startTime != null and query.startTime !=''">
+            and tor.pay_time >= #{query.startTime}
+        </if>
+        <if test="query.endTime != null and query.endTime != ''">
+            and tor.pay_time <![CDATA[<=]]> #{query.endTime}
+        </if>
+        <if test="query.shopType != null and query.shopType != '' ">
+            and gp.id = #{query.shopType}
         </if>
         GROUP BY tor.shop_id ) a
         ORDER BY shopMoney DESC

+ 59 - 2
src/main/resources/mapper/order/OrderMapper.xml

@@ -149,7 +149,7 @@
         shopPhone,
         tiu.nick_name as riderNickName,tiu.phone as riderPhone,ti.indent_id as indentId,ti.is_rider as isRider,
         ti.rider_user_id as riderUserId, tcu.money as couponMoney,
-        apr.discount_amount as activityDiscountAmount, ai.title activityTitle
+        apr.discount_amount as activityDiscountAmount, ai.title activityTitle,ogg.detail,ogg.sumPrice
         from tb_order tor
         left join tb_user tu on tor.user_id = tu.user_id
         left join goods_shop gs on tor.shop_id = gs.shop_id
@@ -158,6 +158,8 @@
         left join tb_coupon_user tcu on tor.coupon_id = tcu.id
         left join activity_part_record apr on apr.order_id = tor.order_id
         left join activity ai on ai.id = apr.activity_id
+        left join (  select @a:=0,order_id ,group_concat(@a:=@a+1,".商品名:",goods_name,",数量:",goods_num,",规格:",sku_message) detail,sum(goods_num*goods_price) sumPrice  from order_goods og group by order_id
+        ) ogg on ogg.order_id =tor.order_id
         where 1 = 1
         <if test="riderPhone!=null and riderPhone!=''">
             and tiu.phone =#{riderPhone}
@@ -184,7 +186,56 @@
             and tor.shop_id = #{shopId}
         </if>
         <if test="orderType!=null">
-            and tor.order_type = #{orderType}
+            and tor.order_type_extra = #{orderType}
+        </if>
+        <if test="startTime!=null and startTime!=''">
+            and date_format(tor.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
+        </if>
+        <if test="endTime!=null and endTime!='' ">
+            and date_format(tor.create_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
+        </if>
+        <if test="payStartTime != null and payStartTime != ''">
+            and date_format(tor.pay_time,'%Y-%m-%d') >= date_format(#{payStartTime},'%Y-%m-%d')
+        </if>
+        <if test="payEndTime != null and payEndTime != '' ">
+            and date_format(tor.pay_time,'%Y-%m-%d') &lt;= date_format(#{payEndTime},'%Y-%m-%d')
+        </if>
+        order by tor.pay_time desc, tor.create_time desc
+    </select>
+
+    <select id="excelAllOrderAdminCount" resultType="java.lang.Integer">
+        select count(1) from tb_order tor
+        left join tb_user tu on tor.user_id = tu.user_id
+        left join goods_shop gs on tor.shop_id = gs.shop_id
+        left join tb_indent ti on tor.order_id = ti.order_id
+        left join tb_user tiu on tiu.user_id = ti.rider_user_id
+        where 1 = 1
+        <if test="riderPhone!=null and riderPhone!=''">
+            and tiu.phone =#{riderPhone}
+        </if>
+        <if test="shopName!=null and shopName!=''">
+            and gs.shop_name like concat('%',#{shopName},'%')
+        </if>
+        <if test="userName!=null and userName!=''">
+            and tor.user_name like concat('%',#{userName},'%')
+        </if>
+        <if test="phone!=null and phone!=''">
+            and tor.phone like concat('%',#{phone},'%')
+        </if>
+        <if test="orderNumber!=null and orderNumber!=''">
+            and tor.order_number = #{orderNumber}
+        </if>
+        <if test="status!=null and status!=-1 and status!=1">
+            and tor.status = #{status}
+        </if>
+        <if test="status!=null and status==1">
+            and tor.status in (1,2)
+        </if>
+        <if test="shopId!=null">
+            and tor.shop_id = #{shopId}
+        </if>
+        <if test="orderType!=null">
+            and tor.order_type_extra = #{orderType}
         </if>
         <if test="startTime!=null and startTime!=''">
             and date_format(tor.create_time,'%Y-%m-%d') >= date_format(#{startTime},'%Y-%m-%d')
@@ -192,6 +243,12 @@
         <if test="endTime!=null and endTime!='' ">
             and date_format(tor.create_time,'%Y-%m-%d') &lt;= date_format(#{endTime},'%Y-%m-%d')
         </if>
+        <if test="payStartTime != null and payStartTime != ''">
+            and date_format(tor.pay_time,'%Y-%m-%d') >= date_format(#{payStartTime},'%Y-%m-%d')
+        </if>
+        <if test="payEndTime != null and payEndTime != '' ">
+            and date_format(tor.pay_time,'%Y-%m-%d') &lt;= date_format(#{payEndTime},'%Y-%m-%d')
+        </if>
         order by tor.pay_time desc, tor.create_time desc
     </select>
 

+ 190 - 28
src/main/resources/mapper/userMoney/UserMoneyDetailsMapper.xml

@@ -3,16 +3,27 @@
 <mapper namespace="com.sqx.modules.app.dao.UserMoneyDetailsDao">
 
     <select id="selectUserMoneyDetails" resultType="com.sqx.modules.app.entity.UserMoneyDetails">
-        select * from user_money_details where user_id = #{userId} and classify = #{classify} order by create_time desc
+        select *
+        from user_money_details
+        where user_id = #{userId}
+          and classify = #{classify}
+        order by create_time desc
     </select>
 
     <select id="selectShopCashDeposit" resultType="com.sqx.modules.app.entity.UserMoneyDetails">
-        select * from user_money_details where shop_id = #{shopId} and classify = #{classify}
+        select *
+        from user_money_details
+        where shop_id = #{shopId}
+          and classify = #{classify}
         order by create_time desc
     </select>
 
     <select id="selectShopCashDepositList" resultType="com.sqx.modules.app.entity.UserMoneyDetails">
-        select * from user_money_details where shop_id = #{shopId} and classify = 2 order by create_time desc
+        select *
+        from user_money_details
+        where shop_id = #{shopId}
+          and classify = 2
+        order by create_time desc
     </select>
 
     <sql id="walletQueryCondition">
@@ -29,48 +40,199 @@
                 and umd.classify = #{query.classify}
             </if>
 
-            <if test="query.startTime != null">
+            <if test="query.startTime != null and query.startTime != ''">
                 and umd.create_time >= #{query.startTime}
             </if>
 
-            <if test="query.endTime != null">
+            <if test="query.endTime != null and query.endTime != ''">
                 and umd.create_time <![CDATA[<=]]> #{query.endTime}</if>
         </where>
     </sql>
 
     <select id="walletDetailList" resultType="com.sqx.modules.pay.vo.WalletDetailVO">
         select
-            umd.id,
-            gs.shop_name,
-            umd.title,
-            umd.content,
-            umd.type,
-            umd.classify,
-            umd.money,
-            umd.create_time
+        umd.id,
+        gs.shop_name,
+        umd.title,
+        umd.content,
+        umd.type,
+        umd.classify,
+        umd.money,
+        umd.create_time
+        from
+        user_money_details umd
+        left join goods_shop gs on gs.shop_id = umd.shop_id
+        <include refid="walletQueryCondition"></include>
+        order by umd.create_time desc
+    </select>
+
+    <select id="excelWalletDetails" resultType="com.sqx.modules.pay.vo.WalletDetailVO">
+        select
+        umd.id,
+        gs.shop_name,
+        umd.title,
+        umd.content,
+        umd.type,
+        umd.classify,
+        umd.money,
+        umd.create_time
         from
-            user_money_details umd
-            left join goods_shop gs on gs.shop_id = umd.shop_id
+        user_money_details umd
+        left join goods_shop gs on gs.shop_id = umd.shop_id
         <include refid="walletQueryCondition"></include>
         order by umd.create_time desc
     </select>
 
     <select id="walletDetailStatistics" resultType="java.math.BigDecimal">
         select
-            sum(o.amount)
+        sum(o.amount)
+        from
+        (
+        select
+        case
+        when umd.type = 1 then umd.money
+        else -umd.money
+        end as amount
         from
-            (
-                select
-                    case
-                        when umd.type = 1 then umd.money
-                        else -umd.money
-                    end as amount
-                from
-                    user_money_details umd
-                left join goods_shop gs on gs.shop_id = umd.shop_id
-                <include refid="walletQueryCondition"></include>
-                order by umd.create_time desc
-            ) o
+        user_money_details umd
+        left join goods_shop gs on gs.shop_id = umd.shop_id
+        <include refid="walletQueryCondition"></include>
+        order by umd.create_time desc
+        ) o
     </select>
 
+    <select id="accountEntryManagementDetailsList" resultType="com.sqx.modules.app.entity.UserMoneyDetails">
+        SELECT
+        umd2.id,
+        umd2.orderNumber,
+        umd2.user_id as userId,
+        umd2.shop_id as shopId,
+        umd2.title,
+        umd2.content,
+        umd2.type,
+        umd2.classify,
+        umd2.money,
+        umd2.create_time as createTime,
+        umd2.state,
+        tbu.user_name as userName,
+        tbu.phone as userPhone,
+        gs.shop_name as shopName,
+        gs.phone as shopPhone,
+        tcu.coupon_name as couponName,
+        tcu.money as couponMoney,
+        apr.discount_amount as activityDiscountAmount,
+        tbo.errand_money as errandMoney
+        FROM
+        (
+        SELECT
+        RIGHT( umd.title, 18 ) AS orderNumber,
+        umd.id,
+        umd.user_id,
+        umd.shop_id,
+        umd.title,
+        umd.content,
+        umd.type,
+        umd.classify,
+        umd.money,
+        umd.create_time,
+        umd.state,
+        umd.children_id
+        FROM
+        `user_money_details` umd
+        WHERE
+        umd.type = 1
+        AND umd.classify = 3
+        AND umd.shop_id IS NOT NULL
+        AND umd.state=2
+        AND umd.title LIKE '商户订单收入' '%'
+        ) umd2
+        LEFT JOIN tb_order tbo on tbo.order_number=umd2.orderNumber
+        LEFT JOIN tb_user tbu on tbu.user_id=tbo.user_id
+        LEFT JOIN goods_shop gs on gs.shop_id=tbo.shop_id
+        LEFT JOIN tb_coupon_user tcu on tbo.coupon_id = tcu.id
+        LEFT JOIN activity_part_record apr on apr.order_id = tbo.order_id
+        where 1 = 1
+        <if test="shopName != null and shopName != ''">
+            and gs.shop_name like  concat("%", #{shopName}, "%")
+        </if>
+
+        <if test="shopPhone != null and shopPhone != ''">
+            and gs.phone= #{shopPhone}
+        </if>
+
+        <if test="userPhone != null and userPhone != ''">
+            and tbu.phone=#{userPhone}
+        </if>
+
+        <if test="couponName != null and couponName != ''">
+            and tcu.coupon_name like  concat("%", #{couponName}, "%")
+        </if>
+
+        <if test="orderNumber != null and orderNumber != ''">
+            and tbo.order_number = #{orderNumber}
+        </if>
+
+        <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
+            and umd2.create_time >= #{startTime} and #{endTime} >= umd2.create_time
+        </if>
+        ORDER BY umd2.id desc
+        LIMIT #{limit} OFFSET #{row}
+    </select>
+    <select id="accountEntryManagementDetailsCount" resultType="java.lang.Integer">
+        SELECT
+        count(*)
+        FROM
+        (
+        SELECT
+        RIGHT( umd.title, 18 ) AS orderNumber,
+        umd.id,
+        umd.user_id,
+        umd.shop_id,
+        umd.title,
+        umd.content,
+        umd.type,
+        umd.classify,
+        umd.money,
+        umd.create_time,
+        umd.state,
+        umd.children_id
+        FROM
+        `user_money_details` umd
+        WHERE
+        umd.type = 1
+        AND umd.classify = 3
+        AND umd.shop_id IS NOT NULL
+        AND umd.state=2
+        AND umd.title LIKE '商户订单收入' '%'
+        ) umd2
+        LEFT JOIN tb_order tbo on tbo.order_number=umd2.orderNumber
+        LEFT JOIN tb_user tbu on tbu.user_id=tbo.user_id
+        LEFT JOIN goods_shop gs on gs.shop_id=tbo.shop_id
+        LEFT JOIN tb_coupon_user tcu on tbo.coupon_id = tcu.id
+        LEFT JOIN activity_part_record apr on apr.order_id = tbo.order_id
+        where 1 = 1
+        <if test="shopName != null and shopName != ''">
+            and gs.shop_name like concat("%", #{shopName}, "%")
+        </if>
+
+        <if test="shopPhone != null and shopPhone != ''">
+            and gs.phone= #{shopPhone}
+        </if>
+
+        <if test="userPhone != null and userPhone != ''">
+            and tbu.phone=#{userPhone}
+        </if>
+
+        <if test="couponName != null and couponName != ''">
+            and tcu.coupon_name like concat("%", #{couponName}, "%")
+        </if>
+
+        <if test="orderNumber != null and orderNumber != ''">
+            and tbo.order_number = #{orderNumber}
+        </if>
+
+        <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
+            and umd2.create_time >= #{startTime} and #{endTime} >= umd2.create_time
+        </if>
+    </select>
 </mapper>