修复会员卡支付bug
This commit is contained in:
@@ -1,15 +1,17 @@
|
|||||||
package com.gxwebsoft.booking.controller;
|
package com.gxwebsoft.booking.controller;
|
||||||
|
|
||||||
import com.gxwebsoft.common.core.web.BaseController;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.gxwebsoft.booking.service.UserCardService;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
import com.gxwebsoft.booking.entity.UserCard;
|
import com.gxwebsoft.booking.entity.UserCard;
|
||||||
import com.gxwebsoft.booking.param.UserCardParam;
|
import com.gxwebsoft.booking.param.UserCardParam;
|
||||||
|
import com.gxwebsoft.booking.service.UserCardService;
|
||||||
import com.gxwebsoft.common.core.web.ApiResult;
|
import com.gxwebsoft.common.core.web.ApiResult;
|
||||||
import com.gxwebsoft.common.core.web.PageResult;
|
import com.gxwebsoft.common.core.web.BaseController;
|
||||||
import com.gxwebsoft.common.core.web.PageParam;
|
|
||||||
import com.gxwebsoft.common.core.web.BatchParam;
|
import com.gxwebsoft.common.core.web.BatchParam;
|
||||||
import com.gxwebsoft.common.core.annotation.OperationLog;
|
import com.gxwebsoft.common.core.web.PageResult;
|
||||||
import com.gxwebsoft.common.system.entity.User;
|
import com.gxwebsoft.common.system.entity.User;
|
||||||
|
import com.gxwebsoft.shop.entity.Merchant;
|
||||||
|
import com.gxwebsoft.shop.service.MerchantService;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
@@ -30,6 +32,32 @@ import java.util.List;
|
|||||||
public class UserCardController extends BaseController {
|
public class UserCardController extends BaseController {
|
||||||
@Resource
|
@Resource
|
||||||
private UserCardService userCardService;
|
private UserCardService userCardService;
|
||||||
|
@Resource
|
||||||
|
private MerchantService merchantService;
|
||||||
|
|
||||||
|
@ApiOperation("查询可用的会员卡")
|
||||||
|
@GetMapping("/findUseCard")
|
||||||
|
public ApiResult<?> findUseCard(UserCardParam param) {
|
||||||
|
final User loginUser = getLoginUser();
|
||||||
|
if(loginUser == null){
|
||||||
|
return fail("请先登录",null);
|
||||||
|
}
|
||||||
|
// 查询可用的会员卡
|
||||||
|
LambdaUpdateWrapper<UserCard> wrapper = new LambdaUpdateWrapper<>();
|
||||||
|
if(param.getPayPrice() != null){
|
||||||
|
System.out.println("param = " + param);
|
||||||
|
wrapper.ge(UserCard::getRemainingMoney,param.getPayPrice());
|
||||||
|
}
|
||||||
|
final long timeMillis = System.currentTimeMillis();
|
||||||
|
System.out.println("timeMillis = " + timeMillis/1000);
|
||||||
|
wrapper.eq(UserCard::getPhone, loginUser.getPhone())
|
||||||
|
.eq(UserCard::getStatus,1)
|
||||||
|
.like(UserCard::getSid, param.getSid())
|
||||||
|
.ge(UserCard::getExpireTime, timeMillis/1000)
|
||||||
|
.last("limit 1");
|
||||||
|
return success(userCardService.getOne(wrapper));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation("分页查询会员卡")
|
@ApiOperation("分页查询会员卡")
|
||||||
@GetMapping("/page")
|
@GetMapping("/page")
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ public class UserCard implements Serializable {
|
|||||||
private Integer isInvoice;
|
private Integer isInvoice;
|
||||||
|
|
||||||
@ApiModelProperty(value = "vip卡到期时间")
|
@ApiModelProperty(value = "vip卡到期时间")
|
||||||
private String expireTime;
|
private Long expireTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "紧急联系人")
|
@ApiModelProperty(value = "紧急联系人")
|
||||||
private String urgentName;
|
private String urgentName;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import lombok.Data;
|
|||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* @author 科技小王子
|
* @author 科技小王子
|
||||||
* @since 2024-07-13 13:06:37
|
* @since 2024-07-13 13:06:37
|
||||||
@@ -38,7 +38,7 @@ public class UserCardLog implements Serializable {
|
|||||||
@ApiModelProperty(value = "统计金额(正是收入,负是冲抵(退卡后产生))")
|
@ApiModelProperty(value = "统计金额(正是收入,负是冲抵(退卡后产生))")
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
|
||||||
private Integer createTime;
|
private Long createTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "虚拟卡ID")
|
@ApiModelProperty(value = "虚拟卡ID")
|
||||||
private Integer usersVipId;
|
private Integer usersVipId;
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package com.gxwebsoft.booking.param;
|
package com.gxwebsoft.booking.param;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
import com.gxwebsoft.common.core.annotation.QueryField;
|
import com.gxwebsoft.common.core.annotation.QueryField;
|
||||||
import com.gxwebsoft.common.core.annotation.QueryType;
|
import com.gxwebsoft.common.core.annotation.QueryType;
|
||||||
import com.gxwebsoft.common.core.web.BaseParam;
|
import com.gxwebsoft.common.core.web.BaseParam;
|
||||||
@@ -21,141 +24,157 @@ import lombok.EqualsAndHashCode;
|
|||||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||||
@ApiModel(value = "UserCardParam对象", description = "会员卡查询参数")
|
@ApiModel(value = "UserCardParam对象", description = "会员卡查询参数")
|
||||||
public class UserCardParam extends BaseParam {
|
public class UserCardParam extends BaseParam {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
|
||||||
@ApiModelProperty(value = "sid场馆id集合,适用的场馆")
|
@ApiModelProperty(value = "sid场馆id集合,适用的场馆")
|
||||||
private String sid;
|
private String sid;
|
||||||
|
|
||||||
@ApiModelProperty(value = "用户id")
|
@ApiModelProperty(value = "用户id")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer uid;
|
private Integer uid;
|
||||||
|
|
||||||
@ApiModelProperty(value = "vip卡id")
|
@ApiModelProperty(value = "vip卡id")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer vid;
|
private Integer vid;
|
||||||
|
|
||||||
@ApiModelProperty(value = "开卡人id")
|
@ApiModelProperty(value = "开卡人id")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer aid;
|
private Integer aid;
|
||||||
|
|
||||||
@ApiModelProperty(value = "微信订单号")
|
@ApiModelProperty(value = "微信订单号")
|
||||||
private String wechatOrder;
|
private String wechatOrder;
|
||||||
|
|
||||||
@ApiModelProperty(value = "卡号")
|
@ApiModelProperty(value = "卡号")
|
||||||
private String code;
|
private String code;
|
||||||
|
|
||||||
@ApiModelProperty(value = "会员卡名称")
|
@ApiModelProperty(value = "会员卡名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ApiModelProperty(value = "真实姓名")
|
@ApiModelProperty(value = "真实姓名")
|
||||||
private String username;
|
private String username;
|
||||||
|
|
||||||
@ApiModelProperty(value = "手机号码")
|
@ApiModelProperty(value = "手机号码")
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
@ApiModelProperty(value = "vip购卡价格")
|
@ApiModelProperty(value = "vip购卡价格")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private BigDecimal price;
|
private BigDecimal price;
|
||||||
|
|
||||||
@ApiModelProperty(value = "会员卡介绍")
|
@ApiModelProperty(value = "会员卡介绍")
|
||||||
private String comments;
|
private String comments;
|
||||||
|
|
||||||
@ApiModelProperty(value = "会员卡说明")
|
@ApiModelProperty(value = "会员卡说明")
|
||||||
private String info;
|
private String info;
|
||||||
|
|
||||||
@ApiModelProperty(value = "vip卡折扣率")
|
@ApiModelProperty(value = "vip卡折扣率")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private BigDecimal discount;
|
private BigDecimal discount;
|
||||||
|
|
||||||
@ApiModelProperty(value = "使用次数")
|
@ApiModelProperty(value = "使用次数")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer count;
|
private Integer count;
|
||||||
|
|
||||||
@ApiModelProperty(value = "每使用一次减少的金额")
|
@ApiModelProperty(value = "每使用一次减少的金额")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private BigDecimal eachMoney;
|
private BigDecimal eachMoney;
|
||||||
|
|
||||||
@ApiModelProperty(value = "剩余金额")
|
@ApiModelProperty(value = "剩余金额")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private BigDecimal remainingMoney;
|
private BigDecimal remainingMoney;
|
||||||
|
|
||||||
@ApiModelProperty(value = "续费累加次数")
|
@ApiModelProperty(value = "续费累加次数")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer number;
|
private Integer number;
|
||||||
|
|
||||||
@ApiModelProperty(value = "剩余次数")
|
@ApiModelProperty(value = "剩余次数")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer num;
|
private Integer num;
|
||||||
|
|
||||||
@ApiModelProperty(value = "付款状态,1已付款,2未付款")
|
@ApiModelProperty(value = "付款状态,1已付款,2未付款")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@ApiModelProperty(value = "会员卡年限")
|
@ApiModelProperty(value = "会员卡年限")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer term;
|
private Integer term;
|
||||||
|
|
||||||
@ApiModelProperty(value = "月限")
|
@ApiModelProperty(value = "月限")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer month;
|
private Integer month;
|
||||||
|
|
||||||
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
|
@ApiModelProperty(value = "IC卡类型:1年卡,2次卡,3月卡,4会员IC卡,5充值卡 ")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer type;
|
private Integer type;
|
||||||
|
|
||||||
@ApiModelProperty(value = "卡类型:1成人卡,2儿童卡")
|
@ApiModelProperty(value = "卡类型:1成人卡,2儿童卡")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer cardType;
|
private Integer cardType;
|
||||||
|
|
||||||
@ApiModelProperty(value = "vip卡等级类型:1特殊vip卡,2普通vip卡")
|
@ApiModelProperty(value = "vip卡等级类型:1特殊vip卡,2普通vip卡")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer vipType;
|
private Integer vipType;
|
||||||
|
|
||||||
@ApiModelProperty(value = "特殊卡开发凭证图")
|
@ApiModelProperty(value = "特殊卡开发凭证图")
|
||||||
private String pic;
|
private String pic;
|
||||||
|
|
||||||
@ApiModelProperty(value = "价格组")
|
@ApiModelProperty(value = "价格组")
|
||||||
private String prices;
|
private String prices;
|
||||||
|
|
||||||
@ApiModelProperty(value = "1微信支付,2支付宝支付,3现金,4POS机刷卡,15平安健康卡")
|
@ApiModelProperty(value = "1微信支付,2支付宝支付,3现金,4POS机刷卡,15平安健康卡")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer payType;
|
private Integer payType;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否赠送积分:1赠送,2不赠送")
|
@ApiModelProperty(value = "是否赠送积分:1赠送,2不赠送")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer isIntegral;
|
private Integer isIntegral;
|
||||||
|
|
||||||
@ApiModelProperty(value = "是否已开具发票:1已开发票,2未开发票")
|
@ApiModelProperty(value = "是否已开具发票:1已开发票,2未开发票")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer isInvoice;
|
private Integer isInvoice;
|
||||||
|
|
||||||
@ApiModelProperty(value = "vip卡到期时间")
|
@ApiModelProperty(value = "vip卡到期时间")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer expireTime;
|
private Integer expireTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "紧急联系人")
|
@ApiModelProperty(value = "紧急联系人")
|
||||||
private String urgentName;
|
private String urgentName;
|
||||||
|
|
||||||
@ApiModelProperty(value = "紧急联系人号码")
|
@ApiModelProperty(value = "紧急联系人号码")
|
||||||
private String urgentPhone;
|
private String urgentPhone;
|
||||||
|
|
||||||
@ApiModelProperty(value = "卡号")
|
@ApiModelProperty(value = "卡号")
|
||||||
private String cardNum;
|
private String cardNum;
|
||||||
|
|
||||||
@ApiModelProperty(value = "密码")
|
@ApiModelProperty(value = "密码")
|
||||||
private String password;
|
private String password;
|
||||||
|
|
||||||
@ApiModelProperty(value = "使用时间")
|
@ApiModelProperty(value = "使用时间")
|
||||||
@QueryField(type = QueryType.EQ)
|
@QueryField(type = QueryType.EQ)
|
||||||
private Integer useTime;
|
private Integer useTime;
|
||||||
|
|
||||||
@ApiModelProperty(value = "身份证号码")
|
@ApiModelProperty(value = "身份证号码")
|
||||||
private String idcard;
|
private String idcard;
|
||||||
|
|
||||||
@ApiModelProperty(value = "备注")
|
@ApiModelProperty(value = "备注")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "排序号")
|
||||||
|
@QueryField(type = QueryType.EQ)
|
||||||
|
private Integer sortNumber;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "是否删除, 0否, 1是")
|
||||||
|
@QueryField(type = QueryType.EQ)
|
||||||
|
private Integer deleted;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "会员卡ID集合")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Set<Integer> cardIds;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "订单金额")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private BigDecimal payPrice;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ public class OrderController extends BaseController {
|
|||||||
userCard.setType(card.getType());
|
userCard.setType(card.getType());
|
||||||
userCard.setTenantId(card.getTenantId());
|
userCard.setTenantId(card.getTenantId());
|
||||||
final long epochMilli = DateUtil.toInstant(DateUtil.offset(DateUtil.date(), DateField.MONTH, card.getMonth())).toEpochMilli();
|
final long epochMilli = DateUtil.toInstant(DateUtil.offset(DateUtil.date(), DateField.MONTH, card.getMonth())).toEpochMilli();
|
||||||
userCard.setExpireTime(String.valueOf(epochMilli/1000));
|
userCard.setExpireTime(epochMilli/1000);
|
||||||
userCardService.save(userCard);
|
userCardService.save(userCard);
|
||||||
order.setCardId(userCard.getId());
|
order.setCardId(userCard.getId());
|
||||||
}
|
}
|
||||||
@@ -300,8 +300,9 @@ public class OrderController extends BaseController {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// TODO 会员卡支付
|
// TODO 会员卡支付
|
||||||
if(order.getPayType().equals(6)){
|
if(order.getPayType().equals(2)){
|
||||||
order.setAccessToken(order.getAccessToken());
|
order.setAccessToken(order.getAccessToken());
|
||||||
|
System.out.println("getAccessToken = " + order.getAccessToken());
|
||||||
return success("下单成功", orderService.payByUserCard(order));
|
return success("下单成功", orderService.payByUserCard(order));
|
||||||
}
|
}
|
||||||
return fail("支付失败");
|
return fail("支付失败");
|
||||||
|
|||||||
@@ -334,8 +334,10 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
// return true;
|
// return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// @Transactional(rollbackFor = {Exception.class})
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = {Exception.class})
|
|
||||||
public Boolean payByUserCard(Order order) {
|
public Boolean payByUserCard(Order order) {
|
||||||
final Users users = usersService.getByPhone(order.getPhone());
|
final Users users = usersService.getByPhone(order.getPhone());
|
||||||
final User loginUser = order.getLoginUser();
|
final User loginUser = order.getLoginUser();
|
||||||
@@ -372,6 +374,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|||||||
// userCardLog.setComments(order.getComments());
|
// userCardLog.setComments(order.getComments());
|
||||||
userCardLog.setType(userCard.getType());
|
userCardLog.setType(userCard.getType());
|
||||||
userCardLog.setPrice(order.getPayPrice());
|
userCardLog.setPrice(order.getPayPrice());
|
||||||
|
userCardLog.setCreateTime(System.currentTimeMillis()/1000);
|
||||||
// userCardLog.setOrderNo(order.getOrderNo());
|
// userCardLog.setOrderNo(order.getOrderNo());
|
||||||
// userCardLog.setMerchantId(order.getMerchantId());
|
// userCardLog.setMerchantId(order.getMerchantId());
|
||||||
// userCardLog.setMerchantCode(order.getMerchantCode());
|
// userCardLog.setMerchantCode(order.getMerchantCode());
|
||||||
|
|||||||
Reference in New Issue
Block a user