| | |
| | | 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("确认成功");
|
| | | }
|
| | | |
| | | |
| | | |
| | | }
|