From 8bcb47b7ea268061f4629e0953de4e3597fca690 Mon Sep 17 00:00:00 2001 From: Administrator <zhubaomin> Date: 星期二, 16 七月 2024 22:16:53 +0800 Subject: [PATCH] 2024-07-16 朱宝民 --- pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoUnclosedValve.java | 6 pipIrr-platform/pipIrr-global/src/main/resources/application-database-sp.yml | 4 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoVirtualCard.java | 8 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java | 4 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/SeClientToVoClient.java | 29 + pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java | 4 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/enums/RefundStatusENUM.java | 21 + pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoCommand.java | 2 pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java | 2 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PaymentSv.java | 83 ++++ pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java | 2 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/NotifyResource.java | 40 ++ pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java | 12 pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webFilter/WXDataSourceNameSetFilter.java | 4 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/Code2Session.java | 45 ++ pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml | 32 - pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/PayInfo.java | 4 pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml | 2 pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmCommandHistory.java | 2 pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeVirtualCardMapper.xml | 5 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/result/WechatResultCode.java | 10 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java | 85 ++-- pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PaymentCtrl.java | 511 ++++++++++++++++++++++++++++++ pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PayInfo.java | 4 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/DtoOrder.java | 39 ++ pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml | 4 pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/OrderNotify.java | 50 ++ 27 files changed, 921 insertions(+), 93 deletions(-) diff --git a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webFilter/WXDataSourceNameSetFilter.java b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webFilter/WXDataSourceNameSetFilter.java index 3b127ad..385475b 100644 --- a/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webFilter/WXDataSourceNameSetFilter.java +++ b/pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/webFilter/WXDataSourceNameSetFilter.java @@ -22,6 +22,9 @@ @Override public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + String ds = DataSourceContext.get(); + System.out.println(ds); + HttpServletRequest httpRequest = (HttpServletRequest) servletRequest; String wxDataSourceName = httpRequest.getHeader("tag"); if(wxDataSourceName != null && wxDataSourceName.trim().length() > 0){ @@ -30,6 +33,7 @@ DataSourceContext.set(wxDataSourceName); } else { log.info("鐢ㄦ埛鏈�夋嫨鏁版嵁婧�"); + DataSourceContext.set("ym"); } filterChain.doFilter(servletRequest, servletResponse); diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java index f35cd89..234a1bf 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/command/ComSupport.java @@ -143,7 +143,7 @@ */ protected RmCommandHistory getComHistory(Long comId, String commandCode, String commandName, Long intakeId, String rtuAddr, String protocol, Object param, Long operator ) { RmCommandHistory rmCommandHistory = new RmCommandHistory(); - rmCommandHistory.setId(comId); + rmCommandHistory.setComId(comId); rmCommandHistory.setCommandCode(commandCode); //rmCommandHistory.setCommandName(CodeV202404.getCodeName(commandCode)); rmCommandHistory.setCommandName(commandName); @@ -259,13 +259,13 @@ // 鍒涘缓鍛戒护鏃ュ織瀵硅薄骞舵坊鍔犲埌鏁版嵁搴撲腑 RmCommandHistory rmCommandHistory = getComHistory(comId, commandCode, commandName, intakeId, rtuAddr, protocol, param, operator); rmCommandHistoryMapper.insert(rmCommandHistory); - comId = rmCommandHistory.getId(); + comId = rmCommandHistory.getComId(); // 鍥炶皟寮傚父 if(!response_CallBack.getCode().equals("0001")) { // 鍛戒护鏃ュ織鎵ц缁撴灉鏀逛负澶辫触 rmCommandHistory = new RmCommandHistory(); - rmCommandHistory.setId(comId); + rmCommandHistory.setComId(comId); rmCommandHistory.setResult((byte)0); rmCommandHistoryMapper.updateByPrimaryKeySelective(rmCommandHistory); return BaseResponseUtils.buildErrorMsg(response_CallBack.getContent().toString()); @@ -280,7 +280,7 @@ */ rmCommandHistory = new RmCommandHistory(); - rmCommandHistory.setId(comId); + rmCommandHistory.setComId(comId); rmCommandHistory.setResult((byte) 0); rmCommandHistoryMapper.updateByPrimaryKeySelective(rmCommandHistory); return BaseResponseUtils.buildErrorMsg(CommandResultCode.GET_RESULT_IN_ONE_MINUTE.getMessage()); @@ -298,7 +298,7 @@ * 鏇存柊鎵ц缁撴灉銆佽繑鍥炵粨鏋滄椂闂淬�佺粨鏋滃唴瀹� */ rmCommandHistory = new RmCommandHistory(); - rmCommandHistory.setId(comId); + rmCommandHistory.setComId(comId); rmCommandHistory.setResult((byte)0); rmCommandHistory.setResultTime(new Date()); rmCommandHistory.setResultText((JSONObject)JSON.toJSON(response_CallBack.getContent())); @@ -330,7 +330,7 @@ // 鏇存柊鍛戒护鏃ュ織锛氭墽琛岀粨鏋溿�佽繑鍥炵粨鏋滄椂闂淬�佺粨鏋滃唴瀹� rmCommandHistory = new RmCommandHistory(); - rmCommandHistory.setId(comId); + rmCommandHistory.setComId(comId); rmCommandHistory.setResult((byte)1); rmCommandHistory.setResultTime(new Date()); rmCommandHistory.setResultText((JSONObject)JSON.toJSON(myData)); diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmCommandHistory.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmCommandHistory.java index 83b2a95..e880f90 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmCommandHistory.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoRm/RmCommandHistory.java @@ -40,7 +40,7 @@ */ @JSONField(serializeUsing = ObjectWriterImplToString.class) @TableId(type = IdType.INPUT) - private Long id; + private Long comId; /** * 鍔熻兘鐮� diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoCommand.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoCommand.java index 73f38e6..4cc09a9 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoCommand.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoCommand.java @@ -19,7 +19,7 @@ private static final long serialVersionUID = 1L; @JSONField(serializeUsing= ObjectWriterImplToString.class) - private Long id; + private Long comId; private String commandName; diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoUnclosedValve.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoUnclosedValve.java index b398d09..da4c9c2 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoUnclosedValve.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voRm/VoUnclosedValve.java @@ -3,8 +3,6 @@ import com.dy.common.po.BaseEntity; import lombok.Data; -import java.util.Date; - /** * @author ZhuBaoMin * @date 2024-05-24 16:30 @@ -16,7 +14,7 @@ public class VoUnclosedValve implements BaseEntity { private static final long serialVersionUID = 202405241634001L; - private String commandCode; + //private String commandCode; private String intakeNum; @@ -28,5 +26,5 @@ private String vcNum; - private Date openTime; + //private Date openTime; } diff --git a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoVirtualCard.java b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoVirtualCard.java index 6024046..43f3e22 100644 --- a/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoVirtualCard.java +++ b/pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voSe/VoVirtualCard.java @@ -1,5 +1,7 @@ package com.dy.pipIrrGlobal.voSe; +import com.alibaba.fastjson2.annotation.JSONField; +import com.alibaba.fastjson2.writer.ObjectWriterImplToString; import com.dy.common.po.BaseEntity; import lombok.Data; @@ -14,9 +16,11 @@ public class VoVirtualCard implements BaseEntity { private static final long serialVersionUID = 202405240815001L; - private String id; + @JSONField(serializeUsing= ObjectWriterImplToString.class) + private Long id; - private String vcNum; + @JSONField(serializeUsing= ObjectWriterImplToString.class) + private Long vcNum; private Double money; diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/application-database-sp.yml b/pipIrr-platform/pipIrr-global/src/main/resources/application-database-sp.yml index 1bbe4e2..55ffb5f 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/application-database-sp.yml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/application-database-sp.yml @@ -6,8 +6,8 @@ type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver # url: jdbc:mysql://192.168.40.166:3306/pipIrr_sp?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull -# url: jdbc:mysql://127.0.0.1:3306/pipIrr_sp?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull - url: jdbc:mysql://8.140.179.55:3306/pipIrr_sp?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull + url: jdbc:mysql://127.0.0.1:3306/pipIrr_sp?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull +# url: jdbc:mysql://8.140.179.55:3306/pipIrr_sp?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull username: root password: dysql,;.abc!@# druid: diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml b/pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml index 3b1c640..ab10469 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml @@ -5,8 +5,8 @@ #name: ym type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.cj.jdbc.Driver - url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull -# url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull +# url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull + url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull # url: jdbc:mysql://8.140.179.55:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull username: root password: dysql,;.abc!@# diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml index 2ef9373..f0ba647 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmCommandHistoryMapper.xml @@ -4,7 +4,7 @@ <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoRm.RmCommandHistory"> <!--@mbg.generated--> <!--@Table rm_command_history--> - <id column="id" jdbcType="BIGINT" property="id" /> + <id column="com_id" jdbcType="BIGINT" property="comId" /> <result column="command_code" jdbcType="VARCHAR" property="commandCode" /> <result column="command_name" jdbcType="VARCHAR" property="commandName" /> <result column="intake_id" jdbcType="BIGINT" property="intakeId" /> @@ -19,7 +19,7 @@ </resultMap> <sql id="Base_Column_List"> <!--@mbg.generated--> - id, command_code, command_name, intake_id, rtu_addr, protocol, param, send_time, `operator`, + com_id, command_code, command_name, intake_id, rtu_addr, protocol, param, send_time, `operator`, `result`, result_time, result_text </sql> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> @@ -27,20 +27,20 @@ select <include refid="Base_Column_List" /> from rm_command_history - where id = #{id,jdbcType=BIGINT} + where com_id = #{id,jdbcType=BIGINT} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Long"> <!--@mbg.generated--> delete from rm_command_history - where id = #{id,jdbcType=BIGINT} + where com_id = #{id,jdbcType=BIGINT} </delete> <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoRm.RmCommandHistory"> <!--@mbg.generated--> - insert into rm_command_history (id, command_code, command_name, + insert into rm_command_history (com_id, command_code, command_name, intake_id, rtu_addr, protocol, param, send_time, `operator`, `result`, result_time, result_text) - values (#{id,jdbcType=BIGINT}, #{commandCode,jdbcType=VARCHAR}, #{commandName,jdbcType=VARCHAR}, #{intakeId,jdbcType=BIGINT}, + values (#{comId,jdbcType=BIGINT}, #{commandCode,jdbcType=VARCHAR}, #{commandName,jdbcType=VARCHAR}, #{intakeId,jdbcType=BIGINT}, #{rtuAddr,jdbcType=VARCHAR}, #{protocol,jdbcType=VARCHAR}, #{param,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, #{sendTime,jdbcType=TIMESTAMP}, #{operator,jdbcType=BIGINT}, #{result,jdbcType=TINYINT}, #{resultTime,jdbcType=TIMESTAMP}, #{resultText,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}) @@ -49,8 +49,8 @@ <!--@mbg.generated--> insert into rm_command_history <trim prefix="(" suffix=")" suffixOverrides=","> - <if test="id != null"> - id, + <if test="comId != null"> + com_id, </if> <if test="commandCode != null"> command_code, @@ -87,8 +87,8 @@ </if> </trim> <trim prefix="values (" suffix=")" suffixOverrides=","> - <if test="id != null"> - #{id,jdbcType=BIGINT}, + <if test="comId != null"> + #{comId,jdbcType=BIGINT}, </if> <if test="commandCode != null"> #{commandCode,jdbcType=VARCHAR}, @@ -163,7 +163,7 @@ result_text = #{resultText,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler}, </if> </set> - where id = #{id,jdbcType=BIGINT} + where com_id = #{comId,jdbcType=BIGINT} </update> <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoRm.RmCommandHistory"> <!--@mbg.generated--> @@ -179,19 +179,17 @@ `result` = #{result,jdbcType=TINYINT}, result_time = #{resultTime,jdbcType=TIMESTAMP}, result_text = #{resultText,jdbcType= JAVA_OBJECT, typeHandler=com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler} - where id = #{id,jdbcType=BIGINT} + where com_id = #{comId,jdbcType=BIGINT} </update> <!--鏍规嵁鎿嶄綔鍛業D鑾峰彇鏈叧闃�璁板綍锛堝寘鍚湪绾挎儏鍐碉級--> <select id="getUnclosedValves" resultType="com.dy.pipIrrGlobal.voRm.VoUnclosedValve"> SELECT - com.command_code AS commandCode, inta.name AS intakeNum, rtus.isOnLine, com.rtu_addr AS rtuAddr, - com.param ->>'$.orderNo' AS orderNo, com.param ->>'$.icCardNo' AS vcNum, - com.send_time AS openTime + (SELECT param ->>'$.orderNo' AS orderNo FROM rm_command_history WHERE rtu_addr = com.rtu_addr ORDER BY send_time desc LIMIT 0,1) AS orderNo FROM rm_command_history com INNER JOIN pr_controller con ON com.rtu_addr = con.rtuAddr INNER JOIN pr_intake inta ON con.intakeId = inta.id @@ -214,7 +212,7 @@ AND param ->>'$.orderNo' = com.param ->>'$.orderNo' ) </where> - ORDER BY com.send_time DESC + GROUP BY inta.name, rtus.isOnLine, com.rtu_addr, com.param ->>'$.icCardNo' </select> <!--鏍规嵁鍙栨按鍙D鑾峰彇璇ュ彇姘村彛鏈叧闃�鍙傛暟--> @@ -270,7 +268,7 @@ <!--鏍规嵁鎸囧畾鏉′欢鑾峰彇鍛戒护鏃ュ織鍘嗗彶璁板綍--> <select id="getCommandHistories" resultType="com.dy.pipIrrGlobal.voRm.VoCommand"> SELECT - his.id, + his.com_id AS comId, his.command_name AS commandName, inta.name AS intakeName, his.rtu_addr AS rtuAddr, diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml index fbf92a0..cfebc59 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeClientMapper.xml @@ -396,7 +396,7 @@ <!--鏍规嵁鍐滄埛缂栧彿鑾峰彇5绾ц鏀垮尯鍒掍覆areaCode锛岃ˉ鍗¤繃绋嬩腑寮�鏂板崱浣跨敤--> <select id="getAreaCodeById" resultType="java.lang.Long"> - SELECT districtNum FROM se_client WHERE id = ${clientId} + SELECT districtNum FROM se_client WHERE id = #{clientId} </select> <!--鏍规嵁鍐滄埛缂栧彿鑾峰彇鍐滄埛ID--> diff --git a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeVirtualCardMapper.xml b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeVirtualCardMapper.xml index 2e55f5e..cbe262b 100644 --- a/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeVirtualCardMapper.xml +++ b/pipIrr-platform/pipIrr-global/src/main/resources/mapper/SeVirtualCardMapper.xml @@ -170,7 +170,8 @@ <!--鑾峰彇鍐滄埛鍏ㄩ儴铏氭嫙鍗�--> <select id="getVCs" resultType="com.dy.pipIrrGlobal.voSe.VoVirtualCard"> SELECT - CAST(id AS char) AS id, +<!-- CAST(id AS char) AS id,--> + id, vc_num AS vcNum, money, in_use AS inUse, @@ -190,7 +191,7 @@ <!--鏍规嵁铏氭嫙鍗D鑾峰彇铏氭嫙鍗″璞�--> <select id="getVcById" resultType="com.dy.pipIrrGlobal.voSe.VoVirtualCard"> SELECT - CAST(id AS char) AS id, + id, vc_num AS vcNum, money, in_use AS inUse, diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java index 93cd402..f9a8a68 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/common/CommandSv.java @@ -95,7 +95,7 @@ */ public Long insert(RmCommandHistory po) { rmCommandHistoryMapper.insert(po); - return po.getId(); + return po.getComId(); } /** diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java index 279d91c..3d6439f 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-remote/src/main/java/com/dy/pipIrrRemote/valve/ValveCtrl.java @@ -145,7 +145,7 @@ ComCd92_A2Vo param = new ComCd92_A2Vo(); param.controllerType = controllerType; param.projectNo = projectNo; - param.icCardNo = vc.getVcNum(); + param.icCardNo = vc.getVcNum().toString(); param.waterRemain = 0.0; param.moneyRemain = vc.getMoney(); param.waterPrice = waterPrice; @@ -176,7 +176,7 @@ // 鍒涘缓瑙嗗浘 Com97Vo param = new Com97Vo() ; - param.icCardNo = vc.getVcNum(); + param.icCardNo = vc.getVcNum().toString(); param.moneyRemain = vc.getMoney(); param.waterPrice = waterPrice; param.orderNo = orderNo; diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/PayInfo.java b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/PayInfo.java index 687fabb..539ca81 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/PayInfo.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-sell/src/main/java/com/dy/pipIrrSell/wechatpay/PayInfo.java @@ -38,10 +38,10 @@ */ public static String certificates = "https://api.mch.weixin.qq.com/v3/certificates"; - /* + /** * 鏀粯缁撴灉閫氱煡API */ - public static String notifyUrl = "https://44978f7456.imdo.co/sell/payment/orderNotify"; + public static String notifyUrl = "https://44978f7456.imdo.co/wx/payment/orderNotify"; /* * 鏌ヨ璁㈠崟API diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java index 8aedcb7..ae7601e 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/CommandSv.java @@ -145,7 +145,7 @@ */ public Long insert(RmCommandHistory po) { rmCommandHistoryMapper.insert(po); - return po.getId(); + return po.getComId(); } /** diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java index aa0ef5e..b789701 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/command/ValveCtrl.java @@ -159,7 +159,7 @@ ComCd92_A2Vo param = new ComCd92_A2Vo(); param.controllerType = controllerType; param.projectNo = projectNo; - param.icCardNo = vc.getVcNum(); + param.icCardNo = vc.getVcNum().toString(); param.waterRemain = 0.0; param.moneyRemain = vc.getMoney(); param.waterPrice = waterPrice; @@ -191,7 +191,7 @@ // 鍒涘缓瑙嗗浘 Com97Vo param = new Com97Vo(); - param.icCardNo = vc.getVcNum(); + param.icCardNo = vc.getVcNum().toString(); param.moneyRemain = vc.getMoney(); param.waterPrice = waterPrice; param.orderNo = orderNo; diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/result/WechatResultCode.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/result/WechatResultCode.java index ee429dc..ada7522 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/result/WechatResultCode.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/result/WechatResultCode.java @@ -49,6 +49,7 @@ /** * 铏氭嫙鍗� */ + AREA_CODE_MISTAKE(10001, "璇ュ啘鎴疯鏀垮尯鍒掑紓甯�"), ABNORMAL(10001, "閫�娆惧紓甯�"), PROCESSING(10001, "閫�娆惧鐞嗕腑"), VC_OPEN_ACCOUNT_FAIL(90002, "铏氭嫙鍗¤处鎴锋敞鍐屽け璐�"), @@ -56,7 +57,14 @@ VIRTUAL_CARD_NOT_EXIST(90006, "铏氭嫙鍗¤处鎴蜂笉瀛樺湪"), RECHARGE_NOT_EXIST(90006, "鍏呭�艰褰曚笉瀛樺湪"), RECHARGE_FAIL(90006, "鍏呭�煎け璐�"), - NO_ACCOUNT(40001, "鎮ㄦ寚瀹氱殑铏氭嫙鍗℃湭娉ㄥ唽"); + RECHARGE_ADD_FAIL(10001, "鍏呭�艰褰曟坊鍔犲け璐�"), + NO_ACCOUNT(40001, "鎮ㄦ寚瀹氱殑铏氭嫙鍗℃湭娉ㄥ唽"), + VIRTUAL_CARD_CLIENT_NOT_EXIST(40001, "铏氭嫙鍗℃墍灞炲啘鎴蜂笉瀛樺湪"), + + /** + * 浣嶇疆鏀粯 + */ + SESSION_ID_ERROR(50001, "鐧诲綍鎬両D閿欒"); private final Integer code; private final String message; diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/SeClientToVoClient.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/SeClientToVoClient.java new file mode 100644 index 0000000..e203cff --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/SeClientToVoClient.java @@ -0,0 +1,29 @@ +package com.dy.pipIrrWechat.virtualCard; + +import com.dy.pipIrrGlobal.pojoSe.SeClient; +import com.dy.pipIrrGlobal.voSe.VoClient; +import org.mapstruct.Mapper; +import org.mapstruct.Mapping; +import org.mapstruct.factory.Mappers; + +/** + * @author ZhuBaoMin + * @date 2023-12-25 15:54 + * @LastEditTime 2023-12-25 15:54 + * @Description + */ + +@Mapper +public interface SeClientToVoClient { + SeClientToVoClient INSTANCT = Mappers.getMapper(SeClientToVoClient.class); + + @Mapping(target = "name", source = "name") + @Mapping(target = "clientNum", source = "clientnum") + @Mapping(target = "phone", source = "phone") + @Mapping(target = "idCard", source = "idcard") + //@Mapping(target = "cardCount", source = "cardCount") + @Mapping(target = "address", source = "address") + @Mapping(target = "operateDt", source = "operatedt") + @Mapping(target = "typeId", source = "typeid") + VoClient po2vo(SeClient po); +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java index e53ea94..727175d 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/virtualCard/VirtualCardCtrl.java @@ -1,17 +1,16 @@ package com.dy.pipIrrWechat.virtualCard; -import com.dy.common.aop.SsoAop; import com.dy.common.webUtil.BaseResponse; import com.dy.common.webUtil.BaseResponseUtils; import com.dy.common.webUtil.QueryResultVo; import com.dy.pipIrrGlobal.pojoSe.SeVirtualCard; import com.dy.pipIrrGlobal.voSe.VoVcRecharge; import com.dy.pipIrrGlobal.voSe.VoVirtualCard; -import com.dy.pipIrrWechat.util.PayHelper; -import com.dy.pipIrrWechat.virtualCard.enums.LastOperateENUM; import com.dy.pipIrrWechat.result.WechatResultCode; +import com.dy.pipIrrWechat.util.PayHelper; import com.dy.pipIrrWechat.virtualCard.dto.DtoRegist; import com.dy.pipIrrWechat.virtualCard.dto.DtoVcRecharge; +import com.dy.pipIrrWechat.virtualCard.enums.LastOperateENUM; import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; @@ -43,53 +42,25 @@ private final PayHelper payHelper; /** - * 鑾峰彇鍐滄埛鍏ㄩ儴铏氭嫙鍗� - * @return - */ - @GetMapping(path = "/get") - @SsoAop() - public BaseResponse<List<VoVirtualCard>> getVCs(Long clientId){ - try { - List<VoVirtualCard> res = virtualCardSv.getVCs(clientId); - return BaseResponseUtils.buildSuccess(res); - } catch (Exception e) { - log.error("鑾峰彇鏀粯鏂瑰紡璁板綍寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; - } - } - - /** - * 鏍规嵁铏氭嫙鍗D鑾峰彇铏氭嫙鍗″璞� - * @param vcId - * @return - */ - @GetMapping(path = "/getVcById") - @SsoAop() - public BaseResponse<VoVirtualCard> getVcById(@RequestParam Long vcId){ - try { - return BaseResponseUtils.buildSuccess(virtualCardSv.getVcById(vcId)); - } catch (Exception e) { - log.error("鑾峰彇鏀粯鏂瑰紡璁板綍寮傚父", e); - return BaseResponseUtils.buildException(e.getMessage()) ; - } - } - - /** - * 铏氭嫙鍗¤处鍙锋敞鍐� + * 娉ㄥ唽铏氭嫙鍗� * @param po * @param bindingResult * @return */ @PostMapping(path = "add_vc") - @SsoAop() - public BaseResponse<Boolean> addVC(@RequestBody @Valid DtoRegist po, BindingResult bindingResult){ + public BaseResponse<Boolean> addVC(@RequestBody @Valid DtoRegist po, BindingResult bindingResult) { if(bindingResult != null && bindingResult.hasErrors()){ return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); } Long clientId = po.getClientId(); // 鑾峰彇5绾ц鏀垮尯鍒掍覆areaCode - String areaCode = String.valueOf(virtualCardSv.getAreaCodeById(clientId)); + Long areaCodeL = virtualCardSv.getAreaCodeById(clientId); + if(areaCodeL == null) { + return BaseResponseUtils.buildErrorMsg(WechatResultCode.AREA_CODE_MISTAKE.getMessage()); + } + String areaCode = String.valueOf(areaCodeL); + /** * 鏍规嵁琛屾斂鍖哄垝涓诧紙areaCode锛夊湪铏氭嫙鍗¤〃涓拡瀵硅櫄鎷熷崱缂栧彿锛坴cNum锛夎繘琛屾ā绯婃煡璇� * 濡傛灉5浣嶉『搴忓彿宸茬粡杈惧埌鏈�澶у�硷紝鎻愮ず鐢ㄦ埛鑱旂郴绯荤粺绠$悊鍛� @@ -101,7 +72,7 @@ Integer number = Integer.parseInt(vcNum.substring(12)); number = number + 1; if(number > 65535) { - return BaseResponseUtils.buildFail(WechatResultCode.CARD_NUMBER_OVERRUN.getMessage()); + return BaseResponseUtils.buildErrorMsg(WechatResultCode.CARD_NUMBER_OVERRUN.getMessage()); } vcNum = vcNum.substring(0, 12) + String.format("%05d", number); } else { @@ -118,9 +89,38 @@ seVirtualCard.setCreateTime(new Date()); Long rec = virtualCardSv.insertVirtualCard(seVirtualCard); if(rec == null) { - return BaseResponseUtils.buildFail(WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage()); + return BaseResponseUtils.buildErrorMsg(WechatResultCode.VC_OPEN_ACCOUNT_FAIL.getMessage()); } return BaseResponseUtils.buildSuccess(true) ; + } + + /** + * 鑾峰彇鍐滄埛鍏ㄩ儴铏氭嫙鍗� + * @return + */ + @GetMapping(path = "/get") + public BaseResponse<List<VoVirtualCard>> getVCs(Long clientId){ + try { + return BaseResponseUtils.buildSuccess(virtualCardSv.getVCs(clientId)); + } catch (Exception e) { + log.error("鑾峰彇鏀粯鏂瑰紡璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } + } + + /** + * 鏍规嵁铏氭嫙鍗D鑾峰彇铏氭嫙鍗″璞� + * @param vcId + * @return + */ + @GetMapping(path = "/getVcById") + public BaseResponse<VoVirtualCard> getVcById(@RequestParam Long vcId){ + try { + return BaseResponseUtils.buildSuccess(virtualCardSv.getVcById(vcId)); + } catch (Exception e) { + log.error("鑾峰彇鏀粯鏂瑰紡璁板綍寮傚父", e); + return BaseResponseUtils.buildException(e.getMessage()) ; + } } /** @@ -140,7 +140,6 @@ //}) //@PostMapping(path = "add_refund", consumes = MediaType.APPLICATION_JSON_VALUE) //@Transactional(rollbackFor = Exception.class) - //@SsoAop() //public BaseResponse<Boolean> addRefund(@RequestBody @Valid DtoRefund po, BindingResult bindingResult){ // if(bindingResult != null && bindingResult.hasErrors()){ // return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); @@ -198,7 +197,6 @@ //}) //@PostMapping(path = "audit_refund", consumes = MediaType.APPLICATION_JSON_VALUE) //@Transactional(rollbackFor = Exception.class) - //@SsoAop() //public BaseResponse<Boolean> auditRefund(@RequestBody @Valid DtoAudit po, BindingResult bindingResult) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeySpecException, IOException, SignatureException, InvalidKeyException { // if(bindingResult != null && bindingResult.hasErrors()){ // return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); @@ -256,7 +254,6 @@ * @return */ @GetMapping(path = "/getVcRechargeRecords") - @SsoAop() public BaseResponse<QueryResultVo<List<VoVcRecharge>>> getVcRechargeRecords(DtoVcRecharge dtoVcRecharge){ try { QueryResultVo<List<VoVcRecharge>> res = virtualCardSv.getVcRechargeRecords(dtoVcRecharge); diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PayInfo.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PayInfo.java index 690e30a..017b530 100644 --- a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PayInfo.java +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PayInfo.java @@ -38,10 +38,10 @@ */ public static String certificates = "https://api.mch.weixin.qq.com/v3/certificates"; - /* + /** * 鏀粯缁撴灉閫氱煡API */ - public static String notifyUrl = "https://44978f7456.imdo.co/sell/payment/orderNotify"; + public static String notifyUrl = "https://44978f7456.imdo.co/wx/payment/orderNotify"; /* * 鏌ヨ璁㈠崟API diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PaymentCtrl.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PaymentCtrl.java new file mode 100644 index 0000000..0e8d641 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PaymentCtrl.java @@ -0,0 +1,511 @@ +package com.dy.pipIrrWechat.wechatpay; + +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONObject; +import com.dy.common.webUtil.BaseResponse; +import com.dy.common.webUtil.BaseResponseUtils; +import com.dy.common.webUtil.ResultCodeMsg; +import com.dy.pipIrrGlobal.pojoSe.*; +import com.dy.pipIrrGlobal.voSe.VoClient; +import com.dy.pipIrrWechat.result.WechatResultCode; +import com.dy.pipIrrWechat.util.AesUtil; +import com.dy.pipIrrWechat.util.PayHelper; +import com.dy.pipIrrWechat.util.RestTemplateUtil; +import com.dy.pipIrrWechat.virtualCard.VirtualCardSv; +import com.dy.pipIrrWechat.virtualCard.dto.DtoVirtualCard; +import com.dy.pipIrrWechat.virtualCard.enums.LastOperateENUM; +import com.dy.pipIrrWechat.virtualCard.enums.RefundItemStateENUM; +import com.dy.pipIrrWechat.wechatpay.dto.Code2Session; +import com.dy.pipIrrWechat.wechatpay.dto.DtoOrder; +import com.dy.pipIrrWechat.wechatpay.dto.NotifyResource; +import com.dy.pipIrrWechat.wechatpay.dto.OrderNotify; +import com.dy.pipIrrWechat.wechatpay.enums.RefundStatusENUM; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpHeaders; +import org.springframework.http.MediaType; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.BindingResult; +import org.springframework.web.bind.annotation.*; + +import javax.crypto.NoSuchPaddingException; +import java.io.BufferedReader; +import java.io.IOException; +import java.security.GeneralSecurityException; +import java.security.InvalidKeyException; +import java.security.NoSuchAlgorithmException; +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; + +/** + * @author ZhuBaoMin + * @date 2024-07-16 15:05 + * @LastEditTime 2024-07-16 15:05 + * @Description + */ + +@Slf4j +@Tag(name = "寰俊鏀粯绠$悊", description = "寰俊鏀粯鍚勭鎿嶄綔") +@RestController +@RequestMapping(path="payment") +@RequiredArgsConstructor +public class PaymentCtrl { + private final PaymentSv paymentSv; + private final RestTemplateUtil restTemplateUtil; + private final PayHelper payHelper; + private final VirtualCardSv virtualCardSv; + private final String privateCertFileName = com.dy.pipIrrWechat.wechatpay.PayInfo.privateCertFileName; + private final String appid = com.dy.pipIrrWechat.wechatpay.PayInfo.appid; + private final String secret = com.dy.pipIrrWechat.wechatpay.PayInfo.secret; + private final String mchid = com.dy.pipIrrWechat.wechatpay.PayInfo.mchid; + private final String schema = com.dy.pipIrrWechat.wechatpay.PayInfo.schema; + private final String signType = com.dy.pipIrrWechat.wechatpay.PayInfo.signType; + private final String description = com.dy.pipIrrWechat.wechatpay.PayInfo.description; + private final String loginUrl = com.dy.pipIrrWechat.wechatpay.PayInfo.loginUrl; + private final String notifyUrl = com.dy.pipIrrWechat.wechatpay.PayInfo.notifyUrl; + private final String grantType = com.dy.pipIrrWechat.wechatpay.PayInfo.grantType; + + // 骞冲彴璇佷功鍏挜 + private final Map CERTIFICATE_MAP = new HashMap(); + + /** + * 鐧诲綍鍑瘉鏍¢獙锛屽啘鎴风粦瀹氳处鍙烽�昏緫鍖呭惈鐧诲綍鍑瘉鏍¢獙锛屾鎺ュ彛浣滃簾 + * @param code2Session 鐧诲綍鍑瘉鏍¢獙浼犲叆瀵硅薄 + * @param bindingResult + * @return + * @throws Exception + */ + @Operation(summary = "鐧诲綍鍑瘉鏍¢獙", description = "鐧诲綍鍑瘉鏍¢獙") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = Boolean.class))} + ) + }) + @PostMapping(path = "getSessionId") + @Transactional(rollbackFor = Exception.class) + public BaseResponse<Boolean> getSessionId(@RequestBody @Valid Code2Session code2Session, BindingResult bindingResult) throws Exception { + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + String phoneNumber = code2Session.getPhoneNumber(); + String jsCode = code2Session.getJs_code(); + + Map<String, Object> queryParams = new HashMap<>(); + queryParams.put("appid", appid); + queryParams.put("secret", secret); + queryParams.put("js_code", jsCode); + queryParams.put("grant_type", grantType); + Map<String, String> headerParams = new HashMap<>(); + JSONObject job = restTemplateUtil.get(loginUrl, queryParams, headerParams); + + if(job.getLong("errcode") != null && job.getLong("errcode") >= -1) { + return BaseResponseUtils.buildFail("鐧诲綍鍑瘉鏍¢獙澶辫触"); + } + + String openid = job.getString("openid"); + String sessionKey = job.getString("session_key"); + + Long clientId = paymentSv.getClientIdByPhone(phoneNumber); + String SessionId = ""; + if(clientId != null) { + // 娣诲姞寰俊鐢ㄦ埛璐︽埛璁板綍 + SeOpenId seOpenId = new SeOpenId(); + seOpenId.setClientId(clientId); + seOpenId.setOpenId(openid); + seOpenId.setSessionKey(sessionKey); + seOpenId.setCreateTime(new Date()); + Long rec = paymentSv.addOpenId(seOpenId); + if(rec != null) { + SessionId = String.valueOf(rec); + } + return BaseResponseUtils.buildSuccess(SessionId); + + } else { + return BaseResponseUtils.buildError(WechatResultCode.PHONE_NUMBER_IS_ERROR.getMessage()); + } + } + + /** + * 涓嬭浇寰俊鏀粯骞冲彴璇佷功 娴嬭瘯瀹屽簾闄� + * @return + * @throws Exception + */ + @Operation(summary = "涓嬭浇骞冲彴璇佷功", description = "涓嬭浇骞冲彴璇佷功") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = Boolean.class))} + ) + }) + @GetMapping(path = "certificates") + @Transactional(rollbackFor = Exception.class) + public BaseResponse<Boolean> certificates() throws Exception { + String method = "GET"; + String httpUrl = "/v3/certificates"; + String nonceStr = payHelper.generateRandomString(); + Long timestamp = System.currentTimeMillis() / 1000; + + String header = schema + " " + payHelper.getToken(method, httpUrl, "", nonceStr, timestamp, privateCertFileName); + + Map<String, String> headers = new HashMap<>(); + headers.put("Authorization", header); + headers.put("Accept", "application/json"); + JSONObject job_result = restTemplateUtil.getHeaders(com.dy.pipIrrWechat.wechatpay.PayInfo.certificates,null, headers); + JSONObject job_headers = job_result.getJSONObject("headers"); + String wechatpayNonce = job_headers.getJSONArray("Wechatpay-Nonce").getString(0); + String wechatpaySerial = job_headers.getJSONArray("Wechatpay-Serial").getString(0); + String wechatpaySignature = job_headers.getJSONArray("Wechatpay-Signature").getString(0); + String wechatpaySignatureType = job_headers.getJSONArray("Wechatpay-Signature-Type").getString(0); + String wechatpayTimestamp = job_headers.getJSONArray("Wechatpay-Timestamp").getString(0); + + JSONObject job_body = job_result.getJSONObject("body"); + + // 鏋勯�犻獙绛惧悕涓� + String signatureStr = payHelper.responseSign(wechatpayTimestamp, wechatpayNonce, job_body.toJSONString()); + // 楠岃瘉绛惧悕 + Boolean valid = payHelper.responseSignVerify(wechatpaySerial, signatureStr, wechatpaySignature); + + return BaseResponseUtils.buildSuccess(); + } + + /** + * JSAPI涓嬪崟 + * @param order 涓嬪崟璇锋眰瀵硅薄锛屽寘鍚渶瑕佷紶鍏ョ殑鍙傛暟 + * @param bindingResult + * @return 棰勬敮浠樹氦鏄撲細璇濇爣璇嗭紙鏈夋晥鏈�2灏忔椂锛� + */ + @PostMapping(path = "placeOrder") + @Transactional(rollbackFor = Exception.class) + public BaseResponse<Boolean> placeOrder(@RequestBody @Valid DtoOrder order, BindingResult bindingResult) throws NoSuchPaddingException, NoSuchAlgorithmException, InvalidKeySpecException, IOException, SignatureException, InvalidKeyException { + if(bindingResult != null && bindingResult.hasErrors()){ + return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage()); + } + + // 鎺ユ敹鍙傛暟锛氱櫥褰曟�両D銆佽櫄鎷熷崱ID銆佸厖鍊奸噾棰濓紙鍒嗭級 + Long sessionId = order.getSessionId(); + Long virtualId = order.getVcId(); + Integer rechargeAmount = order.getRechargeAmount(); + + String prepayId = ""; + + SeOpenId po = paymentSv.selectOne(sessionId); + if(po == null) { + return BaseResponseUtils.buildErrorMsg(WechatResultCode.SESSION_ID_ERROR.getMessage()); + } + String openid = po.getOpenId(); + + SeVirtualCard seVirtualCard = virtualCardSv.selectVirtuCardById(virtualId); + if(seVirtualCard == null) { + return BaseResponseUtils.buildErrorMsg(WechatResultCode.VIRTUAL_CARD_NOT_EXIST.getMessage()); + } + Long clientId = seVirtualCard.getClientId(); + + VoClient voClient = paymentSv.getOneClient(clientId); + if(voClient == null) { + return BaseResponseUtils.buildErrorMsg(WechatResultCode.VIRTUAL_CARD_CLIENT_NOT_EXIST.getMessage()); + } + String clientNum = voClient.getClientNum(); + + // 鐢熸垚璁㈠崟鍙峰苟娣诲姞鍏呭�艰褰� + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + String orderNumber = clientNum + dateFormat.format(new Date()); + + // 鐢熸垚铏氭嫙鍗″厖鍊艰褰曪紙閮ㄥ垎瀛楁锛� + DtoVirtualCard virtualCard = new DtoVirtualCard(); + virtualCard.setVirtualId(virtualId); + virtualCard.setClientId(clientId); + virtualCard.setOrderNumber(orderNumber); + virtualCard.setRechargeAmount(rechargeAmount); + BaseResponse result = virtualCardSv.insertVCRecharge(virtualCard); + if(!result.getCode().equals("0001")) { + return BaseResponseUtils.buildErrorMsg(WechatResultCode.RECHARGE_ADD_FAIL.getMessage()); + } + + JSONObject job_body = new JSONObject(); + job_body.put("appid", appid); + job_body.put("mchid", mchid); + job_body.put("description", description); + job_body.put("out_trade_no", orderNumber); + job_body.put("notify_url", notifyUrl); + + //璁㈠崟閲戦 + JSONObject job_amount = new JSONObject(); + job_amount.put("total", rechargeAmount); + job_amount.put("currency", "CNY"); + job_body.put("amount", job_amount); + + //鏀粯鑰� + JSONObject job_payer = new JSONObject(); + job_payer.put("openid", openid); + job_body.put("payer", job_payer); + + // 鑾峰彇闅忔満涓插拰鏃堕棿鎴� + String nonceStr = payHelper.generateRandomString(); + Long timestamp = System.currentTimeMillis() / 1000; + + String method = "POST"; + String httpUrl = "/v3/pay/transactions/jsapi"; + + String body = job_body.toJSONString(); + String header = schema + " " + payHelper.getToken(method, httpUrl, body, nonceStr, timestamp, privateCertFileName); + + Map<String, String> headers = new HashMap<>(); + headers.put("Authorization", header); + headers.put("Accept", "application/json"); + headers.put("Content-Type", "application/json"); + + // 鏆傛椂娉ㄩ噴鎺夛紝璁よ瘉閫氳繃鍚庡啀鏀惧紑 + JSONObject job_result = restTemplateUtil.post(com.dy.pipIrrWechat.wechatpay.PayInfo.orderUrl, body, headers); + if(job_result == null) { + return BaseResponseUtils.buildFail(WechatResultCode.RECHARGE_ADD_FAIL.getMessage()); + } + + return BaseResponseUtils.buildSuccess(job_result) ; + } + + /** + * 鍐嶆绛惧悕 + * @param prepayId 棰勬敮浠樹氦鏄撲細璇濇爣璇� + * @return 灏忕▼搴忚皟璧锋敮浠樺弬鏁� + * @throws Exception + */ + @Operation(summary = "鍐嶆绛惧悕", description = "鍐嶆绛惧悕") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = Boolean.class))} + ) + }) + @GetMapping(path = "/signAgain") + @Transactional(rollbackFor = Exception.class) + public BaseResponse<JSONObject> signAgain(@RequestParam("prepayId") String prepayId) throws Exception { + + // 鑾峰彇闅忔満涓插拰鏃堕棿鎴筹紝鏀惧湪姝ゅ浠ヤ繚璇� + String appid = com.dy.pipIrrWechat.wechatpay.PayInfo.appid; + String timeStamp = String.valueOf(System.currentTimeMillis() / 1000); + String nonceStr = payHelper.generateRandomString(); + String pkg = "prepay_id=" + prepayId; + String message = payHelper.buildMessage_signAgain(appid, timeStamp, nonceStr, pkg); + String paySign = payHelper.sign(message.getBytes("utf-8"), privateCertFileName); + + JSONObject job_result = new JSONObject(); + job_result.put("timeStamp", timeStamp); + job_result.put("nonceStr", nonceStr); + job_result.put("package", pkg); + job_result.put("signType", signType); + job_result.put("paySign", paySign); + + return BaseResponseUtils.buildSuccess(job_result) ; + } + + /** + * 鏀粯閫氱煡/閫�娆剧粨鏋滈�氱煡 + * @param headers + * @param request + * @param response + * @return + * @throws IOException + * @throws GeneralSecurityException + */ + @Operation(summary = "鏀粯閫氱煡", description = "鏀粯閫氱煡") + @ApiResponses(value = { + @ApiResponse( + responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE, + description = "鎿嶄綔缁撴灉锛歵rue锛氭垚鍔燂紝false锛氬け璐ワ紙BaseResponse.content锛�", + content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE, + schema = @Schema(implementation = Boolean.class))} + ) + }) + @PostMapping(path = "orderNotify", consumes = MediaType.APPLICATION_JSON_VALUE) + @Transactional(rollbackFor = Exception.class) + public JSONObject orderNotify(@RequestHeader HttpHeaders headers, HttpServletRequest request, HttpServletResponse response) throws IOException, GeneralSecurityException { + JSONObject result = new JSONObject(); + + /** + * 1.楠岀澶勭悊 + * 浠巋eader涓彇鍑�4涓瓙鍙傛暟 + * 楠屾椂闂村樊锛岃秴杩�5鍒嗛挓鐨勪笉澶勭悊 + * 楠岃瘉绛惧悕 + * 楠岃瘉涔﹀簭鍒楀彿锛屽繀椤讳笌鏌愪竴涓瘉涔︾殑搴忓垪鍙蜂竴鑷� + */ + String wechatpayNonce = String.valueOf(headers.get("Wechatpay-Nonce").get(0)); + String wechatpaySerial = String.valueOf(headers.get("Wechatpay-Serial").get(0)); + String wechatpaySignature = String.valueOf(headers.get("Wechatpay-Signature").get(0)); + String wechatpayTimestamp = String.valueOf(headers.get("Wechatpay-Timestamp").get(0)); + + // 鑾峰彇body鍐呭 + BufferedReader reader = request.getReader(); + StringBuilder stringBuilder = new StringBuilder(); + String line; + while ((line = reader.readLine()) != null) { + stringBuilder.append(line); + } + String bodyStr = stringBuilder.toString(); + + // body杞璞� + OrderNotify orderNotify = JSON.parseObject(bodyStr, OrderNotify.class); + + // 楠屾椂闂存埑锛屾椂闂村樊澶т簬5鍒嗛挓鐨勬嫆缁� + Long timeDiff = (System.currentTimeMillis() / 1000 - Long.parseLong(wechatpayTimestamp))/60; + if(timeDiff > 5) { + response.setStatus(500); + result.put("code", "FAIL"); + result.put("message", "澶辫触"); + return result; + } + + // 鏋勯�犻獙绛惧悕涓� + String signatureStr = payHelper.responseSign(wechatpayTimestamp, wechatpayNonce, bodyStr); + // 楠岃瘉绛惧悕 + Boolean valid = payHelper.responseSignVerify(wechatpaySerial, signatureStr, wechatpaySignature); + if(!valid) { + response.setStatus(500); + result.put("code", "FAIL"); + result.put("message", "澶辫触"); + return result; + } + + // 搴忓垪鍙烽獙璇佽鏀惧湪楠岀鍚庯紝鍥犱负楠岀鏃跺彲鑳戒細涓嬭浇鏂扮殑璇佷功 + boolean SerialIsValid = false; + for (String key : payHelper.CERTIFICATE_MAP.keySet()) { + if(key.equals(wechatpaySerial)) { + SerialIsValid = true; + } + } + if(!SerialIsValid) { + response.setStatus(500); + result.put("code", "FAIL"); + result.put("message", "澶辫触"); + return result; + } + + // 瑙e瘑澶勭悊 + String eventType = orderNotify.getEvent_type(); + + if(eventType != null && eventType.equals("TRANSACTION.SUCCESS")) { + // 鏀粯鎴愬姛鍥炶皟 + /** + * 鏀粯鎴愬姛鐨勫洖璋� + * 鍙栧嚭閫氱煡鏁版嵁瀵硅薄锛岀户鑰屽彇鍑鸿В瀵嗘墍闇�鐨刟ssociatedData鍜宯once锛屼互鍙婂瘑鏂嘽iphertext + * 瑙e瘑ciphertext寰楀埌 + */ + NotifyResource notifyResource = orderNotify.getResource(); + String associatedData = notifyResource.getAssociated_data(); + String nonce = notifyResource.getNonce(); + String ciphertext = notifyResource.getCiphertext(); + + String resource = AesUtil.decryptToString(com.dy.pipIrrWechat.wechatpay.PayInfo.key.getBytes("utf-8"), associatedData.getBytes("utf-8"), nonce.getBytes("utf-8"), ciphertext); + JSONObject job_resource = JSONObject.parseObject(resource); + + // 瑙e瘑鍚庡彇鍑猴細鍟嗘埛璁㈠崟鍙枫�佸井淇℃敮浠樿鍗曞彿銆佷氦鏄撶姸鎬併�佹敮浠樺畬鎴愭椂闂� + String out_trade_no = job_resource.getString("out_trade_no"); + String transaction_id = job_resource.getString("transaction_id"); + String trade_state = job_resource.getString("trade_state"); + Date success_time = job_resource.getDate("success_time"); + + // 濡傛灉褰撳墠璁㈠崟鐘舵�佷负鏈敮浠樼姸鎬侊紝鍒欐洿鏂拌櫄鎷熷崱琛ㄥ強鍏呭�艰〃鍝嶅簲瀛楁 + SeVcRecharge seVcRecharge = virtualCardSv.getVCRechargeByorderNumber(out_trade_no); + if(seVcRecharge != null && seVcRecharge.getOrderState() == 1) { + BaseResponse result_ = virtualCardSv.updateVCRecharge(out_trade_no, success_time); + if(!result_.getCode().equals("0001")) { + response.setStatus(500); + result.put("code", "FAIL"); + result.put("message", "澶辫触"); + return result; + } + } + } else if(eventType != null && eventType.equals("REFUND.SUCCESS")) { + // 閫�娆炬垚鍔熷悗鍥炶皟 + /** + * 閫�娆炬垚鍔熺殑鍥炶皟 + * 鍙栧嚭閫氱煡鏁版嵁瀵硅薄锛岀户鑰屽彇鍑鸿В瀵嗘墍闇�鐨刟ssociatedData鍜宯once锛屼互鍙婂瘑鏂嘽iphertext + * 瑙e瘑ciphertext寰楀埌 + */ + NotifyResource notifyResource = orderNotify.getResource(); + String associatedData = notifyResource.getAssociated_data(); + String nonce = notifyResource.getNonce(); + String ciphertext = notifyResource.getCiphertext(); + + String resource = AesUtil.decryptToString(PayInfo.key.getBytes("utf-8"), associatedData.getBytes("utf-8"), nonce.getBytes("utf-8"), ciphertext); + JSONObject job_resource = JSONObject.parseObject(resource); + + // 瑙e瘑鍚庡彇鍑猴細鍟嗘埛璁㈠崟鍛樸�佸井淇℃敮浠樿鍗曞彿銆佷氦鏄撶姸鎬併�佹敮浠樺畬鎴愭椂闂� + String out_trade_no = job_resource.getString("out_trade_no"); + String transaction_id = job_resource.getString("transaction_id"); + String out_refund_no = job_resource.getString("out_refund_no"); + String refund_status = job_resource.getString("refund_status"); + Date success_time = job_resource.getDate("success_time"); + if(!refund_status.equals("SUCCESS")) { + response.setStatus(500); + result.put("code", "FAIL"); + result.put("message", "澶辫触"); + return result; + } + + // 鏇存柊铏氭嫙鍗¤〃鍙婂厖鍊艰〃鍝嶅簲瀛楁 + SeVcRefundItem seVcRefundItem = new SeVcRefundItem(); + seVcRefundItem.setRefundTime(success_time); + seVcRefundItem.setRefundStatus(RefundItemStateENUM.REFUNDED.getCode()); + Integer rec = virtualCardSv.updateRefundItem(seVcRefundItem); + if(rec == null && rec <= 0) { + response.setStatus(500); + result.put("code", "FAIL"); + result.put("message", "澶辫触"); + return result; + } + + // 鏍规嵁閫�娆惧崟鍙峰弽鏌ラ��娆綢D锛屾牴鎹��娆綢D鑾峰彇閫�娆剧姸鎬佹槸鏈��娆剧殑璁板綍鏁伴噺锛屽鏋滄槸0鍒欒鏄庡叏閮ㄩ��娆惧畬鎴愶紝鏇存柊閫�娆捐〃鐘舵�佷负宸查��娆撅紝灏嗛��娆惧悗閲戦鏇存柊鍒拌櫄鎷熷崱琛� + /** + * 鏍规嵁閫�娆鹃�氱煡鎺ュ彛杩斿洖鐨勯��娆惧崟鍙峰弽鏌ラ��娆綢D锛屾煡璇㈣閫�娆綢D涓嬫湭閫�娆捐褰曟暟閲� + * 濡傛灉缁撴灉涓�0锛屽垯璇ラ��娆惧凡缁忓畬鎴� + * 1. 鏇存柊閫�娆捐〃鐘舵�佷负宸查��娆� + * 2. 灏嗛��娆惧悗浣欓鏇存柊鍒拌櫄鎷熷崱琛ㄤ腑 + */ + Integer noRefundedCount = virtualCardSv.getNoRefundedCount(out_refund_no); + if(noRefundedCount != null && noRefundedCount == 0) { + // 鑾峰彇閫�娆惧璞″苟淇敼閫�娆剧姸鎬� + Long refundId = virtualCardSv.getRefundIdByRefundNumber(out_refund_no); + SeVcRefund seVcRefund = virtualCardSv.selectRefundByRefundId(refundId); + seVcRefund.setRefundStatus(RefundStatusENUM.REFUNDED.getCode()); + virtualCardSv.updateRefund(seVcRefund); + + // 鑾峰彇铏氭嫙鍗″璞″苟淇敼浣欓銆佹渶鍚庢搷浣溿�佹渶鍚庢搷浣滄椂闂� + Long vcId = seVcRefund.getVcId(); + Double afterRefund = seVcRefund.getAfterRefund(); + SeVirtualCard seVirtualCard = virtualCardSv.selectVirtuCardById(vcId); + seVirtualCard.setMoney(afterRefund); + seVirtualCard.setLastOperate(LastOperateENUM.REFUND.getCode()); + seVirtualCard.setLastOperateTime(new Date()); + virtualCardSv.updateVirtualCard(seVirtualCard); + } + } + + // 閫氱煡搴旂瓟 + response.setStatus(200); + result.put("code", "SUCCESS"); + result.put("message", "鎴愬姛"); + return result; + } +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PaymentSv.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PaymentSv.java new file mode 100644 index 0000000..bac6e73 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/PaymentSv.java @@ -0,0 +1,83 @@ +package com.dy.pipIrrWechat.wechatpay; + +import com.dy.pipIrrGlobal.daoSe.SeClientMapper; +import com.dy.pipIrrGlobal.daoSe.SeOpenIdMapper; +import com.dy.pipIrrGlobal.daoSe.SeVcRechargeMapper; +import com.dy.pipIrrGlobal.pojoSe.SeClient; +import com.dy.pipIrrGlobal.pojoSe.SeOpenId; +import com.dy.pipIrrGlobal.pojoSe.SeVcRecharge; +import com.dy.pipIrrGlobal.voSe.VoClient; +import com.dy.pipIrrWechat.virtualCard.SeClientToVoClient; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +/** + * @author ZhuBaoMin + * @date 2024-07-16 15:03 + * @LastEditTime 2024-07-16 15:03 + * @Description + */ + +@Slf4j +@Service +public class PaymentSv { + @Autowired + private SeVcRechargeMapper seVcRechargeMapper; + + @Autowired + private SeOpenIdMapper seOpenIdMapper; + + @Autowired + private SeClientMapper seClientMapper; + + /** + * 鏍规嵁鐧诲綍鎬両D鑾峰彇鐧诲綍鎬佸璞� + * @param sessionId + * @return + */ + SeOpenId selectOne(Long sessionId) { + return seOpenIdMapper.selectByPrimaryKey(sessionId); + } + + /** + * 娣诲姞铏氭嫙鍗″厖鍊艰褰� + * @param po + * @return + */ + Long insertVCRecharge(SeVcRecharge po) { + seVcRechargeMapper.insert(po); + return po.getId(); + } + + /** + * 鏍规嵁涓婚敭鑾峰彇鍐滄埛瀵硅薄 + * @param id 鍐滄埛涓婚敭 + * @return 鍐滄埛瀵硅薄 + */ + public VoClient getOneClient(Long id) { + SeClient seClient = seClientMapper.selectByPrimaryKey(id); + VoClient voClient = SeClientToVoClient.INSTANCT.po2vo(seClient); + return voClient; + } + + /** + * 鏍规嵁鐢佃瘽鍙风爜鑾峰彇鍐滄埛ID + * @param phoneNumber + * @return + */ + public Long getClientIdByPhone(String phoneNumber) { + return seClientMapper.getClientIdByPhone(phoneNumber); + } + + /** + * 娣诲姞寰俊鐢ㄦ埛璐︽埛璁板綍 + * @param po + * @return + */ + public Long addOpenId(SeOpenId po) { + seOpenIdMapper.insert(po); + //return po.getClientId(); + return po.getId(); + } +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/Code2Session.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/Code2Session.java new file mode 100644 index 0000000..0320715 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/Code2Session.java @@ -0,0 +1,45 @@ +package com.dy.pipIrrWechat.wechatpay.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotBlank; +import lombok.Data; + +/** + * @author ZhuBaoMin + * @date 2024-07-16 15:13 + * @LastEditTime 2024-07-16 15:13 + * @Description + */ + +@Data +@Schema(name = "鐧诲綍鍑瘉鏍¢獙浼犲叆瀵硅薄") +public class Code2Session { + public static final long serialVersionUID = 202402221335001L; + + /** + * 灏忕▼搴� appId + */ + @Schema(description = "灏忕▼搴� appId", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotBlank(message = "灏忕▼搴� appId涓嶈兘涓虹┖") + private String appid; + + /** + * 灏忕▼搴� appSecret + */ + @Schema(description = "灏忕▼搴� appSecret", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotBlank(message = "灏忕▼搴� appSecret涓嶈兘涓虹┖") + private String secret; + + /** + * js_code + */ + @Schema(description = "js_code", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotBlank(message = "js_code涓嶈兘涓虹┖") + private String js_code; + + /** + * 鎵嬫満鍙� + */ + @NotBlank(message = "鎵嬫満鍙蜂笉鑳戒负绌�") + private String phoneNumber; +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/DtoOrder.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/DtoOrder.java new file mode 100644 index 0000000..eee9246 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/DtoOrder.java @@ -0,0 +1,39 @@ +package com.dy.pipIrrWechat.wechatpay.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * @author ZhuBaoMin + * @date 2024-07-16 15:14 + * @LastEditTime 2024-07-16 15:14 + * @Description + */ + +@Data +@Schema(name = "涓嬪崟璇锋眰瀵硅薄") +public class DtoOrder { + public static final long serialVersionUID = 202403012108001L; + + /** + * 鐧诲綍鎬両D锛岀敤鏉ヨ幏鍙杘penID + */ + @Schema(description = "鐧诲綍鎬両D", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotNull(message = "鐧诲綍鎬両D涓嶈兘涓虹┖") + private Long sessionId; + + /** + * 铏氭嫙鍗D锛岀敤鏉ヨ幏鍙栬櫄鎷熷崱浣欓 + */ + @Schema(description = "铏氭嫙鍗$紪鍙�", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotNull(message = "铏氭嫙鍗D涓嶈兘涓虹┖") + private Long vcId; + + /** + * 鍏呭�奸噾棰濋噾棰� + */ + @Schema(description = "鏀粯閲戦", requiredMode = Schema.RequiredMode.NOT_REQUIRED) + @NotNull(message = "铏氭敮浠橀噾棰濅笉鑳戒负绌�") + private Integer rechargeAmount; +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/NotifyResource.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/NotifyResource.java new file mode 100644 index 0000000..d5c0f8d --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/NotifyResource.java @@ -0,0 +1,40 @@ +package com.dy.pipIrrWechat.wechatpay.dto; + +import lombok.Data; + +/** + * @author ZhuBaoMin + * @date 2024-07-16 15:14 + * @LastEditTime 2024-07-16 15:14 + * @Description + */ + +@Data +public class NotifyResource { + /** + * 鍘熷绫诲瀷 + * 鍘熷鍥炶皟绫诲瀷涓猴細transaction + */ + private String original_type; + + /** + * 鍔犲瘑绠楁硶绫诲瀷 + * 浠呮敮鎸丄EAD_AES_256_GCM + */ + private String algorithm; + + /** + * 鏁版嵁瀵嗘枃 + */ + private String ciphertext; + + /** + * 闄勫姞鏁版嵁 + */ + public String associated_data; + + /** + * 闅忔満涓� + */ + private String nonce; +} diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/OrderNotify.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/OrderNotify.java new file mode 100644 index 0000000..90d584a --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/dto/OrderNotify.java @@ -0,0 +1,50 @@ +package com.dy.pipIrrWechat.wechatpay.dto; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +/** + * @author ZhuBaoMin + * @date 2024-07-16 15:15 + * @LastEditTime 2024-07-16 15:15 + * @Description + */ + +@Data +@Schema(name = "鏀粯鍜岄��娆惧洖璋冨璞�") +public class OrderNotify { + public static final long serialVersionUID = 202402291431001L; + + /** + * 閫氱煡ID + */ + private String id; + + /** + * 閫氱煡鍒涘缓鏃堕棿 + */ + private String create_time; + + /** + * 閫氱煡绫诲瀷 + * 鏀粯鎴愬姛閫氱煡鐨勭被鍨嬩负锛歍RANSACTION.SUCCESS + */ + private String event_type; + + /** + * 閫氱煡鏁版嵁绫诲瀷 + * 鏀粯鎴愬姛閫氱煡涓猴細encrypt-resource + */ + private String resource_type; + + /** + * 閫氱煡鏁版嵁 + */ + private NotifyResource resource; + + /** + * 鍥炶皟鎽樿锛岄��娆鹃�氱煡鏃犳灞炴�� + */ + private String summary; + +} \ No newline at end of file diff --git a/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/enums/RefundStatusENUM.java b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/enums/RefundStatusENUM.java new file mode 100644 index 0000000..641e106 --- /dev/null +++ b/pipIrr-platform/pipIrr-web/pipIrr-web-wechat/src/main/java/com/dy/pipIrrWechat/wechatpay/enums/RefundStatusENUM.java @@ -0,0 +1,21 @@ +package com.dy.pipIrrWechat.wechatpay.enums; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +/** + * @author ZhuBaoMin + * @date 2024-07-16 15:17 + * @LastEditTime 2024-07-16 15:17 + * @Description + */ + +@Getter +@AllArgsConstructor +public enum RefundStatusENUM { + NO_REFUND((byte)1, "鏈��娆�"), + REFUNDED((byte)2, "宸查��娆�"); + + private final Byte code; + private final String message; +} -- Gitblit v1.8.0