Bladeren bron

系统创建用户店铺

zoujiajian 2 jaren geleden
bovenliggende
commit
f3b85cc940

+ 3 - 0
netflix-service/src/main/java/com/cyksj/service/cps/shop/YhShopManageService.java

@@ -3,6 +3,7 @@ package com.cyksj.service.cps.shop;
 import cn.hutool.core.date.DateTime;
 import com.cyksj.dto.Result;
 import com.cyksj.model.entity.User;
+import com.cyksj.model.entity.YhShop;
 import com.cyksj.model.request.YhShopApplyMoneyReq;
 import com.cyksj.model.views.YhShopBrokenLineCpsUserWMoneyView;
 import com.cyksj.model.views.YhShopUserWMoneyStatisticsDataView;
@@ -33,4 +34,6 @@ public interface YhShopManageService {
 	User yhShopManageRedirect(long userId);
 
 	Result applyMoney(YhShopApplyMoneyReq applyMoneyReq) throws Exception;
+
+	void addUserShop(YhShop yhShop);
 }

+ 38 - 7
netflix-service/src/main/java/com/cyksj/service/cps/shop/YhShopManageServiceImpl.java

@@ -5,29 +5,31 @@ import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.lang.Validator;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
-import com.cyksj.common.EnvCommonService;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.SmsUtil;
 import com.cyksj.common.util.StringUtil;
 import com.cyksj.dto.Result;
 import com.cyksj.mapper.UserMapper;
-import com.cyksj.mapper.shop.YhShopDistributeMoneyApplyMapper;
+import com.cyksj.mapper.manage.distribute.UserDistributeMapper;
+import com.cyksj.mapper.shop.YhShopApplyRecordMapper;
 import com.cyksj.mapper.shop.YhShopDistributeWaitingSendPointsMapper;
 import com.cyksj.mapper.shop.YhShopMapper;
 import com.cyksj.model.entity.User;
+import com.cyksj.model.entity.UserDistribute;
 import com.cyksj.model.entity.YhShop;
+import com.cyksj.model.entity.YhShopApplyRecord;
 import com.cyksj.model.request.YhShopApplyMoneyReq;
 import com.cyksj.model.views.YhShopBrokenLineCpsUserWMoneyView;
 import com.cyksj.model.views.YhShopUserWMoneyStatisticsDataView;
 import com.cyksj.redis.RedisService;
 import com.cyksj.service.mail.MailService;
 import com.cyksj.service.pay.TransferFuncService;
-import com.cyksj.service.user.UserBenefitsService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
+import java.util.Optional;
 
 /*
  *项目名: yhlxj
@@ -48,13 +50,11 @@ public class YhShopManageServiceImpl implements YhShopManageService{
 
 	private final TransferFuncService transferFuncService;
 
-	private final UserBenefitsService userBenefitsService;
-
 	private final YhShopDistributeWaitingSendPointsMapper yhShopDistributeWaitingSendPointsMapper;
 
-	private final YhShopDistributeMoneyApplyMapper yhShopDistributeMoneyApplyMapper;
+	private final YhShopApplyRecordMapper yhShopApplyRecordMapper;
 
-	private final EnvCommonService envCommonService;
+	private final UserDistributeMapper userDistributeMapper;
 
 	@Override
 	public void getLoginCode(Integer type, String login, Integer cid) {
@@ -186,4 +186,35 @@ public class YhShopManageServiceImpl implements YhShopManageService{
 		}
 		return today;
 	}
+
+	@Override
+	@Transactional(rollbackFor = Throwable.class)
+	public void addUserShop(YhShop yhShop) {
+		Long userId = yhShop.getUserId();
+		Integer count = yhShopMapper.selectCount(Wrappers.lambdaQuery(YhShop.class)
+				.eq(YhShop::getUserId, userId));
+		if (count > 0) {
+			return;
+		}
+		yhShop.setVerifyStatus(YhShop.Status.success);
+		Optional.ofNullable(userDistributeMapper.selectOne(Wrappers.lambdaQuery(UserDistribute.class)
+				.eq(UserDistribute::getUserId, userId)
+				.eq(UserDistribute::getDeleted, 1)
+				.last("limit 1"))).ifPresent(e->{
+			yhShop.setBusinessId(e.getBusinessId());
+		});
+		if (yhShop.getBusinessId() != null) {
+			yhShop.setBusinessBindTime(DateTime.now());
+		}
+
+		yhShopMapper.insert(yhShop);
+
+		YhShopApplyRecord yhShopApplyRecord = new YhShopApplyRecord();
+		yhShopApplyRecord.setName(yhShop.getName());
+		yhShopApplyRecord.setUserId(userId);
+		yhShopApplyRecord.setCustomId(yhShop.getCustomId());
+		yhShopApplyRecord.setVerifyStatus(YhShopApplyRecord.Status.success);
+		yhShopApplyRecord.setBusinessId(yhShop.getBusinessId());
+		yhShopApplyRecordMapper.insert(yhShopApplyRecord);
+	}
 }

+ 9 - 0
netflix-web/src/main/java/com/cyksj/web/controller/manage/goods/shop/YhShopUserController.java

@@ -264,4 +264,13 @@ public class YhShopUserController {
 		applyMoneyReq.setUserId(userId);
 		return yhShopManageService.applyMoney(applyMoneyReq);
 	}
+
+	/**
+	 * 后台添加用户店铺
+	 */
+	@PostMapping("/add/user/shop")
+	public Result<String> addUserShop(@RequestBody YhShop yhShop) {
+		yhShopManageService.addUserShop(yhShop);
+		return GatewayResponse.SUCCESS.newBuilder().toResult();
+	}
 }