Parcourir la source

扫码订单代码提交、红包默认金额

yjwang il y a 5 heures
Parent
commit
8cd7934d85

+ 53 - 5
fs-admin/src/main/java/com/fs/hisStore/controller/FsStorePaymentScrmController.java

@@ -4,6 +4,7 @@ import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
 import com.alipay.api.AlipayApiException;
 import com.alipay.api.domain.AlipayTradeRefundModel;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.fs.bean.AliPayBean;
 import com.fs.common.annotation.Log;
 import com.fs.common.core.controller.BaseController;
@@ -17,11 +18,14 @@ import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.common.utils.spring.SpringUtils;
 import com.fs.company.service.ICompanyService;
 import com.fs.config.cloud.CloudHostProper;
+import com.fs.course.domain.FsCoursePlaySourceConfig;
 import com.fs.course.dto.FsOrderDeliveryNoteDTO;
 import com.fs.course.dto.FsPaymentDeliveryNoteDTO;
+import com.fs.course.service.IFsCoursePlaySourceConfigService;
 import com.fs.his.domain.FsHfpayConfig;
 import com.fs.his.mapper.FsHfpayConfigMapper;
 import com.fs.hisStore.domain.FsPayConfigScrm;
+import com.fs.hisStore.vo.FsMiniProgramOptionVO;
 import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
 import com.fs.huifuPay.domain.HuiFuRefundResult;
 import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayQueryRequest;
@@ -46,10 +50,7 @@ import org.springframework.web.multipart.MultipartFile;
 
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * 支付明细Controller
@@ -84,6 +85,9 @@ public class FsStorePaymentScrmController extends BaseController
     // 最大文件大小(5MB)
     private static final long MAX_FILE_SIZE = 5 * 1024 * 1024; // 5MB
 
+    @Autowired
+    private IFsCoursePlaySourceConfigService coursePlaySourceConfigService;
+
     /**
      * 查询支付明细列表
      */
@@ -96,10 +100,20 @@ public class FsStorePaymentScrmController extends BaseController
             fsStorePayment.setCreateTimeList(fsStorePayment.getCreateTimeRange().split("--"));
         }
         List<FsStorePaymentVO> list = fsStorePaymentService.selectFsStorePaymentListQuery(fsStorePayment);
+        Map<String, BigDecimal> totalAmountMap = fsStorePaymentService.calculateTotalAmount(fsStorePayment);
+        // 计算总支付金额和总退款金额
+        BigDecimal totalPaymentAmount = totalAmountMap.get("totalPaymentAmount");
+        BigDecimal totalRefundAmount = totalAmountMap.get("totalRefundAmount");
+
         for (FsStorePaymentVO vo : list){
             vo.setUserPhone(ParseUtils.parsePhone(vo.getUserPhone()));
         }
-        return getDataTable(list);
+        // 记录查询条件和统计结果
+        TableDataInfo dataTable = getDataTable(list);
+        dataTable.put("totalPaymentAmount", totalPaymentAmount);
+        dataTable.put("totalRefundAmount", totalRefundAmount);
+
+        return dataTable;
     }
 
     /**
@@ -365,4 +379,38 @@ public class FsStorePaymentScrmController extends BaseController
         }
         return false;
     }
+
+    /**
+     * 查询小程序列表
+     */
+    @ApiOperation("查询小程序列表")
+    @GetMapping("/getMiniProgramList")
+    public AjaxResult getMiniProgramList()
+    {
+        try {
+            // 查询所有未删除的小程序配置(排除公众号)
+            QueryWrapper<FsCoursePlaySourceConfig> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq("is_del", 0)  // 未删除
+                    .ne("type", 2)      // 不是公众号
+                    .orderByDesc("create_time");
+
+            List<FsCoursePlaySourceConfig> configList = coursePlaySourceConfigService.list(queryWrapper);
+
+            List<FsMiniProgramOptionVO> optionList = new ArrayList<>();
+            for (FsCoursePlaySourceConfig config : configList) {
+                FsMiniProgramOptionVO vo = new FsMiniProgramOptionVO();
+                vo.setId(config.getId());
+                vo.setName(config.getName());
+                vo.setAppid(config.getAppid());
+                vo.setType(config.getType());
+                optionList.add(vo);
+            }
+
+            logger.info("查询小程序列表成功,数量:{}", optionList.size());
+            return AjaxResult.success(optionList);
+        } catch (Exception e) {
+            logger.error("查询小程序列表失败", e);
+            return AjaxResult.error("查询小程序列表失败:" + e.getMessage());
+        }
+    }
 }

