Commit 300b1541 by 吕明尚

增加次卡购买

parent 0046f57c
package share.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.system.domain.vo.ConsumerMonthlyCardVo;
import share.system.service.ConsumerMonthlyCardService;
import java.util.List;
/**
* 用户月卡Controller
*
* @author wuwenlong
* @date 2024-08-27
*/
@RestController
@RequestMapping("/consumerMonthlyCard")
public class ConsumerMonthlyCardController extends BaseController {
@Autowired
private ConsumerMonthlyCardService consumerMonthlyCardService;
/**
* 查询用户月卡列表
*/
@GetMapping("/list")
public TableDataInfo list(ConsumerMonthlyCardVo consumerMonthlyCard) {
startPage();
List<ConsumerMonthlyCardVo> list = consumerMonthlyCardService.selectConsumerMonthlyCardList(consumerMonthlyCard);
return getDataTable(list);
}
@GetMapping("/query")
public AjaxResult selectByConsumerId() {
return success(consumerMonthlyCardService.selectByConsumerId());
}
}
......@@ -5,6 +5,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.system.domain.vo.ConsumerSecondaryCardVo;
import share.system.service.ConsumerSecondaryCardService;
......@@ -33,4 +34,9 @@ public class ConsumerSecondaryCardController extends BaseController {
return getDataTable(list);
}
@GetMapping("/query")
public AjaxResult selectByConsumerId() {
return success(consumerSecondaryCardService.selectByConsumerId());
}
}
package share.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.core.controller.BaseController;
import share.common.core.domain.R;
import share.common.core.page.TableDataInfo;
import share.system.domain.MonthlyCardConf;
import share.system.service.MonthlyCardConfService;
import java.util.List;
/**
* 月卡配置Controller
*
* @author wuwenlong
* @date 2024-08-27
*/
@RestController
@RequestMapping("/monthlyCardConf")
public class MonthlyCardConfController extends BaseController {
@Autowired
private MonthlyCardConfService monthlyCardConfService;
/**
* 查询月卡配置列表
*/
@GetMapping("/list")
public TableDataInfo list(MonthlyCardConf monthlyCardConf) {
startPage();
List<MonthlyCardConf> list = monthlyCardConfService.selectMonthlyCardConfList(monthlyCardConf);
return getDataTable(list);
}
/**
* 查询月卡配置列表
*/
@GetMapping("/list")
public R<List<MonthlyCardConf>> query() {
return R.ok(monthlyCardConfService.selectMonthlyCardConfList(null));
}
}
package share.web.controller.system;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.page.TableDataInfo;
import share.system.domain.SConsumer;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MonthlyCardLogVo;
import share.system.service.MonthlyCardLogService;
import java.util.List;
/**
* 月卡使用记录Controller
*
* @author wuwenlong
* @date 2024-08-27
*/
@RestController
@RequestMapping("/monthlyCardLog")
public class MonthlyCardLogController extends BaseController {
@Autowired
private MonthlyCardLogService monthlyCardLogService;
/**
* 查询月卡使用记录列表
*/
@GetMapping("/list")
public TableDataInfo list(MonthlyCardLogVo monthlyCardLog) {
startPage();
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
monthlyCardLog.setConsumerId(user.getId());
List<MonthlyCardLogVo> list = monthlyCardLogService.selectMonthlyCardLogList(monthlyCardLog);
return getDataTable(list);
}
@GetMapping("/query")
public AjaxResult query(MonthlyCardLogVo monthlyCardLog) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
monthlyCardLog.setConsumerId(user.getId());
return success(monthlyCardLogService.selectMonthlyCardLogList(monthlyCardLog));
}
}
package share.web.controller.system;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import share.common.core.controller.BaseController;
import share.common.core.domain.AjaxResult;
import share.common.core.domain.R;
import share.common.core.page.TableDataInfo;
import share.common.core.redis.RedisUtil;
import share.common.utils.JsonConvertUtil;
import share.system.domain.SConsumer;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MonthlyCardOrderVo;
import share.system.request.CreateMonthlyCardRequest;
import share.system.response.MonthlyyCardPayResultResponse;
import share.system.service.MonthlyCardOrderService;
import java.util.List;
/**
* 月卡订单Controller
*
* @author wuwenlong
* @date 2024-08-27
*/
@Slf4j
@RestController
@RequestMapping("/monthlyCardOrder")
public class MonthlyCardOrderController extends BaseController {
@Autowired
private MonthlyCardOrderService monthlyCardOrderService;
@Autowired
private RedisUtil redisUtil;
/**
* 查询月卡订单列表
*/
@GetMapping("/list")
public TableDataInfo list(MonthlyCardOrderVo monthlyCardOrder) {
startPage();
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
monthlyCardOrder.setConsumerId(user.getId());
List<MonthlyCardOrderVo> list = monthlyCardOrderService.selectMonthlyCardOrderList(monthlyCardOrder);
return getDataTable(list);
}
@GetMapping("/query")
public AjaxResult query(MonthlyCardOrderVo monthlyCardOrder) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
monthlyCardOrder.setConsumerId(user.getId());
List<MonthlyCardOrderVo> list = monthlyCardOrderService.selectMonthlyCardOrderList(monthlyCardOrder);
return success(list);
}
@PostMapping("/createMonthlyCard")
public R<MonthlyyCardPayResultResponse> createOrder(@RequestBody @Validated CreateMonthlyCardRequest request) {
if ("1".equals(redisUtil.frontInOutLogSwitch())) {
log.debug("MonthlyCardOrderController method preOrder 入参 {}", JsonConvertUtil.write2JsonStr(request));
}
MonthlyyCardPayResultResponse response = monthlyCardOrderService.createMonthlyCard(request);
if ("1".equals(redisUtil.frontInOutLogSwitch())) {
log.debug("MonthlyCardOrderController method preOrder 出参 {}", JsonConvertUtil.write2JsonStr(response));
}
return R.ok(response);
}
@ApiOperation(value = "通过订单编号查询订单")
@GetMapping(value = "/{monthlyCardNo}")
public R<MonthlyCardOrderVo> queryMonthlyCardInfoByNo(@PathVariable("monthlyCardNo") String monthlyCardNo) {
return R.ok(monthlyCardOrderService.queryMonthlyCardInfoByNo(monthlyCardNo));
}
}
package share.web.controller.system;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
......@@ -53,4 +54,10 @@ public class SecondaryCardOrderController extends BaseController {
}
return R.ok(response);
}
@ApiOperation(value = "通过订单编号查询订单")
@GetMapping(value = "/{secondaryCardNo}")
public R<SecondaryCardOrderVo> querySecondaryCardInfoByNo(@PathVariable("secondaryCardNo") String secondaryCardNo) {
return R.ok(secondaryCardOrderService.querySecondaryCardInfoByNo(secondaryCardNo));
}
}
......@@ -73,13 +73,13 @@ public class MonthlyCardOrder extends BaseEntity {
* 支付方式
*/
@Excel(name = "支付方式")
private Long payType;
private Integer payType;
/**
* 状态:0-待支付,1-支付成功,2-退款中,3-退款完成
*/
@Excel(name = "状态:0-待支付,1-支付成功,2-退款中,3-退款完成")
private Long payStatus;
private Integer payStatus;
/**
* 支付时间
......
......@@ -60,4 +60,6 @@ public interface ConsumerMonthlyCardMapper extends BaseMapper<ConsumerMonthlyCar
* @return 结果
*/
public int deleteConsumerMonthlyCardByIds(Long[] ids);
ConsumerMonthlyCardVo selectByConsumerId(ConsumerMonthlyCardVo consumerMemberVo);
}
......@@ -60,4 +60,6 @@ public interface ConsumerSecondaryCardMapper extends BaseMapper<ConsumerSecondar
* @return 结果
*/
public int deleteConsumerSecondaryCardByIds(Long[] ids);
List<ConsumerSecondaryCardVo> selectByConsumerId(ConsumerSecondaryCardVo vo);
}
......@@ -60,4 +60,6 @@ public interface MonthlyCardOrderMapper extends BaseMapper<MonthlyCardOrder> {
* @return 结果
*/
public int deleteMonthlyCardOrderByIds(Long[] ids);
MonthlyCardOrder getInfoByEntity(MonthlyCardOrder monthlyCardOrder);
}
package share.system.request;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "CreateMonthlyCardRequest对象", description = "下单请求对象")
public class CreateMonthlyCardRequest {
@ApiModelProperty(value = "支付类型(1:微信,2:支付宝)", required = true)
@NotNull(message = "支付类型不能为空")
private Integer payType;
@ApiModelProperty(value = "充值配置表id")
@NotNull(message = "充值配置表id")
private Long monthlyCardConfId;
}
......@@ -27,7 +27,7 @@ public class EquityMembersResultResponse {
private String payType;
@ApiModelProperty(value = "订单编号")
private String rechargeNo;
private String equityOrderNo;
@ApiModelProperty(value = "微信支付回调的url")
private String notifyUrl;
......
package share.system.response;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import share.system.domain.vo.WxPayJsResultVo;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "MonthlyyCardPayResultResponse对象", description = "订单支付结果响应对象")
public class MonthlyyCardPayResultResponse {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "支付状态")
private Boolean status;
@ApiModelProperty(value = "微信调起支付参数对象")
private WxPayJsResultVo jsConfig;
@ApiModelProperty(value = "支付类型")
private String payType;
@ApiModelProperty(value = "订单编号")
private String monthlyCardNo;
@ApiModelProperty(value = "微信支付回调的url")
private String notifyUrl;
}
......@@ -60,4 +60,6 @@ public interface ConsumerMonthlyCardService extends IService<ConsumerMonthlyCard
* @return 结果
*/
public int deleteConsumerMonthlyCardById(Long id);
ConsumerMonthlyCardVo selectByConsumerId();
}
......@@ -60,4 +60,6 @@ public interface ConsumerSecondaryCardService extends IService<ConsumerSecondary
* @return 结果
*/
public int deleteConsumerSecondaryCardById(Long id);
List<ConsumerSecondaryCardVo> selectByConsumerId();
}
......@@ -3,6 +3,8 @@ package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.MonthlyCardOrder;
import share.system.domain.vo.MonthlyCardOrderVo;
import share.system.request.CreateMonthlyCardRequest;
import share.system.response.MonthlyyCardPayResultResponse;
import java.util.List;
......@@ -60,4 +62,12 @@ public interface MonthlyCardOrderService extends IService<MonthlyCardOrder> {
* @return 结果
*/
public int deleteMonthlyCardOrderById(Long id);
MonthlyyCardPayResultResponse createMonthlyCard(CreateMonthlyCardRequest request);
MonthlyCardOrderVo queryMonthlyCardInfoByNo(String monthlyCardNo);
void paymentSuccessful(MonthlyCardOrder monthlyCardOrder);
MonthlyCardOrder getInfoByEntity(MonthlyCardOrder monthlyCardOrder);
}
package share.system.service;
import share.system.domain.EquityMembersOrder;
import share.system.domain.Recharge;
import share.system.domain.SOrder;
import share.system.domain.SecondaryCardOrder;
import share.system.response.EquityMembersResultResponse;
import share.system.response.OrderPayResultResponse;
import share.system.response.RechargePayResultResponse;
import share.system.response.SecondaryCardOrderPayResultResponse;
import share.system.domain.*;
import share.system.response.*;
/**
* @Author wwl
......@@ -39,4 +33,6 @@ public interface OrderPayService {
EquityMembersResultResponse saobeiEquityMembersOrderPayment(EquityMembersOrder equityMembersOrder);
SecondaryCardOrderPayResultResponse saobeiSecondaryCardOrderPayment(SecondaryCardOrder secondaryCardOrder);
MonthlyyCardPayResultResponse saobeiCreateMonthlyCardOrderPayment(MonthlyCardOrder monthlyCardOrder);
}
......@@ -68,4 +68,6 @@ public interface SecondaryCardOrderService extends IService<SecondaryCardOrder>
void paymentSuccessful(SecondaryCardOrder secondaryCardOrder);
SecondaryCardOrder getInfoByEntity(SecondaryCardOrder secondaryCardOrderParam);
SecondaryCardOrderVo querySecondaryCardInfoByNo(String secondaryCardNo);
}
......@@ -76,6 +76,9 @@ public class CallbackServiceImpl implements CallbackService {
@Autowired
private SecondaryCardOrderService secondaryCardOrderService;
@Autowired
private MonthlyCardOrderService monthlyCardOrderService;
/**
* 微信支付回调
*/
......@@ -618,6 +621,84 @@ public class CallbackServiceImpl implements CallbackService {
return responseVo;
}
break;
case MONTH_CARD:
logger.debug("开始月卡订单回调");
MonthlyCardOrder monthlyCardOrderParam = new MonthlyCardOrder();
monthlyCardOrderParam.setTerminalTrace(param.getTerminal_trace());
monthlyCardOrderParam.setConsumerId(attachVo.getUserId());
MonthlyCardOrder monthlyCardOrder = monthlyCardOrderService.getInfoByEntity(monthlyCardOrderParam);
if (ObjectUtil.isNull(monthlyCardOrder)) {
logger.error("saobei wechat pay error : 订单信息不存在==》" + param.getTerminal_trace());
responseVo.setReturn_code(SaobeiStatusEnum.FAIL.getCode());
responseVo.setReturn_msg("订单信息不存在!");
// 保存api日志
saobeiApiLog.setResponseParams(JSONUtil.toJsonStr(responseVo));
saobeiApiLog.setResult(responseVo.getReturn_code());
saobeiApiLog.setResultMsg(responseVo.getReturn_msg());
saobeiApiLog.setOutTradeNo(param.getOut_trade_no());
saobeiApiLogService.insertSaobeiApiLog(saobeiApiLog);
return responseVo;
}
if (YesNoEnum.yes.getIndex().equals(monthlyCardOrder.getPayStatus())) {
logger.error("saobei wechat pay error : 订单已处理==》" + param.getTerminal_trace());
responseVo.setReturn_code(SaobeiStatusEnum.SUCCESS.getCode());
responseVo.setReturn_msg("success");
// 保存api日志
saobeiApiLog.setResponseParams(JSONUtil.toJsonStr(responseVo));
saobeiApiLog.setResult(responseVo.getReturn_code());
saobeiApiLog.setResultMsg(responseVo.getReturn_msg());
saobeiApiLog.setOutTradeNo(param.getOut_trade_no());
saobeiApiLogService.insertSaobeiApiLog(saobeiApiLog);
return responseVo;
}
WechatPayInfo monthlyCardOrderPayInfo = wechatPayInfoService.getByNo(monthlyCardOrder.getTerminalTrace());
if (ObjectUtil.isNull(monthlyCardOrderPayInfo)) {
logger.error("saobei wechat pay error : 微信订单信息不存在==》" + param.getTerminal_trace());
responseVo.setReturn_code(SaobeiStatusEnum.FAIL.getCode());
responseVo.setReturn_msg("微信订单信息不存在!");
// 保存api日志
saobeiApiLog.setResponseParams(JSONUtil.toJsonStr(responseVo));
saobeiApiLog.setResult(responseVo.getReturn_code());
saobeiApiLog.setResultMsg(responseVo.getReturn_msg());
saobeiApiLog.setOutTradeNo(param.getOut_trade_no());
saobeiApiLogService.insertSaobeiApiLog(saobeiApiLog);
return responseVo;
}
// wechatPayInfo.setIsSubscribe(param.getIsSubscribe());
monthlyCardOrderPayInfo.setBankType(param.getBank_type());
monthlyCardOrderPayInfo.setCashFee(Integer.valueOf(param.getTotal_fee()));
// wechatPayInfo.setTransactionId(param.getOut_trade_no());
monthlyCardOrderPayInfo.setTimeEnd(param.getEnd_time());
monthlyCardOrderPayInfo.setTimeExpire(param.getEnd_time());
Boolean monthlyCardBoolean = Boolean.FALSE;
try {
monthlyCardOrder.setPayStatus(YesNoEnum.yes.getIndex());
monthlyCardOrder.setPayTime(DateUtils.getNowDate());
monthlyCardOrderService.paymentSuccessful(monthlyCardOrder);
monthlyCardOrderPayInfo.setTradeState("1");
monthlyCardOrderPayInfo.setTradeStateDesc("支付成功");
wechatPayInfoService.updateById(monthlyCardOrderPayInfo);
monthlyCardBoolean = Boolean.TRUE;
} catch (Exception e) {
logger.error("微信支付回调出错");
logger.error(e.toString());
}
logger.debug("结束权益会员订单回调");
if (!monthlyCardBoolean) {
logger.error("saobei wechat pay error : 订单更新失败==》" + param.getTerminal_trace());
responseVo.setReturn_code(SaobeiStatusEnum.FAIL.getCode());
responseVo.setReturn_msg("订单更新失败!");
// 保存api日志
saobeiApiLog.setResponseParams(JSONUtil.toJsonStr(responseVo));
saobeiApiLog.setResult(responseVo.getReturn_code());
saobeiApiLog.setResultMsg(responseVo.getReturn_msg());
saobeiApiLog.setOutTradeNo(param.getOut_trade_no());
saobeiApiLogService.insertSaobeiApiLog(saobeiApiLog);
return responseVo;
}
break;
default:
logger.error("wechat pay err : 未知的支付类型==》" + param.getTerminal_trace());
break;
......
......@@ -5,9 +5,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.utils.DateUtils;
import share.system.domain.ConsumerMonthlyCard;
import share.system.domain.SConsumer;
import share.system.domain.vo.ConsumerMonthlyCardVo;
import share.system.mapper.ConsumerMonthlyCardMapper;
import share.system.service.ConsumerMonthlyCardService;
import share.system.service.SConsumerService;
import java.util.List;
......@@ -21,6 +23,8 @@ import java.util.List;
public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyCardMapper, ConsumerMonthlyCard> implements ConsumerMonthlyCardService {
@Autowired
private ConsumerMonthlyCardMapper consumerMonthlyCardMapper;
@Autowired
private SConsumerService sConsumerService;
/**
* 查询用户月卡
......@@ -89,4 +93,12 @@ public class ConsumerMonthlyCardServiceImpl extends ServiceImpl<ConsumerMonthlyC
public int deleteConsumerMonthlyCardById(Long id) {
return consumerMonthlyCardMapper.deleteConsumerMonthlyCardById(id);
}
@Override
public ConsumerMonthlyCardVo selectByConsumerId() {
SConsumer info = sConsumerService.getInfo();
ConsumerMonthlyCardVo vo = new ConsumerMonthlyCardVo();
vo.setConsumerId(info.getId());
return consumerMonthlyCardMapper.selectByConsumerId(vo);
}
}
......@@ -5,9 +5,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.utils.DateUtils;
import share.system.domain.ConsumerSecondaryCard;
import share.system.domain.SConsumer;
import share.system.domain.vo.ConsumerSecondaryCardVo;
import share.system.mapper.ConsumerSecondaryCardMapper;
import share.system.service.ConsumerSecondaryCardService;
import share.system.service.SConsumerService;
import java.util.List;
......@@ -21,6 +23,8 @@ import java.util.List;
public class ConsumerSecondaryCardServiceImpl extends ServiceImpl<ConsumerSecondaryCardMapper, ConsumerSecondaryCard> implements ConsumerSecondaryCardService {
@Autowired
private ConsumerSecondaryCardMapper consumerSecondaryCardMapper;
@Autowired
private SConsumerService sConsumerService;
/**
* 查询用户次卡
......@@ -89,4 +93,12 @@ public class ConsumerSecondaryCardServiceImpl extends ServiceImpl<ConsumerSecond
public int deleteConsumerSecondaryCardById(Long id) {
return consumerSecondaryCardMapper.deleteConsumerSecondaryCardById(id);
}
@Override
public List<ConsumerSecondaryCardVo> selectByConsumerId() {
SConsumer info = sConsumerService.getInfo();
ConsumerSecondaryCardVo vo = new ConsumerSecondaryCardVo();
vo.setConsumerId(info.getId());
return consumerSecondaryCardMapper.selectByConsumerId(vo);
}
}
package share.system.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.enums.YesNoEnum;
import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil;
import share.common.utils.DateUtils;
import share.common.utils.bean.BeanUtils;
import share.system.domain.ConsumerMonthlyCard;
import share.system.domain.MonthlyCardConf;
import share.system.domain.MonthlyCardOrder;
import share.system.domain.SConsumer;
import share.system.domain.vo.FrontTokenComponent;
import share.system.domain.vo.MonthlyCardOrderVo;
import share.system.mapper.MonthlyCardOrderMapper;
import share.system.service.MonthlyCardOrderService;
import share.system.request.CreateMonthlyCardRequest;
import share.system.response.MonthlyyCardPayResultResponse;
import share.system.service.*;
import java.util.Date;
import java.util.List;
/**
......@@ -21,6 +36,14 @@ import java.util.List;
public class MonthlyCardOrderServiceImpl extends ServiceImpl<MonthlyCardOrderMapper, MonthlyCardOrder> implements MonthlyCardOrderService {
@Autowired
private MonthlyCardOrderMapper monthlyCardOrderMapper;
@Autowired
private SConsumerService sConsumerService;
@Autowired
private OrderPayService orderPayService;
@Autowired
private MonthlyCardConfService monthlyCardConfService;
@Autowired
private ConsumerMonthlyCardService consumerMonthlyCardService;
/**
* 查询月卡订单
......@@ -89,4 +112,66 @@ public class MonthlyCardOrderServiceImpl extends ServiceImpl<MonthlyCardOrderMap
public int deleteMonthlyCardOrderById(Long id) {
return monthlyCardOrderMapper.deleteMonthlyCardOrderById(id);
}
@Override
public MonthlyyCardPayResultResponse createMonthlyCard(CreateMonthlyCardRequest request) {
SConsumer user = FrontTokenComponent.getWxSConsumerEntry();
if (ObjectUtil.isNull(user)) {
throw new BaseException("您的登录已过期,请先登录");
}
if (StringUtils.isEmpty(user.getPhone())) {
user = sConsumerService.getById(user.getId());
if (StringUtils.isEmpty(user.getPhone())) {
throw new BaseException("请绑定手机号");
}
}
MonthlyCardOrder monthlyCardOrder = generatMonthlyCarddOrder(request, user);
monthlyCardOrder.setCreateTime(new Date());
save(monthlyCardOrder);
MonthlyyCardPayResultResponse response = orderPayService.saobeiCreateMonthlyCardOrderPayment(monthlyCardOrder);
return response;
}
private MonthlyCardOrder generatMonthlyCarddOrder(CreateMonthlyCardRequest request, SConsumer user) {
MonthlyCardOrder monthlyCardOrder = new MonthlyCardOrder();
BeanUtils.copyProperties(request, monthlyCardOrder);
MonthlyCardConf byId = monthlyCardConfService.getById(request.getMonthlyCardConfId());
if (ObjectUtil.isEmpty(byId)) {
throw new BaseException("月卡配置异常");
}
monthlyCardOrder.setMonthlyCardNo(BaseUtil.getOrderNo("YK"));
monthlyCardOrder.setMonthlyCardAmount(byId.getMonthlyCardAmount());
monthlyCardOrder.setPayStatus(YesNoEnum.no.getIndex());
monthlyCardOrder.setConsumerId(user.getId());
monthlyCardOrder.setPhone(user.getPhone());
return monthlyCardOrder;
}
@Override
public MonthlyCardOrderVo queryMonthlyCardInfoByNo(String monthlyCardNo) {
LambdaQueryWrapper<MonthlyCardOrder> lqw = Wrappers.lambdaQuery();
lqw.eq(MonthlyCardOrder::getMonthlyCardNo, monthlyCardNo);
MonthlyCardOrder one = getOne(lqw);
MonthlyCardOrderVo vo = new MonthlyCardOrderVo();
BeanUtils.copyProperties(one, vo);
return vo;
}
@Override
public void paymentSuccessful(MonthlyCardOrder monthlyCardOrder) {
ConsumerMonthlyCard consumerMonthlyCard = new ConsumerMonthlyCard();
MonthlyCardConf byId = monthlyCardConfService.getById(monthlyCardOrder.getMonthlyCardConfId());
consumerMonthlyCard.setMonthlyCardConfId(byId.getId());
consumerMonthlyCard.setConsumerId(monthlyCardOrder.getConsumerId());
consumerMonthlyCard.setPhone(monthlyCardOrder.getPhone());
consumerMonthlyCard.setExpirationDate(DateUtils.addYears(new Date(), byId.getMonthlyCardDays().intValue()));
consumerMonthlyCard.setFreeDuration(byId.getFreeDuration());
consumerMonthlyCard.setMonthlyCardDays(byId.getMonthlyCardDays());
consumerMonthlyCardService.save(consumerMonthlyCard);
}
@Override
public MonthlyCardOrder getInfoByEntity(MonthlyCardOrder monthlyCardOrder) {
return monthlyCardOrderMapper.getInfoByEntity(monthlyCardOrder);
}
}
......@@ -22,10 +22,7 @@ import share.common.utils.DateUtil;
import share.common.utils.JsonConvertUtil;
import share.system.domain.*;
import share.system.domain.vo.*;
import share.system.response.EquityMembersResultResponse;
import share.system.response.OrderPayResultResponse;
import share.system.response.RechargePayResultResponse;
import share.system.response.SecondaryCardOrderPayResultResponse;
import share.system.response.*;
import share.system.service.*;
import share.system.util.WxPayUtil;
......@@ -64,6 +61,10 @@ public class OrderPayServiceImpl implements OrderPayService {
private SecondaryCardOrderService secondaryCardOrderService;
@Autowired
private SecondaryCardConfService secondaryCardConfService;
@Autowired
private MonthlyCardOrderService monthlyCardOrderService;
@Autowired
private MonthlyCardConfService monthlyCardConfService;
/**
* 获取域名
......@@ -337,7 +338,7 @@ public class OrderPayServiceImpl implements OrderPayService {
@Override
public EquityMembersResultResponse saobeiEquityMembersOrderPayment(EquityMembersOrder equityMembersOrder) {
EquityMembersResultResponse response = new EquityMembersResultResponse();
response.setRechargeNo(equityMembersOrder.getEquityOrderNo());
response.setEquityOrderNo(equityMembersOrder.getEquityOrderNo());
response.setPayType(PayTypeEnum.getEnumByCode(equityMembersOrder.getPayType().intValue()).getValue());
response.setStatus(YesNoEnum.no.getFlag());
// 扫呗支付
......@@ -480,4 +481,77 @@ public class OrderPayServiceImpl implements OrderPayService {
return vo;
}
@Override
public MonthlyyCardPayResultResponse saobeiCreateMonthlyCardOrderPayment(MonthlyCardOrder monthlyCardOrder) {
MonthlyyCardPayResultResponse response = new MonthlyyCardPayResultResponse();
response.setMonthlyCardNo(monthlyCardOrder.getMonthlyCardNo());
response.setPayType(PayTypeEnum.getEnumByCode(monthlyCardOrder.getPayType()).getValue());
response.setStatus(YesNoEnum.no.getFlag());
// 扫呗支付
ConcurrentHashMap<String, String> unifiedorder = saobeiUnifiedMonthlyCardOrder(monthlyCardOrder);
WxPayJsResultVo vo = new WxPayJsResultVo();
vo.setAppId(unifiedorder.get("appId"));
vo.setNonceStr(unifiedorder.get("nonceStr"));
vo.setPackages(unifiedorder.get("package"));
vo.setSignType(unifiedorder.get("signType"));
vo.setTimeStamp(unifiedorder.get("timeStamp"));
vo.setPaySign(unifiedorder.get("paySign"));
// 更新商户订单号
monthlyCardOrder.setOutTradeNo(unifiedorder.get("outTradeNo"));
monthlyCardOrder.setTerminalTrace(unifiedorder.get("terminalTrace"));
monthlyCardOrderService.updateById(monthlyCardOrder);
response.setJsConfig(vo);
return response;
}
private ConcurrentHashMap<String, String> saobeiUnifiedMonthlyCardOrder(MonthlyCardOrder monthlyCardOrder) {
// 获取用户openId
SConsumerToken userToken = consumerTokenService.getTokenByUserId(monthlyCardOrder.getConsumerId());
if (ObjectUtil.isNull(userToken)) {
throw new BaseException("该用户没有openId");
}
// 获取appid、mch_id
// 微信签名key
String appId = weChatConfig.getAppId();
String mchId = weChatConfig.getMchId();
String signKey = weChatConfig.getSignKey();
// 获取扫呗微信预下单对象
SaobeiMiniPayRequestVo unifiedorderVo = getSaobeiUnifiedMonthlyCardOrderVo(monthlyCardOrder, userToken.getToken(), appId, mchId, signKey);
// 预下单(统一下单)
SaobeiMiniPayResponse response = saobeiService.wechatMinipay(unifiedorderVo);
logger.debug("SaobeiMiniPayResponse :", JsonConvertUtil.write2JsonStr(response));
// 组装前端预下单参数
ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
map.put("appId", response.getAppId());
map.put("nonceStr", response.getNonceStr());
map.put("package", response.getPackage_str());
map.put("signType", response.getSignType());
map.put("timeStamp", response.getTimeStamp());
map.put("paySign", response.getPaySign());
map.put("prepayTime", DateUtil.nowDateTimeStr());
map.put("outTradeNo", response.getOut_trade_no());
map.put("terminalTrace", unifiedorderVo.getTerminal_trace());
return map;
}
private SaobeiMiniPayRequestVo getSaobeiUnifiedMonthlyCardOrderVo(MonthlyCardOrder monthlyCardOrder, String openid, String appId, String mchId, String signKey) {
AttachVo attachVo = new AttachVo(OrderTypeEnum.MONTH_CARD.getValue(), monthlyCardOrder.getConsumerId());
MonthlyCardConf byId = monthlyCardConfService.getById(monthlyCardOrder.getMonthlyCardConfId());
SaobeiMiniPayRequestVo vo = new SaobeiMiniPayRequestVo();
vo.setSub_appid(appId);
vo.setMerchant_no(saobeiConfig.getMerchantNo());
vo.setTerminal_id(saobeiConfig.getTerminalId());
vo.setAttach(JSONObject.toJSONString(attachVo));
vo.setTerminal_trace(BaseUtil.getOrderNo("WXNO"));
vo.setTerminal_time(DateUtil.nowDate(Constants.DATE_TIME_FORMAT_NUM));
vo.setOrder_body(StrUtil.concat(true, "购买" + byId.getMonthlyCardAmount() + "元" + byId.getName() + "月卡"));
// 订单中使用的是BigDecimal,这里要转为Integer类型
vo.setTotal_fee(String.valueOf(monthlyCardOrder.getMonthlyCardAmount().multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue()));
vo.setNotify_url(apiDomain + PayConstants.SAOBEI_PAY_NOTIFY_API_URI);
vo.setTrade_type(PayConstants.WX_PAY_TRADE_TYPE_JS);
vo.setOpen_id(openid);
vo.setDevice_no("WEB");
return vo;
}
}
package share.system.service.impl;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -163,4 +164,14 @@ public class SecondaryCardOrderServiceImpl extends ServiceImpl<SecondaryCardOrde
public SecondaryCardOrder getInfoByEntity(SecondaryCardOrder secondaryCardOrderParam) {
return secondaryCardOrderMapper.getInfoByEntity(secondaryCardOrderParam);
}
@Override
public SecondaryCardOrderVo querySecondaryCardInfoByNo(String secondaryCardNo) {
LambdaQueryWrapper<SecondaryCardOrder> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(SecondaryCardOrder::getSecondaryCardNo, secondaryCardNo);
SecondaryCardOrder secondaryCardOrder = getOne(wrapper);
SecondaryCardOrderVo vo = new SecondaryCardOrderVo();
BeanUtils.copyProperties(secondaryCardOrder, vo);
return vo;
}
}
......@@ -75,6 +75,27 @@
<include refid="selectConsumerMonthlyCardVo"/>
where id = #{id}
</select>
<select id="selectByConsumerId" resultMap="ConsumerMonthlyCardResult">
select c.id,
c.monthly_card_conf_id,
c.consumer_id,
c2.nick_name,
c2.avatar,
c.phone,
c.free_duration,
c.monthly_card_days,
c.expiration_date,
c.is_delete,
c.create_by,
c.create_time,
c.update_by,
c.update_time,
c.remark
from s_consumer_monthly_card c
join s_consumer c2 on c.consumer_id = c2.id
where c.is_delete = 0
and c.consumer_id = #{consumerId}
</select>
<insert id="insertConsumerMonthlyCard" parameterType="ConsumerMonthlyCard" useGeneratedKeys="true" keyProperty="id">
insert into s_consumer_monthly_card
......
......@@ -80,6 +80,27 @@
<include refid="selectConsumerSecondaryCardVo"/>
where id = #{id}
</select>
<select id="selectByConsumerId" resultMap="ConsumerSecondaryCardResult">
select c.id,
c.secondary_card_conf_id,
c.consumer_id,
c.phone,
m.nick_name,
m.avatar,
c.pack_id,
c.expiration_date,
c.number,
c.is_delete,
c.create_by,
c.create_time,
c.update_by,
c.update_time,
c.remark
from s_consumer_secondary_card c
join s_consumer m on c.consumer_id = m.id
where c.is_delete = 0
and c.consumer_id = #{consumerId}
</select>
<insert id="insertConsumerSecondaryCard" parameterType="ConsumerSecondaryCard" useGeneratedKeys="true"
keyProperty="id">
......
......@@ -90,6 +90,10 @@
<include refid="selectMonthlyCardOrderVo"/>
where id = #{id}
</select>
<select id="getInfoByEntity" resultType="share.system.domain.MonthlyCardOrder">
<include refid="selectMonthlyCardOrderVo"/>
where terminal_trace=#{terminalTrace} and consumer_id=#{consumerId}
</select>
<insert id="insertMonthlyCardOrder" parameterType="MonthlyCardOrder" useGeneratedKeys="true" keyProperty="id">
insert into s_monthly_card_order
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment