hmp 4 ani în urmă
părinte
comite
a5a7c48a33

+ 30 - 0
src/main/java/org/springblade/common/enums/ShopEnum.java

@@ -0,0 +1,30 @@
+package org.springblade.common.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * @author cy-computer
+ */
+@AllArgsConstructor
+@Getter
+public enum ShopEnum {
+	/**
+	 * 待审核
+	 */
+	WAITING("WAITING"),
+	/**
+	 * 审核通过
+	 */
+	PASS("PASS"),
+	/**
+	 * 审核不通过
+	 */
+	FAIL("FAIL"),
+	/**
+	 * 停用
+	 */
+	STOP("STOP");
+
+	private String name;
+}

+ 26 - 12
src/main/java/org/springblade/gateway/shop_gateway/controller/AppAccountController.java

@@ -1,5 +1,6 @@
 package org.springblade.gateway.shop_gateway.controller;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.lang.Assert;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
@@ -8,13 +9,17 @@ import io.swagger.annotations.ApiOperation;
 import lombok.AllArgsConstructor;
 import lombok.SneakyThrows;
 import org.springblade.common.enums.ResCode;
+import org.springblade.common.enums.ShopEnum;
 import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.mp.support.Condition;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.DigestUtil;
 import org.springblade.gateway.shop_gateway.entity.dto.AppAccountDto;
 import org.springblade.ldt.account.entity.Account;
 import org.springblade.ldt.account.service.IAccountService;
+import org.springblade.ldt.shop.entity.Shop;
+import org.springblade.ldt.shop.service.IShopService;
 import org.springblade.modules.resource.utils.SmsUtil;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -23,7 +28,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.util.List;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 /**
  * @author cy-computer
@@ -35,35 +42,42 @@ import java.util.Objects;
 public class AppAccountController {
 
 	private IAccountService accountService;
+	private IShopService shopService;
 
 	@PostMapping("login")
-	@ApiOperation(value = "商户商场登录")
+	@ApiOperation(value = "商户登录")
 	@SneakyThrows
-	public R login(@RequestBody @Valid Account account) throws ServiceException  {
-
+	public R login(@RequestBody @Valid Account account) throws ServiceException {
 		Account user = accountService.getOne(new QueryWrapper<Account>().lambda().eq(Account::getPhone, account.getPhone()));
-		Assert.notNull(user,() ->{throw new ServiceException(ResCode.USER_NOT_FOUNT);});
-		Assert.isTrue(Objects.equals(user.getSecret(), DigestUtil.hex(account.getSecret())),() -> {
+		Assert.notNull(user, () -> {
+			throw new ServiceException(ResCode.USER_NOT_FOUNT);
+		});
+		Assert.isTrue(Objects.equals(user.getSecret(), DigestUtil.hex(account.getSecret())), () -> {
 			throw new ServiceException(ResCode.USER_PWS_ERROR);
 		});
-		return R.data(user);
+		List<Shop> list = shopService.list(Condition.getQueryWrapper(new Shop()).lambda().eq(Shop::getPersonTel, account.getPhone()));
+		return R.data(list);
 	}
 
 	@PostMapping("register")
 	@ApiOperation(value = "注册账号")
 	@SneakyThrows
-	public R register(@RequestBody  @Valid AppAccountDto appAccountDto) {
+	public R register(@RequestBody @Valid AppAccountDto appAccountDto) {
+		Account isExit = accountService.getOne(Condition.getQueryWrapper(new Account()).lambda().eq(Account::getPhone, appAccountDto.getPhone()));
+		Assert.isNull(isExit, "该手机号已注册");
 
-		Assert.isTrue(SmsUtil.validateMessage(null,appAccountDto.getSmsId(),appAccountDto.getValue(),appAccountDto.getPhone()),
-			()->{ throw new ServiceException(ResCode.VALIDATE_FAIL); });
+		Assert.isTrue(SmsUtil.validateMessage(null, appAccountDto.getSmsId(), appAccountDto.getValue(), appAccountDto.getPhone()),
+			() -> {
+				throw new ServiceException(ResCode.VALIDATE_FAIL);
+			});
 		Account account = new Account();
-		BeanUtil.copyProperties(appAccountDto,account);
+		BeanUtil.copyProperties(appAccountDto, account);
 		account.setSecret(DigestUtil.hex(account.getSecret()));
-		Assert.isTrue(accountService.saveOrUpdate(account),()->{
+		Assert.isTrue(accountService.saveOrUpdate(account), () -> {
 			throw new ServiceException(ResCode.SHOP_REGISTER_ERROR);
 		});
 		return R.data(account);
-
 	}
 
+
 }

+ 38 - 0
src/main/java/org/springblade/gateway/shop_gateway/controller/AppShopController.java

@@ -0,0 +1,38 @@
+package org.springblade.gateway.shop_gateway.controller;
+
+import io.swagger.annotations.ApiOperation;
+import lombok.SneakyThrows;
+import org.springblade.core.tool.api.R;
+import io.swagger.annotations.Api;
+import lombok.AllArgsConstructor;
+import org.springblade.gateway.shop_gateway.entity.dto.ShopAuditDto;
+import org.springblade.ldt.shop.entity.Audit;
+import org.springblade.ldt.shop.entity.Shop;
+import org.springblade.ldt.shop.service.IShopService;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * @author cy-computer
+ */
+@RestController
+@RequestMapping("/shop")
+@Api(tags = "商户控制层")
+@AllArgsConstructor
+public class AppShopController {
+
+	@Resource
+	private IShopService shopService;
+
+	@PostMapping("submitAudit")
+	@ApiOperation(value = "商户提交审核")
+	@SneakyThrows
+	public R submitAudit(@RequestBody ShopAuditDto shopAuditDto) {
+		shopService.submitAudit(shopAuditDto);
+		return R.success("提交成功");
+	}
+}

