Explorar o código

生成网银支付链接

chao %!s(int64=3) %!d(string=hai) anos
pai
achega
f7f17c9b13

+ 111 - 3
src/main/java/com/caimei365/order/controller/PayOrderApi.java

@@ -3,15 +3,19 @@ package com.caimei365.order.controller;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.PayDto;
+import com.caimei365.order.model.dto.PayLinkDto;
+import com.caimei365.order.model.vo.OrderPayLinkVo;
 import com.caimei365.order.service.PayOrderService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiModelProperty;
 import io.swagger.annotations.ApiOperation;
 import lombok.RequiredArgsConstructor;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.http.HttpHeaders;
 import org.springframework.web.bind.annotation.*;
 
+import java.io.IOException;
 import java.security.NoSuchAlgorithmException;
 import java.security.spec.InvalidKeySpecException;
 import java.util.Map;
@@ -79,19 +83,62 @@ public class PayOrderApi {
         return payOrderService.getCheckoutCounter(orderId);
     }
 
+
+    /**
+     *  生成网银支付链接
+     * @param payLinkDto {
+     *          orderId       订单ID
+     * }
+     */
+    @ApiOperation("生成网银支付链接(旧:/PayOrder/payLink)")
+    @PostMapping("/link")
+    public ResponseJson<String> getPayLink(PayLinkDto payLinkDto) {
+        if (null == payLinkDto.getOrderId()) {
+            return ResponseJson.error("订单Id不能为空!", null);
+        }
+        return payOrderService.getPayLink(payLinkDto);
+    }
+
+//    /**
+//     * 支付链接重定向到页面
+//     */
+//    @ApiOperation("支付链接重定向到页面(旧:/PayOrder/jumpPage)")
+//    @GetMapping("/link/jump")
+//    public void jumpPage(String linkLogo) {
+//        payOrderService.jumpPage(linkLogo);
+//    }
+//
+//    /**
+//     * 支付链接数据
+//     */
+//    @ApiOperation("支付链接重定向到页面(旧:/PayOrder/linkData)")
+//    @GetMapping("/link/data")
+//    public ResponseJson linkData(String linkLogo) {
+//        return payOrderService.linkData(linkLogo);
+//    }
+
+
+
+
+
+
+
+
+
+
     /**
      * 微信线上支付
      * @param payDto {
      *               orderId      订单ID
      *               payAmount     支付金额,单位分,必须大于2
+     *               returnUrl     页面回调地址
      *               code          微信小程序code
      *               state         微信公众号state参数
-     *               returnUrl     页面回调地址
      * }
      */
     @ApiOperation("微信线上支付(旧:/PayOrder/miniWxPay)")
     @PostMapping("/wechat")