+ 32 - 0
fs-common/src/main/java/com/fs/common/core/page/TableDataInfo.java

@@ -1,7 +1,9 @@
 package com.fs.common.core.page;
 
 import java.io.Serializable;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * 表格分页数据对象
@@ -24,6 +26,9 @@ public class TableDataInfo implements Serializable
     /** 消息内容 */
     private String msg;
 
+    /** 扩展数据(用于存放统计信息等额外数据) */
+    private Map<String, Object> ext;
+
     /**
      * 表格数据对象
      */
@@ -82,4 +87,31 @@ public class TableDataInfo implements Serializable
     {
         this.msg = msg;
     }
+
+    public Map<String, Object> getExt()
+    {
+        return ext;
+    }
+
+    public void setExt(Map<String, Object> ext)
+    {
+        this.ext = ext;
+    }
+
+    /**
+     * 添加扩展数据
+     * @param key 键
+     * @param value 值
+     * @return TableDataInfo
+     */
+    public TableDataInfo put(String key, Object value)
+    {
+        if (this.ext == null)
+        {
+            this.ext = new HashMap<>();
+        }
+        this.ext.put(key, value);
+        return this;
+    }
+
 }

+ 5 - 0
fs-service/src/main/java/com/fs/course/service/impl/FsUserCourseVideoServiceImpl.java

@@ -1417,6 +1417,11 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
             amount = video.getRedPacketMoney();
         }
 
+        //设置固定红包金额
+        if(amount.compareTo(BigDecimal.ZERO) == 0){
+            amount = new BigDecimal("0.1");
+        }
+
         // 准备发送红包参数
         WxSendRedPacketParam packetParam = new WxSendRedPacketParam();
 

+ 75 - 17
fs-service/src/main/java/com/fs/hisStore/mapper/FsStorePaymentScrmMapper.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 
 import com.alibaba.fastjson.JSONObject;
+import com.fs.hisStore.vo.FsStorePaymentAmountVO;
 import com.fs.hisStore.vo.FsStorePaymentUsetVo;
 import com.fs.hisStore.domain.FsStorePaymentScrm;
 import com.fs.hisStore.param.FsStorePaymentParam;
@@ -74,7 +75,15 @@ public interface FsStorePaymentScrmMapper
     FsStorePaymentScrm selectFsStorePaymentByCode(String payCode);
 
     @Select({"<script> " +
-            "select p.*,o.order_code,c.company_name,d.dept_name,u.phone as user_phone,cu.nick_name as company_user_nick_name,cu.user_name as company_user_name  from fs_store_payment_scrm p left join company_user cu on p.company_user_id=cu.user_id left join fs_user u on u.user_id=p.user_id left join company_dept d on d.dept_id=p.dept_id left join company c on c.company_id=p.company_id left join fs_store_order_scrm o on o.id=p.order_id   " +
+            "select p.*,o.order_code,c.company_name,d.dept_name,u.phone as user_phone," +
+            "cu.nick_name as company_user_nick_name,cu.user_name as company_user_name ,csc.name miniProgramName " +
+            "from fs_store_payment_scrm p " +
+            "left join company_user cu on p.company_user_id=cu.user_id " +
+            "left join fs_user u on u.user_id=p.user_id " +
+            "left join company_dept d on d.dept_id=p.dept_id " +
+            "left join company c on c.company_id=p.company_id " +
+            "left join fs_store_order_scrm o on o.id=p.order_id   " +
+            "LEFT JOIN fs_course_play_source_config csc ON csc.appid = p.app_id " +
             "where 1=1 " +
             "<if test = 'maps.payCode != null and  maps.payCode !=\"\"    '> " +
             "and p.pay_code like CONCAT('%',#{maps.payCode},'%') " +
@@ -100,14 +109,13 @@ public interface FsStorePaymentScrmMapper
             "<if test = 'maps.companyId != null    '> " +
             "and p.company_id =#{maps.companyId} " +
             "</if>" +
-//            "<if test = 'maps.createTime != null    '> " +
-//            "and DATE_FORMAT(p.create_time,'%Y-%m-%d') = DATE_FORMAT(#{maps.createTime},'%Y-%m-%d')  " +
-//            "</if>" +
-            "<if test = 'maps.beginTime != null and maps.beginTime != \"\"   '> " +
-            " AND date_format(p.pay_time,'%y%m%d') &gt;= date_format(#{maps.beginTime},'%y%m%d') " +
+            "<if test = 'maps.params != null and maps.params != \"\"   '> " +
+            "<if test = 'maps.params.beginTime != null and maps.params.beginTime != \"\"   '> " +
+            " AND date_format(p.pay_time,'%y%m%d') &gt;= date_format(#{maps.params.beginTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.params.endTime != null and maps.params.endTime != \"\"   '> " +
+            " AND date_format(p.pay_time,'%y%m%d') &lt;= date_format(#{maps.params.endTime},'%y%m%d') " +
             "</if>" +
-            "<if test = 'maps.endTime != null and maps.endTime != \"\"   '> " +
-            " AND date_format(p.pay_time,'%y%m%d') &lt;= date_format(#{maps.endTime},'%y%m%d') " +
             "</if>" +
 
             "<if test = 'maps.refundBeginTime != null  and maps.refundBeginTime != \"\"    '> " +
@@ -122,10 +130,6 @@ public interface FsStorePaymentScrmMapper
             "and p.bank_transaction_id like CONCAT('%',#{maps.bankTransactionId},'%') " +
             "</if>" +
 
-            "<if test = 'maps.isShipment != null'> " +
-            "and p.is_shipment = #{maps.isShipment}" +
-            "</if>" +
-
             "<if test = 'maps.companyUserNickName != null and  maps.companyUserNickName !=\"\"     '> " +
             "and cu.nick_name like CONCAT('%',#{maps.companyUserNickName},'%') " +
             "</if>" +
@@ -133,11 +137,7 @@ public interface FsStorePaymentScrmMapper
             " AND date_format(p.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d') " +
             " AND date_format(p.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d') " +
             "</if>" +
-
-//            "<if test = 'maps.refundTime != null    '> " +
-//            "and DATE_FORMAT(p.refund_time,'%Y-%m-%d') = DATE_FORMAT(#{maps.refundTime},'%Y-%m-%d')  " +
-//            "</if>" +
-
+            "<if test=\"maps.appId != null and maps.appId != ''\">  and p.app_id like #{maps.appId}</if>\n" +
             " order by p.payment_id desc "+
             "</script>"})
     List<FsStorePaymentVO> selectFsStorePaymentListQuery(@Param("maps") FsStorePaymentParam fsStorePayment);
@@ -370,4 +370,62 @@ public interface FsStorePaymentScrmMapper
      * 批量更新发货状态
      * **/
     void batchUpadte(@Param("list") List<String> list);
