支付
This commit is contained in:
32
zhwl-business/zhwl-prepaid-card/pom.xml
Normal file
32
zhwl-business/zhwl-prepaid-card/pom.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.zhwl</groupId>
|
||||
<artifactId>zhwl-business</artifactId>
|
||||
<version>3.8.7</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>zhwl-prepaid-card</artifactId>
|
||||
<description>一卡通模块</description>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.zhwl</groupId>
|
||||
<artifactId>zhwl-framework</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.zhwl</groupId>
|
||||
<artifactId>zhwl-payment</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@@ -0,0 +1,153 @@
|
||||
package com.zhwl.prepaidCard.controller;
|
||||
|
||||
import com.zhwl.common.annotation.Log;
|
||||
import com.zhwl.common.core.controller.BaseController;
|
||||
import com.zhwl.common.core.domain.AjaxResult;
|
||||
import com.zhwl.common.core.page.TableDataInfo;
|
||||
import com.zhwl.common.enums.BusinessType;
|
||||
import com.zhwl.common.utils.poi.ExcelUtil;
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCard;
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCardLog;
|
||||
import com.zhwl.prepaidCard.service.IPrepaidCardLogService;
|
||||
import com.zhwl.prepaidCard.service.IPrepaidCardService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 一卡通Controller
|
||||
*
|
||||
* @author duanyashu
|
||||
* @date 2024-08-19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/prepaidCard/card")
|
||||
public class PrepaidCardController extends BaseController {
|
||||
@Autowired
|
||||
private IPrepaidCardService prepaidCardService;
|
||||
@Autowired
|
||||
private IPrepaidCardLogService prepaidCardLogService;
|
||||
|
||||
/**
|
||||
* 查询一卡通列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:card:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PrepaidCard prepaidCard) {
|
||||
startPage();
|
||||
List<PrepaidCard> list = prepaidCardService.selectPrepaidCardList(prepaidCard);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出一卡通列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:card:export')")
|
||||
@Log(title = "一卡通", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PrepaidCard prepaidCard) {
|
||||
List<PrepaidCard> list = prepaidCardService.selectPrepaidCardList(prepaidCard);
|
||||
ExcelUtil<PrepaidCard> util = new ExcelUtil<PrepaidCard>(PrepaidCard. class);
|
||||
util.exportExcel(response, list, "一卡通数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一卡通详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:card:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(prepaidCardService.selectPrepaidCardById(id));
|
||||
}
|
||||
/**
|
||||
* 获取一卡通详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:card:query')")
|
||||
@GetMapping("/account/{accountNo}")
|
||||
public AjaxResult getInfo(@PathVariable("accountNo") String accountNo) {
|
||||
return success(prepaidCardService.selectPrepaidCardByAccountNo(accountNo));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增一卡通
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:card:add')")
|
||||
@Log(title = "一卡通", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@Validated @RequestBody PrepaidCard prepaidCard) {
|
||||
PrepaidCard prepaid = prepaidCardService.selectPrepaidCardByAccountNo(prepaidCard.getAccountNo());
|
||||
if (prepaid!=null){
|
||||
return AjaxResult.error("卡号已开通,禁止多次开通");
|
||||
}
|
||||
prepaid = prepaidCardService.selectPrepaidCardByPhone(prepaidCard.getPhone());
|
||||
if (prepaid!=null){
|
||||
return AjaxResult.error("当前手机号已有开卡,卡号:"+prepaid.getAccountNo());
|
||||
}
|
||||
prepaidCard.setType("1");
|
||||
prepaidCard.setCreateBy(getUserId()+"");
|
||||
return toAjax(prepaidCardService.insertPrepaidCard(prepaidCard));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改一卡通
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:card:edit')")
|
||||
@Log(title = "一卡通", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PrepaidCard prepaidCard) {
|
||||
return toAjax(prepaidCardService.updatePrepaidCard(prepaidCard));
|
||||
}
|
||||
/**
|
||||
* 换卡
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:card:edit')")
|
||||
@Log(title = "一卡通", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/updCard")
|
||||
public AjaxResult updAccountNo(@RequestBody PrepaidCard prepaidCard) {
|
||||
PrepaidCard prepaidCard1 = prepaidCardService.selectPrepaidCardByAccountNo(prepaidCard.getAccountNo());
|
||||
if (prepaidCard1!=null){
|
||||
return AjaxResult.error("当前卡已开通,禁止再次开通");
|
||||
}
|
||||
return toAjax(prepaidCardService.updAccountNo(prepaidCard));
|
||||
}
|
||||
/**
|
||||
* 进行退款
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:card:edit')")
|
||||
@Log(title = "一卡通", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/refund")
|
||||
public AjaxResult refund(@Validated @RequestBody PrepaidCard prepaidCard) {
|
||||
if (prepaidCard.getId()==null){
|
||||
return AjaxResult.error("参数错误");
|
||||
}
|
||||
PrepaidCard prepaid = prepaidCardService.selectPrepaidCardById(prepaidCard.getId());
|
||||
if (prepaid==null){
|
||||
return AjaxResult.error("卡号不存在");
|
||||
}
|
||||
return toAjax(prepaidCardService.refund(prepaid));
|
||||
}
|
||||
/**
|
||||
* 进行充值
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:card:edit')")
|
||||
@Log(title = "一卡通", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/recharge")
|
||||
public AjaxResult recharge(@Validated @RequestBody PrepaidCardLog prepaidCardLog) {
|
||||
prepaidCardLog.setCreateBy(getUserId()+"");
|
||||
return toAjax(prepaidCardService.recharge(prepaidCardLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一卡通
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:card:remove')")
|
||||
@Log(title = "一卡通", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(prepaidCardService.deletePrepaidCardByIds(ids));
|
||||
}
|
||||
}
|
@@ -0,0 +1,91 @@
|
||||
package com.zhwl.prepaidCard.controller;
|
||||
|
||||
import com.zhwl.common.annotation.Log;
|
||||
import com.zhwl.common.core.controller.BaseController;
|
||||
import com.zhwl.common.core.domain.AjaxResult;
|
||||
import com.zhwl.common.core.page.TableDataInfo;
|
||||
import com.zhwl.common.enums.BusinessType;
|
||||
import com.zhwl.common.utils.poi.ExcelUtil;
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCardLog;
|
||||
import com.zhwl.prepaidCard.enums.PrepaidCardLogStatusEnum;
|
||||
import com.zhwl.prepaidCard.service.IPrepaidCardLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 一卡通交易记录Controller
|
||||
*
|
||||
* @author duanyashu
|
||||
* @date 2024-08-19
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/prepaidCard/log")
|
||||
public class PrepaidCardLogController extends BaseController {
|
||||
@Autowired
|
||||
private IPrepaidCardLogService prepaidCardLogService;
|
||||
|
||||
/**
|
||||
* 查询一卡通交易记录列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(PrepaidCardLog prepaidCardLog) {
|
||||
startPage();
|
||||
prepaidCardLog.setStatus(PrepaidCardLogStatusEnum.TRADE_FINISHED.getValue());
|
||||
List<PrepaidCardLog> list = prepaidCardLogService.selectPrepaidCardLogList(prepaidCardLog);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出一卡通交易记录列表
|
||||
*/
|
||||
@Log(title = "一卡通交易记录", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, PrepaidCardLog prepaidCardLog) {
|
||||
List<PrepaidCardLog> list = prepaidCardLogService.selectPrepaidCardLogList(prepaidCardLog);
|
||||
ExcelUtil<PrepaidCardLog> util = new ExcelUtil<PrepaidCardLog>(PrepaidCardLog.class);
|
||||
util.exportExcel(response, list, "一卡通交易记录数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取一卡通交易记录详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:log:query')")
|
||||
@GetMapping(value = "/{id}")
|
||||
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
||||
return success(prepaidCardLogService.selectPrepaidCardLogById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增一卡通交易记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:log:add')")
|
||||
@Log(title = "一卡通交易记录", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody PrepaidCardLog prepaidCardLog) {
|
||||
return toAjax(prepaidCardLogService.insertPrepaidCardLog(prepaidCardLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改一卡通交易记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:log:edit')")
|
||||
@Log(title = "一卡通交易记录", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody PrepaidCardLog prepaidCardLog) {
|
||||
return toAjax(prepaidCardLogService.updatePrepaidCardLog(prepaidCardLog));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一卡通交易记录
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('prepaidCard:log:remove')")
|
||||
@Log(title = "一卡通交易记录", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{ids}")
|
||||
public AjaxResult remove(@PathVariable Long[] ids) {
|
||||
return toAjax(prepaidCardLogService.deletePrepaidCardLogByIds(ids));
|
||||
}
|
||||
}
|
@@ -0,0 +1,132 @@
|
||||
package com.zhwl.prepaidCard.domain;
|
||||
|
||||
import com.zhwl.common.annotation.Excel;
|
||||
import com.zhwl.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 一卡通对象 zdy_prepaid_card
|
||||
*
|
||||
* @author duanyashu
|
||||
* @date 2024-08-19
|
||||
*/
|
||||
public class PrepaidCard extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 卡号
|
||||
*/
|
||||
@NotBlank(message = "卡号不能为空")
|
||||
@Excel(name = "卡号")
|
||||
private String accountNo;
|
||||
|
||||
/**
|
||||
* 类型(1实体卡,2虚拟卡)
|
||||
*/
|
||||
@Excel(name = "类型", readConverterExp = "1=实体卡,2虚拟卡")
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@Excel(name = "姓名")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
@Excel(name = "手机号")
|
||||
private String phone;
|
||||
|
||||
/**
|
||||
* 余额
|
||||
*/
|
||||
@Excel(name = "余额")
|
||||
private BigDecimal balance;
|
||||
|
||||
/**
|
||||
* 状态(1正常,2挂失,3退卡)
|
||||
*/
|
||||
@Excel(name = "状态", readConverterExp = "1=正常,2挂失,3退卡")
|
||||
private String status;
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setAccountNo(String accountNo) {
|
||||
this.accountNo = accountNo;
|
||||
}
|
||||
|
||||
public String getAccountNo() {
|
||||
return accountNo;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setPhone(String phone) {
|
||||
this.phone = phone;
|
||||
}
|
||||
|
||||
public String getPhone() {
|
||||
return phone;
|
||||
}
|
||||
|
||||
public void setBalance(BigDecimal balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public BigDecimal getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("accountNo", getAccountNo())
|
||||
.append("type", getType())
|
||||
.append("name", getName())
|
||||
.append("phone", getPhone())
|
||||
.append("balance", getBalance())
|
||||
.append("status", getStatus())
|
||||
.append("createTime", getCreateTime())
|
||||
.append("createBy", getCreateBy())
|
||||
.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,231 @@
|
||||
package com.zhwl.prepaidCard.domain;
|
||||
|
||||
import com.zhwl.common.annotation.Excel;
|
||||
import com.zhwl.common.core.domain.BaseEntity;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 一卡通交易记录对象 zdy_prepaid_card_log
|
||||
*
|
||||
* @author duanyashu
|
||||
* @date 2024-08-19
|
||||
*/
|
||||
public class PrepaidCardLog extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 开卡id
|
||||
*/
|
||||
private Long cardId;
|
||||
/**
|
||||
* 卡号
|
||||
*/
|
||||
@NotBlank(message = "卡号不能为空")
|
||||
@Excel(name = "卡号")
|
||||
private String accountNo;
|
||||
|
||||
/**
|
||||
* 类型(1实体卡,2虚拟卡)
|
||||
*/
|
||||
@Excel(name = "类型", readConverterExp = "1=实体卡,2虚拟卡")
|
||||
private String accountType;
|
||||
|
||||
/**
|
||||
* 姓名
|
||||
*/
|
||||
@Excel(name = "姓名")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 余额
|
||||
*/
|
||||
@Excel(name = "余额")
|
||||
private BigDecimal balance;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@Excel(name = "订单号")
|
||||
private String orderNo;
|
||||
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 交易类型(1充值,2消费)
|
||||
*/
|
||||
@Excel(name = "交易类型", readConverterExp = "1=充值,2消费")
|
||||
private String tradeType;
|
||||
|
||||
private String tradeTypeLabel;
|
||||
|
||||
/**
|
||||
* 交易金额
|
||||
*/
|
||||
@Excel(name = "交易金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
/**
|
||||
* 状态(1待支付,2已支付)
|
||||
*/
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 支付交易凭证
|
||||
*/
|
||||
private String transactionId;
|
||||
|
||||
/**
|
||||
* 支付订单号
|
||||
*/
|
||||
private String payNo;
|
||||
|
||||
/**
|
||||
* 退款单号
|
||||
*/
|
||||
private String refundCode;
|
||||
|
||||
|
||||
public Long getCardId() {
|
||||
return cardId;
|
||||
}
|
||||
|
||||
public void setCardId(Long cardId) {
|
||||
this.cardId = cardId;
|
||||
}
|
||||
|
||||
public String getTradeTypeLabel() {
|
||||
return tradeTypeLabel;
|
||||
}
|
||||
|
||||
public void setTradeTypeLabel(String tradeTypeLabel) {
|
||||
this.tradeTypeLabel = tradeTypeLabel;
|
||||
}
|
||||
|
||||
public String getRefundCode() {
|
||||
return refundCode;
|
||||
}
|
||||
|
||||
public void setRefundCode(String refundCode) {
|
||||
this.refundCode = refundCode;
|
||||
}
|
||||
|
||||
public String getPayNo() {
|
||||
return payNo;
|
||||
}
|
||||
|
||||
public void setPayNo(String payNo) {
|
||||
this.payNo = payNo;
|
||||
}
|
||||
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
|
||||
public void setTransactionId(String transactionId) {
|
||||
this.transactionId = transactionId;
|
||||
}
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getAccountNo() {
|
||||
return accountNo;
|
||||
}
|
||||
|
||||
public void setAccountNo(String accountNo) {
|
||||
this.accountNo = accountNo;
|
||||
}
|
||||
|
||||
public String getAccountType() {
|
||||
return accountType;
|
||||
}
|
||||
|
||||
public void setAccountType(String accountType) {
|
||||
this.accountType = accountType;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public BigDecimal getBalance() {
|
||||
return balance;
|
||||
}
|
||||
|
||||
public void setBalance(BigDecimal balance) {
|
||||
this.balance = balance;
|
||||
}
|
||||
|
||||
public String getOrderNo() {
|
||||
return orderNo;
|
||||
}
|
||||
|
||||
public void setOrderNo(String orderNo) {
|
||||
this.orderNo = orderNo;
|
||||
}
|
||||
|
||||
public String getTradeType() {
|
||||
return tradeType;
|
||||
}
|
||||
|
||||
public void setTradeType(String tradeType) {
|
||||
this.tradeType = tradeType;
|
||||
}
|
||||
|
||||
public BigDecimal getAmount() {
|
||||
return amount;
|
||||
}
|
||||
|
||||
public void setAmount(BigDecimal amount) {
|
||||
this.amount = amount;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
|
||||
.append("id", getId())
|
||||
.append("accountNo", getAccountNo())
|
||||
.append("accountType", getAccountType())
|
||||
.append("name", getName())
|
||||
.append("balance", getBalance())
|
||||
.append("orderNo", getOrderNo())
|
||||
.append("tradeType", getTradeType())
|
||||
.append("amount", getAmount())
|
||||
.append("createTime", getCreateTime())
|
||||
.toString();
|
||||
}
|
||||
}
|
@@ -0,0 +1,33 @@
|
||||
package com.zhwl.prepaidCard.domain.dto;
|
||||
|
||||
import com.zhwl.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 小程序一卡通充值请求参数
|
||||
* @date 2024/8/22 15:46
|
||||
*/
|
||||
@Data
|
||||
public class RechargePayDto implements Serializable {
|
||||
/** 卡号 */
|
||||
@NotBlank(message = "卡号不能为空")
|
||||
@Excel(name = "卡号")
|
||||
private String accountNo;
|
||||
|
||||
/** 交易金额 */
|
||||
@NotNull(message = "交易金额不能为空")
|
||||
@Excel(name = "交易金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
|
||||
private String openId;
|
||||
|
||||
private String createBy;
|
||||
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.zhwl.prepaidCard.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* 交易状态
|
||||
* 一卡通
|
||||
*
|
||||
* @author song_xiaowei
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum PrepaidCardLogStatusEnum {
|
||||
|
||||
/**
|
||||
* 待支付
|
||||
*/
|
||||
WAIT_BUYER_PAY("1"),
|
||||
|
||||
/**
|
||||
* 已支付
|
||||
*/
|
||||
TRADE_FINISHED("2");
|
||||
|
||||
private final String value;
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
package com.zhwl.prepaidCard.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* 交易类型
|
||||
* 一卡通
|
||||
*
|
||||
* @author song_xiaowei
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
public enum PrepaidCardTradeTypeEnum {
|
||||
|
||||
/**
|
||||
* 充值
|
||||
*/
|
||||
RECHARGE("1"),
|
||||
|
||||
/**
|
||||
* 消费
|
||||
*/
|
||||
CONSUME("2"),
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*/
|
||||
REFUND("3");
|
||||
|
||||
private final String value;
|
||||
}
|
@@ -0,0 +1,78 @@
|
||||
package com.zhwl.prepaidCard.mapper;
|
||||
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCardLog;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 一卡通交易记录Mapper接口
|
||||
*
|
||||
* @author duanyashu
|
||||
* @date 2024-08-19
|
||||
*/
|
||||
public interface PrepaidCardLogMapper {
|
||||
/**
|
||||
* 查询一卡通交易记录
|
||||
*
|
||||
* @param id 一卡通交易记录主键
|
||||
* @return 一卡通交易记录
|
||||
*/
|
||||
public PrepaidCardLog selectPrepaidCardLogById(Long id);
|
||||
|
||||
/**
|
||||
* 查询一卡通交易记录列表
|
||||
*
|
||||
* @param prepaidCardLog 一卡通交易记录
|
||||
* @return 一卡通交易记录集合
|
||||
*/
|
||||
public List<PrepaidCardLog> selectPrepaidCardLogList(PrepaidCardLog prepaidCardLog);
|
||||
|
||||
/**
|
||||
* 新增一卡通交易记录
|
||||
*
|
||||
* @param prepaidCardLog 一卡通交易记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPrepaidCardLog(PrepaidCardLog prepaidCardLog);
|
||||
|
||||
/**
|
||||
* 修改一卡通交易记录
|
||||
*
|
||||
* @param prepaidCardLog 一卡通交易记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePrepaidCardLog(PrepaidCardLog prepaidCardLog);
|
||||
public int updatePrepaidLogByAccountNo(@Param("oldAccountNo") String oldAccountNo,@Param("newAccountNo") String newAccountNo, @Param("name")String name);
|
||||
/**
|
||||
* 删除一卡通交易记录
|
||||
*
|
||||
* @param id 一卡通交易记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrepaidCardLogById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除一卡通交易记录
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrepaidCardLogByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 查询一卡通交易记录
|
||||
*
|
||||
* @param payNo 支付订单号
|
||||
* @return 一卡通交易记录
|
||||
*/
|
||||
PrepaidCardLog selectPrepaidCardLogByPayNo(String payNo);
|
||||
|
||||
/**
|
||||
* 根据订单号查询一卡通已支付交易记录
|
||||
*
|
||||
* @param prepaidCardLog 查询参数
|
||||
* @return 一卡通交易记录
|
||||
*/
|
||||
PrepaidCardLog selectFinishedLogByOrderNo(PrepaidCardLog prepaidCardLog);
|
||||
}
|
@@ -0,0 +1,69 @@
|
||||
package com.zhwl.prepaidCard.mapper;
|
||||
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCard;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 一卡通Mapper接口
|
||||
*
|
||||
* @author duanyashu
|
||||
* @date 2024-08-19
|
||||
*/
|
||||
public interface PrepaidCardMapper {
|
||||
/**
|
||||
* 查询一卡通
|
||||
*
|
||||
* @param id 一卡通主键
|
||||
* @return 一卡通
|
||||
*/
|
||||
public PrepaidCard selectPrepaidCardById(Long id);
|
||||
public PrepaidCard selectPrepaidCardByAccountNo(@Param("accountNo") String accountNo);
|
||||
|
||||
public PrepaidCard selectPrepaidCardByCreateBy(@Param("createBy") String createBy, @Param("type") String type);
|
||||
|
||||
public PrepaidCard selectPrepaidCardByPhone(@Param("phone") String phone);
|
||||
|
||||
/**
|
||||
* 查询一卡通列表
|
||||
*
|
||||
* @param prepaidCard 一卡通
|
||||
* @return 一卡通集合
|
||||
*/
|
||||
public List<PrepaidCard> selectPrepaidCardList(PrepaidCard prepaidCard);
|
||||
|
||||
/**
|
||||
* 新增一卡通
|
||||
*
|
||||
* @param prepaidCard 一卡通
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPrepaidCard(PrepaidCard prepaidCard);
|
||||
|
||||
/**
|
||||
* 修改一卡通
|
||||
*
|
||||
* @param prepaidCard 一卡通
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePrepaidCard(PrepaidCard prepaidCard);
|
||||
public int updatePrepaidCardBalance(@Param("id") Long id, @Param("amount")BigDecimal amount);
|
||||
|
||||
/**
|
||||
* 删除一卡通
|
||||
*
|
||||
* @param id 一卡通主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrepaidCardById(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除一卡通
|
||||
*
|
||||
* @param ids 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrepaidCardByIds(Long[] ids);
|
||||
}
|
@@ -0,0 +1,77 @@
|
||||
package com.zhwl.prepaidCard.service;
|
||||
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCardLog;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 一卡通交易记录Service接口
|
||||
*
|
||||
* @author duanyashu
|
||||
* @date 2024-08-19
|
||||
*/
|
||||
public interface IPrepaidCardLogService {
|
||||
/**
|
||||
* 查询一卡通交易记录
|
||||
*
|
||||
* @param id 一卡通交易记录主键
|
||||
* @return 一卡通交易记录
|
||||
*/
|
||||
public PrepaidCardLog selectPrepaidCardLogById(Long id);
|
||||
|
||||
/**
|
||||
* 查询一卡通交易记录列表
|
||||
*
|
||||
* @param prepaidCardLog 一卡通交易记录
|
||||
* @return 一卡通交易记录集合
|
||||
*/
|
||||
public List<PrepaidCardLog> selectPrepaidCardLogList(PrepaidCardLog prepaidCardLog);
|
||||
|
||||
/**
|
||||
* 新增一卡通交易记录
|
||||
*
|
||||
* @param prepaidCardLog 一卡通交易记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPrepaidCardLog(PrepaidCardLog prepaidCardLog);
|
||||
|
||||
/**
|
||||
* 修改一卡通交易记录
|
||||
*
|
||||
* @param prepaidCardLog 一卡通交易记录
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePrepaidCardLog(PrepaidCardLog prepaidCardLog);
|
||||
|
||||
/**
|
||||
* 批量删除一卡通交易记录
|
||||
*
|
||||
* @param ids 需要删除的一卡通交易记录主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrepaidCardLogByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除一卡通交易记录信息
|
||||
*
|
||||
* @param id 一卡通交易记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrepaidCardLogById(Long id);
|
||||
|
||||
/**
|
||||
* 查询一卡通交易记录
|
||||
*
|
||||
* @param payNo 支付订单号
|
||||
* @return 一卡通交易记录
|
||||
*/
|
||||
PrepaidCardLog selectPrepaidCardLogByPayNo(String payNo);
|
||||
|
||||
/**
|
||||
* 根据订单号查询一卡通已支付交易记录
|
||||
*
|
||||
* @param prepaidCardLog 查询参数
|
||||
* @return 一卡通交易记录
|
||||
*/
|
||||
PrepaidCardLog selectFinishedLogByOrderNo(PrepaidCardLog prepaidCardLog);
|
||||
}
|
@@ -0,0 +1,110 @@
|
||||
package com.zhwl.prepaidCard.service;
|
||||
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCard;
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCardLog;
|
||||
import com.zhwl.prepaidCard.domain.dto.RechargePayDto;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 一卡通Service接口
|
||||
*
|
||||
* @author duanyashu
|
||||
* @date 2024-08-19
|
||||
*/
|
||||
public interface IPrepaidCardService {
|
||||
/**
|
||||
* 查询一卡通
|
||||
*
|
||||
* @param id 一卡通主键
|
||||
* @return 一卡通
|
||||
*/
|
||||
public PrepaidCard selectPrepaidCardById(Long id);
|
||||
public PrepaidCard selectPrepaidCardByAccountNo(String accountNo);
|
||||
|
||||
public PrepaidCard selectPrepaidCardByCreateBy(String createBy, String type);
|
||||
public PrepaidCard selectPrepaidCardByPhone(String Phone);
|
||||
/**
|
||||
* 查询一卡通列表
|
||||
*
|
||||
* @param prepaidCard 一卡通
|
||||
* @return 一卡通集合
|
||||
*/
|
||||
public List<PrepaidCard> selectPrepaidCardList(PrepaidCard prepaidCard);
|
||||
|
||||
/**
|
||||
* 新增一卡通
|
||||
*
|
||||
* @param prepaidCard 一卡通
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertPrepaidCard(PrepaidCard prepaidCard);
|
||||
|
||||
/**
|
||||
* 小程序开卡
|
||||
* @param prepaidCard
|
||||
* @param openId
|
||||
* @return
|
||||
*/
|
||||
public Object appInsertPrepaidCard(PrepaidCard prepaidCard,String openId) throws WxPayException;
|
||||
/**
|
||||
* 修改一卡通
|
||||
*
|
||||
* @param prepaidCard 一卡通
|
||||
* @return 结果
|
||||
*/
|
||||
public int updatePrepaidCard(PrepaidCard prepaidCard);
|
||||
|
||||
/**
|
||||
* 换卡号
|
||||
* @param prepaidCard
|
||||
* @return
|
||||
*/
|
||||
public int updAccountNo(PrepaidCard prepaidCard);
|
||||
|
||||
/**
|
||||
* 退卡
|
||||
* @param prepaidCard
|
||||
* @return
|
||||
*/
|
||||
public int refund(PrepaidCard prepaidCard);
|
||||
|
||||
/**
|
||||
* 后台充值
|
||||
* @param prepaidCardLog
|
||||
* @return
|
||||
*/
|
||||
public int recharge(PrepaidCardLog prepaidCardLog);
|
||||
|
||||
/**
|
||||
* 小程序充值
|
||||
* @param payDto
|
||||
* @return
|
||||
*/
|
||||
public Object rechargePay(RechargePayDto payDto) throws WxPayException;
|
||||
|
||||
|
||||
/**
|
||||
* 消费接口
|
||||
* @return
|
||||
*/
|
||||
public int consume(String accountNo, String title, String orderNo, BigDecimal amount);
|
||||
|
||||
/**
|
||||
* 批量删除一卡通
|
||||
*
|
||||
* @param ids 需要删除的一卡通主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrepaidCardByIds(Long[] ids);
|
||||
|
||||
/**
|
||||
* 删除一卡通信息
|
||||
*
|
||||
* @param id 一卡通主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deletePrepaidCardById(Long id);
|
||||
}
|
@@ -0,0 +1,165 @@
|
||||
package com.zhwl.prepaidCard.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.zhwl.common.enums.PaymentMethodEnum;
|
||||
import com.zhwl.common.enums.PaymentSceneEnum;
|
||||
import com.zhwl.common.utils.StringUtils;
|
||||
import com.zhwl.payment.common.dto.PayCloseDTO;
|
||||
import com.zhwl.payment.common.dto.PayCreateDTO;
|
||||
import com.zhwl.payment.common.dto.PayRefundDTO;
|
||||
import com.zhwl.payment.common.dto.PayResultDTO;
|
||||
import com.zhwl.payment.common.exception.PayException;
|
||||
import com.zhwl.payment.common.service.PayCommonService;
|
||||
import com.zhwl.payment.common.service.PayQueryResult;
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCard;
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCardLog;
|
||||
import com.zhwl.prepaidCard.enums.PrepaidCardLogStatusEnum;
|
||||
import com.zhwl.prepaidCard.enums.PrepaidCardTradeTypeEnum;
|
||||
import com.zhwl.prepaidCard.mapper.PrepaidCardMapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Administrator
|
||||
* @description 一卡通支付
|
||||
* @date 2024/9/10 9:52
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class CardConsumeServiceImpl implements PayCommonService {
|
||||
|
||||
@Autowired
|
||||
private PrepaidCardMapper prepaidCardMapper;
|
||||
@Autowired
|
||||
private PrepaidCardLogServiceImpl prepaidCardLogService;
|
||||
|
||||
@Override
|
||||
public PaymentMethodEnum getPaymentMethodEnum() {
|
||||
return PaymentMethodEnum.MEMBER_AMOUNT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PaymentSceneEnum> getPaymentSceneEnums() {
|
||||
return ListUtil.of(PaymentSceneEnum.WAP, PaymentSceneEnum.MICRO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void micro(PayCreateDTO payCreateDTO) throws PayException {
|
||||
this.consume(payCreateDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayResultDTO wap(PayCreateDTO payCreateDTO) throws PayException {
|
||||
return this.consume(payCreateDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object parsePayCreateNotifyResult(Object request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayQueryResult createQuery(PayCreateDTO payCreateDTO) throws PayException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refund(PayRefundDTO payRefundDTO) throws PayException {
|
||||
PrepaidCardLog query = new PrepaidCardLog();
|
||||
query.setOrderNo(payRefundDTO.getOrderCode());
|
||||
query.setStatus(PrepaidCardLogStatusEnum.TRADE_FINISHED.getValue());
|
||||
query.setTradeType(PrepaidCardTradeTypeEnum.CONSUME.getValue());
|
||||
PrepaidCardLog oldLog = prepaidCardLogService.selectFinishedLogByOrderNo(query);
|
||||
if (oldLog == null) {
|
||||
throw new PayException("未查询到一卡通交易记录");
|
||||
}
|
||||
PrepaidCard prepaid = prepaidCardMapper.selectPrepaidCardById(oldLog.getCardId());
|
||||
if (prepaid == null) {
|
||||
throw new PayException("当前卡未开卡");
|
||||
}
|
||||
if (StringUtils.equals(prepaid.getStatus(), "2")) {
|
||||
throw new PayException("当前卡不可用");
|
||||
}
|
||||
BigDecimal amount = payRefundDTO.getRefund();
|
||||
prepaid.setBalance(NumberUtil.add(prepaid.getBalance(), amount));
|
||||
int i = prepaidCardMapper.updatePrepaidCard(prepaid);
|
||||
if (i > 0) {
|
||||
PrepaidCardLog prepaidCardLog = new PrepaidCardLog();
|
||||
prepaidCardLog.setCardId(prepaid.getId());
|
||||
prepaidCardLog.setAccountNo(prepaid.getAccountNo());
|
||||
prepaidCardLog.setAmount(amount);
|
||||
prepaidCardLog.setTitle("退款");
|
||||
prepaidCardLog.setOrderNo(payRefundDTO.getOrderCode());
|
||||
prepaidCardLog.setRefundCode(payRefundDTO.getRefundCode());
|
||||
prepaidCardLog.setTradeType(PrepaidCardTradeTypeEnum.REFUND.getValue());
|
||||
prepaidCardLog.setAccountType(prepaid.getType());
|
||||
prepaidCardLog.setName(prepaid.getName());
|
||||
prepaidCardLog.setBalance(prepaid.getBalance());
|
||||
prepaidCardLog.setStatus(PrepaidCardLogStatusEnum.TRADE_FINISHED.getValue());
|
||||
prepaidCardLogService.insertPrepaidCardLog(prepaidCardLog);
|
||||
} else {
|
||||
throw new PayException("一卡通操作异常");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object parsePayRefundNotifyResult(Object request) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PayQueryResult refundQuery(PayRefundDTO payRefundDTO) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeOrder(PayCloseDTO payCloseDTO) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 一卡通消费
|
||||
*
|
||||
* @param payCreateDTO 下单参数
|
||||
* @return 结果
|
||||
*/
|
||||
private PayResultDTO consume(PayCreateDTO payCreateDTO) throws PayException {
|
||||
BigDecimal amount = payCreateDTO.getTotalPrice();
|
||||
|
||||
PrepaidCard prepaid = prepaidCardMapper.selectPrepaidCardByAccountNo(payCreateDTO.getAuthCode());
|
||||
if (prepaid == null) {
|
||||
throw new PayException("当前卡未开卡");
|
||||
}
|
||||
if (StringUtils.equals(prepaid.getStatus(), "2")) {
|
||||
throw new PayException("当前卡不可用");
|
||||
}
|
||||
if (NumberUtil.isLess(prepaid.getBalance(), amount)) {
|
||||
throw new PayException("当前卡余额不足");
|
||||
}
|
||||
prepaid.setBalance(NumberUtil.sub(prepaid.getBalance(), amount));
|
||||
int i = prepaidCardMapper.updatePrepaidCard(prepaid);
|
||||
if (i > 0) {
|
||||
PrepaidCardLog prepaidCardLog = new PrepaidCardLog();
|
||||
prepaidCardLog.setCardId(prepaid.getId());
|
||||
prepaidCardLog.setAccountNo(prepaid.getAccountNo());
|
||||
prepaidCardLog.setAmount(amount);
|
||||
prepaidCardLog.setTitle(payCreateDTO.getDescription());
|
||||
prepaidCardLog.setOrderNo(payCreateDTO.getOrderCode());
|
||||
prepaidCardLog.setTradeType(PrepaidCardTradeTypeEnum.CONSUME.getValue());
|
||||
prepaidCardLog.setAccountType(prepaid.getType());
|
||||
prepaidCardLog.setName(prepaid.getName());
|
||||
prepaidCardLog.setBalance(prepaid.getBalance());
|
||||
prepaidCardLog.setStatus(PrepaidCardLogStatusEnum.TRADE_FINISHED.getValue());
|
||||
prepaidCardLogService.insertPrepaidCardLog(prepaidCardLog);
|
||||
} else {
|
||||
throw new PayException("一卡通操作异常");
|
||||
}
|
||||
return PayResultDTO.builder()
|
||||
.orderCode(payCreateDTO.getOrderCode())
|
||||
.build();
|
||||
}
|
||||
}
|
@@ -0,0 +1,111 @@
|
||||
package com.zhwl.prepaidCard.service.impl;
|
||||
|
||||
import com.zhwl.common.enums.DictTypeEnum;
|
||||
import com.zhwl.common.utils.DateUtils;
|
||||
import com.zhwl.common.utils.DictUtils;
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCardLog;
|
||||
import com.zhwl.prepaidCard.mapper.PrepaidCardLogMapper;
|
||||
import com.zhwl.prepaidCard.service.IPrepaidCardLogService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* 一卡通交易记录Service业务层处理
|
||||
*
|
||||
* @author duanyashu
|
||||
* @date 2024-08-19
|
||||
*/
|
||||
@Service
|
||||
public class PrepaidCardLogServiceImpl implements IPrepaidCardLogService {
|
||||
@Autowired
|
||||
private PrepaidCardLogMapper prepaidCardLogMapper;
|
||||
|
||||
/**
|
||||
* 查询一卡通交易记录
|
||||
*
|
||||
* @param id 一卡通交易记录主键
|
||||
* @return 一卡通交易记录
|
||||
*/
|
||||
@Override
|
||||
public PrepaidCardLog selectPrepaidCardLogById(Long id) {
|
||||
return prepaidCardLogMapper.selectPrepaidCardLogById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询一卡通交易记录列表
|
||||
*
|
||||
* @param prepaidCardLog 一卡通交易记录
|
||||
* @return 一卡通交易记录
|
||||
*/
|
||||
@Override
|
||||
public List<PrepaidCardLog> selectPrepaidCardLogList(PrepaidCardLog prepaidCardLog) {
|
||||
List<PrepaidCardLog> list = Optional.ofNullable(prepaidCardLogMapper.selectPrepaidCardLogList(prepaidCardLog))
|
||||
.orElse(Collections.emptyList());
|
||||
Map<String, String> tradeTypeMap = DictUtils.getDictLabelMap(DictTypeEnum.PREPAID_CARD_TRADE_TYPE);
|
||||
list.forEach(item -> {
|
||||
item.setTradeTypeLabel(tradeTypeMap.get(item.getTradeType()));
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增一卡通交易记录
|
||||
*
|
||||
* @param prepaidCardLog 一卡通交易记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertPrepaidCardLog(PrepaidCardLog prepaidCardLog) {
|
||||
prepaidCardLog.setCreateTime(DateUtils.getNowDate());
|
||||
return prepaidCardLogMapper.insertPrepaidCardLog(prepaidCardLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改一卡通交易记录
|
||||
*
|
||||
* @param prepaidCardLog 一卡通交易记录
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePrepaidCardLog(PrepaidCardLog prepaidCardLog) {
|
||||
return prepaidCardLogMapper.updatePrepaidCardLog(prepaidCardLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除一卡通交易记录
|
||||
*
|
||||
* @param ids 需要删除的一卡通交易记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePrepaidCardLogByIds(Long[] ids) {
|
||||
return prepaidCardLogMapper.deletePrepaidCardLogByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一卡通交易记录信息
|
||||
*
|
||||
* @param id 一卡通交易记录主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePrepaidCardLogById(Long id) {
|
||||
return prepaidCardLogMapper.deletePrepaidCardLogById(id);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public PrepaidCardLog selectPrepaidCardLogByPayNo(String payNo) {
|
||||
return prepaidCardLogMapper.selectPrepaidCardLogByPayNo(payNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrepaidCardLog selectFinishedLogByOrderNo(PrepaidCardLog prepaidCardLog) {
|
||||
return prepaidCardLogMapper.selectFinishedLogByOrderNo(prepaidCardLog);
|
||||
}
|
||||
}
|
@@ -0,0 +1,367 @@
|
||||
package com.zhwl.prepaidCard.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.github.binarywang.wxpay.exception.WxPayException;
|
||||
import com.zhwl.common.enums.PaymentMethodEnum;
|
||||
import com.zhwl.common.enums.PaymentSceneEnum;
|
||||
import com.zhwl.common.exception.GlobalException;
|
||||
import com.zhwl.common.utils.DateUtils;
|
||||
import com.zhwl.common.utils.SecurityUtils;
|
||||
import com.zhwl.common.utils.StringUtils;
|
||||
import com.zhwl.common.utils.ip.IpUtils;
|
||||
import com.zhwl.common.utils.redis.RedisBlockingQueueHandle;
|
||||
import com.zhwl.payment.common.dto.PayCreateDTO;
|
||||
import com.zhwl.payment.common.dto.PayNotifyResultDTO;
|
||||
import com.zhwl.payment.common.dto.PayResultDTO;
|
||||
import com.zhwl.payment.common.enums.DataSourceEnum;
|
||||
import com.zhwl.payment.common.exception.PayException;
|
||||
import com.zhwl.payment.common.utils.PayCacheUtils;
|
||||
import com.zhwl.payment.core.service.PayService;
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCard;
|
||||
import com.zhwl.prepaidCard.domain.PrepaidCardLog;
|
||||
import com.zhwl.prepaidCard.domain.dto.RechargePayDto;
|
||||
import com.zhwl.prepaidCard.enums.PrepaidCardLogStatusEnum;
|
||||
import com.zhwl.prepaidCard.enums.PrepaidCardTradeTypeEnum;
|
||||
import com.zhwl.prepaidCard.mapper.PrepaidCardMapper;
|
||||
import com.zhwl.prepaidCard.service.IPrepaidCardService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 一卡通Service业务层处理
|
||||
*
|
||||
* @author duanyashu
|
||||
* @date 2024-08-19
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class PrepaidCardServiceImpl implements IPrepaidCardService, RedisBlockingQueueHandle {
|
||||
@Autowired
|
||||
private PrepaidCardMapper prepaidCardMapper;
|
||||
@Autowired
|
||||
private PrepaidCardLogServiceImpl prepaidCardLogService;
|
||||
@Autowired
|
||||
private PayService payService;
|
||||
@Autowired
|
||||
private PayCacheUtils payCacheUtils;
|
||||
|
||||
@Override
|
||||
public String getQueueName() {
|
||||
return payCacheUtils.getPayCreateNotifyQueueRedisKey(DataSourceEnum.YKCZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(String message) {
|
||||
log.info("一卡通小程序充值支付状态推送数据:{}, queue: {}", message, getQueueName());
|
||||
PayNotifyResultDTO resultDTO = JSONObject.parseObject(message, PayNotifyResultDTO.class);
|
||||
String outTradeNo = resultDTO.getOrderCode();
|
||||
if (resultDTO.getSuccess()) {
|
||||
PrepaidCardLog prepaidCardLog = prepaidCardLogService.selectPrepaidCardLogByPayNo(outTradeNo);
|
||||
if (Objects.isNull(prepaidCardLog)) {
|
||||
log.error("一卡通小程序充值订单号:" + outTradeNo + "不存在");
|
||||
return;
|
||||
}
|
||||
prepaidCardLog.setTransactionId(resultDTO.getThirdPayId());
|
||||
updPrepaidBalance(prepaidCardLog);
|
||||
} else {
|
||||
//日志写入
|
||||
log.error("一卡通小程序充值订单号:" + outTradeNo + "支付失败");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询一卡通
|
||||
*
|
||||
* @param id 一卡通主键
|
||||
* @return 一卡通
|
||||
*/
|
||||
@Override
|
||||
public PrepaidCard selectPrepaidCardById(Long id) {
|
||||
return prepaidCardMapper.selectPrepaidCardById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrepaidCard selectPrepaidCardByAccountNo(String accountNo) {
|
||||
return prepaidCardMapper.selectPrepaidCardByAccountNo(accountNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrepaidCard selectPrepaidCardByCreateBy(String createBy, String type) {
|
||||
return prepaidCardMapper.selectPrepaidCardByCreateBy(createBy, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrepaidCard selectPrepaidCardByPhone(String Phone) {
|
||||
return prepaidCardMapper.selectPrepaidCardByPhone(Phone);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询一卡通列表
|
||||
*
|
||||
* @param prepaidCard 一卡通
|
||||
* @return 一卡通
|
||||
*/
|
||||
@Override
|
||||
public List<PrepaidCard> selectPrepaidCardList(PrepaidCard prepaidCard) {
|
||||
return prepaidCardMapper.selectPrepaidCardList(prepaidCard);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增一卡通
|
||||
*
|
||||
* @param prepaidCard 一卡通
|
||||
* @return 结果
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int insertPrepaidCard(PrepaidCard prepaidCard) {
|
||||
String phone = prepaidCard.getPhone();
|
||||
if (!StrUtil.equals(prepaidCard.getType(),"1")){
|
||||
return 0;
|
||||
}
|
||||
prepaidCard.setCreateTime(DateUtils.getNowDate());
|
||||
prepaidCard.setStatus("1");
|
||||
int i = prepaidCardMapper.insertPrepaidCard(prepaidCard);
|
||||
if (i>0){
|
||||
PrepaidCardLog prepaidCardLog = new PrepaidCardLog();
|
||||
prepaidCardLog.setCardId(prepaidCard.getId());
|
||||
prepaidCardLog.setAccountNo(prepaidCard.getAccountNo());
|
||||
prepaidCardLog.setName(prepaidCard.getName());
|
||||
prepaidCardLog.setBalance(prepaidCard.getBalance());
|
||||
prepaidCardLog.setAccountType(prepaidCard.getType());
|
||||
prepaidCardLog.setAmount(prepaidCard.getBalance());
|
||||
prepaidCardLog.setTitle("余额充值");
|
||||
prepaidCardLog.setTradeType("1");
|
||||
prepaidCardLog.setStatus("2");
|
||||
prepaidCardLogService.insertPrepaidCardLog(prepaidCardLog);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* 小程序新开卡
|
||||
* @param prepaidCard
|
||||
* @param openId
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object appInsertPrepaidCard(PrepaidCard prepaidCard, String openId) throws WxPayException {
|
||||
BigDecimal amount = prepaidCard.getBalance();
|
||||
//虚拟卡 生成卡号
|
||||
prepaidCard.setAccountNo("V"+System.currentTimeMillis()+ RandomUtil.randomNumbers(4));
|
||||
prepaidCard.setType("2");
|
||||
prepaidCard.setCreateTime(DateUtils.getNowDate());
|
||||
prepaidCard.setStatus("1");
|
||||
prepaidCard.setBalance(BigDecimal.ZERO);
|
||||
prepaidCardMapper.insertPrepaidCard(prepaidCard);
|
||||
return proceedRecharge(prepaidCard,amount,openId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改一卡通
|
||||
*
|
||||
* @param prepaidCard 一卡通
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updatePrepaidCard(PrepaidCard prepaidCard) {
|
||||
return prepaidCardMapper.updatePrepaidCard(prepaidCard);
|
||||
}
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int updAccountNo(PrepaidCard prepaidCard) {
|
||||
PrepaidCard oldPrepaidCard = prepaidCardMapper.selectPrepaidCardById(prepaidCard.getId());
|
||||
if (oldPrepaidCard==null){
|
||||
throw new GlobalException("非法操作");
|
||||
}
|
||||
prepaidCard.setUpdateTime(new Date());
|
||||
prepaidCard.setUpdateBy(SecurityUtils.getUserId()+"");
|
||||
int i = prepaidCardMapper.updatePrepaidCard(prepaidCard);
|
||||
return i;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int refund(PrepaidCard prepaidCard) {
|
||||
BigDecimal balance = prepaidCard.getBalance();
|
||||
prepaidCard.setBalance(BigDecimal.ZERO);
|
||||
prepaidCard.setStatus(PrepaidCardTradeTypeEnum.REFUND.getValue());
|
||||
prepaidCard.setUpdateTime(new Date());
|
||||
prepaidCard.setUpdateBy(SecurityUtils.getUserId()+"");
|
||||
int i = prepaidCardMapper.updatePrepaidCard(prepaidCard);
|
||||
if (i>0){
|
||||
PrepaidCardLog prepaidCardLog = new PrepaidCardLog();
|
||||
prepaidCardLog.setCardId(prepaidCard.getId());
|
||||
prepaidCardLog.setAccountNo(prepaidCard.getAccountNo());
|
||||
prepaidCardLog.setAmount(balance);
|
||||
prepaidCardLog.setTitle("退卡退款");
|
||||
prepaidCardLog.setTradeType(PrepaidCardTradeTypeEnum.REFUND.getValue());
|
||||
prepaidCardLog.setStatus(PrepaidCardLogStatusEnum.TRADE_FINISHED.getValue());
|
||||
prepaidCardLog.setAccountType(prepaidCard.getType());
|
||||
prepaidCardLog.setName(prepaidCard.getName());
|
||||
prepaidCardLog.setBalance(BigDecimal.ZERO);
|
||||
prepaidCardLogService.insertPrepaidCardLog(prepaidCardLog);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int recharge(PrepaidCardLog prepaidCardLog) {
|
||||
PrepaidCard prepaid;
|
||||
if (prepaidCardLog.getCardId()==null){
|
||||
prepaid = prepaidCardMapper.selectPrepaidCardByAccountNo(prepaidCardLog.getAccountNo());
|
||||
}else {
|
||||
prepaid = prepaidCardMapper.selectPrepaidCardById(prepaidCardLog.getCardId());
|
||||
}
|
||||
if (prepaid==null){
|
||||
throw new GlobalException("当前卡未开卡");
|
||||
}
|
||||
prepaid.setBalance(NumberUtil.add(prepaid.getBalance(),prepaidCardLog.getAmount()));
|
||||
prepaid.setUpdateTime(new Date());
|
||||
prepaid.setUpdateBy(prepaidCardLog.getUpdateBy());
|
||||
int i = prepaidCardMapper.updatePrepaidCard(prepaid);
|
||||
if (i>0){
|
||||
prepaidCardLog.setTitle("余额充值");
|
||||
prepaidCardLog.setTradeType("1");
|
||||
prepaidCardLog.setStatus("2");
|
||||
prepaidCardLog.setAccountType(prepaid.getType());
|
||||
prepaidCardLog.setName(prepaid.getName());
|
||||
prepaidCardLog.setBalance(prepaid.getBalance());
|
||||
prepaidCardLogService.insertPrepaidCardLog(prepaidCardLog);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public Object rechargePay(RechargePayDto payDto) throws WxPayException {
|
||||
PrepaidCard prepaid = prepaidCardMapper.selectPrepaidCardByAccountNo(payDto.getAccountNo());
|
||||
if (prepaid==null){
|
||||
throw new GlobalException("当前卡未开卡");
|
||||
}
|
||||
if (!Objects.equals(payDto.getCreateBy(),prepaid.getCreateBy())){
|
||||
throw new SecurityException("当前操作用户与持卡人信息不一致");
|
||||
}
|
||||
return proceedRecharge(prepaid,payDto.getAmount(),payDto.getOpenId());
|
||||
}
|
||||
|
||||
private PayResultDTO proceedRecharge(PrepaidCard prepaid,BigDecimal amount,String openId) throws WxPayException {
|
||||
PrepaidCardLog prepaidCardLog = new PrepaidCardLog();
|
||||
prepaidCardLog.setCardId(prepaid.getId());
|
||||
prepaidCardLog.setAccountNo(prepaid.getAccountNo());
|
||||
prepaidCardLog.setAccountType(prepaid.getType());
|
||||
prepaidCardLog.setName(prepaid.getName());
|
||||
prepaidCardLog.setBalance(NumberUtil.add(prepaid.getBalance(), amount));
|
||||
prepaidCardLog.setAmount(amount);
|
||||
prepaidCardLog.setTradeType("1");
|
||||
prepaidCardLog.setStatus("1");
|
||||
prepaidCardLog.setTitle("小程序余额充值");
|
||||
prepaidCardLog.setCreateBy(prepaid.getCreateBy());
|
||||
prepaidCardLog.setPayNo(IdUtil.simpleUUID());
|
||||
prepaidCardLogService.insertPrepaidCardLog(prepaidCardLog);
|
||||
|
||||
//获取默认微信小程序支付方式,二选一
|
||||
PaymentMethodEnum wechatMiniProgramPaymentMethod = payCacheUtils.getWechatMiniProgramPaymentMethod();
|
||||
PayCreateDTO payCreateDTO = PayCreateDTO.builder()
|
||||
.dataSource(DataSourceEnum.YKCZ) //数据来源(哪个模块),用来对应回调模块, 必填
|
||||
// .paymentScene(PaymentSceneEnum.WECHAT_MINI_PROGRAM) //支付场景,必填
|
||||
.paymentMethod(wechatMiniProgramPaymentMethod) //支付方式,必填,微信小程序请暂时填为微信支付,实际支付方式由支付模块返回
|
||||
.orderCode(prepaidCardLog.getPayNo()) //订单编号,必填
|
||||
.description("小程序一卡通充值支付") //订单标题,必填
|
||||
.totalPrice(prepaidCardLog.getAmount()) //订单金额。必填
|
||||
.buyIp(IpUtils.getIpAddr())
|
||||
.createDate(new Date()) //订单创建时间,必填
|
||||
.openId(openId) //微信小程序支付场景下需要
|
||||
.build();
|
||||
try {
|
||||
PayResultDTO payResultDTO = payService.create(payCreateDTO);
|
||||
return payResultDTO;
|
||||
} catch (PayException e) {
|
||||
e.printStackTrace();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 小程序支付更新账户余额
|
||||
* @param prepaidCardLog
|
||||
*/
|
||||
private void updPrepaidBalance(PrepaidCardLog prepaidCardLog) {
|
||||
prepaidCardLog.setStatus("2");
|
||||
prepaidCardLog.setUpdateTime(new Date());
|
||||
prepaidCardLogService.updatePrepaidCardLog(prepaidCardLog);
|
||||
prepaidCardMapper.updatePrepaidCardBalance(prepaidCardLog.getCardId(),prepaidCardLog.getAmount());
|
||||
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@Override
|
||||
public int consume(String accountNo,String title,String orderNo,BigDecimal amount) {
|
||||
PrepaidCard prepaid = prepaidCardMapper.selectPrepaidCardByAccountNo(accountNo);
|
||||
if (prepaid==null){
|
||||
throw new GlobalException("当前卡未开卡");
|
||||
}
|
||||
if (StringUtils.equals(prepaid.getStatus(),"2")){
|
||||
throw new GlobalException("当前卡不可用");
|
||||
}
|
||||
if (NumberUtil.isLess(prepaid.getBalance(),amount)){
|
||||
throw new GlobalException("当前卡余额不足");
|
||||
}
|
||||
prepaid.setBalance(NumberUtil.sub(prepaid.getBalance(),amount));
|
||||
int i = prepaidCardMapper.updatePrepaidCard(prepaid);
|
||||
if (i>0){
|
||||
PrepaidCardLog prepaidCardLog = new PrepaidCardLog();
|
||||
prepaidCardLog.setCardId(prepaid.getId());
|
||||
prepaidCardLog.setAccountNo(prepaid.getAccountNo());
|
||||
prepaidCardLog.setAmount(amount);
|
||||
prepaidCardLog.setTitle(title);
|
||||
prepaidCardLog.setOrderNo(orderNo);
|
||||
prepaidCardLog.setTradeType("2");
|
||||
prepaidCardLog.setAccountType(prepaid.getType());
|
||||
prepaidCardLog.setName(prepaid.getName());
|
||||
prepaidCardLog.setBalance(prepaid.getBalance());
|
||||
prepaidCardLogService.insertPrepaidCardLog(prepaidCardLog);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除一卡通
|
||||
*
|
||||
* @param ids 需要删除的一卡通主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePrepaidCardByIds(Long[] ids) {
|
||||
return prepaidCardMapper.deletePrepaidCardByIds(ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除一卡通信息
|
||||
*
|
||||
* @param id 一卡通主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deletePrepaidCardById(Long id) {
|
||||
return prepaidCardMapper.deletePrepaidCardById(id);
|
||||
}
|
||||
}
|
@@ -0,0 +1,209 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhwl.prepaidCard.mapper.PrepaidCardLogMapper">
|
||||
|
||||
<resultMap type="PrepaidCardLog" id="PrepaidCardLogResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="cardId" column="card_id"/>
|
||||
<result property="accountNo" column="account_no"/>
|
||||
<result property="accountType" column="account_type"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="balance" column="balance"/>
|
||||
<result property="orderNo" column="order_no"/>
|
||||
<result property="tradeType" column="trade_type"/>
|
||||
<result property="amount" column="amount"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="title" column="title"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="transactionId" column="transaction_id"/>
|
||||
<result property="payNo" column="pay_no"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrepaidCardLogVo">
|
||||
select id, card_id,account_no, account_type, name, balance, order_no, trade_type, amount, create_time,title,create_by,status,transaction_id,pay_no
|
||||
from zdy_prepaid_card_log
|
||||
</sql>
|
||||
|
||||
<select id="selectPrepaidCardLogList" parameterType="PrepaidCardLog" resultMap="PrepaidCardLogResult">
|
||||
<include refid="selectPrepaidCardLogVo"/>
|
||||
<where>
|
||||
<if test="accountNo != null and accountNo != ''">
|
||||
and account_no = #{accountNo}
|
||||
</if>
|
||||
<if test="cardId != null and cardId != ''">
|
||||
and card_id = #{cardId}
|
||||
</if>
|
||||
<if test="accountType != null and accountType != ''">
|
||||
and account_type = #{accountType}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name like concat('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="orderNo != null and orderNo != ''">
|
||||
and order_no = #{orderNo}
|
||||
</if>
|
||||
<if test="tradeType != null and tradeType != ''">
|
||||
and trade_type = #{tradeType}
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
and create_by = #{createBy}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
|
||||
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectPrepaidCardLogById" parameterType="Long"
|
||||
resultMap="PrepaidCardLogResult">
|
||||
<include refid="selectPrepaidCardLogVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertPrepaidCardLog" parameterType="PrepaidCardLog" useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
insert into zdy_prepaid_card_log
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="cardId !=null">
|
||||
card_id,
|
||||
</if>
|
||||
<if test="accountNo != null and accountNo != ''">account_no,
|
||||
</if>
|
||||
<if test="accountType != null and accountType != ''">account_type,
|
||||
</if>
|
||||
<if test="name != null">name,
|
||||
</if>
|
||||
<if test="balance != null">balance,
|
||||
</if>
|
||||
<if test="orderNo != null">order_no,
|
||||
</if>
|
||||
<if test="tradeType != null and tradeType != ''">trade_type,
|
||||
</if>
|
||||
<if test="amount != null">amount,
|
||||
</if>
|
||||
<if test="createTime != null">create_time,
|
||||
</if>
|
||||
<if test="title != null">title,
|
||||
</if>
|
||||
<if test="createBy != null">create_by,
|
||||
</if>
|
||||
<if test="status != null">status,
|
||||
</if>
|
||||
<if test="payNo != null">pay_no,
|
||||
</if>
|
||||
<if test="refundCode != null">refund_code,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="cardId !=null">
|
||||
#{cardId},
|
||||
</if>
|
||||
<if test="accountNo != null and accountNo != ''">#{accountNo},
|
||||
</if>
|
||||
<if test="accountType != null and accountType != ''">#{accountType},
|
||||
</if>
|
||||
<if test="name != null">#{name},
|
||||
</if>
|
||||
<if test="balance != null">#{balance},
|
||||
</if>
|
||||
<if test="orderNo != null">#{orderNo},
|
||||
</if>
|
||||
<if test="tradeType != null and tradeType != ''">#{tradeType},
|
||||
</if>
|
||||
<if test="amount != null">#{amount},
|
||||
</if>
|
||||
<if test="createTime != null">#{createTime},
|
||||
</if>
|
||||
<if test="title != null">#{title},
|
||||
</if>
|
||||
<if test="createBy != null">#{createBy},
|
||||
</if>
|
||||
<if test="status != null">#{status},
|
||||
</if>
|
||||
<if test="payNo != null">#{payNo},
|
||||
</if>
|
||||
<if test="refundCode != null">#{refundCode},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePrepaidCardLog" parameterType="PrepaidCardLog">
|
||||
update zdy_prepaid_card_log
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="cardId !=null">
|
||||
card_id = #{cardId},
|
||||
</if>
|
||||
<if test="accountNo != null and accountNo != ''">account_no =
|
||||
#{accountNo},
|
||||
</if>
|
||||
<if test="accountType != null and accountType != ''">account_type =
|
||||
#{accountType},
|
||||
</if>
|
||||
<if test="name != null">name =
|
||||
#{name},
|
||||
</if>
|
||||
<if test="balance != null">balance =
|
||||
#{balance},
|
||||
</if>
|
||||
<if test="orderNo != null">order_no =
|
||||
#{orderNo},
|
||||
</if>
|
||||
<if test="tradeType != null and tradeType != ''">trade_type =
|
||||
#{tradeType},
|
||||
</if>
|
||||
<if test="amount != null">amount =
|
||||
#{amount},
|
||||
</if>
|
||||
<if test="createTime != null">create_time =
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="title != null">title =
|
||||
#{title},
|
||||
</if>
|
||||
<if test="updateTime != null">update_time =
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="status != null">status =
|
||||
#{status},
|
||||
</if>
|
||||
<if test="transactionId != null">transaction_id =
|
||||
#{transactionId},
|
||||
</if>
|
||||
<if test="payNo != null">pay_no =
|
||||
#{payNo},
|
||||
</if>
|
||||
<if test="refundCode != null">refund_code =
|
||||
#{refundCode},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deletePrepaidCardLogById" parameterType="Long">
|
||||
delete from zdy_prepaid_card_log where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrepaidCardLogByIds" parameterType="String">
|
||||
delete from zdy_prepaid_card_log where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectPrepaidCardLogByPayNo" parameterType="String" resultMap="PrepaidCardLogResult">
|
||||
<include refid="selectPrepaidCardLogVo"/>
|
||||
where pay_no = #{payNo}
|
||||
</select>
|
||||
|
||||
<select id="selectFinishedLogByOrderNo" parameterType="PrepaidCardLog" resultMap="PrepaidCardLogResult">
|
||||
<include refid="selectPrepaidCardLogVo"/>
|
||||
where order_no = #{orderNo} and `status` = #{status} and trade_type=#{tradeType}
|
||||
</select>
|
||||
</mapper>
|
@@ -0,0 +1,163 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhwl.prepaidCard.mapper.PrepaidCardMapper">
|
||||
|
||||
<resultMap type="PrepaidCard" id="PrepaidCardResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="accountNo" column="account_no"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="balance" column="balance"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrepaidCardVo">
|
||||
select id, account_no, type, name, phone, balance, status, create_time, create_by,update_by, update_time
|
||||
from zdy_prepaid_card
|
||||
</sql>
|
||||
|
||||
<select id="selectPrepaidCardList" parameterType="PrepaidCard" resultMap="PrepaidCardResult">
|
||||
<include refid="selectPrepaidCardVo"/>
|
||||
<where>
|
||||
<if test="accountNo != null and accountNo != ''">
|
||||
and account_no like concat('%', #{accountNo}, '%')
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
and type = #{type}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name like concat('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">
|
||||
and phone = #{phone}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
|
||||
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<select id="selectPrepaidCardById" parameterType="Long"
|
||||
resultMap="PrepaidCardResult">
|
||||
<include refid="selectPrepaidCardVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectPrepaidCardByAccountNo" parameterType="String"
|
||||
resultMap="PrepaidCardResult">
|
||||
<include refid="selectPrepaidCardVo"/>
|
||||
where account_no = #{accountNo} and (status = '1' or status='2') limit 1
|
||||
</select>
|
||||
<select id="selectPrepaidCardByCreateBy" parameterType="String"
|
||||
resultMap="PrepaidCardResult">
|
||||
<include refid="selectPrepaidCardVo"/>
|
||||
where create_by = #{createBy} and `type` = #{type} and `status` = '1'
|
||||
</select>
|
||||
<select id="selectPrepaidCardByPhone" parameterType="String"
|
||||
resultMap="PrepaidCardResult">
|
||||
<include refid="selectPrepaidCardVo"/>
|
||||
where phone = #{phone} and (status = '1' or status='2') limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertPrepaidCard" parameterType="PrepaidCard" useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
insert into zdy_prepaid_card
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="accountNo != null and accountNo != ''">account_no,
|
||||
</if>
|
||||
<if test="type != null">type,
|
||||
</if>
|
||||
<if test="name != null and name != ''">name,
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">phone,
|
||||
</if>
|
||||
<if test="balance != null">balance,
|
||||
</if>
|
||||
<if test="status != null">status,
|
||||
</if>
|
||||
<if test="createTime != null">create_time,
|
||||
</if>
|
||||
<if test="createBy != null">create_by,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="accountNo != null and accountNo != ''">#{accountNo},
|
||||
</if>
|
||||
<if test="type != null">#{type},
|
||||
</if>
|
||||
<if test="name != null and name != ''">#{name},
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">#{phone},
|
||||
</if>
|
||||
<if test="balance != null">#{balance},
|
||||
</if>
|
||||
<if test="status != null">#{status},
|
||||
</if>
|
||||
<if test="createTime != null">#{createTime},
|
||||
</if>
|
||||
<if test="createBy != null">#{createBy},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePrepaidCard" parameterType="PrepaidCard">
|
||||
update zdy_prepaid_card
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="accountNo != null and accountNo != ''">account_no =
|
||||
#{accountNo},
|
||||
</if>
|
||||
<if test="type != null">type =
|
||||
#{type},
|
||||
</if>
|
||||
<if test="name != null and name != ''">name =
|
||||
#{name},
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">phone =
|
||||
#{phone},
|
||||
</if>
|
||||
<if test="balance != null">balance =
|
||||
#{balance},
|
||||
</if>
|
||||
<if test="status != null">status =
|
||||
#{status},
|
||||
</if>
|
||||
<if test="createTime != null">create_time =
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="createBy != null">create_by =
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="updateTime != null">update_time =
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="updateBy != null">update_by =
|
||||
#{updateBy},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updatePrepaidCardBalance">
|
||||
update zdy_prepaid_card set balance = balance + #{amount} where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deletePrepaidCardById" parameterType="Long">
|
||||
delete from zdy_prepaid_card where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrepaidCardByIds" parameterType="String">
|
||||
delete from zdy_prepaid_card where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,209 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhwl.prepaidCard.mapper.PrepaidCardLogMapper">
|
||||
|
||||
<resultMap type="PrepaidCardLog" id="PrepaidCardLogResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="cardId" column="card_id"/>
|
||||
<result property="accountNo" column="account_no"/>
|
||||
<result property="accountType" column="account_type"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="balance" column="balance"/>
|
||||
<result property="orderNo" column="order_no"/>
|
||||
<result property="tradeType" column="trade_type"/>
|
||||
<result property="amount" column="amount"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="title" column="title"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="transactionId" column="transaction_id"/>
|
||||
<result property="payNo" column="pay_no"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrepaidCardLogVo">
|
||||
select id, card_id,account_no, account_type, name, balance, order_no, trade_type, amount, create_time,title,create_by,status,transaction_id,pay_no
|
||||
from zdy_prepaid_card_log
|
||||
</sql>
|
||||
|
||||
<select id="selectPrepaidCardLogList" parameterType="PrepaidCardLog" resultMap="PrepaidCardLogResult">
|
||||
<include refid="selectPrepaidCardLogVo"/>
|
||||
<where>
|
||||
<if test="accountNo != null and accountNo != ''">
|
||||
and account_no = #{accountNo}
|
||||
</if>
|
||||
<if test="cardId != null and cardId != ''">
|
||||
and card_id = #{cardId}
|
||||
</if>
|
||||
<if test="accountType != null and accountType != ''">
|
||||
and account_type = #{accountType}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name like concat('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="orderNo != null and orderNo != ''">
|
||||
and order_no = #{orderNo}
|
||||
</if>
|
||||
<if test="tradeType != null and tradeType != ''">
|
||||
and trade_type = #{tradeType}
|
||||
</if>
|
||||
<if test="createBy != null and createBy != ''">
|
||||
and create_by = #{createBy}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
|
||||
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
order by create_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectPrepaidCardLogById" parameterType="Long"
|
||||
resultMap="PrepaidCardLogResult">
|
||||
<include refid="selectPrepaidCardLogVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
|
||||
<insert id="insertPrepaidCardLog" parameterType="PrepaidCardLog" useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
insert into zdy_prepaid_card_log
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="cardId !=null">
|
||||
card_id,
|
||||
</if>
|
||||
<if test="accountNo != null and accountNo != ''">account_no,
|
||||
</if>
|
||||
<if test="accountType != null and accountType != ''">account_type,
|
||||
</if>
|
||||
<if test="name != null">name,
|
||||
</if>
|
||||
<if test="balance != null">balance,
|
||||
</if>
|
||||
<if test="orderNo != null">order_no,
|
||||
</if>
|
||||
<if test="tradeType != null and tradeType != ''">trade_type,
|
||||
</if>
|
||||
<if test="amount != null">amount,
|
||||
</if>
|
||||
<if test="createTime != null">create_time,
|
||||
</if>
|
||||
<if test="title != null">title,
|
||||
</if>
|
||||
<if test="createBy != null">create_by,
|
||||
</if>
|
||||
<if test="status != null">status,
|
||||
</if>
|
||||
<if test="payNo != null">pay_no,
|
||||
</if>
|
||||
<if test="refundCode != null">refund_code,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="cardId !=null">
|
||||
#{cardId},
|
||||
</if>
|
||||
<if test="accountNo != null and accountNo != ''">#{accountNo},
|
||||
</if>
|
||||
<if test="accountType != null and accountType != ''">#{accountType},
|
||||
</if>
|
||||
<if test="name != null">#{name},
|
||||
</if>
|
||||
<if test="balance != null">#{balance},
|
||||
</if>
|
||||
<if test="orderNo != null">#{orderNo},
|
||||
</if>
|
||||
<if test="tradeType != null and tradeType != ''">#{tradeType},
|
||||
</if>
|
||||
<if test="amount != null">#{amount},
|
||||
</if>
|
||||
<if test="createTime != null">#{createTime},
|
||||
</if>
|
||||
<if test="title != null">#{title},
|
||||
</if>
|
||||
<if test="createBy != null">#{createBy},
|
||||
</if>
|
||||
<if test="status != null">#{status},
|
||||
</if>
|
||||
<if test="payNo != null">#{payNo},
|
||||
</if>
|
||||
<if test="refundCode != null">#{refundCode},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePrepaidCardLog" parameterType="PrepaidCardLog">
|
||||
update zdy_prepaid_card_log
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="cardId !=null">
|
||||
card_id = #{cardId},
|
||||
</if>
|
||||
<if test="accountNo != null and accountNo != ''">account_no =
|
||||
#{accountNo},
|
||||
</if>
|
||||
<if test="accountType != null and accountType != ''">account_type =
|
||||
#{accountType},
|
||||
</if>
|
||||
<if test="name != null">name =
|
||||
#{name},
|
||||
</if>
|
||||
<if test="balance != null">balance =
|
||||
#{balance},
|
||||
</if>
|
||||
<if test="orderNo != null">order_no =
|
||||
#{orderNo},
|
||||
</if>
|
||||
<if test="tradeType != null and tradeType != ''">trade_type =
|
||||
#{tradeType},
|
||||
</if>
|
||||
<if test="amount != null">amount =
|
||||
#{amount},
|
||||
</if>
|
||||
<if test="createTime != null">create_time =
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="title != null">title =
|
||||
#{title},
|
||||
</if>
|
||||
<if test="updateTime != null">update_time =
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="status != null">status =
|
||||
#{status},
|
||||
</if>
|
||||
<if test="transactionId != null">transaction_id =
|
||||
#{transactionId},
|
||||
</if>
|
||||
<if test="payNo != null">pay_no =
|
||||
#{payNo},
|
||||
</if>
|
||||
<if test="refundCode != null">refund_code =
|
||||
#{refundCode},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deletePrepaidCardLogById" parameterType="Long">
|
||||
delete from zdy_prepaid_card_log where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrepaidCardLogByIds" parameterType="String">
|
||||
delete from zdy_prepaid_card_log where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<select id="selectPrepaidCardLogByPayNo" parameterType="String" resultMap="PrepaidCardLogResult">
|
||||
<include refid="selectPrepaidCardLogVo"/>
|
||||
where pay_no = #{payNo}
|
||||
</select>
|
||||
|
||||
<select id="selectFinishedLogByOrderNo" parameterType="PrepaidCardLog" resultMap="PrepaidCardLogResult">
|
||||
<include refid="selectPrepaidCardLogVo"/>
|
||||
where order_no = #{orderNo} and `status` = #{status} and trade_type=#{tradeType}
|
||||
</select>
|
||||
</mapper>
|
@@ -0,0 +1,163 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.zhwl.prepaidCard.mapper.PrepaidCardMapper">
|
||||
|
||||
<resultMap type="PrepaidCard" id="PrepaidCardResult">
|
||||
<result property="id" column="id"/>
|
||||
<result property="accountNo" column="account_no"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="name" column="name"/>
|
||||
<result property="phone" column="phone"/>
|
||||
<result property="balance" column="balance"/>
|
||||
<result property="status" column="status"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
</resultMap>
|
||||
|
||||
<sql id="selectPrepaidCardVo">
|
||||
select id, account_no, type, name, phone, balance, status, create_time, create_by,update_by, update_time
|
||||
from zdy_prepaid_card
|
||||
</sql>
|
||||
|
||||
<select id="selectPrepaidCardList" parameterType="PrepaidCard" resultMap="PrepaidCardResult">
|
||||
<include refid="selectPrepaidCardVo"/>
|
||||
<where>
|
||||
<if test="accountNo != null and accountNo != ''">
|
||||
and account_no like concat('%', #{accountNo}, '%')
|
||||
</if>
|
||||
<if test="type != null and type != ''">
|
||||
and type = #{type}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
and name like concat('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">
|
||||
and phone = #{phone}
|
||||
</if>
|
||||
<if test="status != null and status != ''">
|
||||
and status = #{status}
|
||||
</if>
|
||||
<if test="params.beginCreateTime != null and params.beginCreateTime != '' and params.endCreateTime != null and params.endCreateTime != ''">
|
||||
and create_time between #{params.beginCreateTime} and #{params.endCreateTime}
|
||||
</if>
|
||||
</where>
|
||||
order by id desc
|
||||
</select>
|
||||
|
||||
<select id="selectPrepaidCardById" parameterType="Long"
|
||||
resultMap="PrepaidCardResult">
|
||||
<include refid="selectPrepaidCardVo"/>
|
||||
where id = #{id}
|
||||
</select>
|
||||
<select id="selectPrepaidCardByAccountNo" parameterType="String"
|
||||
resultMap="PrepaidCardResult">
|
||||
<include refid="selectPrepaidCardVo"/>
|
||||
where account_no = #{accountNo} and (status = '1' or status='2') limit 1
|
||||
</select>
|
||||
<select id="selectPrepaidCardByCreateBy" parameterType="String"
|
||||
resultMap="PrepaidCardResult">
|
||||
<include refid="selectPrepaidCardVo"/>
|
||||
where create_by = #{createBy} and `type` = #{type} and `status` = '1'
|
||||
</select>
|
||||
<select id="selectPrepaidCardByPhone" parameterType="String"
|
||||
resultMap="PrepaidCardResult">
|
||||
<include refid="selectPrepaidCardVo"/>
|
||||
where phone = #{phone} and (status = '1' or status='2') limit 1
|
||||
</select>
|
||||
|
||||
<insert id="insertPrepaidCard" parameterType="PrepaidCard" useGeneratedKeys="true"
|
||||
keyProperty="id">
|
||||
insert into zdy_prepaid_card
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="accountNo != null and accountNo != ''">account_no,
|
||||
</if>
|
||||
<if test="type != null">type,
|
||||
</if>
|
||||
<if test="name != null and name != ''">name,
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">phone,
|
||||
</if>
|
||||
<if test="balance != null">balance,
|
||||
</if>
|
||||
<if test="status != null">status,
|
||||
</if>
|
||||
<if test="createTime != null">create_time,
|
||||
</if>
|
||||
<if test="createBy != null">create_by,
|
||||
</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="accountNo != null and accountNo != ''">#{accountNo},
|
||||
</if>
|
||||
<if test="type != null">#{type},
|
||||
</if>
|
||||
<if test="name != null and name != ''">#{name},
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">#{phone},
|
||||
</if>
|
||||
<if test="balance != null">#{balance},
|
||||
</if>
|
||||
<if test="status != null">#{status},
|
||||
</if>
|
||||
<if test="createTime != null">#{createTime},
|
||||
</if>
|
||||
<if test="createBy != null">#{createBy},
|
||||
</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updatePrepaidCard" parameterType="PrepaidCard">
|
||||
update zdy_prepaid_card
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="accountNo != null and accountNo != ''">account_no =
|
||||
#{accountNo},
|
||||
</if>
|
||||
<if test="type != null">type =
|
||||
#{type},
|
||||
</if>
|
||||
<if test="name != null and name != ''">name =
|
||||
#{name},
|
||||
</if>
|
||||
<if test="phone != null and phone != ''">phone =
|
||||
#{phone},
|
||||
</if>
|
||||
<if test="balance != null">balance =
|
||||
#{balance},
|
||||
</if>
|
||||
<if test="status != null">status =
|
||||
#{status},
|
||||
</if>
|
||||
<if test="createTime != null">create_time =
|
||||
#{createTime},
|
||||
</if>
|
||||
<if test="createBy != null">create_by =
|
||||
#{createBy},
|
||||
</if>
|
||||
<if test="updateTime != null">update_time =
|
||||
#{updateTime},
|
||||
</if>
|
||||
<if test="updateBy != null">update_by =
|
||||
#{updateBy},
|
||||
</if>
|
||||
</trim>
|
||||
where id = #{id}
|
||||
</update>
|
||||
<update id="updatePrepaidCardBalance">
|
||||
update zdy_prepaid_card set balance = balance + #{amount} where id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deletePrepaidCardById" parameterType="Long">
|
||||
delete from zdy_prepaid_card where id = #{id}
|
||||
</delete>
|
||||
|
||||
<delete id="deletePrepaidCardByIds" parameterType="String">
|
||||
delete from zdy_prepaid_card where id in
|
||||
<foreach item="id" collection="array" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
Reference in New Issue
Block a user