zyp 4 일 전
부모
커밋
87759fe7ab

+ 10 - 0
fs-service-system/src/main/java/com/fs/company/domain/Company.java

@@ -97,6 +97,16 @@ public class Company extends BaseEntity
     /** 后台制单是否需要付款 默认1 0-否 1-是*/
     private Integer isPay;
 
+    private String courseMiniAppId;
+
+    public String getCourseMiniAppId() {
+        return courseMiniAppId;
+    }
+
+    public void setCourseMiniAppId(String courseMiniAppId) {
+        this.courseMiniAppId = courseMiniAppId;
+    }
+
     public String getOmsCode() {
         return omsCode;
     }

+ 15 - 0
fs-service-system/src/main/java/com/fs/course/config/CourseMaConfig.java

@@ -35,4 +35,19 @@ public class CourseMaConfig {
      */
     private String msgDataFormat;
 
+    /**
+     * 类型 1小程序 2公众号
+     */
+    private String type;
+
+    /**
+     * 小程序log
+     */
+    private String log;
+
+    /**
+     * 小程序原始ID
+     */
+    private String username;
+
 }

+ 5 - 1
fs-service-system/src/main/java/com/fs/course/mapper/FsCourseRedPacketLogMapper.java

@@ -166,5 +166,9 @@ public interface FsCourseRedPacketLogMapper
     @Select("SELECT company_id, SUM(amount) as money FROM fs_course_red_packet_log    WHERE status = 0 and create_time >= DATE_SUB(CURDATE(), INTERVAL 2 DAY)  AND create_time < DATE_SUB(CURDATE(), INTERVAL 1 DAY) GROUP BY company_id  ")
     List<RedPacketMoneyVO> selectFsCourseAddRedPacketLogByCompany();
 
-
+    @Select("SELECT * \n" +
+            "FROM fs_course_red_packet_log \n" +
+            "WHERE status = 0 \n" +
+            "  AND create_time BETWEEN '2025-07-17 00:00:00' AND '2025-07-18 16:30:00'")
+    List<FsCourseRedPacketLog> selectFail();
 }

+ 2 - 0
fs-service-system/src/main/java/com/fs/course/param/FsCourseSendRewardUParam.java

@@ -28,4 +28,6 @@ public class FsCourseSendRewardUParam implements Serializable
     private Long periodId;
 
     private String appId;
+
+    private String code;
 }

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

@@ -12,6 +12,8 @@ import com.fs.common.enums.BizResponseEnum;
 import com.fs.common.utils.DateUtils;
 import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.date.DateUtil;
+import com.fs.company.domain.Company;
+import com.fs.company.domain.CompanyMoneyLogs;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.mapper.CompanyUserMapper;
 import com.fs.course.config.CourseConfig;
@@ -27,7 +29,9 @@ import com.fs.course.vo.FsUserCourseVideoListUVO;
 import com.fs.course.vo.FsUserCourseVideoQVO;
 import com.fs.course.vo.FsUserCourseVideoVO;
 import com.fs.course.vo.newfs.*;
+import com.fs.his.domain.FsUserWx;
 import com.fs.his.param.WxSendRedPacketParam;
+import com.fs.his.service.IFsUserWxService;
 import com.fs.his.vo.OptionsVO;
 import com.fs.qw.domain.QwCompany;
 import com.fs.qw.domain.QwExternalContact;
@@ -59,6 +63,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.core.parameters.P;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -175,6 +180,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
 
     @Autowired
     private FsUserCourseCompanyUserTimeMapper companyUserTimeMapper;