+
+    @Select({"<script> " +
+            "select  SUM(CASE WHEN p.status IN (1, -1) AND p.pay_money IS NOT NULL  THEN p.pay_money ELSE 0 END) AS  totalPaymentAmount, SUM(CASE WHEN p.status = '-1' AND refund_money IS NOT NULL THEN p.refund_money ELSE 0 END) AS totalRefundAmount  from fs_store_payment_scrm p left join company_user cu on p.company_user_id=cu.user_id left join fs_user u on u.user_id=p.user_id left join company_dept d on d.dept_id=p.dept_id left join company c on c.company_id=p.company_id left join fs_store_order_scrm o on o.id=p.order_id   " +
+            "where 1=1 " +
+            "<if test = 'maps.payCode != null and  maps.payCode !=\"\"    '> " +
+            "and p.pay_code like CONCAT('%',#{maps.payCode},'%') " +
+            "</if>" +
+            "<if test = 'maps.orderCode != null and  maps.orderCode !=\"\"    '> " +
+            "and o.order_code like CONCAT('%',#{maps.orderCode},'%') " +
+            "</if>" +
+            "<if test = 'maps.tradeNo != null and  maps.tradeNo !=\"\"    '> " +
+            "and p.trade_no like CONCAT('%',#{maps.tradeNo},'%') " +
+            "</if>" +
+            "<if test = 'maps.bankSerialNo != null and  maps.bankSerialNo !=\"\"    '> " +
+            "and p.bank_serial_no like CONCAT('%',#{maps.bankSerialNo},'%') " +
+            "</if>" +
+            "<if test = 'maps.mobile != null and  maps.mobile !=\"\"     '> " +
+            "and u.phone like CONCAT('%',#{maps.mobile},'%') " +
+            "</if>" +
+            "<if test = 'maps.status != null    '> " +
+            "and p.status =#{maps.status} " +
+            "</if>" +
+            "<if test = 'maps.businessType != null    '> " +
+            "and p.business_type =#{maps.businessType} " +
+            "</if>" +
+            "<if test = 'maps.companyId != null    '> " +
+            "and p.company_id =#{maps.companyId} " +
+            "</if>" +
+            "<if test = 'maps.appId != null and maps.appId !=\"\"  '> " +
+            "and p.app_id =#{maps.appId} " +
+            "</if>" +
+            "<if test = 'maps.params != null and maps.params != \"\"   '> " +
+            "<if test = 'maps.params.beginTime != null and maps.params.beginTime != \"\"   '> " +
+            " AND date_format(p.pay_time,'%y%m%d') &gt;= date_format(#{maps.params.beginTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.params.endTime != null and maps.params.endTime != \"\"   '> " +
+            " AND date_format(p.pay_time,'%y%m%d') &lt;= date_format(#{maps.params.endTime},'%y%m%d') " +
+            "</if>" +
+            "</if>" +
+            "<if test = 'maps.refundBeginTime != null  and maps.refundBeginTime != \"\"    '> " +
+            "and DATE_FORMAT(p.refund_time,'%y%m%d') &gt;= date_format(#{maps.refundBeginTime},'%y%m%d')  " +
+            "</if>" +
+            "<if test = 'maps.refundEndTime != null and maps.refundEndTime != \"\"   '> " +
+            " AND date_format(p.refund_time,'%y%m%d') &lt;= date_format(#{maps.refundEndTime},'%y%m%d') " +
+            "</if>" +
+            "<if test = 'maps.bankTransactionId != null and  maps.bankTransactionId !=\"\"     '> " +
+            "and p.bank_transaction_id like CONCAT('%',#{maps.bankTransactionId},'%') " +
+            "</if>" +
+            "<if test = 'maps.companyUserNickName != null and  maps.companyUserNickName !=\"\"     '> " +
+            "and cu.nick_name like CONCAT('%',#{maps.companyUserNickName},'%') " +
+            "</if>" +
+            "<if test = 'maps.createTimeList != null    '> " +
+            " AND date_format(p.create_time,'%y%m%d') &gt;= date_format(#{maps.createTimeList[0]},'%y%m%d') " +
+            " AND date_format(p.create_time,'%y%m%d') &lt;= date_format(#{maps.createTimeList[1]},'%y%m%d') " +
+            "</if>" +
+            " order by p.payment_id desc "+
+            "</script>"})
+    FsStorePaymentAmountVO calculateTotalAmount(@Param("maps") FsStorePaymentParam fsStorePayment);
 }

+ 4 - 0
fs-service/src/main/java/com/fs/hisStore/param/FsStorePaymentParam.java

@@ -47,6 +47,10 @@ public class FsStorePaymentParam  extends BaseEntity implements Serializable
 
     private String[] createTimeList;
 
+    // 小程序ID
+    private Long coursePlaySourceConfigId;
+    private String appId;
+
     //是否同步
     private Integer isShipment;
 }

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/service/IFsStorePaymentScrmService.java

