diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/PayController.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/PayController.java index ad67d1c..e16ea40 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/PayController.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/controller/PayController.java @@ -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; + } } } diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/AlipayService.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/AlipayService.java index f20a2fd..b4a7bbf 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/AlipayService.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/AlipayService.java @@ -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(); diff --git a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppProvinceServiceImpl.java b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppProvinceServiceImpl.java index 3709c80..df8c4b2 100644 --- a/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppProvinceServiceImpl.java +++ b/gan-modules/ruoyi-gan/src/main/java/com/ruoyi/app/service/impl/AppProvinceServiceImpl.java @@ -118,7 +118,6 @@ public class AppProvinceServiceImpl implements IAppProvinceService { } List 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 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 areaVos = new ArrayList<>(); - AppTown appTown1 = new AppTown(); - appTown1.setCityId(Long.valueOf(areaVo.getId())); - List appTowns1 = appTownMapper.selectAppTownList(appTown1); - List 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; } diff --git a/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppUserMapper.xml b/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppUserMapper.xml index 96f1035..bb855af 100644 --- a/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppUserMapper.xml +++ b/gan-modules/ruoyi-gan/src/main/resources/mapper/app/AppUserMapper.xml @@ -165,7 +165,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select , 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 diff --git a/gan-ui/src/views/app/dynamic/detail.vue b/gan-ui/src/views/app/dynamic/detail.vue index b0dac8d..9ab2ca8 100644 --- a/gan-ui/src/views/app/dynamic/detail.vue +++ b/gan-ui/src/views/app/dynamic/detail.vue @@ -1,6 +1,86 @@ - + +