Commit 89e293a7 by giaogiao

微信支付

parent 3cfe2dde
package io.geekidea.springbootplus.test; package io.geekidea.springbootplus.test;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
...@@ -11,6 +16,57 @@ import org.springframework.test.context.junit4.SpringRunner; ...@@ -11,6 +16,57 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest @SpringBootTest
public class WxPayTest { public class WxPayTest {
@Autowired
private WxPayService wxService;
/**
* 调用统一下单接口,并组装生成支付所需参数对象.
*
* @param request 统一下单请求参数
* @param <T> 请使用{@link com.github.binarywang.wxpay.bean.order}包下的类
* @return 返回 {@link com.github.binarywang.wxpay.bean.order}包下的类对象
*/
// @ApiOperation(value = "统一下单,并组装所需支付参数")
// @PostMapping("/createOrder")
public <T> T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException {
return this.wxService.createOrder(request);
}
@Test
public void order() {
WxPayUnifiedOrderRequest wxPayUnifiedOrderRequest = new WxPayUnifiedOrderRequest();
wxPayUnifiedOrderRequest.setBody("会员充值");
// 商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号
wxPayUnifiedOrderRequest.setOutTradeNo("00001");
//订单总金额,单位为分,详见支付金额
wxPayUnifiedOrderRequest.setTotalFee(1);
// APP和网页支付提交用户端ip
wxPayUnifiedOrderRequest.setSpbillCreateIp("111.111.222.33");
// 接收微信支付异步通知回调地址,通知url必须为直接可访问的url,不能携带参数。
wxPayUnifiedOrderRequest.setNotifyUrl("http");
wxPayUnifiedOrderRequest.setOpenid("ogXcu56o2ZYi-MgLRkSklKbe-PdU");
wxPayUnifiedOrderRequest.setTradeType("JSAPI");
Object order=null;
try {
order = createOrder(wxPayUnifiedOrderRequest);
} catch (WxPayException e) {
e.printStackTrace();
}
int i =1;
}
} }
...@@ -5,6 +5,7 @@ import me.chanjar.weixin.mp.api.WxMpService; ...@@ -5,6 +5,7 @@ import me.chanjar.weixin.mp.api.WxMpService;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl; import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl; import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
...@@ -17,7 +18,7 @@ import java.util.stream.Collectors; ...@@ -17,7 +18,7 @@ import java.util.stream.Collectors;
* @author Binary Wang(https://github.com/binarywang) * @author Binary Wang(https://github.com/binarywang)
*/ */
@Configuration @Configuration
//@EnableConfigurationProperties(WxMpProperties.class) @EnableConfigurationProperties(WxMpProperties.class)
public class WxMpConfiguration { public class WxMpConfiguration {
// private final LogHandler logHandler; // private final LogHandler logHandler;
// private final NullHandler nullHandler; // private final NullHandler nullHandler;
......
package com.sien.api.app.controller; package com.sien.common.controller;
import io.geekidea.springbootplus.framework.common.api.ApiResult; import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog; import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
......
package com.sien.common.controller; package com.sien.common.controller;
import com.sien.common.service.DonationAgentService;
import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/** /**
* 替他人捐款记录表 控制器 * 替他人捐款记录表 控制器
* *
* @author hewei * @author hewei
* @since 2021-02-25 * @since 2021-02-25
*/ */
@Slf4j //@Slf4j
@RestController //@RestController
@RequestMapping("/donationAgent") //@RequestMapping("/donationAgent")
@Api(value = "替他人捐款记录表API", tags = {"替他人捐款记录表"}) //@Api(value = "替他人捐款记录表API", tags = {"替他人捐款记录表"})
public class DonationAgentController extends BaseController { //public class DonationAgentController extends BaseController {
//
@Autowired // @Autowired
private DonationAgentService donationAgentService; // private DonationAgentService donationAgentService;
// //
// /** // /**
// * 添加替他人捐款记录表 // * 添加替他人捐款记录表
...@@ -78,5 +70,5 @@ public class DonationAgentController extends BaseController { ...@@ -78,5 +70,5 @@ public class DonationAgentController extends BaseController {
// return ApiResult.ok(paging); // return ApiResult.ok(paging);
// } // }
} //}
package com.sien.common.controller; package com.sien.common.controller;
import com.sien.common.param.DonationRecordPageParam;
import com.sien.common.param.app.DonationRecordAdd;
import com.sien.common.service.DonationRecordService; import com.sien.common.service.DonationRecordService;
import com.sien.common.vo.DonationRecordQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
import io.geekidea.springbootplus.framework.common.controller.BaseController; import io.geekidea.springbootplus.framework.common.controller.BaseController;
import io.geekidea.springbootplus.framework.core.pagination.Paging;
import io.geekidea.springbootplus.framework.core.validator.groups.Add;
import io.geekidea.springbootplus.framework.log.annotation.OperationLog;
import io.geekidea.springbootplus.framework.log.enums.OperationLogType;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -23,17 +35,42 @@ public class DonationRecordController extends BaseController { ...@@ -23,17 +35,42 @@ public class DonationRecordController extends BaseController {
@Autowired @Autowired
private DonationRecordService donationRecordService; private DonationRecordService donationRecordService;
// /**
// * 添加捐款记录 /**
* 添加捐款记录
*/
@PostMapping("/add")
@OperationLog(name = "我要捐款", type = OperationLogType.ADD)
@ApiOperation(value = "我要捐款")
public ApiResult<Boolean> addDonationRecord(@Validated(Add.class) @RequestBody DonationRecordAdd donationRecordAdd) throws Exception {
boolean flag = donationRecordService.add(donationRecordAdd);
return ApiResult.result(flag);
}
/**
* 我的捐款记录分页列表
*/
@PostMapping("/getMyPageList")
@OperationLog(name = "我的捐款记录分页列表", type = OperationLogType.PAGE)
@ApiOperation(value = "我的捐款记录分页列表")
public ApiResult<Paging<DonationRecordQueryVo>> getDonationRecordPageList(@Validated @RequestBody DonationRecordPageParam donationRecordPageParam) throws Exception {
Paging<DonationRecordQueryVo> paging = donationRecordService.getDonationRecordPageList(donationRecordPageParam);
return ApiResult.ok(paging);
}
// /**
// * 获取捐款记录详情
// */ // */
// @PostMapping("/add") // @GetMapping("/info/{id}")
// @OperationLog(name = "添加捐款记录", type = OperationLogType.ADD) // @OperationLog(name = "捐款记录详情", type = OperationLogType.INFO)
// @ApiOperation(value = "添加捐款记录") // @ApiOperation(value = "捐款记录详情")
// public ApiResult<Boolean> addDonationRecord(@Validated(Add.class) @RequestBody DonationRecord donationRecord)throws Exception{ // public ApiResult<DonationRecordQueryVo> getDonationRecord(@PathVariable("id") Long id)throws Exception{
// boolean flag= donationRecordService.saveDonationRecord(donationRecord); // DonationRecordQueryVo donationRecordQueryVo = donationRecordService.getDonationRecordById(id);
// return ApiResult.result(flag); // return ApiResult.ok(donationRecordQueryVo);
// } // }
// /** // /**
// * 修改捐款记录 // * 修改捐款记录
// */ // */
...@@ -55,28 +92,7 @@ public class DonationRecordController extends BaseController { ...@@ -55,28 +92,7 @@ public class DonationRecordController extends BaseController {
// boolean flag= donationRecordService.deleteDonationRecord(id); // boolean flag= donationRecordService.deleteDonationRecord(id);
// return ApiResult.result(flag); // return ApiResult.result(flag);
// } // }
//
// /**
// * 获取捐款记录详情
// */
// @GetMapping("/info/{id}")
// @OperationLog(name = "捐款记录详情", type = OperationLogType.INFO)
// @ApiOperation(value = "捐款记录详情")
// public ApiResult<DonationRecordQueryVo> getDonationRecord(@PathVariable("id") Long id)throws Exception{
// DonationRecordQueryVo donationRecordQueryVo = donationRecordService.getDonationRecordById(id);
// return ApiResult.ok(donationRecordQueryVo);
// }
//
// /**
// * 捐款记录分页列表
// */
// @PostMapping("/getPageList")
// @OperationLog(name = "捐款记录分页列表", type = OperationLogType.PAGE)
// @ApiOperation(value = "捐款记录分页列表")
// public ApiResult<Paging<DonationRecordQueryVo>>getDonationRecordPageList(@Validated @RequestBody DonationRecordPageParam donationRecordPageParam)throws Exception{
// Paging<DonationRecordQueryVo> paging = donationRecordService.getDonationRecordPageList(donationRecordPageParam);
// return ApiResult.ok(paging);
// }
} }
package com.sien.common.controller;
import com.sien.common.sms.SignUtil;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
*微信服务器配置 验证api
*/
@Slf4j
@RestController
@RequestMapping("/wxapi")
public class WxConfigController {
/**
* @return
* @description 微信公众号服务器配置校验token
* @author: liyinlong
* @date 2019-05-09 9:38
*/
@ApiOperation("微信公众号服务器配置校验token")
@RequestMapping("/checkToken")
public void checkToken(HttpServletRequest request, HttpServletResponse response) {
//token验证代码段
try {
log.info("请求已到达,开始校验token");
if (StringUtils.isNotBlank(request.getParameter("signature"))) {
String signature = request.getParameter("signature");
String timestamp = request.getParameter("timestamp");
String nonce = request.getParameter("nonce");
String echostr = request.getParameter("echostr");
log.info("signature[{}], timestamp[{}], nonce[{}], echostr[{}]", signature, timestamp, nonce, echostr);
if (SignUtil.checkSignature(signature, timestamp, nonce)) {
log.info("数据源为微信后台,将echostr[{}]返回!", echostr);
response.getOutputStream().println(echostr);
}
}
} catch (IOException e) {
log.error("校验出错");
e.printStackTrace();
}
}
}
\ No newline at end of file
//package com.sien.common.controller;
//
//import com.github.binarywang.wxpay.bean.coupon.WxPayCouponInfoQueryRequest;
//import com.github.binarywang.wxpay.bean.coupon.WxPayCouponInfoQueryResult;
//import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendRequest;
//import com.github.binarywang.wxpay.bean.coupon.WxPayCouponSendResult;
//import com.github.binarywang.wxpay.bean.coupon.WxPayCouponStockQueryRequest;
//import com.github.binarywang.wxpay.bean.coupon.WxPayCouponStockQueryResult;
//import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
//import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
//import com.github.binarywang.wxpay.bean.notify.WxPayRefundNotifyResult;
//import com.github.binarywang.wxpay.bean.notify.WxScanPayNotifyResult;
//import com.github.binarywang.wxpay.bean.request.*;
//import com.github.binarywang.wxpay.bean.result.*;
//import com.github.binarywang.wxpay.exception.WxPayException;
//import com.github.binarywang.wxpay.service.WxPayService;
//import io.swagger.annotations.ApiOperation;
//import lombok.AllArgsConstructor;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PathVariable;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestBody;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RequestParam;
//import org.springframework.web.bind.annotation.RestController;
//
//import java.io.File;
//import java.util.Date;
//
//
///**
// * @author Binary Wang
// */
////@Api(value = "微信支付", hidden = true)
//@RestController
//@RequestMapping("/pay")
//@AllArgsConstructor
//public class WxPayController {
//
// @Autowired
// private WxPayService wxService;
//
// /**
// * <pre>
// * 查询订单(详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_2)
// * 该接口提供所有微信支付订单的查询,商户可以通过查询订单接口主动查询订单状态,完成下一步的业务逻辑。
// * 需要调用查询接口的情况:
// * ◆ 当商户后台、网络、服务器等出现异常,商户系统最终未接收到支付通知;
// * ◆ 调用支付接口后,返回系统错误或未知交易状态情况;
// * ◆ 调用被扫支付API,返回USERPAYING的状态;
// * ◆ 调用关单或撤销接口API之前,需确认支付状态;
// * 接口地址:https://api.mch.weixin.qq.com/pay/orderquery
// * </pre>
// *
// * @param transactionId 微信订单号
// * @param outTradeNo 商户系统内部的订单号,当没提供transactionId时需要传这个。
// */
// @ApiOperation(value = "查询订单")
// @GetMapping("/queryOrder")
// public WxPayOrderQueryResult queryOrder(@RequestParam(required = false) String transactionId,
// @RequestParam(required = false) String outTradeNo)
// throws WxPayException {
// return this.wxService.queryOrder(transactionId, outTradeNo);
// }
//
// @ApiOperation(value = "查询订单")
// @PostMapping("/queryOrder")
// public WxPayOrderQueryResult queryOrder(@RequestBody WxPayOrderQueryRequest wxPayOrderQueryRequest) throws WxPayException {
// return this.wxService.queryOrder(wxPayOrderQueryRequest);
// }
//
// /**
// * <pre>
// * 关闭订单
// * 应用场景
// * 以下情况需要调用关单接口:
// * 1. 商户订单支付失败需要生成新单号重新发起支付,要对原订单号调用关单,避免重复支付;
// * 2. 系统下单后,用户支付超时,系统退出不再受理,避免用户继续,请调用关单接口。
// * 注意:订单生成后不能马上调用关单接口,最短调用时间间隔为5分钟。
// * 接口地址:https://api.mch.weixin.qq.com/pay/closeorder
// * 是否需要证书: 不需要。
// * </pre>
// *
// * @param outTradeNo 商户系统内部的订单号
// */
// @ApiOperation(value = "关闭订单")
// @GetMapping("/closeOrder/{outTradeNo}")
// public WxPayOrderCloseResult closeOrder(@PathVariable String outTradeNo) throws WxPayException {
// return this.wxService.closeOrder(outTradeNo);
// }
//
// @ApiOperation(value = "关闭订单")
// @PostMapping("/closeOrder")
// public WxPayOrderCloseResult closeOrder(@RequestBody WxPayOrderCloseRequest wxPayOrderCloseRequest) throws WxPayException {
// return this.wxService.closeOrder(wxPayOrderCloseRequest);
// }
//
// /**
// * 调用统一下单接口,并组装生成支付所需参数对象.
// *
// * @param request 统一下单请求参数
// * @param <T> 请使用{@link com.github.binarywang.wxpay.bean.order}包下的类
// * @return 返回 {@link com.github.binarywang.wxpay.bean.order}包下的类对象
// */
// @ApiOperation(value = "统一下单,并组装所需支付参数")
// @PostMapping("/createOrder")
// public <T> T createOrder(@RequestBody WxPayUnifiedOrderRequest request) throws WxPayException {
// return this.wxService.createOrder(request);
// }
//
// /**
// * 统一下单(详见https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1)
// * 在发起微信支付前,需要调用统一下单接口,获取"预支付交易会话标识"
// * 接口地址:https://api.mch.weixin.qq.com/pay/unifiedorder
// *
// * @param request 请求对象,注意一些参数如appid、mchid等不用设置,方法内会自动从配置对象中获取到(前提是对应配置中已经设置)
// */
// @ApiOperation(value = "原生的统一下单接口")
// @PostMapping("/unifiedOrder")
// public WxPayUnifiedOrderResult unifiedOrder(@RequestBody WxPayUnifiedOrderRequest request) throws WxPayException {
// return this.wxService.unifiedOrder(request);
// }
//
// /**
// * <pre>
// * 微信支付-申请退款
// * 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_4
// * 接口链接:https://api.mch.weixin.qq.com/secapi/pay/refund
// * </pre>
// *
// * @param request 请求对象
// * @return 退款操作结果
// */
// @ApiOperation(value = "退款")
// @PostMapping("/refund")
// public WxPayRefundResult refund(@RequestBody WxPayRefundRequest request) throws WxPayException {
// return this.wxService.refund(request);
// }
//
// /**
// * <pre>
// * 微信支付-查询退款
// * 应用场景:
// * 提交退款申请后,通过调用该接口查询退款状态。退款有一定延时,用零钱支付的退款20分钟内到账,
// * 银行卡支付的退款3个工作日后重新查询退款状态。
// * 详见 https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_5
// * 接口链接:https://api.mch.weixin.qq.com/pay/refundquery
// * </pre>
// * 以下四个参数四选一
// *
// * @param transactionId 微信订单号
// * @param outTradeNo 商户订单号
// * @param outRefundNo 商户退款单号
// * @param refundId 微信退款单号
// * @return 退款信息
// */
// @ApiOperation(value = "退款查询")
// @GetMapping("/refundQuery")
// public WxPayRefundQueryResult refundQuery(@RequestParam(required = false) String transactionId,
// @RequestParam(required = false) String outTradeNo,
// @RequestParam(required = false) String outRefundNo,
// @RequestParam(required = false) String refundId)
// throws WxPayException {
// return this.wxService.refundQuery(transactionId, outTradeNo, outRefundNo, refundId);
// }
//
// @ApiOperation(value = "退款查询")
// @PostMapping("/refundQuery")
// public WxPayRefundQueryResult refundQuery(@RequestBody WxPayRefundQueryRequest wxPayRefundQueryRequest) throws WxPayException {
// return this.wxService.refundQuery(wxPayRefundQueryRequest);
// }
//
// @ApiOperation(value = "支付回调通知处理")
// @PostMapping("/notify/order")
// public String parseOrderNotifyResult(@RequestBody String xmlData) throws WxPayException {
// final WxPayOrderNotifyResult notifyResult = this.wxService.parseOrderNotifyResult(xmlData);
// // TODO 根据自己业务场景需要构造返回对象
// return WxPayNotifyResponse.success("成功");
// }
//
// @ApiOperation(value = "退款回调通知处理")
// @PostMapping("/notify/refund")
// public String parseRefundNotifyResult(@RequestBody String xmlData) throws WxPayException {
// final WxPayRefundNotifyResult result = this.wxService.parseRefundNotifyResult(xmlData);
// // TODO 根据自己业务场景需要构造返回对象
// return WxPayNotifyResponse.success("成功");
// }
//
// @ApiOperation(value = "扫码支付回调通知处理")
// @PostMapping("/notify/scanpay")
// public String parseScanPayNotifyResult(String xmlData) throws WxPayException {
// final WxScanPayNotifyResult result = this.wxService.parseScanPayNotifyResult(xmlData);
// // TODO 根据自己业务场景需要构造返回对象
// return WxPayNotifyResponse.success("成功");
// }
//
// /**
// * 发送微信红包给个人用户
// * <pre>
// * 文档详见:
// * 发送普通红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_4&index=3
// * 接口地址:https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack
// * 发送裂变红包 https://pay.weixin.qq.com/wiki/doc/api/tools/cash_coupon.php?chapter=13_5&index=4
// * 接口地址:https://api.mch.weixin.qq.com/mmpaymkttransfers/sendgroupredpack
// * </pre>
// *
// * @param request 请求对象
// */
// @ApiOperation(value = "发送红包")
// @PostMapping("/sendRedpack")
// public WxPaySendRedpackResult sendRedpack(@RequestBody WxPaySendRedpackRequest request) throws WxPayException {
// return this.wxService.getRedpackService().sendRedpack(request);
// }
//
// /**
// * <pre>
// * 查询红包记录
// * 用于商户对已发放的红包进行查询红包的具体信息,可支持普通红包和裂变包。
// * 请求Url https://api.mch.weixin.qq.com/mmpaymkttransfers/gethbinfo
// * 是否需要证书 是(证书及使用说明详见商户证书)
// * 请求方式 POST
// * </pre>
// *
// * @param mchBillNo 商户发放红包的商户订单号,比如10000098201411111234567890
// */
// @ApiOperation(value = "查询红包")
// @GetMapping("/queryRedpack/{mchBillNo}")
// public WxPayRedpackQueryResult queryRedpack(@PathVariable String mchBillNo) throws WxPayException {
// return this.wxService.getRedpackService().queryRedpack(mchBillNo);
// }
//
// /**
// * <pre>
// * 扫码支付模式一生成二维码的方法
// * 二维码中的内容为链接,形式为:
// * weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX
// * 其中XXXXX为商户需要填写的内容,商户将该链接生成二维码,如需要打印发布二维码,需要采用此格式。商户可调用第三方库生成二维码图片。
// * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4
// * </pre>
// *
// * @param productId 产品Id
// * @param logoFile 商户logo图片的文件对象,可以为空
// * @param sideLength 要生成的二维码的边长,如果为空,则取默认值400
// * @return 生成的二维码的字节数组
// */
// public byte[] createScanPayQrcodeMode1(String productId, File logoFile, Integer sideLength) {
// return this.wxService.createScanPayQrcodeMode1(productId, logoFile, sideLength);
// }
//
// /**
// * <pre>
// * 扫码支付模式一生成二维码的方法
// * 二维码中的内容为链接,形式为:
// * weixin://wxpay/bizpayurl?sign=XXXXX&appid=XXXXX&mch_id=XXXXX&product_id=XXXXXX&time_stamp=XXXXXX&nonce_str=XXXXX
// * 其中XXXXX为商户需要填写的内容,商户将该链接生成二维码,如需要打印发布二维码,需要采用此格式。商户可调用第三方库生成二维码图片。
// * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_4
// * </pre>
// *
// * @param productId 产品Id
// * @return 生成的二维码URL连接
// */
// public String createScanPayQrcodeMode1(String productId) {
// return this.wxService.createScanPayQrcodeMode1(productId);
// }
//
// /**
// * <pre>
// * 扫码支付模式二生成二维码的方法
// * 对应链接格式:weixin://wxpay/bizpayurl?sr=XXXXX。请商户调用第三方库将code_url生成二维码图片。
// * 该模式链接较短,生成的二维码打印到结账小票上的识别率较高。
// * 文档详见: https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5
// * </pre>
// *
// * @param codeUrl 微信返回的交易会话的二维码链接
// * @param logoFile 商户logo图片的文件对象,可以为空
// * @param sideLength 要生成的二维码的边长,如果为空,则取默认值400
// * @return 生成的二维码的字节数组
// */
// public byte[] createScanPayQrcodeMode2(String codeUrl, File logoFile, Integer sideLength) {
// return this.wxService.createScanPayQrcodeMode2(codeUrl, logoFile, sideLength);
// }
//
// /**
// * <pre>
// * 交易保障
// * 应用场景:
// * 商户在调用微信支付提供的相关接口时,会得到微信支付返回的相关信息以及获得整个接口的响应时间。
// * 为提高整体的服务水平,协助商户一起提高服务质量,微信支付提供了相关接口调用耗时和返回信息的主动上报接口,
// * 微信支付可以根据商户侧上报的数据进一步优化网络部署,完善服务监控,和商户更好的协作为用户提供更好的业务体验。
// * 接口地址: https://api.mch.weixin.qq.com/payitil/report
// * 是否需要证书:不需要
// * </pre>
// */
// @ApiOperation(value = "提交交易保障数据")
// @PostMapping("/report")
// public void report(@RequestBody WxPayReportRequest request) throws WxPayException {
// this.wxService.report(request);
// }
//
// /**
// * <pre>
// * 下载对账单
// * 商户可以通过该接口下载历史交易清单。比如掉单、系统错误等导致商户侧和微信侧数据不一致,通过对账单核对后可校正支付状态。
// * 注意:
// * 1、微信侧未成功下单的交易不会出现在对账单中。支付成功后撤销的交易会出现在对账单中,跟原支付单订单号一致,bill_type为REVOKED;
// * 2、微信在次日9点启动生成前一天的对账单,建议商户10点后再获取;
// * 3、对账单中涉及金额的字段单位为“元”。
// * 4、对账单接口只能下载三个月以内的账单。
// * 接口链接:https://api.mch.weixin.qq.com/pay/downloadbill
// * 详情请见: <a href="https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_6">下载对账单</a>
// * </pre>
// *
// * @param billDate 对账单日期 bill_date 下载对账单的日期,格式:20140603
// * @param billType 账单类型 bill_type ALL,返回当日所有订单信息,默认值,SUCCESS,返回当日成功支付的订单,REFUND,返回当日退款订单
// * @param tarType 压缩账单 tar_type 非必传参数,固定值:GZIP,返回格式为.gzip的压缩包账单。不传则默认为数据流形式。
// * @param deviceInfo 设备号 device_info 非必传参数,终端设备号
// * @return 保存到本地的临时文件
// */
// @ApiOperation(value = "下载对账单")
// @GetMapping("/downloadBill/{billDate}/{billType}/{tarType}/{deviceInfo}")
// public WxPayBillResult downloadBill(@PathVariable String billDate, @PathVariable String billType,
// @PathVariable String tarType, @PathVariable String deviceInfo) throws WxPayException {
// return this.wxService.downloadBill(billDate, billType, tarType, deviceInfo);
// }
//
// @ApiOperation(value = "下载对账单")
// @PostMapping("/downloadBill")
// public WxPayBillResult downloadBill(WxPayDownloadBillRequest wxPayDownloadBillRequest) throws WxPayException {
// return this.wxService.downloadBill(wxPayDownloadBillRequest);
// }
//
// /**
// * <pre>
// * 提交刷卡支付
// * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_10&index=1
// * 应用场景:
// * 收银员使用扫码设备读取微信用户刷卡授权码以后,二维码或条码信息传送至商户收银台,由商户收银台或者商户后台调用该接口发起支付。
// * 提醒1:提交支付请求后微信会同步返回支付结果。当返回结果为“系统错误”时,商户系统等待5秒后调用【查询订单API】,查询支付实际交易结果;当返回结果为“USERPAYING”时,商户系统可设置间隔时间(建议10秒)重新查询支付结果,直到支付成功或超时(建议30秒);
// * 提醒2:在调用查询接口返回后,如果交易状况不明晰,请调用【撤销订单API】,此时如果交易失败则关闭订单,该单不能再支付成功;如果交易成功,则将扣款退回到用户账户。当撤销无返回或错误时,请再次调用。注意:请勿扣款后立即调用【撤销订单API】,建议至少15秒后再调用。撤销订单API需要双向证书。
// * 接口地址: https://api.mch.weixin.qq.com/pay/micropay
// * 是否需要证书:不需要。
// * </pre>
// */
// @ApiOperation(value = "提交刷卡支付")
// @PostMapping("/micropay")
// public WxPayMicropayResult micropay(@RequestBody WxPayMicropayRequest request) throws WxPayException {
// return this.wxService.micropay(request);
// }
//
// /**
// * <pre>
// * 撤销订单API
// * 文档地址:https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_11&index=3
// * 应用场景:
// * 支付交易返回失败或支付系统超时,调用该接口撤销交易。如果此订单用户支付失败,微信支付系统会将此订单关闭;如果用户支付成功,微信支付系统会将此订单资金退还给用户。
// * 注意:7天以内的交易单可调用撤销,其他正常支付的单如需实现相同功能请调用申请退款API。提交支付交易后调用【查询订单API】,没有明确的支付结果再调用【撤销订单API】。
// * 调用支付接口后请勿立即调用撤销订单API,建议支付后至少15s后再调用撤销订单接口。
// * 接口链接 :https://api.mch.weixin.qq.com/secapi/pay/reverse
// * 是否需要证书:请求需要双向证书。
// * </pre>
// */
// @ApiOperation(value = "撤销订单")
// @PostMapping("/reverseOrder")
// public WxPayOrderReverseResult reverseOrder(@RequestBody WxPayOrderReverseRequest request) throws WxPayException {
// return this.wxService.reverseOrder(request);
// }
//
// @ApiOperation(value = "获取沙箱环境签名key")
// @GetMapping("/getSandboxSignKey")
// public String getSandboxSignKey() throws WxPayException {
// return this.wxService.getSandboxSignKey();
// }
//
// @ApiOperation(value = "发放代金券")
// @PostMapping("/sendCoupon")
// public WxPayCouponSendResult sendCoupon(@RequestBody WxPayCouponSendRequest request) throws WxPayException {
// return this.wxService.sendCoupon(request);
// }
//
// @ApiOperation(value = "查询代金券批次")
// @PostMapping("/queryCouponStock")
// public WxPayCouponStockQueryResult queryCouponStock(@RequestBody WxPayCouponStockQueryRequest request) throws WxPayException {
// return this.wxService.queryCouponStock(request);
// }
//
// @ApiOperation(value = "查询代金券信息")
// @PostMapping("/queryCouponInfo")
// public WxPayCouponInfoQueryResult queryCouponInfo(@RequestBody WxPayCouponInfoQueryRequest request) throws WxPayException {
// return this.wxService.queryCouponInfo(request);
// }
//
// @ApiOperation(value = "拉取订单评价数据")
// @PostMapping("/queryComment")
// public String queryComment(Date beginDate, Date endDate, Integer offset, Integer limit) throws WxPayException {
// return this.wxService.queryComment(beginDate, endDate, offset, limit);
// }
//
//}
//
package com.sien.common.param.app;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 捐款记录
*
* @author hewei
* @since 2021-02-25
*/
@Data
public class DonationRecordAdd implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("捐款金额")
private BigDecimal money;
@ApiModelProperty("捐款用途;直接录入字符串: 助学助教,资助病残;慰问孤老,其他")
private String purpose;
@ApiModelProperty("捐款方式;1正常.2匿名,替他人捐款记录在donation_r agent表")
private Integer way;
@ApiModelProperty("是否替别人捐款")
private Integer isReplace;
@NotNull(message = "捐款接收用户手机号")
@ApiModelProperty("捐款接收用户手机号")
private String userPhone;
}
package com.sien.common.param.app;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* <pre>
* 行程付款信息填写
* </pre>
*
* @author wei
* @date 2020-09-29
*/
@Data
@Accessors(chain = true)
@ApiModel(value = "行程付款信息填写")
public class StrokePaymentInfoParam implements Serializable {
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空")
@ApiModelProperty("主键ID")
private Long id;
@NotNull(message = "用户充值金额不能为空")
@ApiModelProperty("用户充值金额")
private BigDecimal userRechargeMoney;
@NotBlank(message = "用户充值账户名不能为空")
@ApiModelProperty("用户充值账户名")
private String userRechargeName;
@NotBlank(message = "用户充值卡号不能为空")
@ApiModelProperty("用户充值卡号")
private String userRechargeBankNumber;
@NotBlank(message = "用户充值截图证据, 传入数组不能为空")
@ApiModelProperty("用户充值截图证据, 传入数组")
private String userRechargeCredentialsUrl;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sien.common.param.sysrole;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <pre>
* 系统角色 查询参数对象
* </pre>
*
* @author geekidea
* @date 2019-10-24
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "SysRolePageParam对象", description = "系统角色查询参数")
public class SysRolePageParam extends BasePageOrderParam {
private static final long serialVersionUID = 5068991832024325736L;
@ApiModelProperty("角色名称")
private String name;
@ApiModelProperty("角色编码")
private String code;
@ApiModelProperty("角色状态,0:禁用,1:启用")
private Integer state;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sien.common.param.sysrole;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <pre>
* 角色权限关系 查询参数对象
* </pre>
*
* @author geekidea
* @date 2019-10-24
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "SysRolePermissionPageParam对象", description = "角色权限关系查询参数")
public class SysRolePermissionPageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sien.common.param.sysrole;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @author geekidea
* @date 2020/3/2
**/
@Data
@ApiModel("修改系统角色权限参数")
public class UpdateSysRolePermissionParam implements Serializable {
private static final long serialVersionUID = -672108684986772098L;
@ApiModelProperty("角色ID")
@NotNull(message = "角色ID不能为空")
private Long roleId;
@ApiModelProperty("权限ID集合")
private List<Long> permissionIds;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sien.common.param.sysuser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 管理员重置用户密码参数
*
* @author geekidea
* @date 2020-3-8
**/
@Data
@Accessors(chain = true)
@ApiModel("管理员重置用户密码参数")
public class ResetPasswordParam implements Serializable {
private static final long serialVersionUID = 5364321420976152005L;
@ApiModelProperty("用户id")
@NotNull(message = "用户id不能为空")
private Long userId;
@ApiModelProperty("新密码")
@NotEmpty(message = "新密码不能为空")
private String newPassword;
@ApiModelProperty("新密码")
@NotEmpty(message = "确认密码不能为空")
private String confirmPassword;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sien.common.param.sysuser;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* <pre>
* 系统用户 查询参数对象
* </pre>
*
* @author geekidea
* @date 2019-10-24
*/
@Data
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "SysUserPageParam对象", description = "系统用户查询参数")
public class SysUserPageParam extends BasePageOrderParam {
private static final long serialVersionUID = 7437881671144580610L;
@ApiModelProperty("部门id")
private Long departmentId;
@ApiModelProperty("角色id")
private Long roleId;
@ApiModelProperty("状态,0:禁用,1:启用,2:锁定")
private Integer state;
@ApiModelProperty("创建时间开始")
private Date createTimeStart;
@ApiModelProperty("创建时间结束")
private Date createTimeEnd;
@ApiModelProperty("用户名")
private String username;
@ApiModelProperty("昵称")
private String nickname;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sien.common.param.sysuser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 修改密码参数
*
* @author geekidea
* @date 2019-10-27
**/
@Data
@Accessors(chain = true)
@ApiModel("修改密码参数")
public class UpdatePasswordParam implements Serializable {
private static final long serialVersionUID = -186284285725426339L;
@ApiModelProperty("用户id")
@NotNull(message = "用户id不能为空")
private Long userId;
@ApiModelProperty("原密码")
@NotEmpty(message = "原密码不能为空")
private String oldPassword;
@ApiModelProperty("新密码")
@NotEmpty(message = "新密码不能为空")
private String newPassword;
@ApiModelProperty("新密码")
@NotEmpty(message = "确认密码不能为空")
private String confirmPassword;
}
/*
* Copyright 2019-2029 geekidea(https://github.com/geekidea)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.sien.common.param.sysuser;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 上传头像参数
*
* @author geekidea
* @date 2020/3/7
**/
@Data
@Accessors(chain = true)
@ApiModel("上传头像参数")
public class UploadHeadParam implements Serializable {
private static final long serialVersionUID = -6871175837435010592L;
@ApiModelProperty("用户ID")
@NotNull(message = "用户ID不能为空")
private Long id;
@ApiModelProperty("头像路径")
@NotBlank(message = "头像不能为空")
private String head;
}
...@@ -2,6 +2,7 @@ package com.sien.common.service; ...@@ -2,6 +2,7 @@ package com.sien.common.service;
import com.sien.common.entity.DonationRecord; import com.sien.common.entity.DonationRecord;
import com.sien.common.param.DonationRecordPageParam; import com.sien.common.param.DonationRecordPageParam;
import com.sien.common.param.app.DonationRecordAdd;
import com.sien.common.vo.DonationRankAndTotal; import com.sien.common.vo.DonationRankAndTotal;
import com.sien.common.vo.DonationRecordQueryVo; import com.sien.common.vo.DonationRecordQueryVo;
import io.geekidea.springbootplus.framework.common.service.BaseService; import io.geekidea.springbootplus.framework.common.service.BaseService;
...@@ -16,57 +17,60 @@ import io.geekidea.springbootplus.framework.core.pagination.Paging; ...@@ -16,57 +17,60 @@ import io.geekidea.springbootplus.framework.core.pagination.Paging;
public interface DonationRecordService extends BaseService<DonationRecord> { public interface DonationRecordService extends BaseService<DonationRecord> {
/** /**
* 查询捐款排名和总捐款 * 查询捐款排名和总捐款
* *
* @param userId * @param userId
* @return * @return
*/ */
DonationRankAndTotal getDonationRankAndTotal(Long userId); DonationRankAndTotal getDonationRankAndTotal(Long userId);
/** /**
* 保存 * 保存
* *
* @param donationRecord * @param donationRecord
* @return * @return
* @throws Exception * @throws Exception
*/ */
boolean saveDonationRecord(DonationRecord donationRecord) throws Exception; boolean saveDonationRecord(DonationRecord donationRecord) throws Exception;
/**
* 修改
*
* @param donationRecord
* @return
* @throws Exception
*/
boolean updateDonationRecord(DonationRecord donationRecord)throws Exception;
/** boolean add(DonationRecordAdd donationRecordAdd) throws Exception;
* 删除
*
* @param id
* @return
* @throws Exception
*/
boolean deleteDonationRecord(Long id)throws Exception;
/** /**
* 根据ID获取查询对象 * 修改
* *
* @param id * @param donationRecord
* @return * @return
* @throws Exception * @throws Exception
*/ */
DonationRecordQueryVo getDonationRecordById(Long id)throws Exception; boolean updateDonationRecord(DonationRecord donationRecord) throws Exception;
/** /**
* 获取分页对象 * 删除
* *
* @param donationRecordPageParam * @param id
* @return * @return
* @throws Exception * @throws Exception
*/ */
Paging<DonationRecordQueryVo> getDonationRecordPageList(DonationRecordPageParam donationRecordPageParam) throws Exception; boolean deleteDonationRecord(Long id) throws Exception;
} /**
* 根据ID获取查询对象
*
* @param id
* @return
* @throws Exception
*/
DonationRecordQueryVo getDonationRecordById(Long id) throws Exception;
/**
* 获取分页对象
*
* @param donationRecordPageParam
* @return
* @throws Exception
*/
Paging<DonationRecordQueryVo> getDonationRecordPageList(DonationRecordPageParam donationRecordPageParam) throws Exception;
}
package com.sien.common.service.impl; package com.sien.common.service.impl;
import cn.hutool.captcha.generator.RandomGenerator;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.sien.common.entity.DonationRecord; import com.sien.common.entity.DonationRecord;
import com.sien.common.mapper.DonationRecordMapper; import com.sien.common.mapper.DonationRecordMapper;
import com.sien.common.param.DonationRecordPageParam; import com.sien.common.param.DonationRecordPageParam;
import com.sien.common.param.app.DonationRecordAdd;
import com.sien.common.service.DonationRecordService; import com.sien.common.service.DonationRecordService;
import com.sien.common.vo.DonationRankAndTotal; import com.sien.common.vo.DonationRankAndTotal;
import com.sien.common.vo.DonationRecordQueryVo; import com.sien.common.vo.DonationRecordQueryVo;
...@@ -30,6 +36,9 @@ public class DonationRecordServiceImpl extends BaseServiceImpl<DonationRecordMap ...@@ -30,6 +36,9 @@ public class DonationRecordServiceImpl extends BaseServiceImpl<DonationRecordMap
@Autowired @Autowired
private DonationRecordMapper donationRecordMapper; private DonationRecordMapper donationRecordMapper;
@Autowired
private WxPayService wxService;
@Override @Override
public DonationRankAndTotal getDonationRankAndTotal(Long userId) { public DonationRankAndTotal getDonationRankAndTotal(Long userId) {
return donationRecordMapper.getDonationRankAndTotal(userId); return donationRecordMapper.getDonationRankAndTotal(userId);
...@@ -41,6 +50,39 @@ public class DonationRecordServiceImpl extends BaseServiceImpl<DonationRecordMap ...@@ -41,6 +50,39 @@ public class DonationRecordServiceImpl extends BaseServiceImpl<DonationRecordMap
return super.save(donationRecord); return super.save(donationRecord);
} }
@Override
public boolean add(DonationRecordAdd donationRecordAdd) throws Exception {
WxPayUnifiedOrderRequest wxPayUnifiedOrderRequest = new WxPayUnifiedOrderRequest();
wxPayUnifiedOrderRequest.setBody("四恩慈善会-捐款");
// 商户系统内部的订单号,32个字符内、可包含字母, 其他说明见商户订单号
wxPayUnifiedOrderRequest.setOutTradeNo(new RandomGenerator(32).generate());
//订单总金额,单位为分,详见支付金额
wxPayUnifiedOrderRequest.setTotalFee(10);
// APP和网页支付提交用户端ip
wxPayUnifiedOrderRequest.setSpbillCreateIp("111.111.222.33");
// 接收微信支付异步通知回调地址,通知url必须为直接可访问的url,不能携带参数。
wxPayUnifiedOrderRequest.setNotifyUrl("http");
wxPayUnifiedOrderRequest.setOpenid("ogXcu56o2ZYi-MgLRkSklKbe-PdU");
wxPayUnifiedOrderRequest.setTradeType("JSAPI");
WxPayMpOrderResult order = null;
try {
order = this.wxService.createOrder(wxPayUnifiedOrderRequest);
} catch (WxPayException e) {
e.printStackTrace();
}
return false;
}
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@Override @Override
public boolean updateDonationRecord(DonationRecord donationRecord) throws Exception { public boolean updateDonationRecord(DonationRecord donationRecord) throws Exception {
......
package com.sien.common.sms;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Arrays;
public class SignUtil {
private static String token = "sDsdaSDADad";
/**
* 校验签名
* @param signature 签名
* @param timestamp 时间戳
* @param nonce 随机数
* @return 布尔值
*/
public static boolean checkSignature(String signature,String timestamp,String nonce){
String checktext = null;
if (null != signature) {
//对ToKen,timestamp,nonce 按字典排序
String[] paramArr = new String[]{token,timestamp,nonce};
Arrays.sort(paramArr);
//将排序后的结果拼成一个字符串
String content = paramArr[0].concat(paramArr[1]).concat(paramArr[2]);
try {
MessageDigest md = MessageDigest.getInstance("SHA-1");
//对接后的字符串进行sha1加密
byte[] digest = md.digest(content.toString().getBytes());
checktext = byteToStr(digest);
} catch (NoSuchAlgorithmException e){
e.printStackTrace();
}
}
//将加密后的字符串与signature进行对比
return checktext !=null ? checktext.equals(signature.toUpperCase()) : false;
}
/**
* 将字节数组转化我16进制字符串
* @param byteArrays 字符数组
* @return 字符串
*/
private static String byteToStr(byte[] byteArrays){
String str = "";
for (int i = 0; i < byteArrays.length; i++) {
str += byteToHexStr(byteArrays[i]);
}
return str;
}
/**
* 将字节转化为十六进制字符串
* @param myByte 字节
* @return 字符串
*/
private static String byteToHexStr(byte myByte) {
char[] Digit = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
char[] tampArr = new char[2];
tampArr[0] = Digit[(myByte >>> 4) & 0X0F];
tampArr[1] = Digit[myByte & 0X0F];
String str = new String(tampArr);
return str;
}
}
...@@ -21,32 +21,32 @@ import java.util.Date; ...@@ -21,32 +21,32 @@ import java.util.Date;
@Accessors(chain = true) @Accessors(chain = true)
@ApiModel(value = "DonationRecordQueryVo对象") @ApiModel(value = "DonationRecordQueryVo对象")
public class DonationRecordQueryVo implements Serializable { public class DonationRecordQueryVo implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty("主键") @ApiModelProperty("主键")
private Long id; private Long id;
//
// @ApiModelProperty("捐款人id")
// private Long fkUserId;
@ApiModelProperty("外键_捐款人_用户表id") @ApiModelProperty("捐款金额")
private Long fkUserId; private BigDecimal money;
@ApiModelProperty("捐款金额") @ApiModelProperty("捐款用途;直接录入字符串: 助学助教,资助病残;慰问孤老,其他")
private BigDecimal money; private String purpose;
@ApiModelProperty("捐款用途;直接录入字符串: 助学助教,资助病残;慰问孤老,其他") @ApiModelProperty("捐款方式;1正常.2匿名,替他人捐款记录在donation_r agent表")
private String purpose; private Integer way;
@ApiModelProperty("捐款方式;1正常.2匿名,替他人捐款记录在donation_r agent表") @ApiModelProperty("备注")
private Integer way; private String remark;
@ApiModelProperty("备注") @ApiModelProperty("创建时间")
private String remark; private Date createTime;
@ApiModelProperty("创建时间") // @ApiModelProperty("修改时间")
private Date createTime; // private Date updateTime;
@ApiModelProperty("修改时间") @ApiModelProperty("是否为别人替我捐款")
private Date updateTime; private Integer isReplace;
@ApiModelProperty("是否为别人替我捐款")
private Integer isReplace;
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment