feat(payment): 支持会员和积分充值的支付宝支付功能
- 新增了 memberPay 和 pointsPay 方法来处理不同类型的支付请求- 实现了订单处理和支付回调逻辑 - 添加了充值记录相关功能和数据库表 - 更新了用户模型,增加了邀请人ID和免费积分字段feature/comment
parent
0f12d1727e
commit
d23497bdc5
|
@ -124,4 +124,20 @@ public class MemberController {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消费积分
|
||||||
|
*/
|
||||||
|
@GetMapping("consumePoints/{consumePoints}")
|
||||||
|
public AjaxResult consumePoints(@PathVariable Double consumePoints) {
|
||||||
|
|
||||||
|
if (consumePoints == null || consumePoints <= 0) {
|
||||||
|
return AjaxResult.warn("消费积分不能为空或小于0");
|
||||||
|
}
|
||||||
|
|
||||||
|
memberService.consumePoints(consumePoints);
|
||||||
|
return AjaxResult.success();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,37 +1,94 @@
|
||||||
package com.mcwl.web.controller.pay;
|
package com.mcwl.web.controller.pay;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.hutool.core.lang.UUID;
|
||||||
|
import cn.hutool.db.sql.Order;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.alipay.easysdk.factory.Factory;
|
import com.alipay.easysdk.factory.Factory;
|
||||||
import com.alipay.easysdk.kernel.Config;
|
import com.alipay.easysdk.kernel.Config;
|
||||||
import com.alipay.easysdk.payment.facetoface.models.AlipayTradePrecreateResponse;
|
import com.alipay.easysdk.payment.facetoface.models.AlipayTradePrecreateResponse;
|
||||||
|
import com.mcwl.common.core.redis.RedisCache;
|
||||||
|
import com.mcwl.common.exception.ServiceException;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
|
import com.mcwl.memberCenter.domain.MemberLevel;
|
||||||
|
import com.mcwl.memberCenter.service.MemberLevelService;
|
||||||
|
import com.mcwl.memberCenter.service.MemberService;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
import com.mcwl.pay.domain.OrderTrade;
|
||||||
|
import com.mcwl.pay.domain.OrderTradeDto;
|
||||||
|
import com.mcwl.resource.domain.MallProduct;
|
||||||
|
import com.mcwl.resource.service.MallProductService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付宝支付
|
* 支付宝支付
|
||||||
|
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
|
||||||
public class AliPayIntegration {
|
public class AliPayIntegration {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Config config;
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberService memberService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberLevelService memberLevelService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MallProductService mallProductService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
|
|
||||||
|
|
||||||
|
public AliPayIntegration(Config config) {
|
||||||
|
Factory.setOptions(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 调用支付宝预下订单接口
|
* 调用支付宝预下订单接口
|
||||||
*
|
*
|
||||||
* @param tradeEntity 订单实体
|
* @param orderTradeDto 订单实体
|
||||||
* @return 二维码url
|
* @return 二维码url
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public String pay(OrderTrade tradeEntity) throws Exception {
|
public String orderPay(OrderTradeDto orderTradeDto) throws Exception {
|
||||||
Factory.setOptions(config);
|
Integer productId = orderTradeDto.getProductId();
|
||||||
|
if (!Optional.ofNullable(productId).isPresent()) {
|
||||||
|
throw new ServiceException("mallProductId不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
MallProduct mallProduct = mallProductService.getById(productId);
|
||||||
|
if (!Optional.ofNullable(mallProduct).isPresent()) {
|
||||||
|
throw new ServiceException("mallProduct不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置orderTrade信息
|
||||||
|
OrderTrade tradeEntity = new OrderTrade();
|
||||||
|
BeanUtil.copyProperties(orderTradeDto, tradeEntity);
|
||||||
|
tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30));
|
||||||
|
tradeEntity.setUserId(SecurityUtils.getUserId());
|
||||||
|
tradeEntity.setUserName(SecurityUtils.getUsername());
|
||||||
|
tradeEntity.setProductName(mallProduct.getProductName());
|
||||||
|
|
||||||
//调用支付宝的接口
|
//调用支付宝的接口
|
||||||
AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
||||||
.preCreate(tradeEntity.getUserName(),
|
.preCreate(mallProduct.getProductName(),
|
||||||
tradeEntity.getCode(),
|
tradeEntity.getCode() + "_product",
|
||||||
tradeEntity.getPaymentAmount().toString());
|
orderTradeDto.getPaymentAmount().toString());
|
||||||
|
// 缓存到redis
|
||||||
|
redisCache.setCacheObject(tradeEntity.getCode() + "_product", JSONUtil.toJsonStr(tradeEntity), 3, TimeUnit.MINUTES);
|
||||||
// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace().preCreate("订单主题:Mac笔记本", "LS123qwe123", "19999");
|
// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace().preCreate("订单主题:Mac笔记本", "LS123qwe123", "19999");
|
||||||
//参照官方文档响应示例,解析返回结果
|
//参照官方文档响应示例,解析返回结果
|
||||||
String httpBodyStr = payResponse.getHttpBody();
|
String httpBodyStr = payResponse.getHttpBody();
|
||||||
|
@ -39,4 +96,81 @@ public class AliPayIntegration {
|
||||||
return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用支付宝预下订单接口
|
||||||
|
*
|
||||||
|
* @param orderTradeDto 订单实体
|
||||||
|
* @return 二维码url
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public String memberPay(OrderTradeDto orderTradeDto) throws Exception {
|
||||||
|
|
||||||
|
// 会员等级id
|
||||||
|
Integer productId = orderTradeDto.getProductId();
|
||||||
|
|
||||||
|
if (!Optional.ofNullable(productId).isPresent()) {
|
||||||
|
throw new ServiceException("memberLevelId不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
MemberLevel memberLevel = memberLevelService.getById(productId);
|
||||||
|
|
||||||
|
if (!Optional.ofNullable(memberLevel).isPresent()) {
|
||||||
|
throw new ServiceException("memberLevel不存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置orderTrade信息
|
||||||
|
OrderTrade tradeEntity = new OrderTrade();
|
||||||
|
BeanUtil.copyProperties(orderTradeDto, tradeEntity);
|
||||||
|
tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30));
|
||||||
|
tradeEntity.setUserId(SecurityUtils.getUserId());
|
||||||
|
tradeEntity.setUserName(SecurityUtils.getUsername());
|
||||||
|
tradeEntity.setProductName(memberLevel.getMemberName());
|
||||||
|
|
||||||
|
//调用支付宝的接口
|
||||||
|
AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
||||||
|
// 设置过期时
|
||||||
|
.preCreate(memberLevel.getMemberName(),
|
||||||
|
tradeEntity.getCode() + "_member",
|
||||||
|
orderTradeDto.getPaymentAmount().toString());
|
||||||
|
// 缓存到redis
|
||||||
|
redisCache.setCacheObject(tradeEntity.getCode() + "_member", JSONUtil.toJsonStr(tradeEntity), 3, TimeUnit.MINUTES);
|
||||||
|
redisCache.setCacheObject(tradeEntity.getCode() + "_member" + "_promotionId", orderTradeDto.getPromotionId(), 3, TimeUnit.MINUTES);
|
||||||
|
// AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace().preCreate("订单主题:Mac笔记本", "LS123qwe123", "19999");
|
||||||
|
//参照官方文档响应示例,解析返回结果
|
||||||
|
String httpBodyStr = payResponse.getHttpBody();
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
|
||||||
|
return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 调用支付宝预下订单接口
|
||||||
|
*
|
||||||
|
* @param paymentAmount 充值金额
|
||||||
|
* @return 二维码url
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public String pointsPay(Double paymentAmount) throws Exception {
|
||||||
|
// 设置orderTrade信息
|
||||||
|
OrderTrade tradeEntity = new OrderTrade();
|
||||||
|
tradeEntity.setCode(UUID.randomUUID().toString(true).substring(0, 30));
|
||||||
|
tradeEntity.setUserId(SecurityUtils.getUserId());
|
||||||
|
tradeEntity.setProductId(-1);
|
||||||
|
tradeEntity.setProductName("积分充值");
|
||||||
|
tradeEntity.setUserName(SecurityUtils.getUsername());
|
||||||
|
tradeEntity.setPaymentAmount(paymentAmount.intValue());
|
||||||
|
|
||||||
|
//调用支付宝的接口
|
||||||
|
AlipayTradePrecreateResponse payResponse = Factory.Payment.FaceToFace()
|
||||||
|
.preCreate(tradeEntity.getProductName(),
|
||||||
|
tradeEntity.getCode() + "_points",
|
||||||
|
tradeEntity.getPaymentAmount().toString());
|
||||||
|
// 缓存到redis
|
||||||
|
redisCache.setCacheObject(tradeEntity.getCode() + "_points", JSONUtil.toJsonStr(tradeEntity), 3, TimeUnit.MINUTES);
|
||||||
|
//参照官方文档响应示例,解析返回结果
|
||||||
|
String httpBodyStr = payResponse.getHttpBody();
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(httpBodyStr);
|
||||||
|
return jsonObject.getJSONObject("alipay_trade_precreate_response").get("qr_code").toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package com.mcwl.web.controller.pay;
|
package com.mcwl.web.controller.pay;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.UUID;
|
||||||
import cn.hutool.extra.qrcode.QrCodeUtil;
|
import cn.hutool.extra.qrcode.QrCodeUtil;
|
||||||
|
import cn.hutool.json.JSONUtil;
|
||||||
import com.alipay.easysdk.factory.Factory;
|
import com.alipay.easysdk.factory.Factory;
|
||||||
import com.alipay.easysdk.payment.common.models.AlipayTradeQueryResponse;
|
import com.alipay.easysdk.payment.common.models.AlipayTradeQueryResponse;
|
||||||
import com.mcwl.common.JSONUtils;
|
import com.mcwl.common.JSONUtils;
|
||||||
|
@ -8,9 +10,11 @@ import com.mcwl.common.annotation.Anonymous;
|
||||||
import com.mcwl.common.core.controller.BaseController;
|
import com.mcwl.common.core.controller.BaseController;
|
||||||
import com.mcwl.common.core.domain.AjaxResult;
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
|
import com.mcwl.common.core.redis.RedisCache;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
import com.mcwl.pay.domain.OrderTrade;
|
||||||
|
import com.mcwl.pay.domain.OrderTradeDto;
|
||||||
import com.mcwl.pay.service.OrderTradeService;
|
import com.mcwl.pay.service.OrderTradeService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import com.alipay.easysdk.kernel.Config;
|
import com.alipay.easysdk.kernel.Config;
|
||||||
|
@ -20,9 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
|
@ -48,12 +50,15 @@ public class OrderTradeController extends BaseController {
|
||||||
@Autowired
|
@Autowired
|
||||||
private AliPayIntegration aliPayIntegration;
|
private AliPayIntegration aliPayIntegration;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询列表
|
* 查询列表
|
||||||
*/
|
*/
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo list(OrderTrade orderTrade)
|
public TableDataInfo list(OrderTrade orderTrade) {
|
||||||
{
|
|
||||||
startPage();
|
startPage();
|
||||||
List<OrderTrade> list = orderTradeService.selectMallProductList(orderTrade);
|
List<OrderTrade> list = orderTradeService.selectMallProductList(orderTrade);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
@ -63,8 +68,7 @@ public class OrderTradeController extends BaseController {
|
||||||
* 新增
|
* 新增
|
||||||
*/
|
*/
|
||||||
@PostMapping("/add")
|
@PostMapping("/add")
|
||||||
public AjaxResult add(@RequestBody OrderTrade orderTrade)
|
public AjaxResult add(@RequestBody OrderTrade orderTrade) {
|
||||||
{
|
|
||||||
// 获取当前用户
|
// 获取当前用户
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
|
@ -79,8 +83,7 @@ public class OrderTradeController extends BaseController {
|
||||||
* 修改
|
* 修改
|
||||||
*/
|
*/
|
||||||
@PostMapping("/upda")
|
@PostMapping("/upda")
|
||||||
public AjaxResult upda(@RequestBody OrderTrade orderTrade)
|
public AjaxResult upda(@RequestBody OrderTrade orderTrade) {
|
||||||
{
|
|
||||||
// 获取当前用户
|
// 获取当前用户
|
||||||
Long userId = SecurityUtils.getUserId();
|
Long userId = SecurityUtils.getUserId();
|
||||||
if (userId == null) {
|
if (userId == null) {
|
||||||
|
@ -95,8 +98,7 @@ public class OrderTradeController extends BaseController {
|
||||||
* 删除
|
* 删除
|
||||||
*/
|
*/
|
||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult remove(@RequestBody IdsParam ids)
|
public AjaxResult remove(@RequestBody IdsParam ids) {
|
||||||
{
|
|
||||||
orderTradeService.deleteMallProductByIds(ids);
|
orderTradeService.deleteMallProductByIds(ids);
|
||||||
return success();
|
return success();
|
||||||
}
|
}
|
||||||
|
@ -105,14 +107,23 @@ public class OrderTradeController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 支付接口
|
* 支付接口
|
||||||
*
|
*
|
||||||
* @param tradeEntity 订单实体
|
* @param orderTradeDto 订单实体
|
||||||
* @param response 响应
|
* @param response 响应
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
@Anonymous
|
@Anonymous
|
||||||
@PostMapping("/doPay")
|
@PostMapping("/doPay")
|
||||||
public void doPay(@RequestBody OrderTrade tradeEntity, HttpServletResponse response) throws Exception {
|
public void doPay(@RequestBody OrderTradeDto orderTradeDto, HttpServletResponse response) throws Exception {
|
||||||
String qrUrl = aliPayIntegration.pay(tradeEntity);
|
String qrUrl = null;
|
||||||
|
|
||||||
|
String type = orderTradeDto.getType();
|
||||||
|
|
||||||
|
if ("member".equals(type)) {
|
||||||
|
qrUrl = aliPayIntegration.memberPay(orderTradeDto);
|
||||||
|
} else if ("points".equals(type)) {
|
||||||
|
qrUrl = aliPayIntegration.pointsPay(orderTradeDto.getPaymentAmount());
|
||||||
|
}
|
||||||
|
|
||||||
QrCodeUtil.generate(qrUrl, 300, 300, "png", response.getOutputStream());
|
QrCodeUtil.generate(qrUrl, 300, 300, "png", response.getOutputStream());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,6 +147,7 @@ public class OrderTradeController extends BaseController {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付回调接口
|
* 支付回调接口
|
||||||
|
*
|
||||||
* @param request
|
* @param request
|
||||||
* @return
|
* @return
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
|
@ -155,23 +167,56 @@ public class OrderTradeController extends BaseController {
|
||||||
// System.out.println(name + " = " + request.getParameter(name));
|
// System.out.println(name + " = " + request.getParameter(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
String tradeNo = params.get("out_trade_no");
|
|
||||||
String gmtPayment = params.get("gmt_payment");
|
|
||||||
String alipayTradeNo = params.get("trade_no");
|
|
||||||
// 支付宝验签
|
// 支付宝验签
|
||||||
if (Factory.Payment.Common().verifyNotify(params)) {
|
if (Factory.Payment.Common().verifyNotify(params)) {
|
||||||
|
// System.out.println("交易名称: " + params.get("subject"));
|
||||||
|
// System.out.println("交易状态: " + params.get("trade_status"));
|
||||||
|
// System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
|
||||||
|
// System.out.println("商户订单号: " + params.get("out_trade_no"));
|
||||||
|
// System.out.println("交易金额: " + params.get("total_amount"));
|
||||||
|
// System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
|
||||||
|
// System.out.println("买家付款时间: " + params.get("gmt_payment"));
|
||||||
|
// System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
|
||||||
// 验签通过
|
// 验签通过
|
||||||
System.out.println("交易名称: " + params.get("subject"));
|
|
||||||
System.out.println("交易状态: " + params.get("trade_status"));
|
String code = params.get("out_trade_no"); // 商户订单号
|
||||||
System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
|
// 获取订单后缀
|
||||||
System.out.println("商户订单号: " + params.get("out_trade_no"));
|
String suffix = code.substring(code.lastIndexOf("_") + 1);
|
||||||
System.out.println("交易金额: " + params.get("total_amount"));
|
String orderTradeJson = redisCache.getCacheObject(code);
|
||||||
System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
|
OrderTrade orderTrade = JSONUtil.toBean(orderTradeJson, OrderTrade.class);
|
||||||
System.out.println("买家付款时间: " + params.get("gmt_payment"));
|
|
||||||
System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
|
orderTradeService.orderHandler(orderTrade, suffix, params);
|
||||||
|
|
||||||
// 更新订单状态
|
// 更新订单状态
|
||||||
|
// if (!StringUtils.isEmpty(orderTradeJson)) {
|
||||||
|
// OrderTrade orderTrade = JSONUtil.toBean(orderTradeJson, OrderTrade.class);
|
||||||
|
// // 支付宝交易凭证号
|
||||||
|
// orderTrade.setPaymentMethod(params.get("trade_no"));
|
||||||
|
// orderTrade.setTransactionId(1);
|
||||||
|
// orderTrade.setOrderTime(DateUtils.parseDate(params.get("gmt_payment")));
|
||||||
|
// orderTrade.setOrderStatus(3);
|
||||||
|
// orderTrade.setPayStatus(2);
|
||||||
|
// String totalAmountStr = params.get("total_amount");
|
||||||
|
// if (totalAmountStr != null && !totalAmountStr.isEmpty()) {
|
||||||
|
// BigDecimal totalAmount = new BigDecimal(totalAmountStr);
|
||||||
|
// orderTrade.setTotalAmount(totalAmount.intValue());
|
||||||
|
// }
|
||||||
|
// String buyerPayAmountStr = params.get("buyer_pay_amount");
|
||||||
|
// if (buyerPayAmountStr != null && !buyerPayAmountStr.isEmpty()) {
|
||||||
|
// BigDecimal buyerPayAmount = new BigDecimal(buyerPayAmountStr);
|
||||||
|
// orderTrade.setPaymentAmount(buyerPayAmount.intValue());
|
||||||
|
// }
|
||||||
|
// orderTradeService.save(orderTrade);
|
||||||
|
// }
|
||||||
|
} else {
|
||||||
|
// 验签失败
|
||||||
|
System.out.println("验签失败");
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
// 验签失败
|
||||||
|
System.out.println("验签失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
return "success";
|
return "success";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -95,6 +95,16 @@ public class SysUser extends BaseEntity
|
||||||
/** 简介 */
|
/** 简介 */
|
||||||
private String brief;
|
private String brief;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 邀请人id
|
||||||
|
*/
|
||||||
|
private Long inviterUserId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 免费用户积分
|
||||||
|
*/
|
||||||
|
private Double freePoints;
|
||||||
|
|
||||||
public SysUser()
|
public SysUser()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -311,6 +321,23 @@ public class SysUser extends BaseEntity
|
||||||
this.brief = brief;
|
this.brief = brief;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Long getInviterUserId() {
|
||||||
|
return inviterUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInviterUserId(Long inviterUserId) {
|
||||||
|
this.inviterUserId = inviterUserId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Double getFreePoints() {
|
||||||
|
return freePoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFreePoints(Double freePoints) {
|
||||||
|
this.freePoints = freePoints;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "SysUser{" +
|
return "SysUser{" +
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
package com.mcwl.memberCenter.domain;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.mcwl.common.core.domain.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@TableName("mem_recharge_record")
|
||||||
|
public class RechargeRecord extends BaseEntity {
|
||||||
|
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 用户ID
|
||||||
|
*/
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单号
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充值金额
|
||||||
|
*/
|
||||||
|
private Double amount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取到的积分
|
||||||
|
*/
|
||||||
|
private Double points;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package com.mcwl.memberCenter.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.mcwl.memberCenter.domain.Promotion;
|
||||||
|
import com.mcwl.memberCenter.domain.RechargeRecord;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 充值记录 Mapper
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface RechargeRecordMapper extends BaseMapper<RechargeRecord> {
|
||||||
|
}
|
|
@ -35,4 +35,10 @@ public interface MemberService extends IService<Member> {
|
||||||
Member rechargePoints(Long userId, Double points);
|
Member rechargePoints(Long userId, Double points);
|
||||||
|
|
||||||
Member latestSubscription(Long userId);
|
Member latestSubscription(Long userId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消费积分
|
||||||
|
* @param consumePoints 消费积分
|
||||||
|
*/
|
||||||
|
void consumePoints(Double consumePoints);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
package com.mcwl.memberCenter.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
|
import com.mcwl.memberCenter.domain.RechargeRecord;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface RechargeRecordService extends IService<RechargeRecord> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -1,9 +1,12 @@
|
||||||
package com.mcwl.memberCenter.service.impl;
|
package com.mcwl.memberCenter.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.core.domain.AjaxResult;
|
||||||
import com.mcwl.common.core.domain.entity.SysUser;
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
import com.mcwl.common.exception.ServiceException;
|
import com.mcwl.common.exception.ServiceException;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.memberCenter.domain.MemberBenefit;
|
import com.mcwl.memberCenter.domain.MemberBenefit;
|
||||||
import com.mcwl.memberCenter.domain.MemberLevel;
|
import com.mcwl.memberCenter.domain.MemberLevel;
|
||||||
import com.mcwl.memberCenter.domain.Member;
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
|
@ -21,6 +24,7 @@ import com.mcwl.memberCenter.service.PromotionService;
|
||||||
import com.mcwl.system.service.ISysUserService;
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
import javax.validation.constraints.NotNull;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
@ -172,6 +176,45 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void consumePoints(Double consumePoints) {
|
||||||
|
Long userId = SecurityUtils.getUserId();
|
||||||
|
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||||
|
Member member = this.getUseUserMemberByUserId(userId);
|
||||||
|
// 用户的免费积分
|
||||||
|
Double freePoints = sysUser.getFreePoints();
|
||||||
|
// 会员积分
|
||||||
|
Double memberPoints = 0.0;
|
||||||
|
if (member != null) {
|
||||||
|
memberPoints = member.getPoints();
|
||||||
|
}
|
||||||
|
// 获取用户的总积分
|
||||||
|
double points = freePoints + memberPoints;
|
||||||
|
if (points < consumePoints) {
|
||||||
|
throw new ServiceException("积分不足");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 先扣除会员的积分
|
||||||
|
if (member != null) {
|
||||||
|
double mp = member.getPoints() - consumePoints;
|
||||||
|
if (mp >= 0) {
|
||||||
|
member.setPoints(mp);
|
||||||
|
} else {
|
||||||
|
member.setPoints(0D);
|
||||||
|
consumePoints = consumePoints - memberPoints;
|
||||||
|
}
|
||||||
|
member.setPoints(mp);
|
||||||
|
baseMapper.updateById(member);
|
||||||
|
}
|
||||||
|
// consumePoints有剩余再扣除用户的积分
|
||||||
|
if (consumePoints > 0) {
|
||||||
|
sysUser.setFreePoints(freePoints - consumePoints);
|
||||||
|
sysUserService.updateUser(sysUser);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private List<Member> getUseUserMember(Long userId) {
|
private List<Member> getUseUserMember(Long userId) {
|
||||||
// startDate 小于等于当前时间、endDate 大于等于当前时间
|
// startDate 小于等于当前时间、endDate 大于等于当前时间
|
||||||
// subscriptionStatus 不为 "过期" 或 "待支付"
|
// subscriptionStatus 不为 "过期" 或 "待支付"
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
package com.mcwl.memberCenter.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.memberCenter.domain.Promotion;
|
||||||
|
import com.mcwl.memberCenter.domain.RechargeRecord;
|
||||||
|
import com.mcwl.memberCenter.mapper.PromotionMapper;
|
||||||
|
import com.mcwl.memberCenter.mapper.RechargeRecordMapper;
|
||||||
|
import com.mcwl.memberCenter.service.PromotionService;
|
||||||
|
import com.mcwl.memberCenter.service.RechargeRecordService;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class RechargeRecordServiceImpl extends ServiceImpl<RechargeRecordMapper, RechargeRecord> implements RechargeRecordService {
|
||||||
|
|
||||||
|
}
|
|
@ -27,6 +27,23 @@
|
||||||
<artifactId>mcwl-common</artifactId>
|
<artifactId>mcwl-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mcwl</groupId>
|
||||||
|
<artifactId>mcwl-system</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mcwl</groupId>
|
||||||
|
<artifactId>mcwl-myInvitation</artifactId>
|
||||||
|
<version>3.8.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mcwl</groupId>
|
||||||
|
<artifactId>mcwl-memberCenter</artifactId>
|
||||||
|
<version>3.8.8</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.baomidou</groupId>
|
<groupId>com.baomidou</groupId>
|
||||||
<artifactId>mybatis-plus-boot-starter</artifactId>
|
<artifactId>mybatis-plus-boot-starter</artifactId>
|
||||||
|
|
|
@ -0,0 +1,27 @@
|
||||||
|
package com.mcwl.pay.domain;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class OrderTradeDto {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品ID
|
||||||
|
*/
|
||||||
|
private Integer productId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付金额
|
||||||
|
*/
|
||||||
|
private Double paymentAmount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 订单类型 member/points
|
||||||
|
*/
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 活动id
|
||||||
|
*/
|
||||||
|
private Long promotionId;
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.mcwl.pay.domain.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum OrderTypeEnum {
|
||||||
|
|
||||||
|
POINTS("points"),
|
||||||
|
MEMBER("member");
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
|
||||||
|
}
|
|
@ -5,6 +5,7 @@ import com.mcwl.common.domain.IdsParam;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
import com.mcwl.pay.domain.OrderTrade;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
|
@ -24,5 +25,5 @@ public interface OrderTradeService extends IService<OrderTrade> {
|
||||||
int updateMallProduct(OrderTrade orderTrade);
|
int updateMallProduct(OrderTrade orderTrade);
|
||||||
|
|
||||||
|
|
||||||
|
void orderHandler(OrderTrade orderTrade, String suffix, Map<String, String> params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,20 +1,35 @@
|
||||||
package com.mcwl.pay.service.impl;
|
package com.mcwl.pay.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
|
import com.mcwl.common.core.redis.RedisCache;
|
||||||
import com.mcwl.common.domain.IdsParam;
|
import com.mcwl.common.domain.IdsParam;
|
||||||
|
import com.mcwl.common.utils.DateUtils;
|
||||||
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.common.utils.StringUtils;
|
import com.mcwl.common.utils.StringUtils;
|
||||||
|
import com.mcwl.common.utils.uuid.IdUtils;
|
||||||
|
import com.mcwl.memberCenter.domain.Member;
|
||||||
|
import com.mcwl.memberCenter.domain.RechargeRecord;
|
||||||
|
import com.mcwl.memberCenter.service.MemberService;
|
||||||
|
import com.mcwl.memberCenter.service.RechargeRecordService;
|
||||||
|
import com.mcwl.myInvitation.domain.Commission;
|
||||||
|
import com.mcwl.myInvitation.domain.Consume;
|
||||||
|
import com.mcwl.myInvitation.service.CommissionService;
|
||||||
|
import com.mcwl.myInvitation.service.ConsumeService;
|
||||||
import com.mcwl.pay.domain.OrderTrade;
|
import com.mcwl.pay.domain.OrderTrade;
|
||||||
import com.mcwl.pay.domain.PaymentResult;
|
import com.mcwl.pay.domain.PaymentResult;
|
||||||
import com.mcwl.pay.domain.enums.PaymentStatus;
|
import com.mcwl.pay.domain.enums.PaymentStatus;
|
||||||
|
import com.mcwl.pay.domain.enums.OrderTypeEnum;
|
||||||
import com.mcwl.pay.mapper.OrderTradeMapper;
|
import com.mcwl.pay.mapper.OrderTradeMapper;
|
||||||
import com.mcwl.pay.service.OrderTradeService;
|
import com.mcwl.pay.service.OrderTradeService;
|
||||||
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Author:ChenYan
|
* @Author:ChenYan
|
||||||
|
@ -27,8 +42,30 @@ import java.util.List;
|
||||||
@Service
|
@Service
|
||||||
public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTrade> implements OrderTradeService {
|
public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTrade> implements OrderTradeService {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderTradeMapper orderTradeMapper;
|
private OrderTradeMapper orderTradeMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderTradeService orderTradeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CommissionService commissionService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ConsumeService consumeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ISysUserService sysUserService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MemberService memberService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RechargeRecordService rechargeRecordService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private RedisCache redisCache;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<OrderTrade> selectMallProductList(OrderTrade orderTrade) {
|
public List<OrderTrade> selectMallProductList(OrderTrade orderTrade) {
|
||||||
|
@ -98,7 +135,105 @@ public class OrderTradeServiceImpl extends ServiceImpl<OrderTradeMapper, OrderTr
|
||||||
return orderTradeMapper.updateById(orderTrade);
|
return orderTradeMapper.updateById(orderTrade);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void orderHandler(OrderTrade orderTrade, String suffix, Map<String, String> params) {
|
||||||
|
this.orderHandler(orderTrade, params);
|
||||||
|
if (OrderTypeEnum.POINTS.getName().equals(suffix)) {
|
||||||
|
pointsHandler(orderTrade, params);
|
||||||
|
} else if (OrderTypeEnum.MEMBER.getName().equals(suffix)) {
|
||||||
|
Long promotionId = redisCache.getCacheObject(params.get("out_trade_no") + "promotionId");
|
||||||
|
memberHandler(orderTrade, promotionId);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void pointsHandler(OrderTrade orderTrade, Map<String, String> params) {
|
||||||
|
|
||||||
|
// 获取支付金额
|
||||||
|
String amount = params.get("buyer_pay_amount");
|
||||||
|
Double points = Double.parseDouble(amount) * 100;
|
||||||
|
Long userId = orderTrade.getUserId();
|
||||||
|
SysUser user = sysUserService.selectUserById(userId);
|
||||||
|
user.setFreePoints(user.getFreePoints() + points);
|
||||||
|
sysUserService.updateUser(user);
|
||||||
|
|
||||||
|
RechargeRecord rechargeRecord = new RechargeRecord();
|
||||||
|
rechargeRecord.setUserId(userId);
|
||||||
|
rechargeRecord.setCode(orderTrade.getCode());
|
||||||
|
rechargeRecord.setAmount(Double.parseDouble(amount));
|
||||||
|
rechargeRecord.setPoints(points);
|
||||||
|
rechargeRecordService.save(rechargeRecord);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void memberHandler(OrderTrade orderTrade, Long promotionId) {
|
||||||
|
Long userId = orderTrade.getUserId();
|
||||||
|
Integer memberLevelId = orderTrade.getProductId();
|
||||||
|
String paymentMethod = "aliPay";
|
||||||
|
|
||||||
|
memberService.createUserMember(userId, memberLevelId.longValue(), paymentMethod, promotionId);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void productHandler(OrderTrade orderTrade) {
|
||||||
|
Long userId = orderTrade.getUserId();
|
||||||
|
SysUser sysUser = sysUserService.selectUserById(userId);
|
||||||
|
double amount = 0.0;
|
||||||
|
// 通过sysUser获取邀请人id
|
||||||
|
Long inviterUserId = sysUser.getInviterUserId();
|
||||||
|
if (Objects.nonNull(inviterUserId)) {
|
||||||
|
amount = 0.5; // 固定0.5元提成
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 保存消费表
|
||||||
|
Consume consume = new Consume();
|
||||||
|
consume.setUserId(userId);
|
||||||
|
consume.setAmount(Double.valueOf(orderTrade.getPaymentAmount()));
|
||||||
|
consume.setConsumeDate(orderTrade.getOrderTime());
|
||||||
|
consume.setCreateBy(orderTrade.getUserName());
|
||||||
|
consume.setUpdateBy(orderTrade.getUserName());
|
||||||
|
consume.setCreateTime(new Date());
|
||||||
|
consume.setUpdateTime(new Date());
|
||||||
|
consume.setRemark("购买商品");
|
||||||
|
consumeService.save(consume);
|
||||||
|
|
||||||
|
|
||||||
|
// 保存提成表
|
||||||
|
Commission commission = new Commission();
|
||||||
|
commission.setConsumeId(inviterUserId);
|
||||||
|
commission.setAmount(amount);
|
||||||
|
commission.setPayStatus(0);
|
||||||
|
commission.setCreateBy(sysUser.getUserName());
|
||||||
|
commission.setUpdateBy(sysUser.getUserName());
|
||||||
|
commission.setCreateTime(new Date());
|
||||||
|
commission.setUpdateTime(new Date());
|
||||||
|
commission.setRemark("提成");
|
||||||
|
commissionService.save(commission);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void orderHandler(OrderTrade orderTrade, Map<String, String> params) {
|
||||||
|
// 更新订单状态
|
||||||
|
// 支付宝交易凭证号
|
||||||
|
orderTrade.setPaymentMethod(params.get("trade_no"));
|
||||||
|
orderTrade.setTransactionId(1);
|
||||||
|
orderTrade.setOrderTime(DateUtils.parseDate(params.get("gmt_payment")));
|
||||||
|
orderTrade.setOrderStatus(3);
|
||||||
|
orderTrade.setPayStatus(2);
|
||||||
|
String totalAmountStr = params.get("total_amount");
|
||||||
|
if (totalAmountStr != null && !totalAmountStr.isEmpty()) {
|
||||||
|
BigDecimal totalAmount = new BigDecimal(totalAmountStr);
|
||||||
|
orderTrade.setTotalAmount(totalAmount.intValue());
|
||||||
|
}
|
||||||
|
String buyerPayAmountStr = params.get("buyer_pay_amount");
|
||||||
|
if (buyerPayAmountStr != null && !buyerPayAmountStr.isEmpty()) {
|
||||||
|
BigDecimal buyerPayAmount = new BigDecimal(buyerPayAmountStr);
|
||||||
|
orderTrade.setPaymentAmount(buyerPayAmount.intValue());
|
||||||
|
}
|
||||||
|
orderTradeService.save(orderTrade);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="updateBy" column="update_by" />
|
<result property="updateBy" column="update_by" />
|
||||||
<result property="updateTime" column="update_time" />
|
<result property="updateTime" column="update_time" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
|
<result property="inviterUserId" column="inviter_user_id" />
|
||||||
|
<result property="freePoints" column="free_points" />
|
||||||
<association property="dept" javaType="SysDept" resultMap="deptResult" />
|
<association property="dept" javaType="SysDept" resultMap="deptResult" />
|
||||||
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
|
<collection property="roles" javaType="java.util.List" resultMap="RoleResult" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
@ -47,7 +49,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectUserVo">
|
<sql id="selectUserVo">
|
||||||
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,
|
select u.user_id, u.dept_id, u.user_name, u.nick_name, u.email, u.avatar, u.phonenumber, u.password, u.sex, u.status, u.del_flag, u.login_ip, u.login_date, u.create_by, u.create_time, u.remark,u.inviter_user_id,u.free_points,
|
||||||
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.status as dept_status,
|
||||||
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
|
r.role_id, r.role_name, r.role_key, r.role_sort, r.data_scope, r.status as role_status
|
||||||
from sys_user u
|
from sys_user u
|
||||||
|
@ -91,7 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
left join sys_dept d on u.dept_id = d.dept_id
|
left join sys_dept d on u.dept_id = d.dept_id
|
||||||
left join sys_user_role ur on u.user_id = ur.user_id
|
left join sys_user_role ur on u.user_id = ur.user_id
|
||||||
left join sys_role r on r.role_id = ur.role_id
|
left join sys_role r on r.role_id = ur.role_id
|
||||||
where u.del_flag = '0' and r.role_id = #{roleId}
|
where u.del_flag = '0'
|
||||||
<if test="userName != null and userName != ''">
|
<if test="userName != null and userName != ''">
|
||||||
AND u.user_name like concat('%', #{userName}, '%')
|
AND u.user_name like concat('%', #{userName}, '%')
|
||||||
</if>
|
</if>
|
||||||
|
@ -199,6 +201,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="loginDate != null">login_date = #{loginDate},</if>
|
<if test="loginDate != null">login_date = #{loginDate},</if>
|
||||||
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
<if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
|
||||||
<if test="remark != null">remark = #{remark},</if>
|
<if test="remark != null">remark = #{remark},</if>
|
||||||
|
<if test="freePoints != null">free_points = #{freePoints},</if>
|
||||||
update_time = sysdate()
|
update_time = sysdate()
|
||||||
</set>
|
</set>
|
||||||
where user_id = #{userId}
|
where user_id = #{userId}
|
||||||
|
|
Loading…
Reference in New Issue