package com.stylefeng.guns.modular.system.controller.specialTrain;
|
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.rabbitmq.client.LongString;
|
import com.stylefeng.guns.core.base.controller.BaseController;
|
import com.stylefeng.guns.core.beetl.ShiroExtUtil;
|
import com.stylefeng.guns.core.util.DateUtil;
|
import com.stylefeng.guns.core.util.SinataUtil;
|
import com.stylefeng.guns.core.util.ToolUtil;
|
import com.stylefeng.guns.modular.system.model.DriverRankVo;
|
import com.stylefeng.guns.modular.system.model.TRegion;
|
import com.stylefeng.guns.modular.system.service.ITRegionService;
|
import com.stylefeng.guns.modular.system.util.ExcelExportUtil;
|
import lombok.SneakyThrows;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.*;
|
import org.springframework.ui.Model;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import com.stylefeng.guns.core.log.LogObjectHolder;
|
import com.stylefeng.guns.modular.system.model.TDriverPromotionActivity;
|
import com.stylefeng.guns.modular.system.service.ITDriverPromotionActivityService;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.math.BigDecimal;
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
|
/**
|
* 控制器
|
*
|
* @author fengshuonan
|
* @Date 2025-07-31 11:20:54
|
*/
|
@Controller
|
@RequestMapping("/tDriverPromotionActivity")
|
public class TDriverPromotionActivityController extends BaseController {
|
|
private String PREFIX = "/system/tDriverPromotionActivity/";
|
|
@Autowired
|
private ITDriverPromotionActivityService tDriverPromotionActivityService;
|
|
@Autowired
|
private ITRegionService tRegionService;
|
|
|
@Autowired
|
private ShiroExtUtil shiroExtUtil;
|
|
/**
|
* 跳转到首页
|
*/
|
@RequestMapping("")
|
public String index() {
|
return PREFIX + "tDriverPromotionActivity.html";
|
}
|
|
/**
|
* 跳转到添加
|
*/
|
@RequestMapping("/tDriverPromotionActivity_add")
|
public String tDriverPromotionActivityAdd(Model model) {
|
List<TRegion> provinceList = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
|
model.addAttribute("provinceList",provinceList);
|
return PREFIX + "tDriverPromotionActivity_add.html";
|
}
|
|
/**
|
* 跳转到修改
|
*/
|
@RequestMapping("/tDriverPromotionActivity_update/{tDriverPromotionActivityId}")
|
public String tDriverPromotionActivityUpdate(@PathVariable Integer tDriverPromotionActivityId, Model model) {
|
TDriverPromotionActivity tDriverPromotionActivity = tDriverPromotionActivityService.selectById(tDriverPromotionActivityId);
|
model.addAttribute("item",tDriverPromotionActivity);
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
model.addAttribute("time",simpleDateFormat.format(tDriverPromotionActivity.getStartTime())+" - "+simpleDateFormat.format(tDriverPromotionActivity.getEndTime()));
|
|
|
LogObjectHolder.me().set(tDriverPromotionActivity);
|
List<TRegion> provinceList = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
|
model.addAttribute("provinceList",provinceList);
|
|
TRegion province = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", tDriverPromotionActivity.getProvinceCode()));
|
//市
|
List<TRegion> cityList = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", province.getId()));
|
model.addAttribute("cityList",cityList);
|
|
//区
|
TRegion city = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", tDriverPromotionActivity.getCityCode()));
|
List<TRegion> areaList = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", city.getId()));
|
model.addAttribute("areaList",areaList);
|
|
|
|
|
|
|
|
|
return PREFIX + "tDriverPromotionActivity_edit.html";
|
}
|
@RequestMapping("/tDriverPromotionActivity_viewUser/{id}")
|
public String tDriverPromotionActivityViewUser(@PathVariable Integer id, Model model) {
|
|
model.addAttribute("driverId",id);
|
return PREFIX + "tDriverPromotionActivityUser.html";
|
}
|
/**
|
* 跳转到修改
|
*/
|
@RequestMapping("/tDriverPromotionActivity_info/{tDriverPromotionActivityId}")
|
public String tDriverPromotionActivityInfo(@PathVariable Integer tDriverPromotionActivityId, Model model) {
|
TDriverPromotionActivity tDriverPromotionActivity = tDriverPromotionActivityService.selectById(tDriverPromotionActivityId);
|
model.addAttribute("item",tDriverPromotionActivity);
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
model.addAttribute("time",simpleDateFormat.format(tDriverPromotionActivity.getStartTime())+" - "+simpleDateFormat.format(tDriverPromotionActivity.getEndTime()));
|
|
|
LogObjectHolder.me().set(tDriverPromotionActivity);
|
List<TRegion> provinceList = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0));
|
model.addAttribute("provinceList",provinceList);
|
|
TRegion province = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", tDriverPromotionActivity.getProvinceCode()));
|
//市
|
List<TRegion> cityList = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", province.getId()));
|
model.addAttribute("cityList",cityList);
|
|
//区
|
TRegion city = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", tDriverPromotionActivity.getCityCode()));
|
List<TRegion> areaList = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", city.getId()));
|
model.addAttribute("areaList",areaList);
|
|
return PREFIX + "tDriverPromotionActivity_detail.html";
|
}
|
|
/**
|
* 获取列表
|
*/
|
@RequestMapping(value = "/list")
|
@ResponseBody
|
public Object list(String insertTime,String name,Integer status) {
|
|
String beginTime = null;
|
String endTime = null;
|
if (SinataUtil.isNotEmpty(insertTime)) {
|
String[] timeArray = insertTime.split(" - ");
|
beginTime = timeArray[0];
|
endTime = timeArray[1];
|
}
|
return tDriverPromotionActivityService.list(beginTime,endTime,name,status);
|
}
|
|
|
|
|
/**
|
* 获取列表
|
*/
|
@RequestMapping(value = "/list1")
|
@ResponseBody
|
public Object list1(Long id,String driverName) {
|
|
return tDriverPromotionActivityService.list1(id,driverName);
|
}
|
@RequestMapping(value = "/list2")
|
@ResponseBody
|
public Object list2(Long driverId,String name) {
|
|
return tDriverPromotionActivityService.list2(driverId,name);
|
}
|
@GetMapping("/export1")
|
@ResponseBody
|
public void export1(Long driverId,String name, HttpServletRequest request, HttpServletResponse response) {
|
try {
|
ArrayList<HashMap<String, Object>> list = tDriverPromotionActivityService.list2(driverId, name);
|
|
|
// 表格数据【封装】
|
List<List<String>> dataList = new ArrayList<>();
|
|
//第一行显示【封装】
|
List<String> twoList = new ArrayList<String>();
|
twoList.add("总计:");
|
twoList.add(String.valueOf(list.size())+"条");
|
dataList.add(twoList);
|
// 列【封装】
|
List<String> shellList = new ArrayList<String>();
|
shellList.add("序号");
|
shellList.add("用户昵称");
|
shellList.add("用户手机号");
|
shellList.add("绑定时间");
|
shellList.add("有效期至");
|
shellList.add("产生收益合计");
|
dataList.add(shellList);
|
Integer index = 0;
|
for (HashMap<String, Object> object : list){
|
index++;
|
// 详细数据列【封装】
|
shellList = new ArrayList<String>();
|
shellList.add(index.toString());
|
shellList.add(object.get("userName").toString());
|
shellList.add(object.get("userPhone").toString());
|
shellList.add(object.get("bindDate").toString());
|
shellList.add(object.get("bindExpireDate").toString());
|
shellList.add(object.get("money").toString());
|
|
dataList.add(shellList);
|
}
|
try {
|
// 调用工具类进行导出
|
ExcelExportUtil.easySheet("司机推广下级用户导出记录"+DateUtil.formatDate(new Date(), "YYYYMMddHHmmss"), "司机推广下级用户导出记录", dataList,request, response);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
@GetMapping("/export")
|
@ResponseBody
|
public void export(Long id,String driverName, HttpServletRequest request, HttpServletResponse response) {
|
try {
|
List<DriverRankVo> list = tDriverPromotionActivityService.list1(id, driverName);
|
|
|
// 表格数据【封装】
|
List<List<String>> dataList = new ArrayList<>();
|
|
//第一行显示【封装】
|
List<String> twoList = new ArrayList<String>();
|
twoList.add("总计:");
|
twoList.add(String.valueOf(list.size())+"条");
|
dataList.add(twoList);
|
// 列【封装】
|
List<String> shellList = new ArrayList<String>();
|
shellList.add("推广排名");
|
shellList.add("司机姓名");
|
shellList.add("推广用户数量");
|
shellList.add("推广收益合计");
|
dataList.add(shellList);
|
Integer index = 0;
|
for (DriverRankVo object : list){
|
index++;
|
// 详细数据列【封装】
|
shellList = new ArrayList<String>();
|
shellList.add(index.toString());
|
shellList.add(object.getDriverName());
|
shellList.add(object.getUserNum().toString());
|
shellList.add(object.getMoney().toString());
|
|
|
dataList.add(shellList);
|
}
|
try {
|
// 调用工具类进行导出
|
ExcelExportUtil.easySheet("推广情况导出记录"+DateUtil.formatDate(new Date(), "YYYYMMddHHmmss"), "推广情况导出记录", dataList,request, response);
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
|
|
/**
|
* 新增
|
*/
|
@RequestMapping(value = "/add")
|
@ResponseBody
|
public Object add(String activityTitle,String bizTypeValue,String province,String city,String area,String time,Integer commissionRatio,Integer bindingDays,String content) throws ParseException {
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
TDriverPromotionActivity tDriverPromotionActivity = new TDriverPromotionActivity();
|
tDriverPromotionActivity.setActivityTitle(activityTitle);
|
tDriverPromotionActivity.setBizType(bizTypeValue);
|
tDriverPromotionActivity.setProvinceCode(province);
|
tDriverPromotionActivity.setCityCode(city);
|
tDriverPromotionActivity.setDistrictCode(area);
|
String s = time.split(" - ")[0] + " 00:00:00";
|
String s1 = time.split(" - ")[1] + " 23:59:59";
|
tDriverPromotionActivity.setStartTime(simpleDateFormat.parse(s));
|
tDriverPromotionActivity.setEndTime(simpleDateFormat.parse(s1));
|
tDriverPromotionActivity.setCommissionRatio(BigDecimal.valueOf(commissionRatio));
|
tDriverPromotionActivity.setBindingDays(bindingDays);
|
tDriverPromotionActivity.setActivityDesc(ToolUtil.cleanXSS(content));
|
tDriverPromotionActivity.setStatus(1);
|
tDriverPromotionActivity.setCreator(shiroExtUtil.getUser().getName());
|
tDriverPromotionActivity.setCreateTime(new Date());
|
tDriverPromotionActivityService.insert(tDriverPromotionActivity);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 删除
|
*/
|
@RequestMapping(value = "/delete")
|
@ResponseBody
|
public Object delete(@RequestParam Integer tDriverPromotionActivityId) {
|
TDriverPromotionActivity tDriverPromotionActivity = tDriverPromotionActivityService.selectById(tDriverPromotionActivityId);
|
tDriverPromotionActivity.setRemove(1);
|
tDriverPromotionActivityService.updateById(tDriverPromotionActivity);
|
return SUCCESS_TIP;
|
}
|
@RequestMapping(value = "/stop")
|
@ResponseBody
|
public Object stop(@RequestParam Integer id) {
|
TDriverPromotionActivity tDriverPromotionActivity = tDriverPromotionActivityService.selectById(id);
|
tDriverPromotionActivity.setState(2);
|
tDriverPromotionActivityService.updateById(tDriverPromotionActivity);
|
return SUCCESS_TIP;
|
}
|
@RequestMapping(value = "/start")
|
@ResponseBody
|
public Object start(@RequestParam Integer id) {
|
TDriverPromotionActivity tDriverPromotionActivity = tDriverPromotionActivityService.selectById(id);
|
tDriverPromotionActivity.setState(1);
|
tDriverPromotionActivityService.updateById(tDriverPromotionActivity);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 修改
|
*/
|
@SneakyThrows
|
@RequestMapping(value = "/update")
|
@ResponseBody
|
public Object update(Long id,String activityTitle, String bizTypeValue, String province, String city, String area, String time, Integer commissionRatio, Integer bindingDays, String content) {
|
TDriverPromotionActivity tDriverPromotionActivity = tDriverPromotionActivityService.selectById(id);
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
tDriverPromotionActivity.setActivityTitle(activityTitle);
|
tDriverPromotionActivity.setBizType(bizTypeValue);
|
tDriverPromotionActivity.setProvinceCode(province);
|
tDriverPromotionActivity.setCityCode(city);
|
tDriverPromotionActivity.setDistrictCode(area);
|
String s = time.split(" - ")[0] + " 00:00:00";
|
String s1 = time.split(" - ")[1] + " 23:59:59";
|
tDriverPromotionActivity.setStartTime(simpleDateFormat.parse(s));
|
tDriverPromotionActivity.setEndTime(simpleDateFormat.parse(s1));
|
tDriverPromotionActivity.setCommissionRatio(BigDecimal.valueOf(commissionRatio));
|
tDriverPromotionActivity.setBindingDays(bindingDays);
|
tDriverPromotionActivity.setActivityDesc(ToolUtil.cleanXSS(content));
|
tDriverPromotionActivity.setStatus(1);
|
tDriverPromotionActivity.setCreator(shiroExtUtil.getUser().getName());
|
tDriverPromotionActivity.setCreateTime(new Date());
|
tDriverPromotionActivity.setUpdateTime(new Date());
|
tDriverPromotionActivityService.updateById(tDriverPromotionActivity);
|
return SUCCESS_TIP;
|
}
|
|
/**
|
* 详情
|
*/
|
@RequestMapping(value = "/detail/{tDriverPromotionActivityId}")
|
@ResponseBody
|
public Object detail(@PathVariable("tDriverPromotionActivityId") Integer tDriverPromotionActivityId) {
|
return tDriverPromotionActivityService.selectById(tDriverPromotionActivityId);
|
}
|
}
|