package com.dsh.guns.modular.system.controller.code;
|
|
import com.alibaba.fastjson.JSON;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.dsh.course.feignClient.competition.CompetitionClient;
|
import com.dsh.course.feignClient.competition.model.Competition;
|
import com.dsh.course.feignClient.competition.model.CompetitionUser;
|
import com.dsh.course.feignClient.competition.model.GetPeopleQuery;
|
import com.dsh.course.feignClient.course.CourseClient;
|
import com.dsh.course.feignClient.course.CoursePackageDiscountClient;
|
import com.dsh.course.feignClient.course.CoursePackagePaymentConfigClient;
|
import com.dsh.course.feignClient.course.model.*;
|
import com.dsh.course.model.AuditDiscount;
|
import com.dsh.guns.config.UserExt;
|
import com.dsh.guns.core.base.controller.BaseController;
|
import com.dsh.guns.core.base.tips.ErrorTip;
|
import com.dsh.guns.core.base.tips.SuccessTip;
|
import com.dsh.guns.core.common.constant.factory.PageFactory;
|
import com.dsh.guns.core.util.ToolUtil;
|
import com.dsh.guns.modular.system.model.DiscountUpdateState;
|
import com.dsh.guns.modular.system.model.TCity;
|
import com.dsh.guns.modular.system.model.TStore;
|
import com.dsh.guns.modular.system.model.dto.CoursePackage;
|
import com.dsh.guns.modular.system.service.ICityService;
|
import com.dsh.guns.modular.system.service.ICoursePackageService;
|
import com.dsh.guns.modular.system.service.IStoreService;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.ui.Model;
|
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import javax.annotation.Resource;
|
import java.text.SimpleDateFormat;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.stream.Collectors;
|
|
/**
|
* 车辆管理控制器
|
*
|
* @author fengshuonan
|
* @Date 2020-06-05 17:25:12
|
*/
|
@Controller
|
@RequestMapping("/tDiscount")
|
public class TDiscountController extends BaseController {
|
|
private String PREFIX = "/system/tDiscount/";
|
private String PREFIX1 = "/system/tDiscountAudit/";
|
|
@Autowired
|
private CompetitionClient competitionClient;
|
|
@Autowired
|
private IStoreService storeService;
|
|
@Autowired
|
private ICityService cityService;
|
|
@Autowired
|
private CourseClient courseClient;
|
|
/**
|
* 跳转到车辆管理首页
|
*/
|
@RequestMapping("")
|
public String index(Model model) {
|
List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
|
model.addAttribute("list",list);
|
model.addAttribute("role",UserExt.getUser().getObjectType());
|
return PREFIX + "TDiscount.html";
|
}
|
@RequestMapping("/audit")
|
public String indexAudit(Model model) {
|
List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
|
model.addAttribute("list",list);
|
return PREFIX1 + "TDiscount.html";
|
}
|
|
/**
|
* 跳转到添加车辆管理
|
*/
|
@RequestMapping("/tCompetition_add")
|
public String tCompetitionAdd(Model model) {
|
List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
|
model.addAttribute("list",list);
|
return PREFIX + "TCompetition_add.html";
|
}
|
|
|
/**
|
* 跳转到修改车辆管理
|
*/
|
@RequestMapping("/tCompetition_update/{id}")
|
public String tCarUpdate(@PathVariable Integer id, Model model) {
|
Competition competition = competitionClient.queryById(id);
|
model.addAttribute("item",competition);
|
List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
|
TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getProvinceCode()));
|
List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId()));
|
|
List<TStore> list2 = storeService.list(new LambdaQueryWrapper<TStore>().eq(TStore::getCityCode,competition.getCityCode()));
|
model.addAttribute("list",list);
|
model.addAttribute("list1",list1);
|
model.addAttribute("list2",list2);
|
model.addAttribute("type",1);
|
return PREFIX + "TCompetition_edit.html";
|
}
|
@RequestMapping("/tCompetition_info/{id}")
|
public String tCarInfo(@PathVariable Integer id, Model model) {
|
Competition competition = competitionClient.queryById(id);
|
model.addAttribute("item",competition);
|
List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0));
|
TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getProvinceCode()));
|
List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId()));
|
|
List<TStore> list2 = storeService.list(new LambdaQueryWrapper<TStore>().eq(TStore::getCityCode,competition.getCityCode()));
|
model.addAttribute("list",list);
|
model.addAttribute("list1",list1);
|
model.addAttribute("list2",list2);
|
model.addAttribute("type",2);
|
|
return PREFIX + "TCompetition_edit.html";
|
}
|
@RequestMapping("/tCompetition_user/{id}")
|
public String tCarUser(@PathVariable Integer id, Model model) {
|
model.addAttribute("id",id);
|
return PREFIX + "TCompetitionUser.html";
|
}
|
|
@Autowired
|
private ICoursePackageService coursePackageService;
|
|
@Resource
|
private CoursePackagePaymentConfigClient coursePackagePaymentConfigClient;
|
|
@Resource
|
private CoursePackageDiscountClient coursePackageDiscountClient;
|
@RequestMapping("/info")
|
public String info( Integer id, Model model) {
|
TCoursePackage tCoursePackage = coursePackageService.queryById(id);
|
model.addAttribute("item", tCoursePackage);
|
List<CoursePackagePaymentConfig> list4 = coursePackagePaymentConfigClient.queryCoursePackagePaymentConfigList(id);
|
List<Map<String, Object>> list = new ArrayList<>();
|
for (CoursePackagePaymentConfig coursePackagePaymentConfig : list4) {
|
if(coursePackagePaymentConfig.getCashPayment() == 0){
|
continue;
|
}
|
Map<String, Object> map = new HashMap<>();
|
map.put("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId());
|
map.put("classHours", coursePackagePaymentConfig.getClassHours());
|
String payment = "";
|
if(coursePackagePaymentConfig.getCashPayment() > 0){
|
payment += "现金支付";
|
}
|
if(coursePackagePaymentConfig.getPlayPaiCoin() > 0){
|
payment += (ToolUtil.isNotEmpty(payment) ? "、" : "") + "玩湃币支付";
|
}
|
map.put("payment", payment);
|
map.put("cashPayment", coursePackagePaymentConfig.getCashPayment());
|
List<TCoursePackageDiscount> tCoursePackageDiscounts = coursePackageDiscountClient.queryCoursePackageDiscount(coursePackagePaymentConfig.getId());
|
map.put("coursePackageDiscount", tCoursePackageDiscounts);
|
list.add(map);
|
}
|
model.addAttribute("role",UserExt.getUser().getObjectType());
|
model.addAttribute("type",tCoursePackage.getType());
|
model.addAttribute("coursePackagePaymentConfig", JSON.toJSONString(list));
|
return PREFIX + "coursePackageDiscount.html";
|
}
|
@RequestMapping("/infoOne")
|
public String infoOne( Integer id, Model model) {
|
TCoursePackage tCoursePackage = coursePackageService.queryById(id);
|
model.addAttribute("item", tCoursePackage);
|
List<CoursePackagePaymentConfig> list4 = coursePackagePaymentConfigClient.queryCoursePackagePaymentConfigList(id);
|
List<Map<String, Object>> list = new ArrayList<>();
|
// 拒绝理由
|
StringBuilder reasons = new StringBuilder("");
|
for (CoursePackagePaymentConfig coursePackagePaymentConfig : list4) {
|
if(coursePackagePaymentConfig.getCashPayment() == 0){
|
continue;
|
}
|
Map<String, Object> map = new HashMap<>();
|
map.put("coursePackagePaymentConfigId", coursePackagePaymentConfig.getId());
|
map.put("classHours", coursePackagePaymentConfig.getClassHours());
|
String payment = "";
|
if(coursePackagePaymentConfig.getCashPayment() > 0){
|
payment += "现金支付";
|
}
|
if(coursePackagePaymentConfig.getPlayPaiCoin() > 0){
|
payment += (ToolUtil.isNotEmpty(payment) ? "、" : "") + "玩湃币支付";
|
}
|
map.put("payment", payment);
|
map.put("cashPayment", coursePackagePaymentConfig.getCashPayment());
|
List<TCoursePackageDiscount> tCoursePackageDiscounts = coursePackageDiscountClient.queryCoursePackageDiscount(coursePackagePaymentConfig.getId());
|
for (TCoursePackageDiscount tCoursePackageDiscount : tCoursePackageDiscounts) {
|
if (tCoursePackageDiscount.getAuditStatus()==3){
|
reasons.append(tCoursePackageDiscount.getAuditRemark()+",");
|
model.addAttribute("type1",3);
|
}else{
|
model.addAttribute("type1",-1);
|
}
|
}
|
map.put("coursePackageDiscount", tCoursePackageDiscounts);
|
list.add(map);
|
}
|
model.addAttribute("role",UserExt.getUser().getObjectType());
|
Integer type1 = tCoursePackage.getType();
|
// 审核状态
|
StringBuilder stringBuilder = new StringBuilder("");
|
|
switch (type1){
|
case 1:
|
stringBuilder.append("待审核");
|
break;
|
case 2:
|
stringBuilder.append("已通过");
|
break;
|
case 3:
|
stringBuilder.append("未通过");
|
break;
|
}
|
model.addAttribute("type",stringBuilder);
|
|
String string = reasons.toString();
|
if (!string.equals("")){
|
String substring = string.substring(0, string.length() - 1);
|
model.addAttribute("reasons", substring);
|
}else{
|
model.addAttribute("reasons", "");
|
}
|
model.addAttribute("coursePackagePaymentConfig", JSON.toJSONString(list));
|
model.addAttribute("type2",tCoursePackage.getType());
|
|
return PREFIX1 + "coursePackageDiscount.html";
|
}
|
|
|
@RequestMapping(value = "/list")
|
@ResponseBody
|
public Object list(String provinceCode, String cityCode, String shopName, String name, Integer type) {
|
LambdaQueryWrapper<TStore> wrapper = new LambdaQueryWrapper<>();
|
if(ToolUtil.isNotEmpty(shopName)){
|
wrapper.like(TStore::getName, shopName);
|
}
|
if(UserExt.getUser().getObjectType()==3){
|
wrapper.eq(TStore::getId, UserExt.getUser().getObjectId());
|
}
|
if(UserExt.getUser().getObjectType()==2){
|
wrapper.eq(TStore::getOperatorId, UserExt.getUser().getObjectId());
|
}
|
List<TStore> list = storeService.list(wrapper);
|
Page<DiscountList> page = new PageFactory<DiscountList>().defaultPage();
|
List<DiscountList> discountLists = courseClient.queryDiscountList(new QueryDiscountList
|
(page.getCurrent(),page.getSize(),provinceCode,cityCode,name,type,
|
list.stream().map(TStore::getId).collect(Collectors.toList())));
|
for (DiscountList discountList : discountLists) {
|
for (TStore tStore : list) {
|
if(discountList.getStoreId().equals(tStore.getId())){
|
discountList.setShopName(tStore.getName());
|
}
|
}
|
}
|
page.setRecords(discountLists);
|
return super.packForBT(page);
|
}
|
@RequestMapping(value = "/listAudit")
|
@ResponseBody
|
public Object listAudit(String provinceCode, String cityCode, String shopName, String name, Integer type) {
|
LambdaQueryWrapper<TStore> wrapper = new LambdaQueryWrapper<>();
|
if(ToolUtil.isNotEmpty(shopName)){
|
wrapper.like(TStore::getName, shopName);
|
}
|
List<TStore> list = storeService.list(wrapper);
|
Page<DiscountList> page = new PageFactory<DiscountList>().defaultPage();
|
List<DiscountList> discountLists = courseClient.queryDiscountListAudit(new QueryDiscountList(page.getCurrent(),page.getSize(),provinceCode,cityCode,name,type,list.stream().map(TStore::getId).collect(Collectors.toList())));
|
for (DiscountList discountList : discountLists) {
|
for (TStore tStore : list) {
|
if(discountList.getStoreId().equals(tStore.getId())){
|
discountList.setShopName(tStore.getName());
|
}
|
}
|
}
|
page.setRecords(discountLists);
|
return super.packForBT(page);
|
}
|
|
|
@RequestMapping(value = "/updateState")
|
@ResponseBody
|
public Object updateState( Integer id,Integer status) {
|
try {
|
Boolean b = courseClient.updateState(new DiscountUpdateState(id,status));
|
if(b){
|
return new SuccessTip<>();
|
}
|
return new ErrorTip(500,"");
|
}catch (Exception e){
|
e.printStackTrace();
|
return ERROR;
|
}
|
}
|
@RequestMapping(value = "/auditDiscount")
|
@ResponseBody
|
public Object auditDiscount(Integer id,Integer audit,String text) {
|
try {
|
Boolean b = courseClient.auditDiscount(new AuditDiscount(id,audit,text));
|
if(b){
|
return new SuccessTip<>();
|
}
|
return new ErrorTip(500,"");
|
}catch (Exception e){
|
e.printStackTrace();
|
return ERROR;
|
}
|
}
|
|
|
@RequestMapping(value = "/add")
|
@ResponseBody
|
public Object list(Competition competition) {
|
try {
|
if(ToolUtil.isNotEmpty(competition.getProvinceCode())) {
|
TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getProvinceCode()));
|
competition.setProvince(one.getName());
|
TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getCityCode()));
|
competition.setCity(one1.getName());
|
}
|
competition.setAuditStatus(1);
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
competition.setStartTime(format.parse(competition.getSTime()));
|
competition.setEndTime(format.parse(competition.getETime()));
|
competition.setRegisterEndTime(format.parse(competition.getREndTime()));
|
competitionClient.add(competition);
|
return new SuccessTip<>();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ERROR;
|
}
|
}
|
|
@RequestMapping(value = "/update")
|
@ResponseBody
|
public Object update(Competition competition) {
|
try {
|
Competition competition1 = competitionClient.queryById(competition.getId());
|
if(ToolUtil.isNotEmpty(competition.getProvinceCode())) {
|
TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getProvinceCode()));
|
competition.setProvince(one.getName());
|
TCity one1 = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getCityCode()));
|
competition.setCity(one1.getName());
|
}
|
if(ToolUtil.isEmpty(competition.getCoverDrawing())){
|
competition.setCoverDrawing(competition1.getCoverDrawing());
|
}
|
if(ToolUtil.isEmpty(competition.getRegistrationNotes())){
|
competition.setRegistrationNotes(competition1.getRegistrationNotes());
|
}
|
competitionClient.update(competition);
|
return new SuccessTip<>();
|
}catch (Exception e){
|
e.printStackTrace();
|
return ERROR;
|
}
|
}
|
|
|
@RequestMapping(value = "/cancel")
|
public Object cancel(Integer id) {
|
try {
|
competitionClient.cancel(id);
|
return SUCCESS_TIP;
|
}catch (Exception e){
|
e.printStackTrace();
|
return ERROR;
|
}
|
}
|
|
@RequestMapping(value = "/getPeopleFromId")
|
public Object getPeopleFromId(Integer id,Integer state) {
|
try {
|
Page<Object> page = new PageFactory<>().defaultPage();
|
Page<CompetitionUser> data = competitionClient.getPeopleFromId(new GetPeopleQuery(page.getSize(),page.getCurrent(),id,state));
|
return super.packForBT(data);
|
}catch (Exception e){
|
e.printStackTrace();
|
return ERROR;
|
}
|
}
|
|
@RequestMapping(value = "/onChange")
|
@ResponseBody
|
public Object onChange(Integer oneId) {
|
try {
|
TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, oneId));
|
return cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId()));
|
}catch (Exception e){
|
e.printStackTrace();
|
return ERROR;
|
}
|
}
|
@RequestMapping(value = "/oneChangeNext")
|
@ResponseBody
|
public Object oneChangeNext(Integer oneId) {
|
try {
|
return storeService.list(new LambdaQueryWrapper<TStore>().eq(TStore::getCityCode, oneId));
|
}catch (Exception e){
|
e.printStackTrace();
|
return ERROR;
|
}
|
}
|
|
|
}
|