客户页面添加人员类别
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java b/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java
index 79a05ee..d6a30a0 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/controller/CustomerController.java
@@ -1,12 +1,15 @@
package com.supwisdom.dlpay.restaurant.controller;
+import com.google.gson.Gson;
import com.supwisdom.dlpay.api.bean.JsonResult;
import com.supwisdom.dlpay.framework.util.ExportExcel;
import com.supwisdom.dlpay.framework.util.PageResult;
import com.supwisdom.dlpay.framework.util.WebConstant;
import com.supwisdom.dlpay.restaurant.bean.CustomerSearchBean;
+import com.supwisdom.dlpay.restaurant.domain.TCustType;
import com.supwisdom.dlpay.restaurant.domain.TCustomer;
+import com.supwisdom.dlpay.restaurant.service.CustTypeService;
import com.supwisdom.dlpay.restaurant.service.CustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -18,6 +21,9 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
@Controller
@RequestMapping("/customer")
@@ -26,8 +32,19 @@
@Autowired
private CustomerService customerService;
+ @Autowired
+ private CustTypeService custTypeService;
+
@RequestMapping("/index")
public String indexView(ModelMap model) {
+ List<TCustType> lst = custTypeService.findAll();
+ Map<Integer, String> map = new HashMap<>();
+ for (TCustType type : lst) {
+ map.put(type.getCusttypeid(), type.getCusttypename());
+ }
+ Gson gson = new Gson();
+ String gsonString = gson.toJson(map);
+ model.put("custtypelist", gsonString);
return "restaurant/customer/index";
}
@@ -56,6 +73,8 @@
@GetMapping("/loadadd")
@PreAuthorize("hasPermission('/customer/loadadd','')")
public String loadadd(Model model) {
+ List<TCustType> list=custTypeService.findAll();
+ model.addAttribute("typelist",list);
return "restaurant/customer/form";
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/CustTypeService.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/CustTypeService.java
index 844b5a5..da62ea9 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/CustTypeService.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/CustTypeService.java
@@ -22,4 +22,8 @@
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
JsonResult deleteCusttype(Integer id);
+
+ @Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
+ List<TCustType> findAll();
+
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustTypeServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustTypeServiceImpl.java
index 34ff82e..dfae627 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustTypeServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustTypeServiceImpl.java
@@ -42,4 +42,9 @@
custTypeDao.deleteById(id);
return JsonResult.ok("成功");
}
+
+ @Override
+ public List<TCustType> findAll() {
+ return custTypeDao.findAll();
+ }
}
diff --git a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
index 2d1c455..db5ca4d 100644
--- a/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
+++ b/src/main/java/com/supwisdom/dlpay/restaurant/service/impl/CustomerServiceImpl.java
@@ -51,9 +51,11 @@
}
@Override
public JsonResult saveCustomer(TCustomer customer) {
- List<TCustomer> cus=customerDao.findAllByCardno(customer.getCardno());
- if(cus.size()!=0){
- return JsonResult.error("用户"+cus.get(0).getCustname()+"已拥有该卡");
+ if(StringUtil.isEmpty(customer.getCustid())){
+ List<TCustomer> cus=customerDao.findAllByCardno(customer.getCardno());
+ if(cus.size()!=0){
+ return JsonResult.error("用户"+cus.get(0).getCustname()+"已拥有该卡");
+ }
}
customer.setLastsaved(DateUtil.getNow("yyyyMMddHHmmss"));
customerDao.save(customer);
@@ -75,6 +77,7 @@
return JsonResult.ok("成功");
}
+
/*
private void saveCardver(String cardverno, String date, TCustomer cus) {
TCardver tCardver=new TCardver();
diff --git a/src/main/resources/templates/restaurant/customer/form.html b/src/main/resources/templates/restaurant/customer/form.html
index f324fac..757f63a 100644
--- a/src/main/resources/templates/restaurant/customer/form.html
+++ b/src/main/resources/templates/restaurant/customer/form.html
@@ -17,6 +17,15 @@
</div>
<div class="layui-form-item">
+ <label class="layui-form-label">人员类别</label>
+ <div class="layui-input-block">
+ <select name="custtype" id="customer-custtype" lay-verify="required">
+ <option th:each="type : ${typelist}" th:value="${type.custtypeid}">[[${type.custtypename}]]</option>
+ </select>
+ </div>
+ </div>
+
+ <div class="layui-form-item">
<label class="layui-form-label"><span style="color: red">* </span>银行卡号</label>
<div class="layui-input-block">
<input name="bankcardno" placeholder="请输入" type="text" class="layui-input" maxlength="30"
diff --git a/src/main/resources/templates/restaurant/customer/index.html b/src/main/resources/templates/restaurant/customer/index.html
index 9ebbf2b..47b1a9c 100644
--- a/src/main/resources/templates/restaurant/customer/index.html
+++ b/src/main/resources/templates/restaurant/customer/index.html
@@ -19,10 +19,12 @@
<table class="layui-table" id="customer-table" lay-filter="customer-table"></table>
</div>
</div>
-
+<input hidden th:value="${custtypelist}" id="custtypelist">
<script>
+ var rawlist=$("#custtypelist").val();
+ var custtypelist=JSON.parse(rawlist);
layui.use(['form', 'table', 'layer', 'admin', 'element'], function () {
let form = layui.form;
let table = layui.table;
@@ -40,9 +42,18 @@
{field: 'custid', title: '客户号',width: 140, sort: true},
{field: 'custname', sort: true, width: 150, title: '客户姓名'},
{field: 'cardno', sort: true, width: 150, title: '市名卡号'},
- {field: 'phone', sort: true, width: 200, title: '联系电话'},
+ {field: 'phone', sort: true, width: 140, title: '联系电话'},
{field: 'bankcardno', sort: true, width: 200, title: '银行卡号'},
{
+ field: 'custtype', width:100, title: '人员类别', templet: function (item) {
+ if(item.custtype==null){
+ return ''
+ }else{
+ return custtypelist[item.custtype];
+ }
+ }
+ },
+ {
field: 'custid', align: 'center', title: '操作', fixed: 'right', templet: function (item) {
return ' <a class="layui-btn layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a> '+
' <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>';