feat: 会员充值,退款

pull/2/head
tangqian 2023-05-16 18:19:33 +08:00
parent 4ce486afef
commit 26a8631927
25 changed files with 980 additions and 47 deletions

View File

@ -0,0 +1,40 @@
package cn.iocoder.yudao.framework.pay.config;
import cn.iocoder.yudao.framework.pay.properties.AliPayProperties;
import cn.iocoder.yudao.framework.pay.properties.WxPayProperties;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.github.binarywang.wxpay.service.WxPayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @Title:AliPayConfig
* @Description: TODO
* @author: tangqian
* @date: 2023/5/16 13:29
* @version: V1.0.0
*/
@Configuration
@ConditionalOnClass(AlipayClient.class)
@EnableConfigurationProperties(AliPayProperties.class)
@ConditionalOnProperty(prefix = "ali.pay.one", value = "enabled", matchIfMissing = true)
public class AliPayConfig {
private AliPayProperties aliPayProperties;
@Autowired
public AliPayConfig(AliPayProperties aliPayProperties) {
this.aliPayProperties = aliPayProperties;
}
@Bean
@ConditionalOnMissingBean(AlipayClient.class)
public AlipayClient alipayClient() {
return new DefaultAlipayClient(aliPayProperties.getGatewayUrl(), aliPayProperties.getAppId(),
aliPayProperties.getMerchantPrivateKey(), "json", "UTF-8", aliPayProperties.getAlipayPublicKey(), "RSA2");
}
}

View File

@ -0,0 +1,40 @@
package cn.iocoder.yudao.framework.pay.properties;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @Title:AliPayProperties
* @Description: TODO
* @author: tangqian
* @date: 2023/5/16 13:35
* @version: V1.0.0
*/
@Data
@Component
@ConfigurationProperties(prefix = AliPayProperties.PREFIX)
public class AliPayProperties {
public static final String PREFIX = "ali.pay.one";
/**
* appId.
*/
private String appId;
/**
* .
*/
private String merchantPrivateKey;
/**
* .
*/
private String alipayPublicKey;
/**
* .
*/
private String gatewayUrl;
/**
* .
*/
private String notifyUrl;
}

View File

@ -1,3 +1,4 @@
cn.iocoder.yudao.framework.pay.config.YudaoPayAutoConfiguration
cn.iocoder.yudao.framework.pay.config.WxPayOneAutoConfiguration
cn.iocoder.yudao.framework.pay.config.WxPayTwoAutoConfiguration
cn.iocoder.yudao.framework.pay.config.WxPayTwoAutoConfiguration
cn.iocoder.yudao.framework.pay.config.AliPayConfig

View File

@ -0,0 +1,60 @@
package cn.iocoder.yudao.module.shop.request.member;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @Title:OrderContentRequest
* @Description:
* @author: tangqian
* @date: 2023/5/15 20:45
* @version: V1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Schema(description="会员充值下单请求入参")
public class OrderContentRequest implements Serializable {
private static final long serialVersionUID = -9170167938995005780L;
@Schema(description = "用户电话")
private String userPhone;
@Schema(description = "确认手机号")
private String confirmPhone;
@Schema(description = "openid(支付者微信支付)")
private String openid;
@Schema(description = "支付类型 支付宝ALIPAY 微信WXPAY")
@NotEmpty(message = "支付类型不能为空")
private String payType;
@Schema(description = "订单信息")
private List<OrderInfo> orderInfos;
@Data
public static class OrderInfo implements Serializable{
private static final long serialVersionUID = -4967251473044468810L;
@Schema(description = "订单id")
@NotNull(message = "挡位id不能为空")
private Integer gearId;
@Schema(description = "档位名称")
@NotEmpty(message = "挡位名称不能为空")
private String name;
@Schema(description = "挡位备注不能为空")
@NotEmpty(message = "挡位备注不能为空")
private String gearRemarks;
@Schema(description = "挡位金额不能为空")
@NotNull(message = "挡位金额不能为空")
private Integer gearAmount;
}
}

View File

@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.shop.request.member;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import java.io.Serializable;
/**
* @Title:OrderPayRequest
* @Description:
* @author: tangqian
* @date: 2023/5/15 20:54
* @version: V1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Schema(description="订单选择支付方式发起支付入参")
public class OrderPayRequest implements Serializable {
private static final long serialVersionUID = 6720933184418303650L;
@Schema(description = "订单id")
@NotEmpty(message = "orderId不能为空")
private String orderId;
@Schema(description = "支付类型 支付宝ALIPAY 微信WXPAY")
@NotEmpty(message = "支付类型不能为空")
private String payType;
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.shop.request.member;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
/**
* @Title:OrderContentRequest
* @Description: 退
* @author: tangqian
* @date: 2023/5/15 20:45
* @version: V1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Schema(description="退款")
public class RefundRequest implements Serializable {
private static final long serialVersionUID = -9170167938995005780L;
@Schema(description = "数据id")
private String orderId;
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.shop.response.member;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* @Title:AliPayOrderResponse
* @Description: TODO
* @author: tangqian
* @date: 2023/5/15 21:09
* @version: V1.0.0
*/
@Data
@Accessors(chain = true)
public class AliPayOrderResponse extends PayResponse {
//支付宝统一下单返回参数
private String body;
}

View File

@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.shop.response.member;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* @Title:ChangeOrderPayTypeResponse
* @Description: -
* @author: tangqian
* @date: 2023/5/15 21:05
* @version: V1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Schema(description="订单选择订单支付方式-返回参数")
public class ChangeOrderPayTypeResponse implements Serializable {
private static final long serialVersionUID = -4147278073881962962L;
@Schema(description = "订单id")
private String orderId;
@Schema(description = "支付类型 支付宝ALIPAY 微信WXPAY")
private String payType;
@Schema(description = "订单金额(分)")
private String orderPay;
@Schema(description = "需要支付金额(分)")
private String needPay;
@Schema(description = "商品名称")
private String goodsName;
@Schema(description = "此参数根据支付类型的不同,返回的参数有所不同。")
private PayResponse orderInfo;
}

