package com.stylefeng.guns.modular.system.controller;
|
|
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateUtil;
|
import com.baomidou.mybatisplus.mapper.EntityWrapper;
|
import com.stylefeng.guns.core.base.controller.BaseController;
|
import com.stylefeng.guns.modular.system.model.IndexInfo;
|
import com.stylefeng.guns.modular.system.model.IndexMonth;
|
import com.stylefeng.guns.modular.system.model.TOrder;
|
import com.stylefeng.guns.modular.system.model.TUser;
|
import com.stylefeng.guns.modular.system.model.dto.UserAddInfoDto;
|
import com.stylefeng.guns.modular.system.service.ITOrderService;
|
import com.stylefeng.guns.modular.system.service.ITUserAddressService;
|
import com.stylefeng.guns.modular.system.service.ITUserService;
|
import com.stylefeng.guns.modular.system.utils.tips.SuccessTip;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 控制器
|
*
|
* @author fengshuonan
|
* @Date 2022-12-28 09:33:09
|
*/
|
@Controller
|
@Api(tags = "用户端 -- 主页")
|
@RequestMapping("/api/index")
|
public class IndexController extends BaseController {
|
|
@Autowired
|
private ITOrderService orderService;
|
|
@Resource
|
private ITUserService userService;
|
|
@Resource
|
private ITUserAddressService userAddressService;
|
/**
|
* 完善信息
|
*/
|
@ApiOperation(value = "用户-完善信息",notes="用户-完善信息")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
})
|
@PostMapping(value = "/addInfo")
|
@ResponseBody
|
public Object addInfo(@RequestBody UserAddInfoDto userAddInfoDto) {
|
TUser tUser = userService.selectById(userAddInfoDto.getUserId());
|
tUser.setPhone(userAddInfoDto.getPhone());
|
tUser.setContactName(userAddInfoDto.getContactName());
|
tUser.setContactEmail(userAddInfoDto.getContactEmail());
|
tUser.setContactPhone(userAddInfoDto.getContactPhone());
|
tUser.setLogisticsContactName(userAddInfoDto.getLogisticsContactName());
|
tUser.setLogisticsContactEmail(userAddInfoDto.getLogisticsContactEmail());
|
tUser.setLogisticsContactPhone(userAddInfoDto.getLogisticsContactPhone());
|
tUser.setEmail(userAddInfoDto.getEmail());
|
tUser.setCompanyName(userAddInfoDto.getCompanyName());
|
tUser.setBusinessLicense(userAddInfoDto.getImg());
|
// TUserAddress tUserAddress = new TUserAddress();
|
// tUserAddress.setAddress(userAddInfoDto.getAddress());
|
// tUserAddress.setUserId(userAddInfoDto.getUserId());
|
userService.updateById(tUser);
|
// userAddressService.insert(tUserAddress);
|
return new SuccessTip();
|
}
|
|
|
/**
|
* 完善信息
|
*/
|
@ApiOperation(value = "用户-完善信息--获取信息",notes="用户-完善信息--获取信息")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "int"),
|
})
|
@PostMapping(value = "/getInfo")
|
@ResponseBody
|
public Object getInfo( int id) {
|
TUser tUser = userService.selectById(id);
|
// userAddressService.insert(tUserAddress);
|
return new SuccessTip(tUser);
|
}
|
|
/**
|
* 获取首页信息
|
*/
|
@ApiOperation(value = "用户端-首页信息",notes="用户端-首页信息")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."),
|
@ApiImplicitParam(name = "time", value = "2000-01-01 - 2000-11-11", required = false, dataType = "String"),
|
@ApiImplicitParam(name = "type", value = "1all 2this year 3this quarter 4自定义时间", required = true, dataType = "String"),
|
@ApiImplicitParam(name = "userId", value = "用户id", required = true, dataType = "String"),
|
})
|
@GetMapping(value = "/index")
|
@ResponseBody
|
public Object list(String time,int type,int userId) {
|
TUser tUser = userService.selectById(userId);
|
IndexInfo indexInfo = new IndexInfo();
|
int numberOfOrder = orderService.selectCount(new EntityWrapper<TOrder>().eq("user_id", userId));
|
int dispatching = orderService.selectCount(new EntityWrapper<TOrder>().eq("user_id", userId).eq("status",0));
|
int pendingPickup = orderService.selectCount(new EntityWrapper<TOrder>().eq("user_id", userId).eq("status",2));
|
int inTransit = orderService.selectCount(new EntityWrapper<TOrder>().eq("user_id", userId).eq("status",7));
|
int toBeUnloaded = orderService.selectCount(new EntityWrapper<TOrder>().eq("user_id", userId).eq("status",8));
|
int unloaded = orderService.selectCount(new EntityWrapper<TOrder>().eq("user_id", userId).eq("status",9));
|
int unpaidBills = orderService.selectCount(new EntityWrapper<TOrder>().eq("user_id", userId).isNull("pay_time"));
|
indexInfo.setNumberOfOrder(numberOfOrder);
|
indexInfo.setDispatching(dispatching);
|
indexInfo.setPendingPickup(pendingPickup);
|
indexInfo.setInTransit(inTransit);
|
indexInfo.setToBeUnloaded(toBeUnloaded);
|
indexInfo.setUnloaded(unloaded);
|
indexInfo.setUnpaidBills(unpaidBills);
|
indexInfo.setAllQuota(tUser.getReditLimit());
|
indexInfo.setResidueQuota(tUser.getResidueLimit());
|
|
if(type==1){
|
List<IndexMonth> list = orderService.index(userId);
|
indexInfo.setList(list);
|
}else if(type==2){
|
int i = DateUtil.thisYear();
|
List<IndexMonth> list = orderService.indexYear(i,userId);
|
indexInfo.setList(list);
|
}else if(type==3){
|
String sTime = DateUtil.beginOfQuarter(new Date()).toString();
|
String eTime = DateUtil.endOfQuarter(new Date()).toString();
|
List<IndexMonth> list = orderService.indexTime(sTime,eTime,userId);
|
indexInfo.setList(list);
|
}else {
|
String sTime =time.split(" - ")[0]+" 00:00:00";
|
String eTime =time.split(" - ")[1]+" 23:59:59";
|
List<IndexMonth> list = orderService.indexTime(sTime,eTime,userId);
|
indexInfo.setList(list);
|
}
|
return new SuccessTip(indexInfo);
|
}
|
|
public static void main(String[] args) {
|
DateTime dateTime = DateUtil.beginOfQuarter(new Date());
|
System.out.println(dateTime);
|
String s = dateTime.toString();
|
System.out.println(s);
|
}
|
|
}
|