详情页面

main
王宇航 2024-05-14 16:04:53 +08:00
parent 7c081d82b0
commit 57157cc6be
5 changed files with 118 additions and 92 deletions

View File

@ -3,6 +3,7 @@ package com.ruoyi.app.controller;
import com.alipay.api.AlipayApiException;
import com.alipay.api.internal.util.AlipaySignature;
import com.alipay.api.request.AlipayTradeCreateRequest;
import com.alipay.api.response.AlipayTradeAppPayResponse;
import com.alipay.api.response.AlipayTradeCreateResponse;
import com.ruoyi.app.domain.*;
import com.ruoyi.app.domain.dto.*;
@ -478,30 +479,29 @@ public class PayController extends BaseController
@PostMapping(value = "/aliPay")
@ApiOperation(value = "支付宝支付", notes = "支付宝支付", httpMethod = "POST")
public String aliPay(@RequestBody AppOrderArg appOrderArg) throws Exception{
return alipayService.startPay();
// String orderNo = KeyUtil.generateUniqueKey();
// AlipayTradeCreateResponse result = null;
// try {
// result = alipayService.startPay(orderNo, appOrderArg.getPrice());
// } catch (AlipayApiException e) {
// e.printStackTrace();
// }
// if (result.isSuccess()) {
// AppOrder order = new AppOrder();
// order.setOutTradeNo(orderNo);
// order.setPrice(appOrderArg.getPrice());
// order.setAppId(AlipayService.APP_ID);
// order.setUserId(appOrderArg.getUserId());
// order.setPayStatus(1);
// order.setPaySoure(2);
// order.setCreateTime(new Date());
// order.setLevel(appOrderArg.getLevel());
// appOrderMapper.insertAppOrder(order);
// //valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
// String orderStr = new String(result.getBody().getBytes("ISO-8859-1"), "utf-8");
// return orderStr;
// } else {
// return null;
// }
//return alipayService.startPay(appOrderArg);
String orderNo = KeyUtil.generateUniqueKey();
AlipayTradeAppPayResponse result = null;
try {
result = alipayService.startPay(orderNo,appOrderArg.getPrice());
} catch (AlipayApiException e) {
e.printStackTrace();
}
if (result.isSuccess()) {
AppOrder order = new AppOrder();
order.setOutTradeNo(orderNo);
order.setPrice(appOrderArg.getPrice());
order.setAppId(AlipayService.APP_ID);
order.setUserId(appOrderArg.getUserId());
order.setPayStatus(1);
order.setPaySoure(2);
order.setCreateTime(new Date());
order.setLevel(appOrderArg.getLevel());
appOrderMapper.insertAppOrder(order);
String orderStr = result.getBody();
return orderStr;
} else {
return null;
}
}
}

View File

