Jelajahi Sumber

Merge branch 'dev/db-up' of mxys/mxys_backend into dev/cache

lzl 8 bulan lalu
induk
melakukan
b3dbf6b787

File diff ditekan karena terlalu besar
+ 4654 - 0
db/tcwm.log.2025-10-10.0


File diff ditekan karena terlalu besar
+ 6977 - 0
db/tcwm.log.2025-10-12.13.30


+ 2 - 0
src/main/java/com/sqx/modules/order/dao/AppOrderDao.java

@@ -112,4 +112,6 @@ public interface AppOrderDao extends BaseMapper<TbOrder> {
     List<TbOrder> changeTimeOutOrder(@Param("time") long time);
 
     IPage<GoodsSkuSalesCountVO> getGoodsSkuSalesCount(Page<GoodsSkuSalesCountVO> pages, GoodsSkuQuery query);
+
+    List<TbOrder> temp();
 }

+ 34 - 16
src/main/java/com/sqx/modules/order/service/impl/AppAppOrderServiceImpl.java

@@ -1033,14 +1033,22 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
         BigDecimal rider = new BigDecimal(0);
         if (ObjectUtils.isNotEmpty(order.getOrderTypeExtra())&&order.getOrderTypeExtra()==2) {
             //        获取骑手额外配送费
-            CommonInfo commonInfo = commonInfoService.findOne(443);
-            if (ObjectUtils.isNotEmpty(commonInfo)) {
-                rider =rider.add(new BigDecimal(commonInfo.getValue()));
-                shopMoney=shopMoney.subtract(rider);
+            //        配送费大于等于1.5就不需要骑手额外配送费
+            if (order.getErrandMoney().doubleValue()<1.5) {
+                CommonInfo commonInfo = commonInfoService.findOne(443);
+                if (ObjectUtils.isNotEmpty(commonInfo)) {
+                    rider =rider.add(new BigDecimal(commonInfo.getValue()));
+                    shopMoney=shopMoney.subtract(rider);
+                }
+                order.setShopIncomeMoney(shopMoney.setScale(2, BigDecimal.ROUND_DOWN));
+                log.info("preOrder==>[{}],订单计算店铺预计收益,商家佣金比例[{}],本单用户应付金额[{}],本单店铺预计收益[{}],骑手额外配送费[{}]",
+                        order.getOrderId(), shopRate, sumMoney, order.getShopIncomeMoney(),rider);
+            }else {
+                order.setShopIncomeMoney(shopMoney.setScale(2, BigDecimal.ROUND_DOWN));
+                log.info("preOrder==>[{}],订单计算店铺预计收益,商家佣金比例[{}],本单用户应付金额[{}],本单店铺预计收益[{}]",
+                        order.getOrderId(), shopRate, sumMoney, order.getShopIncomeMoney());
             }
-            order.setShopIncomeMoney(shopMoney.setScale(2, BigDecimal.ROUND_DOWN));
-            log.info("preOrder==>[{}],订单计算店铺预计收益,商家佣金比例[{}],本单用户应付金额[{}],本单店铺预计收益[{}],骑手额外配送费[{}]",
-                    order.getOrderId(), shopRate, sumMoney, order.getShopIncomeMoney(),rider);
+
         }else {
             order.setShopIncomeMoney(shopMoney.setScale(2, BigDecimal.ROUND_DOWN));
             log.info("preOrder==>[{}],订单计算店铺预计收益,商家佣金比例[{}],本单用户应付金额[{}],本单店铺预计收益[{}]",
@@ -1804,11 +1812,15 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
             BigDecimal rider = new BigDecimal(0);
             if (ObjectUtils.isNotEmpty(order.getOrderTypeExtra())&&order.getOrderTypeExtra()==2) {
                 //        获取骑手额外配送费
-                CommonInfo commonInfo = commonInfoService.findOne(443);
-                if (ObjectUtils.isNotEmpty(commonInfo)) {
-                    rider =rider.add(new BigDecimal(commonInfo.getValue()));
-                    shopMoney=shopMoney.subtract(rider);
+                //        配送费大于等于1.5就不需要骑手额外配送费
+                if (order.getErrandMoney().doubleValue()<1.5) {
+                    CommonInfo commonInfo = commonInfoService.findOne(443);
+                    if (ObjectUtils.isNotEmpty(commonInfo)) {
+                        rider =rider.add(new BigDecimal(commonInfo.getValue()));
+                        shopMoney=shopMoney.subtract(rider);
+                    }
                 }
+
             }
 
             shopMoney = (shopMoney.setScale(2, BigDecimal.ROUND_DOWN));
@@ -2174,10 +2186,13 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
         BigDecimal rider = new BigDecimal(0);
         if (ObjectUtils.isNotEmpty(tbOrder.getOrderTypeExtra())&&tbOrder.getOrderTypeExtra()==2) {
             //        获取骑手额外配送费
-            CommonInfo commonInfo = commonInfoService.findOne(443);
-            if (ObjectUtils.isNotEmpty(commonInfo)) {
-                rider =rider.add(new BigDecimal(commonInfo.getValue()));
-                shopMoney=shopMoney.subtract(rider);
+            //        配送费大于等于1.5就不需要骑手额外配送费
+            if (tbOrder.getErrandMoney().doubleValue()<1.5) {
+                CommonInfo commonInfo = commonInfoService.findOne(443);
+                if (ObjectUtils.isNotEmpty(commonInfo)) {
+                    rider = rider.add(new BigDecimal(commonInfo.getValue()));
+                    shopMoney = shopMoney.subtract(rider);
+                }
             }
             log.info("订单id【{}】,骑手额外配送费【{}】", orderId,rider);
         }
@@ -2213,7 +2228,10 @@ public class AppAppOrderServiceImpl extends ServiceImpl<AppOrderDao, TbOrder> im
         contentBuffer.append("平台服务费:").append(pingRate.setScale(2, BigDecimal.ROUND_DOWN)).append(",");
         contentBuffer.append("短信服务费:").append(smsSendMoney.setScale(2, BigDecimal.ROUND_DOWN)).append(",");
         if (ObjectUtils.isNotEmpty(tbOrder.getOrderTypeExtra())&&tbOrder.getOrderTypeExtra()==2) {
-            contentBuffer.append("骑手额外配送费:").append(rider.setScale(2, BigDecimal.ROUND_DOWN)).append(",");
+            //        配送费大于等于1.5就不需要骑手额外配送费
+            if (tbOrder.getErrandMoney().doubleValue()<1.5) {
+                contentBuffer.append("骑手额外配送费:").append(rider.setScale(2, BigDecimal.ROUND_DOWN)).append(",");
+            }
         }
         contentBuffer.append("到账金额:").append(shopMoney.setScale(2, BigDecimal.ROUND_DOWN));
 

+ 163 - 0
src/main/resources/application-mysql8.yml

@@ -0,0 +1,163 @@
+spring:
+    datasource:
+        type: com.alibaba.druid.pool.DruidDataSource
+        druid:
+            driver-class-name: com.mysql.cj.jdbc.Driver
+            url: jdbc:mysql://172.22.45.21:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT&useAffectedRows=true
+            username: root
+            password: Chuanghai2024.
+            initial-size: 10
+            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: CH
+                login-password: CH_2025@.
+                allow: ""
+            filter:
+                stat:
+                    log-slow-sql: true
+                    slow-sql-millis: 1000
+                    merge-sql: false
+                wall:
+                    config:
+                        multi-statement-allow: true
+    redis:
+        host: 172.16.20.108
+        port: 6379
+        password: chuanghai_2024.
+        database: 3
+        timeout: 5000
+        jedis:
+            pool:
+                enabled: true
+                max-active: 20
+                min-idle: 0
+                max-idle: 10
+                max-wait: -1
+secure-api:
+    # 开启SecureApi功能,如果为false则其余配置项均不生效
+    enabled: true
+    # 开启加解密日志打印,会打印出接口名、加密模式、算法、明文和密文等信息
+    show-log: true
+    url-safe: true
+    # 加密模式,common和session_key可选,session_key是会话密钥模式,用于每次请求都使用不同的密钥,需要前端配合
+    mode: common
+    # 加密算法
+    cipher-algorithm: aes_cbc_pkcs5
+    # 对称算法用于加解密的密钥,Base64格式,cipher-algorithm选择对称加密算法时配置,也可为空,组件会随机生成一个
+    key: oURKtBcNU6axnNoebKkuPqkCn6ivhE9qbg9FpeNnfpo=
+    # 对称算法用于加解密的偏移量,Base64格式,cipher-algorithm选择对称加密算法时配置,也可为空,组件会随机生成一个
+    iv: eW1xeThJSkprcEZUTGh1Ng==
+    # 需要加密的接口路径匹配,遵循spring boot拦截器的正则规则,留空或者不配置代表不使用url匹配,只对注解的接口进行解密
+    encrypt-url:
+        # 配置了此项,接口有无注解都将进行返回值加密
+        include-urls: /**
+        # 即使配置了排除,注解的优先级也高于此项
+        exclude-urls:
+            - /captcha.jpg
+            - /app/wxPay/notifyMp
+            - /app/wxPay/notify
+            - /app/wxPay/notifyJsApi
+            - /app/wxPay/notifyShop
+            - /app/wxPay/notifyJsApiShop
+            - /app/wxPay/notifyMpShop
+            - /pay/open/notify
+            - /app/new-pay/wechat-pay/notify
+            - /chatSocket/**
+            - /websocket/**
+            - /alioss/**
+            - /swagger-ui.html
+            - /v2/api-docs
+            - /swagger-resources/**
+            - /webjars/**
+            - /app/tbindent/droneAirReceiving
+            - /app/tbindent/droneAirDelivery
+            - /back/open
+    # 需要解密的接口路径匹配,遵循spring boot拦截器的正则规则,留空或者不配置代表不使用url匹配,只对注解的接口、参数、字段进行解密
+    decrypt-url:
+        # 配置了此项,接口、参数、字段有无注解都将进行解密
+        include-urls: /**
+        # 即使配置了排除,注解的优先级也高于此项
+        exclude-urls:
+            - /captcha.jpg
+            - /app/wxPay/notifyMp
+            - /app/wxPay/notify
+            - /app/wxPay/notifyJsApi
+            - /app/wxPay/notifyShop
+            - /app/wxPay/notifyJsApiShop
+            - /app/wxPay/notifyMpShop
+            - /pay/open/notify
+            - /app/new-pay/wechat-pay/notify
+            - /chatSocket/**
+            - /websocket/**
+            - /alioss/**
+            - /swagger-ui.html
+            - /v2/api-docs
+            - /swagger-resources/**
+            - /webjars/**
+            - /back/open
+    # Date类型日期格式化
+    date-format: yyyy-MM-dd HH:mm:ss
+    # LocalDateTime类型日期格式化
+    local-date-time-format: yyyy-MM-dd HH:mm:ss
+
+mp:
+    temp: false
+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.22.45.21:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT&useAffectedRows=true
+    #    url: jdbc:mysql://172.16.20.108:3306/tcwm2.5?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&serverTimezone=CTT
+    username: root
+    password: Chuanghai2024.
+    #    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

+ 1 - 1
src/main/resources/application.yml

@@ -21,7 +21,7 @@ spring:
     allow-circular-references: true
   # 环境 dev|test|prod
   profiles:
-    active: dev
+    active: mysql8
   # jackson时间格式化
   jackson:
     time-zone: GMT+8

+ 0 - 59
src/main/resources/mapper/baseDate/RegionDao.xml

@@ -1,59 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-<mapper namespace="com.sqx.modules.baseDate.dao.RegionDao">
-    <select id="selectRegion" resultType="Map">
-     select region_id,parent_id,region_name,status,ischildren,idtree from tb_region where isdelete=0
-        <if test ='0 != parentId'>
-            and parent_id=#{parentId}
-        </if>
-        <if test ='0 == parentId'>
-            and parent_id=0
-        </if>
-    </select>
-
-    <!--<insert id="insertRegion" useGeneratedKeys="true" keyColumn="regionId" keyProperty="regionId" parameterType="com.sqx.modules.app.order.entity.Order">
-        insert into tb_region
-        <trim prefix="(" suffix=")" suffixOverrides=",">
-            <if test ='null != regionName'>
-                region_name,
-            </if>
-            <if test ='null != status'>
-                status,
-            </if>
-            <if test ='null != ischildren'>
-                ischildren
-            </if>
-        </trim>
-        <trim prefix="values (" suffix=")" suffixOverrides=",">
-            <if test ='null != regionName'>
-                #{regionName},
-            </if>
-            <if test ='null != status'>
-                #{status},
-            </if>
-            <if test ='null != ischildren'>
-                #{ischildren}
-            </if>
-        </trim>
-    </insert>-->
-
-    <update id="updateIschildren">
-        update tb_region set ischildren=1 where 1=1
-    <if test ='null != id'>
-        and region_id=#{id}
-    </if>
-    </update>
-
-    <update id="updateStatus">
-        update tb_region set
-            status= #{status}
-            where 1=1
-        <if test ='null != id'>
-            and idtree like #{id}
-        </if>
-    </update>
-
-    <update id="deleteRegion">
-        update tb_region set isdelete =1 where idtree like #{id}
-    </update>
-</mapper>

+ 167 - 131
src/main/resources/mapper/dataCentre/dataCenterMapper.xml

@@ -80,7 +80,7 @@
         select count(*)
         from tb_indent
         where rider_user_id = #{userId}
-          and indent_state in (2, 3, 4, 6, 11)
+          and indent_state in ('2', '3', '4', '6', '11')
           and date_format(create_time, '%Y-%m') = date_format(#{date}, '%Y-%m')
     </select>
 
@@ -88,7 +88,7 @@
         select ifnull(sum(rider_money), 0)
         from tb_indent
         where rider_user_id = #{userId}
-          and indent_state = 6
+          and indent_state = '6'
     </select>
 
     <select id="sumCashMoney" resultType="java.math.BigDecimal">
@@ -158,67 +158,84 @@
 
     <select id="rankingList" resultType="com.sqx.modules.errand.entity.TbIndent">
         SELECT
-        *,
-        @rank_num := @rank_num + 1 AS rankNum
-        FROM
-        ( SELECT @rank_num := 0 ) r,
-        ( SELECT ifnull( sum( rider_money ), 0 ) AS moneyOrder, i.rider_user_id, u.nick_name as nickName, u.avatar as
-        avatar,
-        i.user_province as userProvince, i.user_city as userCity, i.user_district as userDistrict,rs.station_name as stationName,
-        u.user_name as riderNickName,u.balance as riderBalance,u.phone as riderPhone
-        FROM tb_indent i left join tb_user u on i.rider_user_id = u.user_id
-        left join rider_station rs on u.rider_station_id=rs.id
-        WHERE i.rider_user_id IS NOT NULL and i.indent_state = 6
-        <if test="address!=null and address!=''">
-                and (i.user_province like concat('%',#{address},'%') or i.user_city like concat('%',#{address},'%') or
-                i.user_district like concat('%',#{address},'%'))
-        </if>
-        <if test="dateType=='day'">
-            and date_format(i.create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
-        </if>
-        <if test="dateType=='month'">
-            and date_format(i.create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
-        </if>
-        <if test="dateType=='year'">
-            and date_format(i.create_time,'%Y')=date_format(#{date},'%Y')
-        </if>
-        <if test="riderStationId != null and riderStationId != ''">
-            and u.rider_station_id=#{riderStationId}
-        </if>
-        GROUP BY i.rider_user_id ) a
+            a.*,
+            ROW_NUMBER() OVER (ORDER BY a.moneyOrder DESC) AS rankNum
+        FROM (
+            SELECT
+                ifnull(sum(rider_money), 0) AS moneyOrder,
+                i.rider_user_id,
+                u.nick_name as nickName,
+                u.avatar as avatar,
+                i.user_province as userProvince,
+                i.user_city as userCity,
+                i.user_district as userDistrict,
+                rs.station_name as stationName,
+                u.user_name as riderNickName,
+                u.balance as riderBalance,
+                u.phone as riderPhone
+            FROM tb_indent i
+                LEFT JOIN tb_user u ON i.rider_user_id = u.user_id
+                LEFT JOIN rider_station rs ON u.rider_station_id=rs.id
+            WHERE i.rider_user_id IS NOT NULL and i.indent_state = '6'
+            <if test="address!=null and address!=''">
+                    and (i.user_province like concat('%',#{address},'%') or i.user_city like concat('%',#{address},'%') or
+                    i.user_district like concat('%',#{address},'%'))
+            </if>
+            <if test="dateType=='day'">
+                and date_format(i.create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
+            </if>
+            <if test="dateType=='month'">
+                and date_format(i.create_time,'%Y-%m')=date_format(#{date},'%Y-%m')
+            </if>
+            <if test="dateType=='year'">
+                and date_format(i.create_time,'%Y')=date_format(#{date},'%Y')
+            </if>
+            <if test="riderStationId != null and riderStationId != ''">
+                and u.rider_station_id=#{riderStationId}
+            </if>
+            GROUP BY i.rider_user_id
+        ) a
         ORDER BY moneyOrder DESC
     </select>
 
     <select id="excelRankList" resultType="com.sqx.modules.errand.entity.TbIndent">
         SELECT
-        *,
-        @rank_num := @rank_num + 1 AS rankNum
-        FROM
-        ( SELECT @rank_num := 0 ) r,
-        ( SELECT ifnull( sum( rider_money ), 0 ) AS moneyOrder, i.rider_user_id, u.nick_name as nickName, u.avatar as
-        avatar,
-        i.user_province as userProvince, i.user_city as userCity, i.user_district as userDistrict,rs.station_name as stationName,
-        u.user_name as riderNickName,u.balance as riderBalance
-        FROM tb_indent i left join tb_user u on i.rider_user_id = u.user_id
-        left join rider_station rs on u.rider_station_id=rs.id
-        WHERE i.rider_user_id IS NOT NULL
-        <if test="query.address!=null and query.address!=''">
-            and (i.user_province like concat('%',#{query.address},'%') or i.user_city like concat('%',#{query.address},'%') or
-            i.user_district like concat('%',#{query.address},'%'))
-        </if>
-        <if test="query.dateType=='day'">
-            and date_format(i.create_time,'%Y-%m-%d')=date_format(#{query.date},'%Y-%m-%d')
-        </if>
-        <if test="query.dateType=='month'">
-            and date_format(i.create_time,'%Y-%m')=date_format(#{query.date},'%Y-%m')
-        </if>
-        <if test="query.dateType=='year'">
-            and date_format(i.create_time,'%Y')=date_format(#{query.date},'%Y')
-        </if>
-        <if test="query.riderStationId != null and query.riderStationId !=''">
-            and u.rider_station_id=#{query.riderStationId}
-        </if>
-        GROUP BY i.rider_user_id ) a
+            a.*,
+            ROW_NUMBER() OVER (ORDER BY a.moneyOrder DESC) AS rankNum
+        FROM (
+            SELECT
+                ifnull(sum(rider_money), 0) AS moneyOrder,
+                i.rider_user_id,
+                u.nick_name as nickName,
+                u.avatar as avatar,
+                i.user_province as userProvince,
+                i.user_city as userCity,
+                i.user_district as userDistrict,
+                rs.station_name as stationName,
+                u.user_name as riderNickName,
+                u.balance as riderBalance
+            FROM tb_indent i
+                LEFT JOIN tb_user u ON i.rider_user_id = u.user_id
+                LEFT JOIN rider_station rs ON u.rider_station_id=rs.id
+            WHERE i.rider_user_id IS NOT NULL
+            <if test="query.address!=null and query.address!=''">
+                and (i.user_province like concat('%',#{query.address},'%') or i.user_city like concat('%',#{query.address},'%') or
+                i.user_district like concat('%',#{query.address},'%'))
+            </if>
+            <if test="query.dateType=='day'">
+                and date_format(i.create_time,'%Y-%m-%d')=date_format(#{query.date},'%Y-%m-%d')
+            </if>
+            <if test="query.dateType=='month'">
+                and date_format(i.create_time,'%Y-%m')=date_format(#{query.date},'%Y-%m')
+            </if>
+            <if test="query.dateType=='year'">
+                and date_format(i.create_time,'%Y')=date_format(#{query.date},'%Y')
+            </if>
+            <if test="query.riderStationId != null and query.riderStationId !=''">
+                and u.rider_station_id=#{query.riderStationId}
+            </if>
+            GROUP BY i.rider_user_id
+        ) a
         ORDER BY moneyOrder DESC
     </select>
 
@@ -243,74 +260,89 @@
 
     <select id="selectRankingList" resultType="com.sqx.modules.order.entity.TbOrder">
         SELECT
-        *,
-        @rank_num := @rank_num + 1 AS rankNum
-        FROM
-        ( SELECT @rank_num := 0 ) r,
-        ( SELECT ifnull( sum( pay_money ), 0 ) AS shopMoney,ifnull( sum( shop_income_money ), 0 ) AS shopIncomeMoney, tor.shop_id , u.shop_name,gp.id as
-        shopType,gp.shop_type_name as shopTypeName
-        FROM tb_order tor force index(tb_order_pay_time_IDX) 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
+            a.*,
+            ROW_NUMBER() OVER (ORDER BY a.shopMoney DESC) AS rankNum
+        FROM (
+            SELECT
+                ifnull(sum(pay_money), 0) AS shopMoney,
+                ifnull(sum(shop_income_money), 0) AS shopIncomeMoney,
+                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
     </select>
 
     <select id="selectRankingListAmount" resultType="com.sqx.modules.order.entity.TbOrder">
-        SELECT ifnull( sum( pay_money ), 0 ) AS shopMoney,ifnull( sum( shop_income_money ), 0 ) AS shopIncomeMoney
-        FROM tb_order tor force index(tb_order_pay_time_IDX) left join goods_shop u on tor.shop_id = u.shop_id
-        left join shop_type gp on gp.id=u.shop_type_id
+        SELECT
+            ifnull( sum( pay_money ), 0 ) AS shopMoney,
+            ifnull( sum( shop_income_money ), 0 ) AS shopIncomeMoney
+        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>
+            <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>
     </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,ifnull( sum( shop_income_money ), 0 ) AS shopIncomeMoney, 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>
-        <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
+            a.*,
+            ROW_NUMBER() OVER (ORDER BY a.shopMoney DESC) AS `Rank`
+        FROM (
+            SELECT
+                ifnull(sum(pay_money), 0) AS shopMoney,
+                ifnull(sum(shop_income_money), 0) AS shopIncomeMoney,
+                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>
+                <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>
 
@@ -368,7 +400,7 @@
                  left join tb_indent ti on ti.order_id = i.order_id
                  left join tb_user tu on ti.rider_user_id = tu.user_id
         where i.user_id = #{userId}
-          and i.indent_state in (2, 3, 4, 5, 6, 8, 9, 10)
+          and i.indent_state in ('2', '3', '4', '5', '6', '8', '9', '10')
         order by i.create_time desc
     </select>
 
@@ -376,25 +408,29 @@
         select *
         from tb_indent
         where rider_user_id = #{userId}
-          and indent_state in (3, 4, 5, 6)
+          and indent_state in ('3', '4', '5', '6')
         order by create_time desc
     </select>
 
     <select id="findTopUpMoney" resultType="com.sqx.modules.pay.entity.PayDetails">
-        select pd.*, tu.nick_name as nickName from pay_details pd left join tb_user tu on pd.user_id = tu.user_id where
-        1 = 1
-        <if test="userId!=null">
-            and pd.user_id = #{userId}
-        </if>
-        <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
-            and str_to_date(pd.create_time, '%Y-%m-%d') between str_to_date(#{startTime}, '%Y-%m-%d') AND
-            str_to_date(#{endTime}, '%Y-%m-%d')
-        </if>
+        select
+            pd.*,
+            tu.nick_name as nickName
+        from pay_details pd
+            left join tb_user tu on pd.user_id = tu.user_id
+        <where>
+            <if test="userId!=null">
+                and pd.user_id = #{userId}
+            </if>
+            <if test="startTime!=null and startTime!=''and endTime!=null and endTime!='' ">
+                and pd.create_time between #{startTime} AND #{endTime}
+            </if>
+        </where>
         order by pd.create_time desc
     </select>
 
     <select id="billMoney" resultType="java.math.BigDecimal">
-        select ifnull(sum(indent_money),0) from tb_indent where indent_state in (2, 3, 4, 6)
+        select ifnull(sum(indent_money),0) from tb_indent where indent_state in ('2', '3', '4', '6')
         <if test="dateType=='day'">
             and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
         </if>
@@ -407,7 +443,7 @@
     </select>
 
     <select id="riderMoney" resultType="java.math.BigDecimal">
-        select ifnull(sum(rider_money),0) from tb_indent where indent_state = "6"
+        select ifnull(sum(rider_money),0) from tb_indent where indent_state = '6'
         <if test="dateType=='day'">
             and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
         </if>
@@ -420,7 +456,7 @@
     </select>
 
     <select id="platformMoney" resultType="java.math.BigDecimal">
-        select ifnull(sum(platform_money),0) from tb_indent where indent_state = "6"
+        select ifnull(sum(platform_money),0) from tb_indent where indent_state = '6'
         <if test="dateType=='day'">
             and date_format(create_time,'%Y-%m-%d')=date_format(#{date},'%Y-%m-%d')
         </if>

+ 1 - 1
src/main/resources/mapper/errand/TbIndentMapper.xml

@@ -424,7 +424,7 @@
 
     <select id="findAllIndent" resultType="com.sqx.modules.errand.entity.TbIndent">
         select i.*, t.nick_name as nickName, t.avatar as avatar , r.red_packet_amount as redPacketAmount,
-        ru.nick_name as riderNickName, ru.phone as riderPhone,
+        ru.nick_name as riderNickName, ru.phone as riderPhone
         from tb_indent i
         LEFT JOIN tb_user t on i.user_id = t.user_id
         LEFT JOIN tb_user ru on i.rider_user_id = ru.user_id

+ 1 - 0
src/main/resources/mapper/errand/UserInfoMapper.xml

@@ -96,6 +96,7 @@
         update tb_user set on_line_flag = #{onLineFlag} where user_id = #{userId}
     </update>
 
+    <!-- 废弃 -->
     <select id="rankingList" resultType="com.sqx.modules.errand.entity.TbIndent">
         SELECT
         *,

+ 19 - 20
src/main/resources/mapper/goods/GoodsMapper.xml

@@ -121,26 +121,25 @@
 
 
     <select id="selectGoodsBySalesAndGoodsNameAndShopIds" resultType="com.sqx.modules.goods.entity.Goods">
-        SELECT x.*
-        FROM (SELECT g.*,
-        CASE
-        WHEN @shopId != g.shop_id THEN @rownum := 1
-        ELSE @rownum := @rownum + 1
-        END AS rank,
-        @shopId := g.shop_id AS shopId
-        FROM goods g
-        JOIN (SELECT @rownum := NULL, @shopId := '') r
-        where g.status=0
-        <if test="goodsName!=null and goodsName!=''">
-            and g.goods_name like concat('%',#{goodsName},'%')
-        </if>
-        <if test="shopIdList.size()>0">
-            and g.shop_id in
-            <foreach collection="shopIdList" item="id" index="index" open="(" close=")" separator=",">
-                #{id}
-            </foreach>
-        </if>
-        ORDER BY g.shop_id,g.sort asc,g.sales_volume desc) x
+        SELECT
+            x.*
+        FROM (
+            SELECT
+                g.*,
+                ROW_NUMBER() OVER (PARTITION BY g.shop_id ORDER BY g.sort asc, g.sales_volume desc) AS `rank`
+            FROM
+                goods g
+            WHERE g.status=0
+                <if test="goodsName!=null and goodsName!=''">
+                    and g.goods_name like concat('%',#{goodsName},'%')
+                </if>
+                <if test="shopIdList.size()>0">
+                    and g.shop_id in
+                    <foreach collection="shopIdList" item="id" index="index" open="(" close=")" separator=",">
+                        #{id}
+                    </foreach>
+                </if>
+        ) x
         WHERE x.rank &lt;= 3
     </select>
 

+ 0 - 14
src/main/resources/mapper/job/ScheduleJobDao.xml

@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="com.sqx.modules.job.dao.ScheduleJobDao">
-
-	<!-- 批量更新状态 -->
-	<update id="updateBatch">
-		update schedule_job set status = #{status} where job_id in
-		<foreach item="jobId" collection="list"  open="(" separator="," close=")">
-			#{jobId}
-		</foreach>
-	</update>
-
-</mapper>

+ 0 - 6
src/main/resources/mapper/job/ScheduleJobLogDao.xml

@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
-
-<mapper namespace="com.sqx.modules.job.dao.ScheduleJobLogDao">
-
-</mapper>

+ 13 - 0
src/main/resources/mapper/order/OrderMapper.xml

@@ -798,5 +798,18 @@
         ORDER BY
             value DESC
     </select>
+    <select id="temp" resultType="com.sqx.modules.order.entity.TbOrder">
+
+        SELECT
+        *
+        FROM
+        `tcwm2.5`.`tb_order`
+        WHERE
+        `pay_time` > '2025-10-12 00:00:00'
+        AND `status` = '3'
+        AND `pay_time` <![CDATA[ <= ]]> '2025-10-12 15:00:00'
+        AND `trade_no` IS NOT NULL
+
+    </select>
 
 </mapper>

+ 181 - 0
src/test/java/OrderTest.java

@@ -1,15 +1,40 @@
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.sqx.SqxApplication;
+import com.sqx.common.utils.Query;
 import com.sqx.common.utils.RedisUtils;
+import com.sqx.modules.activity.entity.ActivityPartRecord;
+import com.sqx.modules.activity.service.ActivityPartRecordService;
+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.app.service.UserMoneyService;
+import com.sqx.modules.common.entity.CommonInfo;
+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.coupon.service.TbCouponService;
+import com.sqx.modules.errand.entity.TbIndentSmsSendLog;
+import com.sqx.modules.goods.entity.GoodsShop;
+import com.sqx.modules.order.dao.AppOrderDao;
+import com.sqx.modules.order.entity.TbOrder;
 import com.sqx.modules.order.service.AppOrderService;
 import com.sqx.modules.pay.service.WxService;
+import com.sqx.modules.shop.service.ShopMessageService;
 import com.sqx.scheduler.order.OrderScheduler;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.jupiter.api.Test;
 import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.List;
 
 /**
  * @author : codingliang
@@ -24,6 +49,27 @@ public class OrderTest {
     private AppOrderService appOrderService;
 
     @Resource
+    private ShopMessageService shopMessageService;
+
+    @Resource
+    private TbCouponUserDao tbCouponUserDao;
+
+    @Resource
+    private ActivityPartRecordService activityPartRecordService;
+
+    @Resource
+    private CommonInfoService commonInfoService;
+
+    @Resource
+    private UserMoneyDetailsDao userMoneyDetailsDao;
+
+    @Resource
+    private UserMoneyDetailsService userMoneyDetailsService;
+
+    @Resource
+    private UserMoneyService userMoneyService;
+
+    @Resource
     private OrderScheduler orderScheduler;
 
     @Resource
@@ -31,9 +77,144 @@ public class OrderTest {
 
     @Resource
     private RedisUtils redisUtils;
+    @Autowired
+    private AppOrderDao appOrderDao;
 
     @Test
     public void test() {
+        List<TbOrder> orderList = appOrderDao.temp();
+        for (TbOrder tbOrder : orderList) {
+            QueryWrapper<UserMoneyDetails> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("title", "商户订单收入,订单号:" + tbOrder.getOrderNumber());
+            if (userMoneyDetailsService.count(queryWrapper) > 0) {
+                log.info("订单id【{}】,商户用户钱包收入记录已存在,跳过", tbOrder.getOrderId());
+                continue;
+            }
+
+            log.info("订单id【{}】,开始计算商户用户钱包收入记录", tbOrder.getOrderId());
+
+
+            GoodsShop goodsShop = shopMessageService.selectShopId(tbOrder.getShopId());
+
+            // 计算商户应得金额
+            BigDecimal shopRate = goodsShop.getShopRate();
+            BigDecimal sumMoney = tbOrder.getPayMoney();
+            BigDecimal couponMoney = BigDecimal.ZERO;
+            Long shopIds = -1L;
+            if (tbOrder.getCouponId() != null) {
+                TbCouponUser tbCouponUser = tbCouponUserDao.selectById(tbOrder.getCouponId());
+                sumMoney = tbOrder.getPayMoney().add(tbCouponUser.getMoney());
+                couponMoney = tbCouponUser.getMoney();
+                shopIds = tbCouponUser.getShopId();
+            }
 
+            BigDecimal errandMoney = BigDecimal.ZERO;
+            if (tbOrder.getOrderType() != 1) {
+                //判断是否达到商家满减  如果达到商家满减 跑腿费让商家承担
+                if (tbOrder.getAutoSendOrder() != null && tbOrder.getAutoSendOrder() == 0) {
+                    errandMoney = tbOrder.getErrandMoney();
+                    sumMoney = sumMoney.subtract(tbOrder.getErrandMoney());
+                } else {
+                    sumMoney = sumMoney.subtract(tbOrder.getErrandMoney());
+                    errandMoney = tbOrder.getErrandMoney();
+                }
+            }
+
+            // 再减去校内配送费
+            sumMoney = sumMoney.subtract(tbOrder.getInsideDeliveryFee());
+
+            // 店铺收入
+            BigDecimal shopMoney = sumMoney.multiply(shopRate);
+            shopMoney = shopMoney.setScale(2, BigDecimal.ROUND_DOWN);
+            BigDecimal pingRate = sumMoney.subtract(shopMoney);
+
+            // 商家配送短信服务费 为0
+            BigDecimal smsSendMoney = BigDecimal.ZERO;
+
+            // 这里再判断 是否是商家优惠券  如果是商家优惠券  这笔钱商家承担
+            if (shopIds != -1 && shopIds != 0) {
+                shopMoney = shopMoney.subtract(couponMoney);
+            }
+
+            // 判断订单是否参与活动,如果参与活动,则优惠金额由商家承担
+            ActivityPartRecord activityPartRecord = activityPartRecordService.getByOrderId(tbOrder.getOrderId());
+            BigDecimal activityDiscountAmount = BigDecimal.ZERO;
+            if (ObjectUtil.isNotNull(activityPartRecord)) {
+                activityDiscountAmount = activityPartRecord.getDiscountAmount();
+            }
+
+            if (tbOrder.getAutoSendOrder() != null && tbOrder.getAutoSendOrder() == 1) {
+                //如果达到商家满减 则商家不加上配送费
+                if (!"本单已达到商家满减金额,跑腿费由商家承担".equals(tbOrder.getErrandMoneyIsShop())) {
+                    shopMoney = shopMoney.add(tbOrder.getErrandMoney());
+                }
+            }
+
+            StringBuffer contentBuffer = new StringBuffer();
+            BigDecimal rider = new BigDecimal(0);
+            if (ObjectUtils.isNotEmpty(tbOrder.getOrderTypeExtra())&&tbOrder.getOrderTypeExtra()==2) {
+                //        获取骑手额外配送费
+                CommonInfo commonInfo = commonInfoService.findOne(443);
+                if (ObjectUtils.isNotEmpty(commonInfo)) {
+                    rider =rider.add(new BigDecimal(commonInfo.getValue()));
+                    shopMoney=shopMoney.subtract(rider);
+                }
+                log.info("订单id【{}】,骑手额外配送费【{}】", tbOrder.getOrderId(), rider);
+            }
+
+            // 添加商户用户钱包收入记录
+            UserMoneyDetails userMoneyDetails1 = new UserMoneyDetails();
+            userMoneyDetails1.setShopId(goodsShop.getShopId());
+            userMoneyDetails1.setTitle("商户订单收入,订单号:" + tbOrder.getOrderNumber());
+
+            // 订单金额
+            BigDecimal orderAmount = tbOrder.getPayMoney().add(couponMoney).add(activityDiscountAmount);
+            contentBuffer.append("订单金额:").append(orderAmount.setScale(2, BigDecimal.ROUND_DOWN));
+            if (!couponMoney.equals(BigDecimal.ZERO)) {
+                contentBuffer.append(",优惠券金额:").append(couponMoney.setScale(2, BigDecimal.ROUND_DOWN));
+            }
+            if (!activityDiscountAmount.equals(BigDecimal.ZERO)) {
+                contentBuffer.append(",活动优惠金额:").append(activityDiscountAmount.setScale(2, BigDecimal.ROUND_DOWN));
+            }
+
+            contentBuffer.append(",用户实付金额:").append(tbOrder.getPayMoney()).append(",其中");
+            if (tbOrder.getOrderType() != 1) {
+                contentBuffer.append("跑腿费:").append(errandMoney.setScale(2, BigDecimal.ROUND_DOWN)).append("(").append(tbOrder.getErrandMoneyIsShop()).append(")").append(",");
+            }
+
+            contentBuffer.append("特殊地址跑腿费:").append(tbOrder.getInsideDeliveryFee().setScale(2, BigDecimal.ROUND_DOWN)).append(",");
+            contentBuffer.append("平台服务费:").append(pingRate.setScale(2, BigDecimal.ROUND_DOWN)).append(",");
+            contentBuffer.append("短信服务费:").append(smsSendMoney.setScale(2, BigDecimal.ROUND_DOWN)).append(",");
+            if (ObjectUtils.isNotEmpty(tbOrder.getOrderTypeExtra())&&tbOrder.getOrderTypeExtra()==2) {
+                contentBuffer.append("骑手额外配送费:").append(rider.setScale(2, BigDecimal.ROUND_DOWN)).append(",");
+            }
+            contentBuffer.append("到账金额:").append(shopMoney.setScale(2, BigDecimal.ROUND_DOWN));
+
+            if (shopIds == 0) {
+                contentBuffer.append("(本单为平台优惠券,平台补贴)");
+            } else if (shopIds != -1) {
+                contentBuffer.append("(本单为商家优惠券,商家补贴)");
+            }
+
+            userMoneyDetails1.setContent(contentBuffer.toString());
+
+            userMoneyDetails1.setType(1);
+            userMoneyDetails1.setClassify(3);
+            userMoneyDetails1.setMoney(shopMoney);
+            DateTimeFormatter dateTimeFormatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+            userMoneyDetails1.setCreateTime(LocalDateTime.now().format(dateTimeFormatter1));
+            userMoneyDetails1.setState(2);
+            userMoneyDetailsDao.insert(userMoneyDetails1);
+            log.info("订单id【{}】,商户用户钱包收入记录新增成功", tbOrder.getOrderId());
+
+            //将用户支付的金额转入商户用户钱包
+            userMoneyService.updateMoney(1, goodsShop.getUserId(), shopMoney.doubleValue());
+        }
+    }
+
+    @Test
+    public void test2() {
+        String value = commonInfoService.findOne(19).getValue();
+        System.out.println("value = " + value);
     }
 }