增加支付商品
parent
0bcb6a611d
commit
336cd37581
|
@ -55,7 +55,7 @@ public class AppletPayController {
|
|||
// 构建service
|
||||
log.info("payDto===================>{}",payDto);
|
||||
JsapiServiceExtension service = createService();
|
||||
OrderPayInfo orderPayInfo = orderPayInfoService.createOrderPayInfo(payDto.getMoney(),payDto.getUserId(), payDto.getDescription(), payDto.getOutTradeNo(), "applet");
|
||||
OrderPayInfo orderPayInfo = orderPayInfoService.createOrderPayInfo(payDto.getMoney(),payDto.getUserId(), payDto.getDescription(), payDto.getTradeType(), payDto.getOutTradeNo(),"applet");
|
||||
|
||||
// 请求下单参数
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
|
|
|
@ -54,7 +54,7 @@ public class H5PayController {
|
|||
// 构建service
|
||||
H5Service service = createService();
|
||||
//在order_pay_info里新增一条数据
|
||||
OrderPayInfo orderPayInfo = orderPayInfoService.createOrderPayInfo(payVo.getMoney(),payVo.getUserId(),payVo.getDescription(), payVo.getOutTradeNo(), "h5");
|
||||
OrderPayInfo orderPayInfo = orderPayInfoService.createOrderPayInfo(payVo.getMoney(),payVo.getUserId(),payVo.getDescription(), payVo.getTradeType(), payVo.getOutTradeNo(), "h5");
|
||||
|
||||
// 请求下单参数
|
||||
PrepayRequest request = new PrepayRequest();
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
package com.jwl.driver.server.controller;
|
||||
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jwl.driver.server.config.WechatPayConfig;
|
||||
import com.jwl.driver.server.entity.OrderPayInfo;
|
||||
import com.jwl.driver.server.enums.PurchaseProductTypeEnum;
|
||||
import com.jwl.driver.server.response.BaseResponse;
|
||||
import com.jwl.driver.server.service.IOrderPayInfoService;
|
||||
import com.jwl.driver.server.service.ITdMemberService;
|
||||
|
@ -92,17 +95,19 @@ public class PayNoticeLogController {
|
|||
//取业务id
|
||||
String outTradeNo = decryptObject.getString("out_trade_no");
|
||||
JSONObject jsonResponse = new JSONObject();
|
||||
OrderPayInfo payInfo = payInfoService.getById(Long.parseLong(outTradeNo));
|
||||
if(trade_state.equals("SUCCESS")) {
|
||||
//各种业务逻辑
|
||||
//1.订单详情表里修改数据
|
||||
payInfoService.payNotice(Long.parseLong(outTradeNo),Boolean.FALSE);
|
||||
//2.冲会员
|
||||
userMemberService.purchaseMember(Long.parseLong(outTradeNo));
|
||||
|
||||
payInfoService.payNotice(payInfo,Boolean.TRUE);
|
||||
//2.如果购买商品是会员则冲会员,其余的则不做操作
|
||||
if (StrUtil.equals(payInfo.getPurchaseProductType(), PurchaseProductTypeEnum.MEMBER.getValue())){
|
||||
userMemberService.purchaseMember(payInfo);
|
||||
}
|
||||
}else{
|
||||
//还是各种业务逻辑
|
||||
//1.订单详情表里修改数据
|
||||
payInfoService.payNotice(Long.parseLong(outTradeNo),Boolean.FALSE);
|
||||
payInfoService.payNotice(payInfo,Boolean.FALSE);
|
||||
}
|
||||
jsonResponse.put("code", "SUCCESS");
|
||||
jsonResponse.put("message", "成功");
|
||||
|
|
|
@ -41,21 +41,31 @@ public class TdSysConfigListController {
|
|||
@ApiOperation("根据configKey和carTypeId查询系统配置列表")
|
||||
@GetMapping("/querySysConfigList")
|
||||
public BaseResponse querySysConfigList(@RequestParam("configKey") String configKey, @RequestParam("carTypeId") Integer carTypeId) {
|
||||
log.info("request to querySysConfigList :{}", configKey);
|
||||
log.info("request to querySysConfigList :{}, carTypeId:{}", configKey,carTypeId);
|
||||
List<TdSysConfigList> resultList = configListService.querySysConfigList(configKey, carTypeId);
|
||||
return BaseResponse.success(resultList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过多个配置key 和 carTypeId 查询多个配置列表
|
||||
* 通过多个configKey(以逗号分隔) 和 carTypeId 查询多个配置列表
|
||||
*/
|
||||
@ApiOperation("通过多个配置key 和 carTypeId 查询多个配置列表")
|
||||
@ApiOperation("通过多个configKey(以逗号分隔) 和 carTypeId 查询多个配置列表")
|
||||
@GetMapping("/querySysConfigMap")
|
||||
public BaseResponse querySysConfigMap(@RequestParam("configKeys") String configKeys, @RequestParam("carTypeId") Integer carTypeId) {
|
||||
log.info("request to querySysConfigList :{}", configKeys);
|
||||
log.info("request to querySysConfigMap :{}, carTypeId:{}", configKeys,carTypeId);
|
||||
Map<String, Map<String, String>> map = configListService.querySysConfigMap(Arrays.asList(configKeys.split(",")), carTypeId);
|
||||
return BaseResponse.success(map);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据configKey和carTypeId查询系统配置列表数量
|
||||
*/
|
||||
@ApiOperation("根据configKey和carTypeId查询系统配置列表数量")
|
||||
@GetMapping("/querySysConfigListNum")
|
||||
public BaseResponse querySysConfigListNum(@RequestParam("configKey") String configKey, @RequestParam("carTypeId") Integer carTypeId) {
|
||||
log.info("request to querySysConfigListNum :{}, carTypeId:{}", configKey,carTypeId);
|
||||
Integer listNum = configListService.querySysConfigListNum(configKey, carTypeId);
|
||||
return BaseResponse.success(listNum);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,10 +31,16 @@ public class OrderPayInfo implements Serializable {
|
|||
private Long payId;
|
||||
|
||||
/**
|
||||
* 会员标识
|
||||
* 购买的商品类型:1.购买会员,2.证件照上传,3.查询体检信息
|
||||
*/
|
||||
@TableField("MEMBER_ID")
|
||||
private Integer memberId;
|
||||
@TableField("PURCHASE_PRODUCT_TYPE")
|
||||
private String purchaseProductType;
|
||||
|
||||
/**
|
||||
* 购买商品主键标识
|
||||
*/
|
||||
@TableField("PURCHASE_PRODUCT_ID")
|
||||
private String purchaseProductId;
|
||||
|
||||
/**
|
||||
* 支付金额,单位元
|
||||
|
|
|
@ -0,0 +1,49 @@
|
|||
package com.jwl.driver.server.enums;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author 曹林
|
||||
* @description 购买产品类型
|
||||
* @create 2023/9/17 17:19
|
||||
*/
|
||||
public enum PurchaseProductTypeEnum {
|
||||
MEMBER("1", "会员"),
|
||||
|
||||
UPLOAD_PHOTO_ID ("2", "上传证件照"),
|
||||
|
||||
PHYSICAL_EXAMINATION_INFORMATION("3", "体检信息");
|
||||
|
||||
private String value;
|
||||
private String desc;
|
||||
public static final Map<String, PurchaseProductTypeEnum> valueMap = new HashMap();
|
||||
|
||||
public static PurchaseProductTypeEnum fromValue(String value) {
|
||||
return (PurchaseProductTypeEnum)valueMap.get(value);
|
||||
}
|
||||
|
||||
private PurchaseProductTypeEnum(String value, String name) {
|
||||
this.value = value;
|
||||
this.desc = name;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
static {
|
||||
PurchaseProductTypeEnum[] var0 = values();
|
||||
int var1 = var0.length;
|
||||
|
||||
for(int var2 = 0; var2 < var1; ++var2) {
|
||||
PurchaseProductTypeEnum value = var0[var2];
|
||||
valueMap.put(value.getValue(), value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -21,16 +21,17 @@ public interface IOrderPayInfoService extends IService<OrderPayInfo> {
|
|||
* @param money
|
||||
* @param userIdStr
|
||||
* @param description
|
||||
* @param tradeType
|
||||
* @param outTradeNo
|
||||
* @param payType
|
||||
* @return
|
||||
*/
|
||||
OrderPayInfo createOrderPayInfo(BigDecimal money,String userIdStr,String description,String outTradeNo,String payType);
|
||||
OrderPayInfo createOrderPayInfo(BigDecimal money,String userIdStr,String description,String tradeType,String outTradeNo,String payType);
|
||||
|
||||
/**
|
||||
* 支付结果
|
||||
* @param payId
|
||||
* @param payInfo
|
||||
* @param payResult
|
||||
*/
|
||||
Boolean payNotice(Long payId, Boolean payResult);
|
||||
Boolean payNotice( OrderPayInfo payInfo, Boolean payResult);
|
||||
}
|
||||
|
|
|
@ -25,10 +25,18 @@ public interface ITdSysConfigListService extends IService<TdSysConfigList> {
|
|||
List<TdSysConfigList> querySysConfigList(String configKey, Integer carTypeId);
|
||||
|
||||
/**
|
||||
* 通过多个配置key 和 carTypeId 查询多个配置列表
|
||||
* 通过多个configKey 和 carTypeId 查询多个配置列表
|
||||
* @param configKeyList
|
||||
* @param carTypeId
|
||||
* @return
|
||||
*/
|
||||
Map<String, Map<String, String>> querySysConfigMap(List<String> configKeyList, Integer carTypeId);
|
||||
|
||||
/**
|
||||
* 根据configKey和carTypeId查询系统配置列表数量
|
||||
* @param configKey
|
||||
* @param carTypeId
|
||||
* @return
|
||||
*/
|
||||
Integer querySysConfigListNum(String configKey, Integer carTypeId);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.jwl.driver.server.service;
|
||||
|
||||
import com.jwl.driver.server.entity.OrderPayInfo;
|
||||
import com.jwl.driver.server.entity.TdSysUserMember;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
|
@ -15,8 +16,8 @@ public interface ITdSysUserMemberService extends IService<TdSysUserMember> {
|
|||
|
||||
/**
|
||||
* 慧眼充值
|
||||
* @param payId
|
||||
* @param payInfo
|
||||
* @return
|
||||
*/
|
||||
Boolean purchaseMember(Long payId);
|
||||
Boolean purchaseMember(OrderPayInfo payInfo);
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class OrderPayInfoServiceImpl extends ServiceImpl<OrderPayInfoMapper, Ord
|
|||
private Snowflake snowflake;
|
||||
|
||||
@Override
|
||||
public OrderPayInfo createOrderPayInfo(BigDecimal money,String userIdStr,String description,String outTradeNo,String payType) {
|
||||
public OrderPayInfo createOrderPayInfo(BigDecimal money,String userIdStr,String description,String tradeType,String outTradeNo,String payType) {
|
||||
Long userId = StrUtil.isNotBlank(userIdStr) ? Long.parseLong(userIdStr) : SecurityUtil.getUserId();
|
||||
TdSysUser user = userService.getById(userId);
|
||||
if (Objects.isNull(user)) {
|
||||
|
@ -60,7 +60,8 @@ public class OrderPayInfoServiceImpl extends ServiceImpl<OrderPayInfoMapper, Ord
|
|||
}
|
||||
OrderPayInfo orderPayInfo = new OrderPayInfo()
|
||||
.setPayId(snowflake.nextId())
|
||||
.setMemberId(Integer.parseInt(outTradeNo))
|
||||
.setPurchaseProductType(tradeType)
|
||||
.setPurchaseProductId(outTradeNo)
|
||||
.setMoney(money)
|
||||
.setPaymentType(Constants.WECHAT_PAY)
|
||||
.setPayType(payType)
|
||||
|
@ -77,16 +78,15 @@ public class OrderPayInfoServiceImpl extends ServiceImpl<OrderPayInfoMapper, Ord
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean payNotice(Long payId, Boolean payResult) {
|
||||
log.info("支付回调信息===============> payId{} , payResult{}",payId,payResult);
|
||||
OrderPayInfo orderPayInfo = this.getById(payId);
|
||||
if (Objects.isNull(orderPayInfo)){
|
||||
public Boolean payNotice( OrderPayInfo payInfo, Boolean payResult) {
|
||||
log.info("支付回调信息===============> payInfo{} , payResult{}",payInfo,payResult);
|
||||
if (Objects.isNull(payInfo)){
|
||||
throw new BusinessException("订单信息不存在");
|
||||
}
|
||||
orderPayInfo.setPayStatus(payResult?PayStatus.SUCCESS.getValue() : PayStatus.FAIL.getValue())
|
||||
payInfo.setPayStatus(payResult?PayStatus.SUCCESS.getValue() : PayStatus.FAIL.getValue())
|
||||
.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
this.updateById(orderPayInfo);
|
||||
this.updateById(payInfo);
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,4 +86,10 @@ public class TdSysConfigListServiceImpl extends ServiceImpl<TdSysConfigListMappe
|
|||
}
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer querySysConfigListNum(String configKey, Integer carTypeId) {
|
||||
List<TdSysConfigList> configLists = querySysConfigList(configKey, carTypeId);
|
||||
return CollectionUtil.isEmpty(configLists) ? 0 : configLists.size();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,15 +43,14 @@ public class TdSysUserMemberServiceImpl extends ServiceImpl<TdSysUserMemberMappe
|
|||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean purchaseMember(Long payId) {
|
||||
public Boolean purchaseMember(OrderPayInfo payInfo) {
|
||||
final LocalDateTime nowTime = LocalDateTime.now();
|
||||
|
||||
OrderPayInfo payInfo = payInfoService.getById(payId);
|
||||
if (Objects.isNull(payInfo)){
|
||||
throw new BusinessException("订单信息不存在");
|
||||
}
|
||||
final Long userId = payInfo.getUserId();
|
||||
final Integer memberId = payInfo.getMemberId();
|
||||
final Integer memberId = Integer.parseInt(payInfo.getPurchaseProductId());
|
||||
// 查询会员 不管有效无效
|
||||
TdMember member = memberService.getById(memberId);
|
||||
if (Objects.isNull(member)){
|
||||
|
|
|
@ -22,6 +22,9 @@ public class AppletPayVo {
|
|||
@ApiModelProperty("支付描述")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty("商户系统的订单类型")
|
||||
private String tradeType;
|
||||
|
||||
@ApiModelProperty("商户系统的订单号")
|
||||
private String outTradeNo;
|
||||
|
||||
|
|
|
@ -18,6 +18,9 @@ public class H5PayVo {
|
|||
@ApiModelProperty("支付描述")
|
||||
private String description;
|
||||
|
||||
@ApiModelProperty("商户系统的订单类型")
|
||||
private String tradeType;
|
||||
|
||||
@ApiModelProperty("商户系统的订单号")
|
||||
private String outTradeNo;
|
||||
|
||||
|
|
|
@ -1,11 +1,17 @@
|
|||
spring:
|
||||
# redis 配置
|
||||
redis:
|
||||
host: 118.31.23.45
|
||||
port: 6973
|
||||
# 测试redis
|
||||
# host: 118.31.23.45
|
||||
# port: 6973
|
||||
# database: 8
|
||||
# timeout: 5000
|
||||
# password: c12&%3s7l=
|
||||
# 生产redis
|
||||
host: 114.55.169.15
|
||||
port: 6379
|
||||
database: 8
|
||||
timeout: 5000
|
||||
password: c12&%3s7l=
|
||||
|
||||
# 数据库 配置
|
||||
datasource:
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.jwl.driver.server;
|
||||
|
||||
import com.jwl.driver.server.config.WechatPayConfig;
|
||||
import com.jwl.driver.server.entity.OrderPayInfo;
|
||||
import com.jwl.driver.server.service.IOrderPayInfoService;
|
||||
import com.jwl.driver.server.service.ITdSysUserMemberService;
|
||||
import com.jwl.driver.server.util.InputStreamUtil;
|
||||
|
@ -56,17 +57,18 @@ public class WechatPayTest {
|
|||
void purchaseMember(){
|
||||
String trade_state = "SUCCESS";
|
||||
String outTradeNo = "1694594904308846592";
|
||||
OrderPayInfo payInfo = payInfoService.getById(Long.parseLong(outTradeNo));
|
||||
if(trade_state.equals("SUCCESS")) {
|
||||
//各种业务逻辑
|
||||
//1.订单详情表里修改数据
|
||||
payInfoService.payNotice(Long.parseLong(outTradeNo),Boolean.FALSE);
|
||||
payInfoService.payNotice(payInfo,Boolean.FALSE);
|
||||
//2.冲会员
|
||||
userMemberService.purchaseMember(Long.parseLong(outTradeNo));
|
||||
userMemberService.purchaseMember(payInfo);
|
||||
|
||||
}else{
|
||||
//还是各种业务逻辑
|
||||
//1.订单详情表里修改数据
|
||||
payInfoService.payNotice(Long.parseLong(outTradeNo),Boolean.FALSE);
|
||||
payInfoService.payNotice(payInfo,Boolean.FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue