会员支付

This commit is contained in:
khy 2024-10-21 08:49:23 +08:00
parent d2c735ac18
commit 11dd5f7f6f
29 changed files with 1336 additions and 8 deletions

View File

@ -63,7 +63,9 @@ public interface ErrorCodeConstants {
ErrorCode TRANSFER_NOT_EXISTS = new ErrorCode(1_004_017_000, "会员卡划拨不存在");
ErrorCode TRANSFER_LOG_NOT_EXISTS = new ErrorCode(1_004_018_000, "会员卡划拨记录不存在");
// ========== ==========
// ==========会员类型权益支付 1-019-22-000 ==========
ErrorCode INPUTCODE_NOT_EXISTS = new ErrorCode(1_004_019_000, "进件码不存在");
ErrorCode CARD_NOT_EXISTS = new ErrorCode(1_004_020_000, "会员卡类型不存在");
ErrorCode MEMBER_USER_NOT_EXISTS = new ErrorCode(1_004_021_000, "会员不存在");
ErrorCode PAID_MEMBER_ORDER_NOT_EXISTS = new ErrorCode(1_004_022_000, "付费会员订单不存在");
}

View File

@ -0,0 +1,95 @@
package cn.iocoder.yudao.module.member.controller.admin.order;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*;
import cn.iocoder.yudao.module.member.controller.admin.order.vo.*;
import cn.iocoder.yudao.module.member.dal.dataobject.order.PaidMemberOrderDO;
import cn.iocoder.yudao.module.member.service.order.PaidMemberOrderService;
@Tag(name = "管理后台 - 付费会员订单")
@RestController
@RequestMapping("/member/paid-member-order")
@Validated
public class PaidMemberOrderController {
@Resource
private PaidMemberOrderService paidMemberOrderService;
@PostMapping("/create")
@Operation(summary = "创建付费会员订单")
@PreAuthorize("@ss.hasPermission('member:paid-member-order:create')")
public CommonResult<Integer> createPaidMemberOrder(@Valid @RequestBody PaidMemberOrderSaveReqVO createReqVO) {
return success(paidMemberOrderService.createPaidMemberOrder(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新付费会员订单")
@PreAuthorize("@ss.hasPermission('member:paid-member-order:update')")
public CommonResult<Boolean> updatePaidMemberOrder(@Valid @RequestBody PaidMemberOrderSaveReqVO updateReqVO) {
paidMemberOrderService.updatePaidMemberOrder(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除付费会员订单")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('member:paid-member-order:delete')")
public CommonResult<Boolean> deletePaidMemberOrder(@RequestParam("id") Integer id) {
paidMemberOrderService.deletePaidMemberOrder(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得付费会员订单")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('member:paid-member-order:query')")
public CommonResult<PaidMemberOrderRespVO> getPaidMemberOrder(@RequestParam("id") Integer id) {
PaidMemberOrderDO paidMemberOrder = paidMemberOrderService.getPaidMemberOrder(id);
return success(BeanUtils.toBean(paidMemberOrder, PaidMemberOrderRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得付费会员订单分页")
@PreAuthorize("@ss.hasPermission('member:paid-member-order:query')")
public CommonResult<PageResult<PaidMemberOrderRespVO>> getPaidMemberOrderPage(@Valid PaidMemberOrderPageReqVO pageReqVO) {
PageResult<PaidMemberOrderDO> pageResult = paidMemberOrderService.getPaidMemberOrderPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, PaidMemberOrderRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出付费会员订单 Excel")
@PreAuthorize("@ss.hasPermission('member:paid-member-order:export')")
@ApiAccessLog(operateType = EXPORT)
public void exportPaidMemberOrderExcel(@Valid PaidMemberOrderPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<PaidMemberOrderDO> list = paidMemberOrderService.getPaidMemberOrderPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "付费会员订单.xls", "数据", PaidMemberOrderRespVO.class,
BeanUtils.toBean(list, PaidMemberOrderRespVO.class));
}
}

View File

@ -0,0 +1,73 @@
package cn.iocoder.yudao.module.member.controller.admin.order.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 付费会员订单分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PaidMemberOrderPageReqVO extends PageParam {
@Schema(description = "用户UID", example = "23917")
private Integer uid;
@Schema(description = "订单号")
private String orderNo;
@Schema(description = "付费会员卡ID", example = "8322")
private Integer cardId;
@Schema(description = "会员卡名称", example = "赵六")
private String cardName;
@Schema(description = "0-试用1-期限2-永久", example = "2")
private Integer type;
@Schema(description = "期限天数")
private Integer deadlineDay;
@Schema(description = "会员卡原价", example = "16244")
private BigDecimal originalPrice;
@Schema(description = "会员卡售价", example = "17277")
private BigDecimal price;
@Schema(description = "赠送余额")
private BigDecimal giftBalance;
@Schema(description = "支付方式:weixin,alipay,give,yue", example = "2")
private String payType;
@Schema(description = "支付渠道public-公众号,mini-小程序h5-网页支付,wechatIos-微信IoswechatAndroid-微信Android,alipay-支付包alipayApp-支付宝App,give-平台赠送,yue-余额支付")
private String payChannel;
@Schema(description = "是否支付", example = "29374")
private Boolean paid;
@Schema(description = "支付时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] payTime;
@Schema(description = "支付服务方订单号")
private String outTradeNo;
@Schema(description = "会员卡到期时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] cardExpirationTime;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "是否微信小程序发货")
private Boolean isWechatShipping;
}

View File

@ -0,0 +1,88 @@
package cn.iocoder.yudao.module.member.controller.admin.order.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 付费会员订单 Response VO")
@Data
@ExcelIgnoreUnannotated
public class PaidMemberOrderRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30259")
@ExcelProperty("编号")
private Integer id;
@Schema(description = "用户UID", example = "23917")
@ExcelProperty("用户UID")
private Integer uid;
@Schema(description = "订单号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("订单号")
private String orderNo;
@Schema(description = "付费会员卡ID", example = "8322")
@ExcelProperty("付费会员卡ID")
private Integer cardId;
@Schema(description = "会员卡名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@ExcelProperty("会员卡名称")
private String cardName;
@Schema(description = "0-试用1-期限2-永久", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("0-试用1-期限2-永久")
private Integer type;
@Schema(description = "期限天数", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("期限天数")
private Integer deadlineDay;
@Schema(description = "会员卡原价", requiredMode = Schema.RequiredMode.REQUIRED, example = "16244")
@ExcelProperty("会员卡原价")
private BigDecimal originalPrice;
@Schema(description = "会员卡售价", requiredMode = Schema.RequiredMode.REQUIRED, example = "17277")
@ExcelProperty("会员卡售价")
private BigDecimal price;
@Schema(description = "赠送余额", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("赠送余额")
private BigDecimal giftBalance;
@Schema(description = "支付方式:weixin,alipay,give,yue", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@ExcelProperty("支付方式:weixin,alipay,give,yue")
private String payType;
@Schema(description = "支付渠道public-公众号,mini-小程序h5-网页支付,wechatIos-微信IoswechatAndroid-微信Android,alipay-支付包alipayApp-支付宝App,give-平台赠送,yue-余额支付", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("支付渠道public-公众号,mini-小程序h5-网页支付,wechatIos-微信IoswechatAndroid-微信Android,alipay-支付包alipayApp-支付宝App,give-平台赠送,yue-余额支付")
private String payChannel;
@Schema(description = "是否支付", requiredMode = Schema.RequiredMode.REQUIRED, example = "29374")
@ExcelProperty("是否支付")
private Boolean paid;
@Schema(description = "支付时间")
@ExcelProperty("支付时间")
private LocalDateTime payTime;
@Schema(description = "支付服务方订单号", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("支付服务方订单号")
private String outTradeNo;
@Schema(description = "会员卡到期时间")
@ExcelProperty("会员卡到期时间")
private LocalDateTime cardExpirationTime;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "是否微信小程序发货", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("是否微信小程序发货")
private Boolean isWechatShipping;
}

View File

@ -0,0 +1,78 @@
package cn.iocoder.yudao.module.member.controller.admin.order.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 付费会员订单新增/修改 Request VO")
@Data
public class PaidMemberOrderSaveReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "30259")
private Integer id;
@Schema(description = "用户UID", example = "23917")
private Integer uid;
@Schema(description = "订单号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "订单号不能为空")
private String orderNo;
@Schema(description = "付费会员卡ID", example = "8322")
private Integer cardId;
@Schema(description = "会员卡名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@NotEmpty(message = "会员卡名称不能为空")
private String cardName;
@Schema(description = "0-试用1-期限2-永久", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotNull(message = "0-试用1-期限2-永久不能为空")
private Integer type;
@Schema(description = "期限天数", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "期限天数不能为空")
private Integer deadlineDay;
@Schema(description = "会员卡原价", requiredMode = Schema.RequiredMode.REQUIRED, example = "16244")
@NotNull(message = "会员卡原价不能为空")
private BigDecimal originalPrice;
@Schema(description = "会员卡售价", requiredMode = Schema.RequiredMode.REQUIRED, example = "17277")
@NotNull(message = "会员卡售价不能为空")
private BigDecimal price;
@Schema(description = "赠送余额", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "赠送余额不能为空")
private BigDecimal giftBalance;
@Schema(description = "支付方式:weixin,alipay,give,yue", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
@NotEmpty(message = "支付方式:weixin,alipay,give,yue不能为空")
private String payType;
@Schema(description = "支付渠道public-公众号,mini-小程序h5-网页支付,wechatIos-微信IoswechatAndroid-微信Android,alipay-支付包alipayApp-支付宝App,give-平台赠送,yue-余额支付", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "支付渠道public-公众号,mini-小程序h5-网页支付,wechatIos-微信IoswechatAndroid-微信Android,alipay-支付包alipayApp-支付宝App,give-平台赠送,yue-余额支付不能为空")
private String payChannel;
@Schema(description = "是否支付", requiredMode = Schema.RequiredMode.REQUIRED, example = "29374")
@NotNull(message = "是否支付不能为空")
private Boolean paid;
@Schema(description = "支付时间")
private LocalDateTime payTime;
@Schema(description = "支付服务方订单号", requiredMode = Schema.RequiredMode.REQUIRED)
@NotEmpty(message = "支付服务方订单号不能为空")
private String outTradeNo;
@Schema(description = "会员卡到期时间")
private LocalDateTime cardExpirationTime;
@Schema(description = "是否微信小程序发货", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "是否微信小程序发货不能为空")
private Boolean isWechatShipping;
}

View File

@ -0,0 +1,74 @@
package cn.iocoder.yudao.module.member.controller.admin.user.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 会员新增/修改 Request VO")
@Data
public class PaidMemberUserSaveReqVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "12209")
private Long id;
@Schema(description = "手机号")
private String mobile;
@Schema(description = "密码")
private String password;
@Schema(description = "状态", example = "1")
private Integer status;
@Schema(description = "注册 IP")
private String registerIp;
@Schema(description = "注册终端")
private Integer registerTerminal;
@Schema(description = "最后登录IP")
private String loginIp;
@Schema(description = "最后登录时间")
private LocalDateTime loginDate;
@Schema(description = "用户昵称", example = "赵六")
private String nickname;
@Schema(description = "头像")
private String avatar;
@Schema(description = "真实名字", example = "张三")
private String name;
@Schema(description = "性别")
private Integer sex;
@Schema(description = "出生日期")
private LocalDateTime birthday;
@Schema(description = "所在地", example = "18998")
private Integer areaId;
@Schema(description = "用户备注")
private String mark;
@Schema(description = "积分")
private Integer point;
@Schema(description = "用户标签编号列表,以逗号分隔")
private String tagIds;
@Schema(description = "等级编号", example = "27166")
private Long levelId;
@Schema(description = "经验")
private Integer experience;
@Schema(description = "用户分组编号", example = "27409")
private Long groupId;
}

View File

@ -5,16 +5,20 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.member.controller.app.type.vo.AppMemberCardTypeRespVO;
import cn.iocoder.yudao.module.member.convert.type.MemberCardTypeConvert;
import cn.iocoder.yudao.module.member.dal.dataobject.membercardtype.PaidMemberCardTypeDO;
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.user.MemberUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.lang.reflect.Member;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
@Tag(name = "用户 App - 会员卡类型")
@RestController
@ -25,13 +29,19 @@ public class AppMemberCardTypeController {
@Resource
private PaidMemberCardTypeService cardService;
@Resource
private MemberUserService userService;
@GetMapping("/list")
@Operation(summary = "获得会员卡类型列表")
public CommonResult<List<AppMemberCardTypeRespVO>> list() {
/** 查询状态为启用的会员卡类型列表*/
List<PaidMemberCardTypeDO> list = cardService.getCardTypeList(CommonStatusEnum.DISABLE.getStatus());
/** 查询状态为启用的会员卡类型列表 */
MemberUserDO memberUserDO = userService.getUser(getLoginUserId());
/** 根据用户查询是否有试用会员的类型列表 */
List<PaidMemberCardTypeDO> list = cardService.getCardTypeList(memberUserDO.getActivate());
return success(MemberCardTypeConvert.INSTANCE.convertList(list));
}
}

View File

@ -0,0 +1,18 @@
package cn.iocoder.yudao.module.member.convert.order;
import cn.iocoder.yudao.module.member.dal.dataobject.order.PaidMemberOrderDO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Mapper
public interface PaidMemberOrderConvert {
PaidMemberOrderConvert INSTANCE = Mappers.getMapper(PaidMemberOrderConvert.class);
PaidMemberOrderDO convert(Long uid, String cardName, Integer type,
String payChannel, BigDecimal price, LocalDateTime payTime);
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.member.dal.dataobject.membercardtype;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
@ -21,7 +22,7 @@ import java.math.BigDecimal;
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PaidMemberCardTypeDO extends BaseDO {
public class PaidMemberCardTypeDO extends TenantBaseDO {
/**
* id

View File

@ -0,0 +1,107 @@
package cn.iocoder.yudao.module.member.dal.dataobject.order;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 付费会员订单 DO
*
* @author 管理员
*/
@TableName("paid_member_order")
@KeySequence("paid_member_order_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PaidMemberOrderDO extends TenantBaseDO {
/**
* 编号
*/
@TableId
private Integer id;
/**
* 用户UID
*/
private Integer uid;
/**
* 订单号
*/
private String orderNo;
/**
* 付费会员卡ID
*/
private Integer cardId;
/**
* 会员卡名称
*/
private String cardName;
/**
* 0-试用1-期限2-永久
*/
private Integer type;
/**
* 期限天数
*/
private Integer deadlineDay;
/**
* 会员卡原价
*/
private BigDecimal originalPrice;
/**
* 会员卡售价
*/
private BigDecimal price;
/**
* 赠送余额
*/
private BigDecimal giftBalance;
/**
* 支付方式:weixin,alipay,give,yue
*/
private String payType;
/**
* 支付渠道public-公众号,mini-小程序h5-网页支付,wechatIos-微信IoswechatAndroid-微信Android,alipay-支付包alipayApp-支付宝App,give-平台赠送,yue-余额支付
*/
private String payChannel;
/**
* 是否支付
*/
private Boolean paid;
/**
* 支付时间
*/
private LocalDateTime payTime;
/**
* 支付服务方订单号
*/
private String outTradeNo;
/**
* 会员卡到期时间
*/
private LocalDateTime cardExpirationTime;
/**
* 是否微信小程序发货
*/
private Boolean isWechatShipping;
/**
* 支付订单编号
*
* 关联 {@link PayOrderDO#getId()}
*/
private Long payOrderId;
}

View File

@ -143,7 +143,7 @@ public class MemberUserDO extends TenantBaseDO {
private Long groupId;
/**
* 是否绑过卡
* 是否绑过卡,是否开通过试用会员
*/
private Integer activate;

View File

@ -0,0 +1,110 @@
package cn.iocoder.yudao.module.member.dal.dataobject.user;
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
/**
* 会员 DO
*
* @author 管理员
*/
@TableName("paid_member_user")
@KeySequence("paid_member_user_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class PaidMemberUserDO extends TenantBaseDO {
/**
* 编号
*/
@TableId
private Long id;
/**
* 手机号
*/
private String mobile;
/**
* 密码
*/
private String password;
/**
* 状态
*/
private Integer status;
/**
* 注册 IP
*/
private String registerIp;
/**
* 注册终端
*/
private Integer registerTerminal;
/**
* 最后登录IP
*/
private String loginIp;
/**
* 最后登录时间
*/
private LocalDateTime loginDate;
/**
* 用户昵称
*/
private String nickname;
/**
* 头像
*/
private String avatar;
/**
* 真实名字
*/
private String name;
/**
* 性别
*/
private Integer sex;
/**
* 出生日期
*/
private LocalDateTime birthday;
/**
* 所在地
*/
private Integer areaId;
/**
* 用户备注
*/
private String mark;
/**
* 积分
*/
private Integer point;
/**
* 用户标签编号列表,以逗号分隔
*/
private String tagIds;
/**
* 等级编号
*/
private Long levelId;
/**
* 经验
*/
private Integer experience;
/**
* 用户分组编号
*/
private Long groupId;
}

View File

@ -31,4 +31,11 @@ public interface PaidMemberCardTypeMapper extends BaseMapperX<PaidMemberCardType
default List<PaidMemberCardTypeDO> selectListByStatus(Integer status){
return selectList(PaidMemberCardTypeDO::getStatus, status);
}
default List<PaidMemberCardTypeDO> selectListByIsActivate(Integer status){
return selectList(new LambdaQueryWrapperX<PaidMemberCardTypeDO>()
.eqIfPresent(PaidMemberCardTypeDO::getStatus,status)
.neIfPresent(PaidMemberCardTypeDO::getName,"试用")
.orderByAsc(PaidMemberCardTypeDO::getId));
}
}

View File

@ -0,0 +1,42 @@
package cn.iocoder.yudao.module.member.dal.mysql.order;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.order.PaidMemberOrderDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.order.vo.*;
/**
* 付费会员订单 Mapper
*
* @author 管理员
*/
@Mapper
public interface PaidMemberOrderMapper extends BaseMapperX<PaidMemberOrderDO> {
default PageResult<PaidMemberOrderDO> selectPage(PaidMemberOrderPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PaidMemberOrderDO>()
.eqIfPresent(PaidMemberOrderDO::getUid, reqVO.getUid())
.eqIfPresent(PaidMemberOrderDO::getOrderNo, reqVO.getOrderNo())
.eqIfPresent(PaidMemberOrderDO::getCardId, reqVO.getCardId())
.likeIfPresent(PaidMemberOrderDO::getCardName, reqVO.getCardName())
.eqIfPresent(PaidMemberOrderDO::getType, reqVO.getType())
.eqIfPresent(PaidMemberOrderDO::getDeadlineDay, reqVO.getDeadlineDay())
.eqIfPresent(PaidMemberOrderDO::getOriginalPrice, reqVO.getOriginalPrice())
.eqIfPresent(PaidMemberOrderDO::getPrice, reqVO.getPrice())
.eqIfPresent(PaidMemberOrderDO::getGiftBalance, reqVO.getGiftBalance())
.eqIfPresent(PaidMemberOrderDO::getPayType, reqVO.getPayType())
.eqIfPresent(PaidMemberOrderDO::getPayChannel, reqVO.getPayChannel())
.eqIfPresent(PaidMemberOrderDO::getPaid, reqVO.getPaid())
.betweenIfPresent(PaidMemberOrderDO::getPayTime, reqVO.getPayTime())
.eqIfPresent(PaidMemberOrderDO::getOutTradeNo, reqVO.getOutTradeNo())
.betweenIfPresent(PaidMemberOrderDO::getCardExpirationTime, reqVO.getCardExpirationTime())
.betweenIfPresent(PaidMemberOrderDO::getCreateTime, reqVO.getCreateTime())
.eqIfPresent(PaidMemberOrderDO::getIsWechatShipping, reqVO.getIsWechatShipping())
.orderByDesc(PaidMemberOrderDO::getId));
}
}

View File

@ -0,0 +1,19 @@
package cn.iocoder.yudao.module.member.dal.mysql.user;
import java.util.*;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.member.dal.dataobject.user.PaidMemberUserDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.*;
/**
* 会员 Mapper
*
* @author 管理员
*/
@Mapper
public interface PaidMemberUserMapper extends BaseMapperX<PaidMemberUserDO> {
}

View File

@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo.PaidMem
import cn.iocoder.yudao.module.member.dal.dataobject.membercardtype.PaidMemberCardTypeDO;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;
/**
@ -53,6 +54,18 @@ public interface PaidMemberCardTypeService {
*/
PageResult<PaidMemberCardTypeDO> getcardPage(PaidMemberCardTypePageReqVO pageReqVO);
List<PaidMemberCardTypeDO> getCardTypeList (Integer status);
/**
* 根据用户是否使用试用会员
* 查询会员类型列表
* @param activate
* @return
*/
List<PaidMemberCardTypeDO> getCardTypeList (Integer activate);
/**
* 根据发起的订单type确定试用有效期永久的会员卡
* @param type
* @return
*/
PaidMemberCardTypeDO selectMemberCardType(Integer type, BigDecimal price);
}

View File

@ -2,18 +2,24 @@ package cn.iocoder.yudao.module.member.service.membercardtype;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo.PaidMemberCardTypePageReqVO;
import cn.iocoder.yudao.module.member.controller.admin.membercardtype.vo.PaidMemberCardTypeSaveReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.membercardtype.PaidMemberCardTypeDO;
import cn.iocoder.yudao.module.member.dal.dataobject.user.PaidMemberUserDO;
import cn.iocoder.yudao.module.member.dal.mysql.membercardtype.PaidMemberCardTypeMapper;
import cn.iocoder.yudao.module.member.service.user.PaidMemberUserService;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.CARD_NOT_EXISTS;
/**
@ -28,6 +34,9 @@ public class PaidMemberCardTypeServiceImpl implements PaidMemberCardTypeService
@Resource
private PaidMemberCardTypeMapper cardMapper;
@Resource
private PaidMemberUserService paidMemberUserService01;
@Override
public Long createcard(PaidMemberCardTypeSaveReqVO createReqVO) {
// 插入
@ -71,10 +80,37 @@ public class PaidMemberCardTypeServiceImpl implements PaidMemberCardTypeService
}
@Override
public List<PaidMemberCardTypeDO> getCardTypeList(Integer status) {
List<PaidMemberCardTypeDO> list = cardMapper.selectListByStatus(status);
public List<PaidMemberCardTypeDO> getCardTypeList(Integer activate) {
List<PaidMemberCardTypeDO> list = new ArrayList<>();
Integer status = 1;
if(activate == 1){
list = cardMapper.selectListByIsActivate(status);
}
else {
list = cardMapper.selectListByStatus(status);
}
return list;
}
@Override
public PaidMemberCardTypeDO selectMemberCardType(Integer type, BigDecimal price) {
PaidMemberCardTypeDO paidMemberCardTypeDO = new PaidMemberCardTypeDO();
PaidMemberUserDO paidMemberUserDO = paidMemberUserService01.getMemberUser(getLoginUserId());
if(type == 0){
paidMemberCardTypeDO =cardMapper.selectOne(new LambdaQueryWrapperX<PaidMemberCardTypeDO>()
.eqIfPresent(PaidMemberCardTypeDO::getName,"试用"));
} else if (type == 1 && paidMemberUserDO == null) {
paidMemberCardTypeDO =cardMapper.selectOne(new LambdaQueryWrapperX<PaidMemberCardTypeDO>()
.eqIfPresent(PaidMemberCardTypeDO::getOriginalPrice,price));
} else if (type == 1 && paidMemberUserDO != null) {
paidMemberCardTypeDO =cardMapper.selectOne(new LambdaQueryWrapperX<PaidMemberCardTypeDO>()
.eqIfPresent(PaidMemberCardTypeDO::getSpecialPrice,price));
} else if (type == 2) {
paidMemberCardTypeDO =cardMapper.selectOne(new LambdaQueryWrapperX<PaidMemberCardTypeDO>()
.eqIfPresent(PaidMemberCardTypeDO::getName,"永久"));
}
return paidMemberCardTypeDO;
}
}

View File

@ -0,0 +1,80 @@
package cn.iocoder.yudao.module.member.service.order;
import java.math.BigDecimal;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.member.controller.admin.order.vo.*;
import cn.iocoder.yudao.module.member.dal.dataobject.order.PaidMemberOrderDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* 付费会员订单 Service 接口
*
* @author 管理员
*/
public interface PaidMemberOrderService {
/**
* 创建付费会员订单
*
* @param createReqVO 创建信息
* @return 编号
*/
Integer createPaidMemberOrder(@Valid PaidMemberOrderSaveReqVO createReqVO);
/**
* 更新付费会员订单
*
* @param updateReqVO 更新信息
*/
void updatePaidMemberOrder(@Valid PaidMemberOrderSaveReqVO updateReqVO);
/**
* 删除付费会员订单
*
* @param id 编号
*/
void deletePaidMemberOrder(Integer id);
/**
* 获得付费会员订单
*
* @param id 编号
* @return 付费会员订单
*/
PaidMemberOrderDO getPaidMemberOrder(Integer id);
/**
* 获得付费会员订单分页
*
* @param pageReqVO 分页查询
* @return 付费会员订单分页
*/
PageResult<PaidMemberOrderDO> getPaidMemberOrderPage(PaidMemberOrderPageReqVO pageReqVO);
/**
* 创建会员支付记录
*
* @return 编号
*/
BigDecimal createMemberRecord(Long userId, Integer userType, String userIp,
BigDecimal price, Integer type);
/**
* 创建付费会员订单
*
* @param createReqVO 创建信息
* @return 编号
*/
void createOrder(@Valid PaidMemberOrderDO createReqVO);
/**
* 更新付费会员订单
*
* @param updateReqVO 更新信息
*/
void updateOrder(@Valid PaidMemberOrderDO updateReqVO);
}

View File

@ -0,0 +1,118 @@
package cn.iocoder.yudao.module.member.service.order;
import cn.iocoder.yudao.module.member.dal.dataobject.membercardtype.PaidMemberCardTypeDO;
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.user.PaidMemberUserService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.*;
import cn.iocoder.yudao.module.member.controller.admin.order.vo.*;
import cn.iocoder.yudao.module.member.dal.dataobject.order.PaidMemberOrderDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.dal.mysql.order.PaidMemberOrderMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
/**
* 付费会员订单 Service 实现类
*
* @author 管理员
*/
@Service
@Validated
public class PaidMemberOrderServiceImpl implements PaidMemberOrderService {
@Resource
private PaidMemberOrderMapper paidMemberOrderMapper;
@Resource
private PaidMemberCardTypeService typeService;
@Resource
private PaidMemberUserService paidMemberUserService;
@Override
public Integer createPaidMemberOrder(PaidMemberOrderSaveReqVO createReqVO) {
// 插入
PaidMemberOrderDO paidMemberOrder = BeanUtils.toBean(createReqVO, PaidMemberOrderDO.class);
paidMemberOrderMapper.insert(paidMemberOrder);
// 返回
return paidMemberOrder.getId();
}
@Override
public void updatePaidMemberOrder(PaidMemberOrderSaveReqVO updateReqVO) {
// 校验存在
validatePaidMemberOrderExists(updateReqVO.getId());
// 更新
PaidMemberOrderDO updateObj = BeanUtils.toBean(updateReqVO, PaidMemberOrderDO.class);
paidMemberOrderMapper.updateById(updateObj);
}
@Override
public void deletePaidMemberOrder(Integer id) {
// 校验存在
validatePaidMemberOrderExists(id);
// 删除
paidMemberOrderMapper.deleteById(id);
}
private void validatePaidMemberOrderExists(Integer id) {
if (paidMemberOrderMapper.selectById(id) == null) {
throw exception(PAID_MEMBER_ORDER_NOT_EXISTS);
}
}
@Override
public PaidMemberOrderDO getPaidMemberOrder(Integer id) {
return paidMemberOrderMapper.selectById(id);
}
@Override
public PageResult<PaidMemberOrderDO> getPaidMemberOrderPage(PaidMemberOrderPageReqVO pageReqVO) {
return paidMemberOrderMapper.selectPage(pageReqVO);
}
@Override
public BigDecimal createMemberRecord(Long userId, Integer userType, String userIp,
BigDecimal price, Integer type) {
//定义一个支付金额
BigDecimal payPrice = null;
BigDecimal gitBalance = BigDecimal.valueOf(0);//赠送余额权益规则还未定
if(Objects.nonNull(type)){
PaidMemberUserDO paidMemberUserDO = paidMemberUserService.getMemberUser(getLoginUserId());
PaidMemberCardTypeDO paidMemberCardTypeDO =typeService.selectMemberCardType(type,price);
if(paidMemberCardTypeDO.getName().equals("试用")){
payPrice = paidMemberCardTypeDO.getOriginalPrice();
}else if (paidMemberUserDO != null){
payPrice = paidMemberCardTypeDO.getSpecialPrice();
}
else {
payPrice = paidMemberCardTypeDO.getOriginalPrice();
}
}
return payPrice;
}
@Override
public void createOrder(PaidMemberOrderDO createReqVO) {
paidMemberOrderMapper.insert(createReqVO);
}
@Override
public void updateOrder(PaidMemberOrderDO updateReqVO) {
paidMemberOrderMapper.updateById(updateReqVO);
}
}

View File

@ -188,4 +188,5 @@ public interface MemberUserService {
boolean updateUserPoint(Long userId, Integer point);
void updateUserDo(MemberUserDO user);
}

View File

@ -0,0 +1,58 @@
package cn.iocoder.yudao.module.member.service.user;
import java.util.*;
import javax.validation.*;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.*;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.member.dal.dataobject.user.PaidMemberUserDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
/**
* 会员 Service 接口
*
* @author 管理员
*/
public interface PaidMemberUserService {
/**
* 创建会员
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createMemberUser(@Valid PaidMemberUserSaveReqVO createReqVO);
/**
* 更新会员
*
* @param updateReqVO 更新信息
*/
void updateMemberUser(@Valid PaidMemberUserSaveReqVO updateReqVO);
/**
* 删除会员
*
* @param id 编号
*/
void deleteMemberUser(Long id);
/**
* 获得会员
*
* @param id 编号
* @return 会员
*/
PaidMemberUserDO getMemberUser(Long id);
// /**
// * 获得会员分页
// *
// * @param pageReqVO 分页查询
// * @return 会员分页
// */
// PageResult<PaidMemberUserDO> getMemberUserPage(PaidMemberUserPageReqVO pageReqVO);
}

View File

@ -0,0 +1,76 @@
package cn.iocoder.yudao.module.member.service.user;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import cn.iocoder.yudao.module.member.controller.admin.user.vo.*;
import cn.iocoder.yudao.module.member.dal.dataobject.user.PaidMemberUserDO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.member.dal.mysql.user.PaidMemberUserMapper;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
/**
* 会员 Service 实现类
*
* @author 管理员
*/
@Service
@Validated
public class PaidMemberUserServiceImpl implements PaidMemberUserService {
@Resource
private PaidMemberUserMapper paidMemberUserMapper;
@Override
public Long createMemberUser(PaidMemberUserSaveReqVO createReqVO) {
// 插入
PaidMemberUserDO memberUser = BeanUtils.toBean(createReqVO, PaidMemberUserDO.class);
paidMemberUserMapper.insert(memberUser);
// 返回
return memberUser.getId();
}
@Override
public void updateMemberUser(PaidMemberUserSaveReqVO updateReqVO) {
// 校验存在
validateMemberUserExists(updateReqVO.getId());
// 更新
PaidMemberUserDO updateObj = BeanUtils.toBean(updateReqVO, PaidMemberUserDO.class);
paidMemberUserMapper.updateById(updateObj);
}
@Override
public void deleteMemberUser(Long id) {
// 校验存在
validateMemberUserExists(id);
// 删除
paidMemberUserMapper.deleteById(id);
}
private void validateMemberUserExists(Long id) {
if (paidMemberUserMapper.selectById(id) == null) {
throw exception(MEMBER_USER_NOT_EXISTS);
}
}
@Override
public PaidMemberUserDO getMemberUser(Long id) {
return paidMemberUserMapper.selectById(id);
}
// @Override
// public PageResult<PaidMemberUserDO> getMemberUserPage(PaidMemberUserPageReqVO pageReqVO) {
// return memberUserMapper.selectPage(pageReqVO);
// }
}

View File

@ -70,6 +70,18 @@
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-member-api</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-member-biz</artifactId>
<version>${revision}</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,132 @@
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.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.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.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.wallet.vo.transaction.AppPayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO;
import cn.iocoder.yudao.module.pay.convert.member.PayMemberOrderConvert;
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.Duration;
import java.time.LocalDateTime;
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;
@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;
@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){
memberUserDO.setActivate(CommonStatusEnum.DISABLE.getStatus());
BeanUtils.copyProperties(memberUserDO,paidMemberUserSaveReqVO);
// 若不是会员则往会员表插入数据
if(memberUserService1.getMemberUser(memberUserDO.getId()) == null){
memberUserService1.createMemberUser(paidMemberUserSaveReqVO);
}
}
//判断会员类型
if(reqVO.getCardName().equals("试用")){
reqVO.setType(0);
} else if (reqVO.getCardName().equals("永久")) {
reqVO.setType(2);
}else {
reqVO.setType(1);
}
BigDecimal payPrice = paidMemberOrderService1.createMemberRecord(getLoginUserId(),
getLoginUserType(),getClientIP(),reqVO.getPrice(),reqVO.getType());
BigDecimal p = payPrice.multiply(new BigDecimal("100"));
Integer payPriceInt = p.intValue();
PayWalletDO walletDO = memberWalletService.getWalletByUserIdAndType(getLoginUserId(),getLoginUserType());
LocalDateTime payTime = LocalDateTime.now();
PaidMemberOrderDO paidMemberOrderDO = PaidMemberOrderConvert.INSTANCE.convert(getLoginUserId(),
reqVO.getCardName(),reqVO.getType(),reqVO.getPayChannel(),reqVO.getPrice(),payTime);
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.createOrder(paidMemberOrderDO);
return success(PayMemberOrderConvert.INSTANCE.convert(paidMemberOrderDO));
// BigDecimal payPrice = paidMemberOrderService1.createMemberRecord(getLoginUserId(),
// getLoginUserType(),getClientIP(),reqVO.getPrice(),reqVO.getType());
// BigDecimal p = payPrice.multiply(new BigDecimal("100"));
// Integer payPriceInt = p.intValue();
// PayWalletDO walletDO = memberWalletService.getWalletByUserIdAndType(getLoginUserId(),getLoginUserType());
// LocalDateTime payTime = LocalDateTime.now();
// PaidMemberOrderDO paidMemberOrderDO = PaidMemberOrderConvert.INSTANCE.convert(getLoginUserId(),
// reqVO.getCardName(),reqVO.getType(),reqVO.getPayChannel(),reqVO.getPrice(),payTime);
//
// 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);
// paidMemberOrderService1.createOrder(paidMemberOrderDO);
// return success(PayMemberOrderConvert.INSTANCE.convert(paidMemberOrderDO));
}
}

View File

@ -0,0 +1,29 @@
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-微信IoswechatAndroid-微信Android,alipay-支付包alipayApp-支付宝App,give-平台赠送")
private String payChannel;
}

View File

@ -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;
@Schema(description = "用户 APP - 会员支付 Resp VO")
@Data
public class AppPaidMemberOrderRespVO {
@Schema(description = "会员支付编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "o100")
private Long payOrderId;
}

View File

@ -0,0 +1,15 @@
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.dal.dataobject.order.PaidMemberOrderDO;
import cn.iocoder.yudao.module.pay.controller.app.member.vo.AppPaidMemberOrderRespVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
@Mapper
public interface PayMemberOrderConvert {
PayMemberOrderConvert INSTANCE = Mappers.getMapper(PayMemberOrderConvert.class);
AppPaidMemberOrderRespVO convert(PaidMemberOrderDO bean);
}

View File

@ -98,6 +98,16 @@ public interface PayWalletService {
*/
void unfreezePrice(Long id, Integer price);
/**
* 获取钱包信息
* <p>
* 如果不存在则创建钱包由于用户注册时候不会创建钱包
*
* @param userId 用户编号
* @param userType 用户类型
*/
PayWalletDO getWalletByUserIdAndType(Long userId, Integer userType);
// /**
// * 修改钱包余额后台操作
// * @param reqVo

View File

@ -226,6 +226,15 @@ public class PayWalletServiceImpl implements PayWalletService {
}
}
@Override
public PayWalletDO getWalletByUserIdAndType(Long userId, Integer userType) {
PayWalletDO wallet = walletMapper.selectByUserIdAndType(userId, userType);
if (wallet == null) {
throw exception(WALLET_NOT_FOUND);
}
return wallet;
}
// @Override
// public void updateWallet(PayWalletUserBalanceVo reqVo) {
// // 如果