liurunyu
2024-10-22 360fd7787f6f5981411e255f86e7d5b2a979f5f6
Merge branch 'master' of http://8.140.179.55:20000/r/pipIrr-SV
4个文件已添加
6个文件已修改
390 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeWechatpayMapper.java 33 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeWechatpay.java 68 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeWechatpayMapper.xml 142 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/PipIrrSellApplication.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/PaymentCtrl.java 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/PaymentSv.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/dto/Wechatpay.java 53 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientCtrl.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientSv.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PayInfo.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoSe/SeWechatpayMapper.java
New file
@@ -0,0 +1,33 @@
package com.dy.pipIrrGlobal.daoSe;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoSe.SeWechatpay;
import org.apache.ibatis.annotations.Mapper;
/**
 * @author ZhuBaoMin
 * @date 2024-10-22 11:18
 * @LastEditTime 2024-10-22 11:18
 * @Description
 */
@Mapper
public interface SeWechatpayMapper extends BaseMapper<SeWechatpay> {
    int deleteByPrimaryKey(Long id);
    int insert(SeWechatpay record);
    int insertSelective(SeWechatpay record);
    SeWechatpay selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(SeWechatpay record);
    int updateByPrimaryKey(SeWechatpay record);
    /**
     * 根据AppId获取微信支付对象
     * @param appId
     * @return
     */
    SeWechatpay getWechatpayByAppId(String appId);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoSe/SeWechatpay.java
New file
@@ -0,0 +1,68 @@
package com.dy.pipIrrGlobal.pojoSe;
/**
 * @author ZhuBaoMin
 * @date 2024-10-22 11:18
 * @LastEditTime 2024-10-22 11:18
 * @Description 微信支付信息实体类
 */
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dy.common.po.BaseEntity;
import lombok.*;
@TableName(value="se_wechatpay", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class SeWechatpay implements BaseEntity {
    public static final long serialVersionUID = 202410221122001L;
    /**
    * 主键
    */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId(type = IdType.INPUT)
    private Long id;
    /**
    * 小程序唯一标识
    */
    private String appId;
    /**
    * 小程序秘钥
    */
    private String appSecret;
    /**
    * 商户号
    */
    private String mchId;
    /**
    * 秘钥key
    */
    private String mchKey;
    /**
    * API证书序列号
    */
    private String serialNo;
    /**
    * 支付结果通知url
    */
    private String notifyUrl;
    /**
     * 备注信息
     */
    private String remarks;
}
pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeWechatpayMapper.xml
New file
@@ -0,0 +1,142 @@
<?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.dy.pipIrrGlobal.daoSe.SeWechatpayMapper">
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoSe.SeWechatpay">
    <!--@mbg.generated-->
    <!--@Table se_wechatpay-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="app_id" jdbcType="VARCHAR" property="appId" />
    <result column="app_secret" jdbcType="VARCHAR" property="appSecret" />
    <result column="mch_id" jdbcType="VARCHAR" property="mchId" />
    <result column="mch_key" jdbcType="VARCHAR" property="mchKey" />
    <result column="serial_no" jdbcType="VARCHAR" property="serialNo" />
    <result column="remarks" jdbcType="VARCHAR" property="remarks" />
    <result column="notify_url" jdbcType="VARCHAR" property="notifyUrl" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, app_id, app_secret, mch_id, mch_key, serial_no, remarks, notify_url
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select
    <include refid="Base_Column_List" />
    from se_wechatpay
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from se_wechatpay
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoSe.SeWechatpay">
    <!--@mbg.generated-->
    insert into se_wechatpay (id, app_id, app_secret,
      mch_id, mch_key, serial_no,
      remarks, notify_url)
    values (#{id,jdbcType=BIGINT}, #{appId,jdbcType=VARCHAR}, #{appSecret,jdbcType=VARCHAR},
      #{mchId,jdbcType=VARCHAR}, #{mchKey,jdbcType=VARCHAR}, #{serialNo,jdbcType=VARCHAR},
      #{remarks,jdbcType=VARCHAR}, #{notifyUrl,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeWechatpay">
    <!--@mbg.generated-->
    insert into se_wechatpay
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="appId != null">
        app_id,
      </if>
      <if test="appSecret != null">
        app_secret,
      </if>
      <if test="mchId != null">
        mch_id,
      </if>
      <if test="mchKey != null">
        mch_key,
      </if>
      <if test="serialNo != null">
        serial_no,
      </if>
      <if test="remarks != null">
        remarks,
      </if>
      <if test="notifyUrl != null">
        notify_url,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="appId != null">
        #{appId,jdbcType=VARCHAR},
      </if>
      <if test="appSecret != null">
        #{appSecret,jdbcType=VARCHAR},
      </if>
      <if test="mchId != null">
        #{mchId,jdbcType=VARCHAR},
      </if>
      <if test="mchKey != null">
        #{mchKey,jdbcType=VARCHAR},
      </if>
      <if test="serialNo != null">
        #{serialNo,jdbcType=VARCHAR},
      </if>
      <if test="remarks != null">
        #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="notifyUrl != null">
        #{notifyUrl,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoSe.SeWechatpay">
    <!--@mbg.generated-->
    update se_wechatpay
    <set>
      <if test="appId != null">
        app_id = #{appId,jdbcType=VARCHAR},
      </if>
      <if test="appSecret != null">
        app_secret = #{appSecret,jdbcType=VARCHAR},
      </if>
      <if test="mchId != null">
        mch_id = #{mchId,jdbcType=VARCHAR},
      </if>
      <if test="mchKey != null">
        mch_key = #{mchKey,jdbcType=VARCHAR},
      </if>
      <if test="serialNo != null">
        serial_no = #{serialNo,jdbcType=VARCHAR},
      </if>
      <if test="remarks != null">
        remarks = #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="notifyUrl != null">
        notify_url = #{notifyUrl,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoSe.SeWechatpay">
    <!--@mbg.generated-->
    update se_wechatpay
    set app_id = #{appId,jdbcType=VARCHAR},
      app_secret = #{appSecret,jdbcType=VARCHAR},
      mch_id = #{mchId,jdbcType=VARCHAR},
      mch_key = #{mchKey,jdbcType=VARCHAR},
      serial_no = #{serialNo,jdbcType=VARCHAR},
      remarks = #{remarks,jdbcType=VARCHAR},
      notify_url = #{notifyUrl,jdbcType=VARCHAR}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <!--根据AppId获取微信支付对象-->
  <select id="getWechatpayByAppId" resultType="com.dy.pipIrrGlobal.pojoSe.SeWechatpay">
    SELECT * FROM se_wechatpay WHERE app_id = #{appId}
  </select>
</mapper>
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/PipIrrSellApplication.java
@@ -27,7 +27,7 @@
                })
        }
)
@MapperScan({"com.dy.pipIrrGlobal.daoSe", "com.dy.pipIrrGlobal.daoBa", "com.dy.pipIrrGlobal.daoPr", "com.dy.pipIrrGlobal.daoRm","com.dy.pipIrrGlobal.daoFi"})
@MapperScan({"com.dy.pipIrrGlobal.daoSe", "com.dy.pipIrrGlobal.daoBa", "com.dy.pipIrrGlobal.daoPr", "com.dy.pipIrrGlobal.daoRm", "com.dy.pipIrrGlobal.daoFi"})
public class PipIrrSellApplication {
    public static void main(String[] args) {
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/PaymentCtrl.java
@@ -19,10 +19,7 @@
import com.dy.pipIrrSell.virtualCard.enums.LastOperateENUM;
import com.dy.pipIrrSell.virtualCard.enums.RefundItemStateENUM;
import com.dy.pipIrrSell.wallet.enums.RefundStatusENUM;
import com.dy.pipIrrSell.wechatpay.dto.Code2Session;
import com.dy.pipIrrSell.wechatpay.dto.DtoOrder;
import com.dy.pipIrrSell.wechatpay.dto.NotifyResource;
import com.dy.pipIrrSell.wechatpay.dto.OrderNotify;
import com.dy.pipIrrSell.wechatpay.dto.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -50,10 +47,7 @@
import java.security.SignatureException;
import java.security.spec.InvalidKeySpecException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.*;
/**
 * @author ZhuBaoMin
@@ -522,4 +516,32 @@
        result.put("message", "成功");
        return  result;
    }
    @PostMapping(path = "add_wechatpay", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> addWechatpay(@RequestBody @Valid Wechatpay po, BindingResult bindingResult) {
        if(bindingResult != null && bindingResult.hasErrors()){
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        if(paymentSv.getWechatpayByAppId(po.getAppId()) != null) {
            return BaseResponseUtils.buildErrorMsg("该微信支付信息已经存在");
        }
        SeWechatpay seWechatpay = new SeWechatpay();
        seWechatpay.setAppId(po.getAppId());
        seWechatpay.setAppSecret(po.getAppSecret());
        seWechatpay.setMchId(po.getMchId());
        seWechatpay.setMchKey(po.getMchKey());
        seWechatpay.setSerialNo(po.getSerialNo());
        seWechatpay.setNotifyUrl(po.getNotifyUrl());
        seWechatpay.setRemarks(po.getRemarks());
        Long rec = Optional.ofNullable(paymentSv.addWechatpay(seWechatpay)).orElse(0L);
        if(rec == 0) {
            return BaseResponseUtils.buildFail("添加微信支付信息失败");
        }
        return BaseResponseUtils.buildSuccess(true) ;
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/PaymentSv.java
@@ -2,8 +2,10 @@
import com.dy.pipIrrGlobal.daoSe.SeOpenIdMapper;
import com.dy.pipIrrGlobal.daoSe.SeVcRechargeMapper;
import com.dy.pipIrrGlobal.daoSe.SeWechatpayMapper;
import com.dy.pipIrrGlobal.pojoSe.SeOpenId;
import com.dy.pipIrrGlobal.pojoSe.SeVcRecharge;
import com.dy.pipIrrGlobal.pojoSe.SeWechatpay;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -24,6 +26,9 @@
    @Autowired
    private SeOpenIdMapper seOpenIdMapper;
    @Autowired
    private SeWechatpayMapper seWechatpayMapper;
    /**
     * 根据登录态ID获取登录态对象
     * @param sessionId
@@ -42,4 +47,23 @@
        seVcRechargeMapper.insert(po);
        return po.getId();
    }
    /**
     * 添加微信支付信息
     * @param po
     * @return
     */
    Long addWechatpay(SeWechatpay po) {
        seWechatpayMapper.insert(po);
        return po.getId();
    }
    /**
     * 根据AppId获取微信支付对象
     * @param appId
     * @return
     */
    SeWechatpay getWechatpayByAppId(String appId) {
        return seWechatpayMapper.getWechatpayByAppId(appId);
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/dto/Wechatpay.java
New file
@@ -0,0 +1,53 @@
package com.dy.pipIrrSell.wechatpay.dto;
import lombok.Data;
import org.apache.logging.log4j.core.config.plugins.validation.constraints.NotBlank;
/**
 * @author ZhuBaoMin
 * @date 2024-10-22 11:31
 * @LastEditTime 2024-10-22 11:31
 * @Description 微信支付传入对象
 */
@Data
public class Wechatpay {
    public static final long serialVersionUID = 202404220954001L;
    /**
     * 小程序唯一标识
     */
    @NotBlank(message = "小程序唯一标识不能为空")
    private String appId;
    /**
     * 小程序秘钥
     */
    @NotBlank(message = "小程序秘钥不能为空")
    private String appSecret;
    /**
     * 商户号
     */
    private String mchId;
    /**
     * 秘钥key
     */
    private String mchKey;
    /**
     * API证书序列号
     */
    private String serialNo;
    /**
     * 支付结果通知url
     */
    private String notifyUrl;
    /**
     * 备注信息
     */
    private String remarks;
}
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientCtrl.java
@@ -216,6 +216,26 @@
    }
    /**
     * 解绑农户与微信的绑定,根据sessionId删除绑定记录
     * @param sessionId
     * @return
     */
    @PostMapping(path = "unbind")
    @Transactional(rollbackFor = Exception.class)
    public BaseResponse<Boolean> unbindWechat(@RequestParam("sessionId")Long sessionId) {
        if(sessionId == null || sessionId <=0) {
            return BaseResponseUtils.buildErrorMsg("sessionId无效");
        }
        Integer rec = clientSv.unbindWechat(sessionId);
        if(rec == null || rec == 0) {
            return BaseResponseUtils.buildErrorMsg("sessionId错误");
        }
        return BaseResponseUtils.buildSuccess();
    }
    /**
     * 获取农户基本信息,小程序首页使用
     * @param sessionId
     * @return
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/client/ClientSv.java
@@ -73,4 +73,13 @@
    public VoClientWechat getSimpleClientInfo(Long sessionId, String openId) {
        return seClientMapper.getSimpleClientInfo(sessionId, openId);
    }
    /**
     * 解绑农户与微信的绑定,根据sessionId删除绑定记录
     * @param sessionId
     * @return
     */
    public Integer unbindWechat(Long sessionId) {
        return seOpenIdMapper.deleteByPrimaryKey(sessionId);
    }
}
pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PayInfo.java
@@ -30,7 +30,6 @@
    /**
     * 统一下单API
     */
    //public static String orderUrl = "https://api.mch.weixin.qq.com/pay/unifiedorder";
    public static String orderUrl = "https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi";
    /**