-    public ResponseJson<JSONObject> weChatPay(PayDto payDto, @RequestHeader HttpHeaders headers){
+    public ResponseJson<JSONObject> payByWeChat(PayDto payDto, @RequestHeader HttpHeaders headers){
         if (null == payDto.getOrderId()) {
             return ResponseJson.error("订单Id不能为空!", null);
         }
@@ -101,7 +148,61 @@ public class PayOrderApi {
         if (StringUtils.isEmpty(payDto.getCode())) {
             return ResponseJson.error("微信code不能为空!", null);
         }
-        return payOrderService.weChatPay(payDto, headers);
+        return payOrderService.payByWeChat(payDto, headers);
+    }
+
+    /**
+     * 支付宝线上支付
+     * @param payDto {
+     *               orderId      订单ID
+     *               payAmount     支付金额,单位分,必须大于2
+     *               returnUrl     页面回调地址
+     * }
+     */
+    @ApiOperation("支付宝线上支付(旧:/PayOrder/pcMallPay[ALIPAY])")
+    @PostMapping("/alipay")
+    public ResponseJson<JSONObject> payByAlipay(PayDto payDto, @RequestHeader HttpHeaders headers){
+        if (null == payDto.getOrderId()) {
+            return ResponseJson.error("订单Id不能为空!", null);
+        }
+        if (null == payDto.getPayAmount() || payDto.getPayAmount() < 2) {
+            return ResponseJson.error("支付金额不正确!", null);
+        }
+        if (StringUtils.isEmpty(payDto.getReturnUrl())) {
+            return ResponseJson.error("回调地址不能为空!", null);
+        }
+        return payOrderService.payByAlipay(payDto, headers);
+    }
+
+    /**
+     * 银联线上支付
+     * @param payDto {
+     *               orderId       订单ID
+     *               payAmount     支付金额,单位分,必须大于2
+     *               returnUrl     页面回调地址
+     *               bankCode      银行编码(银联支付使用)
+     *               userType      用户类型(银联支付使用)企业:ENTERPRISE,个人:USER
+     * }
+     */
+    @ApiOperation("银联线上支付(旧:/PayOrder/pcMallPay[UNIONPAY])")
+    @PostMapping("/union")
+    public ResponseJson<JSONObject> payByUnionPay(PayDto payDto, @RequestHeader HttpHeaders headers){
+        if (null == payDto.getOrderId()) {
+            return ResponseJson.error("订单Id不能为空!", null);
+        }
+        if (null == payDto.getPayAmount() || payDto.getPayAmount() < 2) {
+            return ResponseJson.error("支付金额不正确!", null);
+        }
+        if (StringUtils.isEmpty(payDto.getReturnUrl())) {
+            return ResponseJson.error("回调地址不能为空!", null);
+        }
+        if (StringUtils.isEmpty(payDto.getBankCode())) {
+            return ResponseJson.error("银行编码不能为空!", null);
+        }
+        if (StringUtils.isEmpty(payDto.getUserType())) {
+            return ResponseJson.error("银行用户类型不能为空!", null);
+        }
+        return payOrderService.payByUnionPay(payDto, headers);
     }
 
     /**
@@ -119,4 +220,11 @@ public class PayOrderApi {
 
 
 
+
+
+
+
+
+
+
 }

+ 10 - 0
src/main/java/com/caimei365/order/mapper/PayOrderMapper.java

@@ -46,6 +46,14 @@ public interface PayOrderMapper {
      * @param amount  本次待付款金额
      */
     OrderPayLinkVo getOrderPayLink(Integer orderId, Double amount);
+    /**
+     * 新增支付链接
+     */
+    void insertOrderPayLink(OrderPayLinkVo orderPayLink);
+    /**
+     * 更新支付链接
+     */
+    void updateOrderPayLink(OrderPayLinkVo orderPayLink);
     /**
      * 修改支付链接状态
      */
@@ -55,4 +63,6 @@ public interface PayOrderMapper {
      * @param orderId 订单Id
      */
     Integer getOrderPromotionsId(Integer orderId);
+
+
 }

+ 0 - 3
src/main/java/com/caimei365/order/model/bo/PayParamBo.java

@@ -66,7 +66,4 @@ public class PayParamBo implements Serializable {
      * 个人:USER
      */
     private String userType;
-
-
-
 }

+ 15 - 4
src/main/java/com/caimei365/order/model/dto/PayDto.java

@@ -22,6 +22,11 @@ public class PayDto {
      */
     @ApiModelProperty("支付金额,单位分,必须大于2")
     private Integer payAmount;
+    /**
+     * 页面回调地址
+     */
+    @ApiModelProperty("页面回调地址")
+    private String returnUrl;
     /**
      * 微信小程序code,微信小程序支付使用
      */
@@ -33,9 +38,15 @@ public class PayDto {
     @ApiModelProperty("微信公众号state参数")
     private String state;
     /**
-     * 页面回调地址
+     * 银行编码(银联支付使用)
      */
-    @ApiModelProperty("页面回调地址")
-    private String returnUrl;
-
+    @ApiModelProperty("银行编码(银联支付使用)")
+    private String bankCode;
+    /**
+     * 用户类型(银联支付使用)
+     * 企业:ENTERPRISE
+     * 个人:USER
+     */
+    @ApiModelProperty("用户类型(银联支付使用)企业:ENTERPRISE,个人:USER")
+    private String userType;
 }

+ 30 - 0
src/main/java/com/caimei365/order/model/dto/PayLinkDto.java

@@ -0,0 +1,30 @@
+package com.caimei365.order.model.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * Description
+ *
+ * @author : Charles
+ * @date : 2021/8/2
+ */
+@Data
+public class PayLinkDto {
+    private static final long serialVersionUID = 1L;
+    /**
+     * 订单Id
+     */
+    @ApiModelProperty("订单Id")
+    private Integer orderId;
+    /**
+     * 支付类型,1企业网银,2个人网银
+     */
+    @ApiModelProperty("支付类型,1企业网银,2个人网银")
+    private Integer payType;
+    /**
+     * 本次待付款金额
+     */
+    @ApiModelProperty("本次待付款金额")
+    private Double unpaidAmount;
+}

+ 31 - 1
src/main/java/com/caimei365/order/service/PayOrderService.java

@@ -3,6 +3,7 @@ package com.caimei365.order.service;
 import com.alibaba.fastjson.JSONObject;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.dto.PayDto;
+import com.caimei365.order.model.dto.PayLinkDto;
 import org.springframework.http.HttpHeaders;
 
 import java.security.NoSuchAlgorithmException;
@@ -35,6 +36,13 @@ public interface PayOrderService {
      * @param orderId 订单Id
      */
     ResponseJson<Map<String, Object>> getCheckoutCounter(Integer orderId);
+    /**
+     * 生成网银支付链接
+     * @param payLinkDto {
+     *          orderId       订单ID
+     * }
+     */
+    ResponseJson<String> getPayLink(PayLinkDto payLinkDto);
     /**
      * 微信线上支付
      * @param payDto {
@@ -46,9 +54,31 @@ public interface PayOrderService {
      * }
      * @param headers HttpHeaders
      */
-    ResponseJson<JSONObject> weChatPay(PayDto payDto, HttpHeaders headers);
+    ResponseJson<JSONObject> payByWeChat(PayDto payDto, HttpHeaders headers);
+    /**
+     * 支付宝线上支付
+     * @param payDto {
+     *               orderId      订单ID
+     *               payAmount     支付金额,单位分,必须大于2
+     *               returnUrl     页面回调地址
+     * }
+     */
+    ResponseJson<JSONObject> payByAlipay(PayDto payDto, HttpHeaders headers);
+    /**
+     * 银联线上支付
+     * @param payDto {
+     *               orderId       订单ID
+     *               payAmount     支付金额,单位分,必须大于2
+     *               returnUrl     页面回调地址
+     *               bankCode      银行编码(银联支付使用)
+     *               userType      用户类型(银联支付使用)企业:ENTERPRISE,个人:USER
+     * }
+     */
+    ResponseJson<JSONObject> payByUnionPay(PayDto payDto, HttpHeaders headers);
     /**
      * 支付异步通知回调
      */
     String paymentCallback(String data) throws NoSuchAlgorithmException, InvalidKeySpecException;
+
+
 }

+ 114 - 10
src/main/java/com/caimei365/order/service/impl/PayOrderServiceImpl.java

@@ -10,6 +10,7 @@ import com.caimei365.order.mapper.OrderCommonMapper;
 import com.caimei365.order.model.ResponseJson;
 import com.caimei365.order.model.bo.PayParamBo;
 import com.caimei365.order.model.dto.PayDto;
+import com.caimei365.order.model.dto.PayLinkDto;
 import com.caimei365.order.model.po.BalanceRecordPo;
 import com.caimei365.order.model.po.DiscernReceiptPo;
 import com.caimei365.order.model.po.OrderReceiptRelationPo;
@@ -20,9 +21,10 @@ import com.caimei365.order.model.vo.OrderProductVo;
 import com.caimei365.order.model.vo.OrderVo;
 import com.caimei365.order.service.PayOrderService;
 import com.caimei365.order.service.RemoteCallService;
+import com.caimei365.order.utils.CodeUtil;
 import com.caimei365.order.utils.MathUtil;
+import com.caimei365.order.utils.Md5Util;
 import com.caimei365.order.utils.PayUtil;
-import com.caimei365.order.utils.pay.HttpRequest;
 import com.caimei365.order.utils.pay.RSAUtil;
 import com.google.common.util.concurrent.AtomicDouble;
 import lombok.extern.slf4j.Slf4j;
@@ -34,14 +36,10 @@ import org.springframework.http.HttpHeaders;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
-import java.math.BigDecimal;
 import java.security.NoSuchAlgorithmException;
 import java.security.spec.InvalidKeySpecException;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
 
 /**
@@ -65,10 +63,13 @@ public class PayOrderServiceImpl implements PayOrderService {
     private ProductService productService;
     @Resource
     private WeChatService weChatService;
-    @Value("${caimei.notifyUrl}")
-    private String notifyUrl;
     @Resource
     private RemoteCallService remoteCallService;
+    @Value("${caimei.notifyUrl}")
+    private String notifyUrl;
+    @Value("${caimei.redirectLink}")
+    private String redirectLink;
+
 
     /**
      * 订单支付前效验付款规则
@@ -268,6 +269,54 @@ public class PayOrderServiceImpl implements PayOrderService {
         return ResponseJson.success(map);
     }
 
+    /**
+     * 生成网银支付链接
+     *
+     * @param payLinkDto {
+     *                   orderId       订单ID
+     *                   }
+     */
+    @Override
+    public ResponseJson<String> getPayLink(PayLinkDto payLinkDto) {
+        // 订单信息
+        OrderVo order = payOrderMapper.getOrderByOrderId(payLinkDto.getOrderId());
+        if (null == order) {
+            return ResponseJson.error("订单不存在", null);
+        }
+        // 时间戳
+        long time = System.currentTimeMillis() / 1000;
+        String linkLogo = CodeUtil.randomLetter(4);
+        try {
+            linkLogo = Md5Util.MD5To16Bit(linkLogo + time);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        Date date = new Date();
+        GregorianCalendar calendar = new GregorianCalendar();
+        calendar.setTime(date);
+        calendar.add(Calendar.DATE, 1);
+        OrderPayLinkVo orderPayLink = payOrderMapper.getOrderPayLink(payLinkDto.getOrderId(), null);
+        if (null == orderPayLink) {
+            orderPayLink = new OrderPayLinkVo();
+            orderPayLink.setOrderId(payLinkDto.getOrderId());
+            orderPayLink.setPayType(payLinkDto.getPayType());
+            orderPayLink.setUnpaidAmount(payLinkDto.getUnpaidAmount());
+        }
+        orderPayLink.setRedirectLink(redirectLink);
+        orderPayLink.setLinkLogo(linkLogo);
+        orderPayLink.setGenerateTime(date);
+        orderPayLink.setEffectiveTime(calendar.getTime());
+        orderPayLink.setPayStatus(0);
+        orderPayLink.setDelFlag(0);
+        if (null == orderPayLink.getId()) {
+            payOrderMapper.insertOrderPayLink(orderPayLink);
+        } else {
+            payOrderMapper.updateOrderPayLink(orderPayLink);
+        }
+        String link = orderPayLink.getRedirectLink() + "?linkLogo=" + linkLogo;
+        return ResponseJson.success(link);
+    }
+
     /**
      * 微信线上支付
      *
@@ -282,7 +331,7 @@ public class PayOrderServiceImpl implements PayOrderService {
      * @param headers HttpHeaders
      */
     @Override
-    public ResponseJson<JSONObject> weChatPay(PayDto payDto, HttpHeaders headers) {
+    public ResponseJson<JSONObject> payByWeChat(PayDto payDto, HttpHeaders headers) {
         PayParamBo payParam = new PayParamBo();
         // payDto -> payParam
         BeanUtils.copyProperties(payDto, payParam);
@@ -317,6 +366,61 @@ public class PayOrderServiceImpl implements PayOrderService {
         payParam.setOpenId(openId);
         payParam.setNotifyUrl(notifyUrl);
         log.info("【微信支付】>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>获取openId:" + openId);
+        return toPay(payParam, headers);
+    }
+
+    /**
+     * 支付宝线上支付
+     *
+     * @param payDto  {
+     *                orderId      订单ID
+     *                payAmount     支付金额,单位分,必须大于2
+     *                returnUrl     页面回调地址
+     *                }
+     * @param headers
+     */
+    @Override
+    public ResponseJson<JSONObject> payByAlipay(PayDto payDto, HttpHeaders headers) {
+        PayParamBo payParam = new PayParamBo();
+        // payDto -> payParam
+        BeanUtils.copyProperties(payDto, payParam);
+        //支付宝支付
+        payParam.setPayWay("ALIPAY");
+        payParam.setPayType("ALIPAY_H5");
+        payParam.setNotifyUrl(notifyUrl);
+        log.info("【支付宝支付】>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>orderId:" + payParam.getOrderId());
+        return toPay(payParam, headers);
+    }
+
+    /**
+     * 银联线上支付
+     *
+     * @param payDto  {
+     *                orderId       订单ID
+     *                payAmount     支付金额,单位分,必须大于2
+     *                returnUrl     页面回调地址
+     *                bankCode      银行编码(银联支付使用)
+     *                userType      用户类型(银联支付使用)企业:ENTERPRISE,个人:USER
+     *                }
+     * @param headers
+     */
+    @Override
+    public ResponseJson<JSONObject> payByUnionPay(PayDto payDto, HttpHeaders headers) {
+        PayParamBo payParam = new PayParamBo();
+        // payDto -> payParam
+        BeanUtils.copyProperties(payDto, payParam);
+        //支付宝支付
+        payParam.setPayWay("UNIONPAY");
+        payParam.setPayType("GATEWAY_UNIONPAY");
+        payParam.setNotifyUrl(notifyUrl);
+        log.info("【银联支付】>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>orderId:" + payParam.getOrderId());
+        return toPay(payParam, headers);
+    }
+
+    /**
+     * 线上支付
+     */
+    private ResponseJson<JSONObject> toPay(PayParamBo payParam, HttpHeaders headers) {
         // 订单信息
         OrderVo order = payOrderMapper.getOrderByOrderId(payParam.getOrderId());
         if (null == order) {
@@ -338,7 +442,7 @@ public class PayOrderServiceImpl implements PayOrderService {
                 return ResponseJson.error("已经线下支付过,只能线下支付!", null);
             }
         }
-        log.info("【微信支付】>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>本次付款金额:" + payParam.getPayAmount());
+        log.info(">>>>>>>>>>>>>>本次付款金额:" + payParam.getPayAmount());
         if (MathUtil.compare(MathUtil.mul(order.getPayableAmount(), 100), payParam.getPayAmount()) < 0) {
             return ResponseJson.error("付款金额错误!", null);
         }

+ 84 - 0
src/main/java/com/caimei365/order/utils/Md5Util.java

@@ -0,0 +1,84 @@
+package com.caimei365.order.utils;
+
+import java.security.MessageDigest;
+import java.util.UUID;
+
+/**
+ * md5加密工具类
+ *
+ * @author : Charles
+ * @date : 2020/1/17
+ */
+public class Md5Util {
+    /**
+     * md5加密
+     * @param s:待加密字符串
+     * @return 加密后16进制字符串
+     */
+    public static String md5(String s) {
+        try {
+            //实例化MessageDigest的MD5算法对象
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            //通过digest方法返回哈希计算后的字节数组
+            byte[] bytes = md.digest(s.getBytes("utf-8"));
+            //将字节数组转换为16进制字符串并返回
+            return toHex(bytes);
+        }
+        catch (Exception e) {
+            throw new RuntimeException(e);
+        }
+    }
+    /**
+     * 获取随即盐
+     * @return
+     */
+    public static String salt(){
+        //利用UUID生成随机盐
+        UUID uuid = UUID.randomUUID();
+        //返回a2c64597-232f-4782-ab2d-9dfeb9d76932
+        String[] arr = uuid.toString().split("-");
+        return arr[0];
+    }
+    /**
+     * 字节数组转换为16进制字符串
+     * @param bytes数组
+     * @return 16进制字符串
+     */
+    private static String toHex(byte[] bytes) {
+        final char[] HEX_DIGITS = "0123456789ABCDEF".toCharArray();
+        StringBuilder ret = new StringBuilder(bytes.length * 2);
+        for (int i=0; i<bytes.length; i++) {
+            ret.append(HEX_DIGITS[(bytes[i] >> 4) & 0x0f]);
+            ret.append(HEX_DIGITS[bytes[i] & 0x0f]);
+        }
+        return ret.toString();
+    }
+
+    /**
+     * <p>Description: 16位的MD5值</p>
+     * <p>Company: caimei365</p>
+     * @author dmeng
+     * @date 2015年12月17日 下午5:28:49
+     * @param s
+     * @return
+     * @throws Exception
+     */
+    public static String MD5To16Bit(String s) throws Exception {
+        MessageDigest md = MessageDigest.getInstance("MD5");
+        md.update(s.getBytes());
+        byte b[] = md.digest();
+        int i;
+        StringBuffer buf = new StringBuffer("");
+        for (int offset = 0; offset < b.length; offset++) {
+            i = b[offset];
+            if (i < 0)
+                i += 256;
+            if (i < 16)
+                buf.append("0");
+            buf.append(Integer.toHexString(i));
+        }
+        return buf.toString().substring(8, 24);
+    }
+
+}
+

+ 0 - 116
src/main/java/com/caimei365/order/utils/pay/RandomCodeGenerator.java

@@ -1,116 +0,0 @@
-package com.caimei365.order.utils.pay;
-import java.util.Random;
-
-public class RandomCodeGenerator {
-
-	// TODO 与WWW的RandomCodeGenerator是重复的,后续需要删除www的RandomCodeGenerator
-	private static char codeSequence[] = {
-			'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 
-			'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 
-			'W', 'X', 'Y', 'Z', '2', '3', '4', '5', '6', '7', 
-			'8', '9'
-		};
-	
-	private static char intSequence[] = {
-		'2', '3', '4', '5', '6', '7', 
-		'8', '9'
-	};
-	
-	private static char stringSequence[] = {
-		'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 
-		'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 
-		'W', 'X', 'Y', 'Z'
-	};
-
-	private static char newStringSequence[] = {
-			'A','a', 'B','b', 'D','d', 'E' ,'e', 'F','f', 'G','g', 'H','h',
-			'L', 'N','n', 'Q','q', 'R','r', 'T','t', 'Y','y'
-	};
-//	C,i,j,k,M,O,P,S,U,V,W,X,Z,l
-
-	private static char[] shortLink = {
-		'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K',
-		'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'O',
-		'W', 'X', 'Y', 'Z',
-		'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k',
-		'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'u', 'v', 'o',
-		'w', 'x', 'y', 'z' ,
-		'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'
-	};
-
-	public static String generateShortLink(int length) {
-		StringBuffer sb = new StringBuffer();
-		Random random = new Random();
-		for (int i = 0; i < shortLink.length && i < length; ++i) {
-			sb.append(shortLink[random.nextInt(shortLink.length)]);
-		}
-		return sb.toString();
-	}
-
-	public static String generateCode(int length) {
-		StringBuffer sb = new StringBuffer();
-		Random random = new Random();
-		for (int i = 0; i < codeSequence.length && i < length; ++i) {
-			sb.append(codeSequence[random.nextInt(codeSequence.length)]);
-		}
-		
-		return sb.toString();
-	}
-	
-	public static String generateCodeInt(int length) {
-		StringBuffer sb = new StringBuffer();
-		Random random = new Random();
-		for (int i = 0; i < intSequence.length && i < length; ++i) {
-			sb.append(intSequence[random.nextInt(intSequence.length)]);
-		}
-		
-		return sb.toString();
-	}
-	
-	public static String generateCodeString(int length) {
-		StringBuffer sb = new StringBuffer();
-		Random random = new Random();
-		for (int i = 0; i < stringSequence.length && i < length; ++i) {
-			sb.append(stringSequence[random.nextInt(stringSequence.length)]);
-		}
-		
-		return sb.toString();
-	}
-	
-	/**
-	 * 随机生成指定位数字母与数字组成的字符串
-	 * @param length 长度
-	 * @return
-	 */
-	/*public static String generateRandomCode(int length) {
-		// 允许字母与数字的字符串
-		return RandomStringUtils.random(length, true, true);
-	}*/
-
-	public static String getRandomCharAndNumr(int length) {
-		String val = "";
-		Random random = new Random();
-		for (int i = 0; i < length; i++) {
-			// 输出字母还是数字
-			String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
-			// 字符串
-			if ("char".equalsIgnoreCase(charOrNum)) {
-				// 取得大写字母还是小写字母
-				int choice = random.nextInt(2) % 2 == 0 ? 65 : 97;
-				val += (char) (choice + random.nextInt(26));
-			} else if ("num".equalsIgnoreCase(charOrNum)) { // 数字
-				val += String.valueOf(random.nextInt(10));
-			}
-		}
-		return val;
-	}
-
-	public static String generateAccount(int length){
-		StringBuffer sb = new StringBuffer();
-		Random random = new Random();
-		for (int i = 0; i < newStringSequence.length && i < length; ++i) {
-			sb.append(newStringSequence[random.nextInt(newStringSequence.length)]);
-		}
-		return sb.toString();
-	}
-}

+ 11 - 1
src/main/resources/mapper/PayOrderMapper.xml

@@ -29,12 +29,22 @@
         UPDATE USER SET userMoney = #{userMoney}, ableUserMoney = #{ableUserMoney}
         WHERE userID = #{userId}
     </update>
+    <insert id="insertOrderPayLink" keyColumn="id" keyProperty="id"  parameterType="com.caimei365.order.model.vo.OrderPayLinkVo" useGeneratedKeys="true">
+        INSERT INTO (orderId, linkLogo, unpaidAmount, generateTime, effectiveTime, payStatus, payType, delFlag)
+        VALUES (#{orderId}, #{linkLogo}, #{unpaidAmount}, #{generateTime}, #{effectiveTime}, #{payStatus}, #{payType}, #{delFlag})
+    </insert>
+    <update id="updateOrderPayLink">
+        UPDATE cm_order_pay_link SET
+            orderId = #{orderId}, linkLogo = #{linkLogo}, unpaidAmount = #{unpaidAmount}, generateTime = #{generateTime},
+            effectiveTime = #{effectiveTime}, payStatus = #{payStatus}, payType = #{payType}, delFlag = #{delFlag}
+        WHERE id = #{id}
+    </update>
     <update id="updateOrderPayLinkStatus">
         UPDATE cm_order_pay_link SET payStatus = #{payStatus}
         WHERE id = #{id}
     </update>
     <select id="getPayOnLineSwitch" resultType="java.lang.Integer">
-        select status from cm_pay_online_switch where id=1
+        SELECT STATUS FROM cm_pay_online_switch WHERE id=1
     </select>
     <select id="getOrderByOrderId" resultType="com.caimei365.order.model.vo.OrderVo">
         SELECT