169 changed files with 7686 additions and 246 deletions
@ -0,0 +1,23 @@ |
|||
package com.bnyer.img.api.dto; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/31 |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
@ApiModel("会员vip查询类") |
|||
public class QueryUserVipDto { |
|||
@ApiModelProperty(value="主键Id") |
|||
private Long id; |
|||
|
|||
@ApiModelProperty(value="vip客户端类型:10用户-抖音 20用户-快手 30用户-微信 40艺术家-微信") |
|||
private Integer userClientType; |
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.bnyer.img.api.factory; |
|||
|
|||
import com.bnyer.common.core.domain.R; |
|||
import com.bnyer.img.api.dto.QueryUserVipDto; |
|||
import com.bnyer.img.api.remote.RemoteWxMiniService; |
|||
import com.bnyer.img.api.vo.UserVipInfoVo; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.cloud.openfeign.FallbackFactory; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 图文服务降级处理 |
|||
* |
|||
* @author penny |
|||
*/ |
|||
@Component |
|||
public class RemoteWxMiniFallbackFactory implements FallbackFactory<RemoteWxMiniService> |
|||
{ |
|||
private static final Logger log = LoggerFactory.getLogger(RemoteWxMiniFallbackFactory.class); |
|||
|
|||
|
|||
@Override |
|||
public RemoteWxMiniService create(Throwable throwable) { |
|||
log.error("api图文服务调用失败:{}", throwable.getMessage()); |
|||
return new RemoteWxMiniService() { |
|||
@Override |
|||
public R<List<UserVipInfoVo>> queryUserVipList(QueryUserVipDto dto) { |
|||
return R.fail("获取会员信息失败:+"+throwable.getMessage()); |
|||
} |
|||
|
|||
}; |
|||
} |
|||
} |
|||
@ -1,4 +1,4 @@ |
|||
package com.bnyer.img.api; |
|||
package com.bnyer.img.api.remote; |
|||
|
|||
import com.bnyer.common.core.constant.ServiceNameConstants; |
|||
import com.bnyer.common.core.domain.R; |
|||
@ -0,0 +1,27 @@ |
|||
package com.bnyer.img.api.remote; |
|||
|
|||
import com.bnyer.common.core.constant.ServiceNameConstants; |
|||
import com.bnyer.common.core.domain.R; |
|||
import com.bnyer.img.api.dto.QueryUserVipDto; |
|||
import com.bnyer.img.api.factory.RemoteWxMiniFallbackFactory; |
|||
import com.bnyer.img.api.vo.UserVipInfoVo; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
@FeignClient(contextId = "remoteWxMiniService", value = ServiceNameConstants.IMG_SERVICE, fallbackFactory = RemoteWxMiniFallbackFactory.class) |
|||
public interface RemoteWxMiniService { |
|||
|
|||
/** |
|||
* 获取会员列表 |
|||
* @return |
|||
*/ |
|||
@PostMapping(value = "/img/mini/fh/queryUserVipList") |
|||
R<List<UserVipInfoVo>> queryUserVipList(@RequestBody QueryUserVipDto dto); |
|||
} |
|||
@ -0,0 +1,63 @@ |
|||
package com.bnyer.img.api.vo; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
import java.io.Serializable; |
|||
import java.math.BigDecimal; |
|||
|
|||
|
|||
@Getter |
|||
@Setter |
|||
@ApiModel("会员vip响应类") |
|||
public class UserVipInfoVo implements Serializable { |
|||
|
|||
@ApiModelProperty(value="主键Id") |
|||
private Long id; |
|||
|
|||
@ApiModelProperty(value="vip类型id") |
|||
private Long vipTypeId; |
|||
|
|||
@ApiModelProperty(value="vip编码") |
|||
private String vipCode; |
|||
|
|||
@ApiModelProperty(value="vip名称") |
|||
private String vipName; |
|||
|
|||
@ApiModelProperty(value="原价") |
|||
private BigDecimal originPrice; |
|||
|
|||
@ApiModelProperty(value="售价") |
|||
private BigDecimal price; |
|||
|
|||
@ApiModelProperty(value="描述") |
|||
private String description; |
|||
|
|||
@ApiModelProperty(value="热门描述") |
|||
private String hotSignDesc; |
|||
|
|||
@ApiModelProperty(value="排序") |
|||
private Integer sort; |
|||
|
|||
@ApiModelProperty(value="是否到期自动续费(0>否;1->是)") |
|||
private String isDelay; |
|||
|
|||
@ApiModelProperty(value = "用户客户端类型:10用户-抖音 20用户-快手 30用户-微信 40艺术家-微信") |
|||
private Integer userClientType; |
|||
|
|||
@ApiModelProperty(value = "有效时长单位:0天,1周,2月,3季,4年") |
|||
private Integer validTimeUnit; |
|||
|
|||
@ApiModelProperty(value = "有效时长:表示几天、几周、几月、几年") |
|||
private Integer validTimeNum; |
|||
|
|||
@ApiModelProperty(value = "会员类型编码") |
|||
private String vipTypeCode; |
|||
|
|||
@ApiModelProperty(value = "会员类型名称") |
|||
private String vipTypeName; |
|||
|
|||
private static final long serialVersionUID = 1L; |
|||
} |
|||
@ -0,0 +1,26 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<parent> |
|||
<groupId>com.dimensionalnode</groupId> |
|||
<artifactId>bnyer-api</artifactId> |
|||
<version>1.0.0</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<artifactId>bnyer-api-order</artifactId> |
|||
|
|||
<description> |
|||
bnyer-api-order订单服务接口模块 |
|||
</description> |
|||
|
|||
<dependencies> |
|||
<!-- bnyer Common Core--> |
|||
<dependency> |
|||
<groupId>com.dimensionalnode</groupId> |
|||
<artifactId>bnyer-common-core</artifactId> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
</project> |
|||
@ -0,0 +1,23 @@ |
|||
package com.bnyer.order.api.dto; |
|||
|
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/27 |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
@NoArgsConstructor |
|||
public class QueryVipOrderDto implements Serializable { |
|||
|
|||
@ApiModelProperty(value="订单号") |
|||
private String orderNo; |
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.bnyer.order.api.factory; |
|||
|
|||
import com.bnyer.common.core.domain.R; |
|||
import com.bnyer.order.api.dto.QueryVipOrderDto; |
|||
import com.bnyer.order.api.remote.RemoteVipOrderService; |
|||
import com.bnyer.order.api.vo.VipOrderVo; |
|||
import org.slf4j.Logger; |
|||
import org.slf4j.LoggerFactory; |
|||
import org.springframework.cloud.openfeign.FallbackFactory; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/04/03 |
|||
* @description :订单服务:vip订单接口熔断降级 |
|||
*/ |
|||
@Component |
|||
public class RemoteVipOrderFallbackFactory implements FallbackFactory<RemoteVipOrderService> |
|||
{ |
|||
private static final Logger log = LoggerFactory.getLogger(RemoteVipOrderFallbackFactory.class); |
|||
|
|||
|
|||
@Override |
|||
public RemoteVipOrderService create(Throwable throwable) { |
|||
log.error("api订单服务调用失败:{}", throwable.getMessage()); |
|||
return new RemoteVipOrderService() { |
|||
|
|||
@Override |
|||
public R<List<VipOrderVo>> getVipOrderList(QueryVipOrderDto dto) { |
|||
return R.fail("获取会员订单信息失败:+"+throwable.getMessage()); |
|||
} |
|||
}; |
|||
} |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
package com.bnyer.order.api.remote; |
|||
|
|||
import com.bnyer.common.core.constant.ServiceNameConstants; |
|||
import com.bnyer.common.core.domain.R; |
|||
import com.bnyer.order.api.dto.QueryVipOrderDto; |
|||
import com.bnyer.order.api.factory.RemoteVipOrderFallbackFactory; |
|||
import com.bnyer.order.api.vo.VipOrderVo; |
|||
import org.springframework.cloud.openfeign.FeignClient; |
|||
import org.springframework.web.bind.annotation.PostMapping; |
|||
import org.springframework.web.bind.annotation.RequestBody; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/04/03 |
|||
* @description :订单服务:vip订单接口远程调用 |
|||
*/ |
|||
@FeignClient(contextId = "remoteVipOrderService", value = ServiceNameConstants.ORDER_SERVICE, fallbackFactory = RemoteVipOrderFallbackFactory.class) |
|||
public interface RemoteVipOrderService { |
|||
|
|||
/** |
|||
* 获取会员订单信息 |
|||
* @param dto |
|||
* @return |
|||
*/ |
|||
@PostMapping("/getVipOrderList") |
|||
R<List<VipOrderVo>> getVipOrderList(@RequestBody QueryVipOrderDto dto); |
|||
} |
|||
@ -0,0 +1,69 @@ |
|||
package com.bnyer.order.api.vo; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/27 |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
@NoArgsConstructor |
|||
public class VipOrderVo { |
|||
|
|||
@ApiModelProperty(value="主键") |
|||
private Long id; |
|||
|
|||
@ApiModelProperty(value="订单号") |
|||
private String orderNo; |
|||
|
|||
@ApiModelProperty(value="手机号") |
|||
private String phone; |
|||
|
|||
@ApiModelProperty(value="用户id") |
|||
private Long userId; |
|||
|
|||
@ApiModelProperty(value="vip表id") |
|||
private Long vipId; |
|||
|
|||
@ApiModelProperty(value = "vip编码") |
|||
private String vipCode; |
|||
|
|||
@ApiModelProperty(value = "vip名称") |
|||
private String vipName; |
|||
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@ApiModelProperty(value="开始时间") |
|||
private Date startTime; |
|||
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@ApiModelProperty(value="到期时间") |
|||
private Date endTime; |
|||
|
|||
@ApiModelProperty(value = "用户客户端类型:10用户-抖音 20用户-快手 30用户-微信 40艺术家-微信") |
|||
private Integer userClientType; |
|||
|
|||
@ApiModelProperty(value="是否到期自动续费(0>否;1->是)") |
|||
private String isDelay; |
|||
|
|||
@ApiModelProperty(value="时长天数") |
|||
private Integer days; |
|||
|
|||
@ApiModelProperty(value="支付金额") |
|||
private BigDecimal payAmount; |
|||
|
|||
@ApiModelProperty(value = "vip类型名称") |
|||
private String vipTypeName; |
|||
|
|||
@ApiModelProperty(value="支付状态:1000未支付;1001支付成功 ;1002支付失败") |
|||
private Integer payStatus; |
|||
|
|||
} |
|||
@ -0,0 +1,351 @@ |
|||
package com.bnyer.common.core.annotation; |
|||
|
|||
|
|||
import org.apache.commons.lang3.StringUtils; |
|||
|
|||
import javax.validation.Constraint; |
|||
import javax.validation.ConstraintValidator; |
|||
import javax.validation.ConstraintValidatorContext; |
|||
import javax.validation.Payload; |
|||
import java.lang.annotation.Documented; |
|||
import java.lang.annotation.Retention; |
|||
import java.lang.annotation.RetentionPolicy; |
|||
import java.lang.annotation.Target; |
|||
import java.util.regex.Matcher; |
|||
import java.util.regex.Pattern; |
|||
|
|||
import static java.lang.annotation.ElementType.*; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/04/11 |
|||
* @description : |
|||
*/ |
|||
@Target({ METHOD, FIELD, ANNOTATION_TYPE, CONSTRUCTOR, PARAMETER}) |
|||
@Retention(RetentionPolicy.RUNTIME) |
|||
@Documented |
|||
@Constraint(validatedBy = { CustomParamsValidation.CustomParamsValidationImpl.class }) |
|||
public @interface CustomParamsValidation { |
|||
|
|||
/** |
|||
* 预定义的正则表达式 |
|||
*/ |
|||
class Regexp{ |
|||
/** |
|||
* 常规输入框:匹配中文,字母,数字 |
|||
*/ |
|||
private final static String INPUTTXT="^[A-Za-z0-9\u4e00-\u9fa5]*$"; |
|||
|
|||
/** |
|||
* 昵称匹配:匹配中文,字母,数字 下划线 |
|||
*/ |
|||
private final static String NICKNAME="^[A-Za-z0-9_\u4e00-\u9fa5]*$"; |
|||
|
|||
/**********以上public 的正则提供 regexp 属性使用**********/ |
|||
|
|||
/**********以下private 的正则提供 paramType 计算**********/ |
|||
/** |
|||
* 匹配邮箱 |
|||
*/ |
|||
private final static String EMAIL="^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$"; |
|||
/** |
|||
* uuid |
|||
* 格式 |
|||
* {8}-{4}-{4}-{4}-{12} |
|||
* 如 |
|||
* 4cbd6c8b-1111-45f4-b477-a524707aedfd |
|||
*/ |
|||
private static final String UUID="^[a-z0-9]{8}(-[a-z0-9]{4}){3}-[a-z0-9]{12}$"; |
|||
/** |
|||
* yyyy-MM-dd |
|||
*/ |
|||
private static final String DATE = "^[1-9][0-9]{3}-((01|03|05|07|08|10|12)-(0[1-9]|[1-2][0-9]|30|31)|(04|06|09|11)-(0[1-9]|[1-2][0-9]|30)|(02)-(0[1-9]|1[0-9]|2[0-9]))$"; |
|||
/** |
|||
* yyyyMMdd |
|||
*/ |
|||
private static final String DATE2 = "^[1-9][0-9]{3}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|30|31)|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|(02)(0[1-9]|1[0-9]|2[0-9]))$"; |
|||
/** |
|||
* yyyy-MM-dd HH:mm:ss |
|||
*/ |
|||
private static final String DATETIME = "^[1-9][0-9]{3}-((01|03|05|07|08|10|12)-(0[1-9]|[1-2][0-9]|30|31)|(04|06|09|11)-(0[1-9]|[1-2][0-9]|30)|(02)-(0[1-9]|1[0-9]|2[0-9])) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$"; |
|||
/** |
|||
* yyyyMMddHHmmss |
|||
*/ |
|||
private static final String DATETIME2 = "^[1-9][0-9]{3}((01|03|05|07|08|10|12)(0[1-9]|[1-2][0-9]|30|31)|(04|06|09|11)(0[1-9]|[1-2][0-9]|30)|(02)(0[1-9]|1[0-9]|2[0-9]))([01][0-9]|2[0-3])([0-5][0-9])([0-5][0-9])$"; |
|||
/** |
|||
* yyyy-MM-dd HH:mm |
|||
*/ |
|||
private static final String DATETIME3 = "^[1-9][0-9]{3}-((01|03|05|07|08|10|12)-(0[1-9]|[1-2][0-9]|30|31)|(04|06|09|11)-(0[1-9]|[1-2][0-9]|30)|(02)-(0[1-9]|1[0-9]|2[0-9])) ([01][0-9]|2[0-3]):([0-5][0-9])$"; |
|||
|
|||
/** |
|||
* HH:mm:ss |
|||
*/ |
|||
private static final String TIME = "^([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$"; |
|||
/** |
|||
* HHmmss |
|||
*/ |
|||
private static final String TIME2 = "^([01][0-9]|2[0-3])([0-5][0-9])([0-5][0-9])$"; |
|||
|
|||
/** |
|||
* 手机号码 |
|||
*/ |
|||
private static final String MOBILEPHONE="^1\\d{10}$"; |
|||
|
|||
/** |
|||
* 匹配IPV4地址 |
|||
*/ |
|||
private final static String IPV4="((25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))\\.){3}(25[0-5]|2[0-4]\\d|((1\\d{2})|([1-9]?\\d)))"; |
|||
//=============可以在此扩展正则=============
|
|||
|
|||
|
|||
/** |
|||
* 校验正则 |
|||
* @param regexp |
|||
* @param value |
|||
* @return |
|||
*/ |
|||
public static boolean validateRegexp(String regexp,String value){ |
|||
Pattern pattern = Pattern.compile(regexp); |
|||
Matcher matcher = pattern.matcher(value); |
|||
return matcher.matches(); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 预定义的参数类型 |
|||
*/ |
|||
class ParamType { |
|||
//匹配IPV4地址
|
|||
public static final String IPV4 = "ipv4"; |
|||
/** |
|||
* uuid |
|||
*/ |
|||
public static final String UUID="uuid"; |
|||
/** |
|||
* 匹配中文 |
|||
*/ |
|||
public static final String INPUTTXT="inputtxt"; |
|||
/** |
|||
* 匹配中文英文数字下划线 |
|||
*/ |
|||
public static final String NICKNAME="nickname"; |
|||
|
|||
/** |
|||
* 匹配邮箱 |
|||
*/ |
|||
public static final String EMAIL="email"; |
|||
|
|||
/** |
|||
* 手机号码 |
|||
*/ |
|||
public static final String MOBILEPHONE="mobilephone"; |
|||
|
|||
/** |
|||
* yyyy-MM-dd |
|||
*/ |
|||
public static final String DATE = "yyyy-MM-dd"; |
|||
/** |
|||
* yyyyMMdd |
|||
*/ |
|||
public static final String DATE2 = "yyyyMMdd"; |
|||
/** |
|||
* yyyy-MM-dd HH:mm:ss |
|||
*/ |
|||
public static final String DATETIME = "yyyy-MM-dd HH:mm:ss"; |
|||
/** |
|||
* yyyyMMddHHmmss |
|||
*/ |
|||
public static final String DATETIME2 = "yyyyMMddHHmmss"; |
|||
/** |
|||
* yyyy-MM-dd HH:mm |
|||
*/ |
|||
public static final String DATETIME3 = "yyyy-MM-dd HH:mm"; |
|||
|
|||
/** |
|||
* HH:mm:ss |
|||
*/ |
|||
public static final String TIME = "HH:mm:ss"; |
|||
/** |
|||
* HHmmss |
|||
*/ |
|||
public static final String TIME2 = "HHmmss"; |
|||
/** |
|||
* 参数类型校验 |
|||
* |
|||
* @param paramType |
|||
* @param value |
|||
* @return |
|||
*/ |
|||
public static boolean validateParamType(String paramType, String value) { |
|||
boolean flag = false; |
|||
|
|||
switch (paramType) { |
|||
case ParamType.IPV4: |
|||
value = value.replaceAll(" ",""); |
|||
flag = Regexp.validateRegexp(Regexp.IPV4, value); |
|||
break; |
|||
case ParamType.MOBILEPHONE: flag = Regexp.validateRegexp(Regexp.MOBILEPHONE, value);break; |
|||
case ParamType.NICKNAME: flag = Regexp.validateRegexp(Regexp.NICKNAME, value);break; |
|||
case ParamType.EMAIL: flag = Regexp.validateRegexp(Regexp.EMAIL, value);break; |
|||
case ParamType.UUID : flag = Regexp.validateRegexp(Regexp.UUID, value);break; |
|||
case ParamType.INPUTTXT : flag = Regexp.validateRegexp(Regexp.INPUTTXT, value);break; |
|||
case ParamType.DATE : flag = validateDateParamType(ParamType.DATE, value);break; |
|||
case ParamType.DATE2 : flag = validateDateParamType(ParamType.DATE2, value);break; |
|||
case ParamType.DATETIME : flag = validateDateParamType(ParamType.DATETIME, value);break; |
|||
case ParamType.DATETIME2 : flag = validateDateParamType(ParamType.DATETIME2, value);break; |
|||
case ParamType.DATETIME3 : flag = validateDateParamType(ParamType.DATETIME3, value);break; |
|||
case ParamType.TIME : flag = validateDateParamType(ParamType.TIME, value);break; |
|||
case ParamType.TIME2 : flag = validateDateParamType(ParamType.TIME2, value);break; |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
/** |
|||
* dateFormat 属性配置,配置的值 不是内置值,验证无法通过 |
|||
* @param dateFormat |
|||
* @param value |
|||
* @return |
|||
*/ |
|||
private static boolean validateDateParamType(String dateFormat,String value){ |
|||
String regexp = null; |
|||
|
|||
if(DATE.equals(dateFormat)){ |
|||
regexp = Regexp.DATE; |
|||
}else if(DATE2.equals(dateFormat)){ |
|||
regexp = Regexp.DATE2; |
|||
}else if(DATETIME.equals(dateFormat)){ |
|||
regexp = Regexp.DATETIME; |
|||
}else if(DATETIME2.equals(dateFormat)){ |
|||
regexp = Regexp.DATETIME2; |
|||
}else if(DATETIME3.equals(dateFormat)){ |
|||
regexp = Regexp.DATETIME3; |
|||
}else if(TIME.equals(dateFormat)){ |
|||
regexp = Regexp.TIME; |
|||
}else if(TIME2.equals(dateFormat)){ |
|||
regexp = Regexp.TIME2; |
|||
} |
|||
|
|||
if(regexp!=null){ |
|||
boolean flag = Regexp.validateRegexp(regexp, value); |
|||
//时间不用做2月29日瑞年判断
|
|||
if(TIME.equals(dateFormat) || TIME2.equals(dateFormat)){ |
|||
return flag; |
|||
} |
|||
if(flag){ |
|||
//月份和日期部分
|
|||
String monthAndDay = ""; |
|||
//2月29日常量
|
|||
String monthAndDayConstant = ""; |
|||
Integer year = null; |
|||
switch (dateFormat) { |
|||
case DATE: |
|||
case DATETIME: |
|||
case DATETIME3: |
|||
monthAndDay = StringUtils.substring(value, 5, 10); |
|||
monthAndDayConstant = "02-29"; |
|||
year = Integer.valueOf(StringUtils.substring(value, 0, 4)); |
|||
break; |
|||
case DATE2: |
|||
case DATETIME2: |
|||
monthAndDay = StringUtils.substring(value, 4, 8); |
|||
monthAndDayConstant = "0229"; |
|||
year = Integer.valueOf(StringUtils.substring(value, 0, 4)); |
|||
break; |
|||
} |
|||
//2月29日判断是否是润年,非润年没有2月29日
|
|||
if(monthAndDay.equals(monthAndDayConstant)){ |
|||
if(!isLeapYear(year)){ |
|||
flag = false; |
|||
} |
|||
} |
|||
} |
|||
return flag; |
|||
} |
|||
|
|||
return false; |
|||
} |
|||
|
|||
/** |
|||
* 判断是否是润年 |
|||
* @param year |
|||
* @return |
|||
*/ |
|||
private static boolean isLeapYear(int year){ |
|||
return year % 400 == 0 || (year % 4 == 0 && year % 100 != 0); |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 预定义Range |
|||
* |
|||
*/ |
|||
class Range{ |
|||
private static boolean contains(String range,String value){ |
|||
boolean flag = false; |
|||
if(StringUtils.isEmpty(value)){ |
|||
return false; |
|||
} |
|||
if(StringUtils.isNotEmpty(range)){ |
|||
String[] arr = range.split("\\|"); |
|||
for (String string : arr) { |
|||
if(value.equals(string)){ |
|||
flag = true; |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
return flag; |
|||
} |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 参数类型,最优先推荐使用的属性 |
|||
* @return |
|||
*/ |
|||
String paramType() default ""; |
|||
|
|||
/** |
|||
* 限制字符串或者数字 可选项,用 | 分割 ,如 00|10|20 |
|||
* @return |
|||
*/ |
|||
String range() default ""; |
|||
|
|||
String message() default "参数基本校验不通过错误:注意格式及长度"; |
|||
|
|||
Class<?>[]groups() default {}; |
|||
|
|||
Class<? extends Payload>[]payload() default {}; |
|||
|
|||
class CustomParamsValidationImpl implements ConstraintValidator<CustomParamsValidation,String> { |
|||
|
|||
String paramType; |
|||
|
|||
String range; |
|||
|
|||
|
|||
@Override |
|||
public void initialize(CustomParamsValidation constraintAnnotation) { |
|||
paramType = constraintAnnotation.paramType(); |
|||
range = constraintAnnotation.range(); |
|||
} |
|||
|
|||
@Override |
|||
public boolean isValid(String value, ConstraintValidatorContext context) { |
|||
if(StringUtils.isNotEmpty(value)){ |
|||
//根据参数类型校验正则
|
|||
if(StringUtils.isNotEmpty(paramType)){ |
|||
return ParamType.validateParamType(paramType, value); |
|||
} |
|||
//校验参数范围
|
|||
if (StringUtils.isNotEmpty(range)){ |
|||
return Range.contains(range, value); |
|||
} |
|||
} |
|||
return true; |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,77 @@ |
|||
package com.bnyer.common.core.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import java.util.Date; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
/** |
|||
* 支付宝支付配置表 |
|||
*/ |
|||
@ApiModel(value="com-bnyer-common-core-domain-PayAlipayConfig") |
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
@TableName(value = "pay_alipay_config") |
|||
public class AlipayConfig extends BaseDomain { |
|||
|
|||
/** |
|||
* appid |
|||
*/ |
|||
@TableField(value = "appid") |
|||
@ApiModelProperty(value="appid") |
|||
private String appid; |
|||
|
|||
/** |
|||
* app私钥 |
|||
*/ |
|||
@TableField(value = "app_private_key") |
|||
@ApiModelProperty(value="app私钥") |
|||
private String appPrivateKey; |
|||
|
|||
/** |
|||
* 阿里公钥 |
|||
*/ |
|||
@TableField(value = "alipay_public_key") |
|||
@ApiModelProperty(value="阿里公钥") |
|||
private String alipayPublicKey; |
|||
|
|||
/** |
|||
* RSA/RSA2 |
|||
*/ |
|||
@TableField(value = "key_type") |
|||
@ApiModelProperty(value="RSA/RSA2") |
|||
private String keyType; |
|||
|
|||
/** |
|||
* 回调地址url |
|||
*/ |
|||
@TableField(value = "backurl") |
|||
@ApiModelProperty(value="回调地址url") |
|||
private String backurl; |
|||
|
|||
/** |
|||
* 帐号状态(0正常 1停用) |
|||
*/ |
|||
@TableField(value = "status") |
|||
@ApiModelProperty(value="帐号状态(0正常 1停用)") |
|||
private String status; |
|||
|
|||
@TableField(value = "remark") |
|||
@ApiModelProperty(value="") |
|||
private String remark; |
|||
} |
|||
@ -0,0 +1,69 @@ |
|||
package com.bnyer.common.core.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import java.util.Date; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
/** |
|||
* 抖音支付配置表 |
|||
*/ |
|||
@ApiModel(value="com-bnyer-common-core-domain-PayDypayConfig") |
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
@TableName(value = "pay_dypay_config") |
|||
public class DypayConfig extends BaseDomain { |
|||
/** |
|||
* appid |
|||
*/ |
|||
@TableField(value = "appid") |
|||
@ApiModelProperty(value="appid") |
|||
private String appid; |
|||
|
|||
/** |
|||
* 秘钥 |
|||
*/ |
|||
@TableField(value = "salt") |
|||
@ApiModelProperty(value="秘钥") |
|||
private String salt; |
|||
|
|||
/** |
|||
* 令牌 |
|||
*/ |
|||
@TableField(value = "token") |
|||
@ApiModelProperty(value="令牌") |
|||
private String token; |
|||
|
|||
/** |
|||
* 回调地址url |
|||
*/ |
|||
@TableField(value = "backurl") |
|||
@ApiModelProperty(value="回调地址url") |
|||
private String backurl; |
|||
|
|||
/** |
|||
* 帐号状态(0正常 1停用) |
|||
*/ |
|||
@TableField(value = "status") |
|||
@ApiModelProperty(value="帐号状态(0正常 1停用)") |
|||
private String status; |
|||
|
|||
@TableField(value = "remark") |
|||
@ApiModelProperty(value="") |
|||
private String remark; |
|||
} |
|||
@ -0,0 +1,62 @@ |
|||
package com.bnyer.common.core.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import java.util.Date; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
/** |
|||
* 快手支付配置表 |
|||
*/ |
|||
@ApiModel(value="com-bnyer-common-core-domain-PayKspayConfig") |
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
@TableName(value = "pay_kspay_config") |
|||
public class KspayConfig extends BaseDomain { |
|||
/** |
|||
* appid |
|||
*/ |
|||
@TableField(value = "appid") |
|||
@ApiModelProperty(value="appid") |
|||
private String appid; |
|||
|
|||
/** |
|||
* 秘钥 |
|||
*/ |
|||
@TableField(value = "secret") |
|||
@ApiModelProperty(value="秘钥") |
|||
private String secret; |
|||
|
|||
/** |
|||
* 回调地址url |
|||
*/ |
|||
@TableField(value = "backurl") |
|||
@ApiModelProperty(value="回调地址url") |
|||
private String backurl; |
|||
|
|||
/** |
|||
* 帐号状态(0正常 1停用) |
|||
*/ |
|||
@TableField(value = "status") |
|||
@ApiModelProperty(value="帐号状态(0正常 1停用)") |
|||
private String status; |
|||
|
|||
@TableField(value = "remark") |
|||
@ApiModelProperty(value="") |
|||
private String remark; |
|||
} |
|||
@ -0,0 +1,180 @@ |
|||
package com.bnyer.common.core.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
/** |
|||
* 付款信息表 |
|||
*/ |
|||
@ApiModel(value="com-bnyer-common-core-domain-PayPayInfo") |
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
@TableName(value = "pay_pay_info") |
|||
public class PayInfo extends BaseDomain { |
|||
|
|||
/** |
|||
* 支付单号(内部生成) |
|||
*/ |
|||
@TableField(value = "pay_id") |
|||
@ApiModelProperty(value="支付单号(内部生成)") |
|||
private String payId; |
|||
|
|||
/** |
|||
* 业务主订单号:关联内部业务订单表 |
|||
*/ |
|||
@TableField(value = "order_no") |
|||
@ApiModelProperty(value="业务主订单号:关联内部业务订单表") |
|||
private String orderNo; |
|||
|
|||
/** |
|||
* 支付状态:1000未支付;1001支付成功 ;1002支付失败 |
|||
*/ |
|||
@TableField(value = "pay_status") |
|||
@ApiModelProperty(value="支付状态:1000未支付;1001支付成功 ;1002支付失败") |
|||
private Integer payStatus; |
|||
|
|||
/** |
|||
* 单笔对账状态:1001 对账成功 |
|||
*/ |
|||
@TableField(value = "single_status") |
|||
@ApiModelProperty(value="单笔对账状态:1001 对账成功") |
|||
private Integer singleStatus; |
|||
|
|||
/** |
|||
* 单笔对账时间 |
|||
*/ |
|||
@TableField(value = "single_time") |
|||
@ApiModelProperty(value="单笔对账时间") |
|||
private Date singleTime; |
|||
|
|||
|
|||
/** |
|||
* 支付类型:wxpay/alipay/kspay/dypay |
|||
*/ |
|||
@TableField(value = "pay_type") |
|||
@ApiModelProperty(value="支付类型:wxpay/alipay/kspay/dypay") |
|||
private String payType; |
|||
|
|||
/** |
|||
* 支付渠道 |
|||
*/ |
|||
@TableField(value = "pay_channel") |
|||
@ApiModelProperty(value="支付渠道:wxpay/alipay") |
|||
private String payChannel; |
|||
|
|||
/** |
|||
* 交易类型:JSAPI等 |
|||
*/ |
|||
@TableField(value = "trade_type") |
|||
@ApiModelProperty(value = "交易类型:JSAPI等") |
|||
private String tradeType; |
|||
|
|||
/** |
|||
* 支付单号(第三方返回) |
|||
*/ |
|||
@TableField(value = "pay_no") |
|||
@ApiModelProperty(value="支付单号(第三方返回)") |
|||
private String payNo; |
|||
|
|||
/** |
|||
* 用户侧订单号(第三方返回) |
|||
*/ |
|||
@TableField(value = "trade_no") |
|||
@ApiModelProperty(value="用户侧订单号(第三方返回)") |
|||
private String tradeNo; |
|||
|
|||
/** |
|||
* appid |
|||
*/ |
|||
@TableField(value = "appid") |
|||
@ApiModelProperty(value="appid") |
|||
private String appid; |
|||
|
|||
/** |
|||
* 商品标题 |
|||
*/ |
|||
@TableField(value = "goods_subject") |
|||
@ApiModelProperty(value="商品标题") |
|||
private String goodsSubject; |
|||
|
|||
/** |
|||
* 商品描述 |
|||
*/ |
|||
@TableField(value = "goods_desc") |
|||
@ApiModelProperty(value="商品描述") |
|||
private String goodsDesc; |
|||
|
|||
/** |
|||
* 支付金额,单位元 |
|||
*/ |
|||
@TableField(value = "pay_amount") |
|||
@ApiModelProperty(value="支付金额,单位元") |
|||
private BigDecimal payAmount; |
|||
|
|||
/** |
|||
* 支付时间 |
|||
*/ |
|||
@TableField(value = "pay_time") |
|||
@ApiModelProperty(value="支付时间") |
|||
private Date payTime; |
|||
|
|||
/** |
|||
* 支付场景:1.会员充值 |
|||
*/ |
|||
@TableField(value = "scene_code") |
|||
@ApiModelProperty(value="支付场景:1.会员充值") |
|||
private Integer sceneCode; |
|||
|
|||
/** |
|||
* 用户ip |
|||
*/ |
|||
@TableField(value = "ip") |
|||
@ApiModelProperty(value="用户ip") |
|||
private String ip; |
|||
|
|||
/** |
|||
* 调用第三方下单返回 |
|||
*/ |
|||
@TableField(value = "third_code") |
|||
@ApiModelProperty(value="调用第三方下单返回") |
|||
private String thirdCode; |
|||
|
|||
/** |
|||
* 调用第三方下单返回 |
|||
*/ |
|||
@TableField(value = "third_msg") |
|||
@ApiModelProperty(value="调用第三方下单返回") |
|||
private String thirdMsg; |
|||
|
|||
/** |
|||
* 调用第三方下单返回 |
|||
*/ |
|||
@TableField(value = "third_no") |
|||
@ApiModelProperty(value="调用第三方下单返回") |
|||
private String thirdNo; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
@TableField(value = "remark") |
|||
@ApiModelProperty(value="备注") |
|||
private String remark; |
|||
} |
|||
@ -0,0 +1,168 @@ |
|||
package com.bnyer.common.core.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
/** |
|||
* 会员订单表 |
|||
*/ |
|||
@ApiModel(value="com-bnyer-common-core-domain-OrderVipOrder") |
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
@TableName(value = "order_vip_order") |
|||
public class VipOrder extends BaseDomain { |
|||
|
|||
/** |
|||
* 订单号 |
|||
*/ |
|||
@TableField(value = "order_no") |
|||
@ApiModelProperty(value="订单号") |
|||
private String orderNo; |
|||
|
|||
/** |
|||
* 用户手机号 |
|||
*/ |
|||
@TableField(value = "phone") |
|||
@ApiModelProperty(value="用户手机号") |
|||
private String phone; |
|||
|
|||
/** |
|||
* 用户id |
|||
*/ |
|||
@TableField(value = "user_id") |
|||
@ApiModelProperty(value="用户id") |
|||
private Long userId; |
|||
|
|||
/** |
|||
* vip主键Id |
|||
*/ |
|||
@TableField(value = "vip_id") |
|||
@ApiModelProperty(value="vip主键Id") |
|||
private Long vipId; |
|||
|
|||
/** |
|||
* vip编码 |
|||
*/ |
|||
@TableField(value = "vip_code") |
|||
@ApiModelProperty(value="vip编码") |
|||
private String vipCode; |
|||
|
|||
/** |
|||
* vip名称 |
|||
*/ |
|||
@TableField(value = "vip_name") |
|||
@ApiModelProperty(value="vip名称") |
|||
private String vipName; |
|||
|
|||
/** |
|||
* 支付金额,单位元 |
|||
*/ |
|||
@TableField(value = "pay_amount") |
|||
@ApiModelProperty(value="支付金额,单位元") |
|||
private BigDecimal payAmount; |
|||
|
|||
/** |
|||
* 是否到期自动续费(0>否;1->是) |
|||
*/ |
|||
@TableField(value = "is_delay") |
|||
@ApiModelProperty(value="是否到期自动续费(0>否;1->是)") |
|||
private String isDelay; |
|||
|
|||
/** |
|||
* 时长天数 |
|||
*/ |
|||
@TableField(value = "days") |
|||
@ApiModelProperty(value="时长天数") |
|||
private Integer days; |
|||
|
|||
/** |
|||
* 开始时间 |
|||
*/ |
|||
@TableField(value = "start_time") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@ApiModelProperty(value="开始时间") |
|||
private Date startTime; |
|||
|
|||
/** |
|||
* 到期时间 |
|||
*/ |
|||
@TableField(value = "end_time") |
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@ApiModelProperty(value="到期时间") |
|||
private Date endTime; |
|||
|
|||
/** |
|||
* 订单状态:0未处理;1成功;2失败 |
|||
*/ |
|||
@TableField(value = "order_status") |
|||
@ApiModelProperty(value="订单状态:0未处理;1成功;2失败") |
|||
private Integer orderStatus; |
|||
|
|||
/** |
|||
* 订单关闭原因:0超时未支付; 1买家取消 |
|||
*/ |
|||
@TableField(value = "close_type") |
|||
@ApiModelProperty(value="订单关闭原因:0超时未支付; 1买家取消") |
|||
private Integer closeType; |
|||
|
|||
/** |
|||
* 支付时间 |
|||
*/ |
|||
@TableField(value = "pay_time") |
|||
@ApiModelProperty(value="支付时间") |
|||
private Date payTime; |
|||
|
|||
/** |
|||
* 取消时间 |
|||
*/ |
|||
@TableField(value = "cancel_time") |
|||
@ApiModelProperty(value="取消时间") |
|||
private Date cancelTime; |
|||
|
|||
/** |
|||
* 用户客户端类型:10用户-抖音 20用户-快手 30用户-微信 40艺术家-微信 |
|||
*/ |
|||
@TableField(value = "user_client_type") |
|||
@ApiModelProperty(value = "用户客户端类型:10用户-抖音 20用户-快手 30用户-微信 40艺术家-微信") |
|||
private Integer userClientType; |
|||
|
|||
/** |
|||
* vip类型名称 |
|||
*/ |
|||
@TableField(value = "vip_type_name") |
|||
@ApiModelProperty(value = "vip类型名称") |
|||
private String vipTypeName; |
|||
|
|||
/** |
|||
* 备注 |
|||
*/ |
|||
@TableField(value = "remark") |
|||
@ApiModelProperty(value="备注") |
|||
private String remark; |
|||
|
|||
/** |
|||
* 支付状态:1000未支付;1001支付成功 ;1002支付失败 |
|||
*/ |
|||
@TableField(value = "pay_status") |
|||
@ApiModelProperty(value="支付状态:1000未支付;1001支付成功 ;1002支付失败") |
|||
private Integer payStatus; |
|||
} |
|||
@ -0,0 +1,83 @@ |
|||
package com.bnyer.common.core.domain; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableField; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.baomidou.mybatisplus.annotation.TableName; |
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import java.util.Date; |
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
import lombok.ToString; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
/** |
|||
* 微信支付配置表 |
|||
*/ |
|||
@ApiModel(value="com-bnyer-common-core-domain-PayWxpayConfig") |
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
@TableName(value = "pay_wxpay_config") |
|||
public class WxpayConfig extends BaseDomain { |
|||
/** |
|||
* 主键 |
|||
*/ |
|||
@TableId(value = "id", type = IdType.AUTO) |
|||
@ApiModelProperty(value="主键") |
|||
private Long id; |
|||
|
|||
/** |
|||
* APP|JSAPI|MWEB|MINIPROGRAM 支付 |
|||
*/ |
|||
@TableField(value = "trade_type") |
|||
@ApiModelProperty(value="APP|JSAPI|MWEB|MINIPROGRAM 支付") |
|||
private String tradeType; |
|||
|
|||
/** |
|||
* appid |
|||
*/ |
|||
@TableField(value = "appid") |
|||
@ApiModelProperty(value="appid") |
|||
private String appid; |
|||
|
|||
/** |
|||
* 商户号 |
|||
*/ |
|||
@TableField(value = "mchid") |
|||
@ApiModelProperty(value="商户号") |
|||
private String mchid; |
|||
|
|||
/** |
|||
* 回调地址url |
|||
*/ |
|||
@TableField(value = "backurl") |
|||
@ApiModelProperty(value="回调地址url") |
|||
private String backurl; |
|||
|
|||
/** |
|||
* 密钥 |
|||
*/ |
|||
@TableField(value = "key") |
|||
@ApiModelProperty(value="密钥") |
|||
private String key; |
|||
|
|||
/** |
|||
* 帐号状态(0正常 1停用) |
|||
*/ |
|||
@TableField(value = "status") |
|||
@ApiModelProperty(value="帐号状态(0正常 1停用)") |
|||
private String status; |
|||
|
|||
@TableField(value = "remark") |
|||
@ApiModelProperty(value="") |
|||
private String remark; |
|||
} |
|||
@ -0,0 +1,44 @@ |
|||
package com.bnyer.common.core.dto; |
|||
|
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.*; |
|||
|
|||
import java.util.Date; |
|||
|
|||
@Getter |
|||
@Setter |
|||
@ToString |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class AddUserVipRecordDto { |
|||
|
|||
@ApiModelProperty(value="订单号") |
|||
private String orderNo; |
|||
|
|||
@ApiModelProperty(value="用户id") |
|||
private Long userId; |
|||
|
|||
@ApiModelProperty(value="用户手机号") |
|||
private String phone; |
|||
|
|||
@ApiModelProperty(value="vip表id") |
|||
private Long vipId; |
|||
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@ApiModelProperty(value="开始时间") |
|||
private Date startTime; |
|||
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@ApiModelProperty(value="到期时间") |
|||
private Date endTime; |
|||
|
|||
@ApiModelProperty(value="vip名称") |
|||
private String vipName; |
|||
|
|||
@ApiModelProperty(value = "vip类型名称") |
|||
private String vipTypeName; |
|||
|
|||
@ApiModelProperty(value = "用户客户端类型:10用户-抖音 20用户-快手 30用户-微信 40艺术家-微信") |
|||
private Integer userClientType; |
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package com.bnyer.common.core.dto; |
|||
|
|||
import io.swagger.annotations.ApiModel; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Getter; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/31 |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
@ApiModel("会员vip查询类") |
|||
public class QueryUserVipDto { |
|||
@ApiModelProperty(value="主键Id") |
|||
private Long id; |
|||
|
|||
@ApiModelProperty(value="vip客户端类型:10用户-抖音 20用户-快手 30用户-微信 40艺术家-微信") |
|||
private Integer userClientType; |
|||
|
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
package com.bnyer.common.core.enums; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
import java.util.Arrays; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum EnumPayStatus { |
|||
|
|||
NO_PAY(1000,"未支付"), |
|||
SUCCESS(1001,"已支付"), |
|||
FAILS(1002,"支付失败"), |
|||
; |
|||
|
|||
private final int status; |
|||
|
|||
private final String name; |
|||
|
|||
public static EnumPayStatus getEnumPayStatusByStatus(int status) { |
|||
return Arrays.stream(values()) |
|||
.filter(payStatus -> payStatus.getStatus() == status) |
|||
.findFirst().orElseThrow(() -> new SecurityException("status 未匹配上对应的支付状态")); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,42 @@ |
|||
package com.bnyer.common.core.enums; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.Objects; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum EnumPayType { |
|||
|
|||
WX_PAY("wxpay","微信支付"), |
|||
ALI_PAY("alipay","支付宝支付"), |
|||
DY_PAY("dypay","抖音支付"), |
|||
KS_PAY("kspay","快手支付"), |
|||
; |
|||
|
|||
private final String type; |
|||
|
|||
private final String name; |
|||
|
|||
public static String getName(String type) { |
|||
for (EnumPayType s : EnumPayType.values()) { |
|||
if (Objects.equals(type, s.getType())) { |
|||
return s.getName(); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public static EnumPayType getEnumPayTypeByType(String type) { |
|||
return Arrays.stream(values()) |
|||
.filter(payType -> Objects.equals(payType.getType(), type)) |
|||
.findFirst().orElseThrow(() -> new SecurityException("type 未匹配上对应的支付方式")); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,38 @@ |
|||
package com.bnyer.common.core.enums; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
import java.util.Arrays; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum EnumSceneCode { |
|||
|
|||
VIP_RECHARGE(1,"会员充值"), |
|||
UNKNOWN(-1,"未知"), |
|||
; |
|||
|
|||
private final int sceneCode; |
|||
|
|||
private final String name; |
|||
|
|||
public static String getSceneCodeName(int sceneCode) { |
|||
for (EnumSceneCode s : EnumSceneCode.values()) { |
|||
if (sceneCode == s.getSceneCode()) { |
|||
return s.getName(); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public static EnumSceneCode getSceneCodeByCode(int code) { |
|||
return Arrays.stream(values()) |
|||
.filter(sceneCode -> sceneCode.getSceneCode() == code) |
|||
.findFirst().orElse(EnumSceneCode.UNKNOWN); |
|||
} |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.bnyer.common.core.enums; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
import java.util.Arrays; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/04/23 |
|||
* @description :时间单位 |
|||
*/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum EnumTimeUnit { |
|||
|
|||
DAY(0,"天"), |
|||
WEEK(1,"周"), |
|||
MONTH(2,"月"), |
|||
QUARTER(3,"季"), |
|||
YEAR(4,"年"), |
|||
HOURS(5,"时"), |
|||
MINUTE(6,"分"), |
|||
SECONDS(7,"秒"), |
|||
; |
|||
|
|||
private final int unit; |
|||
private final String name; |
|||
|
|||
public static EnumTimeUnit getEnumTimeUnitByUnit(int unit) { |
|||
return Arrays.stream(values()) |
|||
.filter(vipTimeUnit -> unit == vipTimeUnit.getUnit()) |
|||
.findFirst().orElseThrow(() -> new SecurityException("unit 未匹配上对应的时间单位")); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,34 @@ |
|||
package com.bnyer.common.core.enums; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum EnumUserClientType { |
|||
|
|||
DU(10,"DU","抖音用户"), |
|||
KU(20,"KU","快手用户"), |
|||
WU(30,"WU","微信用户"), |
|||
WY(40,"WY","微信艺术家"), |
|||
; |
|||
|
|||
private final int type; |
|||
|
|||
private final String code; |
|||
|
|||
private final String desc; |
|||
|
|||
public static String getCodeByType(int type) { |
|||
for (EnumUserClientType s : EnumUserClientType.values()) { |
|||
if (type == s.type) { |
|||
return s.getCode(); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
|||
@ -0,0 +1,41 @@ |
|||
package com.bnyer.common.core.enums; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.Objects; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum EnumVipType { |
|||
|
|||
IMG_VIP("img","下图会员"), |
|||
VIDEO_VIP("video","视频会员"), |
|||
AI_VIP("ai","ai会员"), |
|||
UNKNOWN("unknown","未知"), |
|||
; |
|||
|
|||
private final String code; |
|||
|
|||
private final String name; |
|||
|
|||
public static String getNameByCode(String code) { |
|||
for (EnumVipType s : EnumVipType.values()) { |
|||
if (Objects.equals(code, s.code)) { |
|||
return s.getName(); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public static EnumVipType getVipTypeByCode(String code) { |
|||
return Arrays.stream(values()) |
|||
.filter(vipCategory -> Objects.equals(vipCategory.getCode(), code)) |
|||
.findFirst().orElse(EnumVipType.UNKNOWN); |
|||
} |
|||
} |
|||
@ -0,0 +1,73 @@ |
|||
package com.bnyer.common.core.enums; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/28 |
|||
* @description : |
|||
*/ |
|||
public enum ResponseEnum { |
|||
|
|||
//======================系统异常========================,
|
|||
SERVER_ERROR(500, "系统繁忙,请稍候重试!"), |
|||
PARAM_ERROR(400, "参数异常!"), |
|||
NOT_EXIST(110001, "查询为空"), |
|||
PAY_CONFIG_ERROR(110002, "支付配置未启用或未配置!"), |
|||
|
|||
|
|||
//======================订单异常========================
|
|||
|
|||
/** |
|||
* 订单已过期,当前端看到该状态码的时候,提示订单信息已过期,请重新确认后提交,此时用户点击确定,前端刷新页面。 |
|||
*/ |
|||
ORDER_EXPIRED(210001, "订单已过期"), |
|||
|
|||
/** |
|||
* 请勿重复提交订单, |
|||
* 1.当前端遇到该异常时,说明前端防多次点击没做好 |
|||
* 2.提示用户 订单已发生改变,请勿重复下单 |
|||
*/ |
|||
REPEAT_ORDER(210002,"请勿重复提交订单"), |
|||
|
|||
|
|||
|
|||
//======================第三方接口调用异常========================
|
|||
PAY_FAILS(220001,"支付失败,请稍后重试"), |
|||
ORDER_QUERY_FAILS(220002,"订单查询失败,请稍后重试"), |
|||
|
|||
; |
|||
|
|||
|
|||
private final int code; |
|||
|
|||
private final String msg; |
|||
|
|||
public int getCode() { |
|||
return code; |
|||
} |
|||
|
|||
public String getMsg() { |
|||
return msg; |
|||
} |
|||
|
|||
ResponseEnum(int code, String msg) { |
|||
this.code = code; |
|||
this.msg = msg; |
|||
} |
|||
|
|||
@Override |
|||
public String toString() { |
|||
return "ResponseEnum{" + |
|||
"code=" + code + |
|||
", msg='" + msg + '\'' + |
|||
'}'; |
|||
} |
|||
|
|||
public static String getCodeMsg(int code) { |
|||
for (ResponseEnum s : ResponseEnum.values()) { |
|||
if (code == s.getCode()) { |
|||
return s.getMsg(); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
|||
@ -0,0 +1,30 @@ |
|||
package com.bnyer.common.core.utils; |
|||
|
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Date; |
|||
import java.util.Random; |
|||
|
|||
public class OrderUtil { |
|||
|
|||
/** |
|||
* 生成流水(不超过32位) |
|||
* |
|||
* @frontStr 费用类型 RV=充值会员 |
|||
* @return 2费用类型+14时间+2客户端类型+11userId+3随机位 |
|||
*/ |
|||
public static String getOrderNo(String frontStr, Date curTime, String userClientType, String userId) { |
|||
SimpleDateFormat simple = new SimpleDateFormat("yyyyMMddHHmmss"); |
|||
String ms = simple.format(curTime); |
|||
|
|||
Random rand = new Random(); |
|||
StringBuilder strRand = new StringBuilder(String.valueOf(rand.nextInt(100))); |
|||
while (strRand.length() < 3) { |
|||
strRand.insert(0, "0"); |
|||
} |
|||
return frontStr+userClientType + ms + userId+ strRand; |
|||
} |
|||
|
|||
public static void main(String[] args) { |
|||
System.out.println(getOrderNo("RV",new Date(),"DU","12345678910")); |
|||
} |
|||
} |
|||
@ -0,0 +1,203 @@ |
|||
package com.bnyer.common.core.utils.bean; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.ArrayUtils; |
|||
import org.springframework.beans.BeanUtils; |
|||
import org.springframework.beans.BeanWrapper; |
|||
import org.springframework.beans.BeanWrapperImpl; |
|||
import org.springframework.util.CollectionUtils; |
|||
|
|||
import java.beans.BeanInfo; |
|||
import java.beans.Introspector; |
|||
import java.beans.PropertyDescriptor; |
|||
import java.lang.reflect.*; |
|||
import java.util.*; |
|||
|
|||
@Slf4j |
|||
public class EntityConvertUtil { |
|||
|
|||
/** |
|||
* 数组集合转化为指定对象集合 |
|||
* 指定的实体对象必须包含所以字段的构造方法,数组的元素的顺序将和构造方法顺序和类型一一对应 |
|||
* |
|||
* @param list 集合 |
|||
* @param clazz c |
|||
* @param <T> 类型 |
|||
* @return List<T> |
|||
* @description 用于jpa查询自定义vo用的 |
|||
*/ |
|||
public static <T> List<T> castEntity(List<Object[]> list, Class<T> clazz) { |
|||
List<T> returnList = new ArrayList<>(); |
|||
if (list.size() == 0) { |
|||
return returnList; |
|||
} |
|||
Class[] c2 = null; |
|||
Constructor[] constructors = clazz.getConstructors(); |
|||
for (Constructor constructor : constructors) { |
|||
Class[] tClass = constructor.getParameterTypes(); |
|||
if (tClass.length == list.get(0).length) { |
|||
c2 = tClass; |
|||
break; |
|||
} |
|||
} |
|||
//构造方法实例化对象
|
|||
for (Object[] o : list) { |
|||
Constructor<T> constructor = null; |
|||
try { |
|||
constructor = clazz.getConstructor(c2); |
|||
} catch (NoSuchMethodException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
try { |
|||
assert constructor != null; |
|||
returnList.add(constructor.newInstance(o)); |
|||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) { |
|||
e.printStackTrace(); |
|||
} |
|||
} |
|||
|
|||
return returnList; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @param object 要强转的对象 , entityClass 强转后的类型 |
|||
*/ |
|||
public static <T> T convertBean(Object object, Class<T> entityClass) { |
|||
if (null == object) { |
|||
return null; |
|||
} |
|||
return JSON.parseObject(JSON.toJSONString(object), entityClass); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @param object 要转话的对象 |
|||
*/ |
|||
public static Map<?, ?> objectToMap(Object object) { |
|||
return convertBean(object, Map.class); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @param map map集合, t 对象 |
|||
*/ |
|||
public static <T> T mapToObject(Map<String, Object> map, Class<T> beanClass) throws InstantiationException, IllegalAccessException, InvocationTargetException { |
|||
T t = beanClass.newInstance(); |
|||
Field[] declaredFields = t.getClass().getDeclaredFields(); |
|||
for(Field field:declaredFields){ |
|||
int mod = field.getModifiers(); |
|||
if(Modifier.isStatic(mod) || Modifier.isFinal(mod)){ |
|||
continue; |
|||
} |
|||
field.setAccessible(true); |
|||
field.set(t, map.get(field.getName())); |
|||
} |
|||
return t; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* @param source 资源对象, target 目标对象, ignoreProperties 赋值new String[]{} |
|||
* @return T target对象 |
|||
*/ |
|||
public static <T> T copy(Object source, Class<T> target, String... ignoreProperties) { |
|||
T targetInstance = null; |
|||
try { |
|||
targetInstance = target.newInstance(); |
|||
} catch (Exception e) { |
|||
e.printStackTrace(); |
|||
} |
|||
if (ArrayUtils.isEmpty(ignoreProperties)) { |
|||
assert targetInstance != null; |
|||
BeanUtils.copyProperties(source, targetInstance); |
|||
} else { |
|||
assert targetInstance != null; |
|||
BeanUtils.copyProperties(source, targetInstance, ignoreProperties); |
|||
} |
|||
return targetInstance; |
|||
|
|||
} |
|||
|
|||
/** |
|||
* 从List<A> copy到List<B> |
|||
* @param list List<B> |
|||
* @param clazz B |
|||
* @return List<B> |
|||
*/ |
|||
public static <T> List<T> copy(List<?> list,Class<T> clazz){ |
|||
String oldOb = JSON.toJSONString(list); |
|||
return JSON.parseArray(oldOb, clazz); |
|||
} |
|||
|
|||
public static <T, E> List<T> copyList(List<E> list, Class<T> target, String... ignoreProperties) { |
|||
List<T> targetList = new ArrayList<>(); |
|||
if (CollectionUtils.isEmpty(list)) { |
|||
return targetList; |
|||
} |
|||
for (E e : list) { |
|||
targetList.add(copy(e, target, ignoreProperties)); |
|||
} |
|||
return targetList; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 功能描述: Bean --> Map 1: 利用Introspector和PropertyDescriptor 将Bean --> Map |
|||
* |
|||
*/ |
|||
public static Map<String, String> transBean2Map(Object obj) { |
|||
if (obj == null) { |
|||
return null; |
|||
} |
|||
Map<String, String> map = new HashMap<String, String>(); |
|||
try { |
|||
BeanInfo beanInfo = Introspector.getBeanInfo(obj.getClass()); |
|||
PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); |
|||
for (PropertyDescriptor property : propertyDescriptors) { |
|||
String key = property.getName(); |
|||
// 过滤class属性
|
|||
if (!"class".equals(key)) { |
|||
// 得到property对应的getter方法
|
|||
Method getter = property.getReadMethod(); |
|||
Object value = getter.invoke(obj); |
|||
map.put(key, value.toString()); |
|||
} |
|||
} |
|||
} catch (Exception e) { |
|||
log.error("transBean2Map Error " + e); |
|||
} |
|||
return map; |
|||
} |
|||
|
|||
/** |
|||
* 属性复制,跳过为null的值 |
|||
* @param source 提供值的obj |
|||
* @param target 接收值的obj |
|||
* @param <T> |
|||
* @return target |
|||
*/ |
|||
public static <T> T copyNotNullProperties(T source, T target){ |
|||
BeanUtils.copyProperties(source, target, getNullPropertyNames(source)); |
|||
return target; |
|||
} |
|||
|
|||
/** |
|||
* 获取值为Null的字段名称 |
|||
* @param source |
|||
* @return |
|||
*/ |
|||
public static String[] getNullPropertyNames (Object source) { |
|||
final BeanWrapper src = new BeanWrapperImpl(source); |
|||
java.beans.PropertyDescriptor[] pds = src.getPropertyDescriptors(); |
|||
|
|||
Set<String> emptyNames = new HashSet<>(); |
|||
for(java.beans.PropertyDescriptor pd : pds) { |
|||
Object srcValue = src.getPropertyValue(pd.getName()); |
|||
if (srcValue == null) emptyNames.add(pd.getName()); |
|||
} |
|||
String[] result = new String[emptyNames.size()]; |
|||
return emptyNames.toArray(result); |
|||
} |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package com.bnyer.common.redis.adapter; |
|||
|
|||
import com.bnyer.common.redis.bo.CacheNameWithTtlBo; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/28 |
|||
* @description : 实现该接口之后,根据缓存的cacheName和ttl将缓存进行过期 |
|||
*/ |
|||
public interface CacheTtlAdapter { |
|||
|
|||
/** |
|||
* 根据缓存的cacheName和ttl将缓存进行过期 |
|||
* @return 需要独立设置过期时间的缓存列表 |
|||
*/ |
|||
List<CacheNameWithTtlBo> listCacheNameWithTtl(); |
|||
|
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package com.bnyer.common.redis.bo; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/28 |
|||
* @description : 通过 cacheName 配置 和 时间告诉缓存多久清楚一遍 |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
@AllArgsConstructor |
|||
@NoArgsConstructor |
|||
public class CacheNameWithTtlBo { |
|||
|
|||
/** |
|||
* 缓存名称 |
|||
*/ |
|||
private String cacheName; |
|||
|
|||
/** |
|||
* 过期时间 |
|||
*/ |
|||
private Integer ttl; |
|||
} |
|||
@ -0,0 +1,20 @@ |
|||
package com.bnyer.common.redis.constant; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/28 |
|||
* @description : |
|||
*/ |
|||
public class CacheNames { |
|||
/** |
|||
* |
|||
* 参考CacheKeyPrefix |
|||
* cacheNames 与 key 之间的默认连接字符 |
|||
*/ |
|||
public final static String UNION = "::"; |
|||
|
|||
/** |
|||
* key内部的连接字符(自定义) |
|||
*/ |
|||
public final static String UNION_KEY = ":"; |
|||
} |
|||
@ -0,0 +1,25 @@ |
|||
package com.bnyer.common.redis.constant; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/27 |
|||
* @description : |
|||
*/ |
|||
public class OrderCacheNames { |
|||
|
|||
/** |
|||
* 会员订单前缀 |
|||
*/ |
|||
public static final String VIP_ORDER_PREFIX = "vip_cloud_order:"; |
|||
|
|||
/** |
|||
* 确认订单信息缓存 |
|||
*/ |
|||
public static final String ORDER_CONFIRM_KEY = "order:confirm"; |
|||
|
|||
/** |
|||
* 订单uid |
|||
*/ |
|||
public static final String ORDER_CONFIRM_UID_KEY = "order:uid_confirm"; |
|||
|
|||
} |
|||
@ -0,0 +1,49 @@ |
|||
package com.bnyer.common.redis.service; |
|||
|
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.cache.Cache; |
|||
import org.springframework.cache.CacheManager; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/28 |
|||
* @description : |
|||
*/ |
|||
@Component |
|||
public class RedisCacheService { |
|||
private final CacheManager cacheManager; |
|||
|
|||
@Autowired |
|||
public RedisCacheService(CacheManager cacheManager) { |
|||
this.cacheManager = cacheManager; |
|||
} |
|||
|
|||
@SuppressWarnings({ "unchecked" }) |
|||
public <T> T getCache(String cacheName, String key) { |
|||
Cache cache = cacheManager.getCache(cacheName); |
|||
if (cache == null) { |
|||
return null; |
|||
} |
|||
Cache.ValueWrapper valueWrapper = cache.get(key); |
|||
if (valueWrapper == null) { |
|||
return null; |
|||
} |
|||
return (T) valueWrapper.get(); |
|||
} |
|||
|
|||
public void putCache(String cacheName, String key, Object value) { |
|||
Cache cache = cacheManager.getCache(cacheName); |
|||
if (cache != null) { |
|||
cache.put(key, value); |
|||
} |
|||
} |
|||
|
|||
public void evictCache(String cacheName, String key) { |
|||
Cache cache = cacheManager.getCache(cacheName); |
|||
if (cache != null) { |
|||
cache.evict(key); |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
|||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
|||
<parent> |
|||
<groupId>com.dimensionalnode</groupId> |
|||
<artifactId>bnyer-common</artifactId> |
|||
<version>1.0.0</version> |
|||
</parent> |
|||
<modelVersion>4.0.0</modelVersion> |
|||
|
|||
<description> |
|||
bnyer-common-rocketmq消息队列模块 |
|||
</description> |
|||
|
|||
<artifactId>bnyer-common-rocketmq</artifactId> |
|||
|
|||
<dependencies> |
|||
<!-- bnyer Common Core--> |
|||
<dependency> |
|||
<groupId>com.dimensionalnode</groupId> |
|||
<artifactId>bnyer-common-core</artifactId> |
|||
</dependency> |
|||
|
|||
<!-- bnyer Common rocketmq--> |
|||
<dependency> |
|||
<groupId>org.apache.rocketmq</groupId> |
|||
<artifactId>rocketmq-spring-boot-starter</artifactId> |
|||
</dependency> |
|||
</dependencies> |
|||
|
|||
</project> |
|||
@ -0,0 +1,38 @@ |
|||
package com.bnyer.common.rocketmq.config; |
|||
|
|||
import org.apache.rocketmq.client.producer.DefaultMQProducer; |
|||
import org.apache.rocketmq.spring.core.RocketMQTemplate; |
|||
import org.apache.rocketmq.spring.support.RocketMQMessageConverter; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.beans.factory.annotation.Value; |
|||
import org.springframework.cloud.context.config.annotation.RefreshScope; |
|||
import org.springframework.context.annotation.Configuration; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/24 |
|||
* @description : |
|||
*/ |
|||
@RefreshScope |
|||
@Configuration |
|||
public class RocketMqAdapter { |
|||
|
|||
@Autowired |
|||
private RocketMQMessageConverter rocketMqMessageConverter; |
|||
|
|||
@Value("${rocketmq.name-server:}") |
|||
private String nameServer; |
|||
|
|||
public RocketMQTemplate getTemplateByTopicName(String topic){ |
|||
RocketMQTemplate mqTemplate = new RocketMQTemplate(); |
|||
DefaultMQProducer producer = new DefaultMQProducer(topic); |
|||
producer.setNamesrvAddr(nameServer); |
|||
producer.setRetryTimesWhenSendFailed(RocketMqConstant.SYNC_RETRY_FAILED_COUNT); |
|||
producer.setRetryTimesWhenSendAsyncFailed(RocketMqConstant.ASYNC_RETRY_FAILED_COUNT); |
|||
producer.setSendMsgTimeout((int) RocketMqConstant.TIMEOUT); |
|||
mqTemplate.setProducer(producer); |
|||
mqTemplate.setMessageConverter(rocketMqMessageConverter.getMessageConverter()); |
|||
return mqTemplate; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
package com.bnyer.common.rocketmq.config; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/24 |
|||
* @description : |
|||
*/ |
|||
public class RocketMqConstant { |
|||
/** |
|||
* 默认发送消息超时时间 |
|||
*/ |
|||
public static final long TIMEOUT = 3000; |
|||
|
|||
/** |
|||
* 延迟队列取消订单时间,实际上30分钟 |
|||
* 按顺序匹配:1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h 2h (1-18) |
|||
*/ |
|||
public static final int CANCEL_ORDER_DELAY_LEVEL = 16; |
|||
|
|||
/** |
|||
* 发送同步消息失败重试次数,默认2 |
|||
*/ |
|||
public static final int SYNC_RETRY_FAILED_COUNT = 2; |
|||
|
|||
/** |
|||
* 发送异步消息失败重试次数,默认2 |
|||
*/ |
|||
public static final int ASYNC_RETRY_FAILED_COUNT = 2; |
|||
|
|||
/** |
|||
* vip订单取消 |
|||
*/ |
|||
public static final String VIP_ORDER_CANCEL_TOPIC = "vip-order-cancel-topic"; |
|||
|
|||
/** |
|||
* vip订单支付成功 |
|||
*/ |
|||
public static final String VIP_ORDER_PAY_NOTIFY_TOPIC = "vip-order-pay-notify-topic"; |
|||
|
|||
/** |
|||
* vip记录创建 |
|||
*/ |
|||
public static final String VIP_RECORD_CREATE_TOPIC = "vip-record-create-topic"; |
|||
|
|||
} |
|||
@ -1,24 +0,0 @@ |
|||
package com.bnyer.img.constants; |
|||
|
|||
/** |
|||
* 用户会员vip常量 |
|||
* @author chengkun |
|||
* @date 2022/4/21 18:12 |
|||
*/ |
|||
public class UserVipTypeConstant { |
|||
|
|||
/** |
|||
* 月卡 |
|||
*/ |
|||
public static final String MONTH_CARD = "0"; |
|||
|
|||
/** |
|||
* 季卡 |
|||
*/ |
|||
public static final String SEASON_CARD = "1"; |
|||
|
|||
/** |
|||
* 年卡 |
|||
*/ |
|||
public static final String YEAR_CARD = "2"; |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
package com.bnyer.img.enums; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum EnumUserVipRecordStatus { |
|||
|
|||
EXPIRE(0,"已到期"), |
|||
VALID(1,"已生效"), |
|||
; |
|||
|
|||
private final int status; |
|||
|
|||
private final String name; |
|||
|
|||
public static String getStatusName(int status) { |
|||
for (EnumUserVipRecordStatus s : EnumUserVipRecordStatus.values()) { |
|||
if (status == s.status) { |
|||
return s.getName(); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.bnyer.img.listener; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.bnyer.common.core.domain.UserVipRecord; |
|||
import com.bnyer.common.core.dto.AddUserVipRecordDto; |
|||
import com.bnyer.common.rocketmq.config.RocketMqConstant; |
|||
import com.bnyer.img.service.UserVipRecordService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; |
|||
import org.apache.rocketmq.spring.core.RocketMQListener; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/24 |
|||
* @description :取消订单mq消费监听 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RocketMQMessageListener(topic = RocketMqConstant.VIP_RECORD_CREATE_TOPIC,consumerGroup = RocketMqConstant.VIP_RECORD_CREATE_TOPIC) |
|||
public class VipRecordCreateConsumer implements RocketMQListener<String> { |
|||
|
|||
@Autowired |
|||
private UserVipRecordService userVipRecordService; |
|||
|
|||
@Override |
|||
public void onMessage(String message) { |
|||
log.info("收到消息:{}", message); |
|||
JSONObject jsonObject = JSON.parseObject(message); |
|||
AddUserVipRecordDto addUserVipRecordDto = JSON.toJavaObject(jsonObject, AddUserVipRecordDto.class); |
|||
//添加用户会员记录
|
|||
userVipRecordService.addUserVipRecord(addUserVipRecordDto); |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.bnyer.order.config; |
|||
|
|||
import com.bnyer.common.redis.adapter.CacheTtlAdapter; |
|||
import com.bnyer.common.redis.bo.CacheNameWithTtlBo; |
|||
import com.bnyer.common.redis.constant.OrderCacheNames; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.ArrayList; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/28 |
|||
* @description : |
|||
*/ |
|||
@Component |
|||
public class OrderCacheTtlAdapter implements CacheTtlAdapter{ |
|||
|
|||
@Override |
|||
public List<CacheNameWithTtlBo> listCacheNameWithTtl() { |
|||
List<CacheNameWithTtlBo> cacheNameWithTtls = new ArrayList<>(); |
|||
// 确认订单缓存30分钟
|
|||
cacheNameWithTtls.add(new CacheNameWithTtlBo(OrderCacheNames.VIP_ORDER_PREFIX + OrderCacheNames.ORDER_CONFIRM_UID_KEY, 60 * 30)); |
|||
cacheNameWithTtls.add(new CacheNameWithTtlBo(OrderCacheNames.VIP_ORDER_PREFIX + OrderCacheNames.ORDER_CONFIRM_KEY, 60 * 30)); |
|||
return cacheNameWithTtls; |
|||
} |
|||
} |
|||
@ -0,0 +1,35 @@ |
|||
package com.bnyer.order.config; |
|||
|
|||
import com.bnyer.common.rocketmq.config.RocketMqAdapter; |
|||
import com.bnyer.common.rocketmq.config.RocketMqConstant; |
|||
import org.apache.rocketmq.spring.core.RocketMQTemplate; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.cloud.context.config.annotation.RefreshScope; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.context.annotation.Lazy; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/24 |
|||
* @description : |
|||
*/ |
|||
@RefreshScope |
|||
@Configuration |
|||
public class RocketMqConfig { |
|||
@Autowired |
|||
private RocketMqAdapter rocketMqAdapter; |
|||
|
|||
@Lazy |
|||
@Bean(destroyMethod = "destroy") |
|||
public RocketMQTemplate orderCancelMqTemplate() { |
|||
return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.VIP_ORDER_CANCEL_TOPIC); |
|||
} |
|||
|
|||
@Lazy |
|||
@Bean(destroyMethod = "destroy") |
|||
public RocketMQTemplate vipRecordMqTemplate() { |
|||
return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.VIP_RECORD_CREATE_TOPIC); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,54 @@ |
|||
package com.bnyer.order.controller; |
|||
|
|||
import com.bnyer.common.core.domain.R; |
|||
import com.bnyer.common.core.web.controller.BaseController; |
|||
import com.bnyer.order.dto.AddVipOrderDto; |
|||
import com.bnyer.order.dto.QueryVipOrderDto; |
|||
import com.bnyer.order.service.VipOrderService; |
|||
import com.bnyer.order.vo.VipOrderVo; |
|||
import io.swagger.annotations.Api; |
|||
import io.swagger.v3.oas.annotations.Operation; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.web.bind.annotation.*; |
|||
|
|||
import javax.validation.Valid; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/24 |
|||
* @description : |
|||
*/ |
|||
@Api(value = "会员订单相关接口",tags = "会员订单相关接口") |
|||
@RestController |
|||
@RequestMapping("/vip") |
|||
@Slf4j |
|||
public class VipOrderController extends BaseController { |
|||
|
|||
|
|||
@Autowired |
|||
private VipOrderService vipOrderService; |
|||
|
|||
|
|||
/** |
|||
* 提交订单 |
|||
*/ |
|||
@PostMapping("/addVipOrder") |
|||
@Operation(summary = "生成会员订单,返回订单号" , description = "生成会员订单,返回订单号,通过订单号调用支付接口") |
|||
public R<String> addVipOrder(@Valid @RequestBody AddVipOrderDto addVipOrderDto) { |
|||
String orderNo = vipOrderService.addVipOrder(addVipOrderDto); |
|||
return R.ok(orderNo); |
|||
} |
|||
|
|||
/** |
|||
* 查询订单信息 |
|||
*/ |
|||
@PostMapping("/getVipOrderList") |
|||
@Operation(summary = "查询会员订单列表信息" , description = "查询会员订单列表信息") |
|||
public R<List<VipOrderVo>> getVipOrderList(@Valid @RequestBody QueryVipOrderDto dto) { |
|||
List<VipOrderVo> vipOrderVoList = vipOrderService.getVipOrderList(dto); |
|||
return R.ok(vipOrderVoList); |
|||
} |
|||
|
|||
} |
|||
@ -1,4 +0,0 @@ |
|||
package com.bnyer.order.controller; |
|||
|
|||
public class testController { |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.bnyer.order.dto; |
|||
|
|||
import com.bnyer.common.core.annotation.CustomParamsValidation; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
import org.hibernate.validator.constraints.Range; |
|||
|
|||
import javax.validation.constraints.NotBlank; |
|||
import javax.validation.constraints.NotNull; |
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/27 |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
@NoArgsConstructor |
|||
public class AddVipOrderDto implements Serializable { |
|||
|
|||
@NotBlank(message = "手机号不能为空!") |
|||
@ApiModelProperty(value="手机号") |
|||
private String phone; |
|||
|
|||
@NotNull(message = "vipId不能为空!") |
|||
@ApiModelProperty(value="vip表id") |
|||
private Long vipId; |
|||
|
|||
@NotNull(message = "用户客户端类型不能为空!") |
|||
@ApiModelProperty(value="用户客户端类型:10用户-抖音 20用户-快手 30用户-微信 40艺术家-微信") |
|||
private Integer userClientType; |
|||
|
|||
} |
|||
@ -0,0 +1,23 @@ |
|||
package com.bnyer.order.dto; |
|||
|
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
|
|||
import java.io.Serializable; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/27 |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
@NoArgsConstructor |
|||
public class QueryVipOrderDto implements Serializable { |
|||
|
|||
@ApiModelProperty(value="订单号") |
|||
private String orderNo; |
|||
|
|||
} |
|||
@ -0,0 +1,32 @@ |
|||
package com.bnyer.order.enums; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum EnumVipOrderStatus { |
|||
|
|||
NOT_PROCESS(0,"未处理"), |
|||
SUCCESS(1,"成功"), |
|||
FAILS(2,"失败"), |
|||
; |
|||
|
|||
private final int status; |
|||
|
|||
private final String name; |
|||
|
|||
public static String getStatusName(int status) { |
|||
for (EnumVipOrderStatus s : EnumVipOrderStatus.values()) { |
|||
if (status == s.status) { |
|||
return s.getName(); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,50 @@ |
|||
package com.bnyer.order.enums; |
|||
|
|||
import lombok.AllArgsConstructor; |
|||
import lombok.Getter; |
|||
|
|||
/** |
|||
* 用户会员vip常量 |
|||
* @author chengkun |
|||
* @date 2022/4/21 18:12 |
|||
*/ |
|||
@Getter |
|||
@AllArgsConstructor |
|||
public enum EnumVipType { |
|||
|
|||
//========================下图会员===================
|
|||
MONTH_CARD("0","月卡", com.bnyer.common.core.enums.EnumVipType.IMG_VIP), |
|||
SEASON_CARD("1","季卡", com.bnyer.common.core.enums.EnumVipType.IMG_VIP), |
|||
YEAR_CARD("2","年卡", com.bnyer.common.core.enums.EnumVipType.IMG_VIP), |
|||
|
|||
//========================视频会员(待扩展)===================
|
|||
|
|||
|
|||
|
|||
//========================AI会员(待扩展)====================
|
|||
; |
|||
|
|||
private final String typeCode; |
|||
|
|||
private final String typeName; |
|||
|
|||
private final com.bnyer.common.core.enums.EnumVipType enumVipType; |
|||
|
|||
public static String getNameByTypeCode(String typeCode) { |
|||
for (EnumVipType s : com.bnyer.order.enums.EnumVipType.values()) { |
|||
if (typeCode.equals(s.getTypeCode())) { |
|||
return s.getTypeName(); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
|
|||
public static String getCategoryByTypeCode(String typeCode){ |
|||
for (EnumVipType s : com.bnyer.order.enums.EnumVipType.values()) { |
|||
if (typeCode.equals(s.getTypeCode())) { |
|||
return s.getEnumVipType().getCode(); |
|||
} |
|||
} |
|||
return null; |
|||
} |
|||
} |
|||
@ -0,0 +1,31 @@ |
|||
package com.bnyer.order.listener.vip; |
|||
|
|||
import com.bnyer.common.rocketmq.config.RocketMqConstant; |
|||
import com.bnyer.order.service.VipOrderService; |
|||
import com.google.common.collect.Lists; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; |
|||
import org.apache.rocketmq.spring.core.RocketMQListener; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/24 |
|||
* @description :取消订单mq消费监听 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RocketMQMessageListener(topic = RocketMqConstant.VIP_ORDER_CANCEL_TOPIC,consumerGroup = RocketMqConstant.VIP_ORDER_CANCEL_TOPIC) |
|||
public class VipOrderCancelConsumer implements RocketMQListener<String> { |
|||
|
|||
@Autowired |
|||
private VipOrderService vipOrderService; |
|||
|
|||
@Override |
|||
public void onMessage(String orderNo) { |
|||
log.info("收到消息:{}", orderNo); |
|||
// 如果订单未支付的话,将订单设为取消状态
|
|||
vipOrderService.cancelVipOrder(Lists.newArrayList(orderNo),0); |
|||
} |
|||
} |
|||
@ -0,0 +1,82 @@ |
|||
package com.bnyer.order.listener.vip; |
|||
|
|||
import com.alibaba.fastjson.JSON; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.bnyer.common.core.domain.VipOrder; |
|||
import com.bnyer.common.core.enums.ResponseEnum; |
|||
import com.bnyer.common.core.exception.ServiceException; |
|||
import com.bnyer.common.core.utils.SpringUtils; |
|||
import com.bnyer.common.rocketmq.config.RocketMqConstant; |
|||
import com.bnyer.order.mapper.VipOrderMapper; |
|||
import com.bnyer.order.service.VipOrderService; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.rocketmq.client.producer.SendStatus; |
|||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener; |
|||
import org.apache.rocketmq.spring.core.RocketMQListener; |
|||
import org.apache.rocketmq.spring.core.RocketMQTemplate; |
|||
import org.springframework.messaging.support.GenericMessage; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import javax.annotation.Resource; |
|||
import java.util.Objects; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/24 |
|||
* @description :订单支付回调mq消费监听 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
@RocketMQMessageListener(topic = RocketMqConstant.VIP_ORDER_PAY_NOTIFY_TOPIC,consumerGroup = RocketMqConstant.VIP_ORDER_PAY_NOTIFY_TOPIC) |
|||
public class VipOrderPayNotifyConsumer implements RocketMQListener<String> { |
|||
|
|||
@Resource |
|||
private VipOrderMapper vipOrderMapper; |
|||
|
|||
@Resource |
|||
private RocketMQTemplate vipRecordMqTemplate; |
|||
|
|||
@Override |
|||
public void onMessage(String message) { |
|||
log.info("收到消息:{}", message); |
|||
//修改订单并添加会员记录
|
|||
VipOrderService vipOrderService = SpringUtils.getBean(VipOrderService.class); |
|||
JSONObject orderObj = JSON.parseObject(message); |
|||
String orderNo = orderObj.getString("orderNo"); |
|||
VipOrder vipOrder = vipOrderMapper.selectOne(new LambdaQueryWrapper<VipOrder>().eq(VipOrder::getOrderNo, orderNo)); |
|||
if (Objects.isNull(vipOrder)){ |
|||
log.error("订单不存在,订单号:{}",orderNo); |
|||
return; |
|||
} |
|||
//修改订单表状态为已支付
|
|||
vipOrderService.updateByToPaySuccess(vipOrder); |
|||
//发消息,添加用户会员记录
|
|||
String msg = buildVipRecordMsg(vipOrder); |
|||
SendStatus sendStatus = vipRecordMqTemplate.syncSend(RocketMqConstant.VIP_RECORD_CREATE_TOPIC, new GenericMessage<>(msg)).getSendStatus(); |
|||
if (!Objects.equals(sendStatus, SendStatus.SEND_OK)) { |
|||
// 消息发不出去就抛异常
|
|||
throw new ServiceException(ResponseEnum.SERVER_ERROR); |
|||
} |
|||
} |
|||
|
|||
/** |
|||
* 构建vip记录消息体 |
|||
* @param vipOrder |
|||
* @return |
|||
*/ |
|||
private String buildVipRecordMsg(VipOrder vipOrder) { |
|||
JSONObject jsonObject = new JSONObject(); |
|||
jsonObject.put("orderNo",vipOrder.getOrderNo()); |
|||
jsonObject.put("startTime",vipOrder.getStartTime()); |
|||
jsonObject.put("endTime",vipOrder.getEndTime()); |
|||
jsonObject.put("vipId",vipOrder.getVipId()); |
|||
jsonObject.put("vipName",vipOrder.getVipName()); |
|||
jsonObject.put("vipTypeName",vipOrder.getVipTypeName()); |
|||
jsonObject.put("userClientType",vipOrder.getUserClientType()); |
|||
jsonObject.put("phone",vipOrder.getPhone()); |
|||
jsonObject.put("userId",vipOrder.getUserId()); |
|||
return JSON.toJSONString(jsonObject); |
|||
} |
|||
|
|||
} |
|||
@ -1,7 +0,0 @@ |
|||
package com.bnyer.order.mapper; |
|||
|
|||
import org.apache.ibatis.annotations.Mapper; |
|||
|
|||
@Mapper |
|||
public class TestMapper { |
|||
} |
|||
@ -0,0 +1,36 @@ |
|||
package com.bnyer.order.mapper; |
|||
|
|||
import java.util.List; |
|||
|
|||
import com.bnyer.order.dto.QueryVipOrderDto; |
|||
|
|||
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
|||
import com.bnyer.common.core.domain.VipOrder; |
|||
import org.apache.ibatis.annotations.Mapper; |
|||
import org.apache.ibatis.annotations.Param; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @description : |
|||
*/ |
|||
@Mapper |
|||
public interface VipOrderMapper extends BaseMapper<VipOrder> { |
|||
/** |
|||
* 查询订单信息 |
|||
* @param dto |
|||
* @return |
|||
*/ |
|||
List<VipOrder> queryVipOrderList(QueryVipOrderDto dto); |
|||
|
|||
/** |
|||
* 取消订单 |
|||
* @param orderNos |
|||
*/ |
|||
void cancelVipOrder(@Param("orderNos") List<String> orderNos, @Param("closeType") Integer closeType); |
|||
|
|||
/** |
|||
* 修改订单表状态为已支付 |
|||
* @param orderNo |
|||
*/ |
|||
void updateByToPaySuccess(@Param("orderNo") String orderNo); |
|||
} |
|||
@ -1,4 +0,0 @@ |
|||
package com.bnyer.order.service; |
|||
|
|||
public interface TestService { |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
package com.bnyer.order.service; |
|||
|
|||
import com.baomidou.mybatisplus.extension.service.IService; |
|||
import com.bnyer.common.core.domain.VipOrder; |
|||
import com.bnyer.order.dto.QueryVipOrderDto; |
|||
import com.bnyer.order.dto.AddVipOrderDto; |
|||
import com.bnyer.order.vo.VipOrderVo; |
|||
|
|||
import java.util.List; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/27 |
|||
* @description : |
|||
*/ |
|||
public interface VipOrderService extends IService<VipOrder> { |
|||
|
|||
/** |
|||
* 生成会员订单,返回订单号 |
|||
* |
|||
* @param addVipOrderDto 下单所需要的参数 |
|||
* @return 支付流水号 |
|||
*/ |
|||
String addVipOrder(AddVipOrderDto addVipOrderDto); |
|||
|
|||
/** |
|||
* 取消订单 |
|||
* @param orderNos 订单号 |
|||
* @param closeType 订单关闭原因类型 |
|||
*/ |
|||
void cancelVipOrder(List<String> orderNos,Integer closeType); |
|||
|
|||
/** |
|||
* 查询会员订单列表信息 |
|||
* @param dto |
|||
* @return |
|||
*/ |
|||
List<VipOrderVo> getVipOrderList(QueryVipOrderDto dto); |
|||
|
|||
/** |
|||
* 更新订单信息 |
|||
* @param vipOrder |
|||
*/ |
|||
void updateByToPaySuccess(VipOrder vipOrder); |
|||
} |
|||
@ -1,8 +0,0 @@ |
|||
package com.bnyer.order.service.impl; |
|||
|
|||
import com.bnyer.order.service.TestService; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
@Service |
|||
public class TestServiceImpl implements TestService { |
|||
} |
|||
@ -0,0 +1,195 @@ |
|||
package com.bnyer.order.service.impl; |
|||
|
|||
import cn.hutool.core.collection.CollUtil; |
|||
import cn.hutool.core.date.DateUtil; |
|||
import com.alibaba.fastjson.JSON; |
|||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|||
import com.bnyer.common.core.domain.R; |
|||
import com.bnyer.common.core.domain.VipOrder; |
|||
import com.bnyer.common.core.enums.*; |
|||
import com.bnyer.common.core.exception.ServiceException; |
|||
import com.bnyer.common.core.utils.DateUtils; |
|||
import com.bnyer.common.core.utils.OrderUtil; |
|||
import com.bnyer.common.core.utils.bean.EntityConvertUtil; |
|||
import com.bnyer.common.rocketmq.config.RocketMqConstant; |
|||
import com.bnyer.common.security.utils.SecurityUtils; |
|||
import com.bnyer.img.api.dto.QueryUserVipDto; |
|||
import com.bnyer.img.api.remote.RemoteWxMiniService; |
|||
import com.bnyer.img.api.vo.UserVipInfoVo; |
|||
import com.bnyer.order.dto.AddVipOrderDto; |
|||
import com.bnyer.order.dto.QueryVipOrderDto; |
|||
import com.bnyer.order.enums.EnumVipOrderStatus; |
|||
import com.bnyer.order.mapper.VipOrderMapper; |
|||
import com.bnyer.order.service.VipOrderService; |
|||
import com.bnyer.order.vo.VipOrderVo; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.rocketmq.client.producer.SendStatus; |
|||
import org.apache.rocketmq.spring.core.RocketMQTemplate; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.messaging.support.GenericMessage; |
|||
import org.springframework.stereotype.Service; |
|||
import org.springframework.transaction.annotation.Transactional; |
|||
|
|||
import java.util.Date; |
|||
import java.util.List; |
|||
import java.util.Objects; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/28 |
|||
* @description : |
|||
*/ |
|||
@Slf4j |
|||
@Service |
|||
public class VipOrderServiceImpl extends ServiceImpl<VipOrderMapper, VipOrder> implements VipOrderService { |
|||
|
|||
@Autowired |
|||
private RocketMQTemplate orderCancelMqTemplate; |
|||
|
|||
@Autowired |
|||
private VipOrderMapper vipOrderMapper; |
|||
|
|||
@Autowired |
|||
private RemoteWxMiniService remoteWxMiniService; |
|||
|
|||
/** |
|||
* 查询会员订单列表信息 |
|||
* @param dto |
|||
* @return |
|||
*/ |
|||
@Override |
|||
public List<VipOrderVo> getVipOrderList(QueryVipOrderDto dto) { |
|||
List<VipOrder> vipOrderList = vipOrderMapper.queryVipOrderList(dto); |
|||
List<VipOrderVo> vipOrderVoList = EntityConvertUtil.copy(vipOrderList, VipOrderVo.class); |
|||
return vipOrderVoList; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 生成会员订单,返回订单号 |
|||
* @param addVipOrderDto 下单所需要的参数 |
|||
* @return |
|||
*/ |
|||
@Override |
|||
@Transactional(rollbackFor = Exception.class) |
|||
public String addVipOrder(AddVipOrderDto addVipOrderDto) { |
|||
//构建订单
|
|||
VipOrder vipOrder = buildVipOrder(addVipOrderDto); |
|||
vipOrderMapper.insert(vipOrder); |
|||
String orderNo = vipOrder.getOrderNo(); |
|||
//发送消息,如果三十分钟后没有支付,则取消订单
|
|||
SendStatus sendStatus = orderCancelMqTemplate.syncSend(RocketMqConstant.VIP_ORDER_CANCEL_TOPIC, new GenericMessage<>(orderNo), RocketMqConstant.TIMEOUT, RocketMqConstant.CANCEL_ORDER_DELAY_LEVEL).getSendStatus(); |
|||
if (!Objects.equals(sendStatus,SendStatus.SEND_OK)) { |
|||
// 消息发不出去就抛异常,发的出去无所谓
|
|||
throw new ServiceException(ResponseEnum.SERVER_ERROR); |
|||
}else { |
|||
log.info("消息发送成功,topic:{}",RocketMqConstant.VIP_ORDER_CANCEL_TOPIC); |
|||
} |
|||
return orderNo; |
|||
} |
|||
|
|||
/** |
|||
* 构建订单 |
|||
* @param addVipOrderDto |
|||
* @return |
|||
*/ |
|||
private VipOrder buildVipOrder(AddVipOrderDto addVipOrderDto) { |
|||
//查询会员信息
|
|||
QueryUserVipDto queryUserVipDto = new QueryUserVipDto(); |
|||
queryUserVipDto.setId(addVipOrderDto.getVipId()); |
|||
R<List<UserVipInfoVo>> userVipVoListResult = remoteWxMiniService.queryUserVipList(queryUserVipDto); |
|||
if (!userVipVoListResult.isSuccess()){ |
|||
log.error("内部接口调用异常:url:{}request{},result{},error:{}","queryUserVipList", JSON.toJSONString(queryUserVipDto),JSON.toJSONString(userVipVoListResult),userVipVoListResult.getMsg()); |
|||
throw new ServiceException(userVipVoListResult.getMsg()); |
|||
} |
|||
List<UserVipInfoVo> userVipInfoVoList = userVipVoListResult.getData(); |
|||
if (CollUtil.isEmpty(userVipInfoVoList)){ |
|||
throw new ServiceException(ResponseEnum.NOT_EXIST,"会员信息"); |
|||
} |
|||
UserVipInfoVo userVipInfoVo = userVipInfoVoList.get(0); |
|||
VipOrder vipOrder = null; |
|||
EnumVipType enumVipType = EnumVipType.getVipTypeByCode(userVipInfoVo.getVipTypeCode()); |
|||
switch (enumVipType){ |
|||
case IMG_VIP: |
|||
vipOrder = buildImgVipOrder(userVipInfoVo,addVipOrderDto); |
|||
break; |
|||
case VIDEO_VIP: |
|||
break; |
|||
case AI_VIP: |
|||
break; |
|||
default: |
|||
throw new ServiceException("vipTypeCode 未匹配上对应分类"); |
|||
} |
|||
return vipOrder; |
|||
} |
|||
|
|||
/** |
|||
* 构建下图会员订单 |
|||
* @param userVipInfoVo |
|||
* @param addVipOrderDto |
|||
* @return |
|||
*/ |
|||
private VipOrder buildImgVipOrder(UserVipInfoVo userVipInfoVo, AddVipOrderDto addVipOrderDto) { |
|||
Long userId = SecurityUtils.getUserId(); |
|||
VipOrder vipOrder = EntityConvertUtil.copy(userVipInfoVo, VipOrder.class); |
|||
vipOrder.setPhone(addVipOrderDto.getPhone()); |
|||
vipOrder.setVipId(addVipOrderDto.getVipId()); |
|||
vipOrder.setVipName(userVipInfoVo.getVipName()); |
|||
vipOrder.setVipTypeName(userVipInfoVo.getVipTypeName()); |
|||
vipOrder.setPayAmount(userVipInfoVo.getPrice()); |
|||
vipOrder.setVipTypeName(userVipInfoVo.getVipTypeName()); |
|||
vipOrder.setUserId(userId); |
|||
// vipOrder.setIsDelay("0");
|
|||
Date nowDate = new Date(); |
|||
vipOrder.setStartTime(nowDate); |
|||
EnumTimeUnit enumTimeUnitByUnit = EnumTimeUnit.getEnumTimeUnitByUnit(userVipInfoVo.getValidTimeUnit()); |
|||
//计算会员结束时间
|
|||
vipOrder.setEndTime(DateUtils.getDateByType(enumTimeUnitByUnit,nowDate, userVipInfoVo.getValidTimeNum())); |
|||
//开通的天数
|
|||
vipOrder.setDays((int) DateUtil.betweenDay(vipOrder.getStartTime(), vipOrder.getEndTime(), true)); |
|||
vipOrder.setUserClientType(addVipOrderDto.getUserClientType()); |
|||
vipOrder.setOrderNo(OrderUtil.getOrderNo("RV",nowDate, EnumUserClientType.getCodeByType(addVipOrderDto.getUserClientType()),String.valueOf(userId))); |
|||
vipOrder.setCreateTime(nowDate); |
|||
return vipOrder; |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 取消订单 |
|||
* @param orderNos 订单id |
|||
* @param closeType 订单关闭原因类型 |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void cancelVipOrder(List<String> orderNos,Integer closeType) { |
|||
List<VipOrder> vipOrderList = vipOrderMapper.selectList(new LambdaQueryWrapper<VipOrder>().in(VipOrder::getOrderNo, orderNos)); |
|||
if (CollUtil.isEmpty(vipOrderList)){ |
|||
return; |
|||
} |
|||
List<String> cancelOrderNos = vipOrderList.stream().filter(vipOrder -> Objects.nonNull(vipOrder.getOrderStatus()) && EnumVipOrderStatus.FAILS.getStatus() |
|||
!= vipOrder.getOrderStatus()).map(VipOrder::getOrderNo).collect(Collectors.toList()); |
|||
if (CollUtil.isEmpty(cancelOrderNos)){ |
|||
return; |
|||
} |
|||
vipOrderMapper.cancelVipOrder(cancelOrderNos,closeType); |
|||
} |
|||
|
|||
|
|||
/** |
|||
* 更新订单信息为已支付 |
|||
* @param vipOrder |
|||
*/ |
|||
@Transactional(rollbackFor = Exception.class) |
|||
@Override |
|||
public void updateByToPaySuccess(VipOrder vipOrder) { |
|||
vipOrder.setPayStatus(EnumPayStatus.SUCCESS.getStatus()); |
|||
vipOrder.setOrderStatus(EnumVipOrderStatus.SUCCESS.getStatus()); |
|||
vipOrder.setUpdateTime(new Date()); |
|||
vipOrder.setPayTime(new Date()); |
|||
//更新订单
|
|||
vipOrderMapper.updateById(vipOrder); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,71 @@ |
|||
package com.bnyer.order.vo; |
|||
|
|||
import com.baomidou.mybatisplus.annotation.IdType; |
|||
import com.baomidou.mybatisplus.annotation.TableId; |
|||
import com.fasterxml.jackson.annotation.JsonFormat; |
|||
import io.swagger.annotations.ApiModelProperty; |
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
|
|||
import java.math.BigDecimal; |
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/27 |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
@NoArgsConstructor |
|||
public class VipOrderVo { |
|||
|
|||
@ApiModelProperty(value="主键") |
|||
private Long id; |
|||
|
|||
@ApiModelProperty(value="订单号") |
|||
private String orderNo; |
|||
|
|||
@ApiModelProperty(value="手机号") |
|||
private String phone; |
|||
|
|||
@ApiModelProperty(value="用户id") |
|||
private Long userId; |
|||
|
|||
@ApiModelProperty(value="vip表id") |
|||
private Long vipId; |
|||
|
|||
@ApiModelProperty(value = "vip编码") |
|||
private String vipCode; |
|||
|
|||
@ApiModelProperty(value = "vip名称") |
|||
private String vipName; |
|||
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@ApiModelProperty(value="开始时间") |
|||
private Date startTime; |
|||
|
|||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") |
|||
@ApiModelProperty(value="到期时间") |
|||
private Date endTime; |
|||
|
|||
@ApiModelProperty(value = "用户客户端类型:10用户-抖音 20用户-快手 30用户-微信 40艺术家-微信") |
|||
private Integer userClientType; |
|||
|
|||
@ApiModelProperty(value="是否到期自动续费(0>否;1->是)") |
|||
private String isDelay; |
|||
|
|||
@ApiModelProperty(value="时长天数") |
|||
private Integer days; |
|||
|
|||
@ApiModelProperty(value="支付金额") |
|||
private BigDecimal payAmount; |
|||
|
|||
@ApiModelProperty(value = "vip类型名称") |
|||
private String vipTypeName; |
|||
|
|||
@ApiModelProperty(value="支付状态:1000未支付;1001支付成功 ;1002支付失败") |
|||
private Integer payStatus; |
|||
|
|||
} |
|||
@ -0,0 +1,94 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
|||
<mapper namespace="com.bnyer.order.mapper.VipOrderMapper"> |
|||
<resultMap id="BaseResultMap" type="com.bnyer.common.core.domain.VipOrder"> |
|||
<!--@mbg.generated--> |
|||
<!--@Table order_vip_order--> |
|||
<id column="id" jdbcType="BIGINT" property="id" /> |
|||
<result column="order_no" jdbcType="VARCHAR" property="orderNo" /> |
|||
<result column="phone" jdbcType="VARCHAR" property="phone" /> |
|||
<result column="user_id" jdbcType="BIGINT" property="userId" /> |
|||
<result column="vip_id" jdbcType="BIGINT" property="vipId" /> |
|||
<result column="vip_code" jdbcType="VARCHAR" property="vipCode" /> |
|||
<result column="vip_name" jdbcType="VARCHAR" property="vipName" /> |
|||
<result column="pay_amount" jdbcType="DECIMAL" property="payAmount" /> |
|||
<result column="is_delay" jdbcType="CHAR" property="isDelay" /> |
|||
<result column="days" jdbcType="INTEGER" property="days" /> |
|||
<result column="vip_type_name" jdbcType="INTEGER" property="vipTypeName" /> |
|||
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" /> |
|||
<result column="end_time" jdbcType="TIMESTAMP" property="endTime" /> |
|||
<result column="order_status" jdbcType="INTEGER" property="orderStatus" /> |
|||
<result column="close_type" jdbcType="INTEGER" property="closeType" /> |
|||
<result column="pay_time" jdbcType="TIMESTAMP" property="payTime" /> |
|||
<result column="cancel_time" jdbcType="TIMESTAMP" property="cancelTime" /> |
|||
<result column="user_client_type" jdbcType="INTEGER" property="userClientType" /> |
|||
<result column="remark" jdbcType="VARCHAR" property="remark" /> |
|||
<result column="pay_status" jdbcType="INTEGER" property="payStatus" /> |
|||
<result column="is_show" jdbcType="CHAR" property="isShow" /> |
|||
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> |
|||
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" /> |
|||
<result column="sort" jdbcType="INTEGER" property="sort" /> |
|||
</resultMap> |
|||
<sql id="Base_Column_List"> |
|||
<!--@mbg.generated--> |
|||
o.id, |
|||
o.order_no, |
|||
o.phone, |
|||
o.user_id, |
|||
o.vip_id, |
|||
o.vip_code, |
|||
o.vip_name, |
|||
o.pay_amount, |
|||
o.is_delay, |
|||
o.`days`, |
|||
o.vip_type_name, |
|||
o.start_time, |
|||
o.end_time, |
|||
o.order_status, |
|||
o.close_type, |
|||
o.pay_time, |
|||
o.cancel_time, |
|||
o.user_client_type, |
|||
o.remark, |
|||
o.pay_status, |
|||
o.sort, |
|||
o.is_show, |
|||
o.create_time, |
|||
o.update_time |
|||
</sql> |
|||
|
|||
<!-- 查询订单信息--> |
|||
<select id="queryVipOrderList" resultMap="BaseResultMap"> |
|||
select |
|||
<include refid="Base_Column_List"/> |
|||
from order_vip_order o |
|||
where |
|||
o.is_show = '1' |
|||
<if test="orderNo != null and orderNo != ''"> |
|||
and o.order_no = #{orderNo,jdbcType=VARCHAR} |
|||
</if> |
|||
</select> |
|||
|
|||
<!-- 取消订单--> |
|||
<update id="cancelVipOrder"> |
|||
update order_vip_order |
|||
set |
|||
order_status = 2, |
|||
close_type = #{closeType,jdbcType=VARCHAR}, |
|||
cancel_time = now(), |
|||
update_time=now() |
|||
where pay_status = 1000 and order_no in |
|||
<foreach collection="orderNos" item="orderNo" open="(" close=")" separator=","> |
|||
#{orderNo} |
|||
</foreach> |
|||
</update> |
|||
<update id="updateByToPaySuccess"> |
|||
update order_vip_order |
|||
set |
|||
order_status = 1, |
|||
pay_status = 1001, |
|||
pay_time = now(), |
|||
update_time = now() |
|||
where order_no = #{orderNo} |
|||
</update> |
|||
</mapper> |
|||
@ -0,0 +1,30 @@ |
|||
package com.bnyer.pay.bo; |
|||
|
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/05/05 |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
@NoArgsConstructor |
|||
public class QueryOrderBo { |
|||
|
|||
/** |
|||
* 支付类型:wxpay/alipay/kspay/dypay |
|||
*/ |
|||
private String payType; |
|||
/** |
|||
* 交易类型 1--JSAPI支付(小程序appId支付)、2--Native支付、3--app支付,4--JSAPI支付(公众号appId支付)5--H5支付,微信支付必填 |
|||
*/ |
|||
private String tradeType; |
|||
/** |
|||
* 支付单号 |
|||
*/ |
|||
private String payId; |
|||
|
|||
} |
|||
@ -0,0 +1,55 @@ |
|||
package com.bnyer.pay.bo; |
|||
|
|||
import lombok.Getter; |
|||
import lombok.NoArgsConstructor; |
|||
import lombok.Setter; |
|||
|
|||
import java.util.Date; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/04/03 |
|||
* @description : |
|||
*/ |
|||
@Getter |
|||
@Setter |
|||
@NoArgsConstructor |
|||
public class UnifiedOrderBo { |
|||
|
|||
/** |
|||
* 内部支付单号 |
|||
*/ |
|||
private String payId; |
|||
/** |
|||
* trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。 |
|||
*/ |
|||
private String openId; |
|||
/** |
|||
* 支付金额:元 |
|||
*/ |
|||
private String payAmount; |
|||
/** |
|||
* ip地址 |
|||
*/ |
|||
private String ip; |
|||
/** |
|||
* 当前时间 |
|||
*/ |
|||
private Date currDate; |
|||
/** |
|||
* 交易类型 1--JSAPI支付(小程序appId支付)、2--Native支付、3--app支付,4--JSAPI支付(公众号appId支付)5--H5支付,微信支付必填 |
|||
*/ |
|||
private String tradeType; |
|||
/** |
|||
* 商品类型:快手支付需要 |
|||
*/ |
|||
private Integer goodsType; |
|||
/** |
|||
* 商品标题:会员充值 |
|||
*/ |
|||
private String goodsSubject; |
|||
/** |
|||
* 商品描述: 会员充值 |
|||
*/ |
|||
private String goodsDesc; |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
package com.bnyer.pay.config; |
|||
|
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.http.client.ClientHttpRequestFactory; |
|||
import org.springframework.http.client.SimpleClientHttpRequestFactory; |
|||
import org.springframework.web.client.RestTemplate; |
|||
|
|||
/** |
|||
* @author chengkun |
|||
* @date 2022/4/28 17:27 |
|||
*/ |
|||
@Configuration |
|||
public class RestTemplateConfiguration { |
|||
@Bean |
|||
public RestTemplate restTemplate(ClientHttpRequestFactory factory) { |
|||
return new RestTemplate(factory); |
|||
} |
|||
|
|||
@Bean |
|||
public ClientHttpRequestFactory simpleClientHttpRequestFactory(){ |
|||
SimpleClientHttpRequestFactory factory = new SimpleClientHttpRequestFactory(); |
|||
factory.setConnectTimeout(15000); |
|||
factory.setReadTimeout(10000); |
|||
return factory; |
|||
} |
|||
} |
|||
@ -0,0 +1,28 @@ |
|||
package com.bnyer.pay.config; |
|||
|
|||
import com.bnyer.common.rocketmq.config.RocketMqAdapter; |
|||
import com.bnyer.common.rocketmq.config.RocketMqConstant; |
|||
import org.apache.rocketmq.spring.core.RocketMQTemplate; |
|||
import org.springframework.beans.factory.annotation.Autowired; |
|||
import org.springframework.cloud.context.config.annotation.RefreshScope; |
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.context.annotation.Lazy; |
|||
|
|||
/** |
|||
* @author :WXC |
|||
* @Date :2023/03/24 |
|||
* @description : |
|||
*/ |
|||
@RefreshScope |
|||
@Configuration |
|||
public class RocketMqConfig { |
|||
@Autowired |
|||
private RocketMqAdapter rocketMqAdapter; |
|||
|
|||
@Lazy |
|||
@Bean(destroyMethod = "destroy") |
|||
public RocketMQTemplate vipOrderPayNotifyMqTemplate() { |
|||
return rocketMqAdapter.getTemplateByTopicName(RocketMqConstant.VIP_ORDER_PAY_NOTIFY_TOPIC); |
|||
} |
|||
} |
|||
@ -1,4 +0,0 @@ |
|||
package com.bnyer.pay.config; |
|||
|
|||
public class TestConfig { |
|||
} |
|||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue