package com.stylefeng.guns.modular.system.controller.general;
|
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.stylefeng.guns.core.base.controller.BaseController;
|
import com.stylefeng.guns.core.shiro.ShiroKit;
|
import com.stylefeng.guns.modular.system.controller.resp.CommissionAuditResp;
|
import com.stylefeng.guns.modular.system.model.TAgent;
|
import com.stylefeng.guns.modular.system.model.TBranchOffice;
|
import com.stylefeng.guns.modular.system.service.ITAgentService;
|
import com.stylefeng.guns.modular.system.service.ITBranchOfficeService;
|
import com.stylefeng.guns.modular.system.util.DateUtil;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.ui.Model;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import com.stylefeng.guns.core.log.LogObjectHolder;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import com.stylefeng.guns.modular.system.model.TSystemConfig;
|
import com.stylefeng.guns.modular.system.service.ITSystemConfigService;
|
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
|
/**
|
* 控制器
|
*
|
* @author fengshuonan
|
* @Date 2023-03-02 17:09:55
|
*/
|
@Controller
|
@RequestMapping("/tSystemConfig")
|
public class TSystemConfigController extends BaseController {
|
|
private String PREFIX = "/system/tSystemConfig/";
|
|
@Autowired
|
private ITSystemConfigService tSystemConfigService;
|
@Autowired
|
private ITAgentService agentService;
|
@Autowired
|
private ITBranchOfficeService branchOfficeService;
|
|
/**
|
* 跳转到首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "tSystemConfig.html";
|
}
|
/**
|
* 跳转到佣金审核
|
*/
|
@RequestMapping("/commissionAudit")
|
public String commissionAudit() {
|
return PREFIX + "commissionAudit.html";
|
}
|
|
/**
|
* 跳转到添加
|
*/
|
@RequestMapping("/tSystemConfig_add")
|
public String tSystemConfigAdd() {
|
return PREFIX + "tSystemConfig_add.html";
|
}
|
|
/**
|
* 跳转到修改
|
*/
|
@RequestMapping("/tSystemConfig_update/{tSystemConfigId}")
|
public String tSystemConfigUpdate(@PathVariable Integer tSystemConfigId, Model model) {
|
TSystemConfig tSystemConfig = tSystemConfigService.selectById(tSystemConfigId);
|
model.addAttribute("item",tSystemConfig);
|
LogObjectHolder.me().set(tSystemConfig);
|
return PREFIX + "tSystemConfig_edit.html";
|
}
|
|
/**
|
* 跳转到派单规则
|
*/
|
@RequestMapping("/dispatchRules")
|
public String dispatchRules(Model model) {
|
TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 1)
|
.eq("companyType",1)
|
.eq("companyId",1)
|
.last("LIMIT 1"));
|
if(null != tSystemConfig){
|
JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
|
model.addAttribute("num1",jsonObject.getInteger("num1"));
|
model.addAttribute("num2",jsonObject.getInteger("num2"));
|
model.addAttribute("num3",jsonObject.getInteger("num3"));
|
model.addAttribute("num4",jsonObject.getInteger("num4"));
|
}else{
|
model.addAttribute("num1",0);
|
model.addAttribute("num2",0);
|
model.addAttribute("num3",0);
|
model.addAttribute("num4",0);
|
}
|
// model.addAttribute("num5",jsonObject.getInteger("num5"));
|
return PREFIX + "tSystemConfigDispatchRules.html";
|
}
|
|
/**
|
* 跳转到佣金分成规则
|
*/
|
@RequestMapping("/commissionShareRules")
|
public String commissionShareRules(Model model) {
|
Integer roleType = ShiroKit.getUser().getRoleType();
|
Integer objectId = ShiroKit.getUser().getObjectId();
|
TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 2)
|
.eq("companyType",roleType)
|
.eq("companyId",objectId)
|
.last("LIMIT 1"));
|
if(Objects.nonNull(tSystemConfig)){
|
JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
|
model.addAttribute("num1",jsonObject.getString("num1"));
|
model.addAttribute("num2",jsonObject.getString("num2"));
|
model.addAttribute("num3",jsonObject.getString("num3"));
|
model.addAttribute("num4",jsonObject.getString("num4"));
|
model.addAttribute("num5",jsonObject.getString("num5"));
|
model.addAttribute("num6",jsonObject.getString("num6"));
|
model.addAttribute("num7",jsonObject.getString("num7"));
|
}else {
|
model.addAttribute("num1",0);
|
model.addAttribute("num2",0);
|
model.addAttribute("num3",0);
|
model.addAttribute("num4",0);
|
model.addAttribute("num5",0);
|
model.addAttribute("num6",0);
|
model.addAttribute("num7",0);
|
}
|
return PREFIX + "tSystemConfigCommissionShareRules.html";
|
}
|
/**
|
* 跳转到佣金分成规则详情页面
|
*/
|
@RequestMapping("/commissionAuditDetail/{id}")
|
public String commissionAuditDetail(@PathVariable(value = "id") Integer id, Model model) {
|
TSystemConfig tSystemConfig = tSystemConfigService.selectById(id);
|
if(Objects.nonNull(tSystemConfig)){
|
JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
|
model.addAttribute("num1",jsonObject.getString("num1"));
|
model.addAttribute("num2",jsonObject.getString("num2"));
|
model.addAttribute("num3",jsonObject.getString("num3"));
|
model.addAttribute("num4",jsonObject.getString("num4"));
|
model.addAttribute("num5",jsonObject.getString("num5"));
|
model.addAttribute("num6",jsonObject.getString("num6"));
|
model.addAttribute("num7",jsonObject.getString("num7"));
|
// 查询分公司信息
|
TBranchOffice tBranchOffice = branchOfficeService.selectOne(new EntityWrapper<TBranchOffice>()
|
.eq("id", tSystemConfig.getCompanyId())
|
.eq("status",1));
|
if(Objects.nonNull(tBranchOffice)){
|
model.addAttribute("branchOfficeName",tBranchOffice.getBranchOfficeName());
|
model.addAttribute("principal",tBranchOffice.getPrincipal());
|
model.addAttribute("principalPhone",tBranchOffice.getPrincipalPhone());
|
}else {
|
model.addAttribute("branchOfficeName","");
|
model.addAttribute("principal","");
|
model.addAttribute("principalPhone","");
|
}
|
switch (tSystemConfig.getStatus()){
|
case 1:
|
model.addAttribute("statusStr","待审核");
|
break;
|
case 2:
|
model.addAttribute("statusStr","审核通过");
|
break;
|
case 3:
|
model.addAttribute("statusStr","审核驳回");
|
break;
|
default:
|
model.addAttribute("statusStr","");
|
}
|
model.addAttribute("remark",tSystemConfig.getRemark());
|
}else {
|
model.addAttribute("num1",0);
|
model.addAttribute("num2",0);
|
model.addAttribute("num3",0);
|
model.addAttribute("num4",0);
|
model.addAttribute("num5",0);
|
model.addAttribute("num6",0);
|
model.addAttribute("num7",0);
|
model.addAttribute("branchOfficeName","");
|
model.addAttribute("principal","");
|
model.addAttribute("principalPhone","");
|
model.addAttribute("statusStr","");
|
model.addAttribute("remark","");
|
}
|
return PREFIX + "tSystemConfigCommissionShareRulesDetail.html";
|
}
|
/**
|
* 跳转到佣金分成规则详情提交审核
|
*/
|
@RequestMapping("/commitAuditDetail/{id}")
|
public String commitAuditDetail(@PathVariable(value = "id") Integer id, Model model) {
|
TSystemConfig tSystemConfig = tSystemConfigService.selectById(id);
|
if(Objects.nonNull(tSystemConfig)){
|
JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
|
model.addAttribute("num1",jsonObject.getString("num1"));
|
model.addAttribute("num2",jsonObject.getString("num2"));
|
model.addAttribute("num3",jsonObject.getString("num3"));
|
model.addAttribute("num4",jsonObject.getString("num4"));
|
model.addAttribute("num5",jsonObject.getString("num5"));
|
model.addAttribute("num6",jsonObject.getString("num6"));
|
model.addAttribute("num7",jsonObject.getString("num7"));
|
// 查询分公司信息
|
TBranchOffice tBranchOffice = branchOfficeService.selectOne(new EntityWrapper<TBranchOffice>()
|
.eq("id", tSystemConfig.getCompanyId())
|
.eq("status",1));
|
if(Objects.nonNull(tBranchOffice)){
|
model.addAttribute("branchOfficeName",tBranchOffice.getBranchOfficeName());
|
model.addAttribute("principal",tBranchOffice.getPrincipal());
|
model.addAttribute("principalPhone",tBranchOffice.getPrincipalPhone());
|
}else {
|
model.addAttribute("branchOfficeName","");
|
model.addAttribute("principal","");
|
model.addAttribute("principalPhone","");
|
}
|
switch (tSystemConfig.getStatus()){
|
case 1:
|
model.addAttribute("statusStr","待审核");
|
break;
|
case 2:
|
model.addAttribute("statusStr","审核通过");
|
break;
|
case 3:
|
model.addAttribute("statusStr","审核驳回");
|
break;
|
default:
|
model.addAttribute("statusStr","");
|
}
|
model.addAttribute("remark",tSystemConfig.getRemark());
|
model.addAttribute("id",tSystemConfig.getId());
|
}else {
|
model.addAttribute("num1",0);
|
model.addAttribute("num2",0);
|
model.addAttribute("num3",0);
|
model.addAttribute("num4",0);
|
model.addAttribute("num5",0);
|
model.addAttribute("num6",0);
|
model.addAttribute("num7",0);
|
model.addAttribute("branchOfficeName","");
|
model.addAttribute("principal","");
|
model.addAttribute("principalPhone","");
|
model.addAttribute("statusStr","");
|
model.addAttribute("remark","");
|
model.addAttribute("id","");
|
}
|
return PREFIX + "tSystemConfigCommissionShareRulesAudit.html";
|
}
|
|
/**
|
* 跳转到抽成规则
|
*/
|
@RequestMapping("/extractionRules")
|
public String extractionRules(Model model) {
|
Integer roleType = ShiroKit.getUser().getRoleType();
|
Integer objectId = ShiroKit.getUser().getObjectId();
|
model.addAttribute("roleType",roleType);
|
TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 3)
|
.eq("companyType",roleType)
|
.eq("companyId",objectId)
|
.last("LIMIT 1"));
|
if(Objects.nonNull(tSystemConfig)){
|
JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
|
model.addAttribute("num1",jsonObject.getInteger("num1"));
|
model.addAttribute("num2",jsonObject.getInteger("num2"));
|
model.addAttribute("num3",jsonObject.getString("num3"));
|
model.addAttribute("num4",jsonObject.getString("num4"));
|
model.addAttribute("num5",jsonObject.getString("num5"));
|
}else {
|
model.addAttribute("num1",0);
|
model.addAttribute("num2",0);
|
model.addAttribute("num3",0);
|
model.addAttribute("num4",0);
|
model.addAttribute("num5",0);
|
}
|
return PREFIX + "tSystemConfigExtractionRules.html";
|
}
|
/**
|
* 跳转到积分规则
|
*/
|
@RequestMapping("/integralRules")
|
public String integralRules(Model model) {
|
TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 4)
|
.last("LIMIT 1"));
|
JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
|
model.addAttribute("num1",jsonObject.getString("num1"));
|
model.addAttribute("num2",jsonObject.getString("num2"));
|
model.addAttribute("num3",jsonObject.getInteger("num3"));
|
model.addAttribute("num4",jsonObject.getInteger("num4"));
|
model.addAttribute("num5",jsonObject.getInteger("num5"));
|
model.addAttribute("num6",jsonObject.getInteger("num6"));
|
model.addAttribute("num7",jsonObject.getInteger("num7"));
|
model.addAttribute("num8",jsonObject.getInteger("num8"));
|
model.addAttribute("num9",jsonObject.getInteger("num9"));
|
model.addAttribute("num10",jsonObject.getInteger("num10"));
|
return PREFIX + "tSystemConfigIntegralRules.html";
|
}
|
|
/**
|
* 跳转到价格规则
|
*/
|
@RequestMapping("/priceRules")
|
public String priceRules(Model model) {
|
TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 5)
|
.last("LIMIT 1"));
|
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)
|
.last("LIMIT 1"));
|
JSONObject jsonObj = JSONObject.parseObject(config.getContent());
|
Integer zcOne = jsonObj.getInteger("num1");
|
model.addAttribute("zcOne",zcOne);
|
model.addAttribute("array",objects);
|
JSONObject extraCost = JSONObject.parseObject(jsonObject.getString("ExtraCost"));
|
model.addAttribute("ExtraCost",extraCost);
|
return PREFIX + "tSystemConfigPriceRules.html";
|
}
|
/**
|
* 跳转到余额规则
|
*/
|
@RequestMapping("/balanceRules")
|
public String balanceRules(Model model) {
|
Integer roleType = Objects.requireNonNull(ShiroKit.getUser()).getRoleType();
|
Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId();
|
TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 6)
|
.eq("companyType",roleType)
|
.eq("companyId",objectId)
|
.last("LIMIT 1"));
|
if(Objects.nonNull(tSystemConfig)){
|
JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
|
model.addAttribute("num1",jsonObject.getInteger("num1"));
|
model.addAttribute("num2",jsonObject.getInteger("num2"));
|
}else {
|
model.addAttribute("num1",0);
|
model.addAttribute("num2",0);
|
}
|
return PREFIX + "tSystemConfigBalanceRules.html";
|
}
|
/**
|
* 跳转到客服管理
|
*/
|
@RequestMapping("/serviceMgmt")
|
public String serviceMgmt(Model model) {
|
Integer roleType = Objects.requireNonNull(ShiroKit.getUser()).getRoleType();
|
Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId();
|
if(roleType == 1){
|
TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 7)
|
.last("LIMIT 1"));
|
JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent());
|
model.addAttribute("num1",jsonObject.getString("num1"));
|
}
|
if(roleType == 3){
|
TAgent tAgent = agentService.selectById(objectId);
|
if (Objects.nonNull(tAgent)){
|
model.addAttribute("num1",tAgent.getServiceCalls());
|
}
|
}
|
return PREFIX + "tSystemConfigServiceMgmt.html";
|
}
|
|
|
/**
|
* 获取列表
|
*/
|
@RequestMapping(value = "/systemConfigSubmit")
|
@ResponseBody
|
public Object systemConfigSubmit(Integer type,String content) {
|
|
Integer roleType = Objects.requireNonNull(ShiroKit.getUser()).getRoleType();
|
Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId();
|
if(roleType == 3){
|
TAgent tAgent = agentService.selectById(objectId);
|
if (Objects.nonNull(tAgent)){
|
JSONObject jsonObject = JSONObject.parseObject(content);
|
String num1 = jsonObject.getString("num1");
|
tAgent.setServiceCalls(num1);
|
agentService.updateById(tAgent);
|
}
|
}else {
|
TSystemConfig tSystemConfig;
|
if(type == 1){
|
tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 1)
|
.eq("companyType",1)
|
.eq("companyId",1)
|
.last("LIMIT 1"));
|
}else {
|
tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", type)
|
.eq("companyType",roleType)
|
.eq("companyId",objectId)
|
.last("LIMIT 1"));
|
}
|
if(Objects.nonNull(tSystemConfig)){
|
tSystemConfig.setContent(content);
|
tSystemConfig.setCompanyId(objectId);
|
tSystemConfig.setType(type);
|
if(roleType == 1){
|
tSystemConfig.setCompanyType(1);
|
tSystemConfig.setStatus(2);
|
}else{
|
tSystemConfig.setStatus(1);
|
}
|
if(roleType == 2){
|
tSystemConfig.setCompanyType(2);
|
}
|
tSystemConfigService.updateById(tSystemConfig);
|
}else {
|
tSystemConfig = new TSystemConfig();
|
tSystemConfig.setContent(content);
|
tSystemConfig.setCompanyId(objectId);
|
tSystemConfig.setType(type);
|
if(roleType == 1){
|
tSystemConfig.setCompanyType(1);
|
}
|
if(roleType == 2){
|
tSystemConfig.setCompanyType(2);
|
}
|
tSystemConfigService.insert(tSystemConfig);
|
}
|
}
|
return SUCCESS_TIP;
|
}
|
/**
|
* 获取列表
|
*/
|
@RequestMapping(value = "/list")
|
@ResponseBody
|
public Object list(String condition) {
|
return tSystemConfigService.selectList(null);
|
}
|
/**
|
* 提交审核
|
*/
|
@RequestMapping(value = "/commitAudit")
|
@ResponseBody
|
public Object commitAudit(Integer id,Integer status,String remark) {
|
TSystemConfig tSystemConfig = tSystemConfigService.selectById(id);
|
|
tSystemConfig.setStatus(status);
|
|
tSystemConfig.setRemark(remark);
|
tSystemConfig.setCommitTime(new Date());
|
tSystemConfigService.updateById(tSystemConfig);
|
return SUCCESS_TIP;
|
}
|
/**
|
* 获取列表
|
*/
|
@RequestMapping(value = "/commissionAuditList")
|
@ResponseBody
|
public Object commissionAuditList(String branchOfficeName,String principal,String principalPhone,Integer status) {
|
|
List<CommissionAuditResp> commissionAuditResps =tSystemConfigService.getList(branchOfficeName,principal,principalPhone,status);
|
for (CommissionAuditResp commissionAuditResp : commissionAuditResps) {
|
if(Objects.nonNull(commissionAuditResp.getCommitTime())){
|
commissionAuditResp.setCommitTimeStr(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(commissionAuditResp.getCommitTime()));
|
}
|
}
|
return commissionAuditResps;
|
}
|
|
/**
|
* 新增
|
*/
|
@RequestMapping(value = "/add")
|
@ResponseBody
|
public Object add(TSystemConfig tSystemConfig) {
|
tSystemConfigService.insert(tSystemConfig);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除
|
*/
|
@RequestMapping(value = "/delete")
|
@ResponseBody
|
public Object delete(@RequestParam Integer tSystemConfigId) {
|
tSystemConfigService.deleteById(tSystemConfigId);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改
|
*/
|
@RequestMapping(value = "/update")
|
@ResponseBody
|
public Object update(TSystemConfig tSystemConfig) {
|
tSystemConfigService.updateById(tSystemConfig);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改价格规则开关
|
*/
|
@RequestMapping(value = "/openOrClose")
|
@ResponseBody
|
public Object openOrClose(Integer num1) {
|
TSystemConfig config = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 8)
|
.last("LIMIT 1"));
|
JSONObject jsonObject = JSONObject.parseObject(config.getContent());
|
jsonObject.remove(jsonObject.getString("num1"));
|
jsonObject.put("num1",num1);
|
config.setContent(JSONObject.toJSONString(jsonObject));
|
tSystemConfigService.updateById(config);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改启动页状态
|
*/
|
@RequestMapping(value = "/updateStartState")
|
@ResponseBody
|
public Object updateStartState(Integer num2) {
|
TSystemConfig config = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 8)
|
.last("LIMIT 1"));
|
JSONObject jsonObject = JSONObject.parseObject(config.getContent());
|
jsonObject.remove(jsonObject.getString("num2"));
|
jsonObject.put("num2",num2);
|
config.setContent(JSONObject.toJSONString(jsonObject));
|
tSystemConfigService.updateById(config);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 详情
|
*/
|
@RequestMapping(value = "/detail/{tSystemConfigId}")
|
@ResponseBody
|
public Object detail(@PathVariable("tSystemConfigId") Integer tSystemConfigId) {
|
return tSystemConfigService.selectById(tSystemConfigId);
|
}
|
}
|