+ 14 - 0
src/main/java/org/springblade/gateway/shop_gateway/entity/dto/ShopAuditDto.java

@@ -0,0 +1,14 @@
+package org.springblade.gateway.shop_gateway.entity.dto;
+
+import lombok.Data;
+import org.springblade.ldt.shop.entity.Audit;
+import org.springblade.ldt.shop.entity.Shop;
+
+/**
+ * @author cy-computer
+ */
+@Data
+public class ShopAuditDto {
+	private Shop shop;
+	private Audit audit;
+}

+ 8 - 0
src/main/java/org/springblade/ldt/shop/service/IShopService.java

@@ -16,6 +16,8 @@
  */
 package org.springblade.ldt.shop.service;
 
+import org.springblade.gateway.shop_gateway.entity.dto.ShopAuditDto;
+import org.springblade.ldt.shop.entity.Audit;
 import org.springblade.ldt.shop.entity.Shop;
 import org.springblade.ldt.shop.vo.ShopVO;
 import com.baomidou.mybatisplus.extension.service.IService;
@@ -38,4 +40,10 @@ public interface IShopService extends IService<Shop> {
 	 */
 	IPage<ShopVO> selectShopPage(IPage<ShopVO> page, ShopVO shop);
 
+	/**
+	 * 商户提交审核
+	 * @param shopAuditDto
+
+	 */
+    void submitAudit(ShopAuditDto shopAuditDto);
 }

+ 19 - 0
src/main/java/org/springblade/ldt/shop/service/impl/ShopServiceImpl.java

@@ -16,13 +16,20 @@
  */
 package org.springblade.ldt.shop.service.impl;
 
+import cn.hutool.core.util.RandomUtil;
+import org.springblade.gateway.shop_gateway.entity.dto.ShopAuditDto;
+import org.springblade.ldt.shop.entity.Audit;
 import org.springblade.ldt.shop.entity.Shop;
+import org.springblade.ldt.shop.service.IAuditService;
 import org.springblade.ldt.shop.vo.ShopVO;
 import org.springblade.ldt.shop.mapper.ShopMapper;
 import org.springblade.ldt.shop.service.IShopService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
 
 /**
  *  服务实现类
@@ -33,9 +40,21 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 @Service
 public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop> implements IShopService {
 
+	@Resource
+	private IAuditService auditService;
+
 	@Override
 	public IPage<ShopVO> selectShopPage(IPage<ShopVO> page, ShopVO shop) {
 		return page.setRecords(baseMapper.selectShopPage(page, shop));
 	}
 
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void submitAudit(ShopAuditDto shopAuditDto) {
+		Shop shop = shopAuditDto.getShop();
+		Audit audit = shopAuditDto.getAudit();
+		this.save(shop);
+		auditService.save(audit);
+	}
+
 }

+ 2 - 1
src/main/java/org/springblade/modules/resource/utils/SmsUtil.java

@@ -17,6 +17,7 @@
 package org.springblade.modules.resource.utils;
 
 import cn.hutool.core.convert.Convert;
+import cn.hutool.core.util.RandomUtil;
 import org.springblade.core.sms.model.SmsCode;
 import org.springblade.core.sms.model.SmsData;
 import org.springblade.core.sms.model.SmsResponse;
@@ -66,7 +67,7 @@ public class SmsUtil {
 	 */
 	public static Map<String, String> getValidateParams() {
 		Map<String, String> params = new HashMap<>(1);
-		params.put(PARAM_KEY, StringUtil.random(6, RandomType.INT));
+		params.put(PARAM_KEY, RandomUtil.randomNumbers(6));
 		return params;
 	}