@ -12,6 +12,7 @@ import com.alipay.api.request.AlipayTradePagePayRequest;
import com.alipay.api.response.AlipayOpenOperationOpenbizmockBizQueryResponse;
import com.alipay.api.response.AlipayTradeAppPayResponse;
import com.alipay.api.response.AlipayTradeCreateResponse;
import com.ruoyi.app.domain.AppOrderArg;
import com.ruoyi.app.domain.dto.KeyUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@ -132,33 +133,23 @@ public class AlipayService {
// System.out.println(diagnosisUrl);
}
}*/
public String startPay() throws AlipayApiException{
public AlipayTradeAppPayResponse startPay(String orderNo,String price) throws AlipayApiException{
try {
// 1. 创建AlipayClient实例
AlipayClient alipayClient = new DefaultAlipayClient(getClientParams());
// 2. 创建使用的Open API对应的Request请求对象
//AlipayOpenOperationOpenbizmockBizQueryRequest request = getRequest();
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
request.setNotifyUrl(NOTIFY_URL);
//SDK已经封装掉了公共参数这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
// AlipayTradeAppPayModel model = new AlipayTradeAppPayModel ();
// //model.setBody("我是测试数据" );
// model.setSubject ( "App支付测试Java" );
// model.setOutTradeNo ( KeyUtil.generateUniqueKey() );
// //model.setTimeoutExpress ( "30m" );
// model.setTotalAmount ( "0.01" );
// //model.setProductCode ( "QUICK_MSECURITY_PAY" );
// request.setBizModel ( model );
JSONObject jsonObject = new JSONObject();
jsonObject.put("out_trade_no" , KeyUtil.generateUniqueKey());
jsonObject.put("total_amount",0.01);
jsonObject.put("out_trade_no" , orderNo);
jsonObject.put("total_amount",price);
jsonObject.put("subject","订单充值");
request.setBizContent(jsonObject.toString());
// 3. 发起请求并处理响应
AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
if (response.isSuccess()) {
return response.getBody();
return response;
} else {
System.out.println("调用失败,原因:" + response.getMsg() + "" + response.getSubMsg());
}
@ -169,31 +160,7 @@ public class AlipayService {
return null;
}
public AlipayTradeCreateResponse startPay(String outTradeNo, String totalAmount) throws AlipayApiException {
// 创建客户端
AlipayClient alipayClient = new DefaultAlipayClient(
ALIPAY_GATEWAY,
APP_ID,
APP_PRIVATE_KEY,
FORMAT,
CHARSET,
ALIPAY_PUBLIC_KEY,
SIGN_TYPE);
// 创建API请求
AlipayTradeCreateRequest alipayRequest = new AlipayTradeCreateRequest();
alipayRequest.setNotifyUrl(NOTIFY_URL);
// 设置请求参数
alipayRequest.setBizContent("{" +
"\"out_trade_no\":\"" + outTradeNo + "\"," +
"\"total_amount\":\"" + totalAmount + "\"," +
"\"subject\":\"" + SUBJECT + "\"" +
"}");
// 发起支付请求并获取支付结果
return alipayClient.sdkExecute(alipayRequest);
}
/*public static void main(String[] args) throws Exception{
AlipayService alipayService = new AlipayService();

View File

@ -118,7 +118,6 @@ public class AppProvinceServiceImpl implements IAppProvinceService {
}
List<AreaVo> children = appCities.stream()
.filter(appCity -> !appCity.getId().equals(appCity.getId()))
.map(appCity -> {
AreaVo child = new AreaVo();
child.setId(appCity.getId());
@ -132,7 +131,7 @@ public class AppProvinceServiceImpl implements IAppProvinceService {
}
List<AreaVo> townChildren = appTowns.stream()
.filter(appTown -> !appTown.getId().equals(appCity.getId())) // Filter out where child id is same as parent id
// .filter(!appTown -> !appTown.getId().equals(appCity.getId())) // Filter out where child id is same as parent id
.map(appTown -> {
AreaVo townChild = new AreaVo();
townChild.setId(appTown.getId());
@ -152,28 +151,7 @@ public class AppProvinceServiceImpl implements IAppProvinceService {
return areaVo;
})
.collect(Collectors.toList());
collect.stream().forEach(
areaVo -> {
if (areaVo.getChildren() == null || areaVo.getChildren().isEmpty()) {
areaVo.setIsLeaf(true);
}
if ( areaVo.getLevel() == 1 && areaVo.getChildren().isEmpty()) {
ArrayList<AreaVo> areaVos = new ArrayList<>();
AppTown appTown1 = new AppTown();
appTown1.setCityId(Long.valueOf(areaVo.getId()));
List<AppTown> appTowns1 = appTownMapper.selectAppTownList(appTown1);
List<AreaVo> townChildren = appTowns1.stream().map(appTown -> {
AreaVo townChild = new AreaVo();
townChild.setId(appTown.getId());
townChild.setName(appTown.getName());
townChild.setLevel(3);
townChild.setIsLeaf(true);
return townChild;
}).collect(Collectors.toList());
areaVo.setChildren(townChildren);
}
}
);
return collect;
}

View File

@ -165,7 +165,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
select
<include refid="appUserColumns"/>,
s.name as "schoolName",
count(f.user_id) as "fansNum"
count(f.user_id) as "fansNum",
a.id as "userId"
from app_user a
left join app_school s on s.id = a.school
left join app_user_fans f on f.user_id = a.id

View File

@ -1,6 +1,86 @@
<!-- 动态详情 -->
<template>
<div>
这是动态详情页面
</div>
<el-descriptions title="动态详情">
<el-descriptions-item label="姓名">kooriookami</el-descriptions-item>
<el-descriptions-item label="手机号">18100000000</el-descriptions-item>
<el-descriptions-item label="居住地">苏州市</el-descriptions-item>
<el-descriptions-item label="备注">
<el-tag size="small">学校</el-tag>
</el-descriptions-item>
<el-descriptions-item label="联系地址">江苏省苏州市吴中区吴中大道 1188 </el-descriptions-item>
</el-descriptions>
</template>
<script>
import {listDynamic, getDynamic, treeDynamic} from "@/api/app/dynamic";
export default {
data() {
return {
id: '',
//
loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true,
//
total: 0,
// App
dynamicList: [],
//
title: "",
//
open: false,
created() {
this.getList();
this.getDynamic(this.id);
},
mounted: function () {
this.id = this.$route().params.dynamicId;
},
methods: {
getList() {
this.loading = true;
listDynamic(this.queryParams).then(response => {
this.registerList = response.rows;
this.total = response.total;
this.loading = false;
});
},
handleDetail(row) {
const id = row.id || row.ids;
this.$router.push({path: '/app/dynamic/detail'});
this.queryParams.dynamicId = id;
treeDynamic(this.queryParams).then(response => {
this.form = response.data;
this.open = true;
this.title = "App用户动态详情";
// Access the data here
console.log(this.form); // Or use the data in any way you need
});
},
getDynamic(id){
getDynamic(id).then(response => {
console.log(response.data);
})
}
}
}
}
}
</script>