|
@@ -16,6 +16,7 @@ import com.txz.cif.service.*;
|
|
|
import com.txz.cif.web.para.RedEnvelopeParam;
|
|
|
import com.txz.operating.dto.ConfigDTO;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.dubbo.config.annotation.DubboService;
|
|
|
import org.apache.dubbo.config.annotation.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -25,39 +26,39 @@ import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Slf4j
|
|
|
-@Service
|
|
|
+@DubboService
|
|
|
public class AccountDubboServiceImpl implements AccountDubboService {
|
|
|
-
|
|
|
+
|
|
|
@Resource
|
|
|
private FlowService flowService;
|
|
|
-
|
|
|
+
|
|
|
@Resource
|
|
|
private AccountService accountService;
|
|
|
-
|
|
|
+
|
|
|
@Resource
|
|
|
private UserService userService;
|
|
|
-
|
|
|
+
|
|
|
@Resource
|
|
|
private RedEnvelopeService redEnvelopeService;
|
|
|
-
|
|
|
+
|
|
|
@Resource
|
|
|
private OperatingConfigDubboServiceClient operatingConfigDubboServiceClient;
|
|
|
-
|
|
|
-
|
|
|
-// @Override
|
|
|
-// public Result freeze(FreezdParam param) {
|
|
|
-// return flowService.freeze(param);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public Result unFreeze(Long freezdId) {
|
|
|
-// return flowService.unFreeze(freezdId);
|
|
|
-// }
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
+ // @Override
|
|
|
+ // public Result freeze(FreezdParam param) {
|
|
|
+ // return flowService.freeze(param);
|
|
|
+ // }
|
|
|
+ //
|
|
|
+ // @Override
|
|
|
+ // public Result unFreeze(Long freezdId) {
|
|
|
+ // return flowService.unFreeze(freezdId);
|
|
|
+ // }
|
|
|
+
|
|
|
@Override
|
|
|
public Result createAccount(Long userId) {
|
|
|
User user = userService.findById(userId);
|
|
|
-
|
|
|
+
|
|
|
Account qb = Account.builder().userId(userId).createTime(DateUtil.date())
|
|
|
.aliases("202").freezeAmount(BigDecimal.ZERO).balance(BigDecimal.ZERO)
|
|
|
.type(1).beforeDayBalance(BigDecimal.ZERO).beforeDayTime(DateUtil.date())
|
|
@@ -76,34 +77,34 @@ public class AccountDubboServiceImpl implements AccountDubboService {
|
|
|
accountService.save(add);
|
|
|
return Result.genSuccessResult();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public Result getWalletAccount(Long userId) {
|
|
|
Account account = accountService.getAccount(userId, 1);
|
|
|
- if (account == null){
|
|
|
+ if (account == null) {
|
|
|
return Result.genFailResult("没有找到");
|
|
|
}
|
|
|
- AccountDTO dto = BeanUtil.toBean(account,AccountDTO.class);
|
|
|
+ AccountDTO dto = BeanUtil.toBean(account, AccountDTO.class);
|
|
|
return Result.genSuccessResult(dto);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public Result openGroup(OpenParam param) {
|
|
|
- //支付
|
|
|
- //BizTypeEnum 类型 1001充值 2001提现 3001开团支付 3002参团支付 4001未成团退款 4002成团退款 5001开团红包收益 5002参团红包收益 5003签到红包收益 5004下级红包佣金 5005下下级红包佣金
|
|
|
+ // 支付
|
|
|
+ // BizTypeEnum 类型 1001充值 2001提现 3001开团支付 3002参团支付 4001未成团退款 4002成团退款 5001开团红包收益 5002参团红包收益 5003签到红包收益 5004下级红包佣金 5005下下级红包佣金
|
|
|
Result result = flowService.pay(PayParam.builder().bizNo(param.getBizNo())
|
|
|
.amount(param.getAmount())
|
|
|
.bizId(param.getBizId())
|
|
|
.transTime(param.getTransTime())
|
|
|
.bizType(BizTypeEnum.OPEN_GROUP_PAY.getKey())
|
|
|
.build());
|
|
|
- if (StrUtil.equals("200",result.getCode())){
|
|
|
- //计算开团红包金额
|
|
|
+ if (StrUtil.equals("200", result.getCode())) {
|
|
|
+ // 计算开团红包金额
|
|
|
com.txz.operating.result.Result<ConfigDTO> openRedEnvelopeRate = operatingConfigDubboServiceClient.getConfigByCode("open_red_envelope_rate");
|
|
|
String rate = openRedEnvelopeRate.getData().getValueInfo();
|
|
|
- BigDecimal amount = param.getAmount().multiply(new BigDecimal(rate)).divide(BigDecimal.valueOf(100),2, RoundingMode.DOWN);
|
|
|
-
|
|
|
- //开团红包
|
|
|
+ BigDecimal amount = param.getAmount().multiply(new BigDecimal(rate)).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN);
|
|
|
+
|
|
|
+ // 开团红包
|
|
|
Result result1 = redEnvelopeService.addRedEnvelope(RedEnvelopeParam.builder()
|
|
|
.amount(amount).bizType(BizTypeEnum.OPEN_GROUP_RED_ENVELOPE.getKey()).orderNo(param.getBizNo())
|
|
|
.userIds(CollUtil.newArrayList(param.getUserId()))
|
|
@@ -112,11 +113,11 @@ public class AccountDubboServiceImpl implements AccountDubboService {
|
|
|
}
|
|
|
return Result.genSuccessResult();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public Result joinGroup(JoinParam param) {
|
|
|
- //支付
|
|
|
- //类型 1001充值 2001提现 3001开团支付 3002参团支付 4001未成团退款 4002成团退款 5001开团红包收益 5002参团红包收益 5003签到红包收益 5004下级红包佣金 5005下下级红包佣金
|
|
|
+ // 支付
|
|
|
+ // 类型 1001充值 2001提现 3001开团支付 3002参团支付 4001未成团退款 4002成团退款 5001开团红包收益 5002参团红包收益 5003签到红包收益 5004下级红包佣金 5005下下级红包佣金
|
|
|
Result result = flowService.pay(PayParam.builder().bizNo(param.getBizNo())
|
|
|
.amount(param.getAmount())
|
|
|
.bizId(param.getBizId())
|
|
@@ -125,11 +126,11 @@ public class AccountDubboServiceImpl implements AccountDubboService {
|
|
|
.build());
|
|
|
return Result.genSuccessResult();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public Result cancelGroup(CancelParam param) {
|
|
|
- //类型 1001充值 2001提现 3001开团支付 3002参团支付 4001未成团退款 4002成团退款 5001开团红包收益 5002参团红包收益 5003签到红包收益 5004下级红包佣金 5005下下级红包佣金
|
|
|
- for (Long userId:param.getUserIds()){
|
|
|
+ // 类型 1001充值 2001提现 3001开团支付 3002参团支付 4001未成团退款 4002成团退款 5001开团红包收益 5002参团红包收益 5003签到红包收益 5004下级红包佣金 5005下下级红包佣金
|
|
|
+ for (Long userId : param.getUserIds()) {
|
|
|
Result result = flowService.refund(RefundParam.builder()
|
|
|
.transTime(param.getTransTime())
|
|
|
.bizType(BizTypeEnum.FAIL_GROUP_REFUND.getKey()).bizNo(param.getBizNo())
|
|
@@ -137,16 +138,16 @@ public class AccountDubboServiceImpl implements AccountDubboService {
|
|
|
.amount(param.getAmount())
|
|
|
.userId(userId)
|
|
|
.build());
|
|
|
- if (!StrUtil.equals("200",result.getCode())){
|
|
|
- throw new ServiceException() ;
|
|
|
+ if (!StrUtil.equals("200", result.getCode())) {
|
|
|
+ throw new ServiceException();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
- //TODO 计算参团红包金额
|
|
|
+ // TODO 计算参团红包金额
|
|
|
com.txz.operating.result.Result<ConfigDTO> openRedEnvelopeRate = operatingConfigDubboServiceClient.getConfigByCode("join_red_envelope_rate");
|
|
|
String rate = openRedEnvelopeRate.getData().getValueInfo();
|
|
|
- BigDecimal amount = param.getAmount().multiply(new BigDecimal(rate)).divide(BigDecimal.valueOf(100),2, RoundingMode.DOWN);
|
|
|
- //参团红包
|
|
|
+ BigDecimal amount = param.getAmount().multiply(new BigDecimal(rate)).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN);
|
|
|
+ // 参团红包
|
|
|
Result result1 = redEnvelopeService.addRedEnvelope(RedEnvelopeParam.builder()
|
|
|
.amount(amount).bizType(BizTypeEnum.JOIN_GROUP_RED_ENVELOPE.getKey()).orderNo(param.getBizNo())
|
|
|
.userIds(param.getUserIds())
|
|
@@ -154,11 +155,11 @@ public class AccountDubboServiceImpl implements AccountDubboService {
|
|
|
.build());
|
|
|
return Result.genSuccessResult();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public Result accomplishGroup(AccomplishParam param) {
|
|
|
- //类型 1001充值 2001提现 3001开团支付 3002参团支付 4001未成团退款 4002成团退款 5001开团红包收益 5002参团红包收益 5003签到红包收益 5004下级红包佣金 5005下下级红包佣金
|
|
|
- for (Long userId:param.getUserIds()){
|
|
|
+ // 类型 1001充值 2001提现 3001开团支付 3002参团支付 4001未成团退款 4002成团退款 5001开团红包收益 5002参团红包收益 5003签到红包收益 5004下级红包佣金 5005下下级红包佣金
|
|
|
+ for (Long userId : param.getUserIds()) {
|
|
|
Result result = flowService.refund(RefundParam.builder()
|
|
|
.transTime(param.getTransTime())
|
|
|
.bizType(BizTypeEnum.SUCCESS_GROUP_REFUND.getKey()).bizNo(param.getBizNo())
|
|
@@ -166,16 +167,16 @@ public class AccountDubboServiceImpl implements AccountDubboService {
|
|
|
.amount(param.getAmount())
|
|
|
.userId(userId)
|
|
|
.build());
|
|
|
- if (!StrUtil.equals("200",result.getCode())){
|
|
|
- throw new ServiceException() ;
|
|
|
+ if (!StrUtil.equals("200", result.getCode())) {
|
|
|
+ throw new ServiceException();
|
|
|
}
|
|
|
}
|
|
|
- //TODO 计算参团红包金额
|
|
|
+ // TODO 计算参团红包金额
|
|
|
com.txz.operating.result.Result<ConfigDTO> openRedEnvelopeRate = operatingConfigDubboServiceClient.getConfigByCode("join_red_envelope_rate");
|
|
|
String rate = openRedEnvelopeRate.getData().getValueInfo();
|
|
|
- BigDecimal amount = param.getAmount().multiply(new BigDecimal(rate)).divide(BigDecimal.valueOf(100),2, RoundingMode.DOWN);
|
|
|
-
|
|
|
- //参团红包
|
|
|
+ BigDecimal amount = param.getAmount().multiply(new BigDecimal(rate)).divide(BigDecimal.valueOf(100), 2, RoundingMode.DOWN);
|
|
|
+
|
|
|
+ // 参团红包
|
|
|
Result result1 = redEnvelopeService.addRedEnvelope(RedEnvelopeParam.builder()
|
|
|
.amount(amount).bizType(BizTypeEnum.JOIN_GROUP_RED_ENVELOPE.getKey()).orderNo(param.getBizNo())
|
|
|
.userIds(param.getUserIds())
|
|
@@ -183,47 +184,48 @@ public class AccountDubboServiceImpl implements AccountDubboService {
|
|
|
.build());
|
|
|
return Result.genSuccessResult();
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 类型 1001充值 2001提现 3001开团支付 3002参团支付 4001未成团退款 4002成团退款 5001开团红包收益 5002参团红包收益 5003签到红包收益 5004下级红包佣金 5005下下级红包佣金
|
|
|
+ *
|
|
|
* @param param
|
|
|
+ *
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
public Result addRedEnvelope(SignRedEnvelopeParam param) {
|
|
|
- RedEnvelopeParam p = BeanUtil.toBean(param,RedEnvelopeParam.class);
|
|
|
+ RedEnvelopeParam p = BeanUtil.toBean(param, RedEnvelopeParam.class);
|
|
|
p.setUserIds(CollUtil.newArrayList(param.getUserId()));
|
|
|
- if (param.getBizType() == BizTypeEnum.SIGN_RED_ENVELOPE || param.getBizType() == BizTypeEnum.PROMOTION_COMMISSION){
|
|
|
+ if (param.getBizType() == BizTypeEnum.SIGN_RED_ENVELOPE || param.getBizType() == BizTypeEnum.PROMOTION_COMMISSION) {
|
|
|
p.setBizType(param.getBizType().getKey());
|
|
|
} else {
|
|
|
return Result.genFailResult("不支持类型");
|
|
|
}
|
|
|
return redEnvelopeService.addRedEnvelope(p);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Result recharge(RechargeParam param) {
|
|
|
- if (param == null){
|
|
|
+ if (param == null) {
|
|
|
return Result.genFailResult("参数为空");
|
|
|
}
|
|
|
- if (param.getUserId() == null){
|
|
|
+ if (param.getUserId() == null) {
|
|
|
return Result.genFailResult("参数账号id为空");
|
|
|
}
|
|
|
- if (param.getAmount() == null){
|
|
|
+ if (param.getAmount() == null) {
|
|
|
return Result.genFailResult("参数金额为空");
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
param.setBizType(BizTypeEnum.RECHARGE.getKey());
|
|
|
- if (param.getTransTime() == null){
|
|
|
+ if (param.getTransTime() == null) {
|
|
|
param.setTransTime(DateUtil.date());
|
|
|
}
|
|
|
Result result = flowService.recharge(param);
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
@Override
|
|
|
public Result withdraw(WithdrawParam param) {
|
|
|
param.setBizType(BizTypeEnum.WITHDRAW.getKey());
|