From 9a56c5710eb281afc06e2f3a211b8b595f24bbe1 Mon Sep 17 00:00:00 2001
From: liujie <liujie>
Date: 星期三, 16 八月 2023 09:39:34 +0800
Subject: [PATCH] update
---
management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java | 125 ++++++++++++++++++++++++++++++++++++++---
1 files changed, 116 insertions(+), 9 deletions(-)
diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java
index 67041e2..f0266f0 100644
--- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java
+++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java
@@ -1,6 +1,7 @@
package com.stylefeng.guns.modular.system.controller.general;
import cn.hutool.crypto.SecureUtil;
+import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.base.controller.BaseController;
@@ -112,6 +113,41 @@
model.addAttribute("item",tBranchOfficeResp);
LogObjectHolder.me().set(tBranchOffice);
+
+ TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 5)
+ .eq("companyId", tBranchOfficeId).last("LIMIT 1"));
+ if(null != tSystemConfig){
+ JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
+ JSONArray array = jsonObject.getJSONArray("ChargeStandard");
+ JSONArray objects = new JSONArray();
+ for (int i = 0; i < array.size(); i++) {
+ JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(array.get(i)));
+ if(i == 0){
+ jsonObject1.put("key",0);
+ }else {
+ jsonObject1.put("key",1);
+ }
+ objects.add(jsonObject1);
+ }
+ TSystemConfig config = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 8)
+ .eq("companyId", tBranchOfficeId).last("LIMIT 1"));
+ JSONObject jsonObj = JSONObject.parseObject(config.getContent());
+ Integer zcOne = jsonObj.getInteger("num1");
+ String serviceTel = jsonObj.getString("num2");
+ Integer zcTwo = jsonObj.getInteger("num3");
+ model.addAttribute("zcOne", zcOne);
+ model.addAttribute("serviceTel", serviceTel);
+ model.addAttribute("zcTwo", zcTwo);
+ model.addAttribute("array",objects);
+ JSONObject extraCost = JSONObject.parseObject(jsonObject.getString("ExtraCost"));
+ model.addAttribute("ExtraCost",extraCost);
+ }else{
+ model.addAttribute("zcOne",1);
+ model.addAttribute("serviceTel", "");
+ model.addAttribute("zcTwo", 1);
+ model.addAttribute("array",null);
+ model.addAttribute("ExtraCost",null);
+ }
return PREFIX + "tBranchOffice_edit.html";
}
@@ -125,6 +161,40 @@
JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
model.addAttribute("num2",jsonObject.getInteger("num2"));
model.addAttribute("num3",jsonObject.getInteger("num3"));
+ TSystemConfig tSystemConfig1 = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 5)
+ .eq("companyId", tBranchOfficeId).last("LIMIT 1"));
+ if(null != tSystemConfig1){
+ JSONObject jsonObject2 = JSONObject.parseObject(tSystemConfig1.getContent());
+ JSONArray array = jsonObject2.getJSONArray("ChargeStandard");
+ JSONArray objects = new JSONArray();
+ for (int i = 0; i < array.size(); i++) {
+ JSONObject jsonObject1 = JSONObject.parseObject(JSONObject.toJSONString(array.get(i)));
+ if(i == 0){
+ jsonObject1.put("key",0);
+ }else {
+ jsonObject1.put("key",1);
+ }
+ objects.add(jsonObject1);
+ }
+ TSystemConfig config = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 8)
+ .eq("companyId", tBranchOfficeId).last("LIMIT 1"));
+ JSONObject jsonObj = JSONObject.parseObject(config.getContent());
+ Integer zcOne = jsonObj.getInteger("num1");
+ String serviceTel = jsonObj.getString("num2");
+ Integer zcTwo = jsonObj.getInteger("num3");
+ model.addAttribute("zcOne", zcOne);
+ model.addAttribute("serviceTel", serviceTel);
+ model.addAttribute("zcTwo", zcTwo);
+ model.addAttribute("array",objects);
+ JSONObject extraCost = JSONObject.parseObject(jsonObject2.getString("ExtraCost"));
+ model.addAttribute("ExtraCost",extraCost);
+ }else{
+ model.addAttribute("zcOne",1);
+ model.addAttribute("serviceTel", "");
+ model.addAttribute("zcTwo", 1);
+ model.addAttribute("array",null);
+ model.addAttribute("ExtraCost",null);
+ }
return PREFIX + "tBranchOfficeDetail.html";
}
@@ -309,16 +379,15 @@
@RequestMapping(value = "/add")
@ResponseBody
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW)
- public Object add(TBranchOffice tBranchOffice) {
- int count = tBranchOfficeService.selectCount(new EntityWrapper<TBranchOffice>().eq("branchOfficeName", tBranchOffice.getBranchOfficeName()));
+ public Object add(TBranchOffice tBranchOffice, Integer systemPriceType, String systemPriceContent, Integer isTaxiCar, Integer holiday, String serviceTel) {
+ int count = tBranchOfficeService.selectCount(new EntityWrapper<TBranchOffice>().eq("branchOfficeName", tBranchOffice.getBranchOfficeName()).ne("status", 3));
if(count>0){
return new SuccessTip(500,"该分公司名称已存在!");
}
- int count1 = userService.selectCount(new EntityWrapper<User>().eq("account", tBranchOffice.getAccount()));
+ int count1 = userService.selectCount(new EntityWrapper<User>().eq("account", tBranchOffice.getAccount()).ne("status", 3));
if (count1 > 0){
return new SuccessTip(500,"该账号已存在!");
}
-
Object o = tBranchOfficeService.addOrUpdate(tBranchOffice);
if(Objects.nonNull(o)){
return o;
@@ -342,7 +411,17 @@
user.setName(tBranchOffice.getPrincipal());
user.setSex(1);
userService.insert(user);
-
+ //添加价格规则
+ TSystemConfig tSystemConfig = new TSystemConfig();
+ tSystemConfig.setCompanyId(tBranchOffice.getId());
+ tSystemConfig.setType(systemPriceType);
+ tSystemConfig.setContent(systemPriceContent);
+ tSystemConfigService.insert(tSystemConfig);
+ tSystemConfig = new TSystemConfig();
+ tSystemConfig.setType(8);
+ tSystemConfig.setCompanyId(tBranchOffice.getId());
+ tSystemConfig.setContent("{\"num1\":" + isTaxiCar + ",\"num2\":\"" + serviceTel + "\",\"num3\":" + holiday + "}");
+ tSystemConfigService.insert(tSystemConfig);
return SUCCESS_TIP;
}
@@ -355,6 +434,12 @@
TBranchOffice tBranchOffice = tBranchOfficeService.selectById(tBranchOfficeId);
tBranchOffice.setStatus(StatusEnum.DELETE.getCode());
tBranchOfficeService.updateById(tBranchOffice);
+ List<User> users = userService.selectList(new EntityWrapper<User>().eq("role_type", 2).eq("object_id", tBranchOfficeId));
+ for (User user : users) {
+ user.setStatus(3);
+ userService.updateById(user);
+ }
+ tSystemConfigService.delete(new EntityWrapper<TSystemConfig>().eq("type", 5).eq("companyId", tBranchOfficeId));
return SUCCESS_TIP;
}
@@ -364,8 +449,7 @@
@RequestMapping(value = "/update")
@ResponseBody
@Transactional(rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW)
- public Object update(TBranchOffice tBranchOffice) {
- TBranchOffice branchOffice = tBranchOfficeService.selectById(tBranchOffice.getId());
+ public Object update(TBranchOffice tBranchOffice, Integer systemPriceType, String systemPriceContent, Integer holiday, Integer isTaxiCar, String serviceTel) { TBranchOffice branchOffice = tBranchOfficeService.selectById(tBranchOffice.getId());
User user = userService.selectOne(new EntityWrapper<User>()
.eq("role_type", 2)
.eq("object_id", branchOffice.getId())
@@ -389,7 +473,7 @@
}else {
if (!tBranchOffice.getAccount().equals(user.getAccount())){
//判断账号是否已存在
- int count = userService.selectCount(new EntityWrapper<User>().eq("account", tBranchOffice.getAccount()));
+ int count = userService.selectCount(new EntityWrapper<User>().eq("account", tBranchOffice.getAccount()).ne("status", 3));
if (count > 0){
return new SuccessTip(500,"该账号已存在!");
}
@@ -401,7 +485,7 @@
}
TBranchOffice office = tBranchOfficeService.selectOne(new EntityWrapper<TBranchOffice>().eq("branchOfficeName", tBranchOffice.getBranchOfficeName())
- .last("LIMIT 1"));
+ .ne("status", 3).last("LIMIT 1"));
if(Objects.nonNull(office) && !tBranchOffice.getId().equals(office.getId())){
return new SuccessTip(500,"该分公司名称已存在!");
}
@@ -413,6 +497,29 @@
}
tBranchOffice.setPrincipal(tBranchOffice.getPrincipal().replace(" ",""));
tBranchOfficeService.updateById(tBranchOffice);
+
+ TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 5).eq("companyId", tBranchOffice.getId()));
+ if(null == tSystemConfig){
+ tSystemConfig = new TSystemConfig();
+ tSystemConfig.setType(systemPriceType);
+ tSystemConfig.setCompanyId(tBranchOffice.getId());
+ tSystemConfig.setContent(systemPriceContent);
+ tSystemConfigService.insert(tSystemConfig);
+ }else{
+ tSystemConfig.setContent(systemPriceContent);
+ tSystemConfigService.updateById(tSystemConfig);
+ }
+ tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 8).eq("companyId", tBranchOffice.getId()));
+ if(null == tSystemConfig){
+ tSystemConfig = new TSystemConfig();
+ tSystemConfig.setType(8);
+ tSystemConfig.setCompanyId(tBranchOffice.getId());
+ tSystemConfig.setContent("{\"num1\":" + isTaxiCar + ",\"num2\":\"" + serviceTel + "\",\"num3\":" + holiday + "}");
+ tSystemConfigService.insert(tSystemConfig);
+ }else{
+ tSystemConfig.setContent("{\"num1\":" + isTaxiCar + ",\"num2\":\"" + serviceTel + "\",\"num3\":" + holiday + "}");
+ tSystemConfigService.updateById(tSystemConfig);
+ }
return SUCCESS_TIP;
}
--
Gitblit v1.7.1