src/main/java/com/xcong/excoin/modules/home/controller/MemberQuickBuySaleController.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/home/dao/MemberQuickBuySaleDao.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleDto.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java | ●●●●● patch | view | raw | blame | history | |
src/main/java/com/xcong/excoin/modules/home/mapper/MemberQuickBuySaleEntityMapper.java | ●●●●● patch | view | raw | blame | history | |
src/main/resources/mapper/home/MemberQuickBuySaleDao.xml | ●●●●● patch | view | raw | blame | history |
src/main/java/com/xcong/excoin/modules/home/controller/MemberQuickBuySaleController.java
@@ -1,25 +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快速充值") @ApiImplicitParam(name = "token", value = "token", required = false, dataType = "String", paramType = "body") @RequestMapping(value = "/recharge", method = RequestMethod.POST) public void recharge(@RequestBody MemberQuickBuySaleDto memberQuickBuySaleDto) { // 获取当前登录用户 // String mId = (String) redisUtil.get(token); 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("确认成功"); } } src/main/java/com/xcong/excoin/modules/home/dao/MemberQuickBuySaleDao.java
@@ -1,5 +1,9 @@ package com.xcong.excoin.modules.home.dao; public class MemberQuickBuySaleDao { import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.xcong.excoin.modules.home.entity.MemberQuickBuySaleEntity; public interface MemberQuickBuySaleDao extends BaseMapper<MemberQuickBuySaleEntity> { } src/main/java/com/xcong/excoin/modules/home/dto/MemberQuickBuySaleDto.java
@@ -1,6 +1,7 @@ package com.xcong.excoin.modules.home.dto; import java.math.BigDecimal; import java.util.Date; import javax.validation.constraints.NotNull; @@ -36,10 +37,13 @@ @ApiModelProperty(value = "单价",example = "7") private BigDecimal unitPrice; @ApiModelProperty(value = "订单状态 1-新建2-已付款3-已审核4-撤单5-系统取消",example = "1") private int orderStatus; @NotNull(message = "订单类型不能为空") @ApiModelProperty(value = "订单类型 B买入 S卖出",example = "B") private String orderType; @NotNull(message = "交易密码不能为空") private String tradePassword; @ApiModelProperty(value = "充值时间") private Date ChargeTime; } src/main/java/com/xcong/excoin/modules/home/entity/MemberQuickBuySaleEntity.java
@@ -12,6 +12,31 @@ @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; /** src/main/java/com/xcong/excoin/modules/home/mapper/MemberQuickBuySaleEntityMapper.java
New file @@ -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); } src/main/resources/mapper/home/MemberQuickBuySaleDao.xml
New file @@ -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>