From 8d3b7abedb862a933bfb29768a8982fcbaa24d0d Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 25 May 2020 12:19:39 +0800
Subject: [PATCH] Merge branch 'master' of https://gitee.com/chonggaoxiao/new_excoin.git

---
 src/main/java/com/xcong/excoin/utils/SpringContextHolder.java                               |    2 
 src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java              |   16 +
 src/main/resources/mapper/home/MemberQuickBuySaleDao.xml                                    |   42 -----
 src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java            |   12 
 src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleVo.java                    |    2 
 src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java                             |    8 
 src/main/java/com/xcong/excoin/configurations/security/TokenFilter.java                     |    1 
 src/main/java/com/xcong/excoin/modules/home/mapper/MemberQuickBuySaleEntityMapper.java      |    3 
 src/main/java/com/xcong/excoin/modules/home/service/impl/MemberQuickBuySaleServiceImpl.java |  157 +++++++++++++++++++
 src/main/java/com/xcong/excoin/modules/home/entity/MemberPaymentMethodEntity.java           |   86 ++++++++++
 src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleDto.java                  |   10 -
 src/main/java/com/xcong/excoin/modules/home/service/MemberQuickBuySaleService.java          |   11 +
 src/main/java/com/xcong/excoin/modules/home/controller/MemberQuickBuySaleController.java    |   96 +++--------
 src/main/java/com/xcong/excoin/modules/home/dao/MemberPaymentMethodDao.java                 |    8 +
 src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleCommitDto.java            |   22 ++
 15 files changed, 344 insertions(+), 132 deletions(-)

diff --git a/src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java b/src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java
index cc8e77b..ae63e6d 100644
--- a/src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java
+++ b/src/main/java/com/xcong/excoin/configurations/WebMvcConfig.java
@@ -38,8 +38,8 @@
                 .allowCredentials(true).maxAge(3600);
     }
 
-    @Bean
-    public SpringContextHolder springContextHolder() {
-        return new SpringContextHolder();
-    }
+//    @Bean
+//    public SpringContextHolder springContextHolder() {
+//        return new SpringContextHolder();
+//    }
 }
diff --git a/src/main/java/com/xcong/excoin/configurations/security/TokenFilter.java b/src/main/java/com/xcong/excoin/configurations/security/TokenFilter.java
index 60b161b..0e5624d 100644
--- a/src/main/java/com/xcong/excoin/configurations/security/TokenFilter.java
+++ b/src/main/java/com/xcong/excoin/configurations/security/TokenFilter.java
@@ -74,7 +74,6 @@
             } else {
                 bearerToken = request.getHeader(AppContants.TOKEN_HEADER);
             }
