From d47060658f33b38688b41224bb787370547e7c7d Mon Sep 17 00:00:00 2001
From: zjh <1084500556@qq.com>
Date: 星期一, 20 五月 2024 17:43:12 +0800
Subject: [PATCH] zjh 2024/05/20-1

---
 ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjCustomerBlackController.java |  105 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 103 insertions(+), 2 deletions(-)

diff --git a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjCustomerBlackController.java b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjCustomerBlackController.java
index bb2d489..fd75f5b 100644
--- a/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjCustomerBlackController.java
+++ b/ltkj-admin/src/main/java/com/ltkj/web/controller/system/TjCustomerBlackController.java
@@ -1,15 +1,116 @@
 package com.ltkj.web.controller.system;
 
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+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.ltkj.common.core.controller.BaseController;
+import com.ltkj.common.core.domain.AjaxResult;
+import com.ltkj.hosp.domain.TjCustomer;
+import com.ltkj.hosp.domain.TjCustomerBlack;
+import com.ltkj.hosp.service.*;
+import com.ltkj.system.service.ISysConfigService;
 import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import javax.annotation.Resource;
+import java.util.Date;
+import java.util.List;
 
 @RestController
 @RequestMapping("/hosp/cusBlack")
 @Api(tags = "PC绔� ----浣撴榛戝悕鍗曡褰曟帴鍙�")
 @Slf4j
 public class TjCustomerBlackController extends BaseController {
+    @Resource
+    private ITjCustomerService customerService;
+    @Resource
+    private TjCustomerBlackService blackService;
+    @Resource
+    private ITjOrderService tjOrderService;
+    @Autowired
+    private ISysConfigService configService;
 
+    @PostMapping("/addCustomerBlack")
+    @ApiOperation(value = "娣诲姞榛戝悕鍗�")
+    public AjaxResult addCustomerBlack(@RequestBody TjCustomerBlack customerBlack) {
+//        TjCustomer customer = customerService.getTjCustomerByCusIdCard(String.valueOf(customerBlack.getCusId()));
+        TjCustomer customer = customerService.getById(customerBlack.getCusId());
+        if (null != customer) {
+            LambdaQueryWrapper<TjCustomerBlack>wq=new LambdaQueryWrapper<>();
+            wq.eq(TjCustomerBlack::getCusId,customer.getCusId());
+            wq.eq(TjCustomerBlack::getIsExpiration,"N");
+           TjCustomerBlack tjCustomerBlack = blackService.getOne(wq);
+            if(null !=tjCustomerBlack){
+                return AjaxResult.error("璇ヤ汉鍛樺凡缁忔槸榛戝悕鍗�  涓嶅彲閲嶅鍔犲叆!");
+            }
+            customerBlack.setCusId(customer.getCusId());
+            String days = customerBlack.getDays();
+            if(null ==days){
+                days = configService.selectConfigByKey("Blacklist");
+                customerBlack.setDays(days);
+            }
+            DateTime day = DateUtil.offsetDay(new Date(), Integer.parseInt(days));
+            customerBlack.setExpirationTime(day);
+            customerBlack.setIsExpiration("N");
+            customerBlack.setCusName(customer.getCusName());
+            customerBlack.setCusPhone(customer.getCusPhone());
+            return AjaxResult.success(blackService.save(customerBlack));
+        }
+        return AjaxResult.success("璇ヤ汉鍛樹笉瀛樺湪!");
+    }
+
+    @PutMapping("/putCustomerBlack")
+    @ApiOperation(value = "淇敼榛戝悕鍗�")
+    public AjaxResult putCustomerBlack(@RequestBody TjCustomerBlack customerBlack) {
+
+        String days = customerBlack.getDays();
+        if(null ==days){
+             days = configService.selectConfigByKey("Blacklist");
+        }
+        DateTime day = DateUtil.offsetDay(new Date(), Integer.parseInt(days));
+        customerBlack.setExpirationTime(day);
+        if(day.before(new Date())){
+            customerBlack.setIsExpiration("Y");
+        }else {
+            customerBlack.setIsExpiration("N");
+        }
+        return AjaxResult.success(blackService.updateById(customerBlack));
+    }
+
+    @DeleteMapping("/delCustomerBlack")
+    @ApiOperation(value = "鍒犻櫎榛戝悕鍗�")
+    public AjaxResult delCustomerBlack(@RequestBody TjCustomerBlack customerBlack) {
+        return AjaxResult.success(blackService.save(customerBlack));
+    }
+
+
+    @GetMapping("/getCustomerBlack")
+    @ApiOperation(value = "鏌ヨ榛戝悕鍗曞垪琛�")
+    public AjaxResult getCustomerBlack(@RequestParam(required = false) @ApiParam(value = "瀹㈡埛濮撳悕") String name,
+                                       @RequestParam(required = false) @ApiParam(value = "瀹㈡埛鎵嬫満鍙�") String phone,
+                                       @RequestParam(defaultValue = "1") @ApiParam(value = "椤电爜鏁�") Integer page,
+                                       @RequestParam(defaultValue = "10") @ApiParam(value = "姣忛〉鏄剧ず鏉℃暟") Integer pageSize) {
+
+        LambdaQueryWrapper<TjCustomerBlack>wq=new LambdaQueryWrapper<>();
+        wq.eq(TjCustomerBlack::getIsExpiration,"N");
+        if(null !=name)wq.like(TjCustomerBlack::getCusName,name);
+        if(null !=phone)wq.like(TjCustomerBlack::getCusPhone,phone);
+        IPage<TjCustomerBlack> pages=new Page<>(page,pageSize);
+        IPage<TjCustomerBlack> iPage = blackService.page(pages, wq);
+        List<TjCustomerBlack> list = iPage.getRecords();
+        if(null !=list && list.size()>0){
+            for (TjCustomerBlack black : list) {
+                TjCustomer customer = customerService.getById(black.getCusId());
+                black.setCusName(customer.getCusName());
+                black.setCusSex(customer.getCusSex());
+                black.setTjCompName(customerService.getCompNameByCusId(String.valueOf(black.getCusId())));
+            }
+        }
+        return AjaxResult.success(iPage);
+    }
 }

--
Gitblit v1.8.0