修复会员卡支付bug

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