创建订单
This commit is contained in:
parent
9465085136
commit
e0bac9998e
@ -68,4 +68,8 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode CARD_NOT_EXISTS = new ErrorCode(1_004_020_000, "会员卡类型不存在");
|
ErrorCode CARD_NOT_EXISTS = new ErrorCode(1_004_020_000, "会员卡类型不存在");
|
||||||
ErrorCode MEMBER_USER_NOT_EXISTS = new ErrorCode(1_004_021_000, "会员不存在");
|
ErrorCode MEMBER_USER_NOT_EXISTS = new ErrorCode(1_004_021_000, "会员不存在");
|
||||||
ErrorCode PAID_MEMBER_ORDER_NOT_EXISTS = new ErrorCode(1_004_022_000, "付费会员订单不存在");
|
ErrorCode PAID_MEMBER_ORDER_NOT_EXISTS = new ErrorCode(1_004_022_000, "付费会员订单不存在");
|
||||||
|
|
||||||
|
ErrorCode PAID_MEMBER_USER_ORDER_NO_NOT_EXISTS = new ErrorCode(1_004_023_000, "生成会员订单号失败,请重新提交");
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,20 +34,20 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|||||||
public class PaidMemberCardTypeController {
|
public class PaidMemberCardTypeController {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private PaidMemberCardTypeService cardService;
|
private PaidMemberCardTypeService cardTypeService;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建会员卡类型")
|
@Operation(summary = "创建会员卡类型")
|
||||||
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:create')")
|
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:create')")
|
||||||
public CommonResult<Long> createcard(@Valid @RequestBody PaidMemberCardTypeSaveReqVO createReqVO) {
|
public CommonResult<Long> createcard(@Valid @RequestBody PaidMemberCardTypeSaveReqVO createReqVO) {
|
||||||
return success(cardService.createcard(createReqVO));
|
return success(cardTypeService.createcard(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新会员卡类型")
|
@Operation(summary = "更新会员卡类型")
|
||||||
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:update')")
|
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:update')")
|
||||||
public CommonResult<Boolean> updatecard(@Valid @RequestBody PaidMemberCardTypeSaveReqVO updateReqVO) {
|
public CommonResult<Boolean> updatecard(@Valid @RequestBody PaidMemberCardTypeSaveReqVO updateReqVO) {
|
||||||
cardService.updatecard(updateReqVO);
|
cardTypeService.updatecard(updateReqVO);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ public class PaidMemberCardTypeController {
|
|||||||
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:delete')")
|
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:delete')")
|
||||||
public CommonResult<Boolean> deletecard(@RequestParam("id") long memberCardId) {
|
public CommonResult<Boolean> deletecard(@RequestParam("id") long memberCardId) {
|
||||||
System.out.println(memberCardId);
|
System.out.println(memberCardId);
|
||||||
cardService.deletecard(memberCardId);
|
cardTypeService.deletecard(memberCardId);
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ public class PaidMemberCardTypeController {
|
|||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:query')")
|
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:query')")
|
||||||
public CommonResult<PaidMemberCardTypeRespVO> getcard(@RequestParam("id") Long id) {
|
public CommonResult<PaidMemberCardTypeRespVO> getcard(@RequestParam("id") Long id) {
|
||||||
PaidMemberCardTypeDO card = cardService.getcard(id);
|
PaidMemberCardTypeDO card = cardTypeService.getcard(id);
|
||||||
return success(BeanUtils.toBean(card, PaidMemberCardTypeRespVO.class));
|
return success(BeanUtils.toBean(card, PaidMemberCardTypeRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ public class PaidMemberCardTypeController {
|
|||||||
@Operation(summary = "获得会员卡类型分页")
|
@Operation(summary = "获得会员卡类型分页")
|
||||||
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:query')")
|
@PreAuthorize("@ss.hasPermission('member:paid-member-card-type:query')")
|
||||||
public CommonResult<PageResult<PaidMemberCardTypeRespVO>> getcardPage(@Valid PaidMemberCardTypePageReqVO pageReqVO) {
|
public CommonResult<PageResult<PaidMemberCardTypeRespVO>> getcardPage(@Valid PaidMemberCardTypePageReqVO pageReqVO) {
|
||||||
PageResult<PaidMemberCardTypeDO> pageResult = cardService.getcardPage(pageReqVO);
|
PageResult<PaidMemberCardTypeDO> pageResult = cardTypeService.getcardPage(pageReqVO);
|
||||||
return success(BeanUtils.toBean(pageResult, PaidMemberCardTypeRespVO.class));
|
return success(BeanUtils.toBean(pageResult, PaidMemberCardTypeRespVO.class));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class PaidMemberCardTypeController {
|
|||||||
public void exportcardExcel(@Valid PaidMemberCardTypePageReqVO pageReqVO,
|
public void exportcardExcel(@Valid PaidMemberCardTypePageReqVO pageReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
List<PaidMemberCardTypeDO> list = cardService.getcardPage(pageReqVO).getList();
|
List<PaidMemberCardTypeDO> list = cardTypeService.getcardPage(pageReqVO).getList();
|
||||||
// 导出 Excel
|
// 导出 Excel
|
||||||
ExcelUtils.write(response, "会员卡类型.xls", "数据", PaidMemberCardTypeRespVO.class,
|
ExcelUtils.write(response, "会员卡类型.xls", "数据", PaidMemberCardTypeRespVO.class,
|
||||||
BeanUtils.toBean(list, PaidMemberCardTypeRespVO.class));
|
BeanUtils.toBean(list, PaidMemberCardTypeRespVO.class));
|
||||||
|
@ -16,6 +16,9 @@ public class PaidMemberUserSaveReqVO {
|
|||||||
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12209")
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12209")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12209")
|
||||||
|
private Long uid;
|
||||||
|
|
||||||
@Schema(description = "手机号")
|
@Schema(description = "手机号")
|
||||||
private String mobile;
|
private String mobile;
|
||||||
|
|
||||||
@ -95,4 +98,7 @@ public class PaidMemberUserSaveReqVO {
|
|||||||
@Schema(description = "支付渠道", example = "public-公众号,mini-小程序,h5-网页支付,wechatIos-微信Ios,wechatAndroid-微信Android,alipay-支付包,alipayApp-支付宝App,give-平台赠送,yue-余额支付")
|
@Schema(description = "支付渠道", example = "public-公众号,mini-小程序,h5-网页支付,wechatIos-微信Ios,wechatAndroid-微信Android,alipay-支付包,alipayApp-支付宝App,give-平台赠送,yue-余额支付")
|
||||||
private String payChannel;
|
private String payChannel;
|
||||||
|
|
||||||
|
@Schema(description = "订单号", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private String orderNo;
|
||||||
|
|
||||||
}
|
}
|
@ -143,7 +143,7 @@ public class MemberUserDO extends TenantBaseDO {
|
|||||||
private Long groupId;
|
private Long groupId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否绑过卡,是否开通过试用会员
|
* 是否绑过卡,是否开通过会员(0:未开通,1:试用,2:有效期,3:永久)
|
||||||
*/
|
*/
|
||||||
private Integer activate;
|
private Integer activate;
|
||||||
|
|
||||||
|
@ -31,6 +31,10 @@ public class PaidMemberUserDO extends TenantBaseDO {
|
|||||||
*/
|
*/
|
||||||
@TableId
|
@TableId
|
||||||
private Long id;
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 用户编号
|
||||||
|
*/
|
||||||
|
private Long uid;
|
||||||
/**
|
/**
|
||||||
* 手机号
|
* 手机号
|
||||||
*/
|
*/
|
||||||
@ -137,6 +141,10 @@ public class PaidMemberUserDO extends TenantBaseDO {
|
|||||||
* 支付渠道
|
* 支付渠道
|
||||||
*/
|
*/
|
||||||
private String payChannel;
|
private String payChannel;
|
||||||
|
/**
|
||||||
|
* 订单号
|
||||||
|
*/
|
||||||
|
private String orderNo;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -34,8 +34,6 @@ public class PaidMemberCardTypeServiceImpl implements PaidMemberCardTypeService
|
|||||||
@Resource
|
@Resource
|
||||||
private PaidMemberCardTypeMapper cardMapper;
|
private PaidMemberCardTypeMapper cardMapper;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PaidMemberUserService paidMemberUserService01;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createcard(PaidMemberCardTypeSaveReqVO createReqVO) {
|
public Long createcard(PaidMemberCardTypeSaveReqVO createReqVO) {
|
||||||
|
@ -60,8 +60,8 @@ public interface PaidMemberOrderService {
|
|||||||
*
|
*
|
||||||
* @return 编号
|
* @return 编号
|
||||||
*/
|
*/
|
||||||
BigDecimal createMemberRecord(Long userId, Integer userType, String userIp,
|
// BigDecimal createMemberRecord(Long userId, Integer userType, String userIp,
|
||||||
Integer type,String cardName);
|
// Integer type,String cardName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 创建付费会员订单
|
* 创建付费会员订单
|
||||||
@ -78,11 +78,11 @@ public interface PaidMemberOrderService {
|
|||||||
*/
|
*/
|
||||||
void updateOrder(@Valid PaidMemberOrderDO updateReqVO);
|
void updateOrder(@Valid PaidMemberOrderDO updateReqVO);
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* 根据订单会员类型
|
// * 根据订单会员类型
|
||||||
* 获得到期时间
|
// * 获得到期时间
|
||||||
*/
|
// */
|
||||||
LocalDateTime getDeadLineDay(String cardName);
|
// LocalDateTime getDeadLineDay(String cardName);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,27 +87,27 @@ public class PaidMemberOrderServiceImpl implements PaidMemberOrderService {
|
|||||||
return paidMemberOrderMapper.selectPage(pageReqVO);
|
return paidMemberOrderMapper.selectPage(pageReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public BigDecimal createMemberRecord(Long userId, Integer userType, String userIp,
|
// public BigDecimal createMemberRecord(Long userId, Integer userType, String userIp,
|
||||||
Integer type, String cardName) {
|
// Integer type, String cardName) {
|
||||||
//定义一个支付金额
|
// //定义一个支付金额
|
||||||
BigDecimal payPrice = null;
|
// BigDecimal payPrice = null;
|
||||||
BigDecimal gitBalance = BigDecimal.valueOf(0);//赠送余额,权益规则还未定
|
// BigDecimal gitBalance = BigDecimal.valueOf(0);//赠送余额,权益规则还未定
|
||||||
|
//
|
||||||
if(Objects.nonNull(type)){
|
// if(Objects.nonNull(type)){
|
||||||
PaidMemberUserDO paidMemberUserDO = paidMemberUserService.getMemberUser(getLoginUserId());
|
// PaidMemberUserDO paidMemberUserDO = paidMemberUserService.getMemberUser(getLoginUserId());
|
||||||
PaidMemberCardTypeDO paidMemberCardTypeDO =typeService.selectByName(cardName);
|
// PaidMemberCardTypeDO paidMemberCardTypeDO =typeService.selectByName(cardName);
|
||||||
if(paidMemberCardTypeDO.getName().equals("试用")){
|
// if(paidMemberCardTypeDO.getName().equals("试用")){
|
||||||
payPrice = paidMemberCardTypeDO.getOriginalPrice();
|
// payPrice = paidMemberCardTypeDO.getOriginalPrice();
|
||||||
}else if (paidMemberUserDO != null){
|
// }else if (paidMemberUserDO != null){
|
||||||
payPrice = paidMemberCardTypeDO.getSpecialPrice();
|
// payPrice = paidMemberCardTypeDO.getSpecialPrice();
|
||||||
}
|
// }
|
||||||
else {
|
// else {
|
||||||
payPrice = paidMemberCardTypeDO.getOriginalPrice();
|
// payPrice = paidMemberCardTypeDO.getOriginalPrice();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
return payPrice;
|
// return payPrice;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createOrder(PaidMemberOrderDO createReqVO) {
|
public void createOrder(PaidMemberOrderDO createReqVO) {
|
||||||
@ -119,23 +119,23 @@ public class PaidMemberOrderServiceImpl implements PaidMemberOrderService {
|
|||||||
paidMemberOrderMapper.updateById(updateReqVO);
|
paidMemberOrderMapper.updateById(updateReqVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public LocalDateTime getDeadLineDay(String cardName) {
|
// public LocalDateTime getDeadLineDay(String cardName) {
|
||||||
LocalDateTime now = LocalDateTime.now();
|
// LocalDateTime now = LocalDateTime.now();
|
||||||
LocalDateTime deadlineDay;
|
// LocalDateTime deadlineDay;
|
||||||
if (cardName.equals("试用")){
|
// if (cardName.equals("试用")){
|
||||||
deadlineDay = now.plus(1, ChronoUnit.DAYS);
|
// deadlineDay = now.plus(1, ChronoUnit.DAYS);
|
||||||
} else if (cardName.equals("月卡")) {
|
// } else if (cardName.equals("月卡")) {
|
||||||
deadlineDay = now.plus(1,ChronoUnit.MONTHS);
|
// deadlineDay = now.plus(1,ChronoUnit.MONTHS);
|
||||||
} else if (cardName.equals("季卡")) {
|
// } else if (cardName.equals("季卡")) {
|
||||||
deadlineDay = now.plus(3,ChronoUnit.MONTHS);
|
// deadlineDay = now.plus(3,ChronoUnit.MONTHS);
|
||||||
} else if (cardName.equals("年卡")) {
|
// } else if (cardName.equals("年卡")) {
|
||||||
deadlineDay = now.plus(1,ChronoUnit.YEARS);
|
// deadlineDay = now.plus(1,ChronoUnit.YEARS);
|
||||||
} else {
|
// } else {
|
||||||
deadlineDay = null;
|
// deadlineDay = null;
|
||||||
}
|
// }
|
||||||
return deadlineDay;
|
// return deadlineDay;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PaidMemberOrderDO getPaidMemeberOrder(Long id) {
|
public PaidMemberOrderDO getPaidMemeberOrder(Long id) {
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.member.service.user;
|
package cn.iocoder.yudao.module.member.service.user;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import javax.validation.*;
|
import javax.validation.*;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.*;
|
import cn.iocoder.yudao.module.member.controller.admin.user.vo.*;
|
||||||
@ -24,6 +25,9 @@ public interface PaidMemberUserService {
|
|||||||
*/
|
*/
|
||||||
Long createMemberUser(@Valid PaidMemberUserSaveReqVO createReqVO);
|
Long createMemberUser(@Valid PaidMemberUserSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新会员
|
* 更新会员
|
||||||
*
|
*
|
||||||
@ -46,6 +50,12 @@ public interface PaidMemberUserService {
|
|||||||
*/
|
*/
|
||||||
PaidMemberUserDO getMemberUser(Long id);
|
PaidMemberUserDO getMemberUser(Long id);
|
||||||
|
|
||||||
|
int getPriceByTtype(Integer activate, String cardName);
|
||||||
|
|
||||||
|
LocalDateTime getDeadLineDay(String cardName);
|
||||||
|
|
||||||
|
PaidMemberUserDO getPaidMemberUserByOrderNo(String orderNO);
|
||||||
|
|
||||||
|
|
||||||
// /**
|
// /**
|
||||||
// * 获得会员分页
|
// * 获得会员分页
|
||||||
|
@ -1,11 +1,18 @@
|
|||||||
package cn.iocoder.yudao.module.member.service.user;
|
package cn.iocoder.yudao.module.member.service.user;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DatePattern;
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
|
import cn.iocoder.yudao.module.member.service.membercardtype.PaidMemberCardTypeService;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.temporal.ChronoUnit;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.*;
|
import cn.iocoder.yudao.module.member.controller.admin.user.vo.*;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.PaidMemberUserDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.PaidMemberUserDO;
|
||||||
@ -30,16 +37,29 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
|
|||||||
@Resource
|
@Resource
|
||||||
private PaidMemberUserMapper paidMemberUserMapper;
|
private PaidMemberUserMapper paidMemberUserMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PaidMemberCardTypeService memberCardTypeService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createMemberUser(PaidMemberUserSaveReqVO createReqVO) {
|
public Long createMemberUser(PaidMemberUserSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
PaidMemberUserDO memberUser = BeanUtils.toBean(createReqVO, PaidMemberUserDO.class);
|
PaidMemberUserDO memberUser = BeanUtils.toBean(createReqVO, PaidMemberUserDO.class);
|
||||||
|
String prefix = String.valueOf('m');
|
||||||
|
memberUser.setOrderNo(generate(prefix));
|
||||||
|
if(getPaidMemberUserByOrderNo(memberUser.getOrderNo()) != null){
|
||||||
|
throw exception(PAID_MEMBER_USER_ORDER_NO_NOT_EXISTS);
|
||||||
|
}
|
||||||
paidMemberUserMapper.insert(memberUser);
|
paidMemberUserMapper.insert(memberUser);
|
||||||
// 返回
|
// 返回
|
||||||
return memberUser.getId();
|
return memberUser.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String generate(String prefix){
|
||||||
|
String no = prefix + DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_PATTERN);
|
||||||
|
return no;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateMemberUser(PaidMemberUserSaveReqVO updateReqVO) {
|
public void updateMemberUser(PaidMemberUserSaveReqVO updateReqVO) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
@ -59,15 +79,55 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
|
|||||||
|
|
||||||
private void validateMemberUserExists(Long id) {
|
private void validateMemberUserExists(Long id) {
|
||||||
if (paidMemberUserMapper.selectById(id) == null) {
|
if (paidMemberUserMapper.selectById(id) == null) {
|
||||||
throw exception(MEMBER_USER_NOT_EXISTS);
|
throw exception(PAID_MEMBER_ORDER_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PaidMemberUserDO getMemberUser(Long id) {
|
public PaidMemberUserDO getMemberUser(Long id) {
|
||||||
|
validateMemberUserExists(id);
|
||||||
return paidMemberUserMapper.selectById(id);
|
return paidMemberUserMapper.selectById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getPriceByTtype(Integer activate, String cardName) {
|
||||||
|
int price = 0;
|
||||||
|
if(activate == 0){
|
||||||
|
BigDecimal payprice = memberCardTypeService.selectByName(cardName).getOriginalPrice();
|
||||||
|
price = payprice.multiply(new BigDecimal("100")).intValue();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BigDecimal payprice = memberCardTypeService.selectByName(cardName).getSpecialPrice();
|
||||||
|
price = payprice.multiply(new BigDecimal("100")).intValue();
|
||||||
|
}
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
//获取会员类型对应的过期时间
|
||||||
|
@Override
|
||||||
|
public LocalDateTime getDeadLineDay(String cardName) {
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
LocalDateTime deadlineDay;
|
||||||
|
if (cardName.equals("试用")){
|
||||||
|
deadlineDay = now.plus(1, ChronoUnit.DAYS);
|
||||||
|
} else if (cardName.equals("月卡")) {
|
||||||
|
deadlineDay = now.plus(1,ChronoUnit.MONTHS);
|
||||||
|
} else if (cardName.equals("季卡")) {
|
||||||
|
deadlineDay = now.plus(3,ChronoUnit.MONTHS);
|
||||||
|
} else if (cardName.equals("年卡")) {
|
||||||
|
deadlineDay = now.plus(1,ChronoUnit.YEARS);
|
||||||
|
} else {
|
||||||
|
deadlineDay = null;
|
||||||
|
}
|
||||||
|
return deadlineDay;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PaidMemberUserDO getPaidMemberUserByOrderNo(String orderNO) {
|
||||||
|
PaidMemberUserDO paidMemberUserDO = paidMemberUserMapper.selectOne(PaidMemberUserDO::getOrderNo,orderNO);
|
||||||
|
return paidMemberUserDO;
|
||||||
|
}
|
||||||
|
|
||||||
// @Override
|
// @Override
|
||||||
// public PageResult<PaidMemberUserDO> getMemberUserPage(PaidMemberUserPageReqVO pageReqVO) {
|
// public PageResult<PaidMemberUserDO> getMemberUserPage(PaidMemberUserPageReqVO pageReqVO) {
|
||||||
// return memberUserMapper.selectPage(pageReqVO);
|
// return memberUserMapper.selectPage(pageReqVO);
|
||||||
|
@ -0,0 +1,146 @@
|
|||||||
|
package cn.iocoder.yudao.module.pay.controller.app.member;
|
||||||
|
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
//import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
||||||
|
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
||||||
|
import cn.iocoder.yudao.module.member.controller.admin.user.vo.PaidMemberUserSaveReqVO;
|
||||||
|
import cn.iocoder.yudao.module.member.convert.order.PaidMemberOrderConvert;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.order.PaidMemberOrderDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
||||||
|
import cn.iocoder.yudao.module.member.dal.dataobject.user.PaidMemberUserDO;
|
||||||
|
import cn.iocoder.yudao.module.member.service.membercardtype.PaidMemberCardTypeService;
|
||||||
|
import cn.iocoder.yudao.module.member.service.order.PaidMemberOrderService;
|
||||||
|
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
||||||
|
import cn.iocoder.yudao.module.member.service.user.PaidMemberUserService;
|
||||||
|
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberCreateReqVO;
|
||||||
|
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberCreateRespVO;
|
||||||
|
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemeberOrderReqDto;
|
||||||
|
import cn.iocoder.yudao.module.pay.convert.member.PayMemberOrderConvert;
|
||||||
|
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
|
||||||
|
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||||
|
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
|
||||||
|
import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
|
||||||
|
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||||
|
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||||
|
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType;
|
||||||
|
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.MEMBER_USER_NOT_EXISTS;
|
||||||
|
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.WALLET_BALANCE_NOT_ENOUGH;
|
||||||
|
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.WALLET_NOT_FOUND;
|
||||||
|
import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT;
|
||||||
|
|
||||||
|
@Tag(name = "用户 APP - 会员支付")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/pay/member")
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
public class AppPaidMembeController {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private MemberUserService memberUserService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PaidMemberUserService paidMemberUserService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PaidMemberCardTypeService memberCardService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PayWalletService payWalletService;
|
||||||
|
|
||||||
|
@PostMapping("/create")
|
||||||
|
@Operation(summary = "创建会员支付记录(发起支付)")
|
||||||
|
public CommonResult<AppPaidMemberCreateRespVO> createcard(@Valid @RequestBody AppPaidMemberCreateReqVO reqVO) {
|
||||||
|
//获取当前登录用户信息,并判断用户是否存在
|
||||||
|
MemberUserDO memberUserDO = memberUserService.getUser(getLoginUserId());
|
||||||
|
if (memberUserDO == null){
|
||||||
|
throw exception(MEMBER_USER_NOT_EXISTS);
|
||||||
|
}
|
||||||
|
PaidMemberUserDO paidMemberUserDO = new PaidMemberUserDO();
|
||||||
|
PaidMemberUserSaveReqVO paidMemberUserSaveReqVO = new PaidMemberUserSaveReqVO();
|
||||||
|
//初始化支付金额,单位为分
|
||||||
|
int price = 0;
|
||||||
|
if(reqVO.getCardName().equals("试用")){
|
||||||
|
BeanUtils.copyProperties(memberUserDO,paidMemberUserSaveReqVO);
|
||||||
|
paidMemberUserSaveReqVO.setId(null);
|
||||||
|
paidMemberUserSaveReqVO.setUid(memberUserDO.getId());
|
||||||
|
paidMemberUserSaveReqVO.setPrice(price);
|
||||||
|
paidMemberUserSaveReqVO.setPaid(true);
|
||||||
|
//获取期限天数
|
||||||
|
String deadlineDay = memberCardService.selectByName(reqVO.getCardName()).getVid();
|
||||||
|
paidMemberUserSaveReqVO.setDeadlineDay(deadlineDay);
|
||||||
|
paidMemberUserSaveReqVO.setPayType("免费领取");
|
||||||
|
//获取支付时间
|
||||||
|
LocalDateTime payTime = LocalDateTime.now();
|
||||||
|
paidMemberUserSaveReqVO.setPayTime(payTime);
|
||||||
|
//获取试用类型的过期时间
|
||||||
|
LocalDateTime cardExpirationTime = paidMemberUserService.getDeadLineDay(reqVO.getCardName());
|
||||||
|
paidMemberUserSaveReqVO.setCardExpirationTime(cardExpirationTime);
|
||||||
|
//新增会员订单记录
|
||||||
|
Long id = paidMemberUserService.createMemberUser(paidMemberUserSaveReqVO);
|
||||||
|
//查询新增的会员订单记录
|
||||||
|
paidMemberUserDO = paidMemberUserService.getMemberUser(id);
|
||||||
|
memberUserDO.setActivate(1);
|
||||||
|
//跟新用户的会员启用状态
|
||||||
|
memberUserService.updateUserDo(memberUserDO);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
BeanUtils.copyProperties(memberUserDO,paidMemberUserSaveReqVO);
|
||||||
|
paidMemberUserSaveReqVO.setId(null);
|
||||||
|
paidMemberUserSaveReqVO.setUid(memberUserDO.getId());
|
||||||
|
//获取实际支付金额(判断是否为会员有无优惠价)
|
||||||
|
price = paidMemberUserService.getPriceByTtype(memberUserDO.getActivate(),reqVO.getCardName());
|
||||||
|
//获取期限天数
|
||||||
|
String deadlineDay = memberCardService.selectByName(reqVO.getCardName()).getVid();
|
||||||
|
paidMemberUserSaveReqVO.setDeadlineDay(deadlineDay);
|
||||||
|
paidMemberUserSaveReqVO.setPrice(price);
|
||||||
|
paidMemberUserSaveReqVO.setPayType("钱包支付");
|
||||||
|
//新增会员订单记录
|
||||||
|
Long id = paidMemberUserService.createMemberUser(paidMemberUserSaveReqVO);
|
||||||
|
//查询新增的会员订单记录
|
||||||
|
paidMemberUserDO = paidMemberUserService.getMemberUser(id);
|
||||||
|
}
|
||||||
|
return success(PayMemberOrderConvert.INSTANCE.convert(paidMemberUserDO.getId(),paidMemberUserDO.getOrderNo()
|
||||||
|
,paidMemberUserDO.getCardExpirationTime(),memberUserDO.getActivate()));
|
||||||
|
}
|
||||||
|
|
||||||
|
// @PostMapping("/update")
|
||||||
|
// @Operation(summary = "更新会员订单未支付为已支付") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob
|
||||||
|
// public CommonResult<Boolean> updatePaidMemberUser(@Valid @RequestBody AppPaidMemeberOrderReqDto notifyReqDTO){
|
||||||
|
// //获取订单记录
|
||||||
|
// PaidMemberUserDO paidMemberUserDO = paidMemberUserService.getMemberUser(notifyReqDTO.getId());
|
||||||
|
//// 校验钱包充值是否可以支付
|
||||||
|
// PayWalletDO walletDO = payWalletService.getOrCreateWallet(WebFrameworkUtils.getLoginUserId(),getLoginUserType());
|
||||||
|
// if(walletDO.getBalance()<paidMemberUserDO.getPrice()){
|
||||||
|
// log.error("[updatePaidMemberOrder],updateReqVO({}) 钱包余额不足.");
|
||||||
|
// throw exception(WALLET_BALANCE_NOT_ENOUGH);
|
||||||
|
// }
|
||||||
|
//// 扣减钱包余额
|
||||||
|
// PayWalletTransactionDO payWalletTransactionDO = payWalletService.reduceWalletBalance
|
||||||
|
// (walletDO.getId(),notifyReqDTO.getPayOrderId(),PAYMENT,price);
|
||||||
|
//
|
||||||
|
//// //更新订单支付状态为已支付
|
||||||
|
//// paidMemberOrderDO.setPaid(true);
|
||||||
|
//// paidMemberOrderDO.setPayChannel(payOrderDO.getChannelCode());
|
||||||
|
//// paidMemberOrderService1.updateOrder(paidMemberOrderDO);
|
||||||
|
// return success(true);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -1,176 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.pay.controller.app.member;
|
|
||||||
|
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
|
||||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
|
||||||
//import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
|
|
||||||
import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils;
|
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.user.vo.PaidMemberUserSaveReqVO;
|
|
||||||
import cn.iocoder.yudao.module.member.convert.order.PaidMemberOrderConvert;
|
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.PaidMemberOrderDO;
|
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
|
|
||||||
import cn.iocoder.yudao.module.member.service.membercardtype.PaidMemberCardTypeService;
|
|
||||||
import cn.iocoder.yudao.module.member.service.order.PaidMemberOrderService;
|
|
||||||
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
|
|
||||||
import cn.iocoder.yudao.module.member.service.user.PaidMemberUserService;
|
|
||||||
import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO;
|
|
||||||
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
|
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberOrderReqVO;
|
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberOrderRespVO;
|
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemeberOrderReqDto;
|
|
||||||
import cn.iocoder.yudao.module.pay.convert.member.PayMemberOrderConvert;
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
|
||||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
|
|
||||||
import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
|
|
||||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.springframework.beans.BeanUtils;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
|
||||||
import javax.annotation.security.PermitAll;
|
|
||||||
import javax.validation.Valid;
|
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime;
|
|
||||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
|
||||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
|
||||||
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType;
|
|
||||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.PAID_MEMBER_ORDER_NOT_EXISTS;
|
|
||||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.WALLET_BALANCE_NOT_ENOUGH;
|
|
||||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.WALLET_NOT_FOUND;
|
|
||||||
import static cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum.PAYMENT;
|
|
||||||
|
|
||||||
@Tag(name = "用户 APP - 会员支出")
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/pay/member")
|
|
||||||
@Validated
|
|
||||||
@Slf4j
|
|
||||||
public class AppPaidMembeOrderController {
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private MemberUserService userService1;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PaidMemberUserService memberUserService1;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PaidMemberOrderService paidMemberOrderService1;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PayWalletService memberWalletService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PayOrderService payOrderService01;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PaidMemberCardTypeService cardService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private PayWalletService payWalletService;
|
|
||||||
|
|
||||||
|
|
||||||
@PostMapping("/create")
|
|
||||||
@Operation(summary = "创建会员支付记录(发起支付)")
|
|
||||||
public CommonResult<AppPaidMemberOrderRespVO> createcard(@Valid @RequestBody AppPaidMemberOrderReqVO reqVO) {
|
|
||||||
MemberUserDO memberUserDO = userService1.getUser(getLoginUserId());
|
|
||||||
PaidMemberUserSaveReqVO paidMemberUserSaveReqVO = new PaidMemberUserSaveReqVO();
|
|
||||||
// 判断当前用户是否选择过试用会员
|
|
||||||
if(memberUserDO.getActivate() == 0 && memberUserDO != null && reqVO.getCardName().equals("试用")){
|
|
||||||
//试用会员
|
|
||||||
memberUserDO.setActivate(CommonStatusEnum.DISABLE.getStatus());
|
|
||||||
}else if(reqVO.getCardName().equals("永久")){
|
|
||||||
//永久会员
|
|
||||||
memberUserDO.setActivate(3);
|
|
||||||
}else {
|
|
||||||
//有效期会员
|
|
||||||
memberUserDO.setActivate(2);
|
|
||||||
}
|
|
||||||
// 若不是会员则往会员表插入数据
|
|
||||||
if(memberUserService1.getMemberUser(memberUserDO.getId()) == null){
|
|
||||||
BeanUtils.copyProperties(memberUserDO,paidMemberUserSaveReqVO);
|
|
||||||
memberUserService1.createMemberUser(paidMemberUserSaveReqVO);
|
|
||||||
}
|
|
||||||
//判断会员类型
|
|
||||||
if(reqVO.getCardName().equals("试用")){
|
|
||||||
reqVO.setType(0);
|
|
||||||
} else if (reqVO.getCardName().equals("永久")) {
|
|
||||||
reqVO.setType(2);
|
|
||||||
}else {
|
|
||||||
reqVO.setType(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//获得对应会员期限天数
|
|
||||||
String deadlineDay = cardService.selectByName(reqVO.getCardName()).getVid();
|
|
||||||
LocalDateTime payTime = LocalDateTime.now();
|
|
||||||
LocalDateTime cardExpirationTime = paidMemberOrderService1.getDeadLineDay(reqVO.getCardName());
|
|
||||||
|
|
||||||
//获得支付金额
|
|
||||||
BigDecimal payPrice = paidMemberOrderService1.createMemberRecord(getLoginUserId(),
|
|
||||||
getLoginUserType(),getClientIP(),reqVO.getType(),reqVO.getCardName());
|
|
||||||
BigDecimal p = payPrice.multiply(new BigDecimal("100"));
|
|
||||||
Integer payPriceInt = p.intValue();
|
|
||||||
BigDecimal originalPrice = cardService.selectByName(reqVO.getCardName()).getOriginalPrice();
|
|
||||||
// PayWalletDO walletDO = memberWalletService.getOrCreateWallet(getLoginUserId(),getLoginUserType());
|
|
||||||
//订单对象赋值
|
|
||||||
PaidMemberOrderDO paidMemberOrderDO = PaidMemberOrderConvert.INSTANCE.convert(getLoginUserId(),
|
|
||||||
reqVO.getCardName(),reqVO.getType(),payPrice,payTime,deadlineDay,cardExpirationTime,originalPrice);
|
|
||||||
paidMemberOrderService1.createOrder(paidMemberOrderDO);
|
|
||||||
Long payOrderId = payOrderService01.createOrder(new PayOrderCreateReqDTO()
|
|
||||||
.setAppId(1L).setUserIp(getClientIP())
|
|
||||||
.setMerchantOrderId(""+paidMemberOrderDO.getId()) // 业务的订单编号
|
|
||||||
.setSubject("会员支付").setBody("")
|
|
||||||
.setPrice(payPriceInt)
|
|
||||||
.setExpireTime(addTime(Duration.ofHours(2L)))); // TODO @芋艿:支付超时时间
|
|
||||||
paidMemberOrderDO.setPayOrderId(payOrderId);
|
|
||||||
userService1.updateUserDo(memberUserDO);
|
|
||||||
paidMemberOrderService1.updateOrder(paidMemberOrderDO);
|
|
||||||
return success(PayMemberOrderConvert.INSTANCE.convert(paidMemberOrderDO.getId(),paidMemberOrderDO.getPayOrderId()
|
|
||||||
,paidMemberOrderDO.getCardExpirationTime(),memberUserDO.getActivate()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@PostMapping("/update")
|
|
||||||
@Operation(summary = "更新会员订单未支付为已支付") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob
|
|
||||||
public CommonResult<Boolean> updatePaidMemberOrder(@Valid @RequestBody AppPaidMemeberOrderReqDto notifyReqDTO){
|
|
||||||
//获取订单记录
|
|
||||||
PaidMemberOrderDO paidMemberOrderDO = paidMemberOrderService1.getPaidMemeberOrder(Long.valueOf(notifyReqDTO.getMerchantOrderId()));
|
|
||||||
if(paidMemberOrderDO == null){
|
|
||||||
log.error("[updatePaidMemberOrder],updateReqVO({}) 付费会员订单不存在.");
|
|
||||||
throw exception(PAID_MEMBER_ORDER_NOT_EXISTS);
|
|
||||||
}
|
|
||||||
BigDecimal decimalprice = paidMemberOrderDO.getPrice();
|
|
||||||
Integer price = decimalprice.multiply(new BigDecimal("100")).intValue();
|
|
||||||
// 校验钱包充值是否可以支付
|
|
||||||
PayWalletDO walletDO = payWalletService.getOrCreateWallet(WebFrameworkUtils.getLoginUserId(),getLoginUserType());
|
|
||||||
if(walletDO == null){
|
|
||||||
log.error("[updatePaidMemberOrder],updateReqVO({}) 用户钱包不存在.");
|
|
||||||
throw exception(WALLET_NOT_FOUND);
|
|
||||||
}
|
|
||||||
if(walletDO.getBalance()<price){
|
|
||||||
log.error("[updatePaidMemberOrder],updateReqVO({}) 钱包余额不足.");
|
|
||||||
throw exception(WALLET_BALANCE_NOT_ENOUGH);
|
|
||||||
}
|
|
||||||
PayOrderDO payOrderDO = payOrderService01.getOrder(notifyReqDTO.getPayOrderId());
|
|
||||||
//更新订单支付状态为已支付
|
|
||||||
paidMemberOrderDO.setPaid(true);
|
|
||||||
paidMemberOrderDO.setPayChannel(payOrderDO.getChannelCode());
|
|
||||||
paidMemberOrderService1.updateOrder(paidMemberOrderDO);
|
|
||||||
//扣减钱包余额
|
|
||||||
PayWalletTransactionDO payWalletTransactionDO = payWalletService.reduceWalletBalance
|
|
||||||
(walletDO.getId(),notifyReqDTO.getPayOrderId(),PAYMENT,price);
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,15 @@
|
|||||||
|
package cn.iocoder.yudao.module.pay.controller.app.member.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.Min;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Schema(description = "用户 APP - 会员支付 Request VO")
|
||||||
|
@Data
|
||||||
|
public class AppPaidMemberCreateReqVO {
|
||||||
|
@Schema(description = "会员卡名称", example = "试用")
|
||||||
|
private String cardName;
|
||||||
|
|
||||||
|
}
|
@ -10,13 +10,16 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
|
|||||||
|
|
||||||
@Schema(description = "用户 APP - 会员支付 Resp VO")
|
@Schema(description = "用户 APP - 会员支付 Resp VO")
|
||||||
@Data
|
@Data
|
||||||
public class AppPaidMemberOrderRespVO {
|
public class AppPaidMemberCreateRespVO {
|
||||||
|
|
||||||
@Schema(description = "会员支付编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "会员支付编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "o100")
|
// @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "o100")
|
||||||
private Long payOrderId;
|
// private Long payOrderId;
|
||||||
|
|
||||||
|
@Schema(description = "会员订单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "m100")
|
||||||
|
private String orderNo;
|
||||||
|
|
||||||
@Schema(description = "到期时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-11-22 09:30:05")
|
@Schema(description = "到期时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024-11-22 09:30:05")
|
||||||
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
@ -1,29 +0,0 @@
|
|||||||
package cn.iocoder.yudao.module.pay.controller.app.member.vo;
|
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import javax.validation.constraints.Min;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
@Schema(description = "用户 APP - 会员支付 Request VO")
|
|
||||||
@Data
|
|
||||||
public class AppPaidMemberOrderReqVO {
|
|
||||||
|
|
||||||
@Schema(description = "会员卡售价", example = "1000")
|
|
||||||
@Min(value = 0, message = "会员卡必须大等于零")
|
|
||||||
private BigDecimal price;
|
|
||||||
|
|
||||||
@Schema(description = "会员卡名称", example = "试用")
|
|
||||||
private String cardName;
|
|
||||||
|
|
||||||
|
|
||||||
@Schema(description = "会员类型", example = "0-试用,1-期限,2-永久")
|
|
||||||
private Integer type;
|
|
||||||
|
|
||||||
// @Schema(description = "支付方式", example = "weixin,alipay,give,yue")
|
|
||||||
// private String payType;
|
|
||||||
|
|
||||||
@Schema(description = "支付渠道", example = "公众号,mini-小程序,h5-网页支付,wechatIos-微信Ios,wechatAndroid-微信Android,alipay-支付包,alipayApp-支付宝App,give-平台赠送")
|
|
||||||
private String payChannel;
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.pay.controller.app.member.vo;
|
package cn.iocoder.yudao.module.pay.controller.app.member.vo;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@ -18,17 +19,10 @@ import javax.validation.constraints.NotNull;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class AppPaidMemeberOrderReqDto {
|
public class AppPaidMemeberOrderReqDto {
|
||||||
|
@Schema(description = "会员支付编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
/**
|
|
||||||
* 商户订单编号
|
|
||||||
*/
|
|
||||||
@NotEmpty(message = "商户订单号不能为空")
|
|
||||||
private String merchantOrderId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 支付订单编号
|
|
||||||
*/
|
|
||||||
@NotNull(message = "支付订单编号不能为空")
|
|
||||||
private Long payOrderId;
|
|
||||||
|
|
||||||
|
@Schema(description = "支付渠道", example = "公众号,mini-小程序,h5-网页支付,wechatIos-微信Ios,wechatAndroid-微信Android,alipay-支付包,alipayApp-支付宝App,give-平台赠送")
|
||||||
|
private String payChannel;
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package cn.iocoder.yudao.module.pay.convert.member;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.module.member.controller.admin.order.vo.PaidMemberOrderRespVO;
|
import cn.iocoder.yudao.module.member.controller.admin.order.vo.PaidMemberOrderRespVO;
|
||||||
import cn.iocoder.yudao.module.member.dal.dataobject.order.PaidMemberOrderDO;
|
import cn.iocoder.yudao.module.member.dal.dataobject.order.PaidMemberOrderDO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberOrderRespVO;
|
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberCreateRespVO;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
@ -13,5 +13,5 @@ public interface PayMemberOrderConvert {
|
|||||||
|
|
||||||
PayMemberOrderConvert INSTANCE = Mappers.getMapper(PayMemberOrderConvert.class);
|
PayMemberOrderConvert INSTANCE = Mappers.getMapper(PayMemberOrderConvert.class);
|
||||||
|
|
||||||
AppPaidMemberOrderRespVO convert(Long id, Long payOrderId, LocalDateTime cardExpirationTime, Integer activate);
|
AppPaidMemberCreateRespVO convert(Long id, String orderNo, LocalDateTime cardExpirationTime, Integer activate);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user