|
@@ -29,11 +29,13 @@ import com.cyksj.mapper.UserMapper;
|
|
|
import com.cyksj.mapper.manage.distribute.DistributeMoneyApplyMapper;
|
|
import com.cyksj.mapper.manage.distribute.DistributeMoneyApplyMapper;
|
|
|
import com.cyksj.mapper.manage.distribute.DistributePointsExchangeMoneyMapper;
|
|
import com.cyksj.mapper.manage.distribute.DistributePointsExchangeMoneyMapper;
|
|
|
import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
|
|
import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
|
|
|
|
|
+import com.cyksj.mapper.mirrorshop.UserMirrorShopDistributeMoneyApplyMapper;
|
|
|
import com.cyksj.mapper.shop.YhShopDistributeMoneyApplyMapper;
|
|
import com.cyksj.mapper.shop.YhShopDistributeMoneyApplyMapper;
|
|
|
import com.cyksj.mapper.shop.YhShopMapper;
|
|
import com.cyksj.mapper.shop.YhShopMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.request.ApplyMoneyReq;
|
|
import com.cyksj.model.request.ApplyMoneyReq;
|
|
|
import com.cyksj.model.request.TransferAccountsReq;
|
|
import com.cyksj.model.request.TransferAccountsReq;
|
|
|
|
|
+import com.cyksj.model.request.UserMirrorShopApplyMoneyReq;
|
|
|
import com.cyksj.model.request.YhShopApplyMoneyReq;
|
|
import com.cyksj.model.request.YhShopApplyMoneyReq;
|
|
|
import com.cyksj.redis.RedisService;
|
|
import com.cyksj.redis.RedisService;
|
|
|
import com.cyksj.service.distribute.UserDistributeReturnMoneyDetailService;
|
|
import com.cyksj.service.distribute.UserDistributeReturnMoneyDetailService;
|
|
@@ -84,6 +86,8 @@ public class TransferFuncServiceImpl implements TransferFuncService {
|
|
|
|
|
|
|
|
private final UserDistributeReturnMoneyDetailService userDistributeReturnMoneyDetailService;
|
|
private final UserDistributeReturnMoneyDetailService userDistributeReturnMoneyDetailService;
|
|
|
|
|
|
|
|
|
|
+ private final UserMirrorShopDistributeMoneyApplyMapper userMirrorShopDistributeMoneyApplyMapper;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Result distributeApply(ApplyMoneyReq applyMoneyReq) throws Exception {
|
|
public Result distributeApply(ApplyMoneyReq applyMoneyReq) throws Exception {
|
|
|
applyMoneyReq.setMType(DistributeMoneyApply.MType.ds);
|
|
applyMoneyReq.setMType(DistributeMoneyApply.MType.ds);
|
|
@@ -166,6 +170,120 @@ public class TransferFuncServiceImpl implements TransferFuncService {
|
|
|
return commonApplyMoney(applyMoneyReq);
|
|
return commonApplyMoney(applyMoneyReq);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Result<String> userMirrorShopDistributeApply(UserMirrorShopApplyMoneyReq applyMoneyReq) {
|
|
|
|
|
+ String type = "mirrorShop";
|
|
|
|
|
+ String key = String.format(RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getName(), DateTime.now().toDateStr(), type, applyMoneyReq.getUserId());
|
|
|
|
|
+ if (!redisService.setNx(key, applyMoneyReq.getUserId(), RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getTimeout())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("每天仅可提现一次");
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ Result result = userMirrorShopApplyMoney(applyMoneyReq);
|
|
|
|
|
+ if (result.isFlag()) {
|
|
|
|
|
+ redisService.set(key, applyMoneyReq.getUserId(), RedisService.key.APPLY_MONEY_DAY_LIMIT_KEY.getTimeout());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ redisService.del(key);
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ redisService.del(key);
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance(StringUtil.getErrorMsg(e));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private Result userMirrorShopApplyMoney(UserMirrorShopApplyMoneyReq applyMoneyReq) throws Exception {
|
|
|
|
|
+ Long userId = applyMoneyReq.getUserId();
|
|
|
|
|
+ User user = userMapper.selectById(userId);
|
|
|
|
|
+ if (user == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("请先授权登录");
|
|
|
|
|
+ }
|
|
|
|
|
+ Boolean isTakeAll = applyMoneyReq.getIsTakeAll();
|
|
|
|
|
+ UserMirrorShopDistributeMoneyApply.Type type = applyMoneyReq.getType();
|
|
|
|
|
+ if (type == null) type = UserMirrorShopDistributeMoneyApply.Type.zfb;
|
|
|
|
|
+ if (type == UserMirrorShopDistributeMoneyApply.Type.zfb) {
|
|
|
|
|
+ if (ObjectUtil.hasEmpty(applyMoneyReq.getAccount(), applyMoneyReq.getRealName())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("必填项不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (applyMoneyReq.getAccount().length() > 255 || applyMoneyReq.getRealName().length() > 32) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("请输入正确的账户信息");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (type == UserMirrorShopDistributeMoneyApply.Type.usdt) {
|
|
|
|
|
+ if (StrUtil.isEmpty(applyMoneyReq.getWalletAddr())) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("USDT提现钱包地址不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (applyMoneyReq.getWalletAddr().length() > 1000) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("请输入正确的钱包地址");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotBlank(applyMoneyReq.getRemark()) && applyMoneyReq.getRemark().length() > 512) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("备注过多");
|
|
|
|
|
+ }
|
|
|
|
|
+ isTakeAll = true;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ UserMirrorShopDistributeMoneyApply distributeMoneyApply = null;
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal needApplyMoney = user.getMpMoney();
|
|
|
|
|
+ BigDecimal fourHundred = BigDecimal.valueOf(4 * 10000);
|
|
|
|
|
+ if (isTakeAll == null || !isTakeAll) {
|
|
|
|
|
+ if (needApplyMoney.compareTo(fourHundred) > 0) {
|
|
|
|
|
+ needApplyMoney = fourHundred;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ Integer update = userMapper.subUserMirrorShopMoney(user.getId(), user.getMpMoney(), needApplyMoney);
|
|
|
|
|
+ if (update == 1) {
|
|
|
|
|
+ distributeMoneyApply = Optional.ofNullable(distributeMoneyApply).orElse(new UserMirrorShopDistributeMoneyApply());
|
|
|
|
|
+ distributeMoneyApply.setUserId(userId);
|
|
|
|
|
+ distributeMoneyApply.setMoney(needApplyMoney);
|
|
|
|
|
+ distributeMoneyApply.setAccount(applyMoneyReq.getAccount());
|
|
|
|
|
+ distributeMoneyApply.setRealName(applyMoneyReq.getRealName());
|
|
|
|
|
+ distributeMoneyApply.setWalletAddr(applyMoneyReq.getWalletAddr());
|
|
|
|
|
+ distributeMoneyApply.setRemark(applyMoneyReq.getRemark());
|
|
|
|
|
+ distributeMoneyApply.setType(applyMoneyReq.getType());
|
|
|
|
|
+ if (isTakeAll != null && isTakeAll) {
|
|
|
|
|
+ distributeMoneyApply.setVerifyStatus(UserMirrorShopDistributeMoneyApply.Status.verifying);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ TransferAccountsReq req = new TransferAccountsReq();
|
|
|
|
|
+ req.setMoney(needApplyMoney);
|
|
|
|
|
+ req.setAccount(applyMoneyReq.getAccount());
|
|
|
|
|
+ req.setName(applyMoneyReq.getRealName());
|
|
|
|
|
+ req.setChannelType(2);
|
|
|
|
|
+ req.setUserId(userId);
|
|
|
|
|
+ req.setRemark("镜像小店提现");
|
|
|
|
|
+ AlipayResponse alipayResponse = transferAccounts(req);
|
|
|
|
|
+ if (alipayResponse.isSuccess()) {
|
|
|
|
|
+ distributeMoneyApply.setVerifyStatus(UserMirrorShopDistributeMoneyApply.Status.success);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ distributeMoneyApply.setVerifyStatus(UserMirrorShopDistributeMoneyApply.Status.fail);
|
|
|
|
|
+ distributeMoneyApply.setReason(alipayResponse.getSubMsg());
|
|
|
|
|
+ userBenefitsService.addMpMoney(userId, distributeMoneyApply.getMoney());
|
|
|
|
|
+ if (StrUtil.equals(alipayResponse.getSubCode(), "SECURITY_CHECK_FAILED")) {
|
|
|
|
|
+ return GatewayResponse.FAIL.newBuilder().setMsg("当前支付宝提现人数较多,请稍后再试").toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (alipayResponse.getSubMsg().contains("冻结")) {
|
|
|
|
|
+ return GatewayResponse.FAIL.newBuilder().setMsg("目前财务清账中,48小时后可提现").toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+ if (alipayResponse.getSubMsg().contains("余额不足")) {
|
|
|
|
|
+ return GatewayResponse.FAIL.newBuilder().setMsg("转账失败,请联系客服").toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.FAIL.newBuilder().setMsg(alipayResponse.getSubMsg()).toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ userMirrorShopDistributeMoneyApplyMapper.insert(distributeMoneyApply);
|
|
|
|
|
+ //大额提现 超过400
|
|
|
|
|
+ if (envCommonService.isPrdEnv() && distributeMoneyApply.getVerifyStatus() == UserMirrorShopDistributeMoneyApply.Status.verifying && distributeMoneyApply.getMoney().compareTo(fourHundred) > 0) {
|
|
|
|
|
+ SmsUtil.sendLuoKey2Msg(Constant.ZK_MOBILE, "镜像小店有大额提现申请【银河录像局】");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ userBenefitsService.addMpMoney(userId, distributeMoneyApply.getMoney());
|
|
|
|
|
+ return GatewayResponse.FAIL.newBuilder().setMsg("网络错误,请重试").toResult();
|
|
|
|
|
+ }
|
|
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(distributeMoneyApply);
|
|
|
|
|
+ }
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("系统异常,请重新提交提现申请");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private AlipayRequest aliPayTransferAccountsRequest(String donNo, String account, String name, BigDecimal money, String remark) {
|
|
private AlipayRequest aliPayTransferAccountsRequest(String donNo, String account, String name, BigDecimal money, String remark) {
|
|
|
//支付宝转账
|
|
//支付宝转账
|
|
|
AlipayFundTransUniTransferRequest transUniTransferRequest = new AlipayFundTransUniTransferRequest();
|
|
AlipayFundTransUniTransferRequest transUniTransferRequest = new AlipayFundTransUniTransferRequest();
|