Browse Source

fix 提现

zoujiajian 3 years ago
parent
commit
0d2f5536b9

+ 3 - 0
netflix-dao/src/main/java/com/cyksj/mapper/manage/distribute/UserDistributeMapper.java

@@ -1,6 +1,7 @@
 package com.cyksj.mapper.manage.distribute;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.DistributeMoneyApply;
 import com.cyksj.model.entity.User;
 import com.cyksj.model.entity.UserDistribute;
 import com.cyksj.model.views.UserDistributeViews;
@@ -31,4 +32,6 @@ public interface UserDistributeMapper extends BaseMapper<UserDistribute> {
 	User getUserDistributeDetail(@Param("loginPhone") String loginPhone, @Param("email") String email);
 
 	Integer getDistributeGoodsRateByUidAndGid(@Param("userId") Long userId, @Param("goodsId") Long goodsId);
+
+	DistributeMoneyApply selectRelationBusiness(Long userId);
 }

+ 26 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/DistributeMoneyApply.java

@@ -1,5 +1,6 @@
 package com.cyksj.model.entity;
 
+import cn.hutool.core.util.StrUtil;
 import lombok.Getter;
 import lombok.Setter;
 
@@ -34,16 +35,41 @@ public class DistributeMoneyApply extends BaseEntity {
 
 	private String img;
 
+	/**
+	 * 钱包地址
+	 */
+	private String walletAddr;
+
+	/**
+	 * 备注
+	 */
+	private String remark;
+
+	private Long businessId;
+
+	private String businessName;
+
 	@Getter
 	public enum Type {
 		zfb("支付宝"),
 		wechat("微信"),
+		usdt("usdt"),
+		pwdRed("口令红包"),
+		other("其他")
 		;
 		String desc;
 
 		Type(String desc) {
 			this.desc = desc;
 		}
+
+		public Type getType(String value) {
+			if (StrUtil.isEmpty(value)) {
+				return null;
+			}
+			return Arrays.stream(Type.values()).filter(type -> type.name().equals(value)).findFirst().get();
+		}
+
 	}
 
 	@Getter

+ 10 - 0
netflix-dao/src/main/java/com/cyksj/model/request/ApplyMoneyReq.java

@@ -23,4 +23,14 @@ public class ApplyMoneyReq {
 	 * true提现所有积分金额
 	 */
 	private Boolean isTakeAll;
+
+	/**
+	 * 钱包地址
+	 */
+	private String walletAddr;
+
+	/**
+	 * 备注
+	 */
+	private String remark;
 }

+ 6 - 0
netflix-dao/src/main/resources/mapper/UserDistributeMapper.xml

@@ -95,4 +95,10 @@
                             on udr.distribute_id = ud.id
         where udr.goods_id = #{goodsId}
     </select>
+
+    <select id="selectRelationBusiness" resultType="com.cyksj.model.entity.DistributeMoneyApply">
+        select ud.business_id, cu.nickname as businessName
+        from (select business_id from user_distribute where user_id = #{userId} and deleted is true limit 1) ud
+                 inner join cms_user cu on cu.id = ud.business_id
+    </select>
 </mapper>

+ 24 - 5
netflix-web/src/main/java/com/cyksj/web/controller/user/DistributePopularizeController.java

@@ -243,11 +243,29 @@ public class DistributePopularizeController {
 		if (user == null) {
 			throw BusinessRuntimeException.getInstance("请先授权登录");
 		}
-		if (ObjectUtil.hasEmpty(applyMoneyReq.getAccount(), applyMoneyReq.getRealName())) {
-			throw BusinessRuntimeException.getInstance("必填项不能为空");
+		DistributeMoneyApply.Type type = applyMoneyReq.getType();
+		if (type != null && type == DistributeMoneyApply.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 != null && type == DistributeMoneyApply.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("备注过多");
+			}
 		}
-		if (applyMoneyReq.getAccount().length() > 255 || applyMoneyReq.getRealName().length() > 32) {
-			throw BusinessRuntimeException.getInstance("请输入正确的账户信息");
+		DistributeMoneyApply distributeMoneyApply = null;
+		if (type != null && type == DistributeMoneyApply.Type.pwdRed) {
+			distributeMoneyApply = userDistributeMapper.selectRelationBusiness(userId);
 		}
 		Boolean isTakeAll = applyMoneyReq.getIsTakeAll();
 		BigDecimal userPoints = user.getPoints();
@@ -275,12 +293,13 @@ public class DistributePopularizeController {
 		}
 		Integer update = userMapper.subPoints(user.getId(), needSubPoints);
 		if (update == 1) {
-			DistributeMoneyApply distributeMoneyApply = new DistributeMoneyApply();
 			distributeMoneyApply.setUserId(userId);
 			distributeMoneyApply.setPoints(needSubPoints);
 			distributeMoneyApply.setMoney(needApplyMoney);
 			distributeMoneyApply.setAccount(applyMoneyReq.getAccount());
 			distributeMoneyApply.setRealName(applyMoneyReq.getRealName());
+			distributeMoneyApply.setWalletAddr(applyMoneyReq.getWalletAddr());
+			distributeMoneyApply.setReason(applyMoneyReq.getRemark());
 			if (isTakeAll != null && isTakeAll) {
 				distributeMoneyApply.setVerifyStatus(DistributeMoneyApply.Status.verifying);
 			} else {