Browse Source

合利宝相关

zhijiezhao 3 years ago
parent
commit
d0bc26acd9

+ 5 - 0
pom.xml

@@ -31,6 +31,11 @@
     </dependencyManagement>
 
     <dependencies>
+        <dependency>
+            <groupId>com.squareup.okhttp3</groupId>
+            <artifactId>okhttp</artifactId>
+            <version>3.8.1</version>
+        </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>

+ 68 - 0
src/main/java/com/caimei365/order/model/dto/HeliDto.java

@@ -0,0 +1,68 @@
+package com.caimei365.order.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * Description
+ */
+@Data
+public class HeliDto implements Serializable {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 订单Id
+     */
+    @ApiModelProperty("订单Id")
+    private Integer orderId;
+    /**
+     * 支付金额,单位分,必须大于2
+     */
+    @ApiModelProperty("支付金额,单位元,必须大于0.02")
+    private String payAmount;
+    /**
+     * 页面回调地址
+     */
+    @ApiModelProperty("支付成功跳转地址")
+    private String returnUrl;
+    /**
+     * 微信小程序code,微信小程序支付使用
+     */
+    @ApiModelProperty("微信小程序code")
+    private String code;
+    /**
+     * 微信公众号state参数
+     */
+    @ApiModelProperty("微信公众号state参数")
+    private String state;
+    /**
+     * 银行编码(银联支付使用)
+     */
+    @ApiModelProperty("银行编码(银联支付使用)")
+    private String bankCode;
+    /**
+     * 用户类型(银联支付使用)
+     * 企业:B2B
+     * 个人:B2C
+     */
+    @ApiModelProperty("用户类型(银联支付使用)企业:B2B,个人:B2C")
+    private String userType;
+
+
+    @ApiModelProperty("支付类型 微信:WXEWM  支付宝:ZFBEWM 公众号:GZH 小程序:XCX 银联:YL")
+    private String payType;
+
+    /**
+     * 会员购买记录Id
+     */
+    @ApiModelProperty("会员购买记录Id")
+    private Integer vipRecordId;
+    /**
+     * 二手发布商品id
+     */
+    @ApiModelProperty("二手发布商品id")
+    private Integer productId;
+
+}
+

+ 3 - 0
src/main/java/com/caimei365/order/model/dto/PayDto.java

@@ -51,4 +51,7 @@ public class PayDto implements Serializable {
      */
     @ApiModelProperty("用户类型(银联支付使用)企业:ENTERPRISE,个人:USER")
     private String userType;
+
+    @ApiModelProperty("支付类型 微信:WXPAY  支付宝:ALIPAY 公众号:AppPayPublic 小程序:AppPayApplet 银联:PUBLIC")
+    private String payType;
 }

+ 3 - 0
src/main/java/com/caimei365/order/model/dto/PaySecondDto.java

@@ -46,4 +46,7 @@ public class PaySecondDto implements Serializable {
      */
     @ApiModelProperty("用户类型(银联支付使用)企业:ENTERPRISE,个人:USER")
     private String userType;
+
+    @ApiModelProperty("支付类型 微信:WXPAY  支付宝:ALIPAY 公众号:AppPayPublic 小程序:AppPayApplet 银联:PUBLIC")
+    private String payType;
 }

+ 3 - 0
src/main/java/com/caimei365/order/model/dto/PayVipDto.java

@@ -46,5 +46,8 @@ public class PayVipDto implements Serializable {
      */
     @ApiModelProperty("用户类型(银联支付使用)企业:ENTERPRISE,个人:USER")
     private String userType;
+
+    @ApiModelProperty("支付类型 微信:WXPAY  支付宝:ALIPAY 公众号:AppPayPublic 小程序:AppPayApplet 银联:PUBLIC")
+    private String payType;
 }
 

+ 38 - 0
src/main/java/com/caimei365/order/model/vo/NotifyResponseVo.java

@@ -0,0 +1,38 @@
+package com.caimei365.order.model.vo;
+
+
+import com.google.common.collect.ImmutableSet;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+import java.util.Set;
+
+@Setter
+@Getter
+@ToString
+public class NotifyResponseVo {
+
+    private String rt1_customerNumber;
+    private String rt2_orderId;
+    private String rt3_systemSerial;
+    //INIT:已接收
+    //DOING:处理中
+    //SUCCESS:成功
+    //FAIL:失败
+    //CLOSE:关闭
+    //CANCEL:撤销
+    private String rt4_status;
+    private String rt5_orderAmount;
+    private String rt6_currency;
+    private String rt7_timestamp;
+    private String rt8_desc;
+    private String sign;
+
+    /**
+     * 需要加签的属性参数,要求加签的参数空值也签名
+     * 看接口文档
+     */
+    public static final Set<String> NEED_SIGN_PARAMS = ImmutableSet.of("rt1_customerNumber", "rt2_orderId",
+            "rt3_systemSerial", "rt4_status", "rt5_orderAmount", "rt6_currency", "rt7_timestamp", "rt8_desc");
+}

+ 113 - 0
src/main/java/com/caimei365/order/utils/MyBeanUtils.java

@@ -0,0 +1,113 @@
+package com.caimei365.order.utils;
+
+
+import com.caimei365.order.constant.Constant;
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.beans.IntrospectionException;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ */
+public class MyBeanUtils extends BeanUtils{
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(MyBeanUtils.class);
+
+    private MyBeanUtils(){ }
+
+    public static Map convertBean(Object bean, Map retMap)
+            throws IntrospectionException, IllegalAccessException, InvocationTargetException {
+        Class clazz = bean.getClass();
+        Field[] fields = clazz.getDeclaredFields();
+        for (Field f : fields) {
+            f.setAccessible(true);
+        }
+        for (Field f : fields) {
+            String key = f.toString().substring(f.toString().lastIndexOf(".") + 1);
+            if (StringUtils.equalsIgnoreCase("NEED_SIGN_PARAMS", key)) {
+                continue;
+            }
+            Object value = f.get(bean);
+            if (value == null)
+                value = "";
+            retMap.put(key, value);
+        }
+        return retMap;
+    }
+
+    public static String getSigned(Map<String, String> map, String[] excludes){
+        StringBuffer sb = new StringBuffer();
+        Set<String> excludeSet = new HashSet<String>();
+        excludeSet.add("sign");
+        if(excludes != null){
+            for(String exclude : excludes){
+                excludeSet.add(exclude);
+            }
+        }
+        for(String key : map.keySet()){
+            if(!excludeSet.contains(key)){
+                String value = map.get(key);
+                value = (value == null ? "" : value);
+                sb.append(Constant.SPLIT);
+                sb.append(value);
+            }
+        }
+//        sb.append(Constant.SPLIT);
+        return sb.toString();
+    }
+
+    public static String getSigned(Object bean, String[] excludes) throws IllegalAccessException, IntrospectionException, InvocationTargetException {
+        Map map  = convertBean(bean, new LinkedHashMap());
+        String signedStr = getSigned(map, excludes);
+        return signedStr;
+    }
+
+    /**
+     * new style
+     *
+     * @param bean
+     * @param needSignParams
+     */
+    public static String getSignedByPresetParameter(Object bean, Set<String> needSignParams) throws IllegalAccessException,
+            IntrospectionException, InvocationTargetException {
+        Map map = convertBean(bean, new LinkedHashMap<>());
+        return getSignedByPresetParameter(map, needSignParams);
+    }
+
+    /**
+     * new style
+     *
+     * @param map
+     * @param needSignParams
+     * @return
+     */
+    public static String getSignedByPresetParameter(Map<String, String> map, Set<String> needSignParams) {
+        StringBuffer sb = new StringBuffer();
+        if (needSignParams == null || needSignParams.isEmpty()) {
+            throw new RuntimeException("needSignParams is required");
+        }
+        for (String key : map.keySet()) {
+            if (needSignParams.contains(key)) {
+                // do sign
+                String value = map.get(key);
+                value = (value == null ? "" : value);
+                sb.append(Constant.SPLIT);
+                sb.append(value);
+            }
+        }
+//        改为手动拼接密钥
+//        sb.append(Constant.SPLIT).append(Constant.SAOMA);
+        //LOGGER.info("sign result:{}", sb.toString());
+        return sb.toString();
+    }
+
+}