@@ -1,5 +1,6 @@
 package com.fs.hisStore.service;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -127,4 +128,6 @@ public interface IFsStorePaymentScrmService
      * 批量导入更新微信订单发货状态
      * **/
     R oneClickShipping();
+
+    Map<String, BigDecimal>  calculateTotalAmount(FsStorePaymentParam fsStorePayment);
 }

+ 20 - 0
fs-service/src/main/java/com/fs/hisStore/service/impl/FsStorePaymentScrmServiceImpl.java

@@ -35,6 +35,7 @@ import com.fs.course.config.RedPacketConfig;
 import com.fs.course.domain.FsCourseRedPacketLog;
 import com.fs.course.mapper.FsCourseRedPacketLogMapper;
 import com.fs.course.service.IFsCourseRedPacketLogService;
+import com.fs.hisStore.vo.FsStorePaymentAmountVO;
 import com.fs.hisStore.vo.FsStorePaymentUsetVo;
 import com.fs.his.domain.FsUser;
 import com.fs.his.domain.FsUserWx;
@@ -992,6 +993,23 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
         }
     }
 
+    @Override
+    public Map<String, BigDecimal> calculateTotalAmount(FsStorePaymentParam fsStorePayment) {
+        FsStorePaymentAmountVO fsStorePaymentAmountVO = fsStorePaymentMapper.calculateTotalAmount(fsStorePayment);
+        BigDecimal totalPaymentAmount = BigDecimal.ZERO;
+        BigDecimal totalRefundAmount = BigDecimal.ZERO;
+        if (StringUtils.isNotNull(fsStorePaymentAmountVO)) {
+            totalPaymentAmount = fsStorePaymentAmountVO.getTotalPaymentAmount() == null
+                    ? BigDecimal.ZERO : fsStorePaymentAmountVO.getTotalPaymentAmount();
+            totalRefundAmount = fsStorePaymentAmountVO.getTotalRefundAmount() == null
+                    ? BigDecimal.ZERO : fsStorePaymentAmountVO.getTotalRefundAmount();
+        }
+        Map<String, BigDecimal> resultMap = new HashMap<>();
+        resultMap.put("totalPaymentAmount", totalPaymentAmount);
+        resultMap.put("totalRefundAmount", totalRefundAmount);
+        return resultMap;
+    }
+
     private boolean uploadShippingInfoToWechat(WxMaService wxService,
                                                FsStorePaymentUsetVo dto,
                                                String uploadTime) {
@@ -1027,4 +1045,6 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
             return false;
         }
     }
+
+
 }

+ 28 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsMiniProgramOptionVO.java

@@ -0,0 +1,28 @@
+package com.fs.hisStore.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 小程序选项VO
+ *
+ * @author fs
+ * @date 2025-11-21
+ */
+@Data
+public class FsMiniProgramOptionVO implements Serializable {
+
+    @ApiModelProperty("小程序ID")
+    private Long id;
+
+    @ApiModelProperty("小程序名称")
+    private String name;
+
+    @ApiModelProperty("小程序appid")
+    private String appid;
+
+    @ApiModelProperty("类型 1小程序 2公众号")
+    private Integer type;
+}

+ 13 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStorePaymentAmountVO.java

@@ -0,0 +1,13 @@
+package com.fs.hisStore.vo;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+@Data
+public class FsStorePaymentAmountVO {
+    // 总支付金额(状态为1已支付 或 -1已退款 的 payMoney 总和)
+    private BigDecimal totalPaymentAmount;
+    // 总退款金额(状态为-1已退款 且 退款审核状态为2审核完成 的 refundMoney 总和)
+    private BigDecimal totalRefundAmount;
+}

+ 3 - 0
fs-service/src/main/java/com/fs/hisStore/vo/FsStorePaymentVO.java

@@ -95,6 +95,9 @@ public class FsStorePaymentVO implements Serializable
      * **/
     private Integer isShipment;
 
+    // 小程序名称
+    @Excel(name = "所属小程序")
+    private String miniProgramName;
 
 
 }