-            log.info("123:{}", bearerToken);
             if (StringUtils.hasText(bearerToken) && bearerToken.startsWith(AppContants.TOKEN_START_WITH)) {
                 // 去掉令牌前缀
                 String rsaToken = bearerToken.replace(AppContants.TOKEN_START_WITH, "");
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
index ee26bd5..32725f9 100644
--- a/src/main/java/com/xcong/excoin/modules/home/controller/MemberQuickBuySaleController.java
+++ b/src/main/java/com/xcong/excoin/modules/home/controller/MemberQuickBuySaleController.java
@@ -1,25 +1,19 @@
 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.GetMapping;
 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.MemberQuickBuySaleCommitDto;
 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 com.xcong.excoin.modules.home.service.MemberQuickBuySaleService;
 
 import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiImplicitParam;
 import io.swagger.annotations.ApiOperation;
 
 @RestController
@@ -28,69 +22,41 @@
 public class MemberQuickBuySaleController {
 
 	@Autowired
-	MemberQuickBuySaleDao memberQuickBuySaleDao;
+	MemberQuickBuySaleService memberQuickBuySaleService;
 
 	@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("购买成功,请及时付款");
+	public Result recharge(@RequestBody MemberQuickBuySaleDto memberQuickBuySaleDto) {
+		return memberQuickBuySaleService.recharge(memberQuickBuySaleDto);
 	}
 	
 	
 	@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("确认成功");
+	@RequestMapping(value = "/commitPay", method = RequestMethod.POST)
+	public Result commitPay(@RequestBody MemberQuickBuySaleCommitDto memberQuickBuySaleCommitDto) {
+		return memberQuickBuySaleService.commitPay(memberQuickBuySaleCommitDto);
+	}
+	
+	@ApiOperation(value = "查询单个买卖记录", notes = "查询单个买卖记录")
+	@GetMapping(value = "/selectById/{id}")
+	public Result selectById(@PathVariable(value = "id") Long id) {
+		return memberQuickBuySaleService.selectById(id);
+	}
+	
+	
+	
+	/**
+	 * 充值撤销
+	 * 
+	 * @param memberChargeUsdt
+	 * @param page
+	 * @param rows
+	 * @return
+	 */
+	@ApiOperation(value = "充值撤销", notes = "充值撤销")
+	@GetMapping(value = "/cancel/{id}")
+	public Result cancel(@PathVariable(value = "id") Long id) {
+		return memberQuickBuySaleService.cancelRecharge(id);
 	}
 	
 	
diff --git a/src/main/java/com/xcong/excoin/modules/home/dao/MemberPaymentMethodDao.java b/src/main/java/com/xcong/excoin/modules/home/dao/MemberPaymentMethodDao.java
new file mode 100644
index 0000000..3f8a82c
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/home/dao/MemberPaymentMethodDao.java
@@ -0,0 +1,8 @@
+package com.xcong.excoin.modules.home.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.xcong.excoin.modules.home.entity.MemberPaymentMethodEntity;
+
+public interface MemberPaymentMethodDao extends BaseMapper<MemberPaymentMethodEntity> {
+
+}
diff --git a/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleCommitDto.java b/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleCommitDto.java
new file mode 100644
index 0000000..2746b33
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleCommitDto.java
@@ -0,0 +1,22 @@
+package com.xcong.excoin.modules.home.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+@Data
+@ApiModel(value = "确认快捷买入接收参数", description = "确认快捷买入接收参数")
+public class MemberQuickBuySaleCommitDto {
+
+	@ApiModelProperty(value = "主键",example = "1")
+	private Long id;
+	
+	@ApiModelProperty(value = "付款方式 1-支付宝2-微信3-银行卡",example = "1")
+    private int paymentType;
+	
+	@ApiModelProperty(value = "收款账号",example = "13000000000")
+    private String paymentAccount;
+	
+	@ApiModelProperty(value = "收款人姓名",example = "张三")
+    private String paymentName;
+}
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
index 98c89f2..e927ee2 100644
--- a/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleDto.java
+++ b/src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleDto.java
@@ -25,15 +25,6 @@
 	@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;
 	
@@ -42,6 +33,7 @@
     private String orderType;
 	
 	@NotNull(message = "交易密码不能为空")
+	@ApiModelProperty(value = "交易密码",example = "123456")
 	private String tradePassword;
 	
 	@ApiModelProperty(value = "充值时间")
diff --git a/src/main/java/com/xcong/excoin/modules/home/entity/MemberPaymentMethodEntity.java b/src/main/java/com/xcong/excoin/modules/home/entity/MemberPaymentMethodEntity.java
new file mode 100644
index 0000000..d3de533
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/home/entity/MemberPaymentMethodEntity.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 MemberPaymentMethodEntity  extends BaseEntity{
+	/**
+	 * 订单状态 1-新建
+	 */
+	public static final Integer CHARGE_STATUS_CREATE = 1;
+	
+	/**
+	 * 订单状态 2-已付款
+	 */
+	public static final Integer CHARGE_STATUS_PAID = 2;
+	
+	/**
+	 * 订单状态 3-已审核
+	 */
+	public static final Integer CHARGE_STATUS_CHECKED = 3;
+	
+	/**
+	 * 订单状态 4-撤单
+	 */
+	public static final Integer CHARGE_STATUS_CANCEL_USER = 4;
+	
+	/**
+	 * 订单状态 5-系统取消
+	 */
+	public static final Integer 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 Integer 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/entity/MemberQuickBuySaleEntity.java b/src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java
index 1c2e801..88ca2bc 100644
--- a/src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java
+++ b/src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java
@@ -15,27 +15,27 @@
 	/**
 	 * 订单状态 1-新建
 	 */
-	public final int CHARGE_STATUS_CREATE = 1;
+	public static final Integer CHARGE_STATUS_CREATE = 1;
 	
 	/**
 	 * 订单状态 2-已付款
 	 */
-	public final int CHARGE_STATUS_PAID = 2;
+	public static final Integer CHARGE_STATUS_PAID = 2;
 	
 	/**
 	 * 订单状态 3-已审核
 	 */
-	public final int CHARGE_STATUS_CHECKED = 3;
+	public static final Integer CHARGE_STATUS_CHECKED = 3;
 	
 	/**
 	 * 订单状态 4-撤单
 	 */
-	public final int CHARGE_STATUS_CANCEL_USER = 4;
+	public static final Integer CHARGE_STATUS_CANCEL_USER = 4;
 	
 	/**
 	 * 订单状态 5-系统取消
 	 */
-	public final int CHARGE_STATUS_CANCEL_SYSTEM = 5;
+	public static final Integer CHARGE_STATUS_CANCEL_SYSTEM = 5;
 	
 
 	private static final long serialVersionUID = 1L;
@@ -54,7 +54,7 @@
     /**
      * 付款方式 1-支付宝2-微信3-银行卡
      */
-    private int paymentType;
+    private Integer paymentType;
     /**
      * 收款账号
      */
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
index f48f2bb..c1a10dd 100644
--- a/src/main/java/com/xcong/excoin/modules/home/mapper/MemberQuickBuySaleEntityMapper.java
+++ b/src/main/java/com/xcong/excoin/modules/home/mapper/MemberQuickBuySaleEntityMapper.java
@@ -5,6 +5,8 @@
 import org.mapstruct.factory.Mappers;
 
 import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleDto;
+import com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity;
+import com.xcong.excoin.modules.home.vo.MemberQuickBuySaleVo;
 
 
 @Mapper
@@ -12,6 +14,7 @@
 
     public static final MemberQuickBuySaleEntityMapper INSTANCE = Mappers.getMapper(MemberQuickBuySaleEntityMapper.class);
 
+    public abstract MemberQuickBuySaleVo entityToVo(MemberQuickBuySaleEntity memberQuickBuySaleEntity);
     
     public abstract MemberQuickBuySaleEntity 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
index a4e8413..6ab4ba5 100644
--- a/src/main/java/com/xcong/excoin/modules/home/service/MemberQuickBuySaleService.java
+++ b/src/main/java/com/xcong/excoin/modules/home/service/MemberQuickBuySaleService.java
@@ -1,9 +1,20 @@
 package com.xcong.excoin.modules.home.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.xcong.excoin.common.response.Result;
+import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleCommitDto;
+import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleDto;
 import com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity;
 
 public interface MemberQuickBuySaleService extends IService<MemberQuickBuySaleEntity> {
 
+	public Result recharge(MemberQuickBuySaleDto memberQuickBuySaleDto);
 	
+	public Result commitPay(MemberQuickBuySaleCommitDto memberQuickBuySaleCommitDto);
+	
+	public Result selectById(Long id);
+	
+	public Result sell();
+	
+	public Result cancelRecharge(Long id);
 }
diff --git a/src/main/java/com/xcong/excoin/modules/home/service/impl/MemberQuickBuySaleServiceImpl.java b/src/main/java/com/xcong/excoin/modules/home/service/impl/MemberQuickBuySaleServiceImpl.java
new file mode 100644
index 0000000..567c560
--- /dev/null
+++ b/src/main/java/com/xcong/excoin/modules/home/service/impl/MemberQuickBuySaleServiceImpl.java
@@ -0,0 +1,157 @@
+package com.xcong.excoin.modules.home.service.impl;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Service;
+
+import com.alibaba.druid.util.StringUtils;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.xcong.excoin.common.LoginUserUtils;
+import com.xcong.excoin.common.response.Result;
+import com.xcong.excoin.modules.home.dao.MemberPaymentMethodDao;
+import com.xcong.excoin.modules.home.dao.MemberQuickBuySaleDao;
+import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleCommitDto;
+import com.xcong.excoin.modules.home.dto.MemberQuickBuySaleDto;
+import com.xcong.excoin.modules.home.entity.MemberPaymentMethodEntity;
+import com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity;
+import com.xcong.excoin.modules.home.mapper.MemberQuickBuySaleEntityMapper;
+import com.xcong.excoin.modules.home.service.MemberQuickBuySaleService;
+import com.xcong.excoin.modules.home.vo.MemberQuickBuySaleVo;
+import com.xcong.excoin.modules.member.dao.MemberDao;
+import com.xcong.excoin.modules.member.dao.MemberWalletCoinDao;
+import com.xcong.excoin.modules.member.entity.MemberEntity;
+import com.xcong.excoin.modules.member.entity.MemberWalletCoinEntity;
+
+import cn.hutool.crypto.SecureUtil;
+import lombok.extern.slf4j.Slf4j;
+
+@Service
+@Slf4j
+public class MemberQuickBuySaleServiceImpl extends ServiceImpl<MemberQuickBuySaleDao, MemberQuickBuySaleEntity> implements MemberQuickBuySaleService{
+	
+	@Resource
+	MemberDao memberDao;
+	@Resource
+	MemberQuickBuySaleDao memberQuickBuySaleDao;
+	@Resource
+	MemberWalletCoinDao memberWalletCoinDao;
+	@Resource
+	MemberPaymentMethodDao memberPaymentMethodDao;
+
+	@Override
+	public Result recharge(MemberQuickBuySaleDto memberQuickBuySaleDto) {
+		
+		log.info("入参----->{}", memberQuickBuySaleDto);
+		//获取用户ID
+		Long memberId = LoginUserUtils.getAppLoginUser().getId();
+		MemberEntity member = memberDao.selectById(memberId);
+		log.info("查询到的会员----->{}", member);
+		// 验证是否实名认证
+		if (MemberEntity.CERTIFY_STATUS_Y.equals(member.getCertifyStatus())) {
+			return Result.fail("请先实名认证");
+		}
+		String tradePasswordWeb = memberQuickBuySaleDto.getTradePassword();
+		
+		// 验证支付密码
+		String tradePassword = member.getTradePassword();
+		
+		log.info("入参交易密码{},用户设置的交易密码{}", tradePasswordWeb,tradePassword);
+		if (StringUtils.isEmpty(tradePassword)) {
+			return Result.fail("请先配置交易密码");
+		}
+		if (StringUtils.isEmpty(tradePasswordWeb)) {
+			return Result.fail("请输入交易密码");
+		}
+		// System.out.println("交易密码:"+MD5.GetMD5Code(tradePasswordWeb)+" tradePassword =
+		// "+tradePassword);
+		// 验证交易密码
+		if (!tradePassword.equals(SecureUtil.md5(tradePasswordWeb))) {
+			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(memberId);
+		memberQuickBuySaleEntity.setCreateTime(new Date());
+		memberQuickBuySaleEntity.setOrderNo(chargeNo);
+		memberQuickBuySaleEntity.setOrderType("B");
+		// 支付码 ID+四位随机数
+		int ran = (int) (Math.random() * 10000000);
+		memberQuickBuySaleEntity.setPaymentCode(ran + "");
+		
+		memberQuickBuySaleDao.insert(memberQuickBuySaleEntity);
+		// 返回前台付款方式
+//				memberChargeUsdt.setReceiveMethod(payMethodList.get(index));
+		return Result.ok("购买成功,请及时付款");
+	}
+
+	@Override
+	public Result commitPay(MemberQuickBuySaleCommitDto memberQuickBuySaleCommitDto) {
+		// 用户提交支付确认 将状态改为付款中
+		MemberQuickBuySaleEntity memberQuickBuySaleEntity = new MemberQuickBuySaleEntity();
+		memberQuickBuySaleEntity.setId(memberQuickBuySaleCommitDto.getId());
+		memberQuickBuySaleEntity.setOrderStatus(MemberQuickBuySaleEntity.CHARGE_STATUS_PAID);
+		memberQuickBuySaleEntity.setPaymentAccount(memberQuickBuySaleCommitDto.getPaymentAccount());
+		memberQuickBuySaleEntity.setPaymentName(memberQuickBuySaleCommitDto.getPaymentName());
+
+		memberQuickBuySaleDao.updateById(memberQuickBuySaleEntity);
+
+		// TODO dingtalk
+		
+		return Result.ok("确认成功");
+	}
+
+	@Override
+	public Result selectById(Long id) {
+		MemberQuickBuySaleEntity memberQuickBuySaleEntity = memberQuickBuySaleDao.selectById(id);
+		MemberQuickBuySaleVo memberQuickBuySaleVo = MemberQuickBuySaleEntityMapper.INSTANCE.entityToVo(memberQuickBuySaleEntity);
+		long startTime = memberQuickBuySaleEntity.getCreateTime().getTime();
+		long nowTime = new Date().getTime();
+		long third = 30*60*1000;
+		memberQuickBuySaleVo.setTimeLeft((third-nowTime+startTime)/1000);
+		return Result.ok(memberQuickBuySaleVo);
+	}
+
+	
+
+	@Override
+	public Result cancelRecharge(Long id) {
+		// 获取当前登录用户
+		Long memberId = LoginUserUtils.getAppLoginUser().getId();
+		MemberEntity member = memberDao.selectById(memberId);
+		if(memberId==null) {
+			return Result.fail("登录用户已失效");
+		}
+		MemberQuickBuySaleEntity memberQuickBuySaleEntity = memberQuickBuySaleDao.selectById(id);
+		memberQuickBuySaleEntity.setOrderStatus(MemberQuickBuySaleEntity.CHARGE_STATUS_CANCEL_USER);
+		memberQuickBuySaleDao.updateById(memberQuickBuySaleEntity);
+		
+		// 判断是否存在足够余额
+		MemberWalletCoinEntity walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(id,"USDT");
+		boolean flag = true;
+		while(flag) {
+			walletCoin.setAvailableBalance(walletCoin.getAvailableBalance().add(memberQuickBuySaleEntity.getAmountUsdt()));
+			walletCoin.setFrozenBalance(walletCoin.getFrozenBalance().subtract(memberQuickBuySaleEntity.getAmountUsdt()));
+			int i = memberWalletCoinDao.updateById(walletCoin);
+			if(i>0) {
+				flag = false;
+			}
+			walletCoin = memberWalletCoinDao.selectWalletCoinBymIdAndCode(id,"USDT");
+		}
+		return Result.ok("成功");
+	}
+
+	@Override
+	public Result sell() {
+		// TODO Auto-generated method stub
+		return null;
+	}
+}
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
index 0965427..e38eee5 100644
--- a/src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleVo.java
+++ b/src/main/java/com/xcong/excoin/modules/home/vo/MemberQuickBuySaleVo.java
@@ -31,4 +31,6 @@
     private String orderNo;
 	@ApiModelProperty(value = "订单类型 B买入 S卖出")
     private String orderType;
+	@ApiModelProperty(value = "剩余时间")
+    private Long timeLeft;
 }
diff --git a/src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java b/src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java
index fd2db94..0be8a3b 100644
--- a/src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java
+++ b/src/main/java/com/xcong/excoin/modules/test/controller/TestUserController.java
@@ -11,10 +11,7 @@
 import com.xcong.excoin.modules.test.service.TestUserService;
 import com.xcong.excoin.modules.test.vo.TestUserVo;
 import com.xcong.excoin.utils.MessageSourceUtils;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
+import io.swagger.annotations.*;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.validation.annotation.Validated;
@@ -88,9 +85,18 @@
 
     @ApiOperation(value = "根据Id查询用户信息", notes = "根据Id查询用户信息")
     @GetMapping(value = "/findById/{id}")
-    public Result findById(@PathVariable(value = "id") Long id) {
+    public Result findById(@ApiParam(name = "id", value = "用户ID", required = true, example = "1") @PathVariable(value = "id") Long id) {
         TestUserEntity testUserEntity = testUserService.getById(id);
         TestUserVo testUserVo = TestUserEntityMapper.INSTANCE.entityToVo(testUserEntity);
         return Result.ok("success", testUserVo);
     }
+
+    @ApiOperation(value = "根据Id查询用户信息", notes = "根据Id查询用户信息")
+    @GetMapping(value = "/findByIdAndName/{id}/{name}")
+    public Result findByIdAndName(@ApiParam(name = "id", value="用户ID", required = true, example = "1") @PathVariable(value = "id") Long id,
+                                  @ApiParam(name = "name", value="用户姓名", required = true, example = "wzy") @PathVariable(value = "name") String name) {
+        log.info("---->{}", id);
+        log.info("----<{}", name);
+        return Result.ok("success");
+    }
 }
diff --git a/src/main/java/com/xcong/excoin/utils/SpringContextHolder.java b/src/main/java/com/xcong/excoin/utils/SpringContextHolder.java
index 7dbf951..857d02c 100644
--- a/src/main/java/com/xcong/excoin/utils/SpringContextHolder.java
+++ b/src/main/java/com/xcong/excoin/utils/SpringContextHolder.java
@@ -5,6 +5,7 @@
 import org.springframework.beans.factory.DisposableBean;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Component;
 
 /**
  * @Author wzy
@@ -12,6 +13,7 @@
  * @email wangdoubleone@gmail.com
  * @Version V1.0
  **/
+@Component
 @Slf4j
 public class SpringContextHolder implements ApplicationContextAware, DisposableBean {
 
diff --git a/src/main/resources/mapper/home/MemberQuickBuySaleDao.xml b/src/main/resources/mapper/home/MemberQuickBuySaleDao.xml
index 2633131..44ea088 100644
--- a/src/main/resources/mapper/home/MemberQuickBuySaleDao.xml
+++ b/src/main/resources/mapper/home/MemberQuickBuySaleDao.xml
@@ -3,46 +3,4 @@
 <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