+
+    @Autowired
+    private IFsUserWxService fsUserWxService;
     /**
      * 查询课堂视频
      *
@@ -819,6 +827,9 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         packetParam.setRedPacketMode(config.getRedPacketMode());
         packetParam.setCompanyId(param.getCompanyId());
         packetParam.setAppId(param.getAppId());
+        if (StringUtils.isNotEmpty(param.getCode())){
+            packetParam.setCode(param.getCode());
+        }
 
         //2025.7.11 红包金额为0的时候
         if (amount.compareTo(BigDecimal.ZERO)>0){
@@ -888,6 +899,138 @@ public class FsUserCourseVideoServiceImpl implements IFsUserCourseVideoService
         }
     }
 
+    /**
+     * 发放红包奖励
+     *
+     * @param param 请求参数
+     * @param user 用户信息
+     * @param log 观看日志
+     * @param video 视频信息
+     * @param config 配置信息
+     * @return 处理结果
+     */
+    private R sendRedPacketRewardFsUser(FsCourseSendRewardUParam param, FsUser user, FsCourseWatchLog log, FsUserCourseVideo video, CourseConfig config) {
+        // 判断是否属于领取红包时间(会员看课发放红包)
+        if (param.getPeriodId()!=null && param.getPeriodId()>0) {
+            FsUserCoursePeriodDays periodDays = new FsUserCoursePeriodDays();
+            periodDays.setVideoId(param.getVideoId());
+            periodDays.setPeriodId(param.getPeriodId());
+            //正常情况是只能查询到一条,之前可能存在重复的脏数据,暂使用查询list的方式
+            List<FsUserCoursePeriodDays> fsUserCoursePeriodDays = fsUserCoursePeriodDaysMapper.selectFsUserCoursePeriodDaysList(periodDays);
+            if(fsUserCoursePeriodDays != null && !fsUserCoursePeriodDays.isEmpty()){
+                periodDays = fsUserCoursePeriodDays.get(0);
+            }
+            if(periodDays != null && periodDays.getLastJoinTime() !=null && LocalDateTime.now().isAfter(periodDays.getLastJoinTime())) {
+                return R.error(403,"已超过领取红包时间");
+            }
+        }
+
+        // 确定红包金额
+        BigDecimal amount = BigDecimal.ZERO;
+        FsUserCourseVideoRedPackage redPackage = fsUserCourseVideoRedPackageMapper.selectRedPacketByCompanyId(param.getVideoId(), param.getCompanyId(), param.getPeriodId());
+
+        if (redPackage != null) {
+            amount = redPackage.getRedPacketMoney();
+        } else if (video != null) {
+            amount = video.getRedPacketMoney();
+        }
+
+        // 准备发送红包参数
+        WxSendRedPacketParam packetParam = new WxSendRedPacketParam();
+//        packetParam.setOpenId(getOpenId(user.getUserId(), param.getCompanyId(), param.getSource()));
+        packetParam.setOpenId(user.getMpOpenId());
+        // 来源是小程序切换openId
+        if (param.getSource() == 2) {
+            //处理多小程序问题
+//            Company company = companyMapper.selectCompanyById(param.getCompanyId());
+//            if (company.getCourseMiniAppId()==null){
+//                return R.error("销售公司参数错误,未绑定小程序");
+//            }
+            FsUserWx fsUserWx = fsUserWxService.selectByAppIdAndUserId(param.getAppId(),user.getUserId(),1);
+            if (fsUserWx ==null || fsUserWx.getOpenId()==null){
+                return R.error("小程序openId参数缺失");
+            }
+
+//            System.out.println("小程序id"+user.getCourseMaOpenId());
+            //查出公司绑定openid并赋值
+            packetParam.setOpenId(fsUserWx.getOpenId());
+        }
+        packetParam.setAmount(amount);
+        packetParam.setSource(param.getSource());
+        packetParam.setRedPacketMode(config.getRedPacketMode());
+        packetParam.setCompanyId(param.getCompanyId());
+
+        System.out.println("红包金额"+amount);
+        System.out.println("红包商户号"+packetParam);
+        //2025.7.11 红包金额为0的时候
+        if (amount.compareTo(BigDecimal.ZERO)>0){
+            // 发送红包
+            R sendRedPacket = paymentService.sendRedPacket(packetParam);
+            if (sendRedPacket.get("code").equals(200)) {
+                FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
+                TransferBillsResult transferBillsResult;
+                if (sendRedPacket.get("isNew").equals(1)){
+                    transferBillsResult = (TransferBillsResult)sendRedPacket.get("data");
+                    redPacketLog.setResult(JSON.toJSONString(sendRedPacket));
+                    redPacketLog.setOutBatchNo(transferBillsResult.getOutBillNo());
+                    redPacketLog.setBatchId(transferBillsResult.getTransferBillNo());
+                }else {
+                    redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
+                    redPacketLog.setBatchId(sendRedPacket.get("batchId").toString());
+                }
+                // 添加红包记录
+                redPacketLog.setCourseId(param.getCourseId());
+//            redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
+                redPacketLog.setCompanyId(param.getCompanyId());
+                redPacketLog.setUserId(param.getUserId());
+                redPacketLog.setVideoId(param.getVideoId());
+                redPacketLog.setStatus(0);
+                redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null);
+                redPacketLog.setCompanyUserId(param.getCompanyUserId());
+                redPacketLog.setCreateTime(new Date());
+                redPacketLog.setAmount(amount);
+                redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
+                redPacketLog.setPeriodId(param.getPeriodId());
+
+                redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
+
+                // 更新观看记录的奖励类型
+//            if (param.getLinkType() == null || param.getLinkType() == 0) {
+                log.setRewardType(config.getRewardType());
+                courseWatchLogMapper.updateFsCourseWatchLog(log);
+//            }
+                return sendRedPacket;
+            } else {
+                return R.error("奖励发送失败,请联系客服");
+            }
+
+        } else {
+            // 发送红包
+            FsCourseRedPacketLog redPacketLog = new FsCourseRedPacketLog();
+            // 添加红包记录
+            redPacketLog.setCourseId(param.getCourseId());
+//            redPacketLog.setOutBatchNo(sendRedPacket.get("orderCode").toString());
+            redPacketLog.setCompanyId(param.getCompanyId());
+            redPacketLog.setUserId(param.getUserId());
+            redPacketLog.setVideoId(param.getVideoId());
+            redPacketLog.setStatus(1);//直接设置发送成功
+            redPacketLog.setResult("{\"msg\":\"发送0红包成功\",\"code\":200,\"isNew\":1}");
+            redPacketLog.setQwUserId(param.getQwUserId() != null ? param.getQwUserId() : null);
+            redPacketLog.setCompanyUserId(param.getCompanyUserId());
+            redPacketLog.setCreateTime(new Date());
+            redPacketLog.setAmount(BigDecimal.ZERO);
+            redPacketLog.setWatchLogId(log.getLogId() != null ? log.getLogId() : null);
+            redPacketLog.setPeriodId(param.getPeriodId());
+            redPacketLogMapper.insertFsCourseRedPacketLog(redPacketLog);
+
+            // 更新观看记录的奖励类型
+            log.setRewardType(config.getRewardType());
+            courseWatchLogMapper.updateFsCourseWatchLog(log);
+            return R.ok("红包发送成功");
+        }
+
+    }
+
     /**
      * 发放积分奖励
      *

+ 52 - 0
fs-service-system/src/main/java/com/fs/his/domain/FsUserWx.java

@@ -0,0 +1,52 @@
+package com.fs.his.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+@TableName("fs_user_wx")
+public class FsUserWx {
+    /**
+     * 主键ID
+     */
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    /**
+     * 用户ID
+     */
+    private Long fsUserId;
+
+    /**
+     * 公司ID
+     */
+    private Long companyId;
+    /**
+     * 小程序/公众号appId
+     */
+    private String appId;
+    /**
+     * 微信unionId
+     */
+    private String unionId;
+    /**
+     * 微信openId
+     */
+    private String openId;
+
+    /**
+     * 1:小程序 2:服务号
+     */
+    private Integer type;
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+    /**
+     * 修改时间
+     */
+    private Date updateTime;
+}

+ 13 - 0
fs-service-system/src/main/java/com/fs/his/mapper/FsUserWxMapper.java

@@ -0,0 +1,13 @@
+package com.fs.his.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.his.domain.FsUserWx;
+
+public interface FsUserWxMapper extends BaseMapper<FsUserWx> {
+
+    /**
+     * 根据FsUserId和AppId唯一键保存或更新
+     * @param wx    配置信息
+     */
+    void insertOrUpdateByUniqueKey(FsUserWx wx);
+}

+ 2 - 0
fs-service-system/src/main/java/com/fs/his/param/WxSendRedPacketParam.java

@@ -20,5 +20,7 @@ public class WxSendRedPacketParam implements Serializable {
 
     private String appId;
 
+    private String code;
+
 
 }

+ 15 - 0
fs-service-system/src/main/java/com/fs/his/service/IFsUserWxService.java

@@ -0,0 +1,15 @@
+package com.fs.his.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.fs.his.domain.FsUserWx;
+
+public interface IFsUserWxService extends IService<FsUserWx> {
+
+    /**
+     * 根据FsUserId和AppId唯一键保存或更新
+     * @param wx    配置信息
+     */
+    void saveOrUpdateByUniqueKey(FsUserWx wx);
+
+    FsUserWx selectByAppIdAndUserId(String appId, Long userId,Integer type);
+}

