From a8d2cb07f6440dc54dc4005b0b06d5a47cb1517d Mon Sep 17 00:00:00 2001
From: luodangjia <luodangjia>
Date: 星期一, 16 十二月 2024 13:34:03 +0800
Subject: [PATCH] 12.16

---
 ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PhoneController.java |   72 +++++++++++++++++++++++++++++++++--
 1 files changed, 67 insertions(+), 5 deletions(-)

diff --git a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PhoneController.java b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PhoneController.java
index ff065e3..d918033 100644
--- a/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PhoneController.java
+++ b/ruoyi-service/ruoyi-other/src/main/java/com/ruoyi/other/controller/PhoneController.java
@@ -4,15 +4,16 @@
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.core.web.controller.BaseController;
+import com.ruoyi.common.security.service.TokenService;
 import com.ruoyi.other.api.domain.Phone;
 import com.ruoyi.other.enums.PhoneType;
 import com.ruoyi.other.service.PhoneService;
+import com.ruoyi.system.api.domain.SysUser;
+import com.ruoyi.system.api.feignClient.SysUserClient;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import java.util.List;
@@ -31,16 +32,77 @@
 public class PhoneController extends BaseController {
     @Resource
     private PhoneService phoneService;
+    
+    @Resource
+    private TokenService tokenService;
+    
+    @Resource
+    private SysUserClient sysUserClient;
+    
+    
+    
 
     /**
      * 查询指定门店手机号
      */
-    @RequestMapping("/selectPhoneByShopId")
-    @ApiOperation(value = "查询指定门店手机号", tags = {"小程序-门店详情"})
+    @GetMapping("/selectPhoneByShopId")
+    @ApiOperation(value = "查询指定门店手机号", tags = {"小程序-首页-门店详情"})
     public R<List<Phone>> getPhoneByShopId(@ApiParam("门店id") @RequestParam Integer shopId) {
         return R.ok(phoneService.list(new LambdaQueryWrapper<Phone>()
                 .eq(Phone::getType, PhoneType.SHOP.getCode())
                 .eq(Phone::getShopId, shopId)));
     }
+    
+    
+    
+    @GetMapping("/getSysPhone")
+    @ApiOperation(value = "获取客服电话", tags = {"管理后台-客服电话", "门店后台-客服电话"})
+    public R<Phone> getSysPhone(){
+        Long userid = tokenService.getLoginUser().getUserid();
+        SysUser sysUser = sysUserClient.getSysUser(userid).getData();
+        LambdaQueryWrapper<Phone> wrapper = new LambdaQueryWrapper<>();
+        if(sysUser.getRoleType() == 1){
+            wrapper.eq(Phone::getType, 1);
+        }else{
+            wrapper.eq(Phone::getType, 2).eq(Phone::getShopId, sysUser.getObjectId());
+        }
+        Phone one = phoneService.getOne(wrapper);
+        return R.ok(one);
+    }
+    
+    
+    
+    @PostMapping("/savePhone")
+    @ApiOperation(value = "保存客服电话", tags = {"管理后台-客服电话", "门店后台-客服电话"})
+    public R savePhone(@RequestBody Phone phone){
+        Long userid = tokenService.getLoginUser().getUserid();
+        SysUser sysUser = sysUserClient.getSysUser(userid).getData();
+        //平台配置
+        if(sysUser.getRoleType() == 1){
+            Phone one = phoneService.getOne(new LambdaQueryWrapper<Phone>().eq(Phone::getType, 1));
+            if(null != one){
+                one.setPhoneOne(phone.getPhoneOne());
+                one.setPhoneTwo(phone.getPhoneTwo());
+                phoneService.updateById(one);
+            }else{
+                phone.setType(1);
+                phoneService.save(phone);
+            }
+        }else{
+            //门店配置
+            Phone one = phoneService.getOne(new LambdaQueryWrapper<Phone>().eq(Phone::getType, 2).eq(Phone::getShopId, sysUser.getObjectId()));
+            if(null != one){
+                one.setPhoneOne(phone.getPhoneOne());
+                one.setPhoneTwo(phone.getPhoneTwo());
+                phoneService.updateById(one);
+            }else{
+                phone.setType(2);
+                phone.setShopId(sysUser.getObjectId());
+                phoneService.save(phone);
+            }
+        }
+        return R.ok();
+    }
+    
 }
 

--
Gitblit v1.7.1