Commit ac81c85f by giaogiao

完成捐款支付调用

parent 7475d6d9
......@@ -36,7 +36,6 @@ public class DonationRecordController extends BaseController {
@Autowired
private DonationRecordService donationRecordService;
/**
* 添加捐款记录
*/
......
//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;
package com.sien.common.controller;
import com.github.binarywang.wxpay.bean.notify.WxPayNotifyResponse;
import com.github.binarywang.wxpay.bean.notify.WxPayOrderNotifyResult;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.WxPayService;
import com.sien.common.service.DonationRecordService;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
* @author Binary Wang
*/
//@Api(value = "微信支付", hidden = true)
@RestController
@RequestMapping("/pay")
@AllArgsConstructor
public class WxPayController {
@Autowired
private WxPayService wxService;
@Autowired
private DonationRecordService donationRecordService;
@ApiOperation(value = "捐款支付回调通知处理")
@PostMapping("/notify/donationOrder")
public String parseDonationOrderNotifyResult(@RequestBody String xmlData) throws WxPayException {
return donationRecordService.parseDonationOrderNotifyResult(xmlData);
}
@ApiOperation(value = "会员充值支付回调通知处理")
@PostMapping("/notify/vipOrder")
public String parseVipOrderNotifyResult(@RequestBody String xmlData) throws WxPayException {
final WxPayOrderNotifyResult notifyResult = this.wxService.parseOrderNotifyResult(xmlData);
// TODO 根据自己业务场景需要构造返回对象
return WxPayNotifyResponse.success("成功");
}
//
// /**
// * <pre>
......@@ -395,6 +399,6 @@
// public String queryComment(Date beginDate, Date endDate, Integer offset, Integer limit) throws WxPayException {
// return this.wxService.queryComment(beginDate, endDate, offset, limit);
// }
//
//}
//
}
......@@ -57,4 +57,14 @@ public class DonationRecord extends BaseEntity {
@ApiModelProperty("是否为别人替我捐款")
private Integer isReplace;
@ApiModelProperty("微信商家订单id")
private String wxMerPayId;
@ApiModelProperty("支付状态,1已支付, 0未支付")
private Integer payStatus;
@ApiModelProperty("支付时间")
private Date payTime;
}
......@@ -64,4 +64,13 @@ public class VipRecord extends BaseEntity {
@ApiModelProperty("修改时间")
private Date updateTime;
@ApiModelProperty("微信商家订单id")
private String wxMerPayId;
@ApiModelProperty("支付状态,1已支付, 0未支付")
private Integer payStatus;
@ApiModelProperty("支付时间")
private Date payTime;
}
......@@ -36,7 +36,7 @@ public interface DonationRecordMapper extends BaseMapper<DonationRecord> {
* @param donationRecordPageParam
* @return
*/
IPage<DonationRecordQueryVo> getDonationRecordPageList(@Param("page") Page page, @Param("param") DonationRecordPageParam donationRecordPageParam);
IPage<DonationRecordQueryVo> getDonationRecordPageList(@Param("page") Page page, @Param("param") DonationRecordPageParam donationRecordPageParam, @Param("userId") Long userId);
/**
......
package com.sien.common.param;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
/**
* <pre>
......@@ -18,6 +18,6 @@ import io.geekidea.springbootplus.framework.core.pagination.BasePageOrderParam;
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = true)
@ApiModel(value = "捐款记录分页参数")
public class DonationRecordPageParam extends BasePageOrderParam{
private static final long serialVersionUID=1L;
}
public class DonationRecordPageParam extends BasePageOrderParam {
private static final long serialVersionUID = 1L;
}
......@@ -30,7 +30,7 @@ public class VipRecordOpenParam extends BasePageOrderParam {
private BigDecimal money;
@NotNull(message = "开通多久不能为空")
@ApiModelProperty("开通多")
@ApiModelProperty("开通多少年")
private Integer years;
@NotBlank(message = "会员等级不能为空")
......@@ -38,11 +38,17 @@ public class VipRecordOpenParam extends BasePageOrderParam {
private String vipLevel;
@NotBlank(message = "不能为空")
@ApiModelProperty("是否代替他人捐款")
private Boolean isAgent;
@ApiModelProperty("是否代替他人开通")
private Boolean isReplace;
@NotBlank(message = "不能为空")
@ApiModelProperty("替他人捐款,接收人userId, 当isAgent=1为必填")
private Long agentUserId;
// @NotBlank(message = "不能为空")
// @ApiModelProperty("替他人开通,接收人userId, ")
// private Long agentUserId;
@ApiModelProperty("捐款接收用户手机号,当isAgent=1为必填")
private String userPhone;
@ApiModelProperty("手机区号,当isAgent=1为必填")
private String phoneArea;
}
......@@ -16,18 +16,21 @@ import java.math.BigDecimal;
public class DonationRecordAdd implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty("捐款金额")
@ApiModelProperty(value = "捐款金额", required = true)
private BigDecimal money;
@ApiModelProperty("捐款用途;直接录入字符串: 助学助教,资助病残;慰问孤老,其他")
@ApiModelProperty(value = "捐款用途;直接录入字符串: 助学助教,资助病残;慰问孤老,其他", required = true)
private String purpose;
@ApiModelProperty("捐款方式;1正常,2匿名")
@ApiModelProperty(value = "捐款方式;1正常,2匿名", required = true)
private Integer way;
@ApiModelProperty("是否替别人捐款")
@ApiModelProperty(value = "是否替别人捐款,1是,0不是", required = true)
private Integer isReplace;
@ApiModelProperty("捐款接收用户手机号")
@ApiModelProperty("捐款接收用户手机号,isReplace=1时必传")
private String userPhone;
@ApiModelProperty("手机区号,isReplace=1时必传")
private String phoneArea;
}
......@@ -37,6 +37,10 @@ public interface DonationRecordService extends BaseService<DonationRecord> {
boolean saveDonationRecord(DonationRecord donationRecord) throws Exception;
// 回调
String parseDonationOrderNotifyResult(String xmlData);
ApiResult<WxPayMpOrderResult> add(DonationRecordAdd donationRecordAdd) throws Exception;
/**
......
......@@ -60,8 +60,8 @@ public class VipRecordServiceImpl extends BaseServiceImpl<VipRecordMapper, VipRe
// vipRecord.setUpdateTime(new Date());
// 判断是否为替他人
if (vipRecordOpenParam.getIsAgent()) {
vipRecord.setFkRechargeUser(vipRecordOpenParam.getAgentUserId());
if (vipRecordOpenParam.getIsReplace()) {
// vipRecord.setFkRechargeUser(vipRecordOpenParam.getAgentUserId());
}
return super.save(vipRecord);
......
......@@ -5,7 +5,7 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id
, fk_user_id, money, purpose, way, remark, create_time, update_time, is_replace
, fk_user_id, money, purpose, way, remark, create_time, update_time, is_replace,wx_mer_pay_id,pay_status,pay_time
</sql>
<select id="getDonationRecordById" resultType="com.sien.common.vo.DonationRecordQueryVo">
......@@ -19,13 +19,15 @@
select
<include refid="Base_Column_List"/>
from donation_record
where pay_status=1
and fk_user_id=#{userId}
</select>
<select id="getDonationRankAndTotal" resultType="com.sien.common.vo.DonationRankAndTotal">
SELECT
tb.*,
@curRank := @curRank + 1 AS rank
FROM
( SELECT fk_user_id, sum( money ) AS drTotal FROM donation_record GROUP BY fk_user_id ORDER BY drTotal DESC ) AS tb,
( SELECT fk_user_id, sum( money ) AS drTotal FROM donation_record WHERE donation_record.pay_status = 1 GROUP BY fk_user_id ORDER BY drTotal DESC ) AS tb,
( SELECT @curRank := 0 ) r
WHERE
fk_user_id = #{userId}
......
......@@ -4,7 +4,7 @@
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, fk_user_id, fk_recharge_user, money, expired_at, years, vip_level, remark, create_time, update_time
id, fk_user_id, fk_recharge_user, money, expired_at, years, vip_level, remark, create_time, update_time,wx_mer_pay_id,pay_status,pay_time
</sql>
<select id="getVipRecordById" resultType="com.sien.common.vo.VipRecordQueryVo">
......
......@@ -195,6 +195,9 @@ spring-boot-plus:
# - /actuator/**
- # 排除首页
- /,/index.html
# 微信支付回调
- /pay/notify/donationOrder
- /pay/notify/vipOrder
# 多行字符串权限配置
......
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