+ 33 - 0
fs-service-system/src/main/java/com/fs/his/service/impl/FsUserWxServiceImpl.java

@@ -0,0 +1,33 @@
+package com.fs.his.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fs.his.domain.FsUserWx;
+import com.fs.his.mapper.FsUserWxMapper;
+import com.fs.his.service.IFsUserWxService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+@Service
+@Slf4j
+public class FsUserWxServiceImpl extends ServiceImpl<FsUserWxMapper, FsUserWx> implements IFsUserWxService {
+
+    /**
+     * 根据FsUserId和AppId唯一键保存或更新
+     * @param wx    配置信息
+     */
+    @Override
+    public void saveOrUpdateByUniqueKey(FsUserWx wx) {
+        baseMapper.insertOrUpdateByUniqueKey(wx);
+    }
+
+    @Override
+    public FsUserWx selectByAppIdAndUserId(String appId, Long userId,Integer type) {
+        return this.baseMapper.selectOne(
+                new QueryWrapper<FsUserWx>()
+                        .eq("app_id", appId)
+                        .eq("fs_user_id", userId)
+                        .eq("type", type)
+        );
+    }
+}

+ 1 - 0
fs-service-system/src/main/java/com/fs/store/service/IFsStorePaymentService.java

@@ -112,4 +112,5 @@ public interface IFsStorePaymentService
 
     R sendRedPacketTest(WxSendRedPacketParam param);
 
+    void bufaRedPacket();
 }

+ 71 - 6
fs-service-system/src/main/java/com/fs/store/service/impl/FsStorePaymentServiceImpl.java

@@ -6,6 +6,8 @@ import java.util.Date;
 import java.util.List;
 import java.util.Map;
 
+import cn.binarywang.wx.miniapp.api.WxMaService;
+import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSONObject;
@@ -23,6 +25,8 @@ import com.fs.company.service.ICompanyService;
 import com.fs.company.service.ICompanyUserService;
 import com.fs.core.utils.OrderCodeUtils;
 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.pay.pay.config.PayConfig;
 import com.fs.pay.pay.domain.CreateWxOrderResult;
@@ -32,6 +36,7 @@ import com.fs.store.param.FsStoreStatisticsParam;
 import com.fs.his.param.WxSendRedPacketParam;
 import com.fs.store.vo.FsStorePaymentStatisticsVO;
 import com.fs.system.service.ISysConfigService;