View File

@ -0,0 +1,30 @@
package cn.iocoder.yudao.module.shop.response.member;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* @Title:InitOrderResponse
* @Description: TODO
* @author: tangqian
* @date: 2023/5/15 21:20
* @version: V1.0.0
*/
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@Schema(description="预下单返回参数")
public class InitOrderResponse implements Serializable {
private static final long serialVersionUID = 6894715033655337607L;
@Schema(description = "h5_url")
private String h5Url;
@Schema(description ="二维码链接")
private String codeUrl;
}

View File

@ -0,0 +1,14 @@
package cn.iocoder.yudao.module.shop.response.member;
import java.io.Serializable;
/**
* @Title:PayResponse
* @Description:
* @author: tangqian
* @date: 2023/5/15 21:06
* @version: V1.0.0
*/
public class PayResponse implements Serializable {
private static final long serialVersionUID = 9219937300257494629L;
}

View File

@ -0,0 +1,22 @@
package cn.iocoder.yudao.module.shop.response.member;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* @Title:WxPayOrderResponse
* @Description: TODO
* @author: tangqian
* @date: 2023/5/15 21:11
* @version: V1.0.0
*/
@Data
@Accessors(chain = true)
public class WxPayOrderResponse extends PayResponse{
//交易类型
private String tradeType;
//预支付ID
private String prepayId;
//支付跳转链接
private String mwebUrl;
}

View File

@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.shop.controller.admin.notify;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
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;
import javax.servlet.http.HttpServletRequest;
import java.util.Map;
/**
* @Title:AliPayNotifyController
* @Description: TODO
* @author: tangqian
* @date: 2023/5/16 16:45
* @version: V1.0.0
*/
@Slf4j
@RequestMapping("notify/ali")
@RestController
@Tag(name = "支付宝支付回调 - 订单支付")
public class AliPayNotifyController {
@Autowired
private StoreOrderService storeOrderService;
@PostMapping("pay_notify")
public CommonResult<Object> payNotify(HttpServletRequest request, @RequestBody Map<String, String> params) {
return CommonResult.success(storeOrderService.aliNotify(request, params));
}
@PostMapping("refund_notify")
public CommonResult<Object> refundNotify(HttpServletRequest request, @RequestBody Map<String, String> params) {
return CommonResult.success(storeOrderService.refundNotify(request, params));
}
}

View File

@ -0,0 +1,52 @@
package cn.iocoder.yudao.module.shop.controller.app.buy;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.shop.request.member.OrderContentRequest;
import cn.iocoder.yudao.module.shop.request.member.RefundRequest;
import cn.iocoder.yudao.module.shop.response.member.InitOrderResponse;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
/**
* @Title:TopUpOrderController
* @Description:
* @author: tangqian
* @date: 2023/5/15 20:12
* @version: V1.0.0
*/
@Slf4j
@RestController
@RequestMapping("api/order/member")
@Tag(name = "用户 APP - 会员充值订单管理")
public class TopUpOrderController {
@Autowired
private StoreOrderService storeOrderService;
@Operation(summary = "会员充值")
@RequestMapping(value = "/memberTopUp", method = RequestMethod.POST)
public CommonResult<InitOrderResponse> memberTopUp(@Valid @RequestBody OrderContentRequest request, HttpServletRequest servletRequest) throws Exception {
log.info("initOrder会员充值===>{}", request);
return CommonResult.success(storeOrderService.memberTopUp(request, servletRequest));
}
@Operation(summary = "退款")
@RequestMapping(value = "/memberRefund", method = RequestMethod.POST)
public CommonResult<Object> memberRefund(@Valid @RequestBody RefundRequest request, HttpServletRequest servletRequest) throws Exception {
log.info("memberRefund会员退款===>{}", request);
return CommonResult.success(storeOrderService.memberRefund(request, servletRequest));
}
}

View File

@ -2,15 +2,24 @@ package cn.iocoder.yudao.module.shop.service.order;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
import cn.iocoder.yudao.module.shop.request.member.OrderContentRequest;
import cn.iocoder.yudao.module.shop.request.member.OrderPayRequest;
import cn.iocoder.yudao.module.shop.request.member.RefundRequest;
import cn.iocoder.yudao.module.shop.request.order.StoreOrderRefundRequest;
import cn.iocoder.yudao.module.shop.request.order.StoreOrderSearchRequest;
import cn.iocoder.yudao.module.shop.request.order.StoreOrderSendRequest;
import cn.iocoder.yudao.module.shop.request.order.StoreOrderUpdatePriceRequest;
import cn.iocoder.yudao.module.shop.response.member.ChangeOrderPayTypeResponse;
import cn.iocoder.yudao.module.shop.response.member.InitOrderResponse;
import cn.iocoder.yudao.module.shop.response.order.*;
import cn.iocoder.yudao.module.shop.vo.order.LogisticsResultVo;
import com.baomidou.mybatisplus.extension.service.IService;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.pagehelper.PageInfo;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
@ -370,4 +379,23 @@ public interface StoreOrderService extends IService<StoreOrder> {
* @param spreadId 广uid
*/
OrderBrokerageData getBrokerageData(Integer uid, Integer spreadId);
/**
*
* @param request
* @return
*/
InitOrderResponse memberTopUp(OrderContentRequest request, HttpServletRequest servletRequest) throws WxPayException;
/**
*
* @param request
* @param params
* @return
*/
Object aliNotify(HttpServletRequest request, Map<String, String> params);
Object memberRefund(RefundRequest request, HttpServletRequest servletRequest);
Object refundNotify(HttpServletRequest request, Map<String, String> params);
}

View File

@ -9,28 +9,44 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.DateLimitUtilVo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.pay.config.WxPayOneAutoConfiguration;
import cn.iocoder.yudao.framework.pay.properties.AliPayProperties;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderInfoDO;
import cn.iocoder.yudao.module.shop.dal.mysql.order.StoreOrderMapper;
import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderInfoMapper;
import cn.iocoder.yudao.module.shop.dal.mysql.recharge.RechargeOrderMapper;
import cn.iocoder.yudao.module.shop.request.member.OrderContentRequest;
import cn.iocoder.yudao.module.shop.request.member.RefundRequest;
import cn.iocoder.yudao.module.shop.request.order.StoreOrderRefundRequest;
import cn.iocoder.yudao.module.shop.request.order.StoreOrderSearchRequest;
import cn.iocoder.yudao.module.shop.request.order.StoreOrderSendRequest;
import cn.iocoder.yudao.module.shop.request.order.StoreOrderUpdatePriceRequest;
import cn.iocoder.yudao.module.shop.response.member.InitOrderResponse;
import cn.iocoder.yudao.module.shop.response.order.*;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderInfoService;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderRefundService;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderService;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderStatusService;
import cn.iocoder.yudao.module.shop.support.StrategySupport;
import cn.iocoder.yudao.module.shop.support.pay.IPayStrategy;
import cn.iocoder.yudao.module.shop.utils.CommonPage;
import cn.iocoder.yudao.module.shop.utils.OrderUtil;
import cn.iocoder.yudao.module.shop.utils.RedisUtil;
import cn.iocoder.yudao.module.shop.vo.order.LogisticsResultVo;
import cn.iocoder.yudao.module.shop.vo.order.StoreDateRangeSqlPram;
import cn.iocoder.yudao.module.shop.vo.order.StoreOrderInfoOldVo;
import com.alipay.api.AlipayApiException;
import com.alipay.api.internal.util.AlipaySignature;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
@ -40,14 +56,16 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionTemplate;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -90,7 +108,15 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
private TransactionTemplate transactionTemplate;
@Autowired
private StoreOrderInfoService storeOrderInfoService;
private StrategySupport strategySupport;
@Autowired
private RechargeOrderMapper rechargeOrderMapper;
@Autowired
private RechargeOrderInfoMapper rechargeOrderInfoMapper;
@Autowired
private AliPayProperties aliPayProperties;
/**
* PC
@ -205,14 +231,14 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
public Long getTopDataUtil(Integer status, Integer userId) {
LambdaQueryWrapper<StoreOrder> lqw = new LambdaQueryWrapper<>();
orderUtil.statusApiByWhere(lqw, status);
lqw.eq(StoreOrder::getUid,userId);
lqw.eq(StoreOrder::getUid, userId);
return mapper.selectCount(lqw);
}
@Override
public List<StoreOrder> getOrderGroupByDate(String dateLimit, int lefTime) {
QueryWrapper<StoreOrder> queryWrapper = new QueryWrapper<>();
queryWrapper.select("sum(pay_price) as pay_price", "left(create_time, "+lefTime+") as orderId", "count(id) as id");
queryWrapper.select("sum(pay_price) as pay_price", "left(create_time, " + lefTime + ") as orderId", "count(id) as id");
if (StringUtils.isNotBlank(dateLimit)) {
DateLimitUtilVo dateLimitVo = DateUtils.getDateLimit(dateLimit);
queryWrapper.between("create_time", dateLimitVo.getStartTime(), dateLimitVo.getEndTime());
@ -421,20 +447,20 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
String dateStartD = dateRange.getStartTime();
String dateEndD = dateRange.getEndTime();
int days = DateUtils.daysBetween(
DateUtils.strToDate(dateStartD,Constants.DATE_FORMAT_DATE),
DateUtils.strToDate(dateEndD,Constants.DATE_FORMAT_DATE)
DateUtils.strToDate(dateStartD, Constants.DATE_FORMAT_DATE),
DateUtils.strToDate(dateEndD, Constants.DATE_FORMAT_DATE)
);
// 同时间区间的上一个时间起点
String perDateStart = DateUtils.addDay(
DateUtils.strToDate(dateStartD,Constants.DATE_FORMAT_DATE), -days, Constants.DATE_FORMAT_START);
DateUtils.strToDate(dateStartD, Constants.DATE_FORMAT_DATE), -days, Constants.DATE_FORMAT_START);
// 当前时间区间
String dateStart = DateUtils.addDay(
DateUtils.strToDate(dateStartD,Constants.DATE_FORMAT_DATE),0,Constants.DATE_FORMAT_START);
DateUtils.strToDate(dateStartD, Constants.DATE_FORMAT_DATE), 0, Constants.DATE_FORMAT_START);
String dateEnd = DateUtils.addDay(
DateUtils.strToDate(dateEndD,Constants.DATE_FORMAT_DATE),0,Constants.DATE_FORMAT_END);
DateUtils.strToDate(dateEndD, Constants.DATE_FORMAT_DATE), 0, Constants.DATE_FORMAT_END);
// 上一个时间段查询
List<StoreOrder> orderPerList = getOrderPayedByDateLimit(perDateStart,dateStart);
List<StoreOrder> orderPerList = getOrderPayedByDateLimit(perDateStart, dateStart);
// 当前时间段
List<StoreOrder> orderCurrentList = getOrderPayedByDateLimit(dateStart, dateEnd);
@ -443,23 +469,23 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
double perSumPrice = orderPerList.stream().mapToDouble(e -> e.getPayPrice().doubleValue()).sum();
double currentSumPrice = orderCurrentList.stream().mapToDouble(e -> e.getPayPrice().doubleValue()).sum();
response.setChart(mapper.getOrderStatisticsPriceDetail(new StoreDateRangeSqlPram(dateStart,dateEnd)));
response.setTime(BigDecimal.valueOf(currentSumPrice).setScale(2,BigDecimal.ROUND_HALF_UP));
response.setChart(mapper.getOrderStatisticsPriceDetail(new StoreDateRangeSqlPram(dateStart, dateEnd)));
response.setTime(BigDecimal.valueOf(currentSumPrice).setScale(2, BigDecimal.ROUND_HALF_UP));
// 当前营业额和上一个同比营业额增长区间
increasePrice = currentSumPrice - perSumPrice;
if (increasePrice <= 0) response.setGrowthRate(0);
else if (perSumPrice == 0) response.setGrowthRate((int) increasePrice * 100);
else response.setGrowthRate((int)((increasePrice * perSumPrice) * 100));
}else if (type ==2) {
response.setChart(mapper.getOrderStatisticsOrderCountDetail(new StoreDateRangeSqlPram(dateStart,dateEnd)));
else response.setGrowthRate((int) ((increasePrice * perSumPrice) * 100));
} else if (type == 2) {
response.setChart(mapper.getOrderStatisticsOrderCountDetail(new StoreDateRangeSqlPram(dateStart, dateEnd)));
response.setTime(BigDecimal.valueOf(orderCurrentList.size()));
increasePrice = orderCurrentList.size() - orderPerList.size();
if (increasePrice <= 0) response.setGrowthRate(0);
else if (orderPerList.size() == 0) response.setGrowthRate((int) increasePrice);
else response.setGrowthRate((int)((increasePrice / orderPerList.size()) * 100));
else response.setGrowthRate((int) ((increasePrice / orderPerList.size()) * 100));
}
response.setIncreaseTime(increasePrice+"");
response.setIncreaseTimeStatus(increasePrice >= 0 ? 1:2);
response.setIncreaseTime(increasePrice + "");
response.setIncreaseTimeStatus(increasePrice >= 0 ? 1 : 2);
return response;
}
@ -532,7 +558,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
lqw.set(StoreOrder::getPaid, true);
lqw.set(StoreOrder::getPayTime, DateUtils.nowDateTime());
lqw.eq(StoreOrder::getOrderId, orderNo);
lqw.eq(StoreOrder::getPaid,false);
lqw.eq(StoreOrder::getPaid, false);
return update(lqw);
}
@ -624,10 +650,10 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
throw new ServiceException("系统只支持一次改价");
}
// 修改价格和原来价格相同
if (existOrder.getPayPrice().compareTo(request.getPayPrice()) ==0) {
if (existOrder.getPayPrice().compareTo(request.getPayPrice()) == 0) {
throw new ServiceException(StrUtil.format("修改价格不能和原支付价格相同 原价 {} 修改价 {}", existOrder.getPayPrice(), request.getPayPrice()));
}
String oldPrice = existOrder.getPayPrice()+"";
String oldPrice = existOrder.getPayPrice() + "";
Boolean execute = transactionTemplate.execute(e -> {
// 修改订单价格
@ -640,7 +666,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
});
if (!execute) {
throw new ServiceException(Constants.RESULT_ORDER_EDIT_PRICE_SUCCESS
.replace("${orderNo}", existOrder.getOrderId()).replace("${price}", request.getPayPrice()+""));
.replace("${orderNo}", existOrder.getOrderId()).replace("${price}", request.getPayPrice() + ""));
}
// TODO 发送改价短信提醒
@ -1099,6 +1125,147 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
return null;
}
@Override
@Transactional
public InitOrderResponse memberTopUp(OrderContentRequest request, HttpServletRequest servletRequest) {
LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
Assert.notNull(loginUser, "登录失效,请重新登录!");
// 订单相关检查
orderCheck(request);
// 初始化订单
MemberUserRespDTO user = userService.getUser(loginUser.getId());
String code = generateBillNo("MEMBER");
RechargeOrderDO orderDO = initializeOrder(request, code, user);
// 获取支付策略
IPayStrategy payStrategy = strategySupport.getPayStrategy(request.getPayType());
return payStrategy.pay(orderDO, servletRequest, request.getOpenid());
}
@Override
public Object aliNotify(HttpServletRequest request, Map<String, String> params) {
boolean verifyResult = false;
try {
verifyResult = AlipaySignature.rsaCheckV1(params, aliPayProperties.getAlipayPublicKey(), "UTF-8", "RSA2");
} catch (AlipayApiException e) {
e.printStackTrace();
}
if (verifyResult) {
String orderId = params.get("out_trade_no");
RechargeOrderDO orderDO = rechargeOrderMapper.selectOne(Wrappers.<RechargeOrderDO>lambdaQuery().eq(RechargeOrderDO::getOrderId, orderId));
// 处理相关逻辑
}
return null;
}
@Override
public Object memberRefund(RefundRequest request, HttpServletRequest servletRequest) {
RechargeOrderDO orderDO = rechargeOrderMapper.selectById(request.getOrderId());
// 获取支付策略
IPayStrategy payStrategy = strategySupport.getPayStrategy(orderDO.getPayType());
payStrategy.refund(orderDO);
return null;
}
@Override
public Object refundNotify(HttpServletRequest request, Map<String, String> params1) {
// 解析支付宝回调参数
Map<String, String> params = new HashMap<>();
Map<String, String[]> requestParams = request.getParameterMap();
for (Map.Entry<String, String[]> entry : requestParams.entrySet()) {
String name = entry.getKey();
String[] values = entry.getValue();
StringBuilder sb = new StringBuilder();
for (String value : values) {
sb.append(value);
}
params.put(name, sb.toString());
}
// 验证签名
boolean isSignatureValid = false;
try {
isSignatureValid = AlipaySignature.rsaCheckV1(params, aliPayProperties.getAlipayPublicKey(), "UTF-8", "RSA2");
} catch (AlipayApiException e) {
e.printStackTrace();
}
if (isSignatureValid) {
// 验证通过,处理退款结果
String tradeStatus = params.get("trade_status");
if ("TRADE_SUCCESS".equals(tradeStatus)) {
// 退款成功逻辑
} else {
// 退款失败逻辑
}
return "success"; // 返回给支付宝表示接收成功
} else {
// 签名验证失败
return "failure";
}
}
private RechargeOrderDO initializeOrder(OrderContentRequest request, String code, MemberUserRespDTO user) {
RechargeOrderDO orderDO = new RechargeOrderDO();
List<OrderContentRequest.OrderInfo> orderInfos = request.getOrderInfos();
orderDO.setOrderId(code);
orderDO.setUid(user.getId().intValue());
orderDO.setRealName(user.getNickname());
orderDO.setUserPhone(StringUtils.isEmpty(request.getUserPhone()) ? user.getMobile() : request.getUserPhone());
orderDO.setConfirmPhone(StringUtils.isEmpty(request.getConfirmPhone()) ? user.getMobile() : request.getConfirmPhone());
orderDO.setTotalNum(orderInfos.size());
BigDecimal sum = new BigDecimal(orderInfos.stream().mapToDouble(OrderContentRequest.OrderInfo::getGearAmount).sum());
orderDO.setTotalPrice(sum);
orderDO.setPayPrice(sum);
orderDO.setPayTime(LocalDateTime.now());
orderDO.setPayType(request.getPayType());
orderDO.setMark("会员充值");
orderDO.setCost(sum);
orderDO.setProTotalPrice(sum);
orderDO.setBeforePayPrice(sum);
rechargeOrderMapper.insert(orderDO);
List<RechargeOrderInfoDO> infoDOS = new ArrayList<>();
orderInfos.forEach(info -> {
RechargeOrderInfoDO infoDO = new RechargeOrderInfoDO();
infoDO.setRechargeOrderId(orderDO.getId());
infoDO.setGiveIntegral(info.getGearId());
infoDO.setOrderNo(code);
infoDO.setProductName(info.getName());
infoDO.setPrice(new BigDecimal(info.getGearAmount()));
infoDO.setPayNum(1);
infoDO.setGiveIntegral(info.getGearAmount());
infoDOS.add(infoDO);
});
rechargeOrderInfoMapper.insertBatch(infoDOS);
return orderDO;
}
/**
*
*
* @param prefix
* @return
*/
public static String generateBillNo(String prefix) {
String idStr = IdWorker.getIdStr();
idStr = prefix + "_" + idStr;
return idStr;
}
private void orderCheck(OrderContentRequest request) {
Assert.isTrue(!CollectionUtils.isEmpty(request.getOrderInfos()), "订单信息不能为空!");
if (StringUtils.isNotBlank(request.getUserPhone()) && StringUtils.isNotBlank(request.getConfirmPhone())) {
Assert.isTrue(StringUtils.equals(request.getUserPhone(), request.getConfirmPhone()), "输入号码不一致!");
MemberUserRespDTO userByMobile = userService.getUserByMobile(request.getUserPhone());
// 初始化一个账号
if (Objects.isNull(userByMobile)) {
userService.saveMemberUser(request.getUserPhone());
}
}
}
private StoreOrder getInfoException(String orderNo) {
LambdaQueryWrapper<StoreOrder> lqw = Wrappers.lambdaQuery();
lqw.eq(StoreOrder::getOrderId, orderNo);
@ -1111,8 +1278,9 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
*
*
* @param dateLimit
* @param type
* @param type
* @return Integer
*/
private BigDecimal getAmount(String dateLimit, String type) {
@ -1136,8 +1304,9 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
*
*
* @param dateLimit
* @param status String
* @param status String
* @return Integer
*/
private Long getCount(String dateLimit, String status) {
@ -1153,8 +1322,9 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
*
*
* @param dateLimit
* @param status String
* @param status String
* @return Integer
*/
private Long getCount(String dateLimit, String status, Integer type) {
@ -1173,8 +1343,9 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
*
* @param orderNo
* @param price
*
* @param orderNo
* @param price
* @param oldPrice
*/
private Boolean orderEditPrice(String orderNo, BigDecimal price, BigDecimal oldPrice) {
@ -1189,17 +1360,20 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
*
*
* @return
*/
private List<StoreOrder> getOrderPayedByDateLimit(String startTime, String endTime) {
LambdaQueryWrapper<StoreOrder> lqw = Wrappers.lambdaQuery();
lqw.eq(StoreOrder::getIsDel, false).eq(StoreOrder::getPaid, true).eq(StoreOrder::getRefundStatus,0)
lqw.eq(StoreOrder::getIsDel, false).eq(StoreOrder::getPaid, true).eq(StoreOrder::getRefundStatus, 0)
.between(StoreOrder::getCreateTime, startTime, endTime);
return mapper.selectList(lqw);
}
/**
* @param request StoreOrderSendRequest
/**
*
*
* @param request StoreOrderSendRequest
* @param storeOrder StoreOrder
*/
private void express(StoreOrderSendRequest request, StoreOrder storeOrder) {
@ -1259,19 +1433,22 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
*
*
* @param storeOrder
*/
private void sendGoodsNotify(StoreOrder storeOrder) {
MemberUserRespDTO user = userService.getUser(storeOrder.getUid());
//TODO 发送发货短信提醒
//TODO 发送发货短信提醒
// 发送消息通知
// pushMessageOrder(storeOrder, user, notification);
}
/**
* @param request StoreOrderSendRequest
/**
*
*
* @param request StoreOrderSendRequest
* @param storeOrder StoreOrder
* @author Mr.Zhang
* @since 2020-06-10
@ -1315,8 +1492,10 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
// pushMessageDeliveryOrder(storeOrder, user, request, productNameList);
}
/**
* @param request StoreOrderSendRequest
/**
*
*
* @param request StoreOrderSendRequest
* @param storeOrder StoreOrder
* @author Mr.Zhang
* @since 2020-06-10
@ -1337,11 +1516,12 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
*
*
* @param orderList List<StoreOrder>
* @return List<StoreOrderItemResponse>
*/
private List<StoreOrderDetailResponse> formatOrder1(List<StoreOrder> orderList) {
List<StoreOrderDetailResponse> detailResponseList = new ArrayList<>();
List<StoreOrderDetailResponse> detailResponseList = new ArrayList<>();
if (CollUtil.isEmpty(orderList)) {
return detailResponseList;
}
@ -1378,8 +1558,9 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
* requestwhere
*
* @param queryWrapper QueryWrapper<StoreOrder>
* @param request StoreOrderSearchRequest
* @param request StoreOrderSearchRequest
*/
private void getRequestTimeWhere(QueryWrapper<StoreOrder> queryWrapper, StoreOrderSearchRequest request) {
if (StringUtils.isNotBlank(request.getDateLimit())) {
@ -1390,6 +1571,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
*
*
* @param storeOrder StoreOrder
* @author Mr.Zhang
* @since 2020-06-12
@ -1505,8 +1687,9 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
* where
*
* @param queryWrapper QueryWrapper<StoreOrder>
* @param status String
* @param status String
*/
private void getStatusWhereNew(QueryWrapper<StoreOrder> queryWrapper, String status) {
if (StrUtil.isBlank(status)) {
@ -1554,7 +1737,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
break;
case Constants.ORDER_STATUS_REFUNDING: //退款中
queryWrapper.eq("paid", 1);
queryWrapper.in("refund_status", 1,3);
queryWrapper.in("refund_status", 1, 3);
queryWrapper.eq("is_del", 0);
break;
case Constants.ORDER_STATUS_REFUNDED: //已退款
@ -1575,6 +1758,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
*
*
* @param payType String
*/
private String getPayType(String payType) {
@ -1592,6 +1776,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
*
*
* @param storeOrder
* @return String
*/
@ -1610,8 +1795,9 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
/**
* where
*
* @param queryWrapper QueryWrapper<StoreOrder>
* @param status String
* @param status String
*/
private void getStatusWhere(QueryWrapper<StoreOrder> queryWrapper, String status) {
if (StrUtil.isBlank(status)) {
@ -1657,7 +1843,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
break;
case Constants.ORDER_STATUS_REFUNDING: //退款中
queryWrapper.eq("paid", 1);
queryWrapper.in("refund_status", 1,3);
queryWrapper.in("refund_status", 1, 3);
queryWrapper.eq("is_del", 0);
break;
case Constants.ORDER_STATUS_REFUNDED: //已退款
@ -1677,6 +1863,5 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
}
}

View File

@ -0,0 +1,50 @@
package cn.iocoder.yudao.module.shop.support;
import cn.iocoder.yudao.module.shop.support.pay.AliPayStrategy;
import cn.iocoder.yudao.module.shop.support.pay.IPayStrategy;
import cn.iocoder.yudao.module.shop.support.pay.PayConfigConstant;
import cn.iocoder.yudao.module.shop.support.pay.WxPayStrategy;
import org.springframework.stereotype.Component;
import java.util.HashMap;
/**
* @Title:WxPayStrategy
* @Description:
* @author: tangqian
* @date: 2023/5/15 21:53
* @version: V1.0.0
*/
@Component
public class StrategySupport {
//支付策略
private HashMap<String, IPayStrategy> payMap = new HashMap<>();
public StrategySupport(WxPayStrategy wxPayStrategy,
AliPayStrategy aliPayStrategy
) {
//支付策略
payMap.put(PayConfigConstant.PAY_TYPE_ALIPAY,aliPayStrategy);
payMap.put(PayConfigConstant.PAY_TYPE_WXPAY,wxPayStrategy);
}
/**
*
* @param payType
* @return
*/
public IPayStrategy getPayStrategy(String payType){
if (PayConfigConstant.PAY_TYPE_LIST.contains(payType)){
return payMap.get(payType);
}
return null;
}
}

View File

@ -0,0 +1,87 @@
package cn.iocoder.yudao.module.shop.support.pay;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.pay.config.AliPayConfig;
import cn.iocoder.yudao.framework.pay.properties.AliPayProperties;
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
import cn.iocoder.yudao.module.shop.response.member.InitOrderResponse;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayApiException;
import com.alipay.api.AlipayClient;
import com.alipay.api.request.AlipayTradeRefundRequest;
import com.alipay.api.request.AlipayTradeWapPayRequest;
import com.alipay.api.response.AlipayTradeRefundResponse;
import com.alipay.api.response.AlipayTradeWapPayResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletRequest;
/**
* @Title:AliPayStrategy
* @Description:
* @author: tangqian
* @date: 2023/5/15 21:52
* @version: V1.0.0
*/
@Component
@Slf4j
public class AliPayStrategy implements IPayStrategy {
@Autowired
private AliPayProperties aliPayProperties;
@Autowired
private AliPayConfig aliPayConfig;
@Override
public InitOrderResponse pay(RechargeOrderDO orderDO, HttpServletRequest servletRequest, String openId) {
AlipayClient alipayClient = aliPayConfig.alipayClient();
Assert.notNull(alipayClient, "获取支付宝支付配置失败!");
AlipayTradeWapPayRequest request = new AlipayTradeWapPayRequest();
//异步接收地址仅支持http/https公网可访问
request.setNotifyUrl(aliPayProperties.getNotifyUrl());
//同步跳转地址仅支持http/https
request.setReturnUrl("");
/******必传参数******/
JSONObject bizContent = new JSONObject();
//商户订单号,商家自定义,保持唯一性
bizContent.put("out_trade_no", orderDO.getOrderId());
//支付金额最小值0.01元
bizContent.put("total_amount", orderDO.getPayPrice());
//订单标题,不可使用特殊符号
bizContent.put("subject", "会员充值");
bizContent.put("product_code", "FAST_INSTANT_TRADE_PAY");
request.setBizContent(bizContent.toString());
AlipayTradeWapPayResponse response = null;
try {
response = alipayClient.pageExecute(request);
} catch (AlipayApiException e) {
e.printStackTrace();
}
if (response.isSuccess()) {
return new InitOrderResponse();
}
return null;
}
@Override
public void refund(RechargeOrderDO orderDO) {
AlipayClient alipayClient = aliPayConfig.alipayClient();;
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
JSONObject bizContent = new JSONObject();
bizContent.put("trade_no", orderDO.getPaySerialNumber());
bizContent.put("refund_amount", orderDO.getPayPrice());
bizContent.put("out_request_no", orderDO.getOrderId());
request.setBizContent(bizContent.toString());
AlipayTradeRefundResponse response = null;
try {
response = alipayClient.execute(request);
} catch (AlipayApiException e) {
e.printStackTrace();
}
log.info("退款回调[{}]", JSONUtil.toJsonPrettyStr(response));
}
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.shop.support.pay;
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
import cn.iocoder.yudao.module.shop.response.member.InitOrderResponse;
import javax.servlet.http.HttpServletRequest;
/**
* @Title:IPayStrategy
* @Description:
* @author: tangqian
* @date: 2023/5/15 21:51
* @version: V1.0.0
*/
public interface IPayStrategy {
InitOrderResponse pay(RechargeOrderDO orderDO, HttpServletRequest servletRequest,String openId);
void refund(RechargeOrderDO orderDO);
}

View File

@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.shop.support.pay;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Title:PayConfigConstant
* @Description: TODO
* @author: tangqian
* @date: 2023/5/15 21:54
* @version: V1.0.0
*/
public interface PayConfigConstant {
List<String> PAY_TYPE_LIST = Arrays.asList("ALIPAY", "WXPAY");
String PAY_TYPE_ALIPAY = "ALIPAY";
String PAY_TYPE_WXPAY = "WXPAY";
Map<String, String> PAY_NAMES_MAP = new HashMap() {
{
this.put("ALIPAY", "支付宝");
this.put("WXPAY", "微信");
}
};
String PAY_TYPE_ALIPAY_FIRST = "ALIPAY";
String PAY_TYPE_WXPAY_FIRST = "WXPAY";
Map<String, String> PAY_NAMES_MAP_FIRST = new HashMap() {
{
this.put("ALIPAY", "支付宝");
this.put("WXPAY", "微信");
}
};
}

View File

@ -0,0 +1,83 @@
package cn.iocoder.yudao.module.shop.support.pay;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.servlet.ServletUtils;
import cn.iocoder.yudao.framework.pay.config.WxPayOneAutoConfiguration;
import cn.iocoder.yudao.framework.pay.properties.WxPayProperties;
import cn.iocoder.yudao.module.shop.dal.dataobject.recharge.RechargeOrderDO;
import cn.iocoder.yudao.module.shop.response.member.InitOrderResponse;
import com.github.binarywang.wxpay.bean.request.WxPayRefundV3Request;
import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderV3Request;
import com.github.binarywang.wxpay.bean.result.WxPayRefundV3Result;
import com.github.binarywang.wxpay.bean.result.WxPayUnifiedOrderV3Result;
import com.github.binarywang.wxpay.bean.result.enums.TradeTypeEnum;
import com.github.binarywang.wxpay.service.WxPayService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
/**
* @Title:WxPayStrategy
* @Description: TODO
* @author: tangqian
* @date: 2023/5/15 21:53
* @version: V1.0.0
*/
@Component
@Slf4j
public class WxPayStrategy implements IPayStrategy{
@Autowired
private WxPayOneAutoConfiguration wxPayOneAutoConfiguration;
@Autowired
private WxPayProperties payProperties;
@Override
public InitOrderResponse pay(RechargeOrderDO orderDO, HttpServletRequest servletRequest,String openid) {
InitOrderResponse response = new InitOrderResponse();
WxPayService wxPayService = wxPayOneAutoConfiguration.wxPayOneService();
Assert.notNull(wxPayService, "获取微信支付配置失败!");
WxPayUnifiedOrderV3Request wxPayRequest = new WxPayUnifiedOrderV3Request();
int sum = orderDO.getPayPrice().multiply(new BigDecimal("100")).intValue();
wxPayRequest.setAmount(new WxPayUnifiedOrderV3Request.Amount().setTotal(sum));
wxPayRequest.setDescription("会员充值");
wxPayRequest.setOutTradeNo(orderDO.getOrderId());
wxPayRequest.setNotifyUrl(payProperties.getNotifyUrl());
wxPayRequest.setPayer(new WxPayUnifiedOrderV3Request.Payer().setOpenid(openid));
wxPayRequest.setSceneInfo(new WxPayUnifiedOrderV3Request.SceneInfo().setPayerClientIp(ServletUtils.getClientIP(servletRequest)));
wxPayRequest.setAppid(payProperties.getAppId());
wxPayRequest.setMchid(payProperties.getMchId());
try {
WxPayUnifiedOrderV3Result wxPayUnifiedOrderV3Result = wxPayService.unifiedOrderV3(TradeTypeEnum.JSAPI, wxPayRequest);
BeanUtils.copyProperties(wxPayUnifiedOrderV3Result, response);
} catch (Exception e) {
log.error(e.getMessage());
}
return response;
}
@Override
public void refund(RechargeOrderDO orderDO) {
WxPayRefundV3Request wxPayRefundV3Request = new WxPayRefundV3Request();
wxPayRefundV3Request.setOutTradeNo(orderDO.getOrderId());
wxPayRefundV3Request.setOutRefundNo(orderDO.getPaySerialNumber());
wxPayRefundV3Request.setTransactionId(orderDO.getOrderId());
wxPayRefundV3Request.setReason("商品已售完");
wxPayRefundV3Request.setNotifyUrl(payProperties.getRefundNotifyUrl());
int sum = orderDO.getPayPrice().multiply(new BigDecimal("100")).intValue();
wxPayRefundV3Request.setAmount(new WxPayRefundV3Request.Amount().setTotal(sum).setRefund(sum).setCurrency("CNY"));
try {
WxPayService wxPayService = wxPayOneAutoConfiguration.wxPayOneService();
WxPayRefundV3Result wxPayRefundV3Result = wxPayService.refundV3(wxPayRefundV3Request);
log.info("退款回调[{}]", JSONUtil.toJsonPrettyStr(wxPayRefundV3Request));
}catch (Exception e){
log.error(e.getMessage(),e);
}
}
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.member.api.user;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserBillDTO;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import java.util.Collection;
@ -76,4 +77,7 @@ public interface MemberUserApi {
Long getUserId();
MemberUserRespDTO getInfo();
void saveMemberUser(String phone);
}

View File

@ -92,6 +92,11 @@ public class MemberUserApiImpl implements MemberUserApi {
return UserConvert.INSTANCE.convert2(userService.getUser(getUserId()));
}
@Override
public void saveMemberUser(String phone) {
userService.saveMemberUser(phone);
}
/**
*
*

View File

@ -116,4 +116,5 @@ public interface MemberUserService {
*/
int updateById(MemberUserDO member);
void saveMemberUser(String phone);
}

View File

@ -170,6 +170,17 @@ public class MemberUserServiceImpl implements MemberUserService {
return memberUserMapper.updateById(member);
}
@Override
public void saveMemberUser(String phone) {
MemberUserDO memberUserDO = new MemberUserDO();
memberUserDO.setMobile(phone);
memberUserDO.setNickname("初始化人员");
memberUserDO.setAvatar("");
memberUserDO.setStatus(CommonStatusEnum.ENABLE.getStatus());
memberUserDO.setPassword(passwordEncoder.encode(phone.substring(phone.length() - 6)));
memberUserMapper.insert(memberUserDO);
}
/**
*
*

View File

@ -202,7 +202,14 @@ wx:
notify-url: http://yuxy.perrymake.com/app-api/pay/wxpay/pay_notify
refund-notify-url: http://yuxy.perrymake.com/app-api/pay/wxpay/refund_notify
--- #################### 芋道相关配置 ####################
ali:
pay:
one:
appId: 2021003194654312
merchantPrivateKey: MIIEwAIBADANBgkqhkiG9w0BAQEFAASCBKowggSmAgEAAoIBAQC+m33MrrmGiSBCBTQMkBH9AN7ZKi/ECmgpjIbVIzAbUThqfiKvuWe8haVq0/F5nETZVYKb3kqqcdt5NkUbGkCrCNCOPvQ2FI8VWOalXGSQNA6ItA644m1dv84Khs5K3Tpu6RgcrL5uqmfNzid7YpLlGeSxMq8uqu/adZnEbm+coJAvEH423pnMjsdkI93FUibaDkDQ06V7Z0Su6l4ZoVzLavvPeP/u8NCvelyf5h+BY159rU8XjCaSYYF/2u4DzDV1LqQcSC+fQg/aVd+QcpnhEF715fbNmN3TLuh1ysnfUSFdVMsdWDrOsgriJ7g0D32uWwhR4Brz3dAFs0KdWTmFAgMBAAECggEBAKdX2JCVbijhx0JvUw0ch856ryw2T41sHZss10vVAu1Y15EXgNiKjLsFEv/BaCX+vquY2XyDI0aVg7zdmrp6x//hU0kvmDTKw/xX+td/UIMSURhQDQThNmeyd/Dh/cfYhu7NEvBJ8T8zuMMFlcBMAO/HVfMErqzoQoCn8wJ0euUkxU+0yWjddC5QHdhPwPgfpmPvL/DCPfSCudFy80ix7CP3YID7RwgCy5niZg3e7aDK6DgYTmk2DmoC7B8ES/7Crvf04fH4XzGrSCzL9aGKOWql6dZisbDioRdm67DEWUSjQGTggEZ+eCd9Tr0gnndVWegG5HYJhSpB/JoLsc5J/dkCgYEA8Tumn60cfJU440LWaJ+40gJWcNrOlvpPEX69DRXKG3PlTAk62sSvVBos2nstqNjhHPQDG7rFerQhmSPeGyezVcwPCbWLvLC61vpbfau+RyWvMvm33A1hgP+zXlt9C3etb9w6LUfuqh0Lzi61K3ZNKQGo4ERxgGoMlNZWO0X/mBMCgYEAykZ9PH1b3be9M55BsnCnnrzENV5Bbfj7BToRleiUWA0f0Juurxy9ZACr8rU1oa7+UF32TpXAOL1Peri5vhYF7hdSnlSk5f9lyEzQijbtRytBC9Mexagb4BZWMlars9jMhhsdWiXA2O6Pz9ykLacGOr0DHM8/6HaVJRlPydXHywcCgYEAzwIgT1/vVR18jtD5SxjdMiJdaUTrCXZNSbcXplXvdLV0rFYzUi58QlCf8vDHUuCh9QWUcURKWKyhNFgqLeVYqKSOtwc6nbaO7xIyVtp9U3KMMNNIKqa06E0E8FDUMnYFuDslFVxn+0Unr0w3nc9MEYdiEunI+KiImWSA5SaBWk8CgYEAlbwshRS/ZpfXZVinhXJDgwx1qpQFl2USXUIpNnGfLrc4b/JvE44Q3PBqWRavhurFs7R62p2cV+Q767rHNOGUrjVxoWdDUkcHj4jdbxNN/rsUQa6dPvA9AltGn6jtHgtFC5kS12LPKUcgCl1o46qav+yfWzpIMstliLr+B4lLhw0CgYEA7Bpm0s2uoyC1XtYCqeWzbjODciq/hgIpmBjnP4Xs0ELB0VE95m9CVQk47dSngRqbkrEO2G2zdMTYj5Mr5bm5AXQfUpwMv89fxCxSXq1Andqe1/UphigltW/PXOfvpD1JcHNfalEcTOTdzENVYH4lN3HAoPobj04gCsFZFcqWfps=
alipayPublicKey: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAw21teFhHze8ltibg/mBE0Lo1gTvcRUszQpsiTLWLoYvLxfaEVD+5bkpTYrVFczLNqOw93MJxwF0Pj62T3BZU6IXPdXtkKhcflKiZxleSIaTxPFml8mQ8dfdcT25BPidRaeztxv/FCL+0MUTMVh29Ffm9/DHqkjozs4o/Vcf/BoDssw9L7JQffwo/h69B0O688E+s+SivqvXGbiRdARzPrvuQjUMPwUf9vQZ4/ZgGNlwsEhnF90ESCuBZDm8atOoZlqYSNw6g+TZQH5CVS0WCR41TQoW+R8OsX1cv3ERvJXvh/50dEhl8b4CN3nvdaSYcw93o/nkkTZkdZ7BdcNuW2wIDAQAB
gatewayUrl: https://openapi.alipay.com/gateway.do
notify-url: http://yuxy.perrymake.com/app-api/pay/ali/pay_notify
# 芋道配置项,设置当前项目所有自定义的配置
yudao:
captcha: