lijilei 3 rokov pred
rodič
commit
4beda5a115

+ 3 - 0
book-dao/src/main/java/com/book/dao/VO/WxPayInfo.java

@@ -13,4 +13,7 @@ public class WxPayInfo {
   private Integer userId;
   private String orderId;
   private String payInfo;
+
+  private String url;
+
 }

+ 25 - 0
book-dao/src/main/java/com/book/dao/cps/mapper/OrdersMapper.java

@@ -0,0 +1,25 @@
+package com.book.dao.cps.mapper;
+
+import com.book.dao.cps.pojo.Orders;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface OrdersMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(Orders record);
+
+    int insertSelective(Orders record);
+
+    Orders selectByPrimaryKey(Integer id);
+
+    int updateByPrimaryKeySelective(Orders record);
+
+    int updateByPrimaryKey(Orders record);
+
+    void updateByOutTradeNo(@Param("out_trade_no") String outTradeNo);
+    Orders selectByOutTradeNo(@Param("out_trade_no") String outTradeNo);
+
+
+}

+ 19 - 0
book-dao/src/main/java/com/book/dao/cps/mapper/WxpayMapper.java

@@ -0,0 +1,19 @@
+package com.book.dao.cps.mapper;
+
+import com.book.dao.cps.pojo.Wxpay;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface WxpayMapper {
+    int deleteByPrimaryKey(Integer id);
+
+    int insert(Wxpay record);
+
+    int insertSelective(Wxpay record);
+
+    Wxpay selectByPrimaryKey(Integer id);
+
+    int updateByPrimaryKeySelective(Wxpay record);
+
+    int updateByPrimaryKey(Wxpay record);
+}

+ 231 - 0
book-dao/src/main/java/com/book/dao/cps/pojo/Orders.java

@@ -0,0 +1,231 @@
+package com.book.dao.cps.pojo;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import lombok.Data;
+
+/**
+ * orders
+ * @author 
+ */
+@Data
+public class Orders implements Serializable {
+    private Integer id;
+
+    /**
+     * 用户ID
+     */
+    private Long userId;
+
+    /**
+     * 渠道商/代理商ID
+     */
+    private Integer adminId;
+
+    /**
+     * 资源ID
+     */
+    private Integer resourceId;
+
+    /**
+     * 支付号ID
+     */
+    private Integer wxpayId;
+
+    /**
+     * 收益分成比例[2位小数]
+     */
+    private BigDecimal benefit;
+
+    /**
+     * 金额
+     */
+    private BigDecimal money;
+
+    /**
+     * 金额收益
+     */
+    private BigDecimal moneyBenefit;
+
+    /**
+     * 支付方式 category.nickname
+     */
+    private String category;
+
+    /**
+     * 业务线:0=微信,1=APP
+     */
+    private Integer businessLine;
+
+    /**
+     * 订单ID
+     */
+    private String payid;
+
+    /**
+     * 商户内部订单号
+     */
+    private String outTradeNo;
+
+    /**
+     * 微信支付订单号
+     */
+    private String transactionId;
+
+    /**
+     * 下单IP
+     */
+    private String ip;
+
+    /**
+     * 推广ID
+     */
+    private Integer referralId;
+
+    /**
+     * 永久referral_id
+     */
+    private Integer referralIdPermanent;
+
+    /**
+     * 书籍ID
+     */
+    private Long bookId;
+
+    /**
+     * 章节ID
+     */
+    private Long chapterId;
+
+    /**
+     * 商品ID
+     */
+    private Integer goodsId;
+
+    /**
+     * 充值看点数
+     */
+    private Integer kandian;
+
+    /**
+     * 赠送看点数
+     */
+    private Integer freeKandian;
+
+    /**
+     * VIP天数
+     */
+    private Integer day;
+
+    /**
+     * 充值类型:1=看点充值,2=VIP充值
+     */
+    private Object type;
+
+    /**
+     * 订单状态:0=待支付,1=已支付
+     */
+    private Object state;
+
+    /**
+     * 活动ID
+     */
+    private Integer activityId;
+
+    /**
+     * 是否扣单:0=不是扣单,1=是扣单
+     */
+    private Boolean deduct;
+
+    /**
+     * 赏金邀请人
+     */
+    private Integer rewardAdminId;
+
+    /**
+     * 赏金金额
+     */
+    private BigDecimal rewardMoney;
+
+    /**
+     * 赏金比例
+     */
+    private BigDecimal rewardBenefit;
+
+    /**
+     * 创建时间
+     */
+    private Integer createtime;
+
+    /**
+     * 更新时间
+     */
+    private Integer updatetime;
+
+    /**
+     * 完成时间
+     */
+    private Integer finishtime;
+
+    /**
+     * 支付方式:0=微信支付,1=四方支付
+     */
+    private Boolean paymentMethod;
+
+    /**
+     * 四方平台订单号
+     */
+    private String pdorderid;
+
+    /**
+     * 四方支付json
+     */
+    private String payJson;
+
+    /**
+     * push_id,push_idx,mark,push_time...
+     */
+    private String ext;
+
+    /**
+     * 渠道ID
+     */
+    private Integer channelId;
+
+    /**
+     * 渠道分成比例
+     */
+    private BigDecimal channelBenefit;
+
+    /**
+     * 角色组 3=渠道 4=代理
+     */
+    private Byte group;
+
+    /**
+     * ??ID
+     */
+    private Integer platformId;
+
+    /**
+     * 推送标记
+     */
+    private Integer mark;
+
+    /**
+     * ????:0=????,1=????
+     */
+    private Boolean paymentMethod1;
+
+    /**
+     * ???????
+     */
+    private String pdorderid1;
+
+    /**
+     * 渠道分成金额
+     */
+    private BigDecimal channelBenefitMoney;
+
+    private static final long serialVersionUID = 1L;
+}

+ 143 - 0
book-dao/src/main/java/com/book/dao/cps/pojo/Wxpay.java

@@ -0,0 +1,143 @@
+package com.book.dao.cps.pojo;
+
+import java.io.Serializable;
+import lombok.Data;
+
+/**
+ * wxpay
+ * @author 
+ */
+@Data
+public class Wxpay implements Serializable {
+    /**
+     * ID
+     */
+    private Integer id;
+
+    /**
+     * 支付名
+     */
+    private String name;
+
+    /**
+     * 开放平台ID
+     */
+    private Integer platformId;
+
+    /**
+     * 支付域名
+     */
+    private String payHost;
+
+    /**
+     * 业务线:0=微信,1=app
+     */
+    private String businessLine;
+
+    /**
+     * 微信支付服务号 App Id
+     */
+    private String appid;
+
+    /**
+     * 微信支付服务号 App Secret
+     */
+    private String secret;
+
+    /**
+     * Icon
+     */
+    private String icon;
+
+    /**
+     * 微开支付服务号校验txt文件
+     */
+    private String payfile;
+
+    /**
+     * 微信支付商户ID
+     */
+    private Integer mcid;
+
+    /**
+     * 微信支付商户API KEY
+     */
+    private String apikey;
+
+    /**
+     * 状态:0=关闭,1=启用
+     */
+    private Object status;
+
+    /**
+     * 是否被封:0=正常,1=被封
+     */
+    private Object isClosure;
+
+    /**
+     * 描述
+     */
+    private String pDesc;
+
+    /**
+     * 0:非默认 1:默认
+     */
+    private Object isdefault;
+
+    /**
+     * 创建时间
+     */
+    private Integer createtime;
+
+    /**
+     * 更新时间
+     */
+    private Integer updatetime;
+
+    /**
+     * 支付方式:0=官方支付,1=四方支付,2=汇聚支付,3=米花支付,4=易宝支付,5=银生宝支付,6=微信h5支付,7=支付宝h5支付,8=现在支付,9=银联支付
+     */
+    private Object paymentMethod;
+
+    /**
+     * 四方支付是否启用分账。1:是,2:否,默认2
+     */
+    private Object quartetIsSplit;
+
+    /**
+     * 四方支付商户ID
+     */
+    private String quartetMerchantId;
+
+    /**
+     * 四方支付APPID
+     */
+    private String quartetAppId;
+
+    /**
+     * 四方支付APPKEY
+     */
+    private String quartetAppKey;
+
+    /**
+     * 四方支付公钥
+     */
+    private String quartetAppPublicKey;
+
+    /**
+     * 四方应用私有编号
+     */
+    private String quartetAppPrivateNo;
+
+    /**
+     * 子商户帐号
+     */
+    private String palmpaySubAccountIds;
+
+    /**
+     * 是否复粉:0=否,1=是
+     */
+    private Byte fufen;
+
+    private static final long serialVersionUID = 1L;
+}

+ 633 - 0
book-dao/src/main/resources/mapper/OrdersMapper.xml

@@ -0,0 +1,633 @@
+<?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.book.dao.cps.mapper.OrdersMapper">
+  <resultMap id="BaseResultMap" type="com.book.dao.cps.pojo.Orders">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="user_id" jdbcType="BIGINT" property="userId" />
+    <result column="admin_id" jdbcType="INTEGER" property="adminId" />
+    <result column="resource_id" jdbcType="INTEGER" property="resourceId" />
+    <result column="wxpay_id" jdbcType="INTEGER" property="wxpayId" />
+    <result column="benefit" jdbcType="DECIMAL" property="benefit" />
+    <result column="money" jdbcType="DECIMAL" property="money" />
+    <result column="money_benefit" jdbcType="DECIMAL" property="moneyBenefit" />
+    <result column="category" jdbcType="VARCHAR" property="category" />
+    <result column="business_line" jdbcType="INTEGER" property="businessLine" />
+    <result column="payid" jdbcType="VARCHAR" property="payid" />
+    <result column="out_trade_no" jdbcType="VARCHAR" property="outTradeNo" />
+    <result column="transaction_id" jdbcType="VARCHAR" property="transactionId" />
+    <result column="ip" jdbcType="VARCHAR" property="ip" />
+    <result column="referral_id" jdbcType="INTEGER" property="referralId" />
+    <result column="referral_id_permanent" jdbcType="INTEGER" property="referralIdPermanent" />
+    <result column="book_id" jdbcType="BIGINT" property="bookId" />
+    <result column="chapter_id" jdbcType="BIGINT" property="chapterId" />
+    <result column="goods_id" jdbcType="INTEGER" property="goodsId" />
+    <result column="kandian" jdbcType="INTEGER" property="kandian" />
+    <result column="free_kandian" jdbcType="INTEGER" property="freeKandian" />
+    <result column="day" jdbcType="INTEGER" property="day" />
+    <result column="type" jdbcType="OTHER" property="type" />
+    <result column="state" jdbcType="OTHER" property="state" />
+    <result column="activity_id" jdbcType="INTEGER" property="activityId" />
+    <result column="deduct" jdbcType="BOOLEAN" property="deduct" />
+    <result column="reward_admin_id" jdbcType="INTEGER" property="rewardAdminId" />
+    <result column="reward_money" jdbcType="DECIMAL" property="rewardMoney" />
+    <result column="reward_benefit" jdbcType="DECIMAL" property="rewardBenefit" />
+    <result column="createtime" jdbcType="INTEGER" property="createtime" />
+    <result column="updatetime" jdbcType="INTEGER" property="updatetime" />
+    <result column="finishtime" jdbcType="INTEGER" property="finishtime" />
+    <result column="payment_method" jdbcType="BOOLEAN" property="paymentMethod" />
+    <result column="pdorderid" jdbcType="VARCHAR" property="pdorderid" />
+    <result column="pay_json" jdbcType="VARCHAR" property="payJson" />
+    <result column="ext" jdbcType="VARCHAR" property="ext" />
+    <result column="channel_id" jdbcType="INTEGER" property="channelId" />
+    <result column="channel_benefit" jdbcType="DECIMAL" property="channelBenefit" />
+    <result column="group" jdbcType="TINYINT" property="group" />
+    <result column="platform_id" jdbcType="INTEGER" property="platformId" />
+    <result column="mark" jdbcType="INTEGER" property="mark" />
+    <result column="payment_method1" jdbcType="BOOLEAN" property="paymentMethod1" />
+    <result column="pdorderid1" jdbcType="VARCHAR" property="pdorderid1" />
+    <result column="channel_benefit_money" jdbcType="DECIMAL" property="channelBenefitMoney" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, user_id, admin_id, resource_id, wxpay_id, benefit, money, money_benefit, category, 
+    business_line, payid, out_trade_no, transaction_id, ip, referral_id, referral_id_permanent, 
+    book_id, chapter_id, goods_id, kandian, free_kandian, `day`, `type`, `state`, activity_id, 
+    deduct, reward_admin_id, reward_money, reward_benefit, createtime, updatetime, finishtime, 
+    payment_method, pdorderid, pay_json, ext, channel_id, channel_benefit, `group`, platform_id, 
+    mark, payment_method1, pdorderid1, channel_benefit_money
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from orders
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <select id="selectByOutTradeNo" resultMap="BaseResultMap">
+    SELECT * FROM test_cps.orders where   out_trade_no = #{out_trade_no,jdbcType=VARCHAR}
+
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    delete from orders
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.book.dao.cps.pojo.Orders" useGeneratedKeys="true">
+    insert into orders (user_id, admin_id, resource_id, 
+      wxpay_id, benefit, money, 
+      money_benefit, category, business_line, 
+      payid, out_trade_no, transaction_id, 
+      ip, referral_id, referral_id_permanent, 
+      book_id, chapter_id, goods_id, 
+      kandian, free_kandian, `day`, 
+      `type`, `state`, activity_id, 
+      deduct, reward_admin_id, reward_money, 
+      reward_benefit, createtime, updatetime, 
+      finishtime, payment_method, pdorderid, 
+      pay_json, ext, channel_id, 
+      channel_benefit, `group`, platform_id, 
+      mark, payment_method1, pdorderid1, 
+      channel_benefit_money)
+    values (#{userId,jdbcType=BIGINT}, #{adminId,jdbcType=INTEGER}, #{resourceId,jdbcType=INTEGER}, 
+      #{wxpayId,jdbcType=INTEGER}, #{benefit,jdbcType=DECIMAL}, #{money,jdbcType=DECIMAL}, 
+      #{moneyBenefit,jdbcType=DECIMAL}, #{category,jdbcType=VARCHAR}, #{businessLine,jdbcType=INTEGER}, 
+      #{payid,jdbcType=VARCHAR}, #{outTradeNo,jdbcType=VARCHAR}, #{transactionId,jdbcType=VARCHAR}, 
+      #{ip,jdbcType=VARCHAR}, #{referralId,jdbcType=INTEGER}, #{referralIdPermanent,jdbcType=INTEGER}, 
+      #{bookId,jdbcType=BIGINT}, #{chapterId,jdbcType=BIGINT}, #{goodsId,jdbcType=INTEGER}, 
+      #{kandian,jdbcType=INTEGER}, #{freeKandian,jdbcType=INTEGER}, #{day,jdbcType=INTEGER}, 
+      #{type,jdbcType=OTHER}, #{state,jdbcType=OTHER}, #{activityId,jdbcType=INTEGER}, 
+      #{deduct,jdbcType=BOOLEAN}, #{rewardAdminId,jdbcType=INTEGER}, #{rewardMoney,jdbcType=DECIMAL}, 
+      #{rewardBenefit,jdbcType=DECIMAL}, #{createtime,jdbcType=INTEGER}, #{updatetime,jdbcType=INTEGER}, 
+      #{finishtime,jdbcType=INTEGER}, #{paymentMethod,jdbcType=BOOLEAN}, #{pdorderid,jdbcType=VARCHAR}, 
+      #{payJson,jdbcType=VARCHAR}, #{ext,jdbcType=VARCHAR}, #{channelId,jdbcType=INTEGER}, 
+      #{channelBenefit,jdbcType=DECIMAL}, #{group,jdbcType=TINYINT}, #{platformId,jdbcType=INTEGER}, 
+      #{mark,jdbcType=INTEGER}, #{paymentMethod1,jdbcType=BOOLEAN}, #{pdorderid1,jdbcType=VARCHAR}, 
+      #{channelBenefitMoney,jdbcType=DECIMAL})
+  </insert>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.book.dao.cps.pojo.Orders" useGeneratedKeys="true">
+    insert into orders
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="userId != null">
+        user_id,
+      </if>
+      <if test="adminId != null">
+        admin_id,
+      </if>
+      <if test="resourceId != null">
+        resource_id,
+      </if>
+      <if test="wxpayId != null">
+        wxpay_id,
+      </if>
+      <if test="benefit != null">
+        benefit,
+      </if>
+      <if test="money != null">
+        money,
+      </if>
+      <if test="moneyBenefit != null">
+        money_benefit,
+      </if>
+      <if test="category != null">
+        category,
+      </if>
+      <if test="businessLine != null">
+        business_line,
+      </if>
+      <if test="payid != null">
+        payid,
+      </if>
+      <if test="outTradeNo != null">
+        out_trade_no,
+      </if>
+      <if test="transactionId != null">
+        transaction_id,
+      </if>
+      <if test="ip != null">
+        ip,
+      </if>
+      <if test="referralId != null">
+        referral_id,
+      </if>
+      <if test="referralIdPermanent != null">
+        referral_id_permanent,
+      </if>
+      <if test="bookId != null">
+        book_id,
+      </if>
+      <if test="chapterId != null">
+        chapter_id,
+      </if>
+      <if test="goodsId != null">
+        goods_id,
+      </if>
+      <if test="kandian != null">
+        kandian,
+      </if>
+      <if test="freeKandian != null">
+        free_kandian,
+      </if>
+      <if test="day != null">
+        `day`,
+      </if>
+      <if test="type != null">
+        `type`,
+      </if>
+      <if test="state != null">
+        `state`,
+      </if>
+      <if test="activityId != null">
+        activity_id,
+      </if>
+      <if test="deduct != null">
+        deduct,
+      </if>
+      <if test="rewardAdminId != null">
+        reward_admin_id,
+      </if>
+      <if test="rewardMoney != null">
+        reward_money,
+      </if>
+      <if test="rewardBenefit != null">
+        reward_benefit,
+      </if>
+      <if test="createtime != null">
+        createtime,
+      </if>
+      <if test="updatetime != null">
+        updatetime,
+      </if>
+      <if test="finishtime != null">
+        finishtime,
+      </if>
+      <if test="paymentMethod != null">
+        payment_method,
+      </if>
+      <if test="pdorderid != null">
+        pdorderid,
+      </if>
+      <if test="payJson != null">
+        pay_json,
+      </if>
+      <if test="ext != null">
+        ext,
+      </if>
+      <if test="channelId != null">
+        channel_id,
+      </if>
+      <if test="channelBenefit != null">
+        channel_benefit,
+      </if>
+      <if test="group != null">
+        `group`,
+      </if>
+      <if test="platformId != null">
+        platform_id,
+      </if>
+      <if test="mark != null">
+        mark,
+      </if>
+      <if test="paymentMethod1 != null">
+        payment_method1,
+      </if>
+      <if test="pdorderid1 != null">
+        pdorderid1,
+      </if>
+      <if test="channelBenefitMoney != null">
+        channel_benefit_money,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="userId != null">
+        #{userId,jdbcType=BIGINT},
+      </if>
+      <if test="adminId != null">
+        #{adminId,jdbcType=INTEGER},
+      </if>
+      <if test="resourceId != null">
+        #{resourceId,jdbcType=INTEGER},
+      </if>
+      <if test="wxpayId != null">
+        #{wxpayId,jdbcType=INTEGER},
+      </if>
+      <if test="benefit != null">
+        #{benefit,jdbcType=DECIMAL},
+      </if>
+      <if test="money != null">
+        #{money,jdbcType=DECIMAL},
+      </if>
+      <if test="moneyBenefit != null">
+        #{moneyBenefit,jdbcType=DECIMAL},
+      </if>
+      <if test="category != null">
+        #{category,jdbcType=VARCHAR},
+      </if>
+      <if test="businessLine != null">
+        #{businessLine,jdbcType=INTEGER},
+      </if>
+      <if test="payid != null">
+        #{payid,jdbcType=VARCHAR},
+      </if>
+      <if test="outTradeNo != null">
+        #{outTradeNo,jdbcType=VARCHAR},
+      </if>
+      <if test="transactionId != null">
+        #{transactionId,jdbcType=VARCHAR},
+      </if>
+      <if test="ip != null">
+        #{ip,jdbcType=VARCHAR},
+      </if>
+      <if test="referralId != null">
+        #{referralId,jdbcType=INTEGER},
+      </if>
+      <if test="referralIdPermanent != null">
+        #{referralIdPermanent,jdbcType=INTEGER},
+      </if>
+      <if test="bookId != null">
+        #{bookId,jdbcType=BIGINT},
+      </if>
+      <if test="chapterId != null">
+        #{chapterId,jdbcType=BIGINT},
+      </if>
+      <if test="goodsId != null">
+        #{goodsId,jdbcType=INTEGER},
+      </if>
+      <if test="kandian != null">
+        #{kandian,jdbcType=INTEGER},
+      </if>
+      <if test="freeKandian != null">
+        #{freeKandian,jdbcType=INTEGER},
+      </if>
+      <if test="day != null">
+        #{day,jdbcType=INTEGER},
+      </if>
+      <if test="type != null">
+        #{type,jdbcType=OTHER},
+      </if>
+      <if test="state != null">
+        #{state,jdbcType=OTHER},
+      </if>
+      <if test="activityId != null">
+        #{activityId,jdbcType=INTEGER},
+      </if>
+      <if test="deduct != null">
+        #{deduct,jdbcType=BOOLEAN},
+      </if>
+      <if test="rewardAdminId != null">
+        #{rewardAdminId,jdbcType=INTEGER},
+      </if>
+      <if test="rewardMoney != null">
+        #{rewardMoney,jdbcType=DECIMAL},
+      </if>
+      <if test="rewardBenefit != null">
+        #{rewardBenefit,jdbcType=DECIMAL},
+      </if>
+      <if test="createtime != null">
+        #{createtime,jdbcType=INTEGER},
+      </if>
+      <if test="updatetime != null">
+        #{updatetime,jdbcType=INTEGER},
+      </if>
+      <if test="finishtime != null">
+        #{finishtime,jdbcType=INTEGER},
+      </if>
+      <if test="paymentMethod != null">
+        #{paymentMethod,jdbcType=BOOLEAN},
+      </if>
+      <if test="pdorderid != null">
+        #{pdorderid,jdbcType=VARCHAR},
+      </if>
+      <if test="payJson != null">
+        #{payJson,jdbcType=VARCHAR},
+      </if>
+      <if test="ext != null">
+        #{ext,jdbcType=VARCHAR},
+      </if>
+      <if test="channelId != null">
+        #{channelId,jdbcType=INTEGER},
+      </if>
+      <if test="channelBenefit != null">
+        #{channelBenefit,jdbcType=DECIMAL},
+      </if>
+      <if test="group != null">
+        #{group,jdbcType=TINYINT},
+      </if>
+      <if test="platformId != null">
+        #{platformId,jdbcType=INTEGER},
+      </if>
+      <if test="mark != null">
+        #{mark,jdbcType=INTEGER},
+      </if>
+      <if test="paymentMethod1 != null">
+        #{paymentMethod1,jdbcType=BOOLEAN},
+      </if>
+      <if test="pdorderid1 != null">
+        #{pdorderid1,jdbcType=VARCHAR},
+      </if>
+      <if test="channelBenefitMoney != null">
+        #{channelBenefitMoney,jdbcType=DECIMAL},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.book.dao.cps.pojo.Orders">
+    update orders
+    <set>
+      <if test="userId != null">
+        user_id = #{userId,jdbcType=BIGINT},
+      </if>
+      <if test="adminId != null">
+        admin_id = #{adminId,jdbcType=INTEGER},
+      </if>
+      <if test="resourceId != null">
+        resource_id = #{resourceId,jdbcType=INTEGER},
+      </if>
+      <if test="wxpayId != null">
+        wxpay_id = #{wxpayId,jdbcType=INTEGER},
+      </if>
+      <if test="benefit != null">
+        benefit = #{benefit,jdbcType=DECIMAL},
+      </if>
+      <if test="money != null">
+        money = #{money,jdbcType=DECIMAL},
+      </if>
+      <if test="moneyBenefit != null">
+        money_benefit = #{moneyBenefit,jdbcType=DECIMAL},
+      </if>
+      <if test="category != null">
+        category = #{category,jdbcType=VARCHAR},
+      </if>
+      <if test="businessLine != null">
+        business_line = #{businessLine,jdbcType=INTEGER},
+      </if>
+      <if test="payid != null">
+        payid = #{payid,jdbcType=VARCHAR},
+      </if>
+      <if test="outTradeNo != null">
+        out_trade_no = #{outTradeNo,jdbcType=VARCHAR},
+      </if>
+      <if test="transactionId != null">
+        transaction_id = #{transactionId,jdbcType=VARCHAR},
+      </if>
+      <if test="ip != null">
+        ip = #{ip,jdbcType=VARCHAR},
+      </if>
+      <if test="referralId != null">
+        referral_id = #{referralId,jdbcType=INTEGER},
+      </if>
+      <if test="referralIdPermanent != null">
+        referral_id_permanent = #{referralIdPermanent,jdbcType=INTEGER},
+      </if>
+      <if test="bookId != null">
+        book_id = #{bookId,jdbcType=BIGINT},
+      </if>
+      <if test="chapterId != null">
+        chapter_id = #{chapterId,jdbcType=BIGINT},
+      </if>
+      <if test="goodsId != null">
+        goods_id = #{goodsId,jdbcType=INTEGER},
+      </if>
+      <if test="kandian != null">
+        kandian = #{kandian,jdbcType=INTEGER},
+      </if>
+      <if test="freeKandian != null">
+        free_kandian = #{freeKandian,jdbcType=INTEGER},
+      </if>
+      <if test="day != null">
+        `day` = #{day,jdbcType=INTEGER},
+      </if>
+      <if test="type != null">
+        `type` = #{type,jdbcType=OTHER},
+      </if>
+      <if test="state != null">
+        `state` = #{state,jdbcType=OTHER},
+      </if>
+      <if test="activityId != null">
+        activity_id = #{activityId,jdbcType=INTEGER},
+      </if>
+      <if test="deduct != null">
+        deduct = #{deduct,jdbcType=BOOLEAN},
+      </if>
+      <if test="rewardAdminId != null">
+        reward_admin_id = #{rewardAdminId,jdbcType=INTEGER},
+      </if>
+      <if test="rewardMoney != null">
+        reward_money = #{rewardMoney,jdbcType=DECIMAL},
+      </if>
+      <if test="rewardBenefit != null">
+        reward_benefit = #{rewardBenefit,jdbcType=DECIMAL},
+      </if>
+      <if test="createtime != null">
+        createtime = #{createtime,jdbcType=INTEGER},
+      </if>
+      <if test="updatetime != null">
+        updatetime = #{updatetime,jdbcType=INTEGER},
+      </if>
+      <if test="finishtime != null">
+        finishtime = #{finishtime,jdbcType=INTEGER},
+      </if>
+      <if test="paymentMethod != null">
+        payment_method = #{paymentMethod,jdbcType=BOOLEAN},
+      </if>
+      <if test="pdorderid != null">
+        pdorderid = #{pdorderid,jdbcType=VARCHAR},
+      </if>
+      <if test="payJson != null">
+        pay_json = #{payJson,jdbcType=VARCHAR},
+      </if>
+      <if test="ext != null">
+        ext = #{ext,jdbcType=VARCHAR},
+      </if>
+      <if test="channelId != null">
+        channel_id = #{channelId,jdbcType=INTEGER},
+      </if>
+      <if test="channelBenefit != null">
+        channel_benefit = #{channelBenefit,jdbcType=DECIMAL},
+      </if>
+      <if test="group != null">
+        `group` = #{group,jdbcType=TINYINT},
+      </if>
+      <if test="platformId != null">
+        platform_id = #{platformId,jdbcType=INTEGER},
+      </if>
+      <if test="mark != null">
+        mark = #{mark,jdbcType=INTEGER},
+      </if>
+      <if test="paymentMethod1 != null">
+        payment_method1 = #{paymentMethod1,jdbcType=BOOLEAN},
+      </if>
+      <if test="pdorderid1 != null">
+        pdorderid1 = #{pdorderid1,jdbcType=VARCHAR},
+      </if>
+      <if test="channelBenefitMoney != null">
+        channel_benefit_money = #{channelBenefitMoney,jdbcType=DECIMAL},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.book.dao.cps.pojo.Orders">
+    update orders
+    set user_id = #{userId,jdbcType=BIGINT},
+      admin_id = #{adminId,jdbcType=INTEGER},
+      resource_id = #{resourceId,jdbcType=INTEGER},
+      wxpay_id = #{wxpayId,jdbcType=INTEGER},
+      benefit = #{benefit,jdbcType=DECIMAL},
+      money = #{money,jdbcType=DECIMAL},
+      money_benefit = #{moneyBenefit,jdbcType=DECIMAL},
+      category = #{category,jdbcType=VARCHAR},
+      business_line = #{businessLine,jdbcType=INTEGER},
+      payid = #{payid,jdbcType=VARCHAR},
+      out_trade_no = #{outTradeNo,jdbcType=VARCHAR},
+      transaction_id = #{transactionId,jdbcType=VARCHAR},
+      ip = #{ip,jdbcType=VARCHAR},
+      referral_id = #{referralId,jdbcType=INTEGER},
+      referral_id_permanent = #{referralIdPermanent,jdbcType=INTEGER},
+      book_id = #{bookId,jdbcType=BIGINT},
+      chapter_id = #{chapterId,jdbcType=BIGINT},
+      goods_id = #{goodsId,jdbcType=INTEGER},
+      kandian = #{kandian,jdbcType=INTEGER},
+      free_kandian = #{freeKandian,jdbcType=INTEGER},
+      `day` = #{day,jdbcType=INTEGER},
+      `type` = #{type,jdbcType=OTHER},
+      `state` = #{state,jdbcType=OTHER},
+      activity_id = #{activityId,jdbcType=INTEGER},
+      deduct = #{deduct,jdbcType=BOOLEAN},
+      reward_admin_id = #{rewardAdminId,jdbcType=INTEGER},
+      reward_money = #{rewardMoney,jdbcType=DECIMAL},
+      reward_benefit = #{rewardBenefit,jdbcType=DECIMAL},
+      createtime = #{createtime,jdbcType=INTEGER},
+      updatetime = #{updatetime,jdbcType=INTEGER},
+      finishtime = #{finishtime,jdbcType=INTEGER},
+      payment_method = #{paymentMethod,jdbcType=BOOLEAN},
+      pdorderid = #{pdorderid,jdbcType=VARCHAR},
+      pay_json = #{payJson,jdbcType=VARCHAR},
+      ext = #{ext,jdbcType=VARCHAR},
+      channel_id = #{channelId,jdbcType=INTEGER},
+      channel_benefit = #{channelBenefit,jdbcType=DECIMAL},
+      `group` = #{group,jdbcType=TINYINT},
+      platform_id = #{platformId,jdbcType=INTEGER},
+      mark = #{mark,jdbcType=INTEGER},
+      payment_method1 = #{paymentMethod1,jdbcType=BOOLEAN},
+      pdorderid1 = #{pdorderid1,jdbcType=VARCHAR},
+      channel_benefit_money = #{channelBenefitMoney,jdbcType=DECIMAL}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByOutTradeNo">
+    update orders
+    <set>
+
+
+      <if test="outTradeNo != null">
+        out_trade_no = #{outTradeNo,jdbcType=VARCHAR},
+      </if>
+      <if test="transactionId != null">
+        transaction_id = #{transactionId,jdbcType=VARCHAR},
+      </if>
+      <if test="ip != null">
+        ip = #{ip,jdbcType=VARCHAR},
+      </if>
+
+      <if test="state != null">
+        `state` = #{state,jdbcType=OTHER},
+      </if>
+      <if test="activityId != null">
+        activity_id = #{activityId,jdbcType=INTEGER},
+      </if>
+      <if test="deduct != null">
+        deduct = #{deduct,jdbcType=BOOLEAN},
+      </if>
+      <if test="rewardAdminId != null">
+        reward_admin_id = #{rewardAdminId,jdbcType=INTEGER},
+      </if>
+      <if test="rewardMoney != null">
+        reward_money = #{rewardMoney,jdbcType=DECIMAL},
+      </if>
+      <if test="rewardBenefit != null">
+        reward_benefit = #{rewardBenefit,jdbcType=DECIMAL},
+      </if>
+      <if test="createtime != null">
+        createtime = #{createtime,jdbcType=INTEGER},
+      </if>
+      <if test="updatetime != null">
+        updatetime = #{updatetime,jdbcType=INTEGER},
+      </if>
+      <if test="finishtime != null">
+        finishtime = #{finishtime,jdbcType=INTEGER},
+      </if>
+      <if test="paymentMethod != null">
+        payment_method = #{paymentMethod,jdbcType=BOOLEAN},
+      </if>
+      <if test="pdorderid != null">
+        pdorderid = #{pdorderid,jdbcType=VARCHAR},
+      </if>
+      <if test="payJson != null">
+        pay_json = #{payJson,jdbcType=VARCHAR},
+      </if>
+      <if test="ext != null">
+        ext = #{ext,jdbcType=VARCHAR},
+      </if>
+      <if test="channelId != null">
+        channel_id = #{channelId,jdbcType=INTEGER},
+      </if>
+      <if test="channelBenefit != null">
+        channel_benefit = #{channelBenefit,jdbcType=DECIMAL},
+      </if>
+      <if test="group != null">
+        `group` = #{group,jdbcType=TINYINT},
+      </if>
+      <if test="platformId != null">
+        platform_id = #{platformId,jdbcType=INTEGER},
+      </if>
+      <if test="mark != null">
+        mark = #{mark,jdbcType=INTEGER},
+      </if>
+      <if test="paymentMethod1 != null">
+        payment_method1 = #{paymentMethod1,jdbcType=BOOLEAN},
+      </if>
+      <if test="pdorderid1 != null">
+        pdorderid1 = #{pdorderid1,jdbcType=VARCHAR},
+      </if>
+      <if test="channelBenefitMoney != null">
+        channel_benefit_money = #{channelBenefitMoney,jdbcType=DECIMAL},
+      </if>
+    </set>
+    where out_trade_no = #{out_trade_no,jdbcType=VARCHAR}
+
+  </update>
+</mapper>

+ 335 - 0
book-dao/src/main/resources/mapper/WxpayMapper.xml

@@ -0,0 +1,335 @@
+<?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.book.dao.cps.mapper.WxpayMapper">
+  <resultMap id="BaseResultMap" type="com.book.dao.cps.pojo.Wxpay">
+    <id column="id" jdbcType="INTEGER" property="id" />
+    <result column="name" jdbcType="VARCHAR" property="name" />
+    <result column="platform_id" jdbcType="INTEGER" property="platformId" />
+    <result column="pay_host" jdbcType="VARCHAR" property="payHost" />
+    <result column="business_line" jdbcType="VARCHAR" property="businessLine" />
+    <result column="appid" jdbcType="VARCHAR" property="appid" />
+    <result column="secret" jdbcType="VARCHAR" property="secret" />
+    <result column="icon" jdbcType="VARCHAR" property="icon" />
+    <result column="payfile" jdbcType="VARCHAR" property="payfile" />
+    <result column="mcid" jdbcType="INTEGER" property="mcid" />
+    <result column="apikey" jdbcType="VARCHAR" property="apikey" />
+    <result column="status" jdbcType="OTHER" property="status" />
+    <result column="is_closure" jdbcType="OTHER" property="isClosure" />
+    <result column="p_desc" jdbcType="VARCHAR" property="pDesc" />
+    <result column="isdefault" jdbcType="OTHER" property="isdefault" />
+    <result column="createtime" jdbcType="INTEGER" property="createtime" />
+    <result column="updatetime" jdbcType="INTEGER" property="updatetime" />
+    <result column="payment_method" jdbcType="OTHER" property="paymentMethod" />
+    <result column="quartet_is_split" jdbcType="OTHER" property="quartetIsSplit" />
+    <result column="quartet_merchant_id" jdbcType="VARCHAR" property="quartetMerchantId" />
+    <result column="quartet_app_id" jdbcType="VARCHAR" property="quartetAppId" />
+    <result column="quartet_app_key" jdbcType="VARCHAR" property="quartetAppKey" />
+    <result column="quartet_app_public_key" jdbcType="VARCHAR" property="quartetAppPublicKey" />
+    <result column="quartet_app_private_no" jdbcType="VARCHAR" property="quartetAppPrivateNo" />
+    <result column="palmpay_sub_account_ids" jdbcType="VARCHAR" property="palmpaySubAccountIds" />
+    <result column="fufen" jdbcType="TINYINT" property="fufen" />
+  </resultMap>
+  <sql id="Base_Column_List">
+    id, `name`, platform_id, pay_host, business_line, appid, secret, icon, payfile, mcid, 
+    apikey, `status`, is_closure, p_desc, isdefault, createtime, updatetime, payment_method, 
+    quartet_is_split, quartet_merchant_id, quartet_app_id, quartet_app_key, quartet_app_public_key, 
+    quartet_app_private_no, palmpay_sub_account_ids, fufen
+  </sql>
+  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
+    select 
+    <include refid="Base_Column_List" />
+    from wxpay
+    where id = #{id,jdbcType=INTEGER}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
+    delete from wxpay
+    where id = #{id,jdbcType=INTEGER}
+  </delete>
+  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.book.dao.cps.pojo.Wxpay" useGeneratedKeys="true">
+    insert into wxpay (`name`, platform_id, pay_host, 
+      business_line, appid, secret, 
+      icon, payfile, mcid, 
+      apikey, `status`, is_closure, 
+      p_desc, isdefault, createtime, 
+      updatetime, payment_method, quartet_is_split, 
+      quartet_merchant_id, quartet_app_id, quartet_app_key, 
+      quartet_app_public_key, quartet_app_private_no, 
+      palmpay_sub_account_ids, fufen)
+    values (#{name,jdbcType=VARCHAR}, #{platformId,jdbcType=INTEGER}, #{payHost,jdbcType=VARCHAR}, 
+      #{businessLine,jdbcType=VARCHAR}, #{appid,jdbcType=VARCHAR}, #{secret,jdbcType=VARCHAR}, 
+      #{icon,jdbcType=VARCHAR}, #{payfile,jdbcType=VARCHAR}, #{mcid,jdbcType=INTEGER}, 
+      #{apikey,jdbcType=VARCHAR}, #{status,jdbcType=OTHER}, #{isClosure,jdbcType=OTHER}, 
+      #{pDesc,jdbcType=VARCHAR}, #{isdefault,jdbcType=OTHER}, #{createtime,jdbcType=INTEGER}, 
+      #{updatetime,jdbcType=INTEGER}, #{paymentMethod,jdbcType=OTHER}, #{quartetIsSplit,jdbcType=OTHER}, 
+      #{quartetMerchantId,jdbcType=VARCHAR}, #{quartetAppId,jdbcType=VARCHAR}, #{quartetAppKey,jdbcType=VARCHAR}, 
+      #{quartetAppPublicKey,jdbcType=VARCHAR}, #{quartetAppPrivateNo,jdbcType=VARCHAR}, 
+      #{palmpaySubAccountIds,jdbcType=VARCHAR}, #{fufen,jdbcType=TINYINT})
+  </insert>
+  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.book.dao.cps.pojo.Wxpay" useGeneratedKeys="true">
+    insert into wxpay
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="name != null">
+        `name`,
+      </if>
+      <if test="platformId != null">
+        platform_id,
+      </if>
+      <if test="payHost != null">
+        pay_host,
+      </if>
+      <if test="businessLine != null">
+        business_line,
+      </if>
+      <if test="appid != null">
+        appid,
+      </if>
+      <if test="secret != null">
+        secret,
+      </if>
+      <if test="icon != null">
+        icon,
+      </if>
+      <if test="payfile != null">
+        payfile,
+      </if>
+      <if test="mcid != null">
+        mcid,
+      </if>
+      <if test="apikey != null">
+        apikey,
+      </if>
+      <if test="status != null">
+        `status`,
+      </if>
+      <if test="isClosure != null">
+        is_closure,
+      </if>
+      <if test="pDesc != null">
+        p_desc,
+      </if>
+      <if test="isdefault != null">
+        isdefault,
+      </if>
+      <if test="createtime != null">
+        createtime,
+      </if>
+      <if test="updatetime != null">
+        updatetime,
+      </if>
+      <if test="paymentMethod != null">
+        payment_method,
+      </if>
+      <if test="quartetIsSplit != null">
+        quartet_is_split,
+      </if>
+      <if test="quartetMerchantId != null">
+        quartet_merchant_id,
+      </if>
+      <if test="quartetAppId != null">
+        quartet_app_id,
+      </if>
+      <if test="quartetAppKey != null">
+        quartet_app_key,
+      </if>
+      <if test="quartetAppPublicKey != null">
+        quartet_app_public_key,
+      </if>
+      <if test="quartetAppPrivateNo != null">
+        quartet_app_private_no,
+      </if>
+      <if test="palmpaySubAccountIds != null">
+        palmpay_sub_account_ids,
+      </if>
+      <if test="fufen != null">
+        fufen,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="name != null">
+        #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="platformId != null">
+        #{platformId,jdbcType=INTEGER},
+      </if>
+      <if test="payHost != null">
+        #{payHost,jdbcType=VARCHAR},
+      </if>
+      <if test="businessLine != null">
+        #{businessLine,jdbcType=VARCHAR},
+      </if>
+      <if test="appid != null">
+        #{appid,jdbcType=VARCHAR},
+      </if>
+      <if test="secret != null">
+        #{secret,jdbcType=VARCHAR},
+      </if>
+      <if test="icon != null">
+        #{icon,jdbcType=VARCHAR},
+      </if>
+      <if test="payfile != null">
+        #{payfile,jdbcType=VARCHAR},
+      </if>
+      <if test="mcid != null">
+        #{mcid,jdbcType=INTEGER},
+      </if>
+      <if test="apikey != null">
+        #{apikey,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        #{status,jdbcType=OTHER},
+      </if>
+      <if test="isClosure != null">
+        #{isClosure,jdbcType=OTHER},
+      </if>
+      <if test="pDesc != null">
+        #{pDesc,jdbcType=VARCHAR},
+      </if>
+      <if test="isdefault != null">
+        #{isdefault,jdbcType=OTHER},
+      </if>
+      <if test="createtime != null">
+        #{createtime,jdbcType=INTEGER},
+      </if>
+      <if test="updatetime != null">
+        #{updatetime,jdbcType=INTEGER},
+      </if>
+      <if test="paymentMethod != null">
+        #{paymentMethod,jdbcType=OTHER},
+      </if>
+      <if test="quartetIsSplit != null">
+        #{quartetIsSplit,jdbcType=OTHER},
+      </if>
+      <if test="quartetMerchantId != null">
+        #{quartetMerchantId,jdbcType=VARCHAR},
+      </if>
+      <if test="quartetAppId != null">
+        #{quartetAppId,jdbcType=VARCHAR},
+      </if>
+      <if test="quartetAppKey != null">
+        #{quartetAppKey,jdbcType=VARCHAR},
+      </if>
+      <if test="quartetAppPublicKey != null">
+        #{quartetAppPublicKey,jdbcType=VARCHAR},
+      </if>
+      <if test="quartetAppPrivateNo != null">
+        #{quartetAppPrivateNo,jdbcType=VARCHAR},
+      </if>
+      <if test="palmpaySubAccountIds != null">
+        #{palmpaySubAccountIds,jdbcType=VARCHAR},
+      </if>
+      <if test="fufen != null">
+        #{fufen,jdbcType=TINYINT},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="com.book.dao.cps.pojo.Wxpay">
+    update wxpay
+    <set>
+      <if test="name != null">
+        `name` = #{name,jdbcType=VARCHAR},
+      </if>
+      <if test="platformId != null">
+        platform_id = #{platformId,jdbcType=INTEGER},
+      </if>
+      <if test="payHost != null">
+        pay_host = #{payHost,jdbcType=VARCHAR},
+      </if>
+      <if test="businessLine != null">
+        business_line = #{businessLine,jdbcType=VARCHAR},
+      </if>
+      <if test="appid != null">
+        appid = #{appid,jdbcType=VARCHAR},
+      </if>
+      <if test="secret != null">
+        secret = #{secret,jdbcType=VARCHAR},
+      </if>
+      <if test="icon != null">
+        icon = #{icon,jdbcType=VARCHAR},
+      </if>
+      <if test="payfile != null">
+        payfile = #{payfile,jdbcType=VARCHAR},
+      </if>
+      <if test="mcid != null">
+        mcid = #{mcid,jdbcType=INTEGER},
+      </if>
+      <if test="apikey != null">
+        apikey = #{apikey,jdbcType=VARCHAR},
+      </if>
+      <if test="status != null">
+        `status` = #{status,jdbcType=OTHER},
+      </if>
+      <if test="isClosure != null">
+        is_closure = #{isClosure,jdbcType=OTHER},
+      </if>
+      <if test="pDesc != null">
+        p_desc = #{pDesc,jdbcType=VARCHAR},
+      </if>
+      <if test="isdefault != null">
+        isdefault = #{isdefault,jdbcType=OTHER},
+      </if>
+      <if test="createtime != null">
+        createtime = #{createtime,jdbcType=INTEGER},
+      </if>
+      <if test="updatetime != null">
+        updatetime = #{updatetime,jdbcType=INTEGER},
+      </if>
+      <if test="paymentMethod != null">
+        payment_method = #{paymentMethod,jdbcType=OTHER},
+      </if>
+      <if test="quartetIsSplit != null">
+        quartet_is_split = #{quartetIsSplit,jdbcType=OTHER},
+      </if>
+      <if test="quartetMerchantId != null">
+        quartet_merchant_id = #{quartetMerchantId,jdbcType=VARCHAR},
+      </if>
+      <if test="quartetAppId != null">
+        quartet_app_id = #{quartetAppId,jdbcType=VARCHAR},
+      </if>
+      <if test="quartetAppKey != null">
+        quartet_app_key = #{quartetAppKey,jdbcType=VARCHAR},
+      </if>
+      <if test="quartetAppPublicKey != null">
+        quartet_app_public_key = #{quartetAppPublicKey,jdbcType=VARCHAR},
+      </if>
+      <if test="quartetAppPrivateNo != null">
+        quartet_app_private_no = #{quartetAppPrivateNo,jdbcType=VARCHAR},
+      </if>
+      <if test="palmpaySubAccountIds != null">
+        palmpay_sub_account_ids = #{palmpaySubAccountIds,jdbcType=VARCHAR},
+      </if>
+      <if test="fufen != null">
+        fufen = #{fufen,jdbcType=TINYINT},
+      </if>
+    </set>
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="com.book.dao.cps.pojo.Wxpay">
+    update wxpay
+    set `name` = #{name,jdbcType=VARCHAR},
+      platform_id = #{platformId,jdbcType=INTEGER},
+      pay_host = #{payHost,jdbcType=VARCHAR},
+      business_line = #{businessLine,jdbcType=VARCHAR},
+      appid = #{appid,jdbcType=VARCHAR},
+      secret = #{secret,jdbcType=VARCHAR},
+      icon = #{icon,jdbcType=VARCHAR},
+      payfile = #{payfile,jdbcType=VARCHAR},
+      mcid = #{mcid,jdbcType=INTEGER},
+      apikey = #{apikey,jdbcType=VARCHAR},
+      `status` = #{status,jdbcType=OTHER},
+      is_closure = #{isClosure,jdbcType=OTHER},
+      p_desc = #{pDesc,jdbcType=VARCHAR},
+      isdefault = #{isdefault,jdbcType=OTHER},
+      createtime = #{createtime,jdbcType=INTEGER},
+      updatetime = #{updatetime,jdbcType=INTEGER},
+      payment_method = #{paymentMethod,jdbcType=OTHER},
+      quartet_is_split = #{quartetIsSplit,jdbcType=OTHER},
+      quartet_merchant_id = #{quartetMerchantId,jdbcType=VARCHAR},
+      quartet_app_id = #{quartetAppId,jdbcType=VARCHAR},
+      quartet_app_key = #{quartetAppKey,jdbcType=VARCHAR},
+      quartet_app_public_key = #{quartetAppPublicKey,jdbcType=VARCHAR},
+      quartet_app_private_no = #{quartetAppPrivateNo,jdbcType=VARCHAR},
+      palmpay_sub_account_ids = #{palmpaySubAccountIds,jdbcType=VARCHAR},
+      fufen = #{fufen,jdbcType=TINYINT}
+    where id = #{id,jdbcType=INTEGER}
+  </update>
+</mapper>

+ 10 - 1
book-server/pom.xml

@@ -81,7 +81,16 @@
             <artifactId>commons-lang3</artifactId>
             <version>3.8</version>
         </dependency>
-
+        <dependency>
+            <groupId>org.apache.httpcomponents</groupId>
+            <artifactId>httpclient</artifactId>
+            <exclusions>
+                <exclusion>
+                    <artifactId>commons-logging</artifactId>
+                    <groupId>commons-logging</groupId>
+                </exclusion>
+            </exclusions>
+        </dependency>
         <dependency>
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>

+ 7 - 7
book-server/src/main/java/com/book/server/controller/WxPayController.java

@@ -1,11 +1,9 @@
 package com.book.server.controller;
 
-import com.book.dao.VO.UserRecentReadVO;
 import com.book.dao.VO.WxPayInfo;
 import com.book.dao.VO.WxPayRequest;
-import com.book.dao.cps.entity.Goods;
 import com.book.dao.cps.mapper.GoodsMapper;
-import com.book.dao.cpsshard.entity.UserRecentlyRead;
+import com.book.server.utils.HttpUtils;
 import com.book.server.common.entity.Result;
 import com.book.server.common.entity.ResultCode;
 import com.book.server.service.WxPayService;
@@ -19,6 +17,10 @@ import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * created in 2021/8/30
@@ -30,8 +32,6 @@ import java.io.IOException;
 @RequestMapping("/api/wxpay")
 @Slf4j
 public class WxPayController extends BaseController {
-    @Autowired
-    private GoodsMapper goodsMapper;
     @Autowired
     private WxPayService wxPayService;
 
@@ -56,9 +56,9 @@ public class WxPayController extends BaseController {
     }
 
     @PostMapping("/notify")
-    public String PayNotify() {
+    public String PayNotify(HttpServletRequest request) {
+        return wxPayService.PayNotify(request);
 
-        return "success";
 
     }
 

+ 4 - 0
book-server/src/main/java/com/book/server/service/WxPayService.java

@@ -4,6 +4,8 @@ import com.book.dao.VO.WxPayInfo;
 import com.book.dao.VO.WxPayRequest;
 import com.book.server.common.entity.Result;
 
+import javax.servlet.http.HttpServletRequest;
+
 /**
  * created in 2021/8/30
  * Project: book-store
@@ -17,4 +19,6 @@ public interface WxPayService {
     WxPayInfo createOrder(WxPayRequest wxPayRequest);
 
 
+    String PayNotify(HttpServletRequest request);
+
 }

+ 130 - 29
book-server/src/main/java/com/book/server/service/impl/WxPayServiceImpl.java

@@ -1,29 +1,21 @@
 package com.book.server.service.impl;
 
-import com.book.dao.VO.PalmpayResponse;
 import com.book.dao.VO.WxPayInfo;
 import com.book.dao.VO.WxPayRequest;
 import com.book.dao.cps.entity.Goods;
-import com.book.dao.cps.mapper.AdminConfigMapper;
-import com.book.dao.cps.mapper.ConfigMapper;
-import com.book.dao.cps.mapper.GoodsMapper;
-import com.book.dao.cps.mapper.OphostMapper;
-import com.book.dao.cps.pojo.AdminConfig;
-import com.book.dao.cps.pojo.Config;
-import com.book.dao.cps.pojo.Ophost;
-import com.book.dao.cps.pojo.User;
-import com.book.server.common.entity.Result;
+import com.book.dao.cps.mapper.*;
+import com.book.dao.cps.pojo.*;
+import com.book.dao.utils.DateUtils;
 import com.book.server.service.UserService;
 import com.book.server.service.WxPayService;
-import com.book.server.utils.DateUtil;
-import com.book.server.utils.HTTPSUtil;
-import com.book.server.utils.JsonUtils;
+import com.book.server.utils.DataUtil;
 import com.book.server.utils.Md5Util;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.servlet.http.HttpServletRequest;
 import java.math.BigDecimal;
-import java.util.HashMap;
+import java.util.*;
 import java.util.concurrent.TimeUnit;
 
 /**
@@ -49,6 +41,12 @@ public class WxPayServiceImpl implements WxPayService {
     private ConfigMapper configMapper;
     @Autowired
     private OphostMapper ophostMapper;
+    @Autowired
+    private OrdersMapper ordersMapper;
+    @Autowired
+    private RechargeMapper rechargeMapper;
+    @Autowired
+    private WxpayMapper wxpayMapper;
 
     @Override
     public WxPayInfo createOrder(WxPayRequest wxPayRequest) {
@@ -63,20 +61,45 @@ public class WxPayServiceImpl implements WxPayService {
         User userByUserId = userService.getUserByUserId(wxPayRequest.getUserId());
         Integer channelId = userByUserId.getChannelId();
         AdminConfig adminConfig = adminConfigMapper.selectByPrimaryKey(channelId);
+        Integer wxpayId = adminConfig.getWxpayId();
+        Wxpay wxpay = wxpayMapper.selectByPrimaryKey(wxpayId);
+        String appid = wxpay.getAppid();
+        String host = wxpay.getPayHost();
+        String palmpayAppid = wxpay.getQuartetAppId();
+        String palmpayMchid = wxpay.getQuartetMerchantId();
+
+        String palmpayAppkey = wxpay.getQuartetAppKey();
+
+
         Integer ophostId = adminConfig.getOphostId();
         Ophost ophost = ophostMapper.selectByPrimaryKey(ophostId);
         Config url_pay = configMapper.selectByName("url_pay");
         String url = url_pay.getValue();
         //todo 入库
-
+        long orderid = TimeUnit.NANOSECONDS.convert(System.currentTimeMillis(), TimeUnit.SECONDS) + wxPayRequest.getUserId();
+        Orders order = new Orders();
+        order.setUserId(userByUserId.getId());
+        order.setAdminId(channelId);
+        order.setWxpayId(wxpayId);
+        order.setMoney(money);
+        order.setCategory("wechat");
+        order.setBusinessLine(0);
+        order.setPayid(String.valueOf(orderid).concat(Md5Util.md5(order + "").substring(10, 20)));
+        order.setOutTradeNo(String.valueOf(orderid));
+        order.setIp(wxPayRequest.getIp());
+        order.setGoodsId(goodId);
+        order.setKandian(goods.getKandian());
+        order.setFreeKandian(goods.getFreeKandian());
+        order.setType(1);
+        order.setCreatetime(DateUtils.getNow());
+        order.setPaymentMethod(true);
+        order.setChannelId(channelId);
 
         HashMap<String, String> map = new HashMap();
 
 
-        long orderid = TimeUnit.NANOSECONDS.convert(System.currentTimeMillis(), TimeUnit.SECONDS) + wxPayRequest.getUserId();
-
-        map.put("appid", PALMPAY_APPID);
-        map.put("mchId", PALMPAY_MCHID);
+        map.put("appid", palmpayAppid);
+        map.put("mchId", palmpayMchid);
         map.put("version", "3.0");
         map.put("charset", "UTF-8");
         map.put("signType", "MD5");
@@ -84,25 +107,26 @@ public class WxPayServiceImpl implements WxPayService {
         map.put("productDesc", goods.getTitle());
         map.put("outTradeNo", orderid + "");
         map.put("money", amount);
-        map.put("callbackUrl", String.format("http://%s.%s/home.html#/center?userId=" + wxPayRequest.getUserId(), adminConfig.getAppid(), ophost.getHost()));
+        map.put("callbackUrl", String.format("http://%s.%s/home.html#/center?userId=%s&channelId=%s",
+                adminConfig.getAppid(), ophost.getHost(), wxPayRequest.getUserId(), adminConfig.getAdminId()));
         map.put("notifyUrl", url + "/api/wxpay/notify");
         map.put("ip", wxPayRequest.getIp());
 
-
-        map.put("subAppid", adminConfig.getAppid());
-        map.put("openid", userByUserId.getOpenid());
+        // todo 修改
+      /*  map.put("subAppid", adminConfig.getAppid());
+        map.put("openid", userByUserId.getOpenid());*/
         map.put("api", "1");
 
 
-        String str = PALMPAY_APPID + "WECHAT_SUB" + money + orderid + PALMPAY_APPKEY;
+        String str = palmpayAppid + "WECHAT_SUB" + money + orderid + palmpayAppkey;
 
         String sign = Md5Util.md5(str);
         // sign = generalSign(map,md5key);
         map.put("sign", sign);
 
-        String form = DateUtil.maptoform(map) + "";
+        String form = DataUtil.maptoform(map) + "";
         System.out.println("请求:" + PALMPAY_URL + "?" + form);
-        String result = HTTPSUtil.sendGetByHttps(PALMPAY_URL, map);
+    /*    String result = HTTPSUtil.sendGetByHttps(PALMPAY_URL, map);
         System.out.println("响应:" + result);
         PalmpayResponse object = JsonUtils.getObject(result, PalmpayResponse.class);
         if (object == null) {
@@ -112,11 +136,88 @@ public class WxPayServiceImpl implements WxPayService {
             return null;
         }
         PalmpayResponse.Result r = object.getResult();
+        order.setPdorderid(r.getPdorderid());
+        order.setPayJson(r.getPay_info());*/
+        ordersMapper.insert(order);
         WxPayInfo wxPayInfo = new WxPayInfo();
 
-        r.getPay_info();
-        wxPayInfo.setPayInfo(r.getPay_info());
-        wxPayInfo.setOrderId(r.getOutTradeNo());
+        wxPayInfo.setUrl(PALMPAY_URL + "?" + form);
+        wxPayInfo.setOrderId(order.getOutTradeNo());
         return wxPayInfo;
     }
+
+    @Override
+    public String PayNotify(HttpServletRequest request) {
+        Map<String, String> map = new HashMap();
+        Map<String, String[]> params = request.getParameterMap();
+        Set<Map.Entry<String, String[]>> entries = params.entrySet();
+        for (Map.Entry<String, String[]> entry : entries) {
+            try {
+                String val = entry.getValue()[0];
+                map.put(entry.getKey(), val.equalsIgnoreCase("null") ? "" : val);
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+        boolean b = signCheck(map, PALMPAY_APPKEY);
+
+
+        String appid = map.get("appid");
+        String mchId = map.get("mchId");
+        String outTradeNo = map.get("outTradeNo");
+        String pdorderid = map.get("pdorderid");
+        String chorderid = map.get("chorderid");
+        String attach = map.get("attach");
+        String status = map.get("status");
+        String openid = map.get("openid");
+        String timeEnd = map.get("timeEnd");
+        if ("success".equals(status)) {
+
+            Orders order = ordersMapper.selectByOutTradeNo(outTradeNo);
+            if (!"1".equals(order.getState())) {
+                Orders orders = new Orders();
+                orders.setOutTradeNo(outTradeNo);
+                orders.setState(1);
+                orders.setPdorderid(pdorderid);
+                orders.setTransactionId(chorderid);
+                orders.setUpdatetime(DateUtils.getNow());
+                orders.setFinishtime(DateUtils.getNow());
+                ordersMapper.updateByOutTradeNo(outTradeNo);
+            }
+
+
+            //TODO 看点
+            Recharge recharge = new Recharge();
+            recharge.setUserId(order.getUserId());
+            recharge.setKandian(order.getKandian());
+            recharge.setFreeKandian(order.getKandian());
+            recharge.setType("1");
+            recharge.setRemainFreeKandian(order.getFreeKandian());
+            recharge.setCreatetime(DateUtils.getNow());
+            rechargeMapper.insert(recharge);
+
+
+        }
+
+
+        return "success";
+    }
+
+
+    //排序,校验
+    private boolean signCheck(Map<String, String> src, String sectKey) {
+        List<String> keys = new ArrayList<>(src.keySet());
+        Collections.sort(keys);
+        StringBuilder builder = new StringBuilder();
+        for (String key : keys) {
+            if (key.equals("sign")) {
+                continue;
+            }
+            String val = src.get(key);
+            builder.append(key).append("=").append(val == null ? "" : val).append("&");
+        }
+        builder.append("key=").append(sectKey);
+        String sign = Md5Util.md5(builder.toString());
+        return sign.equals(src.get("sign"));
+    }
 }

+ 1 - 1
book-server/src/main/java/com/book/server/utils/DateUtil.java → book-server/src/main/java/com/book/server/utils/DataUtil.java

@@ -6,7 +6,7 @@ import java.util.Collections;
 import java.util.List;
 import java.util.Map;
 
-public class DateUtil {
+public class DataUtil {
 	
 	public static String maptoform(Map<String, String> map){
 		String str="";

+ 619 - 0
book-server/src/main/java/com/book/server/utils/HttpUtils.java

@@ -0,0 +1,619 @@
+package com.book.server.utils;
+
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.util.EntityUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.HttpsURLConnection;
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLSocketFactory;
+import javax.servlet.http.HttpServletRequest;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public class HttpUtils {
+	private static Logger logger = LoggerFactory.getLogger(HttpUtils.class);
+	//用于打印log
+	private static AtomicInteger cnt = new AtomicInteger();
+	
+	public static String sendPost(String url, byte[] body){
+		return sendPost(url, null, body,"other");
+	}
+	public static String sendPost(String url, byte[] body,String appid){
+		return sendPost(url, null, body,appid);
+	}
+	public static String sendPost(String url, byte[] body,int timeout ,String appid){
+		return sendPost(url, null, body, timeout ,appid);
+	}
+	public static String sendPostHttps(String url, byte[] body,String appid){
+		return NetworkManager.request(url, body,appid);
+	}
+	public static String sendPost(String url, Map<String, String> params){
+		return sendPost(url, params, 5000);
+	}
+	
+	public static String sendPost2(String url, Map<String, String> params){
+		return sendPost2(url, params, 5000);
+	}
+	public static String sendPost(String url,Map<String, String> heads, byte[] body){
+		return sendPost(url,heads,body,"other");
+	}
+	public static String sendPost(String url,Map<String, String> heads, byte[] body,String appid){
+
+		String result = "";
+		HttpURLConnection httpURLConnection = null;
+		InputStream inputStream = null;
+		OutputStream outputStream = null;
+		BufferedReader reader = null;
+		StringBuffer buffer = new StringBuffer();
+		try {
+			URL u = new URL(url);
+			httpURLConnection = (HttpURLConnection) u.openConnection();
+			httpURLConnection.setRequestMethod("POST");
+			httpURLConnection.setConnectTimeout(8000);
+			httpURLConnection.setReadTimeout(30000);
+			httpURLConnection.setDoInput(true);
+			httpURLConnection.setDoOutput(true);
+			httpURLConnection.setUseCaches(false);
+			if(null != heads && !heads.isEmpty()){
+				for (Entry<String, String> entry : heads.entrySet()) {
+					httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
+				}
+			}
+			
+			httpURLConnection.connect();
+			
+			outputStream = httpURLConnection.getOutputStream();
+			
+			outputStream.write(body);
+			outputStream.flush();
+			outputStream.close();
+			inputStream = httpURLConnection.getInputStream();
+			reader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
+			String line = null;
+			while ((line = reader.readLine()) != null) {
+				buffer.append(line);
+			}
+			result = buffer.toString();
+		} catch (Exception e) {
+			e.printStackTrace();
+			logger.error("sendPost Exception", e);
+			logger.error("HttpUtils#sendPost#body=" + new String(body));
+		}
+		finally {
+
+			if(inputStream != null){
+				try {
+					inputStream.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if(reader != null){
+				try {
+					reader.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if(httpURLConnection != null){
+				httpURLConnection.disconnect();
+			}
+		}
+		return result;
+	}
+	public static String sendPost(String url,Map<String, String> heads, byte[] body,int timeout,String appid){
+
+		String result = "";
+		HttpURLConnection httpURLConnection = null;
+		InputStream inputStream = null;
+		OutputStream outputStream = null;
+		BufferedReader reader = null;
+		StringBuffer buffer = new StringBuffer();
+		try {
+			URL u = new URL(url);
+			httpURLConnection = (HttpURLConnection) u.openConnection();
+			httpURLConnection.setRequestMethod("POST");
+			httpURLConnection.setConnectTimeout(timeout);
+			httpURLConnection.setReadTimeout(timeout);
+			//伪造User-Agent
+//			httpURLConnection.setRequestProperty("User-Agent", "Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)");
+			httpURLConnection.setDoInput(true);
+			httpURLConnection.setDoOutput(true);
+			httpURLConnection.setUseCaches(false);
+			if(null != heads && !heads.isEmpty()){
+				for (Entry<String, String> entry : heads.entrySet()) {
+					httpURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
+				}
+			}
+
+			httpURLConnection.connect();
+
+			outputStream = httpURLConnection.getOutputStream();
+
+			outputStream.write(body);
+			outputStream.flush();
+			outputStream.close();
+			inputStream = httpURLConnection.getInputStream();
+			reader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
+			String line = null;
+			while ((line = reader.readLine()) != null) {
+				buffer.append(line);
+			}
+			result = buffer.toString();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		finally {
+
+			if(inputStream != null){
+				try {
+					inputStream.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if(reader != null){
+				try {
+					reader.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if(httpURLConnection != null){
+				httpURLConnection.disconnect();
+			}
+		}
+		return result;
+	}
+
+	public static String sendPostHttps(String url,Map<String, String> heads, byte[] body) {
+		String result = "";
+		HttpsURLConnection httpsURLConnection = null;
+		InputStream inputStream = null;
+		OutputStream outputStream = null;
+		BufferedReader reader = null;
+		StringBuffer buffer = new StringBuffer();
+		try {
+	        javax.net.ssl.TrustManager[] tm = {  new MyX509TrustManager() };    
+	        SSLContext sslContext = SSLContext.getInstance("SSL", "SunJSSE");    
+	        sslContext.init(null,  tm, new java.security.SecureRandom());    
+	          
+	        // 从上述SSLContext对象中得到SSLSocketFactory对象     
+	        SSLSocketFactory ssf = sslContext.getSocketFactory();    
+	        //打开连接  
+	        URL urlObj = new URL(url);    
+	        httpsURLConnection = (HttpsURLConnection) urlObj.openConnection();    
+	        httpsURLConnection.setSSLSocketFactory(ssf);    
+			httpsURLConnection.setRequestMethod("POST");
+			httpsURLConnection.setConnectTimeout(8000);
+			httpsURLConnection.setReadTimeout(30000);
+			httpsURLConnection.setDoInput(true);
+			httpsURLConnection.setDoOutput(true);
+			httpsURLConnection.setUseCaches(false);
+			if(null != heads && !heads.isEmpty()){
+				for (Entry<String, String> entry : heads.entrySet()) {
+					httpsURLConnection.setRequestProperty(entry.getKey(), entry.getValue());
+				}
+			}
+			
+			httpsURLConnection.connect();
+			
+			outputStream = httpsURLConnection.getOutputStream();
+			
+			outputStream.write(body);
+			outputStream.flush();
+			outputStream.close();
+			inputStream = httpsURLConnection.getInputStream();
+			reader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
+			String line = null;
+			while ((line = reader.readLine()) != null) {
+				buffer.append(line);
+			}
+			result = buffer.toString();
+		} catch (Exception e) {
+			logger.error("sendPost Exception", e);
+			logger.error("HttpUtils#sendPost#body=" + new String(body));
+		} 
+		finally {
+			if(inputStream != null){
+				try {
+					inputStream.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if(reader != null){
+				try {
+					reader.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if(httpsURLConnection != null){
+				httpsURLConnection.disconnect();
+			}
+		}
+		return result;
+	}	
+	
+	public static String sendPost(String url, Map<String, String> params,int timeOut){
+		String result = "";
+		HttpURLConnection httpURLConnection = null;
+		InputStream inputStream = null;
+		OutputStream outputStream = null;
+		BufferedReader reader = null;
+		StringBuffer buffer = new StringBuffer();
+		try {
+			URL u = new URL(url);
+			httpURLConnection = (HttpURLConnection) u.openConnection();
+			httpURLConnection.setRequestMethod("POST");
+			httpURLConnection.setConnectTimeout(5000);
+			httpURLConnection.setReadTimeout(timeOut);
+			httpURLConnection.setDoInput(true);
+			httpURLConnection.setDoOutput(true);
+			httpURLConnection.setUseCaches(false);
+			httpURLConnection.connect();
+			
+			outputStream = httpURLConnection.getOutputStream();
+			
+			StringBuffer buffer2 = new StringBuffer();
+			Set<String> keys = params.keySet();
+			for(String key : keys){
+				buffer2.append(key);
+				buffer2.append("=");
+				String v = params.get(key);
+				if(v == null || "".equals(v)){
+					buffer2.append(v);
+				}else{
+					buffer2.append(URLEncoder.encode(params.get(key),"utf-8"));
+				}
+				buffer2.append("&");
+			}
+			
+			String temp = buffer2.toString();
+			String body = temp.substring(0, temp.length() - 1);
+			logger.info("HttpUtils#sendPost#body=" + body);
+			outputStream.write(body.getBytes("utf-8"));
+			outputStream.flush();
+			outputStream.close();
+			inputStream = httpURLConnection.getInputStream();
+			reader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
+			String line = null;
+			while ((line = reader.readLine()) != null) {
+				buffer.append(line);
+			}
+			result = buffer.toString();
+		} catch (Exception e) {
+			e.printStackTrace();
+			return "";
+		} 
+		finally {
+			if(inputStream != null){
+				try {
+					inputStream.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if(reader != null){
+				try {
+					reader.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if(httpURLConnection != null){
+				httpURLConnection.disconnect();
+			}
+		}
+		return result;
+	}
+	
+	
+	
+	public static String sendGet(String url){
+		CloseableHttpClient httpclient = HttpClients.createDefault();
+//		String parameters = httpBuildQuery(data);
+		long time = System.currentTimeMillis();
+		int step = cnt.incrementAndGet();
+//		System.out.println("["+parameters+"]");
+//		logger.info(String.format("request%d:%s",step,parameters));
+		String realUrl = url;
+		logger.info("realUrl==="+realUrl);
+		HttpGet httpget = new HttpGet(realUrl);  
+		RequestConfig requestConfig = RequestConfig.custom()  
+		        .setConnectTimeout(5000).setConnectionRequestTimeout(1000)  
+		        .setSocketTimeout(30000).build(); 
+		httpget.setConfig(requestConfig);
+		httpget.setHeader("Referer", "http://pay.zhangzhongzhifu.com");
+		String result = "";
+		CloseableHttpResponse resp =null;
+		try {
+			resp = httpclient.execute(httpget);
+			logger.info(String.format("time%d:%d",step,(System.currentTimeMillis()-time)));
+			 // 获取响应实体    
+            HttpEntity entity = resp.getEntity();
+            result = EntityUtils.toString(entity);
+            logger.info(String.format("reponse%d:%s",step,result));
+		} catch (Exception e) {
+			e.printStackTrace();
+			logger.error(String.format("err%d:%s",step, url),e);
+		}finally{
+			try {
+				if(resp != null) {
+					resp.close();
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				logger.error(String.format("close%d:%s",step, url),e);
+			}
+		}
+         
+        return result;
+	}
+	public static String sendGet(String url,String parameters){
+		CloseableHttpClient httpclient = HttpClients.createDefault();
+//		String parameters = httpBuildQuery(data);
+		long time = System.currentTimeMillis();
+		int step = cnt.incrementAndGet();
+		System.out.println("["+parameters+"]");
+		logger.info(String.format("request%d:%s",step,parameters));
+		String realUrl = url+"?"+parameters;
+		logger.info("realUrl==="+realUrl);
+		HttpGet httpget = new HttpGet(realUrl);  
+		RequestConfig requestConfig = RequestConfig.custom()  
+				.setConnectTimeout(5000).setConnectionRequestTimeout(1000)  
+				.setSocketTimeout(30000).build(); 
+		httpget.setConfig(requestConfig);
+		String result = "";
+		CloseableHttpResponse resp =null;
+		try {
+			resp = httpclient.execute(httpget);
+			logger.info(String.format("time%d:%d",step,(System.currentTimeMillis()-time)));
+			// 获取响应实体    
+			HttpEntity entity = resp.getEntity();
+			result = EntityUtils.toString(entity);
+			logger.info(String.format("reponse%d:%s",step,result));
+		} catch (Exception e) {
+			e.printStackTrace();
+			logger.error(String.format("err%d:%s",step, url),e);
+		}finally{
+			try {
+				if(resp != null) {
+					resp.close();
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				logger.error(String.format("close%d:%s",step, url),e);
+			}
+		}
+		
+		return result;
+	}
+	public static String sendGet(String url,Map<String, String> data){
+		CloseableHttpClient httpclient = HttpClients.createDefault();
+		String parameters = httpBuildQuery(data);
+		long time = System.currentTimeMillis();
+		int step = cnt.incrementAndGet();
+		logger.info(String.format("request%d:%s",step,parameters));
+		String realUrl = data.size()>0?url+"?"+parameters:url;
+		logger.info("realUrl==="+realUrl);
+		HttpGet httpget = new HttpGet(realUrl);  
+		RequestConfig requestConfig = RequestConfig.custom()  
+				.setConnectTimeout(5000).setConnectionRequestTimeout(1000)  
+				.setSocketTimeout(30000).build(); 
+		httpget.setConfig(requestConfig);
+		String result = "";
+		CloseableHttpResponse resp =null;
+		try {
+			resp = httpclient.execute(httpget);
+			logger.info(String.format("time%d:%d",step,(System.currentTimeMillis()-time)));
+			// 获取响应实体    
+			HttpEntity entity = resp.getEntity();
+			result = EntityUtils.toString(entity);
+			logger.info(String.format("reponse%d:%s",step,result));
+		} catch (Exception e) {
+			e.printStackTrace();
+			logger.error(String.format("err%d:%s",step, url),e);
+		}finally{
+			try {
+				if(resp != null) {
+					resp.close();
+				}
+			} catch (Exception e) {
+				e.printStackTrace();
+				logger.error(String.format("close%d:%s",step, url),e);
+			}
+		}
+		
+		return result;
+	}
+	
+	public static String sendPost2(String url, Map<String, String> params,int timeOut){
+		String result = "";
+		HttpURLConnection httpURLConnection = null;
+		InputStream inputStream = null;
+		OutputStream outputStream = null;
+		BufferedReader reader = null;
+		StringBuffer buffer = new StringBuffer();
+		try {
+			URL u = new URL(url);
+			httpURLConnection = (HttpURLConnection) u.openConnection();
+			httpURLConnection.setRequestMethod("POST");
+			httpURLConnection.setConnectTimeout(5000);
+			httpURLConnection.setReadTimeout(timeOut);
+			httpURLConnection.setDoInput(true);
+			httpURLConnection.setDoOutput(true);
+			httpURLConnection.setUseCaches(false);
+			httpURLConnection.connect();
+			
+			outputStream = httpURLConnection.getOutputStream();
+			
+			StringBuffer buffer2 = new StringBuffer();
+			Set<String> keys = params.keySet();
+			for(String key : keys){
+				buffer2.append(key);
+				buffer2.append("=");
+				String v = params.get(key);
+				if(v == null || "".equals(v)){
+					buffer2.append(v);
+				}else{
+					buffer2.append(params.get(key));
+				}
+				buffer2.append("&");
+			}
+			
+			String temp = buffer2.toString();
+			String body = temp.substring(0, temp.length() - 1);
+			logger.info("HttpUtils#sendPost#body=" + body);
+			outputStream.write(body.getBytes("utf-8"));
+			outputStream.flush();
+			outputStream.close();
+			inputStream = httpURLConnection.getInputStream();
+			reader = new BufferedReader(new InputStreamReader(inputStream, "utf-8"));
+			String line = null;
+			while ((line = reader.readLine()) != null) {
+				buffer.append(line);
+			}
+			result = buffer.toString();
+		} catch (Exception e) {
+			e.printStackTrace();
+			return "";
+		} 
+		finally {
+			if(inputStream != null){
+				try {
+					inputStream.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if(reader != null){
+				try {
+					reader.close();
+				} catch (IOException e) {
+					e.printStackTrace();
+				}
+			}
+			if(httpURLConnection != null){
+				httpURLConnection.disconnect();
+			}
+		}
+		return result;
+	}
+	
+	
+	
+	/**
+	 *  执行POST请求
+	 * @param url String 访问URL
+	 * @param content json 字符串的请求报文
+	 * @return String 响应报文
+	 * @throws IOException 
+	 * @throws ClientProtocolException 
+	 * @throws Exception
+	 *             异常
+	 */
+	public static String executePost(String url, String content) throws ClientProtocolException, IOException {
+		DefaultHttpClient client = new DefaultHttpClient();
+		HttpPost post = new HttpPost(url);
+		try{
+			post.setEntity(new StringEntity(content, "UTF-8"));
+			HttpResponse response = client.execute(post);
+			HttpEntity entity = response.getEntity();
+			String rspMessage = EntityUtils.toString(entity, "UTF-8");
+			EntityUtils.consume(entity);
+			return rspMessage;
+		}finally{
+			client.getConnectionManager().shutdown();
+		}
+	}
+	
+	/**
+	 * 参数编码
+	 * @param data
+	 * @return 
+	 */
+	public static String httpBuildQuery(Map<String, String> data) {
+		if(data.size() == 0) {
+			return "";
+		}
+		
+		String ret = "";
+		String k, v;
+		Iterator<String> iterator = data.keySet().iterator();
+		while (iterator.hasNext()) {
+			k = iterator.next();
+			v = data.get(k);
+			if(v == null) {
+				continue;
+			}
+			try {
+				ret += URLEncoder.encode(k, "utf8") + "=" + URLEncoder.encode(v, "utf8");
+			} catch (Exception e) {
+				logger.error("err:"+k,e);
+				continue;
+			}
+			ret += "&";
+		}
+		return ret.substring(0, ret.length() - 1);
+	}
+	
+	public static String getRequestPostContent(HttpServletRequest request) {
+		try {
+			BufferedReader reader = request.getReader();
+			StringBuilder reportBuilder = new StringBuilder();
+			String tempStr = "";
+			while ((tempStr = reader.readLine()) != null) {
+				reportBuilder.append(tempStr);
+			}
+			return reportBuilder.toString();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return null;
+	}
+	
+	public static Map<String, String> getRequestDecodeParams(HttpServletRequest request){
+		Map<String, String> map = new HashMap<String, String>();
+		
+		Map<String, String[]> params = request.getParameterMap();
+		for (Entry<String, String[]> entry : params.entrySet()) {
+			try {
+				String val = URLDecoder.decode(entry.getValue()[0],"utf-8");
+				map.put(entry.getKey(), val.equalsIgnoreCase("null")?"":val);
+			} catch (UnsupportedEncodingException e) {
+				e.printStackTrace();
+			}
+		}
+		return map;
+	}
+	
+	public static void main(String[] args) throws Exception {
+	}
+
+
+
+
+}

+ 39 - 0
book-server/src/main/java/com/book/server/utils/MyX509TrustManager.java

@@ -0,0 +1,39 @@
+package com.book.server.utils;
+
+import com.sun.net.ssl.TrustManager;
+
+import javax.net.ssl.X509TrustManager;
+import java.security.cert.CertificateException;
+import java.security.cert.X509Certificate;
+
+/**  
+ * 证书信任管理器(用于https请求)  
+ * 这个证书管理器的作用就是让它信任我们指定的证书,下面的代码意味着信任所有证书,不管是否权威机构颁发。  
+ * @author zhangwenchao  
+ *  
+ */  
+public class MyX509TrustManager implements  X509TrustManager, TrustManager{  
+  
+    @Override  
+    public void checkClientTrusted(X509Certificate[] chain, String authType)  
+            throws CertificateException {  
+          
+          
+    }  
+  
+    @Override  
+    public void checkServerTrusted(X509Certificate[] chain, String authType)  
+            throws CertificateException {  
+          
+          
+    }  
+  
+    @Override  
+    public X509Certificate[] getAcceptedIssuers() {  
+  
+        return null;  
+    }  
+  
+  
+  
+}  

+ 353 - 0
book-server/src/main/java/com/book/server/utils/NetworkManager.java

@@ -0,0 +1,353 @@
+package com.book.server.utils;
+
+import javax.net.ssl.*;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.security.cert.X509Certificate;
+import java.util.Map;
+
+public class NetworkManager {
+
+
+    static TrustManager[] trustAllCerts = new TrustManager[]{new X509TrustManager() {
+        @Override
+        public void checkClientTrusted(final X509Certificate[] chain,
+                                       final String authType) {
+        }
+
+        @Override
+        public void checkServerTrusted(final X509Certificate[] chain,
+                                       final String authType) {
+        }
+
+        @Override
+        public X509Certificate[] getAcceptedIssuers() {
+            return null;
+        }
+    }};
+
+
+    public static String request(String requestUrl, byte[] params, String appid) {
+        HttpURLConnection httpConnect = null;
+        String strResponse = "";
+        int connectTimeout = 30 * 1000;
+        int readTimeout = 30 * 1000;
+        try {
+            requestUrl = requestUrl.replaceAll(" ", "%20");
+
+            URL url = new URL(requestUrl);
+
+            SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
+            sslContext.init(null, trustAllCerts,
+                    new java.security.SecureRandom());
+
+            SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
+
+            if (requestUrl.startsWith("https://")) {
+                HttpsURLConnection
+                        .setDefaultHostnameVerifier(new HostnameVerifier() {
+                            @Override
+                            public boolean verify(String hostname,
+                                                  SSLSession session) {
+                                return true;
+                            }
+                        });
+            }
+
+            httpConnect = (HttpURLConnection) url.openConnection();
+
+            if (httpConnect instanceof HttpsURLConnection) {
+                ((HttpsURLConnection) httpConnect).setSSLSocketFactory(sslSocketFactory);
+            }
+            httpConnect.setRequestMethod("POST");
+            httpConnect.setConnectTimeout(connectTimeout);
+            httpConnect.setReadTimeout(readTimeout);
+            httpConnect.setDoOutput(true);
+            httpConnect.setUseCaches(false);
+            httpConnect.setInstanceFollowRedirects(true);
+
+            httpConnect.connect();
+
+            OutputStream outputStream = httpConnect.getOutputStream();
+
+            outputStream.write(params);
+            outputStream.flush();
+            outputStream.close();
+
+            InputStream content = httpConnect.getInputStream();
+            strResponse = convertStreamToString(content);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+//			SendMsgUtil.send2BankFailMsg(requestUrl+" 请求接口异常 ","appid="+appid+" 请求接口异常 "+e);
+            if (e instanceof SSLException){
+
+                return requestv10(requestUrl, params, appid);
+            }
+        } finally {
+            if (httpConnect != null) {
+                try {
+                    httpConnect.disconnect();
+                } catch (Exception e) {
+                }
+                httpConnect = null;
+            }
+        }
+        return strResponse;
+    }
+
+
+    public static String requestv10(String requestUrl, byte[] params, String appid) {
+        HttpURLConnection httpConnect = null;
+        String strResponse = "";
+        int connectTimeout = 30 * 1000;
+        int readTimeout = 30 * 1000;
+        try {
+            requestUrl = requestUrl.replaceAll(" ", "%20");
+
+            URL url = new URL(requestUrl);
+
+            SSLContext sslContext = SSLContext.getInstance("TLS");
+            sslContext.init(null, trustAllCerts,
+                    new java.security.SecureRandom());
+
+            SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
+
+            if (requestUrl.startsWith("https://")) {
+                HttpsURLConnection
+                        .setDefaultHostnameVerifier(new HostnameVerifier() {
+                            @Override
+                            public boolean verify(String hostname,
+                                                  SSLSession session) {
+                                return true;
+                            }
+                        });
+            }
+
+            httpConnect = (HttpURLConnection) url.openConnection();
+
+            if (httpConnect instanceof HttpsURLConnection) {
+                ((HttpsURLConnection) httpConnect).setSSLSocketFactory(sslSocketFactory);
+            }
+            httpConnect.setRequestMethod("POST");
+            httpConnect.setConnectTimeout(connectTimeout);
+            httpConnect.setReadTimeout(readTimeout);
+            httpConnect.setDoOutput(true);
+            httpConnect.setUseCaches(false);
+            httpConnect.setInstanceFollowRedirects(true);
+
+            httpConnect.connect();
+
+            OutputStream outputStream = httpConnect.getOutputStream();
+
+            outputStream.write(params);
+            outputStream.flush();
+            outputStream.close();
+
+            InputStream content = httpConnect.getInputStream();
+            strResponse = convertStreamToString(content);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+
+        } finally {
+            if (httpConnect != null) {
+                try {
+                    httpConnect.disconnect();
+                } catch (Exception e) {
+                }
+                httpConnect = null;
+            }
+        }
+        return strResponse;
+    }
+
+
+    public static String request(String requestUrl) {
+        HttpURLConnection httpConnect = null;
+        String strResponse = null;
+        int connectTimeout = 30 * 1000;
+        int readTimeout = 30 * 1000;
+        try {
+            requestUrl = requestUrl.replaceAll(" ", "%20");
+
+            URL url = new URL(requestUrl);
+
+            SSLContext sslContext = SSLContext.getInstance("TLSv1.2");
+            sslContext.init(null, trustAllCerts,
+                    new java.security.SecureRandom());
+
+            SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
+
+            if (requestUrl.startsWith("https://")) {
+                HttpsURLConnection
+                        .setDefaultHostnameVerifier(new HostnameVerifier() {
+                            @Override
+                            public boolean verify(String hostname,
+                                                  SSLSession session) {
+                                return true;
+                            }
+                        });
+            }
+
+            httpConnect = (HttpURLConnection) url.openConnection();
+
+            if (httpConnect instanceof HttpsURLConnection) {
+                ((HttpsURLConnection) httpConnect).setSSLSocketFactory(sslSocketFactory);
+            }
+
+            httpConnect.setConnectTimeout(connectTimeout);
+            httpConnect.setReadTimeout(readTimeout);
+            httpConnect.setDoOutput(true);
+            httpConnect.setUseCaches(false);
+            httpConnect.setInstanceFollowRedirects(true);
+
+            httpConnect.connect();
+
+
+            InputStream content = httpConnect.getInputStream();
+            strResponse = convertStreamToString(content);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+            if (e instanceof SSLException) {
+                return requestUrlv10(requestUrl);
+            }
+        } finally {
+            if (httpConnect != null) {
+                try {
+                    httpConnect.disconnect();
+                } catch (Exception e) {
+                }
+                httpConnect = null;
+            }
+        }
+        return strResponse;
+    }
+    public static String requestUrlv10(String requestUrl) {
+        HttpURLConnection httpConnect = null;
+        String strResponse = null;
+        int connectTimeout = 30 * 1000;
+        int readTimeout = 30 * 1000;
+        try {
+            requestUrl = requestUrl.replaceAll(" ", "%20");
+
+            URL url = new URL(requestUrl);
+
+            SSLContext sslContext = SSLContext.getInstance("TLS");
+            sslContext.init(null, trustAllCerts,
+                    new java.security.SecureRandom());
+
+            SSLSocketFactory sslSocketFactory = sslContext.getSocketFactory();
+
+            if (requestUrl.startsWith("https://")) {
+                HttpsURLConnection
+                        .setDefaultHostnameVerifier(new HostnameVerifier() {
+                            @Override
+                            public boolean verify(String hostname,
+                                                  SSLSession session) {
+                                return true;
+                            }
+                        });
+            }
+
+            httpConnect = (HttpURLConnection) url.openConnection();
+
+            if (httpConnect instanceof HttpsURLConnection) {
+                ((HttpsURLConnection) httpConnect).setSSLSocketFactory(sslSocketFactory);
+            }
+
+            httpConnect.setConnectTimeout(connectTimeout);
+            httpConnect.setReadTimeout(readTimeout);
+            httpConnect.setDoOutput(true);
+            httpConnect.setUseCaches(false);
+            httpConnect.setInstanceFollowRedirects(true);
+
+            httpConnect.connect();
+
+
+            InputStream content = httpConnect.getInputStream();
+            strResponse = convertStreamToString(content);
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (httpConnect != null) {
+                try {
+                    httpConnect.disconnect();
+                } catch (Exception e) {
+                }
+                httpConnect = null;
+            }
+        }
+        return strResponse;
+    }
+
+    public static String convertStreamToString(InputStream is) {
+        byte[] buff = new byte[4096];
+        int readed = 0;
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        try {
+            while ((readed = is.read(buff)) != -1) {
+                bout.write(buff, 0, readed);
+            }
+        } catch (IOException e1) {
+        }
+        try {
+            return new String(bout.toByteArray(), "UTF-8");
+        } catch (UnsupportedEncodingException e) {
+            return new String(bout.toByteArray());
+        }
+    }
+
+    public static String parseXMLGetValueByKey(String key, String xmlContent) {
+        String value = null;
+        try {
+            String startStr = "<" + key + ">";
+            String endStr = "</" + key + ">";
+            int beginIndex = xmlContent.indexOf(startStr);
+            if (beginIndex == -1) {
+                return null;
+            }
+            int endIndex = xmlContent.indexOf(endStr);
+            value = xmlContent.substring(beginIndex + startStr.length(), endIndex);
+            return value;
+        } catch (Exception e) {
+            return "";
+        }
+    }
+
+    public static String packagingXML(Map<String, String> xmlMap, String xmlHead, boolean isAddStandalone) {
+        if (xmlMap != null && xmlMap.size() > 0) {
+            StringBuilder xmlSbu = new StringBuilder("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+            if (isAddStandalone) {
+                xmlSbu = new StringBuilder("<?xml version=\"1.0\" standalone=\"yes\"?>");
+            }
+            xmlSbu.append("<" + xmlHead + ">");
+            for (Map.Entry<String, String> entry : xmlMap.entrySet()) {
+                xmlSbu.append("<" + entry.getKey() + ">").append(entry.getValue()).append("</" + entry.getKey() + ">");
+            }
+            xmlSbu.append("</" + xmlHead + ">");
+            return xmlSbu.toString();
+        }
+        return null;
+    }
+
+    public static String packagingXMLField(Map<String, String> fieldMap) {
+        if (fieldMap != null && fieldMap.size() > 0) {
+            StringBuilder sbu = new StringBuilder();
+            for (Map.Entry<String, String> entry : fieldMap.entrySet()) {
+                sbu.append("<" + entry.getKey() + ">").append(entry.getValue()).append("</" + entry.getKey() + ">");
+            }
+            return sbu.toString();
+        }
+        return null;
+    }
+
+    public static void main(String[] args) {
+        request("https://api.lyread.com/index/Quickapi1/wxPayNotify","status=success&signType=MD5&charset=UTF-8&appid=6031&outTradeNo=1000463-1626399772-30190&mchId=2082068001&isSubscribe=N&version=3.0&sign=6573ffe8af0b9276010bee5fa97f047b&timeEnd=20210716094309&timeStart=2021-07-16 09:42:52&attach=test&money=1&service=WECHAT_WAP&openid=o64R8v1ilNs5_lG9F_J9znRh4K5w&bank_type=OTHERS&pdorderid=1110005905467913216&chorderid=4200001145202107161468083757".getBytes(StandardCharsets.UTF_8),"");
+    }
+
+}