Commit 87905ced by 吕明尚

增加次卡支付回调,修改次卡管理系统显示数据

parent b84e681a
......@@ -10,6 +10,7 @@ import share.common.core.page.TableDataInfo;
import share.common.enums.BusinessType;
import share.common.utils.poi.ExcelUtil;
import share.system.domain.ConsumerSecondaryCard;
import share.system.domain.vo.ConsumerSecondaryCardVo;
import share.system.service.ConsumerSecondaryCardService;
import javax.servlet.http.HttpServletResponse;
......@@ -32,9 +33,9 @@ public class ConsumerSecondaryCardController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:consumerSecondaryCard:list')")
@GetMapping("/list")
public TableDataInfo list(ConsumerSecondaryCard consumerSecondaryCard) {
public TableDataInfo list(ConsumerSecondaryCardVo consumerSecondaryCard) {
startPage();
List<ConsumerSecondaryCard> list = consumerSecondaryCardService.selectConsumerSecondaryCardList(consumerSecondaryCard);
List<ConsumerSecondaryCardVo> list = consumerSecondaryCardService.selectConsumerSecondaryCardList(consumerSecondaryCard);
return getDataTable(list);
}
......@@ -44,9 +45,9 @@ public class ConsumerSecondaryCardController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:consumerSecondaryCard:export')")
@Log(title = "用户次卡", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, ConsumerSecondaryCard consumerSecondaryCard) {
List<ConsumerSecondaryCard> list = consumerSecondaryCardService.selectConsumerSecondaryCardList(consumerSecondaryCard);
ExcelUtil<ConsumerSecondaryCard> util = new ExcelUtil<ConsumerSecondaryCard>(ConsumerSecondaryCard.class);
public void export(HttpServletResponse response, ConsumerSecondaryCardVo consumerSecondaryCard) {
List<ConsumerSecondaryCardVo> list = consumerSecondaryCardService.selectConsumerSecondaryCardList(consumerSecondaryCard);
ExcelUtil<ConsumerSecondaryCardVo> util = new ExcelUtil<ConsumerSecondaryCardVo>(ConsumerSecondaryCardVo.class);
util.exportExcel(response, list, "用户次卡数据");
}
......
......@@ -10,6 +10,7 @@ import share.common.core.page.TableDataInfo;
import share.common.enums.BusinessType;
import share.common.utils.poi.ExcelUtil;
import share.system.domain.SecondaryCardConf;
import share.system.domain.vo.SecondaryCardConfVo;
import share.system.service.SecondaryCardConfService;
import javax.servlet.http.HttpServletResponse;
......@@ -32,9 +33,9 @@ public class SecondaryCardConfController extends BaseController {
*/
@PreAuthorize("@ss.hasPermi('system:secondaryCardConf:list')")
@GetMapping("/list")
public TableDataInfo list(SecondaryCardConf secondaryCardConf) {
public TableDataInfo list(SecondaryCardConfVo secondaryCardConf) {
startPage();
List<SecondaryCardConf> list = secondaryCardConfService.selectSecondaryCardConfList(secondaryCardConf);
List<SecondaryCardConfVo> list = secondaryCardConfService.selectSecondaryCardConfList(secondaryCardConf);
return getDataTable(list);
}
......@@ -44,9 +45,9 @@ public class SecondaryCardConfController extends BaseController {
@PreAuthorize("@ss.hasPermi('system:secondaryCardConf:export')")
@Log(title = "次卡配置", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, SecondaryCardConf secondaryCardConf) {
List<SecondaryCardConf> list = secondaryCardConfService.selectSecondaryCardConfList(secondaryCardConf);
ExcelUtil<SecondaryCardConf> util = new ExcelUtil<SecondaryCardConf>(SecondaryCardConf.class);
public void export(HttpServletResponse response, SecondaryCardConfVo secondaryCardConf) {
List<SecondaryCardConfVo> list = secondaryCardConfService.selectSecondaryCardConfList(secondaryCardConf);
ExcelUtil<SecondaryCardConfVo> util = new ExcelUtil<SecondaryCardConfVo>(SecondaryCardConfVo.class);
util.exportExcel(response, list, "次卡配置数据");
}
......
......@@ -10,7 +10,13 @@ public enum OrderTypeEnum {
RESERVER(1,"reserver","预定"),
RENEW(2,"renew","续费"),
RECHARGE(3, "recharge", "充值"),
RIGHTS(4, "rights", "权益");
RIGHTS(4, "rights", "权益"),
//次卡
SECONDARY_CARD(5, "secondary_card", "次卡"),
//月卡
MONTH_CARD(6, "month_card", "月卡"),
;
private Integer code;
private String value;
......
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.page.TableDataInfo;
import share.system.domain.vo.ConsumerSecondaryCardVo;
import share.system.service.ConsumerSecondaryCardService;
import java.util.List;
/**
* 用户次卡Controller
*
* @author wuwenlong
* @date 2024-08-22
*/
@RestController
@RequestMapping("/consumerSecondaryCard")
public class ConsumerSecondaryCardController extends BaseController {
@Autowired
private ConsumerSecondaryCardService consumerSecondaryCardService;
/**
* 查询用户次卡列表
*/
@GetMapping("/list")
public TableDataInfo list(ConsumerSecondaryCardVo consumerSecondaryCard) {
startPage();
List<ConsumerSecondaryCardVo> list = consumerSecondaryCardService.selectConsumerSecondaryCardList(consumerSecondaryCard);
return getDataTable(list);
}
}
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.page.TableDataInfo;
import share.system.domain.vo.SecondaryCardConfVo;
import share.system.service.SecondaryCardConfService;
import java.util.List;
/**
* 次卡配置Controller
*
* @author wuwenlong
* @date 2024-08-22
*/
@RestController
@RequestMapping("/secondaryCardConf")
public class SecondaryCardConfController extends BaseController {
@Autowired
private SecondaryCardConfService secondaryCardConfService;
/**
* 查询次卡配置列表
*/
@GetMapping("/list")
public TableDataInfo list(SecondaryCardConfVo secondaryCardConf) {
startPage();
List<SecondaryCardConfVo> list = secondaryCardConfService.selectSecondaryCardConfList(secondaryCardConf);
return getDataTable(list);
}
}
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.page.TableDataInfo;
import share.system.domain.SecondaryCardLog;
import share.system.service.SecondaryCardLogService;
import java.util.List;
/**
* 次卡使用记录Controller
*
* @author wuwenlong
* @date 2024-08-22
*/
@RestController
@RequestMapping("/secondaryCardLog")
public class SecondaryCardLogController extends BaseController {
@Autowired
private SecondaryCardLogService secondaryCardLogService;
/**
* 查询次卡使用记录列表
*/
@GetMapping("/list")
public TableDataInfo list(SecondaryCardLog secondaryCardLog) {
startPage();
List<SecondaryCardLog> list = secondaryCardLogService.selectSecondaryCardLogList(secondaryCardLog);
return getDataTable(list);
}
}
package share.web.controller.system;
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.R;
import share.common.core.page.TableDataInfo;
import share.common.core.redis.RedisUtil;
import share.common.utils.JsonConvertUtil;
import share.system.domain.SecondaryCardOrder;
import share.system.request.SecondaryCardOrderRequest;
import share.system.response.SecondaryCardOrderPayResultResponse;
import share.system.service.SecondaryCardOrderService;
import java.util.List;
/**
* 次卡购买记录Controller
*
* @author wuwenlong
* @date 2024-08-22
*/
@Slf4j
@RestController
@RequestMapping("/secondaryCardOrder")
public class SecondaryCardOrderController extends BaseController {
@Autowired
private SecondaryCardOrderService secondaryCardOrderService;
@Autowired
private RedisUtil redisUtil;
/**
* 查询次卡购买记录列表
*/
@GetMapping("/list")
public TableDataInfo list(SecondaryCardOrder secondaryCardOrder) {
startPage();
List<SecondaryCardOrder> list = secondaryCardOrderService.selectSecondaryCardOrderList(secondaryCardOrder);
return getDataTable(list);
}
@PostMapping("/createSecondaryCardOrder")
public R<SecondaryCardOrderPayResultResponse> createOrder(@RequestBody @Validated SecondaryCardOrderRequest request) {
if ("1".equals(redisUtil.frontInOutLogSwitch())) {
log.debug("SecondaryCardOrderController method preOrder 入参 {}", JsonConvertUtil.write2JsonStr(request));
}
SecondaryCardOrderPayResultResponse response = secondaryCardOrderService.createSecondaryCardOrder(request);
if ("1".equals(redisUtil.frontInOutLogSwitch())) {
log.debug("SecondaryCardOrderController method preOrder 出参 {}", JsonConvertUtil.write2JsonStr(response));
}
return R.ok(response);
}
}
......@@ -2,12 +2,15 @@ package share.system.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import share.common.annotation.Excel;
import share.common.core.domain.BaseEntity;
import java.util.Date;
/**
* 用户次卡对象 s_consumer_secondary_card
*
......@@ -47,17 +50,21 @@ public class ConsumerSecondaryCard extends BaseEntity {
@Excel(name = "套餐id")
private Long packId;
/**
* 次卡有效期
*/
@Excel(name = "次卡有效期")
private Long validityPeriod;
// /**
// * 次卡有效期
// */
// @Excel(name = "次卡有效期")
// private Long validityPeriod;
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "次卡有效期", width = 30, dateFormat = "yyyy-MM-dd")
private Date expirationDate;
/**
* 次卡次数
*/
@Excel(name = "次卡次数")
private Long number;
private Integer number;
/**
* 删除标记:1-删除,0-正常
......@@ -65,7 +72,7 @@ public class ConsumerSecondaryCard extends BaseEntity {
//逻辑删除注解(0 未删除 1 已删除)
@TableLogic
@TableField(select = false)
private Long isDelete;
private Integer isDelete;
@Override
......@@ -76,7 +83,7 @@ public class ConsumerSecondaryCard extends BaseEntity {
.append("consumerId", getConsumerId())
.append("phone", getPhone())
.append("packId", getPackId())
.append("validityPeriod", getValidityPeriod())
.append("expirationDate", getExpirationDate())
.append("number", getNumber())
.append("isDelete", getIsDelete())
.append("createBy", getCreateBy())
......
......@@ -47,13 +47,13 @@ public class SecondaryCardConf extends BaseEntity {
* 次卡有效期
*/
@Excel(name = "次卡有效期")
private Long validityPeriod;
private Integer validityPeriod;
/**
* 次卡次数
*/
@Excel(name = "次卡次数")
private Long number;
private Integer number;
/**
* 是否删除(0:否,1:是)
......
......@@ -73,13 +73,13 @@ public class SecondaryCardOrder 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;
/**
* 支付时间
......
package share.system.domain.vo;
import lombok.Data;
import share.system.domain.ConsumerSecondaryCard;
import java.math.BigDecimal;
@Data
public class ConsumerSecondaryCardVo extends ConsumerSecondaryCard {
//用户昵称
private String nickName;
//用户头像
private String avatar;
//套餐名称
private String packName;
//套餐金额
private BigDecimal packPrice;
//配置名称
private String confName;
//次卡金额
private BigDecimal confAmount;
}
package share.system.domain.vo;
import lombok.Data;
import share.system.domain.SecondaryCardConf;
import java.math.BigDecimal;
@Data
public class SecondaryCardConfVo extends SecondaryCardConf {
//套餐名称
private String packName;
//套餐金额
private BigDecimal packPrice;
}
package share.system.domain.vo;
import lombok.Data;
import share.system.domain.SecondaryCardLog;
import java.math.BigDecimal;
@Data
public class SecondaryCardLogVo extends SecondaryCardLog {
//用户昵称
private String nickName;
//用户头像
private String avatar;
//套餐名称
private String packName;
//套餐金额
private BigDecimal packPrice;
}
package share.system.domain.vo;
import lombok.Data;
import share.system.domain.SecondaryCardOrder;
import java.math.BigDecimal;
@Data
public class SecondaryCardOrderVo extends SecondaryCardOrder {
//用户昵称
private String nickName;
//用户头像
private String avatar;
//套餐名称
private String packName;
//套餐金额
private BigDecimal packPrice;
//配置名称
private String confName;
//次卡金额
private BigDecimal confAmount;
}
......@@ -2,6 +2,7 @@ package share.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.ConsumerSecondaryCard;
import share.system.domain.vo.ConsumerSecondaryCardVo;
import java.util.List;
......@@ -26,7 +27,7 @@ public interface ConsumerSecondaryCardMapper extends BaseMapper<ConsumerSecondar
* @param consumerSecondaryCard 用户次卡
* @return 用户次卡集合
*/
public List<ConsumerSecondaryCard> selectConsumerSecondaryCardList(ConsumerSecondaryCard consumerSecondaryCard);
public List<ConsumerSecondaryCardVo> selectConsumerSecondaryCardList(ConsumerSecondaryCardVo consumerSecondaryCard);
/**
* 新增用户次卡
......
......@@ -2,6 +2,7 @@ package share.system.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import share.system.domain.SecondaryCardConf;
import share.system.domain.vo.SecondaryCardConfVo;
import java.util.List;
......@@ -26,7 +27,7 @@ public interface SecondaryCardConfMapper extends BaseMapper<SecondaryCardConf> {
* @param secondaryCardConf 次卡配置
* @return 次卡配置集合
*/
public List<SecondaryCardConf> selectSecondaryCardConfList(SecondaryCardConf secondaryCardConf);
public List<SecondaryCardConfVo> selectSecondaryCardConfList(SecondaryCardConfVo secondaryCardConf);
/**
* 新增次卡配置
......
......@@ -59,4 +59,6 @@ public interface SecondaryCardOrderMapper extends BaseMapper<SecondaryCardOrder>
* @return 结果
*/
public int deleteSecondaryCardOrderByIds(Long[] ids);
SecondaryCardOrder getInfoByEntity(SecondaryCardOrder secondaryCardOrderParam);
}
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 = "SecondaryCardOrderRequest对象", description = "次卡下单请求对象")
public class SecondaryCardOrderRequest {
@ApiModelProperty(value = "支付类型(1:微信,2:支付宝)", required = true)
@NotNull(message = "支付类型不能为空")
private Integer payType;
@ApiModelProperty(value = "次卡配置表id")
@NotNull(message = "次卡配置表id")
private Long secondaryCardConfId;
}
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 = "SecondaryCardOrderPayResultResponse对象", description = "订单支付结果响应对象")
public class SecondaryCardOrderPayResultResponse {
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 secondaryCardNo;
@ApiModelProperty(value = "微信支付回调的url")
private String notifyUrl;
}
......@@ -2,6 +2,7 @@ package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.ConsumerSecondaryCard;
import share.system.domain.vo.ConsumerSecondaryCardVo;
import java.util.List;
......@@ -26,7 +27,7 @@ public interface ConsumerSecondaryCardService extends IService<ConsumerSecondary
* @param consumerSecondaryCard 用户次卡
* @return 用户次卡集合
*/
public List<ConsumerSecondaryCard> selectConsumerSecondaryCardList(ConsumerSecondaryCard consumerSecondaryCard);
public List<ConsumerSecondaryCardVo> selectConsumerSecondaryCardList(ConsumerSecondaryCardVo consumerSecondaryCard);
/**
* 新增用户次卡
......
......@@ -3,9 +3,11 @@ 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;
/**
* @Author wwl
......@@ -36,4 +38,5 @@ public interface OrderPayService {
EquityMembersResultResponse saobeiEquityMembersOrderPayment(EquityMembersOrder equityMembersOrder);
SecondaryCardOrderPayResultResponse saobeiSecondaryCardOrderPayment(SecondaryCardOrder secondaryCardOrder);
}
......@@ -2,6 +2,7 @@ package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SecondaryCardConf;
import share.system.domain.vo.SecondaryCardConfVo;
import java.util.List;
......@@ -26,7 +27,7 @@ public interface SecondaryCardConfService extends IService<SecondaryCardConf> {
* @param secondaryCardConf 次卡配置
* @return 次卡配置集合
*/
public List<SecondaryCardConf> selectSecondaryCardConfList(SecondaryCardConf secondaryCardConf);
public List<SecondaryCardConfVo> selectSecondaryCardConfList(SecondaryCardConfVo secondaryCardConf);
/**
* 新增次卡配置
......
......@@ -2,6 +2,8 @@ package share.system.service;
import com.baomidou.mybatisplus.extension.service.IService;
import share.system.domain.SecondaryCardOrder;
import share.system.request.SecondaryCardOrderRequest;
import share.system.response.SecondaryCardOrderPayResultResponse;
import java.util.List;
......@@ -59,4 +61,10 @@ public interface SecondaryCardOrderService extends IService<SecondaryCardOrder>
* @return 结果
*/
public int deleteSecondaryCardOrderById(Long id);
SecondaryCardOrderPayResultResponse createSecondaryCardOrder(SecondaryCardOrderRequest request);
void paymentSuccessful(SecondaryCardOrder secondaryCardOrder);
SecondaryCardOrder getInfoByEntity(SecondaryCardOrder secondaryCardOrderParam);
}
......@@ -73,6 +73,9 @@ public class CallbackServiceImpl implements CallbackService {
@Autowired
private EquityMembersOrderService equityMembersOrderService;
@Autowired
private SecondaryCardOrderService secondaryCardOrderService;
/**
* 微信支付回调
*/
......@@ -537,6 +540,84 @@ public class CallbackServiceImpl implements CallbackService {
return responseVo;
}
break;
case SECONDARY_CARD:
logger.debug("开始次卡订单回调");
SecondaryCardOrder secondaryCardOrderParam = new SecondaryCardOrder();
secondaryCardOrderParam.setTerminalTrace(param.getTerminal_trace());
secondaryCardOrderParam.setConsumerId(attachVo.getUserId());
SecondaryCardOrder secondaryCardOrder = secondaryCardOrderService.getInfoByEntity(secondaryCardOrderParam);
if (ObjectUtil.isNull(secondaryCardOrder)) {
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(secondaryCardOrder.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 secondaryCardOrderPayInfo = wechatPayInfoService.getByNo(secondaryCardOrder.getTerminalTrace());
if (ObjectUtil.isNull(secondaryCardOrderPayInfo)) {
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());
secondaryCardOrderPayInfo.setBankType(param.getBank_type());
secondaryCardOrderPayInfo.setCashFee(Integer.valueOf(param.getTotal_fee()));
// wechatPayInfo.setTransactionId(param.getOut_trade_no());
secondaryCardOrderPayInfo.setTimeEnd(param.getEnd_time());
secondaryCardOrderPayInfo.setTimeExpire(param.getEnd_time());
Boolean secondaryCardBoolean = Boolean.FALSE;
try {
secondaryCardOrder.setPayStatus(YesNoEnum.yes.getIndex());
secondaryCardOrder.setPayTime(DateUtils.getNowDate());
secondaryCardOrderService.paymentSuccessful(secondaryCardOrder);
secondaryCardOrderPayInfo.setTradeState("1");
secondaryCardOrderPayInfo.setTradeStateDesc("支付成功");
wechatPayInfoService.updateById(secondaryCardOrderPayInfo);
secondaryCardBoolean = Boolean.TRUE;
} catch (Exception e) {
logger.error("微信支付回调出错");
logger.error(e.toString());
}
logger.debug("结束权益会员订单回调");
if (!secondaryCardBoolean) {
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,6 +5,7 @@ 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.vo.ConsumerSecondaryCardVo;
import share.system.mapper.ConsumerSecondaryCardMapper;
import share.system.service.ConsumerSecondaryCardService;
......@@ -39,7 +40,7 @@ public class ConsumerSecondaryCardServiceImpl extends ServiceImpl<ConsumerSecond
* @return 用户次卡
*/
@Override
public List<ConsumerSecondaryCard> selectConsumerSecondaryCardList(ConsumerSecondaryCard consumerSecondaryCard) {
public List<ConsumerSecondaryCardVo> selectConsumerSecondaryCardList(ConsumerSecondaryCardVo consumerSecondaryCard) {
return consumerSecondaryCardMapper.selectConsumerSecondaryCardList(consumerSecondaryCard);
}
......
......@@ -20,14 +20,12 @@ import share.common.exception.base.BaseException;
import share.common.utils.BaseUtil;
import share.common.utils.DateUtil;
import share.common.utils.JsonConvertUtil;
import share.system.domain.EquityMembersOrder;
import share.system.domain.Recharge;
import share.system.domain.SConsumerToken;
import share.system.domain.SOrder;
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.service.*;
import share.system.util.WxPayUtil;
......@@ -62,6 +60,10 @@ public class OrderPayServiceImpl implements OrderPayService {
private RechargeService rechargeService;
@Autowired
private EquityMembersOrderService equityMembersOrderService;
@Autowired
private SecondaryCardOrderService secondaryCardOrderService;
@Autowired
private SecondaryCardConfService secondaryCardConfService;
/**
* 获取域名
......@@ -405,4 +407,77 @@ public class OrderPayServiceImpl implements OrderPayService {
return vo;
}
@Override
public SecondaryCardOrderPayResultResponse saobeiSecondaryCardOrderPayment(SecondaryCardOrder secondaryCardOrder) {
SecondaryCardOrderPayResultResponse response = new SecondaryCardOrderPayResultResponse();
response.setSecondaryCardNo(secondaryCardOrder.getSecondaryCardNo());
response.setPayType(PayTypeEnum.getEnumByCode(secondaryCardOrder.getPayType()).getValue());
response.setStatus(YesNoEnum.no.getFlag());
// 扫呗支付
ConcurrentHashMap<String, String> unifiedorder = saobeiUnifiedSecondaryCardOrder(secondaryCardOrder);
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"));
// 更新商户订单号
secondaryCardOrder.setOutTradeNo(unifiedorder.get("outTradeNo"));
secondaryCardOrder.setTerminalTrace(unifiedorder.get("terminalTrace"));
secondaryCardOrderService.updateById(secondaryCardOrder);
response.setJsConfig(vo);
return response;
}
private ConcurrentHashMap<String, String> saobeiUnifiedSecondaryCardOrder(SecondaryCardOrder secondaryCardOrder) {
// 获取用户openId
SConsumerToken userToken = consumerTokenService.getTokenByUserId(secondaryCardOrder.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 = getSaobeiUnifiedSecondaryCardOrderVo(secondaryCardOrder, 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 getSaobeiUnifiedSecondaryCardOrderVo(SecondaryCardOrder secondaryCardOrder, String openid, String appId, String mchId, String signKey) {
AttachVo attachVo = new AttachVo(OrderTypeEnum.SECONDARY_CARD.getValue(), secondaryCardOrder.getConsumerId());
SecondaryCardConf byId = secondaryCardConfService.getById(secondaryCardOrder.getSecondaryCardConfId());
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.getSecondaryCardAmount() + "元" + byId.getName() + "次卡"));
// 订单中使用的是BigDecimal,这里要转为Integer类型
vo.setTotal_fee(String.valueOf(secondaryCardOrder.getSecondaryCardAmount().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;
}
}
......@@ -5,6 +5,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import share.common.utils.DateUtils;
import share.system.domain.SecondaryCardConf;
import share.system.domain.vo.SecondaryCardConfVo;
import share.system.mapper.SecondaryCardConfMapper;
import share.system.service.SecondaryCardConfService;
......@@ -39,7 +40,7 @@ public class SecondaryCardConfServiceImpl extends ServiceImpl<SecondaryCardConfM
* @return 次卡配置
*/
@Override
public List<SecondaryCardConf> selectSecondaryCardConfList(SecondaryCardConf secondaryCardConf) {
public List<SecondaryCardConfVo> selectSecondaryCardConfList(SecondaryCardConfVo secondaryCardConf) {
return secondaryCardConfMapper.selectSecondaryCardConfList(secondaryCardConf);
}
......
package share.system.service.impl;
import cn.hutool.core.util.ObjectUtil;
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.ConsumerSecondaryCard;
import share.system.domain.SConsumer;
import share.system.domain.SecondaryCardConf;
import share.system.domain.SecondaryCardOrder;
import share.system.domain.vo.FrontTokenComponent;
import share.system.mapper.SecondaryCardOrderMapper;
import share.system.service.SecondaryCardOrderService;
import share.system.request.SecondaryCardOrderRequest;
import share.system.response.SecondaryCardOrderPayResultResponse;
import share.system.service.*;
import java.util.Date;
import java.util.List;
/**
......@@ -20,6 +33,14 @@ import java.util.List;
public class SecondaryCardOrderServiceImpl extends ServiceImpl<SecondaryCardOrderMapper, SecondaryCardOrder> implements SecondaryCardOrderService {
@Autowired
private SecondaryCardOrderMapper secondaryCardOrderMapper;
@Autowired
private SConsumerService sConsumerService;
@Autowired
private OrderPayService orderPayService;
@Autowired
private SecondaryCardConfService secondaryCardConfService;
@Autowired
private ConsumerSecondaryCardService consumerSecondaryCardService;
/**
* 查询次卡购买记录
......@@ -88,4 +109,57 @@ public class SecondaryCardOrderServiceImpl extends ServiceImpl<SecondaryCardOrde
public int deleteSecondaryCardOrderById(Long id) {
return secondaryCardOrderMapper.deleteSecondaryCardOrderById(id);
}
@Override
public SecondaryCardOrderPayResultResponse createSecondaryCardOrder(SecondaryCardOrderRequest 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("请绑定手机号");
}
}
SecondaryCardOrder secondaryCardOrder = generatSecondaryCardOrder(request, user);
secondaryCardOrder.setCreateTime(new Date());
save(secondaryCardOrder);
SecondaryCardOrderPayResultResponse response = orderPayService.saobeiSecondaryCardOrderPayment(secondaryCardOrder);
return response;
}
private SecondaryCardOrder generatSecondaryCardOrder(SecondaryCardOrderRequest request, SConsumer user) {
SecondaryCardOrder secondaryCardOrder = new SecondaryCardOrder();
BeanUtils.copyProperties(request, secondaryCardOrder);
SecondaryCardConf byId = secondaryCardConfService.getById(request.getSecondaryCardConfId());
if (ObjectUtil.isEmpty(byId)) {
throw new BaseException("次卡配置异常");
}
secondaryCardOrder.setSecondaryCardNo(BaseUtil.getOrderNo("CK"));
secondaryCardOrder.setSecondaryCardAmount(byId.getSecondaryCardAmount());
secondaryCardOrder.setPayStatus(YesNoEnum.no.getIndex());
secondaryCardOrder.setConsumerId(user.getId());
secondaryCardOrder.setPhone(user.getPhone());
return secondaryCardOrder;
}
@Override
public void paymentSuccessful(SecondaryCardOrder secondaryCardOrder) {
ConsumerSecondaryCard consumerSecondaryCard = new ConsumerSecondaryCard();
SecondaryCardConf secondaryCardConf = secondaryCardConfService.getById(secondaryCardOrder.getSecondaryCardConfId());
consumerSecondaryCard.setSecondaryCardConfId(secondaryCardOrder.getSecondaryCardConfId());
consumerSecondaryCard.setConsumerId(secondaryCardOrder.getConsumerId());
consumerSecondaryCard.setPhone(secondaryCardOrder.getPhone());
consumerSecondaryCard.setPackId(secondaryCardConf.getPackId());
consumerSecondaryCard.setExpirationDate(DateUtils.addYears(new Date(), secondaryCardConf.getValidityPeriod()));
consumerSecondaryCard.setNumber(secondaryCardConf.getNumber());
consumerSecondaryCardService.save(consumerSecondaryCard);
}
@Override
public SecondaryCardOrder getInfoByEntity(SecondaryCardOrder secondaryCardOrderParam) {
return secondaryCardOrderMapper.getInfoByEntity(secondaryCardOrderParam);
}
}
......@@ -4,13 +4,19 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="share.system.mapper.ConsumerSecondaryCardMapper">
<resultMap type="ConsumerSecondaryCard" id="ConsumerSecondaryCardResult">
<resultMap type="ConsumerSecondaryCardVo" id="ConsumerSecondaryCardResult">
<result property="id" column="id"/>
<result property="secondaryCardConfId" column="secondary_card_conf_id"/>
<result property="confName" column="conf_name"/>
<result property="confAmount" column="conf_amount"/>
<result property="consumerId" column="consumer_id"/>
<result property="nickName" column="nick_name"/>
<result property="avatar" column="avatar"/>
<result property="phone" column="phone"/>
<result property="packId" column="pack_id"/>
<result property="validityPeriod" column="validity_period"/>
<result property="packName" column="pack_name"/>
<result property="packPrice" column="pack_price"/>
<result property="expirationDate" column="expiration_date"/>
<result property="number" column="number"/>
<result property="isDelete" column="is_delete"/>
<result property="createBy" column="create_by"/>
......@@ -26,7 +32,7 @@
consumer_id,
phone,
pack_id,
validity_period,
expiration_date,
number,
is_delete,
create_by,
......@@ -37,18 +43,39 @@
from s_consumer_secondary_card
</sql>
<select id="selectConsumerSecondaryCardList" parameterType="ConsumerSecondaryCard"
<select id="selectConsumerSecondaryCardList" parameterType="ConsumerSecondaryCardVo"
resultMap="ConsumerSecondaryCardResult">
<include refid="selectConsumerSecondaryCardVo"/>
<where>
<if test="secondaryCardConfId != null ">and secondary_card_conf_id = #{secondaryCardConfId}</if>
<if test="consumerId != null ">and consumer_id = #{consumerId}</if>
<if test="phone != null and phone != ''">and phone = #{phone}</if>
<if test="packId != null ">and pack_id = #{packId}</if>
<if test="validityPeriod != null ">and validity_period = #{validityPeriod}</if>
<if test="number != null ">and number = #{number}</if>
<if test="isDelete != null ">and is_delete = #{isDelete}</if>
</where>
select c.id,
c.secondary_card_conf_id,
c.consumer_id,
c.phone,
m.nick_name,
m.avatar,
p.name as 'pack_name',
p.price as 'pack_price',
c2.name as 'conf_name',
c2.secondary_card_amount as 'conf_amount',
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
join s_pack p on c.pack_id = p.id join s_secondary_card_conf c2 on c.secondary_card_conf_id = c2.id
where
c.is_delete = 0
<if test="secondaryCardConfId != null ">and c.secondary_card_conf_id = #{secondaryCardConfId}</if>
<if test="consumerId != null ">and c.consumer_id = #{consumerId}</if>
<if test="phone != null and phone != ''">and c.phone = #{phone}</if>
<if test="packId != null ">and c.pack_id = #{packId}</if>
<if test="expirationDate != null ">and c.expiration_date = #{expirationDate}</if>
<if test="number != null ">and c.number = #{number}</if>
<if test="isDelete != null ">and c.is_delete = #{isDelete}</if>
</select>
<select id="selectConsumerSecondaryCardById" parameterType="Long" resultMap="ConsumerSecondaryCardResult">
......@@ -64,7 +91,7 @@
<if test="consumerId != null">consumer_id,</if>
<if test="phone != null and phone != ''">phone,</if>
<if test="packId != null">pack_id,</if>
<if test="validityPeriod != null">validity_period,</if>
<if test="expirationDate != null">expiration_date,</if>
<if test="number != null">number,</if>
<if test="isDelete != null">is_delete,</if>
<if test="createBy != null">create_by,</if>
......@@ -78,7 +105,7 @@
<if test="consumerId != null">#{consumerId},</if>
<if test="phone != null and phone != ''">#{phone},</if>
<if test="packId != null">#{packId},</if>
<if test="validityPeriod != null">#{validityPeriod},</if>
<if test="expirationDate != null">#{expiration_date},</if>
<if test="number != null">#{number},</if>
<if test="isDelete != null">#{isDelete},</if>
<if test="createBy != null">#{createBy},</if>
......@@ -96,7 +123,7 @@
<if test="consumerId != null">consumer_id = #{consumerId},</if>
<if test="phone != null and phone != ''">phone = #{phone},</if>
<if test="packId != null">pack_id = #{packId},</if>
<if test="validityPeriod != null">validity_period = #{validityPeriod},</if>
<if test="expirationDate != null">expiration_date = #{expirationDate},</if>
<if test="number != null">number = #{number},</if>
<if test="isDelete != null">is_delete = #{isDelete},</if>
<if test="createBy != null">create_by = #{createBy},</if>
......
......@@ -4,11 +4,13 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="share.system.mapper.SecondaryCardConfMapper">
<resultMap type="SecondaryCardConf" id="SecondaryCardConfResult">
<resultMap type="SecondaryCardConfVo" id="SecondaryCardConfResult">
<result property="id" column="id"/>
<result property="name" column="name"/>
<result property="secondaryCardAmount" column="secondary_card_amount"/>
<result property="packId" column="pack_id"/>
<result property="packName" column="pack_name"/>
<result property="packPrice" column="pack_price"/>
<result property="validityPeriod" column="validity_period"/>
<result property="number" column="number"/>
<result property="isDelete" column="is_delete"/>
......@@ -35,8 +37,22 @@
from s_secondary_card_conf
</sql>
<select id="selectSecondaryCardConfList" parameterType="SecondaryCardConf" resultMap="SecondaryCardConfResult">
<include refid="selectSecondaryCardConfVo"/>
<select id="selectSecondaryCardConfList" parameterType="SecondaryCardConfVo" resultMap="SecondaryCardConfResult">
select c.id,
c.name,
c.secondary_card_amount,
c.pack_id,
p.name as pack_name,
p.price as pack_price,
c.validity_period,
c.number,
c.is_delete,
c.create_by,
c.create_time,
c.update_by,
c.update_time,
c.remark
from s_secondary_card_conf c join s_pack p on c.pack_id = p.id
<where>
<if test="name != null and name != ''">and name like concat('%', #{name}, '%')</if>
<if test="secondaryCardAmount != null ">and secondary_card_amount = #{secondaryCardAmount}</if>
......
......@@ -4,12 +4,16 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="share.system.mapper.SecondaryCardLogMapper">
<resultMap type="SecondaryCardLog" id="SecondaryCardLogResult">
<resultMap type="SecondaryCardLogVo" id="SecondaryCardLogResult">
<result property="id" column="id"/>
<result property="consumerSecondaryCardId" column="consumer_secondary_card_id"/>
<result property="consumerId" column="consumer_id"/>
<result property="nickName" column="nick_name"/>
<result property="avatar" column="avatar"/>
<result property="phone" column="phone"/>
<result property="packId" column="pack_id"/>
<result property="packName" column="pack_name"/>
<result property="packPrice" column="pack_price"/>
<result property="usageCount" column="usage_count"/>
<result property="residueCount" column="residue_count"/>
<result property="isDelete" column="is_delete"/>
......@@ -38,15 +42,33 @@
</sql>
<select id="selectSecondaryCardLogList" parameterType="SecondaryCardLog" resultMap="SecondaryCardLogResult">
<include refid="selectSecondaryCardLogVo"/>
select l.id,
l.consumer_secondary_card_id,
l. consumer_id,
c.name as nick_name,
c.avatar,
l.phone,
l.pack_id,
p.name as pack_name,
p.price as pack_price,
l.usage_count,
l.residue_count,
l.is_delete,
l.create_by,
l.create_time,
l. update_by,
l.update_time,
l.remark
from s_secondary_card_log l join s_pack p on l.pack_id = p.id join s_consumer c on l.consumer_id = c.id
<where>
<if test="consumerSecondaryCardId != null ">and consumer_secondary_card_id = #{consumerSecondaryCardId}</if>
<if test="consumerId != null ">and consumer_id = #{consumerId}</if>
<if test="phone != null and phone != ''">and phone = #{phone}</if>
<if test="packId != null ">and pack_id = #{packId}</if>
<if test="usageCount != null ">and usage_count = #{usageCount}</if>
<if test="residueCount != null ">and residue_count = #{residueCount}</if>
<if test="isDelete != null ">and is_delete = #{isDelete}</if>
<if test="consumerSecondaryCardId != null ">and l.consumer_secondary_card_id = #{consumerSecondaryCardId}
</if>
<if test="consumerId != null ">and l.consumer_id = #{consumerId}</if>
<if test="phone != null and phone != ''">and l.phone = #{phone}</if>
<if test="packId != null ">and l.pack_id = #{packId}</if>
<if test="usageCount != null ">and l.usage_count = #{usageCount}</if>
<if test="residueCount != null ">and l.residue_count = #{residueCount}</if>
<if test="isDelete != null ">and l.is_delete = #{isDelete}</if>
</where>
</select>
......
......@@ -67,6 +67,10 @@
<include refid="selectSecondaryCardOrderVo"/>
where id = #{id}
</select>
<select id="getInfoByEntity" resultType="share.system.domain.SecondaryCardOrder">
<include refid="selectSecondaryCardOrderVo"/>
where terminal_trace=#{terminalTrace} and consumer_id=#{consumerId}
</select>
<insert id="insertSecondaryCardOrder" parameterType="SecondaryCardOrder" useGeneratedKeys="true" keyProperty="id">
insert into s_secondary_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