From 34f741f39e22bf48df33321230380b40c23110c3 Mon Sep 17 00:00:00 2001
From: huliguo <2023611923@qq.com>
Date: 星期五, 18 四月 2025 21:34:13 +0800
Subject: [PATCH] 店铺、积分、订单

---
 ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserApplyForAdmissionServiceImpl.java |   92 ++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 92 insertions(+), 0 deletions(-)

diff --git a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserApplyForAdmissionServiceImpl.java b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserApplyForAdmissionServiceImpl.java
index 5a506dc..eb83a31 100644
--- a/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserApplyForAdmissionServiceImpl.java
+++ b/ruoyi-service/ruoyi-account/src/main/java/com/ruoyi/account/service/impl/UserApplyForAdmissionServiceImpl.java
@@ -1,19 +1,31 @@
 package com.ruoyi.account.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ruoyi.account.api.model.AppUser;
+import com.ruoyi.account.api.model.AppUserShop;
 import com.ruoyi.account.api.model.ApplyForAdmission;
 import com.ruoyi.account.dto.ApplyForAdmissionDTO;
+import com.ruoyi.account.dto.ApplyReviewDTO;
 import com.ruoyi.account.mapper.AppUserMapper;
 import com.ruoyi.account.mapper.ApplyForAdmissionMapper;
 import com.ruoyi.account.service.AppUserService;
+import com.ruoyi.account.service.AppUserShopService;
 import com.ruoyi.account.service.UserApplyForAdmissionService;
 import com.ruoyi.account.util.tencentMap.TencentMapUtil;
+import com.ruoyi.account.vo.ApplyForAdmissionDetailVO;
+import com.ruoyi.account.vo.ApplyForAdmissionListVO;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.security.service.TokenService;
+import com.ruoyi.other.api.domain.Phone;
 import com.ruoyi.other.api.domain.Region;
+import com.ruoyi.other.api.domain.Shop;
+import com.ruoyi.other.api.feignClient.PhoneClient;
 import com.ruoyi.other.api.feignClient.RegionClient;
+import com.ruoyi.other.api.feignClient.ShopClient;
+import com.ruoyi.system.api.model.UserShop;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -34,6 +46,14 @@
     private AppUserService appUserService;
     @Resource
     private RegionClient regionClient;
+    @Resource
+    private ShopClient shopClient;
+    @Resource
+    private PhoneClient phoneClient;
+
+    @Autowired
+    private AppUserShopService appUserShopService;
+
 
     /**
      * 申请入驻
@@ -69,4 +89,76 @@
                         .orderByDesc(ApplyForAdmission::getCreateTime)  // 按申请日期降序
                         .last("LIMIT 1"));
     }
+
+    @Override
+    public IPage<ApplyForAdmissionListVO> getApplyList(Integer pageNum, Integer pageSize, String shopName, String shopManager, String phone, Integer status) {
+        Page<ApplyForAdmissionListVO> page = new Page<>(pageNum, pageSize);
+        return userApplyForAdmissionMapper.selectApplyList(page, shopName, shopManager, phone, status);
+    }
+
+    @Override
+    public ApplyForAdmissionDetailVO getApplyDetail(Integer id) {
+        ApplyForAdmission apply = userApplyForAdmissionMapper.selectById(id);
+        if (apply == null) {
+            throw new RuntimeException("申请记录不存在");
+        }
+
+        ApplyForAdmissionDetailVO detail = new ApplyForAdmissionDetailVO();
+        BeanUtils.copyProperties(apply, detail);
+        detail.setFullAddress(apply.getAddress() + apply.getDetailAddress());
+        return detail;
+    }
+
+    @Override
+    public void review(ApplyReviewDTO applyReviewDTO) {
+        ApplyForAdmission apply = userApplyForAdmissionMapper.selectById(applyReviewDTO.getId());
+        if (apply == null) {
+            throw new RuntimeException("申请记录不存在");
+        }
+        if (apply.getStatus() != 0) {
+            throw new RuntimeException("该记录已审核过");
+        }
+        if(applyReviewDTO.getStatus()==2){
+            //审核不通过
+            apply.setStatus(2);
+            apply.setRemark(applyReviewDTO.getRemark());
+            apply.setUpdateTime(LocalDateTime.now());
+            this.updateById(apply);
+            return;
+        }
+        //审核通过
+        apply.setStatus(1);
+        apply.setUpdateTime(LocalDateTime.now());
+        this.updateById(apply);
+
+        //先加入商店
+        Shop shop = new Shop();
+        BeanUtils.copyProperties(apply, shop);
+        shop.setName(apply.getShopName());
+        shop.setBusinessTime(apply.getBusinessTime());
+        shop.setAppUserId(apply.getApplyUserId());
+        shop.setCreateTime(LocalDateTime.now());
+        R shopR = shopClient.insert(shop);
+        if (shopR.getCode()!=200){
+            throw new RuntimeException("添加店铺失败");
+        }
+        Integer shopId = (Integer) shopR.getData();
+        //加入usershop
+        AppUserShop userShop = new AppUserShop();
+        userShop.setAppUserId(apply.getApplyUserId());
+        userShop.setShopId(shopId);
+        appUserShopService.save(userShop);
+        //加入客服手机号
+        Phone phone = new Phone();
+        phone.setType(2);//门店
+        phone.setPhoneOne(apply.getServiceTel());
+        phone.setShopId(shop.getId());
+        R phoneR = phoneClient.insert(phone);
+        if (phoneR.getCode()!=200){
+            throw new RuntimeException("添加店铺客服电话失败");
+        }
+
+
+    }
+
 }

--
Gitblit v1.7.1