linhw 2024-04-26 14:12:13 +08:00
parent 5f5ab46b05
commit a12486f27c
24 changed files with 1595 additions and 4 deletions

View File

@ -111,7 +111,22 @@
<groupId>org.projectlombok</groupId> <groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId> <artifactId>lombok</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.github.wechatpay-apiv3</groupId>
<artifactId>wechatpay-java</artifactId>
<version>0.2.12</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.3</version>
</dependency>
<!-- dom4j -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies> </dependencies>

View File

@ -0,0 +1,125 @@
package com.ruoyi.app.controller;
import com.ruoyi.app.domain.AppDynamicComment;
import com.ruoyi.app.domain.AppOrder;
import com.ruoyi.app.domain.AppOrderArg;
import com.ruoyi.app.domain.dto.KeyUtil;
import com.ruoyi.app.domain.dto.PayConfig;
import com.ruoyi.app.domain.dto.PayUtils;
import com.ruoyi.app.domain.dto.WeChatPrepayResult;
import com.ruoyi.app.domain.vo.AppDynamicCommentVo;
import com.ruoyi.app.mapper.AppOrderMapper;
import com.ruoyi.app.service.IAppDynamicCommentService;
import com.ruoyi.app.service.IPayService;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
import java.util.List;
import java.util.SortedMap;
import java.util.TreeMap;
/**
* Controller
*
* @author wyh
* @date 2024-04-24
*/
@RestController
@RequestMapping("/pay")
@Api(tags = "支付" , description = "支付")
@Slf4j
public class PayController extends BaseController
{
@Autowired
private IPayService payService;
@Autowired
private AppOrderMapper appOrderMapper;
/**
*
*/
@PostMapping("/wechatPrePay")
@ApiOperation(value = "微信支付", notes = "微信支付", httpMethod = "POST")
public AjaxResult wechatPrePay(AppOrderArg appOrderArg) {
Integer price = appOrderArg.getPrice();
PayConfig payConfig = getPayConfigByAppid();
String orderNo = KeyUtil.generateUniqueKey();
WeChatPrepayResult prePayResult = new WeChatPrepayResult();
String nonce_str = PayUtils.getRandomString(20);
long timeStamp = System.currentTimeMillis()/1000;
String prePayId = "";
System.out.println("orderNo:" + orderNo);
try {
prePayId = payService.getPrepayId(orderNo, price, nonce_str, timeStamp,payConfig);
log.info("=========prepayid===>>"+prePayId);
} catch (Exception e) {
log.info("==========prepayRequest===>>>error");
}
if(prePayId == null|| "".equals(prePayId)){
prePayResult.setCode("001");
return AjaxResult.error("支付失败");
}
SortedMap<String, Object> ps = new TreeMap<String, Object>();
ps.put("appId", payConfig.getAPPID());//app_id
ps.put("timeStamp",timeStamp);//北京时间时间戳
ps.put("nonceStr", nonce_str);//自定义不重复的长度不长于32位
ps.put("package", "prepay_id="+prePayId);
ps.put("signType", "MD5");
String paySign = PayUtils.createSign(payConfig.getAPP_KEY(), ps);
if (paySign==null || "".equals(paySign)) {
prePayResult.setCode("002");
return AjaxResult.error("支付失败");
}
AppOrder order = new AppOrder();
order.setOutTradeNo(orderNo);
order.setPrice(price);
order.setAppId(payConfig.getAPPID());
order.setUserId(appOrderArg.getUserId());
order.setPayStatus(1);
order.setPaySoure(appOrderArg.getPaySoure());
order.setMchId(payConfig.MCH_ID);
order.setCreateTime(new Date());
order.setLevel(appOrderArg.getLevel());
appOrderMapper.insertAppOrder(order);
prePayResult.setCode("000");
prePayResult.setNonceStr(nonce_str);
prePayResult.setTimeStamp(String.valueOf(timeStamp));
prePayResult.setPackageStr("prepay_id="+ prePayId);
prePayResult.setSignType("MD5");
prePayResult.setPaySign(paySign);
prePayResult.setOrderNo(order.getOutTradeNo());
log.info("=====>>>返回给小程序的数据:"+prePayResult.toString());
return AjaxResult.success(prePayResult);
}
public PayConfig getPayConfigByAppid() {
PayConfig payConfig = new PayConfig();
payConfig.setAPPID(payConfig.getAPPID());
payConfig.setMCH_ID(payConfig.getMCH_ID());
payConfig.setWechat_notify_url(payConfig.getWechat_notify_url());
payConfig.setBody(payConfig.body);
payConfig.setAPP_KEY(payConfig.getAPP_KEY());
payConfig.setPayUrl(payConfig.payUrl);
return payConfig;
}
}

View File

