From de75c6e2df0421058d76bb493d123607b81a2c82 Mon Sep 17 00:00:00 2001 From: xiaoyong931011 <15274802129@163.com> Date: Fri, 22 May 2020 16:37:27 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/chonggaoxiao/new_excoin.git --- src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleDto.java | 49 ++++++++ src/main/resources/mapper/home/MemberQuickBuySaleDao.xml | 48 ++++++++ src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java | 86 ++++++++++++++ src/main/java/com/xcong/excoin/modules/home/service/MemberQuickBuySaleService.java | 9 + src/main/java/com/xcong/excoin/modules/home/controller/MemberQuickBuySaleController.java | 98 ++++++++++++++++ src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleVo.java | 34 +++++ src/main/java/com/xcong/excoin/modules/home/mapper/MemberQuickBuySaleEntityMapper.java | 17 ++ src/main/java/com/xcong/excoin/modules/home/dao/MemberQuickBuySaleDao.java | 9 + 8 files changed, 350 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/xcong/excoin/modules/home/controller/MemberQuickBuySaleController.java b/src/main/java/com/xcong/excoin/modules/home/controller/MemberQuickBuySaleController.java new file mode 100644 index 0000000..ee26bd5 --- /dev/null +++ b/src/main/java/com/xcong/excoin/modules/home/controller/MemberQuickBuySaleController.java @@ -0,0 +1,98 @@ +package com.xcong.excoin.modules.home.controller; + +import java.util.Date; + +import org.apache.commons.codec.digest.Md5Crypt; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import com.alibaba.druid.util.StringUtils; +import com.xcong.excoin.common.annotations.UserAuth; +import com.xcong.excoin.common.response.Result; +import com.xcong.excoin.modules.home.dao.MemberQuickBuySaleDao; +import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleDto; +import com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity; +import com.xcong.excoin.modules.member.entity.MemberEntity; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; + +@RestController +@RequestMapping(value = "/api/quick") +@Api(value = "USDT快捷买卖类", tags = "USDT快捷买卖类") +public class MemberQuickBuySaleController { + + @Autowired + MemberQuickBuySaleDao memberQuickBuySaleDao; + + @ApiOperation(value = "USDT快速充值", notes = "USDT快速充值") + @RequestMapping(value = "/recharge", method = RequestMethod.POST) + public Result recharge(@RequestBody MemberQuickBuySaleDto memberQuickBuySaleDto, + @UserAuth MemberEntity memberEntity) { + // 验证是否实名认证 + if (MemberEntity.CERTIFY_STATUS_Y.equals(memberEntity.getCertifyStatus())) { + return Result.fail("请先实名认证"); + } + String tradePasswordWeb = memberQuickBuySaleDto.getTradePassword(); + // 验证支付密码 + String tradePassword = memberEntity.getTradePassword(); + if (StringUtils.isEmpty(tradePassword)) { + return Result.fail("请先配置交易密码"); + } + if (StringUtils.isEmpty(tradePasswordWeb)) { + return Result.fail("请输入交易密码"); + } + // System.out.println("交易密码:"+MD5.GetMD5Code(tradePasswordWeb)+" tradePassword = + // "+tradePassword); + // 验证交易密码 + if (!Md5Crypt.apr1Crypt(tradePasswordWeb).equals(tradePassword)) { + return Result.fail("请输入正确的交易密码"); + } + // 生成订单号 + Long timestamp = System.currentTimeMillis(); + int random = (int) (Math.random() * 10); + String chargeNo = String.valueOf(timestamp).substring(2) + random; + // 插入订单表 + MemberQuickBuySaleEntity memberQuickBuySaleEntity = new MemberQuickBuySaleEntity(); + memberQuickBuySaleEntity.setOrderStatus(memberQuickBuySaleEntity.CHARGE_STATUS_CREATE); + memberQuickBuySaleEntity.setMemberId(memberEntity.getId()); + memberQuickBuySaleEntity.setCreateTime(new Date()); + memberQuickBuySaleEntity.setOrderNo(chargeNo); + memberQuickBuySaleEntity.setOrderType("B"); + // 支付码 ID+四位随机数 + int ran = (int) (Math.random() * 10000000); + memberQuickBuySaleEntity.setPaymentCode(ran + ""); + memberQuickBuySaleEntity.setPaymentAccount(memberQuickBuySaleDto.getPaymentAccount()); + memberQuickBuySaleEntity.setPaymentName(memberQuickBuySaleDto.getPaymentName()); + + System.out.println("实体对象:"+memberQuickBuySaleEntity); + memberQuickBuySaleDao.insert(memberQuickBuySaleEntity); + // 返回前台付款方式 +// memberChargeUsdt.setReceiveMethod(payMethodList.get(index)); + return Result.ok("购买成功,请及时付款"); + } + + + @ApiOperation(value = "USDT充值支付确认", notes = "USDT充值支付确认") + @ApiImplicitParam(name = "token", value = "token", required = false, dataType = "String", paramType = "body") + @RequestMapping(value = "/commitPay", method = RequestMethod.GET) + public Result commitPay(@PathVariable(value = "id") Long id) { + // 用户提交支付确认 将状态改为付款中 + MemberQuickBuySaleEntity MemberQuickBuySaleEntity = new MemberQuickBuySaleEntity(); + MemberQuickBuySaleEntity.setId(id); + MemberQuickBuySaleEntity.setOrderStatus(MemberQuickBuySaleEntity.CHARGE_STATUS_PAID); + memberQuickBuySaleDao.updateById(MemberQuickBuySaleEntity); + + // TODO dingtalk + + return Result.ok("确认成功"); + } + + + +} diff --git a/src/main/java/com/xcong/excoin/modules/home/dao/MemberQuickBuySaleDao.java b/src/main/java/com/xcong/excoin/modules/home/dao/MemberQuickBuySaleDao.java new file mode 100644 index 0000000..b4515af --- /dev/null +++ b/src/main/java/com/xcong/excoin/modules/home/dao/MemberQuickBuySaleDao.java @@ -0,0 +1,9 @@ +package com.xcong.excoin.modules.home.dao; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity; + +public interface MemberQuickBuySaleDao extends BaseMapper<MemberQuickBuySaleEntity> { + + +} diff --git a/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleDto.java b/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleDto.java new file mode 100644 index 0000000..98c89f2 --- /dev/null +++ b/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleDto.java @@ -0,0 +1,49 @@ +package com.xcong.excoin.modules.home.dto; + +import java.math.BigDecimal; +import java.util.Date; + +import javax.validation.constraints.NotNull; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(value = "会员快捷买入卖出参数接收类", description = "会员快捷买入卖出参数接收类") +public class MemberQuickBuySaleDto { + + @NotNull(message = "用户Id不能为空") + @ApiModelProperty(value = "用户Id",example = "1") + private Long memberId; + + @NotNull(message = "金额不能为空") + @ApiModelProperty(value = "金额(人民币)",example = "700") + private BigDecimal amountCny; + + @NotNull(message = "金额不能为空") + @ApiModelProperty(value = "金额(USDT)",example = "100") + private BigDecimal amountUsdt; + + @ApiModelProperty(value = "付款方式 1-支付宝2-微信3-银行卡",example = "1") + private int paymentType; + + @ApiModelProperty(value = "收款账号",example = "13000000000") + private String paymentAccount; + + @ApiModelProperty(value = "收款人姓名",example = "张三") + private String paymentName; + + @ApiModelProperty(value = "单价",example = "7") + private BigDecimal unitPrice; + + @NotNull(message = "订单类型不能为空") + @ApiModelProperty(value = "订单类型 B买入 S卖出",example = "B") + private String orderType; + + @NotNull(message = "交易密码不能为空") + private String tradePassword; + + @ApiModelProperty(value = "充值时间") + private Date ChargeTime; +} diff --git a/src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java b/src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java new file mode 100644 index 0000000..1c2e801 --- /dev/null +++ b/src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java @@ -0,0 +1,86 @@ +package com.xcong.excoin.modules.home.entity; + +import java.math.BigDecimal; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.xcong.excoin.common.system.base.BaseEntity; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +@TableName("member_quick_buy_sale") +public class MemberQuickBuySaleEntity extends BaseEntity{ + /** + * 订单状态 1-新建 + */ + public final int CHARGE_STATUS_CREATE = 1; + + /** + * 订单状态 2-已付款 + */ + public final int CHARGE_STATUS_PAID = 2; + + /** + * 订单状态 3-已审核 + */ + public final int CHARGE_STATUS_CHECKED = 3; + + /** + * 订单状态 4-撤单 + */ + public final int CHARGE_STATUS_CANCEL_USER = 4; + + /** + * 订单状态 5-系统取消 + */ + public final int CHARGE_STATUS_CANCEL_SYSTEM = 5; + + + private static final long serialVersionUID = 1L; + /** + * 用户Id + */ + private Long memberId; + /** + * 金额(人民币) + */ + private BigDecimal amountCny; + /** + * 金额(USDT) + */ + private BigDecimal amountUsdt; + /** + * 付款方式 1-支付宝2-微信3-银行卡 + */ + private int paymentType; + /** + * 收款账号 + */ + private String paymentAccount; + /** + * 收款人姓名 + */ + private String paymentName; + /** + * 支付码 + */ + private String paymentCode; + /** + * 单价 + */ + private BigDecimal unitPrice; + /** + * 订单状态 1-新建2-已付款3-已审核4-撤单5-系统取消 + */ + private int orderStatus; + /** + * 订单编号 + */ + private String orderNo; + /** + * 订单类型 B买入 S卖出 + */ + private String orderType; +} diff --git a/src/main/java/com/xcong/excoin/modules/home/mapper/MemberQuickBuySaleEntityMapper.java b/src/main/java/com/xcong/excoin/modules/home/mapper/MemberQuickBuySaleEntityMapper.java new file mode 100644 index 0000000..2405f92 --- /dev/null +++ b/src/main/java/com/xcong/excoin/modules/home/mapper/MemberQuickBuySaleEntityMapper.java @@ -0,0 +1,17 @@ +package com.xcong.excoin.modules.home.mapper; + +import org.mapstruct.Mapper; +import org.mapstruct.factory.Mappers; + +import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleDto; + + +@Mapper +public abstract class MemberQuickBuySaleEntityMapper { + + public static final MemberQuickBuySaleEntityMapper INSTANCE = Mappers.getMapper(MemberQuickBuySaleEntityMapper.class); + + + public abstract MemberQuickBuySaleEntityMapper dtoToEntity(MemberQuickBuySaleDto dto); + +} diff --git a/src/main/java/com/xcong/excoin/modules/home/service/MemberQuickBuySaleService.java b/src/main/java/com/xcong/excoin/modules/home/service/MemberQuickBuySaleService.java new file mode 100644 index 0000000..a4e8413 --- /dev/null +++ b/src/main/java/com/xcong/excoin/modules/home/service/MemberQuickBuySaleService.java @@ -0,0 +1,9 @@ +package com.xcong.excoin.modules.home.service; + +import com.baomidou.mybatisplus.extension.service.IService; +import com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity; + +public interface MemberQuickBuySaleService extends IService<MemberQuickBuySaleEntity> { + + +} diff --git a/src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleVo.java b/src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleVo.java new file mode 100644 index 0000000..0965427 --- /dev/null +++ b/src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleVo.java @@ -0,0 +1,34 @@ +package com.xcong.excoin.modules.home.vo; + +import java.math.BigDecimal; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +@Data +@ApiModel(value = "会员快捷买入卖出", description = "会员快捷买入卖出类") +public class MemberQuickBuySaleVo { + + @ApiModelProperty(value = "用户Id") + private Long memberId; + @ApiModelProperty(value = "金额(人民币)") + private BigDecimal amountCny; + @ApiModelProperty(value = "金额(USDT)") + private BigDecimal amountUsdt; + @ApiModelProperty(value = "付款方式 1-支付宝2-微信3-银行卡") + private int paymentType; + @ApiModelProperty(value = "收款账号") + private String paymentAccount; + @ApiModelProperty(value = "收款人姓名") + private String paymentName; + @ApiModelProperty(value = "支付码") + private String paymentCode; + @ApiModelProperty(value = "单价") + private BigDecimal unitPrice; + @ApiModelProperty(value = "订单状态 1-新建2-已付款3-已审核4-撤单5-系统取消") + private int orderStatus; + @ApiModelProperty(value = "订单编号") + private String orderNo; + @ApiModelProperty(value = "订单类型 B买入 S卖出") + private String orderType; +} diff --git a/src/main/resources/mapper/home/MemberQuickBuySaleDao.xml b/src/main/resources/mapper/home/MemberQuickBuySaleDao.xml new file mode 100644 index 0000000..2633131 --- /dev/null +++ b/src/main/resources/mapper/home/MemberQuickBuySaleDao.xml @@ -0,0 +1,48 @@ +<?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.xcong.excoin.modules.home.dao.MemberQuickBuySaleDao"> + <!-- 字段sql --> + <sql id="columns"> + id, + member_id, + amount_cny, + amount_usdt, + payment_type, + payment_account, + payment_name, + payment_code, + unit_price, + order_status, + order_no, + order_type + </sql> + + <!-- 属性sql --> + <sql id="propertys"> + #{item.id}, + #{item.memberId}, + #{item.amountCny}, + #{item.amountUsdt}, + #{item.paymentType}, + #{item.paymentAccount}, + #{item.paymentName}, + #{item.paymentCode}, + #{item.unitPrice}, + #{item.orderStatus}, + #{item.orderNo}, + #{item.orderType} + </sql> + + <!-- 插入方法 --> + <insert id="insert" + parameterType="com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity" + useGeneratedKeys="true" keyProperty="id"> + INSERT INTO member_quick_buy_sale ( + <include refid="columns"></include> + ) + VALUES ( + <include refid="propertys"></include> + ) + </insert> +</mapper> \ No newline at end of file -- Gitblit v1.9.1