2023-03-04 16:29:55 +08:00
|
|
|
|
package com.jsowell.service;
|
|
|
|
|
|
|
2023-07-24 15:32:19 +08:00
|
|
|
|
import cn.hutool.core.util.PageUtil;
|
2023-05-27 09:36:07 +08:00
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
2023-05-16 16:24:26 +08:00
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
|
import com.alibaba.fastjson2.TypeReference;
|
2024-06-11 16:30:42 +08:00
|
|
|
|
import com.alipay.easysdk.factory.Factory;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
2023-05-16 16:24:26 +08:00
|
|
|
|
import com.google.common.collect.ImmutableMap;
|
2023-05-27 09:36:07 +08:00
|
|
|
|
import com.google.common.collect.Maps;
|
2023-05-16 16:24:26 +08:00
|
|
|
|
import com.huifu.adapay.core.exception.BaseAdaPayException;
|
|
|
|
|
|
import com.huifu.adapay.model.Payment;
|
|
|
|
|
|
import com.jsowell.adapay.common.CreateAdaPaymentParam;
|
2023-08-15 15:42:39 +08:00
|
|
|
|
import com.jsowell.adapay.config.AbstractAdapayConfig;
|
|
|
|
|
|
import com.jsowell.adapay.factory.AdapayConfigFactory;
|
2024-06-11 16:30:42 +08:00
|
|
|
|
import com.jsowell.alipay.service.AliAppletRemoteService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.constant.CacheConstants;
|
|
|
|
|
|
import com.jsowell.common.constant.Constants;
|
2023-10-10 10:32:19 +08:00
|
|
|
|
import com.jsowell.common.constant.UserConstants;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.core.page.PageResponse;
|
|
|
|
|
|
import com.jsowell.common.core.redis.RedisCache;
|
2023-04-13 15:31:04 +08:00
|
|
|
|
import com.jsowell.common.enums.TitleTypeEnum;
|
2023-09-01 11:36:31 +08:00
|
|
|
|
import com.jsowell.common.enums.adapay.MerchantDelayModeEnum;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.enums.uniapp.BalanceChangesEnum;
|
|
|
|
|
|
import com.jsowell.common.enums.ykc.ReturnCodeEnum;
|
2023-05-16 16:24:26 +08:00
|
|
|
|
import com.jsowell.common.enums.ykc.ScenarioEnum;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.exception.BusinessException;
|
2023-05-16 16:24:26 +08:00
|
|
|
|
import com.jsowell.common.util.AdapayUtil;
|
2023-07-22 15:23:31 +08:00
|
|
|
|
import com.jsowell.common.util.DateUtils;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.common.util.JWTUtils;
|
|
|
|
|
|
import com.jsowell.common.util.StringUtils;
|
|
|
|
|
|
import com.jsowell.common.util.id.IdUtils;
|
2023-05-27 16:01:27 +08:00
|
|
|
|
import com.jsowell.common.util.id.SnowflakeIdWorker;
|
2023-06-20 16:13:25 +08:00
|
|
|
|
import com.jsowell.pile.domain.*;
|
2023-06-20 15:52:13 +08:00
|
|
|
|
import com.jsowell.pile.dto.*;
|
2023-06-20 16:13:25 +08:00
|
|
|
|
import com.jsowell.pile.service.*;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.pile.transaction.dto.MemberTransactionDTO;
|
|
|
|
|
|
import com.jsowell.pile.transaction.service.TransactionService;
|
2024-04-15 15:57:52 +08:00
|
|
|
|
import com.jsowell.pile.util.MerchantUtils;
|
2023-11-21 15:10:54 +08:00
|
|
|
|
import com.jsowell.pile.vo.base.MemberWalletVO;
|
2024-01-22 12:32:22 +08:00
|
|
|
|
import com.jsowell.pile.vo.uniapp.InvoiceTitleVO;
|
|
|
|
|
|
import com.jsowell.pile.vo.uniapp.MemberVO;
|
|
|
|
|
|
import com.jsowell.pile.vo.uniapp.MemberWalletInfoVO;
|
|
|
|
|
|
import com.jsowell.pile.vo.uniapp.MemberWalletLogVO;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import com.jsowell.wxpay.service.WxAppletRemoteService;
|
2023-03-06 15:17:04 +08:00
|
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
2023-04-13 15:31:04 +08:00
|
|
|
|
import org.apache.commons.compress.utils.Lists;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
2023-04-13 15:31:04 +08:00
|
|
|
|
import org.springframework.beans.BeanUtils;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
2023-05-27 14:27:36 +08:00
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
2023-05-16 16:24:26 +08:00
|
|
|
|
import org.springframework.cglib.beans.BeanMap;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
2023-06-20 15:52:13 +08:00
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
import java.text.ParseException;
|
2023-07-22 15:23:31 +08:00
|
|
|
|
import java.util.*;
|
2023-06-20 15:52:13 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
|
public class MemberService {
|
|
|
|
|
|
private final Logger log = LoggerFactory.getLogger(this.getClass());
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private RedisCache redisCache;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private TransactionService transactionService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2024-01-06 15:20:28 +08:00
|
|
|
|
private MemberBasicInfoService memberBasicInfoService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2024-01-06 15:20:28 +08:00
|
|
|
|
private PileMerchantInfoService pileMerchantInfoService;
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private WxAppletRemoteService wxAppletRemoteService;
|
|
|
|
|
|
|
2024-06-11 16:30:42 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private AliAppletRemoteService aliAppletRemoteService;
|
|
|
|
|
|
|
2023-03-06 15:17:04 +08:00
|
|
|
|
@Autowired
|
2024-01-06 15:20:28 +08:00
|
|
|
|
private MemberPlateNumberRelationService memberPlateNumberRelationService;
|
2023-03-06 15:17:04 +08:00
|
|
|
|
|
2023-03-18 10:59:02 +08:00
|
|
|
|
@Autowired
|
2023-12-01 13:29:35 +08:00
|
|
|
|
private PileAuthCardService pileAuthCardService;
|
2023-03-18 10:59:02 +08:00
|
|
|
|
|
2023-04-13 15:31:04 +08:00
|
|
|
|
@Autowired
|
2024-01-06 15:20:28 +08:00
|
|
|
|
private MemberInvoiceTitleService memberInvoiceTitleService;
|
2023-04-13 15:31:04 +08:00
|
|
|
|
|
2023-07-24 15:32:19 +08:00
|
|
|
|
@Autowired
|
2023-11-08 15:59:11 +08:00
|
|
|
|
private MemberWalletInfoService memberWalletInfoService;
|
2023-07-24 15:32:19 +08:00
|
|
|
|
|
2023-06-20 16:13:25 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private PileRemoteService pileRemoteService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
2024-01-06 15:13:50 +08:00
|
|
|
|
private OrderBasicInfoService orderBasicInfoService;
|
2023-06-20 16:13:25 +08:00
|
|
|
|
|
2023-05-16 16:24:26 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private OrderService orderService;
|
|
|
|
|
|
|
2023-08-15 11:02:02 +08:00
|
|
|
|
@Value("${adapay.jsowell.appId}")
|
2023-05-27 14:27:36 +08:00
|
|
|
|
private String ADAPAY_APP_ID;
|
|
|
|
|
|
|
|
|
|
|
|
@Value("${adapay.callback}")
|
|
|
|
|
|
private String ADAPAY_CALLBACK_URL;
|
|
|
|
|
|
|
2023-08-04 13:42:53 +08:00
|
|
|
|
@Value("${weixin.login.appid}")
|
|
|
|
|
|
private String APP_ID;
|
|
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 校验短信验证码
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void checkVerificationCode(MemberRegisterAndLoginDTO dto) {
|
|
|
|
|
|
// 取出缓存中的验证码进行对比,如果缓存中没有,则超时
|
|
|
|
|
|
String captchaCode = redisCache.getCacheObject(CacheConstants.SMS_VERIFICATION_CODE_KEY + dto.getMobileNumber());
|
|
|
|
|
|
if (StringUtils.isEmpty(captchaCode)) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_VERIFICATION_CODE_TIMEOUT_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 如果缓存中有,但与实际不一致,则为验证码错误
|
|
|
|
|
|
if (!StringUtils.equals(captchaCode, dto.getVerificationCode())) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_VERIFICATION_CODE_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 短信验证码登录注册
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String memberRegisterAndLogin(MemberRegisterAndLoginDTO dto) {
|
|
|
|
|
|
// 校验短信验证码 两种情况不能通过校验,1-验证码错误;2-超时 验证码10分钟有效
|
|
|
|
|
|
checkVerificationCode(dto);
|
2023-05-06 17:05:20 +08:00
|
|
|
|
return memberRegisterAndLogin(dto.getMobileNumber(), dto.getMerchantId(), dto.getOpenId());
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 公共登陆注册方法
|
|
|
|
|
|
* @param phoneNumber 手机号
|
2023-12-08 09:59:09 +08:00
|
|
|
|
* @param firstLevelMerchantId 商户id
|
2023-05-06 17:05:20 +08:00
|
|
|
|
* @return token返给前端
|
2023-03-04 16:29:55 +08:00
|
|
|
|
*/
|
2023-12-08 09:59:09 +08:00
|
|
|
|
protected String memberRegisterAndLogin(String phoneNumber, String firstLevelMerchantId, String openId) {
|
2023-03-04 16:29:55 +08:00
|
|
|
|
if (StringUtils.isBlank(phoneNumber)) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_GET_MOBILE_NUMBER_BY_CODE_ERROR);
|
|
|
|
|
|
}
|
2023-12-08 09:59:09 +08:00
|
|
|
|
if (StringUtils.isBlank(firstLevelMerchantId)) {
|
2023-08-04 16:14:55 +08:00
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_GET_MERCHANT_ID_BY_APP_ID_ERROR);
|
|
|
|
|
|
}
|
2024-06-11 16:30:42 +08:00
|
|
|
|
|
|
|
|
|
|
// 2024年6月11日15点37分 支付宝没有openid,改为不校验openid
|
|
|
|
|
|
// if (StringUtils.isBlank(openId)) {
|
|
|
|
|
|
// throw new BusinessException(ReturnCodeEnum.CODE_OPEN_ID_IS_NULL_ERROR);
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
|
// 查询手机号码是否注册过
|
2023-12-08 09:59:09 +08:00
|
|
|
|
MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumber(phoneNumber, firstLevelMerchantId);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
if (Objects.isNull(memberBasicInfo)) {
|
|
|
|
|
|
// 不存在则新增数据
|
2023-05-06 16:02:25 +08:00
|
|
|
|
String memberId = generateNewMemberId();
|
2023-03-04 16:29:55 +08:00
|
|
|
|
memberBasicInfo = new MemberBasicInfo();
|
|
|
|
|
|
memberBasicInfo.setStatus(Constants.ONE);
|
|
|
|
|
|
memberBasicInfo.setMemberId(memberId);
|
|
|
|
|
|
memberBasicInfo.setNickName("会员" + memberId);
|
|
|
|
|
|
memberBasicInfo.setMobileNumber(phoneNumber);
|
2023-12-08 09:59:09 +08:00
|
|
|
|
memberBasicInfo.setMerchantId(Long.valueOf(firstLevelMerchantId));
|
2024-06-11 16:30:42 +08:00
|
|
|
|
if (StringUtils.isBlank(openId)) {
|
|
|
|
|
|
memberBasicInfo.setOpenId(openId);
|
|
|
|
|
|
}
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
2023-12-07 16:12:54 +08:00
|
|
|
|
MemberTransactionDTO memberTransactionDTO = new MemberTransactionDTO();
|
|
|
|
|
|
memberTransactionDTO.setMemberBasicInfo(memberBasicInfo);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
// 首次新建会员,同时新建会员钱包
|
2024-04-15 15:57:52 +08:00
|
|
|
|
if (MerchantUtils.isXiXiaoMerchant(firstLevelMerchantId)) {
|
2023-12-07 16:12:54 +08:00
|
|
|
|
MemberWalletInfo memberWalletInfo = MemberWalletInfo.builder()
|
|
|
|
|
|
.memberId(memberId)
|
2024-04-15 15:57:52 +08:00
|
|
|
|
.merchantId(MerchantUtils.XIXIAO_MERCHANT_ID)
|
2023-12-25 14:00:30 +08:00
|
|
|
|
.walletCode(memberBasicInfoService.generateWalletCode())
|
2023-12-07 16:12:54 +08:00
|
|
|
|
.build();
|
|
|
|
|
|
memberTransactionDTO.setMemberWalletInfo(memberWalletInfo);
|
|
|
|
|
|
}
|
2023-03-04 16:29:55 +08:00
|
|
|
|
transactionService.createMember(memberTransactionDTO);
|
|
|
|
|
|
} else {
|
2023-10-26 11:50:11 +08:00
|
|
|
|
if (!StringUtils.equals(memberBasicInfo.getOpenId(), openId)) {
|
|
|
|
|
|
// openId变化就更新
|
|
|
|
|
|
memberBasicInfo.setOpenId(openId);
|
|
|
|
|
|
memberBasicInfoService.updateMemberBasicInfo(memberBasicInfo);
|
|
|
|
|
|
}
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
// 服务器生成token返给前端
|
|
|
|
|
|
String memberToken = JWTUtils.createMemberToken(memberBasicInfo.getMemberId(), memberBasicInfo.getNickName());
|
|
|
|
|
|
// log.info("memToken:{}", memberToken);
|
|
|
|
|
|
return memberToken;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-06 16:02:25 +08:00
|
|
|
|
private String generateNewMemberId() {
|
|
|
|
|
|
while (true) {
|
|
|
|
|
|
String memberId = IdUtils.getMemberId();
|
|
|
|
|
|
// 通过memberId查询是否已经存在
|
|
|
|
|
|
MemberVO memberVO = memberBasicInfoService.queryMemberInfoByMemberId(memberId);
|
|
|
|
|
|
if (memberVO == null) {
|
|
|
|
|
|
return memberId;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 微信一键登录
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
|
|
|
|
|
public String wechatLogin(WechatLoginDTO dto) {
|
|
|
|
|
|
// 通过微信传的code获取手机号码
|
|
|
|
|
|
String mobileNumber = wxAppletRemoteService.getMobileNumberByCode(dto.getCode());
|
|
|
|
|
|
if (StringUtils.isBlank(mobileNumber)) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_GET_MOBILE_NUMBER_BY_CODE_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 通过code获取openId
|
|
|
|
|
|
String openId = "";
|
|
|
|
|
|
try {
|
2024-06-11 16:30:42 +08:00
|
|
|
|
openId = wxAppletRemoteService.getOpenIdByCode(dto.getOpenIdCode());
|
2023-03-04 16:29:55 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("getOpenIdByCode发生异常", e);
|
|
|
|
|
|
}
|
2023-08-04 13:42:53 +08:00
|
|
|
|
// 根据appid查询merchantId
|
2024-06-11 16:30:42 +08:00
|
|
|
|
String firstLevelMerchantId = pileMerchantInfoService.getFirstLevelMerchantIdByAppId(dto.getAppId());
|
2023-03-04 16:29:55 +08:00
|
|
|
|
// 查询手机号码是否注册过
|
2023-12-08 09:59:09 +08:00
|
|
|
|
return memberRegisterAndLogin(mobileNumber, firstLevelMerchantId, openId);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-06-11 16:30:42 +08:00
|
|
|
|
public String alipayLogin(AlipayLoginDTO dto) throws Exception {
|
|
|
|
|
|
// 通过密文解密 获取手机号码
|
|
|
|
|
|
String mobileNumber = Factory.Util.AES().decrypt(dto.getMobileNumberCiphertext());
|
|
|
|
|
|
|
|
|
|
|
|
// 根据appid查询merchantId
|
|
|
|
|
|
String firstLevelMerchantId = pileMerchantInfoService.getFirstLevelMerchantIdByAppId(dto.getAppId());
|
|
|
|
|
|
|
|
|
|
|
|
// 查询手机号码是否注册过
|
|
|
|
|
|
return memberRegisterAndLogin(mobileNumber, firstLevelMerchantId, "");
|
2024-06-07 11:33:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-04 16:29:55 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取openId
|
|
|
|
|
|
* @param code
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2024-06-11 16:30:42 +08:00
|
|
|
|
// public String getOpenIdByCode(String code) {
|
|
|
|
|
|
// return wxAppletRemoteService.getOpenIdByCode(code);
|
|
|
|
|
|
// }
|
2023-03-04 16:29:55 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 处理用户信息
|
|
|
|
|
|
*
|
2023-06-03 15:35:12 +08:00
|
|
|
|
* @param memberId
|
|
|
|
|
|
* @param dto 用户个人信息
|
2023-03-04 16:29:55 +08:00
|
|
|
|
*/
|
2023-06-03 15:35:12 +08:00
|
|
|
|
public void handleUserInfo(String memberId, MemberRegisterDTO dto) {
|
2023-03-04 16:29:55 +08:00
|
|
|
|
// 通过用户手机号查询数据库,如果数据库中存在,则更新
|
2023-06-03 15:35:12 +08:00
|
|
|
|
// MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMobileNumber(dto.getMobileNumber());
|
|
|
|
|
|
MemberBasicInfo memberBasicInfo = memberBasicInfoService.selectInfoByMemberId(memberId);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
if (Objects.nonNull(memberBasicInfo)) {
|
2023-06-03 15:35:12 +08:00
|
|
|
|
if (StringUtils.isNotBlank(dto.getAvatarUrl())) {
|
|
|
|
|
|
memberBasicInfo.setAvatarUrl(dto.getAvatarUrl());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(dto.getMobileNumber())) {
|
|
|
|
|
|
memberBasicInfo.setMobileNumber(dto.getMobileNumber());
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(dto.getNickName())) {
|
|
|
|
|
|
memberBasicInfo.setNickName(dto.getNickName());
|
|
|
|
|
|
}
|
|
|
|
|
|
memberBasicInfoService.updateMemberBasicInfo(memberBasicInfo);
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 通过memberToken获取用户账户信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param memberId
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public MemberVO getMemberInfoByMemberId(String memberId) {
|
|
|
|
|
|
MemberVO memberVO = memberBasicInfoService.queryMemberInfoByMemberId(memberId);
|
|
|
|
|
|
return memberVO;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 查询用户账户余额变动信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
|
|
|
|
|
public PageResponse getMemberBalanceChanges(UniAppQueryMemberBalanceDTO dto) {
|
|
|
|
|
|
|
|
|
|
|
|
// 获取分页信息以及memberId
|
|
|
|
|
|
int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum();
|
|
|
|
|
|
int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize();
|
|
|
|
|
|
String memberId = dto.getMemberId();
|
|
|
|
|
|
String type = dto.getType();
|
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtils.equals("1", type) && !StringUtils.equals("2", type)) {
|
|
|
|
|
|
type = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
// 分页
|
|
|
|
|
|
PageHelper.startPage(pageNum, pageSize);
|
|
|
|
|
|
List<MemberWalletLogVO> list = memberBasicInfoService.getMemberBalanceChanges(memberId, type);
|
|
|
|
|
|
PageInfo<MemberWalletLogVO> pageInfo = new PageInfo<>(list);
|
|
|
|
|
|
|
|
|
|
|
|
for (MemberWalletLogVO walletLogVO : pageInfo.getList()) {
|
|
|
|
|
|
String subType = walletLogVO.getSubType();
|
|
|
|
|
|
String subTypeValue = BalanceChangesEnum.getValueByCode(subType);
|
|
|
|
|
|
if (StringUtils.isNotBlank(subTypeValue)) {
|
|
|
|
|
|
walletLogVO.setSubType(subTypeValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
// walletLogVO.setTotalAccountAmount(walletLogVO.getPrincipalBalance().add(walletLogVO.getGiftBalance()));
|
|
|
|
|
|
}
|
|
|
|
|
|
PageResponse pageResponse = PageResponse.builder()
|
|
|
|
|
|
.pageSize(pageSize)
|
|
|
|
|
|
.pageNum(pageNum)
|
|
|
|
|
|
.list(pageInfo.getList())
|
|
|
|
|
|
.pages(pageInfo.getPages())
|
|
|
|
|
|
.total(pageInfo.getTotal())
|
|
|
|
|
|
.build();
|
|
|
|
|
|
return pageResponse;
|
|
|
|
|
|
}
|
2023-03-06 08:36:39 +08:00
|
|
|
|
|
2023-07-24 15:32:19 +08:00
|
|
|
|
public MemberWalletInfoVO getMemberWalletInfo(UniAppQueryMemberBalanceDTO dto) throws ParseException {
|
2023-07-28 14:47:26 +08:00
|
|
|
|
log.info("查询用户余额信息 service方法 start");
|
2023-07-24 15:32:19 +08:00
|
|
|
|
MemberWalletInfoVO vo = new MemberWalletInfoVO();
|
|
|
|
|
|
vo.setMemberId(dto.getMemberId());
|
|
|
|
|
|
|
|
|
|
|
|
// 查询会员钱包信息表,获取 本金余额
|
2024-03-04 16:34:55 +08:00
|
|
|
|
MemberWalletVO memberWalletVO = memberWalletInfoService.selectMemberWalletInfo(dto.getWalletCode());
|
|
|
|
|
|
if (memberWalletVO == null) {
|
2023-07-24 15:32:19 +08:00
|
|
|
|
// 用户未注册小程序
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_AUTHENTICATION_ERROR);
|
|
|
|
|
|
}
|
2024-05-22 17:24:42 +08:00
|
|
|
|
// 本金 sql处理为空返回0
|
|
|
|
|
|
vo.setPrincipalBalance(memberWalletVO.getPrincipalBalance());
|
2024-05-22 17:40:55 +08:00
|
|
|
|
|
2024-05-22 17:24:42 +08:00
|
|
|
|
// 赠金 sql处理为空返回0
|
|
|
|
|
|
vo.setGiftBalance(memberWalletVO.getGiftBalance());
|
2024-05-22 17:40:55 +08:00
|
|
|
|
|
2023-07-24 15:32:19 +08:00
|
|
|
|
// 当前余额
|
2024-05-22 17:24:42 +08:00
|
|
|
|
vo.setCurrentBalance(vo.getPrincipalBalance().add(vo.getGiftBalance()));
|
2024-05-22 17:40:55 +08:00
|
|
|
|
|
2024-05-22 17:24:42 +08:00
|
|
|
|
// 累计充值本金
|
|
|
|
|
|
vo.setAccumulatedRechargePrincipal(memberWalletVO.getAccumulatedRechargePrincipal());
|
2024-05-22 17:40:55 +08:00
|
|
|
|
|
2024-03-04 16:34:55 +08:00
|
|
|
|
// 累计赠送金额
|
|
|
|
|
|
vo.setAccumulatedRechargeGift(memberWalletVO.getAccumulatedRechargeGift());
|
2024-05-22 17:40:55 +08:00
|
|
|
|
|
2024-03-04 16:34:55 +08:00
|
|
|
|
// 累计消费金额
|
2024-05-22 17:40:55 +08:00
|
|
|
|
vo.setTotalConsumption(memberWalletVO.getAccumulatedConsumptionAmount());
|
|
|
|
|
|
|
|
|
|
|
|
// 总充值
|
|
|
|
|
|
vo.setTotalRechargeAmount(memberWalletVO.getTotalRechargeAmount());
|
|
|
|
|
|
|
|
|
|
|
|
// 根据日期查询会员钱包变动明细 分页
|
|
|
|
|
|
// 获取分页信息
|
|
|
|
|
|
long pageNum = dto.getPageNum() == 0 ? 1L : dto.getPageNum();
|
|
|
|
|
|
long pageSize = dto.getPageSize() == 0 ? 10L : dto.getPageSize();
|
|
|
|
|
|
String tradeDate = dto.getTradeDate();
|
|
|
|
|
|
// 获取年、月
|
|
|
|
|
|
String[] split = StringUtils.split(tradeDate, "-");
|
|
|
|
|
|
int year = Integer.parseInt(split[0]);
|
|
|
|
|
|
int month = Integer.parseInt(split[1]);
|
|
|
|
|
|
// 根据年月获取当月第一天和最后一天
|
|
|
|
|
|
tradeDate = DateUtils.getFirstDay(year, month, DateUtils.YYYY_MM_DD);
|
|
|
|
|
|
String lastDay = DateUtils.getLastDay(year, month, DateUtils.YYYY_MM_DD);
|
|
|
|
|
|
// sql语句查询日期需要多加一天
|
|
|
|
|
|
Date date = DateUtils.addDays(DateUtils.parseDate(lastDay, DateUtils.YYYY_MM_DD), 1);
|
|
|
|
|
|
lastDay = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date);
|
|
|
|
|
|
dto.setTradeDate(tradeDate);
|
|
|
|
|
|
dto.setEndDate(lastDay);
|
2023-07-24 15:32:19 +08:00
|
|
|
|
// PageHelper.startPage(pageNum, pageSize);
|
2023-07-22 15:23:31 +08:00
|
|
|
|
List<MemberWalletLogVO> list = memberBasicInfoService.getMemberWalletDetail(dto);
|
2024-03-04 16:34:55 +08:00
|
|
|
|
|
2023-07-24 15:32:19 +08:00
|
|
|
|
// 总支出
|
2024-05-22 17:40:55 +08:00
|
|
|
|
// BigDecimal totalConsumption = list.stream()
|
|
|
|
|
|
// .map(MemberWalletLogVO::getOrderAmount)
|
|
|
|
|
|
// .filter(Objects::nonNull)
|
|
|
|
|
|
// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
// vo.setTotalConsumption(totalConsumption);
|
2023-07-24 15:32:19 +08:00
|
|
|
|
|
2024-03-04 16:34:55 +08:00
|
|
|
|
// 总充值
|
2024-05-22 17:40:55 +08:00
|
|
|
|
// BigDecimal totalRechargeAmount = list.stream()
|
|
|
|
|
|
// .filter(x -> StringUtils.equals(x.getType(), "1"))
|
|
|
|
|
|
// .filter(x -> StringUtils.equals(x.getSubType(), "10") || StringUtils.equals(x.getSubType(), "11"))
|
|
|
|
|
|
// .map(MemberWalletLogVO::getAmount)
|
|
|
|
|
|
// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
|
|
|
// vo.setTotalRechargeAmount(totalRechargeAmount);
|
2024-03-04 16:34:55 +08:00
|
|
|
|
|
2023-07-24 15:32:19 +08:00
|
|
|
|
// PageInfo<MemberWalletLogVO> pageInfo = new PageInfo<>(list);
|
2023-07-22 15:23:31 +08:00
|
|
|
|
// 获取 type 和 subType 的对应信息
|
2023-07-24 15:32:19 +08:00
|
|
|
|
for (MemberWalletLogVO walletLogVO : list) {
|
2023-07-22 15:23:31 +08:00
|
|
|
|
// 将负数转为正数
|
|
|
|
|
|
walletLogVO.setAmount(BigDecimal.valueOf(Math.abs(walletLogVO.getAmount().doubleValue())).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
String subType = walletLogVO.getSubType();
|
|
|
|
|
|
String subTypeValue = BalanceChangesEnum.getValueByCode(subType);
|
|
|
|
|
|
if (StringUtils.isNotBlank(subTypeValue)) {
|
|
|
|
|
|
walletLogVO.setSubType(subTypeValue);
|
|
|
|
|
|
}
|
|
|
|
|
|
// walletLogVO.setTotalAccountAmount(walletLogVO.getPrincipalBalance().add(walletLogVO.getGiftBalance()));
|
|
|
|
|
|
}
|
2024-01-22 16:31:37 +08:00
|
|
|
|
// log.info("查询用户余额信息 service方法 开始处理分页----");
|
2023-07-24 15:32:19 +08:00
|
|
|
|
List<MemberWalletLogVO> collect = list.stream()
|
|
|
|
|
|
.skip((pageNum - 1) * pageSize)
|
|
|
|
|
|
.limit(pageSize)
|
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
|
|
int total = list.size();
|
|
|
|
|
|
int pages = PageUtil.totalPage(total, dto.getPageSize());
|
|
|
|
|
|
// 返回结果集
|
2023-07-22 15:23:31 +08:00
|
|
|
|
PageResponse pageResponse = PageResponse.builder()
|
2023-07-24 15:32:19 +08:00
|
|
|
|
.pageNum(Integer.parseInt(String.valueOf(pageNum)))
|
|
|
|
|
|
.pageSize(Integer.parseInt(String.valueOf(pageSize)))
|
|
|
|
|
|
.list(collect)
|
|
|
|
|
|
.pages(pages)
|
|
|
|
|
|
.total(total)
|
2023-07-22 15:23:31 +08:00
|
|
|
|
.build();
|
2023-07-24 15:32:19 +08:00
|
|
|
|
vo.setPageResponse(pageResponse);
|
2024-01-22 16:31:37 +08:00
|
|
|
|
// log.info("查询用户余额信息 service方法 end");
|
2023-07-24 15:32:19 +08:00
|
|
|
|
return vo;
|
2023-07-22 15:23:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2023-07-24 15:32:19 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 获取会员钱包明细
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
// public PageResponse getMemberWalletLog (UniAppQueryMemberBalanceDTO dto) throws ParseException {
|
|
|
|
|
|
// // 获取分页信息以及memberId
|
|
|
|
|
|
// int pageNum = dto.getPageNum() == 0 ? 1 : dto.getPageNum();
|
|
|
|
|
|
// int pageSize = dto.getPageSize() == 0 ? 10 : dto.getPageSize();
|
|
|
|
|
|
// String tradeDate = dto.getTradeDate();
|
|
|
|
|
|
// // 获取年、月
|
|
|
|
|
|
// String[] split = StringUtils.split(tradeDate, "-");
|
|
|
|
|
|
// int year = Integer.parseInt(split[0]);
|
|
|
|
|
|
// int month = Integer.parseInt(split[1]);
|
|
|
|
|
|
// // 根据年月获取当月第一天和最后一天
|
|
|
|
|
|
// tradeDate = DateUtils.getFirstDay(year, month, DateUtils.YYYY_MM_DD);
|
|
|
|
|
|
// String lastDay = DateUtils.getLastDay(year, month, DateUtils.YYYY_MM_DD);
|
|
|
|
|
|
// // sql语句查询日期需要多加一天
|
|
|
|
|
|
// Date date = DateUtils.addDays(DateUtils.parseDate(lastDay, DateUtils.YYYY_MM_DD), 1);
|
|
|
|
|
|
// lastDay = DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD, date);
|
|
|
|
|
|
// dto.setTradeDate(tradeDate);
|
|
|
|
|
|
// dto.setEndDate(lastDay);
|
|
|
|
|
|
// // 根据日期查询会员钱包变动明细
|
|
|
|
|
|
// // 分页
|
|
|
|
|
|
// PageHelper.startPage(pageNum, pageSize);
|
|
|
|
|
|
// List<MemberWalletLogVO> list = memberBasicInfoService.getMemberWalletDetail(dto);
|
|
|
|
|
|
// PageInfo<MemberWalletLogVO> pageInfo = new PageInfo<>(list);
|
|
|
|
|
|
// // 获取 type 和 subType 的对应信息
|
|
|
|
|
|
// for (MemberWalletLogVO walletLogVO : pageInfo.getList()) {
|
|
|
|
|
|
// // 将负数转为正数
|
|
|
|
|
|
// walletLogVO.setAmount(BigDecimal.valueOf(Math.abs(walletLogVO.getAmount().doubleValue())).setScale(2, BigDecimal.ROUND_HALF_UP));
|
|
|
|
|
|
// String subType = walletLogVO.getSubType();
|
|
|
|
|
|
// String subTypeValue = BalanceChangesEnum.getValueByCode(subType);
|
|
|
|
|
|
// if (StringUtils.isNotBlank(subTypeValue)) {
|
|
|
|
|
|
// walletLogVO.setSubType(subTypeValue);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// // walletLogVO.setTotalAccountAmount(walletLogVO.getPrincipalBalance().add(walletLogVO.getGiftBalance()));
|
|
|
|
|
|
// }
|
|
|
|
|
|
//
|
|
|
|
|
|
// PageResponse pageResponse = PageResponse.builder()
|
|
|
|
|
|
// .pageSize(pageSize)
|
|
|
|
|
|
// .pageNum(pageNum)
|
|
|
|
|
|
// .list(pageInfo.getList())
|
|
|
|
|
|
// .pages(pageInfo.getPages())
|
|
|
|
|
|
// .total(pageInfo.getTotal())
|
|
|
|
|
|
// .build();
|
|
|
|
|
|
// return pageResponse;
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
2023-03-06 08:36:39 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 用户绑定车牌号
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void memberBindingCarNo(BindingCarNoDTO dto){
|
2023-08-24 16:06:10 +08:00
|
|
|
|
// 校验短信验证码(2023.8.24 不做校验)
|
|
|
|
|
|
// MemberRegisterAndLoginDTO registerAndLoginDTO = MemberRegisterAndLoginDTO.builder()
|
|
|
|
|
|
// .mobileNumber(dto.getPhoneNumber())
|
|
|
|
|
|
// .verificationCode(dto.getVerificationCode())
|
|
|
|
|
|
// .build();
|
|
|
|
|
|
// checkVerificationCode(registerAndLoginDTO);
|
|
|
|
|
|
|
|
|
|
|
|
// 判断当前车牌号是否已经绑定 (2023.8.24 不做校验)
|
2023-03-07 11:12:01 +08:00
|
|
|
|
MemberPlateNumberRelation relation = new MemberPlateNumberRelation();
|
2023-03-06 15:17:04 +08:00
|
|
|
|
relation.setMemberId(dto.getMemberId());
|
2023-08-24 16:06:10 +08:00
|
|
|
|
relation.setLicensePlateNumber(dto.getCarNo());
|
2023-10-10 10:32:19 +08:00
|
|
|
|
// 判断当前车牌号是否被绑定
|
2024-04-03 08:08:48 +08:00
|
|
|
|
// if (UserConstants.NOT_UNIQUE.equals(memberPlateNumberRelationService.checkPlateNumberUnique(dto.getCarNo()))) {
|
|
|
|
|
|
// // 不为空说明该用户绑定过此车牌号
|
|
|
|
|
|
// throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARNO_HAS_BEEN_BINDING);
|
|
|
|
|
|
// }
|
2023-08-24 16:06:10 +08:00
|
|
|
|
|
2023-08-09 11:45:25 +08:00
|
|
|
|
// 校验该车牌号是否为新能源车牌
|
|
|
|
|
|
|
2023-10-10 10:32:19 +08:00
|
|
|
|
relation.setPhoneNumber(dto.getPhoneNumber());
|
2023-06-09 18:31:54 +08:00
|
|
|
|
if (StringUtils.isNotBlank(dto.getVinCode())) {
|
2023-07-11 08:34:06 +08:00
|
|
|
|
// 判断当前vin是否被绑定
|
2023-10-10 10:32:19 +08:00
|
|
|
|
if (UserConstants.NOT_UNIQUE.equals(memberPlateNumberRelationService.checkVinCodeUnique(dto.getVinCode()))) {
|
2023-07-11 08:34:06 +08:00
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_THIS_VIN_HAS_BEEN_BINDING);
|
|
|
|
|
|
}
|
2023-06-10 11:46:04 +08:00
|
|
|
|
relation.setVinCode(dto.getVinCode().toUpperCase(Locale.ROOT));
|
2023-07-11 08:34:06 +08:00
|
|
|
|
relation.setVinStatus(Constants.ONE); // 1-正常使用
|
2023-06-09 18:31:54 +08:00
|
|
|
|
}
|
2023-03-11 15:57:20 +08:00
|
|
|
|
memberPlateNumberRelationService.insertMemberPlateNumberRelation(relation);
|
2023-03-06 08:36:39 +08:00
|
|
|
|
}
|
2023-03-18 10:59:02 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 用户绑定鉴权卡
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
2023-10-10 10:32:19 +08:00
|
|
|
|
public int memberBindCard(BindingCardDTO dto) {
|
2023-03-18 10:59:02 +08:00
|
|
|
|
// 校验短信验证码
|
|
|
|
|
|
MemberRegisterAndLoginDTO registerAndLoginDTO = MemberRegisterAndLoginDTO.builder()
|
|
|
|
|
|
.mobileNumber(dto.getPhoneNumber())
|
|
|
|
|
|
.verificationCode(dto.getVerificationCode())
|
|
|
|
|
|
.build();
|
2023-03-20 17:02:30 +08:00
|
|
|
|
checkVerificationCode(registerAndLoginDTO);
|
2023-03-18 10:59:02 +08:00
|
|
|
|
// 判断当前鉴权卡是否被绑定过
|
2023-03-30 10:54:02 +08:00
|
|
|
|
PileAuthCard pileAuthCardInfo = pileAuthCardService.selectCardInfoByLogicCard(dto.getLogicCard());
|
2023-03-18 10:59:02 +08:00
|
|
|
|
if (pileAuthCardInfo == null){
|
|
|
|
|
|
// 为空说明没查到此卡信息
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARD_HAS_NO_INFO);
|
|
|
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotBlank(pileAuthCardInfo.getMemberId())) {
|
|
|
|
|
|
// memberId 不为空,说明此卡已被绑定
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARD_HAS_BEEN_BINDING);
|
|
|
|
|
|
}
|
2023-03-28 14:31:31 +08:00
|
|
|
|
if (!StringUtils.equals(pileAuthCardInfo.getSecretKey(), dto.getSecretKey().toUpperCase(Locale.ROOT))) {
|
|
|
|
|
|
// 密钥不一致,不能绑定
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_SECRET_KEY_NOT_SAME);
|
|
|
|
|
|
}
|
2023-03-30 10:54:02 +08:00
|
|
|
|
PileAuthCard authCard = PileAuthCard.builder()
|
|
|
|
|
|
.memberId(dto.getMemberId())
|
|
|
|
|
|
.status("1") // 1-正常使用
|
|
|
|
|
|
.createBy(dto.getMemberId())
|
|
|
|
|
|
.id(pileAuthCardInfo.getId())
|
|
|
|
|
|
.build();
|
2023-03-18 10:59:02 +08:00
|
|
|
|
return pileAuthCardService.updatePileAuthCard(authCard);
|
|
|
|
|
|
}
|
2023-03-20 17:02:30 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 用户解绑鉴权卡
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
public int memberUnbindCard(BindingCardDTO dto) {
|
|
|
|
|
|
// 校验短信验证码
|
2023-11-29 14:27:18 +08:00
|
|
|
|
// MemberRegisterAndLoginDTO registerAndLoginDTO = MemberRegisterAndLoginDTO.builder()
|
|
|
|
|
|
// .mobileNumber(dto.getPhoneNumber())
|
|
|
|
|
|
// .verificationCode(dto.getVerificationCode())
|
|
|
|
|
|
// .build();
|
2023-03-20 17:02:30 +08:00
|
|
|
|
// checkVerificationCode(registerAndLoginDTO);
|
2023-11-29 14:27:18 +08:00
|
|
|
|
|
2023-03-20 17:02:30 +08:00
|
|
|
|
// 校验身份信息
|
|
|
|
|
|
PileAuthCard authCard = PileAuthCard.builder()
|
|
|
|
|
|
.logicCard(dto.getLogicCard())
|
|
|
|
|
|
.memberId(dto.getMemberId())
|
|
|
|
|
|
.build();
|
|
|
|
|
|
PileAuthCard pileAuthCardInfo = pileAuthCardService.selectPileAuthCardInfo(authCard);
|
|
|
|
|
|
if (pileAuthCardInfo == null){
|
|
|
|
|
|
// 为空说明没查到此卡信息
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_THIS_CARD_HAS_NO_INFO);
|
|
|
|
|
|
}
|
|
|
|
|
|
// 解绑鉴权卡
|
|
|
|
|
|
return pileAuthCardService.unBindingCard(authCard);
|
|
|
|
|
|
}
|
2023-04-13 15:31:04 +08:00
|
|
|
|
|
|
|
|
|
|
public List<InvoiceTitleVO> queryMemberInvoiceTitles(String memberId) {
|
|
|
|
|
|
List<InvoiceTitleVO> resultList = Lists.newArrayList();
|
2023-05-20 16:25:24 +08:00
|
|
|
|
List<MemberInvoiceTitle> memberInvoiceTitles = memberInvoiceTitleService.selectMemberInvoiceTitleList(memberId);
|
2023-04-13 15:31:04 +08:00
|
|
|
|
if (CollectionUtils.isEmpty(memberInvoiceTitles)) {
|
|
|
|
|
|
return resultList;
|
|
|
|
|
|
}
|
|
|
|
|
|
for (MemberInvoiceTitle memberInvoiceTitle : memberInvoiceTitles) {
|
2023-05-24 11:58:31 +08:00
|
|
|
|
String reception = StringUtils.isNotEmpty(memberInvoiceTitle.getEmail())
|
|
|
|
|
|
? memberInvoiceTitle.getEmail()
|
|
|
|
|
|
: memberInvoiceTitle.getPhoneNumber();
|
2023-04-13 15:31:04 +08:00
|
|
|
|
resultList.add(
|
|
|
|
|
|
InvoiceTitleVO.builder()
|
|
|
|
|
|
.titleId(memberInvoiceTitle.getId() + "")
|
|
|
|
|
|
.titleName(memberInvoiceTitle.getName())
|
|
|
|
|
|
.titleType(TitleTypeEnum.getLabel(memberInvoiceTitle.getTitleType()))
|
2023-05-12 11:21:13 +08:00
|
|
|
|
.taxId(memberInvoiceTitle.getTaxId())
|
|
|
|
|
|
.unitAddress(memberInvoiceTitle.getUnitAddress())
|
|
|
|
|
|
.phoneNumber(memberInvoiceTitle.getPhoneNumber())
|
2023-05-24 11:58:31 +08:00
|
|
|
|
.email(memberInvoiceTitle.getEmail())
|
|
|
|
|
|
.reception(reception)
|
2023-05-12 11:21:13 +08:00
|
|
|
|
.bankName(memberInvoiceTitle.getBankName())
|
|
|
|
|
|
.bankAccountNumber(memberInvoiceTitle.getBankAccountNumber())
|
2023-05-20 16:25:24 +08:00
|
|
|
|
.defaultFlag(memberInvoiceTitle.getDefaultFlag())
|
2023-04-13 15:31:04 +08:00
|
|
|
|
.build()
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
return resultList;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-23 10:59:16 +08:00
|
|
|
|
public void createMemberInvoiceTitle(InvoiceTitleDTO dto) {
|
2023-04-13 15:31:04 +08:00
|
|
|
|
MemberInvoiceTitle title = new MemberInvoiceTitle();
|
|
|
|
|
|
BeanUtils.copyProperties(dto, title);
|
2023-05-24 14:42:54 +08:00
|
|
|
|
title.setName(dto.getTitleName());
|
2023-05-23 09:02:58 +08:00
|
|
|
|
if (StringUtils.isEmail(dto.getReception())) {
|
|
|
|
|
|
title.setEmail(dto.getReception());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
title.setPhoneNumber(dto.getReception());
|
|
|
|
|
|
}
|
2023-04-13 15:31:04 +08:00
|
|
|
|
int i = memberInvoiceTitleService.insertMemberInvoiceTitle(title);
|
2023-05-23 10:59:16 +08:00
|
|
|
|
// log.info("新增{}条发票抬头", i);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void updateMemberInvoiceTitle(InvoiceTitleDTO dto) {
|
|
|
|
|
|
MemberInvoiceTitle title = new MemberInvoiceTitle();
|
|
|
|
|
|
BeanUtils.copyProperties(dto, title);
|
2023-05-24 09:06:10 +08:00
|
|
|
|
title.setId(Long.valueOf(dto.getTitleId()));
|
|
|
|
|
|
title.setName(dto.getTitleName());
|
2023-05-23 10:59:16 +08:00
|
|
|
|
if (StringUtils.isEmail(dto.getReception())) {
|
|
|
|
|
|
title.setEmail(dto.getReception());
|
|
|
|
|
|
} else {
|
|
|
|
|
|
title.setPhoneNumber(dto.getReception());
|
|
|
|
|
|
}
|
|
|
|
|
|
int i = memberInvoiceTitleService.updateMemberInvoiceTitle(title);
|
2023-04-13 15:31:04 +08:00
|
|
|
|
}
|
2023-05-16 16:24:26 +08:00
|
|
|
|
|
2023-05-24 09:06:10 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 删除会员发票抬头
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
*/
|
|
|
|
|
|
public void deleteMemberInvoiceTitle(InvoiceTitleDTO dto) {
|
|
|
|
|
|
memberInvoiceTitleService.deleteMemberInvoiceTitleById(Long.valueOf(dto.getTitleId()));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-16 16:24:26 +08:00
|
|
|
|
public Map<String, Object> rechargeBalance(WeixinPayDTO dto) throws Exception {
|
|
|
|
|
|
PaymentScenarioDTO paymentScenarioDTO = new PaymentScenarioDTO();
|
|
|
|
|
|
paymentScenarioDTO.setType(ScenarioEnum.BALANCE.getValue());
|
|
|
|
|
|
paymentScenarioDTO.setMemberId(dto.getMemberId());
|
2024-03-19 16:22:40 +08:00
|
|
|
|
dto.setAttach(JSON.toJSONString(paymentScenarioDTO));
|
2023-05-16 16:24:26 +08:00
|
|
|
|
dto.setDescription("会员充值余额");
|
|
|
|
|
|
return orderService.weixinPayV3(dto);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-05-27 09:36:07 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 使用汇付支付充值余额
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2023-08-15 15:43:18 +08:00
|
|
|
|
public Map<String, Object> rechargeBalanceWithAdapay(WeixinPayDTO dto) {
|
2023-08-15 17:04:56 +08:00
|
|
|
|
// 获取支付配置
|
2023-08-17 11:55:14 +08:00
|
|
|
|
AbstractAdapayConfig config = AdapayConfigFactory.getConfig(dto.getWechatAppId());
|
2023-08-15 15:42:39 +08:00
|
|
|
|
if (config == null) {
|
|
|
|
|
|
throw new BusinessException(ReturnCodeEnum.CODE_ADAPAY_CONFIG_IS_NULL_ERROR);
|
|
|
|
|
|
}
|
|
|
|
|
|
log.info("使用汇付支付充值余额 支付配置参数:{}", JSON.toJSONString(config));
|
|
|
|
|
|
|
2023-08-25 16:07:15 +08:00
|
|
|
|
// 查询延时支付模式,由一级运营商配置决定
|
2023-09-01 11:36:31 +08:00
|
|
|
|
String delayMode = pileMerchantInfoService.getDelayModeByWechatAppId(dto.getWechatAppId());
|
|
|
|
|
|
String payMode = MerchantDelayModeEnum.getAdapayPayMode(delayMode);
|
2023-05-16 16:24:26 +08:00
|
|
|
|
// 封装对象
|
2023-08-25 16:07:15 +08:00
|
|
|
|
// String payMode = Constants.ADAPAY_PAY_MODE_DELAY; // 汇付延时分账
|
2023-05-16 16:24:26 +08:00
|
|
|
|
CreateAdaPaymentParam createAdaPaymentParam = new CreateAdaPaymentParam();
|
2023-05-27 16:01:27 +08:00
|
|
|
|
createAdaPaymentParam.setOrder_no(SnowflakeIdWorker.getSnowflakeId());
|
2023-05-16 16:24:26 +08:00
|
|
|
|
createAdaPaymentParam.setPay_amt(AdapayUtil.formatAmount(dto.getAmount()));
|
2023-08-15 15:42:39 +08:00
|
|
|
|
// createAdaPaymentParam.setApp_id(ADAPAY_APP_ID); // 移动到配置文件中
|
|
|
|
|
|
createAdaPaymentParam.setApp_id(config.getAdapayAppId()); // 移动到配置文件中
|
2023-05-16 16:24:26 +08:00
|
|
|
|
createAdaPaymentParam.setPay_channel("wx_lite"); // todo 如果以后有支付宝等别的渠道,这里需要做修改,判断是什么渠道的请求
|
2023-07-27 15:10:11 +08:00
|
|
|
|
createAdaPaymentParam.setGoods_title("充值余额");
|
2023-05-27 09:36:07 +08:00
|
|
|
|
createAdaPaymentParam.setGoods_desc("会员充值余额");
|
2024-03-19 16:22:40 +08:00
|
|
|
|
createAdaPaymentParam.setExpend(JSON.toJSONString( ImmutableMap.of("open_id", dto.getOpenId())));
|
2023-05-17 15:59:16 +08:00
|
|
|
|
//异步通知地址,url为http/https路径,服务器POST回调,URL 上请勿附带参数
|
2023-05-27 14:27:36 +08:00
|
|
|
|
createAdaPaymentParam.setNotify_url(ADAPAY_CALLBACK_URL);
|
2023-05-27 09:36:07 +08:00
|
|
|
|
Map<String, String> map = Maps.newHashMap();
|
|
|
|
|
|
map.put("type", ScenarioEnum.BALANCE.getValue());
|
2023-08-17 11:29:44 +08:00
|
|
|
|
map.put("payMode", payMode);
|
2023-05-27 09:36:07 +08:00
|
|
|
|
map.put("memberId", dto.getMemberId());
|
|
|
|
|
|
createAdaPaymentParam.setDescription(JSON.toJSONString(map));
|
2023-08-17 11:29:44 +08:00
|
|
|
|
// 延时分账
|
2023-08-25 16:07:15 +08:00
|
|
|
|
if (StringUtils.isNotBlank(payMode)) {
|
|
|
|
|
|
createAdaPaymentParam.setPay_mode(payMode);
|
|
|
|
|
|
}
|
2023-05-16 16:24:26 +08:00
|
|
|
|
try {
|
2024-03-19 16:22:40 +08:00
|
|
|
|
log.info("创建汇付支付参数:{}", JSON.toJSONString(createAdaPaymentParam));
|
2023-08-15 17:04:56 +08:00
|
|
|
|
Map<String, Object> response = Payment.create(BeanMap.create(createAdaPaymentParam), config.getWechatAppId());
|
2024-03-19 16:22:40 +08:00
|
|
|
|
log.info("创建汇付支付参数反参:{}", JSON.toJSONString(response));
|
2023-05-16 16:24:26 +08:00
|
|
|
|
if (response != null && !response.isEmpty()) {
|
|
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(response.get("expend").toString());
|
|
|
|
|
|
JSONObject pay_info = jsonObject.getJSONObject("pay_info");
|
2023-07-27 15:55:02 +08:00
|
|
|
|
return JSONObject.parseObject(pay_info.toJSONString(), new TypeReference<Map<String, Object>>() {});
|
2023-05-16 16:24:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
} catch (BaseAdaPayException e) {
|
|
|
|
|
|
log.error("汇付-获取支付对象发生异常", e);
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
2023-05-23 10:59:16 +08:00
|
|
|
|
|
2023-06-20 16:13:25 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 充值订单金额
|
|
|
|
|
|
* @param dto
|
|
|
|
|
|
* @throws ParseException
|
|
|
|
|
|
*/
|
2024-01-22 12:32:22 +08:00
|
|
|
|
// public void rechargeOrderAmount(RechargeOrderAmountDTO dto) throws ParseException {
|
|
|
|
|
|
// // 根据memberId查询出当前用户正在充电的 vin启动订单 或 卡启动订单
|
|
|
|
|
|
// UniAppQueryOrderDTO orderDTO = new UniAppQueryOrderDTO();
|
|
|
|
|
|
// orderDTO.setOrderStatus("4"); // 4-正在充电中
|
|
|
|
|
|
// PageResponse pageResponse = orderService.getListByMemberIdAndOrderStatus(dto.getMemberId(), orderDTO);
|
|
|
|
|
|
// if (pageResponse == null) {
|
|
|
|
|
|
// return;
|
|
|
|
|
|
// }
|
|
|
|
|
|
// List<OrderVO> list = (List<OrderVO>) pageResponse.getList();
|
|
|
|
|
|
// List<OrderVO> chargingList = list.stream()
|
|
|
|
|
|
// .filter(orderVO -> orderVO.getOrderStatus().equals(OrderStatusEnum.IN_THE_CHARGING.getValue()))
|
|
|
|
|
|
// .collect(Collectors.toList());
|
|
|
|
|
|
// for (OrderVO orderVO : chargingList) {
|
|
|
|
|
|
// if (StringUtils.equals(orderVO.getStartMode(), StartModeEnum.AUTH_CARD.getValue())
|
|
|
|
|
|
// || StringUtils.equals(orderVO.getStartMode(), StartModeEnum.OFFLINE_CARD.getValue())
|
|
|
|
|
|
// || StringUtils.equals(orderVO.getStartMode(), StartModeEnum.VIN_CODE.getValue())) {
|
|
|
|
|
|
// // 将充值后的余额计算出来
|
|
|
|
|
|
// BigDecimal rechargeAmount = new BigDecimal(dto.getRechargeAmount());
|
|
|
|
|
|
// BigDecimal payAmount = orderVO.getPayAmount().add(rechargeAmount);
|
|
|
|
|
|
// orderVO.setPayAmount(payAmount);
|
|
|
|
|
|
// // 发送0x41指令更新账户余额
|
|
|
|
|
|
// RemoteAccountBalanceUpdateDTO remoteDTO = new RemoteAccountBalanceUpdateDTO();
|
|
|
|
|
|
// remoteDTO.setPileSn(orderVO.getPileSn());
|
|
|
|
|
|
// remoteDTO.setConnectorCode(orderVO.getConnectorCode());
|
|
|
|
|
|
// remoteDTO.setAccountBalance(String.valueOf(orderVO.getPayAmount()));
|
|
|
|
|
|
//
|
|
|
|
|
|
// pileRemoteService.remoteAccountBalanceUpdate(remoteDTO);
|
|
|
|
|
|
//
|
|
|
|
|
|
// // 将支付金额修改数据库
|
|
|
|
|
|
// OrderBasicInfo basicInfo = new OrderBasicInfo();
|
|
|
|
|
|
// basicInfo.setId(Integer.parseInt(orderVO.getId()));
|
|
|
|
|
|
// basicInfo.setPayAmount(payAmount);
|
|
|
|
|
|
//
|
|
|
|
|
|
// orderBasicInfoService.updateOrderBasicInfo(basicInfo);
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
|
|
|
|
|
// }
|
2023-11-21 15:10:54 +08:00
|
|
|
|
|
|
|
|
|
|
public List<MemberWalletVO> queryMemberWalletList(String memberId) {
|
|
|
|
|
|
return memberWalletInfoService.selectByMemberWalletList(memberId);
|
|
|
|
|
|
}
|
2023-03-04 16:29:55 +08:00
|
|
|
|
}
|