@ -0,0 +1,172 @@
package com.ruoyi.app.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* app_order
*
* @author wyh
* @date 2024-04-25
*/
@Data
public class AppOrder extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** */
private Long id;
/** 订单号 */
@Excel(name = "订单号")
private String outTradeNo;
/** 小程序id */
@Excel(name = "小程序id")
private String appId;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long userId;
/** 支付状态: 1待付款 2已付款 */
@Excel(name = "支付状态: 1待付款 2已付款")
private int payStatus;
/** 支付类型: 1微信2支付宝3兑换码 */
@Excel(name = "支付类型: 1微信2支付宝3兑换码")
private int paySoure;
/** 微信订单号 */
@Excel(name = "微信订单号")
private String tradeNo;
/** 支付金额 */
@Excel(name = "支付金额")
private int price;
/** 商户id */
@Excel(name = "商户id")
private String mchId;
@Excel(name = "会员等级1-7天2-一个月3-一年")
private int level;
/** 支付时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "支付时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date payTime;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setOutTradeNo(String outTradeNo)
{
this.outTradeNo = outTradeNo;
}
public String getOutTradeNo()
{
return outTradeNo;
}
public void setAppId(String appId)
{
this.appId = appId;
}
public String getAppId()
{
return appId;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setPayStatus(int payStatus)
{
this.payStatus = payStatus;
}
public int getPayStatus()
{
return payStatus;
}
public void setPaySoure(int paySoure)
{
this.paySoure = paySoure;
}
public int getPaySoure()
{
return paySoure;
}
public void setTradeNo(String tradeNo)
{
this.tradeNo = tradeNo;
}
public String getTradeNo()
{
return tradeNo;
}
public void setPrice(int price)
{
this.price = price;
}
public int getPrice()
{
return price;
}
public void setMchId(String mchId)
{
this.mchId = mchId;
}
public String getMchId()
{
return mchId;
}
public void setPayTime(Date payTime)
{
this.payTime = payTime;
}
public Date getPayTime()
{
return payTime;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("outTradeNo", getOutTradeNo())
.append("appId", getAppId())
.append("userId", getUserId())
.append("payStatus", getPayStatus())
.append("paySoure", getPaySoure())
.append("tradeNo", getTradeNo())
.append("price", getPrice())
.append("mchId", getMchId())
.append("payTime", getPayTime())
.append("createTime", getCreateTime())
.toString();
}
}

View File

@ -0,0 +1,37 @@
package com.ruoyi.app.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.util.Date;
/**
* app_order
*
* @author wyh
* @date 2024-04-25
*/
@Data
public class AppOrderArg extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
@Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
private Long userId;
/** 支付类型: 1微信2支付宝3兑换码 */
@Excel(name = "支付类型: 1微信2支付宝3兑换码")
private int paySoure;
/** 支付金额 */
@Excel(name = "支付金额")
private int price;
@Excel(name = "会员等级1-7天2-一个月3-一年")
private int level;
}

View File

@ -0,0 +1,135 @@
package com.ruoyi.app.domain;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* app_order_pay
*
* @author wyh
* @date 2024-04-25
*/
public class AppOrderPay extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** */
private Long id;
/** 小程序id */
@Excel(name = "小程序id")
private String appid;
/** 订单号 */
@Excel(name = "订单号")
private String outtradeno;
/** 结果码 */
@Excel(name = "结果码")
private String resultcode;
/** 字符串 */
@Excel(name = "字符串")
private String noncestr;
/** 支付金额 */
@Excel(name = "支付金额")
private String totalfee;
/** 微信订单号 */
@Excel(name = "微信订单号")
private String transactionid;
/** 时间 */
@Excel(name = "时间")
private String timeend;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setAppid(String appid)
{
this.appid = appid;
}
public String getAppid()
{
return appid;
}
public void setOuttradeno(String outtradeno)
{
this.outtradeno = outtradeno;
}
public String getOuttradeno()
{
return outtradeno;
}
public void setResultcode(String resultcode)
{
this.resultcode = resultcode;
}
public String getResultcode()
{
return resultcode;
}
public void setNoncestr(String noncestr)
{
this.noncestr = noncestr;
}
public String getNoncestr()
{
return noncestr;
}
public void setTotalfee(String totalfee)
{
this.totalfee = totalfee;
}
public String getTotalfee()
{
return totalfee;
}
public void setTransactionid(String transactionid)
{
this.transactionid = transactionid;
}
public String getTransactionid()
{
return transactionid;
}
public void setTimeend(String timeend)
{
this.timeend = timeend;
}
public String getTimeend()
{
return timeend;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("appid", getAppid())
.append("outtradeno", getOuttradeno())
.append("resultcode", getResultcode())
.append("noncestr", getNoncestr())
.append("totalfee", getTotalfee())
.append("transactionid", getTransactionid())
.append("timeend", getTimeend())
.toString();
}
}

View File

@ -149,6 +149,8 @@ public class AppUser extends BaseEntity
@Excel(name = "其他信息") @Excel(name = "其他信息")
private String other; private String other;
private int isMember;
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;

View File

@ -0,0 +1,116 @@
package com.ruoyi.app.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.ruoyi.common.core.annotation.Excel;
import com.ruoyi.common.core.web.domain.BaseEntity;
/**
* App app_user_extends
*
* @author wyh
* @date 2024-04-25
*/
public class AppUserExtends extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** $column.columnComment */
private Long id;
/** 关联用户id */
@Excel(name = "关联用户id")
private Long userId;
/** 会员等级1-7天2-一个月3-一年 */
@Excel(name = "会员等级1-7天2-一个月3-一年")
private Long level;
/** 开始时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date startTime;
/** 结束时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date endTime;
/** 注册码 */
@Excel(name = "注册码")
private String code;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
{
return userId;
}
public void setLevel(Long level)
{
this.level = level;
}
public Long getLevel()
{
return level;
}
public void setStartTime(Date startTime)
{
this.startTime = startTime;
}
public Date getStartTime()
{
return startTime;
}
public void setEndTime(Date endTime)
{
this.endTime = endTime;
}
public Date getEndTime()
{
return endTime;
}
public void setCode(String code)
{
this.code = code;
}
public String getCode()
{
return code;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("userId", getUserId())
.append("level", getLevel())
.append("remark", getRemark())
.append("createTime", getCreateTime())
.append("updateTime", getUpdateTime())
.append("createBy", getCreateBy())
.append("updateBy", getUpdateBy())
.append("startTime", getStartTime())
.append("endTime", getEndTime())
.append("code", getCode())
.toString();
}
}

View File

@ -0,0 +1,69 @@
package com.ruoyi.app.domain.dto;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
@Component
@Slf4j
public class HelperUtil {
enum RequestMethod {
POST, GET, PUT
}
//采用post的方式
public static String post(String url, String body) {
String content = getServerResponse(url, body, RequestMethod.POST);
return content;
}
// 取得服务端返回数据
private static String getServerResponse(String url, String body, RequestMethod method) {
StringBuilder sb = new StringBuilder();
OutputStream out = null;
BufferedReader in = null;
try {
URL address = new URL(url);
HttpURLConnection conn = (HttpURLConnection) address.openConnection();
conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);
byte[] requestStringBytes = body.getBytes("UTF-8");
conn.setRequestProperty("Content-length", "" + requestStringBytes.length);
conn.setRequestProperty("Connection", "Keep-Alive");// 维持长连接
conn.setRequestProperty("Charset", "UTF-8");
if (method == RequestMethod.POST) {
conn.setRequestMethod("POST");
} else if (method == RequestMethod.PUT) {
conn.setRequestMethod("PUT");
}
byte[] bytes = body.getBytes("UTF-8");
if (bytes.length > 0) {
out = conn.getOutputStream();
out.write(bytes);
out.flush();
}
if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) {
in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
String line = "";
while ((line = in.readLine()) != null) {
sb.append(line);
}
}
if (out != null)
out.close();
if (in != null)
in.close();
} catch (Exception ex) {
log.info("错误:" + ex);
}
return sb.toString();
}
}

View File

@ -0,0 +1,22 @@
package com.ruoyi.app.domain.dto;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
public class KeyUtil {
public static synchronized String generateUniqueKey(){
Random random = new Random();
// 随机数的量 自由定制这是9位随机数
Integer r = random.nextInt(900000000) + 100000000;
// 返回 17位时间
DateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String timeStr = sdf.format(new Date());
return timeStr + r;
}
}

View File

@ -0,0 +1,29 @@
package com.ruoyi.app.domain.dto;
import lombok.Data;
import lombok.ToString;
/**
* @author heisenbergluck@outlook.com
* @date 2021/6/7 0007 16:27
*/
@Data
@ToString
public class PayConfig {
//商户APPID
public String APPID = "wx55ff808ba0e28b1d";
//商户账户
public String MCH_ID = "1646646755";
//异步回调地址
public String wechat_notify_url = "127.0.0.1";
//商品描述
public String body = "二手车";
public String APP_KEY = "Zzvi53pvCLUdFtvQ3EB0QLHQeKTctZ1c";
public String payUrl = "https://api.mch.weixin.qq.com/pay/unifiedorder";//下单
public static String PAY_API_UNIFIEDORDER = "https://api.mch.weixin.qq.com/pay/unifiedorder";//下单
}

View File

