fix:小程序支付密码修改、充值、充值列表、提现接口
This commit is contained in:
@@ -85,4 +85,25 @@ public interface WalletService {
|
||||
* @return 账户充值VO
|
||||
*/
|
||||
AccountPaymentVO payment(AccountPaymentRequest request);
|
||||
|
||||
/**
|
||||
* 未完成充值订单查询
|
||||
* @param request 查询request
|
||||
* @return 钱包支付订单VO列表
|
||||
*/
|
||||
PageInfo<WalletPaymentOrderVO> nonPaymentOrderPage(LargePaymentQueryRequest request);
|
||||
|
||||
/**
|
||||
* 根据预支付id查询收款账户详情
|
||||
* @param paymentId 预支付id
|
||||
* @return 账户充值VO
|
||||
*/
|
||||
AccountPaymentVO paymentDetail(String paymentId);
|
||||
|
||||
/**
|
||||
* 提现
|
||||
* @param request 钱包提现Request
|
||||
* @return 是否成功
|
||||
*/
|
||||
Boolean withDrawer(WalletWithDrawerRequest request);
|
||||
}
|
||||
|
||||
@@ -3,15 +3,14 @@ package com.cool.store.service.wallet.impl;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.cool.store.constants.CommonConstants;
|
||||
import com.cool.store.dao.LineInfoDAO;
|
||||
import com.cool.store.dao.RegionDao;
|
||||
import com.cool.store.dao.ShopInfoDAO;
|
||||
import com.cool.store.dao.ShopStageInfoDAO;
|
||||
import com.cool.store.dao.wallet.WalletLargePaymentDAO;
|
||||
import com.cool.store.dao.wallet.WalletPaymentOrderDAO;
|
||||
import com.cool.store.dto.wallet.*;
|
||||
import com.cool.store.entity.LicenseTransactDO;
|
||||
import com.cool.store.entity.RegionDO;
|
||||
import com.cool.store.entity.ShopInfoDO;
|
||||
import com.cool.store.entity.ShopStageInfoDO;
|
||||
import com.cool.store.entity.*;
|
||||
import com.cool.store.entity.wallet.WalletPaymentOrderDO;
|
||||
import com.cool.store.enums.ErrorCodeEnum;
|
||||
import com.cool.store.enums.point.ShopSubStageEnum;
|
||||
import com.cool.store.enums.point.ShopSubStageStatusEnum;
|
||||
@@ -25,6 +24,7 @@ import com.cool.store.service.wallet.WalletService;
|
||||
import com.cool.store.utils.BeanUtil;
|
||||
import com.cool.store.utils.UUIDUtils;
|
||||
import com.cool.store.vo.wallet.*;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.github.pagehelper.PageInfo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -32,8 +32,12 @@ import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Date;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -56,7 +60,10 @@ public class WalletServiceImpl implements WalletService {
|
||||
private final ApplyLicenseMapper applyLicenseMapper;
|
||||
private final WalletApiService walletApiService;
|
||||
private final RegionDao regionDao;
|
||||
private final WalletLargePaymentDAO walletLargePaymentDAO;
|
||||
private final WalletPaymentOrderDAO walletPaymentOrderDAO;
|
||||
private final LineInfoDAO lineInfoDAO;
|
||||
|
||||
private final static DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@Override
|
||||
public Boolean accountCreate(AccountCreateRequest request) {
|
||||
@@ -234,11 +241,84 @@ public class WalletServiceImpl implements WalletService {
|
||||
|
||||
@Override
|
||||
public AccountPaymentVO payment(AccountPaymentRequest request) {
|
||||
String storeId = getStoreId(request);
|
||||
ShopInfoDO shopInfo = null;
|
||||
if (Objects.nonNull(request.getShopId())) {
|
||||
shopInfo = shopInfoDAO.getShopInfo(request.getShopId());
|
||||
} else if (StringUtils.isNotBlank(request.getStoreId())) {
|
||||
shopInfo = shopInfoDAO.getShopInfoByStoreId(request.getStoreId());
|
||||
}
|
||||
if (Objects.isNull(shopInfo)) {
|
||||
throw new ServiceException(ErrorCodeEnum.SHOP_NOT_EXIST);
|
||||
}
|
||||
String storeId = shopInfo.getStoreId();
|
||||
LineInfoDO lineInfo = lineInfoDAO.getByPartnerId(shopInfo.getPartnerId());
|
||||
if (Objects.isNull(lineInfo)) {
|
||||
throw new ServiceException(ErrorCodeEnum.LINE_ID_IS_NOT_EXIST);
|
||||
}
|
||||
String paymentId = UUIDUtils.get32UUID();
|
||||
// new LargePaymentRequest(storeId, paymentId, "", request.getAmount());
|
||||
LargePaymentRequest paymentRequest = new LargePaymentRequest(storeId, paymentId, lineInfo.getUsername(), request.getAmount().toString());
|
||||
LargePaymentDTO resultDTO = walletApiService.largePayment(paymentRequest);
|
||||
|
||||
return null;
|
||||
long expiryCountdown = 0;
|
||||
if (StringUtils.isNotBlank(resultDTO.getExpireTime())) {
|
||||
expiryCountdown = Math.max(0, Duration.between(LocalDateTime.now(), LocalDateTime.parse(resultDTO.getExpireTime(), formatter)).getSeconds());
|
||||
}
|
||||
WalletPaymentOrderDO orderDO = WalletPaymentOrderDO.builder()
|
||||
.storeId(storeId)
|
||||
.paymentId(paymentId)
|
||||
.type(0)
|
||||
.amount(request.getAmount())
|
||||
.expireTime(resultDTO.getExpireTime())
|
||||
.orderStatus(3)
|
||||
.build();
|
||||
walletPaymentOrderDAO.insertSelective(orderDO);
|
||||
AccountPaymentVO result = BeanUtil.toBean(resultDTO, AccountPaymentVO.class);
|
||||
result.setExpiryCountdown(expiryCountdown);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageInfo<WalletPaymentOrderVO> nonPaymentOrderPage(LargePaymentQueryRequest request) {
|
||||
PageHelper.startPage(request.getPageNum(), request.getPageSize());
|
||||
String storeId = getStoreId(request);
|
||||
List<WalletPaymentOrderDO> list = walletPaymentOrderDAO.getNonPaymentList(storeId);
|
||||
PageInfo<WalletPaymentOrderDO> page = new PageInfo<>(list);
|
||||
return BeanUtil.toPage(page, WalletPaymentOrderVO.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AccountPaymentVO paymentDetail(String paymentId) {
|
||||
PaymentDetailRequest request = new PaymentDetailRequest();
|
||||
request.setPaymentId(paymentId);
|
||||
PaymentDTO resultDTO = walletApiService.largePaymentQuery(request);
|
||||
|
||||
long expiryCountdown = 0;
|
||||
if (StringUtils.isNotBlank(resultDTO.getExpireTime())) {
|
||||
expiryCountdown = Math.max(0, Duration.between(LocalDateTime.now(), LocalDateTime.parse(resultDTO.getExpireTime(), formatter)).getSeconds());
|
||||
}
|
||||
AccountPaymentVO result = BeanUtil.toBean(resultDTO, AccountPaymentVO.class);
|
||||
result.setExpiryCountdown(expiryCountdown);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean withDrawer(WalletWithDrawerRequest request) {
|
||||
String storeId = getStoreId(request);
|
||||
String reqNo = UUIDUtils.get32UUID();
|
||||
WithDrawerRequest withDrawerRequest = new WithDrawerRequest(storeId, request.getPayPwd(), reqNo, request.getAmount().toString(), "提现");
|
||||
WithDrawerDTO withdraw = walletApiService.withdraw(withDrawerRequest);
|
||||
if ("2".equals(withdraw.getTradeStatus())) {
|
||||
throw new ServiceException(ErrorCodeEnum.WALLET_WITH_DRAWER_FAIL);
|
||||
}
|
||||
WalletPaymentOrderDO orderDO = WalletPaymentOrderDO.builder()
|
||||
.storeId(storeId)
|
||||
.paymentId(reqNo)
|
||||
.type(1)
|
||||
.amount(request.getAmount())
|
||||
.orderStatus(1)
|
||||
.build();
|
||||
walletPaymentOrderDAO.insertSelective(orderDO);
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getStoreId(StoreShopRequest request) {
|
||||
|
||||
Reference in New Issue
Block a user