Commit 89e293a7 by giaogiao

微信支付

parent 3cfe2dde
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
......@@ -11,6 +16,57 @@ import org.springframework.test.context.junit4.SpringRunner;
@SpringBootTest
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;
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
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.Configuration;
......@@ -17,7 +18,7 @@ import java.util.stream.Collectors;
* @author Binary Wang(https://github.com/binarywang)
*/
@Configuration
//@EnableConfigurationProperties(WxMpProperties.class)
@EnableConfigurationProperties(WxMpProperties.class)
public class WxMpConfiguration {
// private final LogHandler logHandler;
// 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.log.annotation.OperationLog;
......
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
* @since 2021-02-25
*/
@Slf4j
@RestController
@RequestMapping("/donationAgent")
@Api(value = "替他人捐款记录表API", tags = {"替他人捐款记录表"})
public class DonationAgentController extends BaseController {
@Autowired
private DonationAgentService donationAgentService;
//@Slf4j
//@RestController
//@RequestMapping("/donationAgent")
//@Api(value = "替他人捐款记录表API", tags = {"替他人捐款记录表"})
//public class DonationAgentController extends BaseController {
//
// @Autowired
// private DonationAgentService donationAgentService;
//
// /**
// * 添加替他人捐款记录表
......@@ -78,5 +70,5 @@ public class DonationAgentController extends BaseController {
// return ApiResult.ok(paging);
// }
}
//}
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.vo.DonationRecordQueryVo;
import io.geekidea.springbootplus.framework.common.api.ApiResult;
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.ApiOperation;
import lombok.extern.slf4j.Slf4j;
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.RestController;
......@@ -23,17 +35,42 @@ public class DonationRecordController extends BaseController {
@Autowired
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")
// @OperationLog(name = "添加捐款记录", type = OperationLogType.ADD)
// @ApiOperation(value = "添加捐款记录")
// public ApiResult<Boolean> addDonationRecord(@Validated(Add.class) @RequestBody DonationRecord donationRecord)throws Exception{
// boolean flag= donationRecordService.saveDonationRecord(donationRecord);
// 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);
// }
// /**
// * 修改捐款记录
// */
......@@ -55,28 +92,7 @@ public class DonationRecordController extends BaseController {
// boolean flag= donationRecordService.deleteDonationRecord(id);
// 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.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;
import com.sien.common.entity.DonationRecord;
import com.sien.common.param.DonationRecordPageParam;
import com.sien.common.param.app.DonationRecordAdd;
import com.sien.common.vo.DonationRankAndTotal;
import com.sien.common.vo.DonationRecordQueryVo;
import io.geekidea.springbootplus.framework.common.service.BaseService;
......@@ -33,6 +34,9 @@ public interface DonationRecordService extends BaseService<DonationRecord> {
*/
boolean saveDonationRecord(DonationRecord donationRecord) throws Exception;
boolean add(DonationRecordAdd donationRecordAdd) throws Exception;
/**
* 修改
*
......@@ -40,7 +44,7 @@ public interface DonationRecordService extends BaseService<DonationRecord> {
* @return
* @throws Exception
*/
boolean updateDonationRecord(DonationRecord donationRecord)throws Exception;
boolean updateDonationRecord(DonationRecord donationRecord) throws Exception;
/**
* 删除
......@@ -49,7 +53,7 @@ public interface DonationRecordService extends BaseService<DonationRecord> {
* @return
* @throws Exception
*/
boolean deleteDonationRecord(Long id)throws Exception;
boolean deleteDonationRecord(Long id) throws Exception;
/**
* 根据ID获取查询对象
......@@ -58,7 +62,7 @@ public interface DonationRecordService extends BaseService<DonationRecord> {
* @return
* @throws Exception
*/
DonationRecordQueryVo getDonationRecordById(Long id)throws Exception;
DonationRecordQueryVo getDonationRecordById(Long id) throws Exception;
/**
* 获取分页对象
......@@ -69,4 +73,4 @@ public interface DonationRecordService extends BaseService<DonationRecord> {
*/
Paging<DonationRecordQueryVo> getDonationRecordPageList(DonationRecordPageParam donationRecordPageParam) throws Exception;
}
}
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.OrderItem;
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.mapper.DonationRecordMapper;
import com.sien.common.param.DonationRecordPageParam;
import com.sien.common.param.app.DonationRecordAdd;
import com.sien.common.service.DonationRecordService;
import com.sien.common.vo.DonationRankAndTotal;
import com.sien.common.vo.DonationRecordQueryVo;
......@@ -30,6 +36,9 @@ public class DonationRecordServiceImpl extends BaseServiceImpl<DonationRecordMap
@Autowired
private DonationRecordMapper donationRecordMapper;
@Autowired
private WxPayService wxService;
@Override
public DonationRankAndTotal getDonationRankAndTotal(Long userId) {
return donationRecordMapper.getDonationRankAndTotal(userId);
......@@ -41,6 +50,39 @@ public class DonationRecordServiceImpl extends BaseServiceImpl<DonationRecordMap
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)
@Override
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;
}
}
......@@ -25,9 +25,9 @@ public class DonationRecordQueryVo implements Serializable {
@ApiModelProperty("主键")
private Long id;
@ApiModelProperty("外键_捐款人_用户表id")
private Long fkUserId;
//
// @ApiModelProperty("捐款人id")
// private Long fkUserId;
@ApiModelProperty("捐款金额")
private BigDecimal money;
......@@ -44,8 +44,8 @@ public class DonationRecordQueryVo implements Serializable {
@ApiModelProperty("创建时间")
private Date createTime;
@ApiModelProperty("修改时间")
private Date updateTime;
// @ApiModelProperty("修改时间")
// private Date updateTime;
@ApiModelProperty("是否为别人替我捐款")
private Integer isReplace;
......
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