@ -0,0 +1,135 @@
package com.ruoyi.app.domain.dto;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import java.security.MessageDigest;
import java.util.*;
@Slf4j
public class PayUtils {
//随机字符串生成
public static String getRandomString(int length) {
String base = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Random random = new Random();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < length; i++) {
int number = random.nextInt(base.length());
sb.append(base.charAt(number));
}
return sb.toString();
}
//请求xml组装
public static String getRequestXml(SortedMap<String,Object> parameters){
StringBuffer sb = new StringBuffer();
// sb.append("<xml version='1.0' encoding='UTF-8'>");
sb.append("<xml>");
Set es = parameters.entrySet();
Iterator it = es.iterator();
while(it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();
String key = (String)entry.getKey();
String value = String.valueOf(entry.getValue());
if ("attach".equalsIgnoreCase(key)||"body".equalsIgnoreCase(key)||"sign".equalsIgnoreCase(key)) {
sb.append("<"+key+">"+"<![CDATA["+value+"]]></"+key+">");
}else {
sb.append("<"+key+">"+value+"</"+key+">");
}
}
sb.append("</xml>");
return sb.toString();
}
/**
* md5,:a-z,
*/
public static String createSign(String APP_KEY,SortedMap<String,Object> parameters){
log.info("APP_KEY="+APP_KEY);
StringBuffer sb = new StringBuffer();
Set es = parameters.entrySet();
Iterator it = es.iterator();
while(it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();
String k = (String)entry.getKey();
Object v = entry.getValue();
if(null != v && !"".equals(v)
&& !"sign".equals(k) && !"key".equals(k)) {
sb.append(k + "=" + v + "&");
}
}
sb.append("key=" + APP_KEY);
String sign = md5Encode(sb.toString(), "UTF-8").toUpperCase();
return sign;
}
public static WeChatPayResult getResultByXml(String response) {
WeChatPayResult wexinResult = new WeChatPayResult();
Document document;
try {
document = DocumentHelper.parseText(response);
Element root = document.getRootElement();
String cashFee = root.element("cash_fee").getText();
String totalFee = root.element("total_fee").getText();
wexinResult.setAppid(root.element("appid").getText());
wexinResult.setBankType(root.element("bank_type").getText());
wexinResult.setCashFee(cashFee);
wexinResult.setMchId(root.element("mch_id").getText());
wexinResult.setNonceStr(root.element("nonce_str").getText());
wexinResult.setOpenid(root.element("openid").getText());
wexinResult.setOutTradeNo(root.element("out_trade_no").getText());
wexinResult.setResultCode(root.element("result_code").getText());
wexinResult.setReturnCode(root.element("return_code").getText());
wexinResult.setSign(root.element("sign").getText());
wexinResult.setTimeEnd(root.element("time_end").getText());
wexinResult.setTotalFee(totalFee);
wexinResult.setTradeType(root.element("trade_type").getText());
wexinResult.setTransactionId(root.element("transaction_id").getText());
return wexinResult;
} catch (Exception ex) {
log.info("解析失败");
}
return null;
}
public static String md5Encode(String origin, String charsetname) {
String resultString = null;
try {
resultString = new String(origin);
MessageDigest md = MessageDigest.getInstance("MD5");
if (charsetname == null || "".equals(charsetname))
resultString = byteArrayToHexString(md.digest(resultString
.getBytes()));
else
resultString = byteArrayToHexString(md.digest(resultString
.getBytes(charsetname)));
} catch (Exception exception) {
}
return resultString;
}
private static String byteArrayToHexString(byte b[]) {
StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < b.length; i++)
resultSb.append(byteToHexString(b[i]));
return resultSb.toString();
}
private static String byteToHexString(byte b) {
int n = b;
if (n < 0)
n += 256;
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + hexDigits[d2];
}
private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
}

View File

@ -0,0 +1,39 @@
package com.ruoyi.app.domain.dto;
import lombok.Data;
import lombok.ToString;
@Data
@ToString
public class WeChatPayResult {
//应用id
private String appid;
//付款银行
private String bankType;
//现金支付金额
private String cashFee;
//商户号
private String mchId;
//随机字符串
private String nonceStr;
//用户标识
private String openid;
//商户订单号
private String outTradeNo;
//业务结果
private String resultCode;
//同步状态码
private String returnCode;
//签名
private String sign;
//支付完成时间
private String timeEnd;
//总金额
private String totalFee;
//交易类型
private String tradeType;
//微信支付订单号
private String transactionId;
}

View File