+import com.fs.wx.miniapp.config.WxMaConfiguration;
 import com.fs.wx.miniapp.config.WxMaProperties;
 import com.fs.wx.pay.config.WxPayProperties;
 import com.fs.store.domain.FsUser;
@@ -53,6 +58,7 @@ import com.github.binarywang.wxpay.exception.WxPayException;
 import com.github.binarywang.wxpay.service.TransferService;
 import com.github.binarywang.wxpay.service.WxPayService;
 import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
+import me.chanjar.weixin.common.error.WxErrorException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeanUtils;
@@ -471,7 +477,23 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
 
         ArrayList<TransferBatchesRequest.TransferDetail> transferDetailList = new ArrayList<>();
         TransferBatchesRequest.TransferDetail transferDetail = new TransferBatchesRequest.TransferDetail();
-        transferDetail.setOpenid(param.getOpenId());
+//        transferDetail.setOpenid(param.getOpenId());
+
+        String openId;
+        //临时方法,有code的时候获取一下客户的openId
+        if (StringUtils.isNotEmpty(param.getCode())){
+            WxMaService wxService = WxMaConfiguration.getMaService(param.getAppId());
+            try {
+                WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
+                openId = session.getOpenid();
+            } catch (WxErrorException e){
+                return R.error("openId获取失败," + e.getMessage());
+            }
+        }else {
+            openId = param.getOpenId();
+        }
+
+        transferDetail.setOpenid(openId);
         String code1 = IdUtil.getSnowflake(0, 0).nextIdStr();
         transferDetail.setOutDetailNo("fsCourse" + code1);
         transferDetail.setTransferAmount(amount);
@@ -499,19 +521,18 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
         config = JSONUtil.toBean(json, RedPacketConfig.class);
 
         param.setSource(2);
-//        param.setOpenId("ooXAA1Fw5ekSqCT-WLKpoA0cDVDo");
-        param.setAmount(new BigDecimal(0.1));
+        param.setAmount(param.getAmount());
 
 
         WxPayConfig payConfig = new WxPayConfig();
         BeanUtils.copyProperties(config, payConfig);
-        payConfig.setAppId(config.getMiniappId());
+        payConfig.setAppId(param.getAppId());
         WxPayService wxPayService = new WxPayServiceImpl();
         wxPayService.setConfig(payConfig);
         TransferService transferService = wxPayService.getTransferService();
 
         TransferBatchesRequest request = new TransferBatchesRequest();
-        request.setAppid(config.getMiniappId());
+        request.setAppid(param.getAppId());
         String code = IdUtil.getSnowflake(0, 0).nextIdStr();
         request.setOutBatchNo("fsCourse" + code);
         request.setBatchRemark("课堂答题奖励");
@@ -524,6 +545,21 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
         ArrayList<TransferBatchesRequest.TransferDetail> transferDetailList = new ArrayList<>();
         TransferBatchesRequest.TransferDetail transferDetail = new TransferBatchesRequest.TransferDetail();
         transferDetail.setOpenid(param.getOpenId());
+
+//        String openId;
+//        //临时方法,有code的时候获取一下客户的openId
+//        if (StringUtils.isNotEmpty(param.getCode())){
+//            WxMaService wxService = WxMaConfiguration.getMaService(param.getAppId());
+//            try {
+//                WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
+//                openId = session.getOpenid();
+//            } catch (WxErrorException e){
+//                return R.error("openId获取失败," + e.getMessage());
+//            }
+//        }else {
+//            openId = param.getOpenId();
+//        }
+//        transferDetail.setOpenid(openId);
         String code1 = IdUtil.getSnowflake(0, 0).nextIdStr();
         transferDetail.setOutDetailNo("fsCourse" + code1);
         transferDetail.setTransferAmount(amount);
@@ -533,7 +569,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
 
         try {
             TransferBatchesResult transferBatchesResult = transferService.transferBatches(request);
-            return R.ok("发送红包成功").put("orderCode", transferBatchesResult.getOutBatchNo());
+            return R.ok("发送红包成功").put("orderCode", transferBatchesResult.getOutBatchNo()).put("batchId", transferBatchesResult.getBatchId());
         } catch (WxPayException e) {
             e.printStackTrace();
             return R.error("发送失败");
@@ -616,4 +652,33 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService
             return WxPayNotifyResponse.fail(e.getMessage());
         }
     }
+
+    @Autowired
+    private FsCourseRedPacketLogMapper redPacketLogMapper;
+
+    @Override
+    public void bufaRedPacket() {
+//        String json = configService.selectConfigByKey("redPacket.config");
+//        RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
+        List<FsCourseRedPacketLog> logs = redPacketLogMapper.selectFail();
+        String appId = "wx414427b10866c04e";
+        for (FsCourseRedPacketLog log : logs){
+            FsUser user = userService.selectFsUserById(log.getUserId());
+            WxSendRedPacketParam param = new WxSendRedPacketParam();
+            param.setAppId(appId);
+            if (user==null || user.getMaOpenId()==null){
+                continue;
+            }
+            param.setOpenId(user.getMaOpenId());
+            param.setAmount(log.getAmount());
+            R r = this.sendRedPacketTest(param);
+            if (r.get("code").equals(200)){
+                log.setOutBatchNo(r.get("orderCode").toString());
+                log.setBatchId(r.get("batchId").toString());
+                redPacketLogMapper.updateFsCourseRedPacketLog(log);
+                logger.info("更新完成:{}",log.getLogId());
+            }
+
+        }
+    }
 }

+ 5 - 0
fs-service-system/src/main/resources/application-config-zkzh.yml

@@ -81,6 +81,11 @@ wx:
         token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
         aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
         msgDataFormat: JSON
+      - appid: wx328c85d0437b5a66   #中康未来智慧服务
+        secret: fa00dce55bc4b6cdc1c692c0496ee2af
+        token: Ncbnd7lJvkripVOpyTFAna6NAWCxCrvC
+        aesKey: HlEiBB55eaWUaeBVAQO3cWKWPYv1vOVQSq7nFNICw4E
+        msgDataFormat: JSON
 
   pay:
     appId: wx11a2ce7c2bbc4521 #微信公众号或者小程序等的appid

+ 19 - 0
fs-service-system/src/main/resources/mapper/his/FsUserWxMapper.xml

@@ -0,0 +1,19 @@
+<?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.fs.his.mapper.FsUserWxMapper">
+
+    <insert id="insertOrUpdateByUniqueKey">
+        insert into fs_user_wx
+            (fs_user_id, app_id, union_id, open_id, create_time, update_time)
+        values
+            (#{fsUserId}, #{appId}, #{unionId}, #{openId}, #{createTime, jdbcType=TIMESTAMP}, #{updateTime, jdbcType=TIMESTAMP})
+        ON DUPLICATE KEY UPDATE
+        <if test="unionId != null">
+            union_id = VALUES(union_id),
+        </if>
+            open_id     = VALUES(open_id),
+            update_time = VALUES(update_time)
+    </insert>
+</mapper>

+ 6 - 0
fs-user-app/src/main/java/com/fs/app/controller/WxPayController.java

@@ -117,6 +117,12 @@ public class WxPayController {
         return R.ok();
     }
 
+    @PostMapping( "/bufa")
+    public R bufa() throws Exception {
+        storePaymentService.bufaRedPacket();
+        return R.ok();
+    }
+
     @PostMapping( "/TransferNotify")
     public String TransferNotify(@RequestBody String notifyData, HttpServletRequest request, HttpServletResponse response) throws Exception {
         return storePaymentService.transferNotify(notifyData,request);