package ;
import ;
import ;
import ;
import ;
import ;
import .*;
import ;
import ;
import ;
import ;
import ;
import .*;
import ;
import ;
import .;
import ;
import org.;
import org.;
import ;
import ;
import .*;
import ;
import ;
import .*;
import .*;
import .*;
import ;
import ;
import .*;
/**
* Repair Order
* Backend interface
* @author
* @email
*/
public class WeixiuxiangmuOrderController {
private static final Logger logger = ();
private WeixiuxiangmuOrderService weixiuxiangmuOrderService;
private TokenService tokenService;
private DictionaryService dictionaryService;
//Cascade table service
private CheliangService cheliangService;
private WeixiuxiangmuService weixiuxiangmuService;
private YonghuService yonghuService;
/**
* Backend list
*/
public R page({ Map<String, Object> params, HttpServletRequest request)
("page method:,,Controller:{},,params:{}",this.getClass().getName(),(params));
String role = (().getAttribute("role"));
if(false)
return (511,"Never enter");
else if("user".equals(role))
("yonghuId",().getAttribute("userId"));
else if("staff".equals(role))
("yuangongId",().getAttribute("userId"));
if(("orderBy")==null || ("orderBy")==""){
("orderBy","id");
}
PageUtils page = (params);
//Dictionary table data conversion
List<WeixiuxiangmuOrderView> list =(List<WeixiuxiangmuOrderView>)();
for(WeixiuxiangmuOrderView c:list){
//Modify the corresponding dictionary table field
(c, request);
}
return ().put("data", page);
}
/**
* Backend details
*/
public R info({ Long id, HttpServletRequest request)
("info method:,,Controller:{},,id:{}",this.getClass().getName(),id);
WeixiuxiangmuOrderEntity weixiuxiangmuOrder = (id);
if(weixiuxiangmuOrder !=null){
//Enterity to view
WeixiuxiangmuOrderView view = new WeixiuxiangmuOrderView();
( weixiuxiangmuOrder , view );//Reconstruct the entity data into the view
//Cascade table
CheliangEntity cheliang = (());
if(cheliang != null){
( cheliang , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "yonghuId"});//Add the cascading data to the view, and exclude the id and create time fields
(());
(());
}
//Cascade table
WeixiuxiangmuEntity weixiuxiangmu = (());
if(weixiuxiangmu != null){
( weixiuxiangmu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//Add the cascading data to the view, and exclude the id and create time fields
(());
}
//Cascade table
YonghuEntity yonghu = (());
if(yonghu != null){
( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//Add the cascading data to the view, and exclude the id and create time fields
(());
}
//Modify the corresponding dictionary table field
(view, request);
return ().put("data", view);
}else {
return (511,"No data found");
}
}
/**
* Backend save
*/
public R save({ WeixiuxiangmuOrderEntity weixiuxiangmuOrder, HttpServletRequest request)
("save method:,,Controller:{},,weixiuxiangmuOrder:{}",this.getClass().getName(),());
String role = (().getAttribute("role"));
if(false)
return (511,"Never enter");
else if("user".equals(role))
(((().getAttribute("userId"))));
(new Date());
(new Date());
(weixiuxiangmuOrder);
return ();
}
/**
* Backend modification
*/
public R update({ WeixiuxiangmuOrderEntity weixiuxiangmuOrder, HttpServletRequest request)
("update method:,,Controller:{},,weixiuxiangmuOrder:{}",this.getClass().getName(),());
String role = (().getAttribute("role"));
// if(false)
// return (511,"Never enter");
// else if("user".equals(role))
// (((().getAttribute("userId"))));
//Query the same data based on the field
Wrapper<WeixiuxiangmuOrderEntity> queryWrapper = new EntityWrapper<WeixiuxiangmuOrderEntity>()
.eq("id",0)
;
("sql statement:"+());
WeixiuxiangmuOrderEntity weixiuxiangmuOrderEntity = (queryWrapper);
if(weixiuxiangmuOrderEntity==null){
(weixiuxiangmuOrder);//Update according to id
return ();
}else {
return (511,"There is the same data in the table");
}
}
/**
* delete
*/
public R delete({ Integer[] ids)
("delete:,,Controller:{},,ids:{}",this.getClass().getName(),());
((ids));
return ();
}
/**
* Bulk upload
*/
public R save( String fileName, HttpServletRequest request){
("batchInsert method:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = ((().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
List<WeixiuxiangmuOrderEntity> weixiuxiangmuOrderList = new ArrayList<>();//Uploaded stuff
Map<String, List<String>> seachFields= new HashMap<>();//The field to be queryed
Date date = new Date();
int lastIndexOf = (".");
if(lastIndexOf == -1){
return (511,"The file has no suffix");
}else{
String suffix = (lastIndexOf);
if(!".xls".equals(suffix)){
return (511,"Only support excel files with suffix xls");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//Get file path
File file = new File(());
if(!()){
return (511,"The uploaded file cannot be found, please contact the administrator");
}else{
List<List<String>> dataList = (());//Read xls file
(0);//Delete the first line, because the first line is a prompt
for(List<String> data:dataList){
//cycle
WeixiuxiangmuOrderEntity weixiuxiangmuOrderEntity = new WeixiuxiangmuOrderEntity();
// ((0)); // Order number to be changed
// (((0))); // Repair project needs to be changed
// (((0))); // The user wants to change
// (((0))); // Repair the vehicle to be modified
// (((0))); //Appointment time needs to be changed
// ((0)); // The actual price needs to be changed
// (((0))); // Order type to be changed
// (date);//Time
// (date);//Time
(weixiuxiangmuOrderEntity);
//Put the fields to be queryed for duplicates into the map
//Order number
if(("weixiuxiangmuOrderUuidNumber")){
List<String> weixiuxiangmuOrderUuidNumber = ("weixiuxiangmuOrderUuidNumber");
((0));//To be changed
}else{
List<String> weixiuxiangmuOrderUuidNumber = new ArrayList<>();
((0));//To be changed
("weixiuxiangmuOrderUuidNumber",weixiuxiangmuOrderUuidNumber);
}
}
//Query whether it is duplicated
//Order number
List<WeixiuxiangmuOrderEntity> weixiuxiangmuOrderEntities_weixiuxiangmuOrderUuidNumber = (new EntityWrapper<WeixiuxiangmuOrderEntity>().in("weixiuxiangmu_order_uuid_number", ("weixiuxiangmuOrderUuidNumber")));
if(weixiuxiangmuOrderEntities_weixiuxiangmuOrderUuidNumber.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
for(WeixiuxiangmuOrderEntity s:weixiuxiangmuOrderEntities_weixiuxiangmuOrderUuidNumber){
(());
}
return (511,"The [Order Number] field in this table of the database already exists. The data exists as:"+());
}
(weixiuxiangmuOrderList);
return ();
}
}
}
}catch (Exception e){
();
return (511,"Batch insertion data is abnormal, please contact the administrator");
}
}
/**
* Front-end list
*/
public R list({ Map<String, Object> params, HttpServletRequest request)
("list method:,,Controller:{},,params:{}",this.getClass().getName(),(params));
// The default id is reversed without specifying the sorting field
if(((("orderBy")))){
("orderBy","id");
}
PageUtils page = (params);
//Dictionary table data conversion
List<WeixiuxiangmuOrderView> list =(List<WeixiuxiangmuOrderView>)();
for(WeixiuxiangmuOrderView c:list)
(c, request); //Modify the corresponding dictionary table field
return ().put("data", page);
}
/**
* Front-end details
*/
public R detail({ Long id, HttpServletRequest request)
("detail method:,,Controller:{},,id:{}",this.getClass().getName(),id);
WeixiuxiangmuOrderEntity weixiuxiangmuOrder = (id);
if(weixiuxiangmuOrder !=null){
//Enterity to view
WeixiuxiangmuOrderView view = new WeixiuxiangmuOrderView();
( weixiuxiangmuOrder , view );//Reconstruct the entity data into the view
//Cascade table
CheliangEntity cheliang = (());
if(cheliang != null){
( cheliang , view ,new String[]{ "id", "createDate"});//Add the cascading data to the view, and exclude the id and create time fields
(());
}
//Cascade table
WeixiuxiangmuEntity weixiuxiangmu = (());
if(weixiuxiangmu != null){
( weixiuxiangmu , view ,new String[]{ "id", "createDate"});//Add the cascading data to the view, and exclude the id and create time fields
(());
}
//Cascade table
YonghuEntity yonghu = (());
if(yonghu != null){
( yonghu , view ,new String[]{ "id", "createDate"});//Add the cascading data to the view, and exclude the id and create time fields
(());
}
//Modify the corresponding dictionary table field
(view, request);
return ().put("data", view);
}else {
return (511,"No data found");
}
}
/**
* Front-end save
*/
public R add({ WeixiuxiangmuOrderEntity weixiuxiangmuOrder, HttpServletRequest request)
("add method:,,Controller:{},,weixiuxiangmuOrder:{}",this.getClass().getName(),());
WeixiuxiangmuEntity weixiuxiangmuEntity = (());
if(weixiuxiangmuEntity == null){
return (511,"The maintenance project cannot be found");
}
if(false){
}
else if(() == null){
return (511,"The price of the repair project cannot be empty");
}
//The points obtained after calculation
Double buyJifen =0.0;
Integer userId = (Integer) ().getAttribute("userId");
YonghuEntity yonghuEntity = (userId);
if(yonghuEntity == null)
return (511,"User cannot be empty");
if(() == null)
return (511,"User amount cannot be empty");
double balance = () - ()*1;//Balance
if(balance<0)
return (511,"The balance is not enough to pay");
(1); //Set the order status to paid
(()*1); //Set the actual paid price
(userId); //Set the order payer id
((new Date().getTime()));
(());
(());
(new Date());
(new Date());
(weixiuxiangmuOrder);//Add a new order
(balance);//Set amount
(yonghuEntity);
return ();
}
/**
* Refund
*/
public R refund(Integer id, HttpServletRequest request){
("refund method:,,Controller:{},,id:{}",this.getClass().getName(),id);
String role = (().getAttribute("role"));
WeixiuxiangmuOrderEntity weixiuxiangmuOrder = (id);
Integer buyNumber = 1;
Integer weixiuxiangmuOrderPaymentTypes = 1;
Integer weixiuxiangmuId = ();
if(weixiuxiangmuId == null)
return (511,"The maintenance project cannot be found");
WeixiuxiangmuEntity weixiuxiangmuEntity = (weixiuxiangmuId);
if(weixiuxiangmuEntity == null)
return (511,"The maintenance project cannot be found");
Double weixiuxiangmuNewMoney = ();
if(weixiuxiangmuNewMoney == null)
return (511,"The price of the repair project cannot be empty");
Integer userId = (Integer) ().getAttribute("userId");
YonghuEntity yonghuEntity = (userId);
if(yonghuEntity == null)
return (511,"User cannot be empty");
if(() == null)
return (511,"User amount cannot be empty");
Double zhekou = 1.0;
//Judge what payment method it is 1 represents the balance 2 represents the points
if(weixiuxiangmuOrderPaymentTypes == 1){//Balance payment
// Calculate the amount
Double money = () * buyNumber * zhekou;
//The points obtained after calculation
Double buyJifen = 0.0;
(() + money); //Set amount
}
(2);//Set the order status as refund
(weixiuxiangmuOrder);//Update according to id
(yonghuEntity);//Update user information
(weixiuxiangmuEntity);//Update the information of maintenance items in the order
return ();
}
/**
* Shipping
*/
public R deliver(Integer id ){
("refund:,,Controller:{},,ids:{}",this.getClass().getName(),());
WeixiuxiangmuOrderEntity weixiuxiangmuOrderEntity = new WeixiuxiangmuOrderEntity();;
(id);
(3);
boolean b = ( weixiuxiangmuOrderEntity);
if(!b){
return ("Addition error");
}
return ();
}
}