@ -0,0 +1,22 @@
package com.ruoyi.app.domain.dto;
import lombok.Data;
@Data
public class WeChatPrepayResult {
public String code;// 返回给app状态码 000 请求成功 001 prePayId没有取到 002 签名为空
public String packageStr;//统一下单接口返回的 prepay_id 参数值提交格式如prepay_id=*
public String nonceStr;// 随机字符串
public String timeStamp;//时间戳从1970年1月1日00:00:00至今的秒数,即当前的时间
public String signType;//签名类型默认为MD5支持HMAC-SHA256和MD5。注意此处需与统一下单的签名类型一致
public String paySign;//签名
public String orderNo;
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.app.mapper;
import java.util.List;
import com.ruoyi.app.domain.AppOrder;
/**
* Mapper
*
* @author wyh
* @date 2024-04-25
*/
public interface AppOrderMapper
{
/**
*
*
* @param id
* @return
*/
public AppOrder selectAppOrderById(Long id);
/**
*
*
* @param appOrder
* @return
*/
public List<AppOrder> selectAppOrderList(AppOrder appOrder);
/**
*
*
* @param appOrder
* @return
*/
public int insertAppOrder(AppOrder appOrder);
/**
*
*
* @param appOrder
* @return
*/
public int updateAppOrder(AppOrder appOrder);
/**
*
*
* @param id
* @return
*/
public int deleteAppOrderById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteAppOrderByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.app.mapper;
import java.util.List;
import com.ruoyi.app.domain.AppOrderPay;
/**
* Mapper
*
* @author wyh
* @date 2024-04-25
*/
public interface AppOrderPayMapper
{
/**
*
*
* @param id
* @return
*/
public AppOrderPay selectAppOrderPayById(Long id);
/**
*
*
* @param appOrderPay
* @return
*/
public List<AppOrderPay> selectAppOrderPayList(AppOrderPay appOrderPay);
/**
*
*
* @param appOrderPay
* @return
*/
public int insertAppOrderPay(AppOrderPay appOrderPay);
/**
*
*
* @param appOrderPay
* @return
*/
public int updateAppOrderPay(AppOrderPay appOrderPay);
/**
*
*
* @param id
* @return
*/
public int deleteAppOrderPayById(Long id);
/**
*
*
* @param ids
* @return
*/
public int deleteAppOrderPayByIds(Long[] ids);
}

View File

@ -0,0 +1,61 @@
package com.ruoyi.app.mapper;
import java.util.List;
import com.ruoyi.app.domain.AppUserExtends;
/**
* AppMapper
*
* @author wyh
* @date 2024-04-25
*/
public interface AppUserExtendsMapper
{
/**
* App
*
* @param id App
* @return App
*/
public AppUserExtends selectAppUserExtendsById(Long id);
/**
* App
*
* @param appUserExtends App
* @return App
*/
public List<AppUserExtends> selectAppUserExtendsList(AppUserExtends appUserExtends);
/**
* App
*
* @param appUserExtends App
* @return
*/
public int insertAppUserExtends(AppUserExtends appUserExtends);
/**
* App
*
* @param appUserExtends App
* @return
*/
public int updateAppUserExtends(AppUserExtends appUserExtends);
/**
* App
*
* @param id App
* @return
*/
public int deleteAppUserExtendsById(Long id);
/**
* App
*
* @param ids
* @return
*/
public int deleteAppUserExtendsByIds(Long[] ids);
}

View File

@ -0,0 +1,97 @@
<?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.ruoyi.app.mapper.AppUser extendsMapper">
<resultMap type="AppUser extends" id="AppUser extendsResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="level" column="level" />
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="updateBy" />
<result property="startTime" column="start_time" />
<result property="endTime" column="end_time" />
<result property="code" column="code" />
</resultMap>
<sql id="selectAppUser extendsVo">
select id, user_id, level, remark, create_time, update_time, create_by, updateBy, start_time, end_time, code from app_user_ extends
</sql>
<select id="selectAppUser extendsList" parameterType="AppUser extends" resultMap="AppUser extendsResult">
<include refid="selectAppUser extendsVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="level != null "> and level = #{level}</if>
<if test="updateBy != null and updateBy != ''"> and updateBy = #{updateBy}</if>
<if test="startTime != null "> and start_time = #{startTime}</if>
<if test="endTime != null "> and end_time = #{endTime}</if>
<if test="code != null and code != ''"> and code = #{code}</if>
</where>
</select>
<select id="selectAppUser extendsById" parameterType="Long" resultMap="AppUser extendsResult">
<include refid="selectAppUser extendsVo"/>
where id = #{id}
</select>
<insert id="insertAppUser extends" parameterType="AppUser extends" useGeneratedKeys="true" keyProperty="id">
insert into app_user_ extends
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="level != null">level,</if>
<if test="remark != null">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">updateBy,</if>
<if test="startTime != null">start_time,</if>
<if test="endTime != null">end_time,</if>
<if test="code != null">code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="level != null">#{level},</if>
<if test="remark != null">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="startTime != null">#{startTime},</if>
<if test="endTime != null">#{endTime},</if>
<if test="code != null">#{code},</if>
</trim>
</insert>
<update id="updateAppUser extends" parameterType="AppUser extends">
update app_user_ extends
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="level != null">level = #{level},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">updateBy = #{updateBy},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="code != null">code = #{code},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAppUser extendsById" parameterType="Long">
delete from app_user_ extends where id = #{id}
</delete>
<delete id="deleteAppUser extendsByIds" parameterType="String">
delete from app_user_ extends where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,28 @@
package com.ruoyi.app.service;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.app.domain.dto.PayConfig;
public interface IPayService {
JSONObject code2session(String code);
/**
* prepayid
*
* @param orderId
* @param orderMoney
* @param nonce_str
* @param timeStamp
* @return
*/
String getPrepayId(String orderId, int orderMoney, String nonce_str, long timeStamp, PayConfig weChatConfig);
/**
*
* @param oid
* @param nonce_str
* @return
*/
boolean isPayOrder(String oid, String nonce_str, PayConfig weChatConfig);
String getAccessToken();
}

View File

@ -0,0 +1,76 @@
package com.ruoyi.app.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.app.domain.dto.HelperUtil;
import com.ruoyi.app.domain.dto.PayConfig;
import com.ruoyi.app.domain.dto.PayUtils;
import com.ruoyi.app.service.IPayService;
import lombok.extern.slf4j.Slf4j;
import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.springframework.stereotype.Service;
import java.util.SortedMap;
import java.util.TreeMap;
@Slf4j
@Service
public class PayServiceImpl implements IPayService {
@Override
public JSONObject code2session(String code) {
return null;
}
@Override
public String getPrepayId(String orderId, int orderMoney, String nonce_str, long timeStamp, PayConfig weChatConfig) {
//long fee = (long) (orderMoney * 100); // 转换为分
long fee = (long) (orderMoney);
SortedMap<String, Object> parameterMap = new TreeMap<String, Object>();
parameterMap.put("appid", weChatConfig.getAPPID());
parameterMap.put("mch_id", weChatConfig.getMCH_ID());
parameterMap.put("nonce_str", nonce_str);
parameterMap.put("body", weChatConfig.getBody());
parameterMap.put("out_trade_no", orderId);
parameterMap.put("total_fee", fee);
parameterMap.put("spbill_create_ip","127.0.0.1");
parameterMap.put("notify_url", weChatConfig.getWechat_notify_url());
parameterMap.put("trade_type", "APP");
//parameterMap.put("openid", openId);
String sign = PayUtils.createSign(weChatConfig.getAPP_KEY(), parameterMap);
log.info("sign:" + sign);
parameterMap.put("sign", sign);
String body = PayUtils.getRequestXml(parameterMap);
String response = "";
try {
response = HelperUtil.post(weChatConfig.payUrl, body);
} catch (Exception e) {
log.info(e.getMessage());
}
log.info("微信支付下单请求的数据" + body);
log.info("微信支付下单返回的数据" + response);
Document document;
try {
document = DocumentHelper.parseText(response);
Element root = document.getRootElement();
Element prepay = root.element("prepay_id");
if (prepay != null) {
String prepayId = prepay.getTextTrim();
return prepayId;
}
} catch (Exception ex) {
}
return "";
}
@Override
public boolean isPayOrder(String oid, String nonce_str, PayConfig weChatConfig) {
return false;
}
@Override
public String getAccessToken() {
return null;
}
}

View File

@ -0,0 +1,103 @@
<?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.ruoyi.app.mapper.AppOrderMapper">
<resultMap type="AppOrder" id="AppOrderResult">
<result property="id" column="id" />
<result property="outTradeNo" column="out_trade_no" />
<result property="appId" column="app_id" />
<result property="userId" column="user_id" />
<result property="payStatus" column="pay_status" />
<result property="paySoure" column="pay_soure" />
<result property="tradeNo" column="trade_no" />
<result property="price" column="price" />
<result property="mchId" column="mch_id" />
<result property="payTime" column="pay_time" />
<result property="createTime" column="create_time" />
<result property="level" column="level" />
</resultMap>
<sql id="selectAppOrderVo">
select id, out_trade_no, app_id, user_id, pay_status, pay_soure, trade_no, price, mch_id, pay_time, create_time,level from app_order
</sql>
<select id="selectAppOrderList" parameterType="AppOrder" resultMap="AppOrderResult">
<include refid="selectAppOrderVo"/>
<where>
<if test="outTradeNo != null and outTradeNo != ''"> and out_trade_no = #{outTradeNo}</if>
<if test="appId != null and appId != ''"> and app_id = #{appId}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="payStatus != null "> and pay_status = #{payStatus}</if>
<if test="paySoure != null "> and pay_soure = #{paySoure}</if>
<if test="tradeNo != null and tradeNo != ''"> and trade_no = #{tradeNo}</if>
<if test="price != null "> and price = #{price}</if>
<if test="mchId != null and mchId != ''"> and mch_id = #{mchId}</if>
<if test="payTime != null "> and pay_time = #{payTime}</if>
</where>
</select>
<select id="selectAppOrderById" parameterType="Long" resultMap="AppOrderResult">
<include refid="selectAppOrderVo"/>
where id = #{id}
</select>
<insert id="insertAppOrder" parameterType="AppOrder" useGeneratedKeys="true" keyProperty="id">
insert into app_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="outTradeNo != null and outTradeNo != ''">out_trade_no,</if>
<if test="appId != null">app_id,</if>
<if test="userId != null">user_id,</if>
<if test="payStatus != null">pay_status,</if>
<if test="paySoure != null">pay_soure,</if>
<if test="tradeNo != null">trade_no,</if>
<if test="price != null">price,</if>
<if test="mchId != null">mch_id,</if>
<if test="payTime != null">pay_time,</if>
<if test="createTime != null">create_time,</if>
<if test="level != null">level,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="outTradeNo != null and outTradeNo != ''">#{outTradeNo},</if>
<if test="appId != null">#{appId},</if>
<if test="userId != null">#{userId},</if>
<if test="payStatus != null">#{payStatus},</if>
<if test="paySoure != null">#{paySoure},</if>
<if test="tradeNo != null">#{tradeNo},</if>
<if test="price != null">#{price},</if>
<if test="mchId != null">#{mchId},</if>
<if test="payTime != null">#{payTime},</if>
<if test="createTime != null">#{createTime},</if>
<if test="level != null">#{level},</if>
</trim>
</insert>
<update id="updateAppOrder" parameterType="AppOrder">
update app_order
<trim prefix="SET" suffixOverrides=",">
<if test="outTradeNo != null and outTradeNo != ''">out_trade_no = #{outTradeNo},</if>
<if test="appId != null">app_id = #{appId},</if>
<if test="userId != null">user_id = #{userId},</if>
<if test="payStatus != null">pay_status = #{payStatus},</if>
<if test="paySoure != null">pay_soure = #{paySoure},</if>
<if test="tradeNo != null">trade_no = #{tradeNo},</if>
<if test="price != null">price = #{price},</if>
<if test="mchId != null">mch_id = #{mchId},</if>
<if test="payTime != null">pay_time = #{payTime},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAppOrderById" parameterType="Long">
delete from app_order where id = #{id}
</delete>
<delete id="deleteAppOrderByIds" parameterType="String">
delete from app_order where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -0,0 +1,86 @@
<?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.ruoyi.app.mapper.AppOrderPayMapper">
<resultMap type="AppOrderPay" id="AppOrderPayResult">
<result property="id" column="id" />
<result property="appid" column="appid" />
<result property="outtradeno" column="outtradeno" />
<result property="resultcode" column="resultcode" />
<result property="noncestr" column="noncestr" />
<result property="totalfee" column="totalfee" />
<result property="transactionid" column="transactionid" />
<result property="timeend" column="timeend" />
</resultMap>
<sql id="selectAppOrderPayVo">
select id, appid, outtradeno, resultcode, noncestr, totalfee, transactionid, timeend from app_order_pay
</sql>
<select id="selectAppOrderPayList" parameterType="AppOrderPay" resultMap="AppOrderPayResult">
<include refid="selectAppOrderPayVo"/>
<where>
<if test="appid != null and appid != ''"> and appid = #{appid}</if>
<if test="outtradeno != null and outtradeno != ''"> and outtradeno = #{outtradeno}</if>
<if test="resultcode != null and resultcode != ''"> and resultcode = #{resultcode}</if>
<if test="noncestr != null and noncestr != ''"> and noncestr = #{noncestr}</if>
<if test="totalfee != null and totalfee != ''"> and totalfee = #{totalfee}</if>
<if test="transactionid != null and transactionid != ''"> and transactionid = #{transactionid}</if>
<if test="timeend != null and timeend != ''"> and timeend = #{timeend}</if>
</where>
</select>
<select id="selectAppOrderPayById" parameterType="Long" resultMap="AppOrderPayResult">
<include refid="selectAppOrderPayVo"/>
where id = #{id}
</select>
<insert id="insertAppOrderPay" parameterType="AppOrderPay" useGeneratedKeys="true" keyProperty="id">
insert into app_order_pay
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="appid != null">appid,</if>
<if test="outtradeno != null">outtradeno,</if>
<if test="resultcode != null">resultcode,</if>
<if test="noncestr != null">noncestr,</if>
<if test="totalfee != null">totalfee,</if>
<if test="transactionid != null">transactionid,</if>
<if test="timeend != null">timeend,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="appid != null">#{appid},</if>
<if test="outtradeno != null">#{outtradeno},</if>
<if test="resultcode != null">#{resultcode},</if>
<if test="noncestr != null">#{noncestr},</if>
<if test="totalfee != null">#{totalfee},</if>
<if test="transactionid != null">#{transactionid},</if>
<if test="timeend != null">#{timeend},</if>
</trim>
</insert>
<update id="updateAppOrderPay" parameterType="AppOrderPay">
update app_order_pay
<trim prefix="SET" suffixOverrides=",">
<if test="appid != null">appid = #{appid},</if>
<if test="outtradeno != null">outtradeno = #{outtradeno},</if>
<if test="resultcode != null">resultcode = #{resultcode},</if>
<if test="noncestr != null">noncestr = #{noncestr},</if>
<if test="totalfee != null">totalfee = #{totalfee},</if>
<if test="transactionid != null">transactionid = #{transactionid},</if>
<if test="timeend != null">timeend = #{timeend},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAppOrderPayById" parameterType="Long">
delete from app_order_pay where id = #{id}
</delete>
<delete id="deleteAppOrderPayByIds" parameterType="String">
delete from app_order_pay where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -48,7 +48,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
u.school as "school", u.school as "school",
u.major as "major", u.major as "major",
u.start_time as "startTime", u.start_time as "startTime",
u.end_time as "endTime" u.end_time as "endTime",
u.is_member as "isMember"
from app_user_dynamic a from app_user_dynamic a
left join app_user u on u.id = a.user_id left join app_user u on u.id = a.user_id
<where> <where>

View File

@ -0,0 +1,97 @@
<?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.ruoyi.app.mapper.AppUserExtendsMapper">
<resultMap type="AppUserExtends" id="AppUserExtendsResult">
<result property="id" column="id" />
<result property="userId" column="user_id" />
<result property="level" column="level" />
<result property="remark" column="remark" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="createBy" column="create_by" />
<result property="updateBy" column="updateBy" />
<result property="startTime" column="start_time" />
<result property="endTime" column="end_time" />
<result property="code" column="code" />
</resultMap>
<sql id="selectAppUserExtendsVo">
select id, user_id, level, remark, create_time, update_time, create_by, updateBy, start_time, end_time, code from app_user_extends
</sql>
<select id="selectAppUserExtendsList" parameterType="AppUserExtends" resultMap="AppUserExtendsResult">
<include refid="selectAppUserExtendsVo"/>
<where>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="level != null "> and level = #{level}</if>
<if test="updateBy != null and updateBy != ''"> and updateBy = #{updateBy}</if>
<if test="startTime != null "> and start_time = #{startTime}</if>
<if test="endTime != null "> and end_time = #{endTime}</if>
<if test="code != null and code != ''"> and code = #{code}</if>
</where>
</select>
<select id="selectAppUserExtendsById" parameterType="Long" resultMap="AppUserExtendsResult">
<include refid="selectAppUserExtendsVo"/>
where id = #{id}
</select>
<insert id="insertAppUserExtends" parameterType="AppUserExtends" useGeneratedKeys="true" keyProperty="id">
insert into app_user_extends
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="userId != null">user_id,</if>
<if test="level != null">level,</if>
<if test="remark != null">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateBy != null">updateBy,</if>
<if test="startTime != null">start_time,</if>
<if test="endTime != null">end_time,</if>
<if test="code != null">code,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="userId != null">#{userId},</if>
<if test="level != null">#{level},</if>
<if test="remark != null">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="startTime != null">#{startTime},</if>
<if test="endTime != null">#{endTime},</if>
<if test="code != null">#{code},</if>
</trim>
</insert>
<update id="updateAppUserExtends" parameterType="AppUserExtends">
update app_user_extends
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="level != null">level = #{level},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateBy != null">updateBy = #{updateBy},</if>
<if test="startTime != null">start_time = #{startTime},</if>
<if test="endTime != null">end_time = #{endTime},</if>
<if test="code != null">code = #{code},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAppUserExtendsById" parameterType="Long">
delete from app_user_extends where id = #{id}
</delete>
<delete id="deleteAppUserExtendsByIds" parameterType="String">
delete from app_user_extends where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -38,6 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="hobby" column="hobby" /> <result property="hobby" column="hobby" />
<result property="city" column="city" /> <result property="city" column="city" />
<result property="other" column="other" /> <result property="other" column="other" />
<result property="isMember" column="is_member" />
</resultMap> </resultMap>
<sql id="appUserColumns"> <sql id="appUserColumns">
a.id as "id", a.id as "id",
@ -71,11 +72,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
a.idea as "idea", a.idea as "idea",
a.is_partner as "isPartner", a.is_partner as "isPartner",
a.hobby as "hobby", a.hobby as "hobby",
a.other as "other" a.other as "other",
a.is_member as "isMember"
</sql> </sql>
<sql id="selectAppUserVo"> <sql id="selectAppUserVo">
select id, username, password, nickname, email, phone, address, create_time, update_time, avatar_url, education, school, major, start_time, end_time, experience, company_name, industry, job_time, job_name, job_type, skill_id, job_content, type from app_user select id, username, password, nickname, email, phone, address, create_time, update_time, avatar_url, education, school, major, start_time, end_time, experience, company_name, industry, job_time, job_name, job_type, skill_id, job_content, type,is_member from app_user
</sql> </sql>
<select id="selectAppUserList" parameterType="AppUser" resultMap="AppUserResult"> <select id="selectAppUserList" parameterType="AppUser" resultMap="AppUserResult">