v1.1 梳理充值策略
This commit is contained in:
@@ -796,7 +796,7 @@ public enum BusiStatus {
|
||||
*/
|
||||
private Object[] formatArgs;
|
||||
|
||||
private BusiStatus(int value, String reasonPhrase) {
|
||||
BusiStatus(int value, String reasonPhrase) {
|
||||
this.value = value;
|
||||
this.reasonPhrase = reasonPhrase;
|
||||
}
|
||||
|
@@ -215,26 +215,22 @@ public class IOSPayPlaService extends BaseService {
|
||||
* @param params
|
||||
* @return
|
||||
*/
|
||||
public BusiResult<RecordIdVo> openVip(VipOpenParams params, UserVipRecord userVipRecord) {
|
||||
BusiResult<RecordIdVo> busiResult = new BusiResult<>(BusiStatus.SUCCESS);
|
||||
ChargeRecord chargeRecord = payCenterService.buildOpenVipChargeRecord(params.getUid(), params.getChargeProd(), params.getPayChannel(),
|
||||
params.getIp(), params.getDeviceInfo(), params.getOpenId());
|
||||
try {
|
||||
//写入数据库
|
||||
chargeRecordService.insertChargeRecord(chargeRecord);
|
||||
userVipRecord.setChargeRecordId(chargeRecord.getChargeRecordId());
|
||||
userVipRecordService.save(userVipRecord);
|
||||
//订单创建成功返回订单号
|
||||
busiResult.setMessage("success");
|
||||
RecordIdVo recordIdVo = new RecordIdVo();
|
||||
recordIdVo.setRecordId(chargeRecord.getChargeRecordId());
|
||||
busiResult.setData(recordIdVo);
|
||||
} catch (Exception e) {
|
||||
logger.error("applyCharge Exception:" + e.getMessage() + " uid=" + params.getUid() + ",chargeProdId=" + chargeRecord.getChargeRecordId(), e);
|
||||
busiResult.setBusiResult(BusiStatus.BUSIERROR);
|
||||
busiResult.setMessage("BusiError");
|
||||
}
|
||||
return busiResult;
|
||||
public RecordIdVo openVip(VipOpenParams params, UserVipRecord userVipRecord) {
|
||||
ChargeRecord chargeRecord = payCenterService.buildOpenVipChargeRecord(params.getUid(), params.getChargeProd(), params.getPayChannel(),
|
||||
params.getIp(), params.getDeviceInfo(), params.getOpenId());
|
||||
try {
|
||||
//写入数据库
|
||||
chargeRecordService.insertChargeRecord(chargeRecord);
|
||||
userVipRecord.setChargeRecordId(chargeRecord.getChargeRecordId());
|
||||
userVipRecordService.save(userVipRecord);
|
||||
//订单创建成功返回订单号
|
||||
RecordIdVo recordIdVo = new RecordIdVo();
|
||||
recordIdVo.setRecordId(chargeRecord.getChargeRecordId());
|
||||
return recordIdVo;
|
||||
} catch (Exception e) {
|
||||
logger.error("applyCharge Exception:" + e.getMessage() + " uid=" + params.getUid() + ",chargeProdId=" + chargeRecord.getChargeRecordId(), e);
|
||||
throw new ServiceException(BusiStatus.SERVER_BUSY);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -99,9 +99,8 @@ public class PayCenterService {
|
||||
* @param countryCode
|
||||
* @return BusiResult
|
||||
*/
|
||||
public BusiResult createOrder(Long uid, String chargeProdId, String channel, String clientIp, String successUrl, ChargeProd chargeProd,
|
||||
public Object createOrder(Long uid, String chargeProdId, String channel, String clientIp, String successUrl, ChargeProd chargeProd,
|
||||
Long erbanNo, String nick, String openId, String realName, String idCardNum, DeviceInfo deviceInfo, String paymentType, String countryCode) throws Exception {
|
||||
BusiResult<Object> BusiResult = new BusiResult<>(BusiStatus.SUCCESS);
|
||||
String recordChannel = getChannelUseInRecord(channel);
|
||||
ChargeRecord chargeRecord =
|
||||
buildChargeRecord(uid, chargeProdId, recordChannel, clientIp, chargeProd, openId, deviceInfo, paymentType, countryCode);
|
||||
@@ -114,20 +113,10 @@ public class PayCenterService {
|
||||
throw new ServiceException(BusiStatus.UNKNOWN_PAYCHANNEL);
|
||||
}
|
||||
Object ret = strategy.pay(payContext);
|
||||
log.info(
|
||||
"Completed charge uid:{} channelProdId:{} channel:{}, ret:{}",
|
||||
uid,
|
||||
chargeProdId,
|
||||
channel,
|
||||
JSON.toJSONString(ret));
|
||||
BusiResult.setData(ret);
|
||||
log.info("Completed charge uid:{} channelProdId:{} channel:{}, ret:{}", uid, chargeProdId, channel, JSON.toJSONString(ret));
|
||||
chargeRecordService.insertChargeRecord(chargeRecord);
|
||||
try {
|
||||
saveOrderToCache(chargeRecord);
|
||||
} catch (Exception e) {
|
||||
log.error("缓存增加订单数出现异常", e);
|
||||
}
|
||||
return BusiResult;
|
||||
saveOrderToCache(chargeRecord);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void saveOrderToCache(ChargeRecord chargeRecord) {
|
||||
@@ -405,9 +394,8 @@ public class PayCenterService {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public BusiResult createOpenVipOrder(Long uid, ChargeProd chargeProd, String channel, String clientIp, UserVipRecord userVipRecord,
|
||||
public Object createOpenVipOrder(Long uid, ChargeProd chargeProd, String channel, String clientIp, UserVipRecord userVipRecord,
|
||||
String realName, String idCardNum, DeviceInfo deviceInfo, String openId) {
|
||||
BusiResult<Object> BaseResponseVO = new BusiResult<>(BusinessStatusCodeEnum.SUCCESS);
|
||||
ChargeRecord chargeRecord = buildOpenVipChargeRecord(uid, chargeProd, channel, clientIp, deviceInfo, openId);
|
||||
if (isTarotLowChargeAmountOpen()) {
|
||||
chargeRecord.setAmount(chargeRecord.getAmount() / 100);
|
||||
@@ -429,8 +417,7 @@ public class PayCenterService {
|
||||
chargeRecordService.insertChargeRecord(chargeRecord);
|
||||
userVipRecord.setChargeRecordId(chargeRecord.getChargeRecordId());
|
||||
userVipRecordService.save(userVipRecord);
|
||||
BaseResponseVO.setData(ret);
|
||||
return BaseResponseVO;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1,23 +1,79 @@
|
||||
package com.accompany.payment.strategy;
|
||||
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.payment.annotation.PayChannelSupport;
|
||||
|
||||
import com.accompany.payment.dto.AppInnerPayRecordDTO;
|
||||
import com.accompany.payment.google.dto.GooglePayLimitConfigDTO;
|
||||
import com.accompany.payment.model.ChargeProd;
|
||||
import com.accompany.payment.model.ChargeRecord;
|
||||
|
||||
import com.accompany.payment.service.ChargeRecordService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@PayChannelSupport(Constant.ChargeChannel.google_play_billing)
|
||||
public class GooglePlayStrategy extends AbstractPayStrategy {
|
||||
|
||||
@Autowired
|
||||
private ChargeRecordService chargeRecordService;
|
||||
@Autowired
|
||||
private SysConfService sysConfService;
|
||||
|
||||
@Override
|
||||
public Object pay(PayContext context) throws Exception {
|
||||
ChargeProd chargeProd = context.getChargeProd();
|
||||
ChargeRecord chargeRecord = context.getChargeRecord();
|
||||
validMoneyLimit(chargeRecord.getUid(), chargeProd);
|
||||
AppInnerPayRecordDTO recordIdVo = new AppInnerPayRecordDTO();
|
||||
recordIdVo.setRecordId(chargeRecord.getChargeRecordId());
|
||||
return recordIdVo;
|
||||
}
|
||||
|
||||
public void validMoneyLimit(Long uid, ChargeProd chargeProd) {
|
||||
GooglePayLimitConfigDTO config = getLimitConfig();
|
||||
Date now = new Date();
|
||||
Date beginTimeOfDay = DateTimeUtil.getBeginTimeOfDay(now);
|
||||
Date endTimeOfDay = DateTimeUtil.getEndTimeOfDay(now);
|
||||
|
||||
Long userChargeAmmount = chargeRecordService.getChargeUserAmountWithProdIds(Collections.singletonList(uid), config.getGoogleChargeProdIds(), beginTimeOfDay, endTimeOfDay);
|
||||
log.info("{}在{}-{}时间段内使用google内购充值了{}", uid, DateTimeUtil.convertDate(beginTimeOfDay), DateTimeUtil.convertDate(endTimeOfDay), userChargeAmmount);
|
||||
// 配置的单位是元,充值记录和产品的数据单位为分
|
||||
if (config.getLimitEveryOneDaySumAmount() * 100 < (chargeProd.getMoney() + userChargeAmmount)) {
|
||||
throw new ServiceException(config.getErrorTip());
|
||||
}
|
||||
Long allUserChargeAmount = chargeRecordService.getChargeUserAmountWithProdIds(null, config.getGoogleChargeProdIds(), beginTimeOfDay, endTimeOfDay);
|
||||
log.info("全部用户{}-{}内使用google内购充值了{}", DateTimeUtil.convertDate(beginTimeOfDay), DateTimeUtil.convertDate(endTimeOfDay), allUserChargeAmount);
|
||||
if (config.getLimitEveryDayAmount() * 100 < (chargeProd.getMoney() + allUserChargeAmount)) {
|
||||
throw new ServiceException(config.getErrorTip());
|
||||
}
|
||||
}
|
||||
|
||||
private GooglePayLimitConfigDTO getLimitConfig() {
|
||||
GooglePayLimitConfigDTO limitConfig = JSONObject.parseObject(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.GOOGLE_PAY_LIMIT_CONFIG, "{}"), GooglePayLimitConfigDTO.class);
|
||||
if (limitConfig.getLimitEveryDayAmount() == null) {
|
||||
limitConfig.setLimitEveryDayAmount(9999999L);
|
||||
}
|
||||
if (limitConfig.getLimitEveryOneDaySumAmount() == null) {
|
||||
limitConfig.setLimitEveryOneDaySumAmount(9999999L);
|
||||
}
|
||||
if (limitConfig.getGoogleChargeProdIds() == null) {
|
||||
limitConfig.setGoogleChargeProdIds(Collections.emptyList());
|
||||
}
|
||||
if (StringUtils.isEmpty(limitConfig.getErrorTip())) {
|
||||
limitConfig.setErrorTip("充值失败,请联系客服处理");
|
||||
}
|
||||
return limitConfig;
|
||||
}
|
||||
}
|
||||
|
@@ -5,6 +5,7 @@ import com.accompany.business.event.ChargeSuccessEvent;
|
||||
import com.accompany.business.message.PayFinishMessage;
|
||||
import com.accompany.business.model.BankCardSign;
|
||||
import com.accompany.business.model.payment.PaymentDTO;
|
||||
import com.accompany.core.service.base.BaseService;
|
||||
import com.accompany.payment.vo.VipOpenParams;
|
||||
import com.accompany.business.service.charge.LuckyTarotChargeService;
|
||||
import com.accompany.business.service.charge.VipChargeService;
|
||||
@@ -30,10 +31,8 @@ import com.accompany.core.enumeration.BillObjTypeEnum;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.service.base.BaseService;
|
||||
import com.accompany.core.service.user.UsersBaseService;
|
||||
import com.accompany.core.util.StringUtils;
|
||||
import com.accompany.core.vo.UserVo;
|
||||
import com.accompany.payment.mapper.ChargeRecordMapper;
|
||||
import com.accompany.payment.model.*;
|
||||
import com.accompany.payment.service.*;
|
||||
@@ -56,8 +55,6 @@ import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.accompany.common.constant.Constant.SysConfId.WX_PAY_INNER_TYPE;
|
||||
|
||||
/**
|
||||
* Created by liuguofu on 2017/6/27.
|
||||
*/
|
||||
@@ -111,7 +108,7 @@ public class ChargeService extends BaseService {
|
||||
private UserVipInfoService userVipInfoService;
|
||||
|
||||
/**
|
||||
* 接入支付宝/微信支付
|
||||
* 接入支付寶/微信支付
|
||||
*
|
||||
* @param clientIp
|
||||
* @param app
|
||||
@@ -120,23 +117,23 @@ public class ChargeService extends BaseService {
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public BusiResult applyCharge3(Long uid, String chargeProdId, String channel, String clientIp, String successUrl, String openId, String app, Long roomUid, Integer chargeMoney){
|
||||
public Object applyCharge3(Long uid, String chargeProdId, String channel, String clientIp, String successUrl, String openId, String app, Long roomUid, Integer chargeMoney){
|
||||
DeviceInfo deviceInfo = new DeviceInfo();
|
||||
deviceInfo.setApp(app);
|
||||
return applyChargeV4(uid, chargeProdId, channel, clientIp, successUrl, openId, deviceInfo, roomUid, chargeMoney, null, null);
|
||||
}
|
||||
|
||||
@CancelUidTag(paramName = {"uid"})
|
||||
public BusiResult applyChargeV4(Long uid, String chargeProdId, String channel, String clientIp,
|
||||
public Object applyChargeV4(Long uid, String chargeProdId, String channel, String clientIp,
|
||||
String successUrl, String openId, DeviceInfo deviceInfo, Long roomUid, Integer chargeMoney,
|
||||
String paymentType, String countryCode) {
|
||||
|
||||
ChargeProd chargeProd = chargeProdService.getChargeProdById(chargeProdId);
|
||||
if (chargeProd == null) {
|
||||
return new BusiResult(BusiStatus.BUSIERROR);
|
||||
throw new ServiceException(BusiStatus.CHARGE_PROD_NOT_EXIST);
|
||||
}
|
||||
|
||||
// 处理自定义充值金额的产品构建
|
||||
// 處理自定義充值金額的產品構建
|
||||
if (Constant.ChargeProdChannel.custom_charge.equals(chargeProd.getChannel())) {
|
||||
chargeProd.setMoney((long) chargeMoney);
|
||||
long goldNum = new BigDecimal(chargeMoney).multiply(new BigDecimal(chargeProd.getChangeGoldRate()))
|
||||
@@ -146,7 +143,7 @@ public class ChargeService extends BaseService {
|
||||
|
||||
if (vipChargeService.isVipCharge(chargeProd)) {
|
||||
/**
|
||||
* v4.1.0 : 贵族开通逻辑
|
||||
* v4.1.0 : 貴族開通邏輯
|
||||
*/
|
||||
VipOpenParams params = VipOpenParams.builder()
|
||||
.roomUid(roomUid).uid(uid).deviceInfo(deviceInfo).ip(clientIp)
|
||||
@@ -157,12 +154,11 @@ public class ChargeService extends BaseService {
|
||||
return vipChargeService.openVip(params);
|
||||
} else {
|
||||
/**
|
||||
* 充值逻辑
|
||||
* 充值邏輯
|
||||
*/
|
||||
return doChargeBuss(uid, chargeProdId, channel, clientIp, successUrl, openId,
|
||||
deviceInfo, chargeProd, paymentType, countryCode);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,98 +172,83 @@ public class ChargeService extends BaseService {
|
||||
* @param openId
|
||||
* @param deviceInfo
|
||||
* @param chargeProd
|
||||
* @param roomUid
|
||||
* @param paymentType
|
||||
* @param countryCode
|
||||
* @return
|
||||
*/
|
||||
private BusiResult doChargeBuss(Long uid, String chargeProdId, String channel, String clientIp, String successUrl, String openId,
|
||||
private Object doChargeBuss(Long uid, String chargeProdId, String channel, String clientIp, String successUrl, String openId,
|
||||
DeviceInfo deviceInfo, ChargeProd chargeProd, String paymentType, String countryCode) {
|
||||
String lockval = jedisLockService.lock(RedisKey.lock_apply_charge.getKey(uid.toString()), 3000);
|
||||
if (StringUtils.isEmpty(lockval)) {
|
||||
String lockKey = RedisKey.lock_apply_charge.getKey(uid.toString());
|
||||
String lockVal = jedisLockService.lock(lockKey, 3000);
|
||||
if (StringUtils.isEmpty(lockVal)) {
|
||||
throw new ServiceException(BusiStatus.SERVERBUSY);
|
||||
}
|
||||
try {
|
||||
//reids 可配置充值限额 开启家长模式的用户 充值限额判断
|
||||
//reids 可配置充值限額 開啟家長模式的用戶 充值限額判斷
|
||||
Users users = usersService.getUsersByUid(uid);
|
||||
BusiResult result = new BusiResult(BusiStatus.SUCCESS);
|
||||
if (users.getParentMode()) {
|
||||
// 校验青少年是否可充值
|
||||
// 校驗青少年是否可充值
|
||||
Boolean teenChargeSwitch = usersBaseService.getTeenChargeSwitch();
|
||||
if(teenChargeSwitch){
|
||||
// 校验青少年充值每日限额
|
||||
// 校驗青少年充值每日限額
|
||||
Integer limitMoney = usersBaseService.getUserTeenConfig().getLimitEveryDay();
|
||||
String chargeLimit = jedisService.hget(RedisKey.user_charge_limit.getKey(), uid.toString());
|
||||
if (StringUtils.isBlank(chargeLimit)) {
|
||||
chargeLimit = chargeProd.getMoney().toString();
|
||||
} else {
|
||||
chargeLimit = String.valueOf(Integer.valueOf(chargeLimit) + chargeProd.getMoney().intValue());
|
||||
chargeLimit = String.valueOf(Integer.parseInt(chargeLimit) + chargeProd.getMoney().intValue());
|
||||
}
|
||||
if (Integer.valueOf(chargeLimit) > limitMoney) {
|
||||
result.setCode(25000);
|
||||
result.setMessage("充值失败:超出当日充值限制");
|
||||
return result;
|
||||
if (Integer.parseInt(chargeLimit) > limitMoney) {
|
||||
throw new ServiceException(BusiStatus.CHARGE_LIMIT, "充值失敗:超出當日充值限制");
|
||||
}
|
||||
}else{
|
||||
result.setCode(25006);
|
||||
result.setMessage("当前处于青少年模式下,无法使用充值功能哦");
|
||||
return result;
|
||||
throw new ServiceException(BusiStatus.UNDER_AGE_WITHDRAWAL, "當前處於青少年模式下,無法使用充值功能哦");
|
||||
}
|
||||
} else{
|
||||
// 2020-02-25: 改为从2020.02.25 0点起,累计充值≥指定人民币金额,需先实名认证
|
||||
// 2020-02-25: 改為從2020.02.25 0點起,累計充值≥指定人民幣金額,需先實名認證
|
||||
Long historyRechargeAmount = chargeRecordService.historyRechargeAmount(users.getUid());
|
||||
// 进行实名认证充值校验
|
||||
// 進行實名認證充值校驗
|
||||
Integer resultCode = chargeCheckService.needCertification(users, chargeProd.getMoney(), historyRechargeAmount);
|
||||
if(resultCode != null && resultCode.equals(BusiStatus.CHARGE_LIMIT.value())){
|
||||
result.setCode(resultCode);
|
||||
result.setMessage("充值失败,已超出充值限制");
|
||||
return result;
|
||||
}else if(resultCode != null && resultCode.equals(BusiStatus.UNDER_AGE_WITHDRAWAL.value())){
|
||||
result.setCode(resultCode);
|
||||
result.setMessage("未成年用户 (<18岁),无法使用充值功能哦");
|
||||
return result;
|
||||
}else if(resultCode != null && resultCode.equals(BusiStatus.NEED_CERTIFICATION.value())){
|
||||
result.setCode(resultCode);
|
||||
result.setMessage(BusiStatus.NEED_CERTIFICATION.getReasonPhrase());
|
||||
return result;
|
||||
if (resultCode != null){
|
||||
if (resultCode.equals(BusiStatus.CHARGE_LIMIT.value())){
|
||||
throw new ServiceException(BusiStatus.CHARGE_LIMIT);
|
||||
} else if (resultCode.equals(BusiStatus.UNDER_AGE_WITHDRAWAL.value())){
|
||||
throw new ServiceException(BusiStatus.UNDER_AGE_WITHDRAWAL);
|
||||
} else if (resultCode.equals(BusiStatus.NEED_CERTIFICATION.value())){
|
||||
throw new ServiceException(BusiStatus.NEED_CERTIFICATION);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//统一下单
|
||||
//統一下單
|
||||
return payCenterService.createOrder(uid, chargeProdId, channel, clientIp, successUrl, chargeProd,
|
||||
users.getErbanNo(), users.getNick(), openId, users.getRealName(), users.getIdCardNum(), deviceInfo, paymentType, countryCode);
|
||||
} catch (ServiceException e) {
|
||||
log.error("applyCharge3() error,uid={},chargeProdId={},channel={},clientIp={},successUrl={},openId={}", uid,
|
||||
chargeProdId, channel, clientIp, successUrl, openId);
|
||||
log.error("applyCharge3() errorMsg:", e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
} catch (Exception e) {
|
||||
log.error("applyCharge3() error,uid={},chargeProdId={},channel={},clientIp={},successUrl={},openId={}", uid,
|
||||
chargeProdId, channel, clientIp, successUrl, openId);
|
||||
log.error("applyCharge3() error,uid={},chargeProdId={},channel={},clientIp={},successUrl={},openId={}", uid, chargeProdId, channel, clientIp, successUrl, openId);
|
||||
log.error("applyCharge3() errorMsg={}", e);
|
||||
return new BusiResult(BusiStatus.SERVERERROR);
|
||||
throw new ServiceException(BusiStatus.SERVERBUSY);
|
||||
} finally {
|
||||
jedisLockService.unlock(RedisKey.lock_apply_charge.getKey(uid.toString()), lockval);
|
||||
jedisLockService.unlock(RedisKey.lock_apply_charge.getKey(uid.toString()), lockVal);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回调处理用户钱包和账单记录
|
||||
* 回調處理用戶錢包和賬單記錄
|
||||
*
|
||||
* @param chargeRecord
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public int updateAppPayData(ChargeRecord chargeRecord){
|
||||
// 按业务类型进行后续的处理
|
||||
// 按業務類型進行後續的處理
|
||||
switch (chargeRecord.getBussType()) {
|
||||
case Constant.PayBussType.charge:
|
||||
// 充值金币
|
||||
// 充值金幣
|
||||
return handleAppPayGoldBuss(chargeRecord);
|
||||
case Constant.PayBussType.lucky_tarot:
|
||||
return doTarotChargeBusiness(chargeRecord);
|
||||
case Constant.PayBussType.OPEN_VIP:
|
||||
// 开通贵族
|
||||
// 開通貴族
|
||||
return doOpenVipBuss(chargeRecord);
|
||||
}
|
||||
log.error("updateChargeData exception,bussType not exist, orderNo =" + chargeRecord.getChargeRecordId() + ",trade_no=" + chargeRecord
|
||||
@@ -276,7 +257,7 @@ public class ChargeService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理开通贵族支付回调
|
||||
* 處理開通貴族支付回調
|
||||
* @param chargeRecord
|
||||
* @return
|
||||
*/
|
||||
@@ -284,32 +265,32 @@ public class ChargeService extends BaseService {
|
||||
public int doOpenVipBuss(ChargeRecord chargeRecord) {
|
||||
String chargeRecordId = chargeRecord.getChargeRecordId();
|
||||
if (null == chargeRecordId) {
|
||||
throw new BusinessException("支付订单号异常");
|
||||
throw new BusinessException("支付訂單號異常");
|
||||
}
|
||||
// 判断用户是否已经是会员
|
||||
// 判斷用戶是否已經是會員
|
||||
VipBaseInfoVO vipInfo = VipUtil.getUserBaseVipInfo(chargeRecord.getUid());
|
||||
if (null != vipInfo) {
|
||||
// 对于已经是贵族的用户,充值订单做特殊标识,不累加用户的贵族权益
|
||||
// 對於已經是貴族的用戶,充值訂單做特殊標識,不累加用戶的貴族權益
|
||||
chargeRecord.setChargeStatus(Constant.ChargeRecordStatus.finish_pay_not_do_buss);
|
||||
return BusiStatus.SUCCESS.value();
|
||||
}
|
||||
UserVipRecord userVipRecord = userVipRecordService.getByChargeRecordId(chargeRecordId);
|
||||
if (null == userVipRecord) {
|
||||
throw new BusinessException("支付订单号异常");
|
||||
throw new BusinessException("支付訂單號異常");
|
||||
}
|
||||
final Date expireTime = VipUtil.genVipExpireTime(new Date());
|
||||
updateUserRecord(chargeRecord, userVipRecord, expireTime);
|
||||
// 异步分发贵族权益
|
||||
// 異步分發貴族權益
|
||||
try {
|
||||
vipAuthItemBizService.distributeVipAuthItemAsync(chargeRecord.getUid(), 1, expireTime, true);
|
||||
} catch (Exception e) {
|
||||
log.error("开通异步分发贵族权益出现异常, uid : " + chargeRecord.getUid(), e);
|
||||
log.error("開通異步分發貴族權益出現異常, uid : " + chargeRecord.getUid(), e);
|
||||
}
|
||||
// 开通贵族消息
|
||||
// 開通貴族消息
|
||||
try {
|
||||
vipMessageService.sendOpenVipMessageAsync(chargeRecord.getUid(), userVipRecord.getRoomUid());
|
||||
} catch (Exception e) {
|
||||
log.error("开通贵族消息出现异常, uid : " + chargeRecord.getUid(), e);
|
||||
log.error("開通貴族消息出現異常, uid : " + chargeRecord.getUid(), e);
|
||||
}
|
||||
return BusiStatus.SUCCESS.value();
|
||||
}
|
||||
@@ -325,24 +306,24 @@ public class ChargeService extends BaseService {
|
||||
Long amount = chargeRecord.getAmount();
|
||||
String orderNo = chargeRecord.getChargeRecordId();
|
||||
if (realAmount != amount) {
|
||||
// 充值金额与实际价格不一致 (amount以分为单位)
|
||||
log.error("非法开通贵族. orderNo=[{}], amountLong=[{}], money=[{}]", orderNo, amount, money);
|
||||
throw new IllegalArgumentException(String.format("非法开通贵族. orderNo=[%s]", orderNo));
|
||||
// 充值金額與實際價格不一致 (amount以分為單位)
|
||||
log.error("非法開通貴族. orderNo=[{}], amountLong=[{}], money=[{}]", orderNo, amount, money);
|
||||
throw new IllegalArgumentException(String.format("非法開通貴族. orderNo=[%s]", orderNo));
|
||||
}
|
||||
chargeRecord.setChargeStatus(Constant.ChargeRecordStatus.finish);
|
||||
int result = completedOrder(chargeRecord);
|
||||
if (result <= 0) {
|
||||
log.info("重复请求:chargeRecordId: " + chargeRecord.getChargeRecordId());
|
||||
log.info("重複請求:chargeRecordId: " + chargeRecord.getChargeRecordId());
|
||||
throw new ApiException(BusiStatus.DUPLICATE_TRANSFER_REQUEST);
|
||||
}
|
||||
// 更新用户vip记录
|
||||
// 更新用戶vip記錄
|
||||
userVipRecord.setType(Constant.UserVipRecordType.OPEN);
|
||||
userVipRecord.setExpectExpireTime(expireTime);
|
||||
userVipRecordService.updateById(userVipRecord);
|
||||
// 新增用户贵族信息记录
|
||||
// 新增用戶貴族信息記錄
|
||||
UserVipInfo userVipInfo = buildUserVipInfo(chargeRecord.getUid(), expireTime);
|
||||
userVipInfoService.save(userVipInfo);
|
||||
// 更新账单表
|
||||
// 更新賬單表
|
||||
billRecordService.insertGeneralBillRecord(
|
||||
chargeRecord.getUid(),
|
||||
chargeRecord.getUid(),
|
||||
@@ -352,7 +333,7 @@ public class ChargeService extends BaseService {
|
||||
money.doubleValue(),
|
||||
BillObjTypeEnum.OPEN_VIP.getDesc()
|
||||
);
|
||||
// 初始化用户贵族等级与权力值
|
||||
// 初始化用戶貴族等級與權力值
|
||||
initUserVipInfo(userVipRecord);
|
||||
}
|
||||
|
||||
@@ -382,7 +363,7 @@ public class ChargeService extends BaseService {
|
||||
try {
|
||||
aliyunSmsService.sendSms(bankCardSign.getBankMobile(), paymentDTO.getFastpayNotifySmsId(), param);
|
||||
} catch (Exception e) {
|
||||
log.error("快捷支付短信通知发送失败!uid:{},手机号:{},订单号:{},异常信息:{}",
|
||||
log.error("快捷支付短信通知發送失敗!uid:{},手機號:{},訂單號:{},異常信息:{}",
|
||||
chargeRecord.getUid(), bankCardSign.getBankMobile(), chargeRecord.getChargeRecordId(),
|
||||
ExceptionUtils.getStackTrace(e));
|
||||
}
|
||||
@@ -391,7 +372,7 @@ public class ChargeService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 用户充值金币钱包和账单数据处理
|
||||
* 用戶充值金幣錢包和賬單數據處理
|
||||
*
|
||||
* @param chargeRecord
|
||||
* @return
|
||||
@@ -415,9 +396,9 @@ public class ChargeService extends BaseService {
|
||||
if (!payCenterService.isTarotLowChargeAmountOpen()) {
|
||||
checkMoney = money * 100;
|
||||
}
|
||||
// 充值金额与实际价格不一致
|
||||
// 充值金額與實際價格不一致
|
||||
if (!amountLong.equals(checkMoney)) {
|
||||
log.info("updateChargeData orderNo=" + chargeRecord.getChargeRecordId() + "&amountLong=" + amountLong + "&checkMoney=" + checkMoney + "数据异常");
|
||||
log.info("updateChargeData orderNo=" + chargeRecord.getChargeRecordId() + "&amountLong=" + amountLong + "&checkMoney=" + checkMoney + "數據異常");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -440,19 +421,19 @@ public class ChargeService extends BaseService {
|
||||
userPurseService.sendSysMsgByModifyGold(userPurseService.queryUserPurse(chargeRecord.getUid()));
|
||||
log.info("charge success, uid:{}, charge record={}", chargeRecord.getUid(), chargeRecord);
|
||||
}
|
||||
//objId保存支付宝/微信订单号
|
||||
//objId保存支付寶/微信訂單號
|
||||
billRecordService
|
||||
.insertGeneralBillRecord(chargeRecord.getUid(), chargeRecord.getUid(), chargeRecord.getChargeRecordId(), BillObjTypeEnum.CHARGE, realGoldNum.doubleValue(),
|
||||
money.doubleValue());
|
||||
// 将支付完成的消息发送到mq中,继续处理后续操作
|
||||
// 將支付完成的消息發送到mq中,繼續處理後續操作
|
||||
sendToMQ(chargeRecord);
|
||||
// 发布充值成功事件
|
||||
// 發布充值成功事件
|
||||
this.applicationContext.publishEvent(new ChargeSuccessEvent(chargeRecord));
|
||||
return 200;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新订单状态,乐观锁方式实现
|
||||
* 更新訂單狀態,樂觀鎖方式實現
|
||||
*
|
||||
* @param record
|
||||
* @return
|
||||
@@ -467,7 +448,7 @@ public class ChargeService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将支付完成的消息发送到mq中
|
||||
* 將支付完成的消息發送到mq中
|
||||
*
|
||||
* @param chargeRecord
|
||||
*/
|
||||
@@ -482,7 +463,7 @@ public class ChargeService extends BaseService {
|
||||
|
||||
|
||||
/**
|
||||
* 用户开启家长模式充值限制--记录充值金额, 达到限制后, 不允许充值, 关闭家长模式后, 清除记录
|
||||
* 用戶開啟家長模式充值限制--記錄充值金額, 達到限制后, 不允許充值, 關閉家長模式后, 清除記錄
|
||||
*
|
||||
* @param uid
|
||||
*/
|
||||
@@ -494,13 +475,13 @@ public class ChargeService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 微信内部支付方式
|
||||
* 微信內部支付方式
|
||||
*
|
||||
* @return WeXinPayTypeEnum
|
||||
*/
|
||||
public String wxpayType(DeviceInfo deviceInfo) {
|
||||
// 没有配置或者配置信息不在候选列表则走 app 支付
|
||||
return Optional.ofNullable(sysConfService.getSysConfValueById(WX_PAY_INNER_TYPE))
|
||||
// 沒有配置或者配置信息不在候選列表則走 app 支付
|
||||
return Optional.ofNullable(sysConfService.getSysConfValueById(Constant.SysConfId.WX_PAY_INNER_TYPE))
|
||||
.map(x -> Arrays.stream(WeXinPayTypeEnum.values())
|
||||
.filter(y -> y.name().equals(x.toUpperCase()))
|
||||
.findAny().orElse(WeXinPayTypeEnum.APP)).get().name();
|
||||
@@ -512,26 +493,26 @@ public class ChargeService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 充值业务回调处理
|
||||
* 充值業務回調處理
|
||||
*
|
||||
* @param orderNo 订单号
|
||||
* @param otherNo 第三方订单号
|
||||
* @param orderNo 訂單號
|
||||
* @param otherNo 第三方訂單號
|
||||
*/
|
||||
@Async
|
||||
public void payCallbackDo(String orderNo, String otherNo) {
|
||||
String lockResult = null;
|
||||
try {
|
||||
// 加锁逻辑
|
||||
// 加鎖邏輯
|
||||
int waitSecondTime = 10;
|
||||
lockResult =
|
||||
jedisLockService.lock(RedisKey.lock_pay_callback_notify.getKey(orderNo), waitSecondTime * 1000);
|
||||
if (org.apache.commons.lang3.StringUtils.isEmpty(lockResult)) {
|
||||
log.warn("订单 {} 处理中,请稍候", orderNo);
|
||||
log.warn("訂單 {} 處理中,請稍候", orderNo);
|
||||
return;
|
||||
}
|
||||
ChargeRecord chargeRecord = chargeRecordService.getChargeRecordById(orderNo);
|
||||
if (chargeRecord.getChargeStatus().equals(Constant.ChargeRecordStatus.finish)) {
|
||||
log.warn("{} 订单已经处理完成", otherNo);
|
||||
log.warn("{} 訂單已經處理完成", otherNo);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -540,8 +521,8 @@ public class ChargeService extends BaseService {
|
||||
chargeRecordService.updateChargeRecord(chargeRecord);
|
||||
updateAppPayData(chargeRecord);
|
||||
} catch (Exception e) {
|
||||
log.error("回调处理用户钱包和账单记录异常", e);
|
||||
throw new BusinessException("回调处理用户钱包和账单记录异常", e);
|
||||
log.error("回調處理用戶錢包和賬單記錄異常", e);
|
||||
throw new BusinessException("回調處理用戶錢包和賬單記錄異常", e);
|
||||
} finally {
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(lockResult)) {
|
||||
jedisLockService.unlock(RedisKey.lock_pay_callback_notify.getKey(orderNo), lockResult);
|
||||
@@ -550,7 +531,7 @@ public class ChargeService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 幸运塔罗充值业务处理
|
||||
* 幸運塔羅充值業務處理
|
||||
*
|
||||
* @param chargeRecord
|
||||
* @return
|
||||
@@ -560,32 +541,32 @@ public class ChargeService extends BaseService {
|
||||
String chargeRecordId = chargeRecord.getChargeRecordId();
|
||||
String tradeNo = chargeRecord.getPingxxChargeId();
|
||||
if (chargeRecordId == null || tradeNo == null) {
|
||||
throw new BusinessException("支付订单号或商户订单号异常");
|
||||
throw new BusinessException("支付訂單號或商戶訂單號異常");
|
||||
}
|
||||
Long chargeUid = chargeRecord.getUid();
|
||||
int outTradeNum = getLastNumFromOrder(chargeRecordId);
|
||||
int tradeNum = getLastNumFromOrder(tradeNo);
|
||||
// 两个订单号最后一位数字相加的结果除以10取余既是中奖号码
|
||||
// 兩個訂單號最後一位数字相加的結果除以10取余既是中獎號碼
|
||||
int luckyNum = (outTradeNum + tradeNum) % 10;
|
||||
LuckyTarotRecord luckyTarotRecord =
|
||||
luckyTarotRecordService.getLuckyTarotRecordByOutTradeNo(chargeUid, chargeRecordId);
|
||||
String cardNo = luckyTarotRecord.getSelectdNo();
|
||||
List<String> cardList = gson.fromJson(cardNo, new TypeToken<List<String>>() {
|
||||
}.getType());
|
||||
// 选的牌有一张是中奖数字就算中奖
|
||||
// 選的牌有一張是中獎数字就算中獎
|
||||
boolean isDraw = cardList.contains(String.valueOf(luckyNum));
|
||||
// 更新钱包和充值记录
|
||||
// 更新錢包和充值記錄
|
||||
this.updateUserPurseAndRecord(chargeRecord, luckyTarotRecord, luckyNum, isDraw, chargeUid);
|
||||
// 统计今日塔罗充值金额
|
||||
// 統計今日塔羅充值金額
|
||||
luckyTarotChargeService.countUserTarotChargeAmount(
|
||||
chargeUid, luckyTarotRecord.getChargeMoney(), chargeRecord.getCreateTime());
|
||||
// 发布充值成功事件
|
||||
// 發布充值成功事件
|
||||
this.applicationContext.publishEvent(new ChargeSuccessEvent(chargeRecord));
|
||||
return 200;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从支付订单号或商户订单号中获取最后一位数字
|
||||
* 從支付訂單號或商戶訂單號中獲取最後一位数字
|
||||
*
|
||||
* @param orderId
|
||||
* @return
|
||||
@@ -605,7 +586,7 @@ public class ChargeService extends BaseService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据是否中奖处理业务
|
||||
* 根據是否中獎處理業務
|
||||
*
|
||||
* @param chargeRecord
|
||||
* @param luckyTarotRecord
|
||||
@@ -619,7 +600,7 @@ public class ChargeService extends BaseService {
|
||||
boolean isDraw,
|
||||
Long chargeUid) {
|
||||
log.info(
|
||||
"幸运塔罗充值业务处理,chargeRecordId={},luckyNum={},isDraw={}",
|
||||
"幸運塔羅充值業務處理,chargeRecordId={},luckyNum={},isDraw={}",
|
||||
chargeRecord.getChargeRecordId(),
|
||||
drawNum,
|
||||
isDraw);
|
||||
@@ -633,14 +614,14 @@ public class ChargeService extends BaseService {
|
||||
Long amount = chargeRecord.getAmount();
|
||||
String orderNo = chargeRecord.getChargeRecordId();
|
||||
if (realAmount != amount) {
|
||||
// 充值金额与实际价格不一致 (amount以分为单位)
|
||||
log.error("非法塔罗充值. orderNo=[{}], amountLong=[{}], money=[{}]", orderNo, amount, money);
|
||||
throw new IllegalArgumentException(String.format("非法塔罗充值. orderNo=[%s]", orderNo));
|
||||
// 充值金額與實際價格不一致 (amount以分為單位)
|
||||
log.error("非法塔羅充值. orderNo=[{}], amountLong=[{}], money=[{}]", orderNo, amount, money);
|
||||
throw new IllegalArgumentException(String.format("非法塔羅充值. orderNo=[%s]", orderNo));
|
||||
}
|
||||
Long chargeGoldNum = 0L;
|
||||
Byte drawStatus = Constant.LuckyTarotStatus.fail;
|
||||
if (isDraw) {
|
||||
// 如果中奖,金币数乘以10倍
|
||||
// 如果中獎,金幣數乘以10倍
|
||||
chargeGoldNum = chargeProd.getChargeGoldNum() * 10;
|
||||
drawStatus = Constant.LuckyTarotStatus.success;
|
||||
}
|
||||
@@ -648,16 +629,16 @@ public class ChargeService extends BaseService {
|
||||
chargeRecord.setTotalGold(chargeGoldNum);
|
||||
int result = completedOrder(chargeRecord);
|
||||
if (result <= 0) {
|
||||
log.info("重复请求:chargeRecordId: " + chargeRecord.getChargeRecordId());
|
||||
log.info("重複請求:chargeRecordId: " + chargeRecord.getChargeRecordId());
|
||||
throw new ApiException(BusiStatus.DUPLICATE_TRANSFER_REQUEST);
|
||||
}
|
||||
// 更新塔罗充值记录
|
||||
// 更新塔羅充值記錄
|
||||
luckyTarotRecord.setDrawStatus(drawStatus);
|
||||
luckyTarotRecord.setGoldNum(chargeGoldNum);
|
||||
luckyTarotRecord.setDrawNum(drawNum);
|
||||
luckyTarotRecord.setUpdateTime(Calendar.getInstance().getTime());
|
||||
luckyTarotRecordService.updateLuckyTarotRecord(luckyTarotRecord);
|
||||
// 更新账单表
|
||||
// 更新賬單表
|
||||
billRecordService.insertGeneralBillRecord(
|
||||
chargeUid,
|
||||
chargeUid,
|
||||
@@ -665,13 +646,13 @@ public class ChargeService extends BaseService {
|
||||
BillObjTypeEnum.TARO_CHARGE,
|
||||
Double.valueOf(chargeGoldNum),
|
||||
money.doubleValue(),
|
||||
"塔罗占卜充值" + chargeGoldNum + BillObjTypeEnum.TARO_CHARGE.getCurrency().getDesc()
|
||||
"塔羅占卜充值" + chargeGoldNum + BillObjTypeEnum.TARO_CHARGE.getCurrency().getDesc()
|
||||
);
|
||||
// 更新钱包
|
||||
// 更新錢包
|
||||
if (chargeGoldNum > 0) {
|
||||
userPurseService.addDiamond(chargeUid, Double.valueOf(chargeGoldNum), null, "幸运塔罗充值");
|
||||
userPurseService.addDiamond(chargeUid, Double.valueOf(chargeGoldNum), null, "幸運塔羅充值");
|
||||
}
|
||||
// 发送小秘书通知和头饰
|
||||
// 發送小秘書通知和頭飾
|
||||
luckyTarotChargeService.sendDrawResultToUsers(luckyTarotRecord);
|
||||
}
|
||||
}
|
@@ -78,7 +78,7 @@ public class VipChargeService {
|
||||
* @return
|
||||
*/
|
||||
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
|
||||
public BusiResult openVip(VipOpenParams params) {
|
||||
public Object openVip(VipOpenParams params) {
|
||||
if (params.getUid() == null) {
|
||||
throw new ServiceException(BusiStatus.PARAMERROR);
|
||||
}
|
||||
|
@@ -1,27 +1,15 @@
|
||||
package com.accompany.business.service.payment;
|
||||
|
||||
import com.accompany.business.service.ChargeService;
|
||||
import com.accompany.business.service.charge.VipChargeService;
|
||||
import com.accompany.common.constant.Constant;
|
||||
import com.accompany.common.device.DeviceInfo;
|
||||
import com.accompany.common.redis.RedisKey;
|
||||
import com.accompany.common.result.BusiResult;
|
||||
import com.accompany.common.status.BusiStatus;
|
||||
import com.accompany.common.utils.DateTimeUtil;
|
||||
import com.accompany.common.utils.UUIDUitl;
|
||||
import com.accompany.core.enumeration.BusinessStatusCodeEnum;
|
||||
import com.accompany.core.exception.ServiceException;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.service.user.UsersBaseService;
|
||||
import com.accompany.payment.dto.AppInnerPayRecordDTO;
|
||||
import com.accompany.payment.google.AndroidPublisherHelper;
|
||||
import com.accompany.payment.google.dto.GooglePayLimitConfigDTO;
|
||||
import com.accompany.payment.model.ChargeProd;
|
||||
import com.accompany.payment.model.ChargeRecord;
|
||||
import com.accompany.payment.service.ChargeProdService;
|
||||
import com.accompany.payment.service.ChargeRecordService;
|
||||
import com.accompany.payment.vo.VipOpenParams;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.api.services.androidpublisher.model.ProductPurchase;
|
||||
@@ -30,7 +18,6 @@ import org.redisson.api.RLock;
|
||||
import org.redisson.api.RedissonClient;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -47,69 +34,11 @@ public class GooglePlayBillingService {
|
||||
@Autowired
|
||||
private ChargeRecordService chargeRecordService;
|
||||
@Autowired
|
||||
private ChargeProdService chargeProdService;
|
||||
@Autowired
|
||||
private ChargeService chargeService;
|
||||
@Autowired
|
||||
private SysConfService sysConfService;
|
||||
@Autowired
|
||||
private UsersBaseService usersBaseService;
|
||||
@Autowired
|
||||
private VipChargeService vipChargeService;
|
||||
|
||||
public AppInnerPayRecordDTO placeOrder(Long uid, String chargeProdId, String clientIp, DeviceInfo deviceInfo) {
|
||||
validMoneyLimit(uid, chargeProdId);
|
||||
|
||||
BusiResult r = chargeService.applyChargeV4(uid, chargeProdId, Constant.ChargeChannel.google_play_billing,
|
||||
return (AppInnerPayRecordDTO) chargeService.applyChargeV4(uid, chargeProdId, Constant.ChargeChannel.google_play_billing,
|
||||
clientIp, null, null, deviceInfo, null, null, null, null);
|
||||
if (r.getCode() == BusinessStatusCodeEnum.SUCCESS.value()){
|
||||
//success
|
||||
return (AppInnerPayRecordDTO) r.getData();
|
||||
} else {
|
||||
throw new ServiceException(BusiStatus.SERVER_BUSY);
|
||||
}
|
||||
}
|
||||
|
||||
private void validMoneyLimit(Long uid, String chargeProdId) {
|
||||
GooglePayLimitConfigDTO config = getLimitConfig();
|
||||
Date now = new Date();
|
||||
Date beginTimeOfDay = DateTimeUtil.getBeginTimeOfDay(now);
|
||||
Date endTimeOfDay = DateTimeUtil.getEndTimeOfDay(now);
|
||||
|
||||
ChargeProd chargeProd = chargeProdService.getChargeProdById(chargeProdId);
|
||||
if (chargeProd == null) {
|
||||
log.error("充值产品不存在,prodId: {} ", chargeProdId);
|
||||
throw new ServiceException(BusiStatus.CHARGE_PROD_NOT_EXIST);
|
||||
}
|
||||
|
||||
Long userChargeAmmount = chargeRecordService.getChargeUserAmountWithProdIds(Collections.singletonList(uid), config.getGoogleChargeProdIds(), beginTimeOfDay, endTimeOfDay);
|
||||
log.info("{}在{}-{}时间段内使用google内购充值了{}", uid, DateTimeUtil.convertDate(beginTimeOfDay), DateTimeUtil.convertDate(endTimeOfDay), userChargeAmmount);
|
||||
// 配置的单位是元,充值记录和产品的数据单位为分
|
||||
if (config.getLimitEveryOneDaySumAmount() * 100 < (chargeProd.getMoney() + userChargeAmmount)) {
|
||||
throw new ServiceException(config.getErrorTip());
|
||||
}
|
||||
Long allUserChargeAmount = chargeRecordService.getChargeUserAmountWithProdIds(null, config.getGoogleChargeProdIds(), beginTimeOfDay, endTimeOfDay);
|
||||
log.info("全部用户{}-{}内使用google内购充值了{}", DateTimeUtil.convertDate(beginTimeOfDay), DateTimeUtil.convertDate(endTimeOfDay), allUserChargeAmount);
|
||||
if (config.getLimitEveryDayAmount() * 100 < (chargeProd.getMoney() + allUserChargeAmount)) {
|
||||
throw new ServiceException(config.getErrorTip());
|
||||
}
|
||||
}
|
||||
|
||||
private GooglePayLimitConfigDTO getLimitConfig() {
|
||||
GooglePayLimitConfigDTO limitConfig = JSONObject.parseObject(sysConfService.getDefaultSysConfValueById(Constant.SysConfId.GOOGLE_PAY_LIMIT_CONFIG, "{}"), GooglePayLimitConfigDTO.class);
|
||||
if (limitConfig.getLimitEveryDayAmount() == null) {
|
||||
limitConfig.setLimitEveryDayAmount(9999999L);
|
||||
}
|
||||
if (limitConfig.getLimitEveryOneDaySumAmount() == null) {
|
||||
limitConfig.setLimitEveryOneDaySumAmount(9999999L);
|
||||
}
|
||||
if (limitConfig.getGoogleChargeProdIds() == null) {
|
||||
limitConfig.setGoogleChargeProdIds(Collections.emptyList());
|
||||
}
|
||||
if (StringUtils.isEmpty(limitConfig.getErrorTip())) {
|
||||
limitConfig.setErrorTip("充值失败,请联系客服处理");
|
||||
}
|
||||
return limitConfig;
|
||||
}
|
||||
|
||||
public void verifyOrder(String chargeRecordId, String packageName, String googlePlayProdId, String purchaseToken) {
|
||||
|
@@ -120,7 +120,7 @@ public class WxService {
|
||||
wxConfigVo.setNonceStr(nonceStr);
|
||||
wxConfigVo.setTimestamp(timestamp);
|
||||
wxConfigVo.setSignature(sign);
|
||||
BusiResult busiResult = new BusiResult(BusiStatus.SUCCESS);
|
||||
BusiResult<WxConfigVo> busiResult = new BusiResult<>(BusiStatus.SUCCESS);
|
||||
busiResult.setData(wxConfigVo);
|
||||
return busiResult;
|
||||
}
|
||||
@@ -149,9 +149,10 @@ public class WxService {
|
||||
return Long.toString(System.currentTimeMillis() / 1000);
|
||||
}
|
||||
|
||||
public BusiResult submitPayWx(Long uid, String chargeProdId, String nick, Long erban_no, String openId, String ip, String app, String successUrl, Integer chargeMoney) throws Exception {
|
||||
return chargeService.applyCharge3(
|
||||
public BusiResult<Object> submitPayWx(Long uid, String chargeProdId, String nick, Long erban_no, String openId, String ip, String app, String successUrl, Integer chargeMoney) {
|
||||
Object result = chargeService.applyCharge3(
|
||||
uid, chargeProdId, Constant.ChargeChannel.wx_pub, ip, successUrl, openId, app, null, chargeMoney);
|
||||
return new BusiResult<>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -179,13 +180,15 @@ public class WxService {
|
||||
}
|
||||
}
|
||||
|
||||
public BusiResult submitPayWxForMicroMall(Long myUid, String chargeProdId, String nick, Long myErBanNo, String openId, String ip, String app, String successUrl) {
|
||||
return chargeService.applyCharge3(
|
||||
public BusiResult<Object> submitPayWxForMicroMall(Long myUid, String chargeProdId, String nick, Long myErBanNo, String openId, String ip, String app, String successUrl) {
|
||||
Object result = chargeService.applyCharge3(
|
||||
myUid, chargeProdId, Constant.ChargeChannel.wx_micro_mall_pub, ip, successUrl, openId, app, null, null);
|
||||
return new BusiResult<>(result);
|
||||
}
|
||||
|
||||
public BusiResult submitPayWxForPub2(Long myUid, String chargeProdId, String nick, Long myErBanNo, String openId, String ip, String app, String successUrl, Integer chargeMoney) {
|
||||
return chargeService.applyCharge3(
|
||||
public BusiResult<Object> submitPayWxForPub2(Long myUid, String chargeProdId, String nick, Long myErBanNo, String openId, String ip, String app, String successUrl, Integer chargeMoney) {
|
||||
Object result = chargeService.applyCharge3(
|
||||
myUid, chargeProdId, Constant.ChargeChannel.wx_pub2, ip, successUrl, openId, app, null, chargeMoney);
|
||||
return new BusiResult<>(result);
|
||||
}
|
||||
}
|
@@ -13,7 +13,6 @@ import com.accompany.common.utils.IPUitls;
|
||||
import com.accompany.core.model.Users;
|
||||
import com.accompany.core.service.SysConfService;
|
||||
import com.accompany.core.service.user.UsersBaseService;
|
||||
import com.accompany.core.vo.UserVo;
|
||||
import com.accompany.payment.vo.WeChatMiniAppPayRequestVO;
|
||||
import com.accompany.payment.vo.WeXinPayTypeVO;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -26,7 +25,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -47,9 +45,8 @@ public class ChargeController extends BaseController {
|
||||
@Autowired
|
||||
private SysConfService sysConfService;
|
||||
|
||||
|
||||
@PostMapping(value = "apply2New")
|
||||
public BusiResult applyH5ChargeNew(HttpServletRequest request,
|
||||
public BusiResult<Object> applyH5ChargeNew(HttpServletRequest request,
|
||||
@NotBlank(message = "交易产品 id 不可为空") String chargeProdId,
|
||||
@NotBlank(message = "支付渠道不可为空") String payChannel,
|
||||
String successUrl, String openId, String phone, Long erbanNo, Integer chargeMoney,
|
||||
@@ -65,7 +62,7 @@ public class ChargeController extends BaseController {
|
||||
if (null == users) {
|
||||
return new BusiResult(BusiStatus.USERNOTEXISTS);
|
||||
}
|
||||
BusiResult result = applyCharge3(request, users.getUid(), chargeProdId, payChannel, successUrl, openId, null, chargeMoney, paymentType, countryCode);
|
||||
BusiResult<Object> result = applyCharge3(request, users.getUid(), chargeProdId, payChannel, successUrl, openId, null, chargeMoney, paymentType, countryCode);
|
||||
if (result.getCode() == BusiStatus.SUCCESS.value()) {
|
||||
Map<String, Object> data = new HashMap<>();
|
||||
data.put("payInfo", result.getData());
|
||||
@@ -77,7 +74,7 @@ public class ChargeController extends BaseController {
|
||||
}
|
||||
|
||||
@PostMapping(value = "pay/apply")
|
||||
public BusiResult applyCharge3(HttpServletRequest request, Long uid, String chargeProdId,
|
||||
public BusiResult<Object> applyCharge3(HttpServletRequest request, Long uid, String chargeProdId,
|
||||
@NotBlank(message = "支付渠道不可为空") String payChannel, String successUrl,
|
||||
@RequestParam(value = "openId", required = false) String openId, Long roomUid, Integer chargeMoney,
|
||||
String paymentType, String countryCode) {
|
||||
@@ -85,7 +82,8 @@ public class ChargeController extends BaseController {
|
||||
uid,chargeProdId,payChannel, roomUid, paymentType, countryCode);
|
||||
DeviceInfo deviceInfo = getDeviceInfo(request);
|
||||
String clientIp = IPUitls.getRealIpAddress(request);
|
||||
return chargeService.applyChargeV4(uid, chargeProdId, payChannel, clientIp, successUrl, openId, deviceInfo, roomUid, chargeMoney, paymentType, countryCode);
|
||||
Object result = chargeService.applyChargeV4(uid, chargeProdId, payChannel, clientIp, successUrl, openId, deviceInfo, roomUid, chargeMoney, paymentType, countryCode);
|
||||
return new BusiResult<>(result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -71,7 +71,8 @@ public class IOSPayPlaController extends BaseController {
|
||||
.chargeProd(chargeProd)
|
||||
.payChannel(Constant.ChargeChannel.ios_pay)
|
||||
.build();
|
||||
busiResult = vipChargeService.openVip(params);
|
||||
Object ret = vipChargeService.openVip(params);
|
||||
busiResult = new BusiResult(ret);
|
||||
} else {
|
||||
// 充值
|
||||
busiResult = iosPayPlaService.placeOrder(uid, chargeProdId, clientIp, deviceId, deviceInfo);
|
||||
|
@@ -35,7 +35,7 @@ public class ChargeServiceTest extends CommonTest {
|
||||
String channel = Constant.ChargeChannel.alipay;
|
||||
String clientIp = "127.0.0.1";
|
||||
|
||||
BusiResult busiResult = chargeService.applyCharge3(uid, prodId, channel, clientIp, null, null, AppEnum.PlanetStar.getValue(), null, null);
|
||||
Object busiResult = chargeService.applyCharge3(uid, prodId, channel, clientIp, null, null, AppEnum.PlanetStar.getValue(), null, null);
|
||||
|
||||
System.out.println(JSONObject.toJSONString(busiResult));
|
||||
}
|
||||
@@ -47,7 +47,7 @@ public class ChargeServiceTest extends CommonTest {
|
||||
String channel = Constant.ChargeChannel.alipay;
|
||||
String clientIp = "127.0.0.1";
|
||||
|
||||
BusiResult busiResult = chargeService.applyCharge3(uid, prodId, channel, clientIp, null, null, AppEnum.PlanetStar.getValue(), null, null);
|
||||
Object busiResult = chargeService.applyCharge3(uid, prodId, channel, clientIp, null, null, AppEnum.PlanetStar.getValue(), null, null);
|
||||
|
||||
System.out.println(JSONObject.toJSONString(busiResult));
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class ChargeServiceTest extends CommonTest {
|
||||
String channel = Constant.ChargeChannel.alipay;
|
||||
String clientIp = "127.0.0.1";
|
||||
|
||||
BusiResult busiResult = chargeService.applyCharge3(uid, prodId, channel, clientIp, null, null, AppEnum.PlanetStar.getValue(), null, null);
|
||||
Object busiResult = chargeService.applyCharge3(uid, prodId, channel, clientIp, null, null, AppEnum.PlanetStar.getValue(), null, null);
|
||||
|
||||
System.out.println(JSONObject.toJSONString(busiResult));
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class ChargeServiceTest extends CommonTest {
|
||||
String channel = Constant.ChargeChannel.alipay_v2;
|
||||
String clientIp = "127.0.0.1";
|
||||
|
||||
BusiResult busiResult = chargeService.applyCharge3(uid, prodId, channel, clientIp, null, null, AppEnum.PlanetStar.getValue(), null, null);
|
||||
Object busiResult = chargeService.applyCharge3(uid, prodId, channel, clientIp, null, null, AppEnum.PlanetStar.getValue(), null, null);
|
||||
|
||||
System.out.println(JSONObject.toJSONString(busiResult));
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class ChargeServiceTest extends CommonTest {
|
||||
DeviceInfo deviceInfo = new DeviceInfo();
|
||||
// deviceInfo.setApp(AppEnum.yinyou.getValue());
|
||||
|
||||
BusiResult busiResult = chargeService.applyChargeV4(uid, prodId, channel, clientIp, null, null, deviceInfo, null, null, null, null);
|
||||
Object busiResult = chargeService.applyChargeV4(uid, prodId, channel, clientIp, null, null, deviceInfo, null, null, null, null);
|
||||
|
||||
System.out.println(JSONObject.toJSONString(busiResult));
|
||||
}
|
||||
|
Reference in New Issue
Block a user