updates
This commit is contained in:
parent
1e9e919911
commit
071a98a032
|
|
@ -48,62 +48,63 @@ public class MiniVipController {
|
|||
private IYxVipSkuService yxVipSkuService;
|
||||
@Autowired
|
||||
private MiniUserService miniUserService;
|
||||
|
||||
@GetMapping(value = "/getVipInfo")
|
||||
@ApiOperation(value = "获取vip信息")
|
||||
public Result<?> vipInfo(){
|
||||
public Result<?> vipInfo() {
|
||||
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
AssertUtils.notNull(loginUser,"未获取到登录信息");
|
||||
AssertUtils.notNull(loginUser, "未获取到登录信息");
|
||||
VipDTO userVip = miniUserService.getUserVip(loginUser.getId());
|
||||
return Result.OK(userVip);
|
||||
}
|
||||
|
||||
@GetMapping(value = "/sku/all")
|
||||
@ApiOperation(value = "获取全部商品信息")
|
||||
public Result<?> skuAll(@RequestParam(defaultValue = "") String provider){
|
||||
if (StringUtils.isNotBlank(provider) && "toutiao".equals(provider)) {
|
||||
public Result<?> skuAll(@RequestParam(defaultValue = "") String provider) {
|
||||
/*if (StringUtils.isNotBlank(provider) && "toutiao".equals(provider)) {
|
||||
LambdaQueryWrapper<YxVipSku> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(YxVipSku::getSkuName,"测试体验卡");
|
||||
queryWrapper.orderByDesc(YxVipSku::getSkuPrice);
|
||||
List<YxVipSku> list = yxVipSkuService.list(queryWrapper);
|
||||
return Result.OK(list);
|
||||
}else{
|
||||
LambdaQueryWrapper<YxVipSku> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(YxVipSku::getSaleable, "1");
|
||||
queryWrapper.orderByDesc(YxVipSku::getSkuPrice);
|
||||
queryWrapper.ne(YxVipSku::getSkuName,"测试体验卡");
|
||||
List<YxVipSku> list = yxVipSkuService.list(queryWrapper);
|
||||
return Result.OK(list);
|
||||
}
|
||||
}else{*/
|
||||
LambdaQueryWrapper<YxVipSku> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(YxVipSku::getSaleable, "1");
|
||||
queryWrapper.orderByDesc(YxVipSku::getSkuPrice);
|
||||
queryWrapper.ne(YxVipSku::getSkuName, "测试体验卡");
|
||||
List<YxVipSku> list = yxVipSkuService.list(queryWrapper);
|
||||
return Result.OK(list);
|
||||
// }
|
||||
}
|
||||
|
||||
@PostMapping(value = "/card/activation")
|
||||
@ApiOperation(value = "卡密激活")
|
||||
public Result<?> cardActivation(@RequestBody JSONObject jsonObject){
|
||||
public Result<?> cardActivation(@RequestBody JSONObject jsonObject) {
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
SysUser user = sysUserService.getById(sysUser.getId());
|
||||
AssertUtils.notNull(user,"获取用户信息失败,请联系管理员");
|
||||
AssertUtils.notNull(user, "获取用户信息失败,请联系管理员");
|
||||
String card = jsonObject.getString("card");
|
||||
AssertUtils.notNull(card,"请输入卡密");
|
||||
AssertUtils.notNull(card, "请输入卡密");
|
||||
//检查card是否有效
|
||||
boolean cardValid = yxVipCardService.cardIsValid(card);
|
||||
AssertUtils.isTrue(cardValid,"当前卡密无效或已被使用");
|
||||
AssertUtils.isTrue(cardValid, "当前卡密无效或已被使用");
|
||||
YxVipCard yxVipCard = yxVipCardService.getOne(new LambdaQueryWrapper<YxVipCard>().eq(YxVipCard::getCardNum, card));
|
||||
VipDTO userVip = miniUserService.getUserVip(user.getId());
|
||||
if (userVip!=null && userVip.getVipLevel()!=0) {
|
||||
AssertUtils.notTrue(yxVipSkuService.convertVipLevel(yxVipCard.getSkuCode())<=userVip.getVipLevel(),"该权益您已激活!不可重复兑换");
|
||||
if (userVip != null && userVip.getVipLevel() != 0) {
|
||||
AssertUtils.notTrue(yxVipSkuService.convertVipLevel(yxVipCard.getSkuCode()) <= userVip.getVipLevel(), "该权益您已激活!不可重复兑换");
|
||||
}
|
||||
//使用卡密
|
||||
boolean exchange = yxVipCardService.exchange(card, user.getId());
|
||||
AssertUtils.isTrue(exchange,"当前卡密已被使用");
|
||||
AssertUtils.isTrue(exchange, "当前卡密已被使用");
|
||||
return Result.OK("激活成功");
|
||||
}
|
||||
|
||||
@GetMapping(value = "/orderDetail")
|
||||
@ApiOperation(value = "获取订单详情")
|
||||
public Result<?> buy(@RequestParam(value = "orderCode")String orderCode){
|
||||
AssertUtils.notNull(orderCode,"订单编号为空!");
|
||||
public Result<?> buy(@RequestParam(value = "orderCode") String orderCode) {
|
||||
AssertUtils.notNull(orderCode, "订单编号为空!");
|
||||
YxOrder yxOrder = yxOrderService.getOne(new LambdaQueryWrapper<YxOrder>().eq(YxOrder::getOrderCode, orderCode));
|
||||
AssertUtils.notNull(yxOrder,"订单信息未找到!");
|
||||
AssertUtils.notNull(yxOrder, "订单信息未找到!");
|
||||
return Result.OK(yxOrder);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue