|
@@ -1,6 +1,7 @@
|
|
|
package com.fdkankan.platform.user.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -8,29 +9,30 @@ import com.fdkankan.common.constant.ConstantFilePath;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
import com.fdkankan.common.constant.ServerCode;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
-import com.fdkankan.common.util.DateUtil;
|
|
|
-import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.common.util.*;
|
|
|
import com.fdkankan.platform.common.ConstantExcel;
|
|
|
import com.fdkankan.platform.common.ExcelUtil;
|
|
|
import com.fdkankan.platform.common.LogFactory;
|
|
|
import com.fdkankan.platform.goods.service.ICameraDetailService;
|
|
|
+import com.fdkankan.platform.goods.service.ICompanyService;
|
|
|
+import com.fdkankan.platform.order.constant.OrderEnum;
|
|
|
import com.fdkankan.platform.order.entity.*;
|
|
|
import com.fdkankan.platform.order.service.*;
|
|
|
import com.fdkankan.platform.user.entity.Manager;
|
|
|
import com.fdkankan.platform.user.entity.ReceiverInfo;
|
|
|
import com.fdkankan.platform.user.entity.User;
|
|
|
import com.fdkankan.platform.user.mapper.IManagerMapper;
|
|
|
-import com.fdkankan.platform.user.request.RequestCamera;
|
|
|
-import com.fdkankan.platform.user.request.RequestInvoice;
|
|
|
-import com.fdkankan.platform.user.request.RequestTrade;
|
|
|
+import com.fdkankan.platform.user.request.*;
|
|
|
import com.fdkankan.platform.user.service.IManagerService;
|
|
|
import com.fdkankan.platform.user.service.IReceiverInfoService;
|
|
|
import com.fdkankan.platform.user.service.IUserService;
|
|
|
import com.fdkankan.platform.user.vo.*;
|
|
|
import com.fdkankan.sms.SendMailAcceUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -38,10 +40,9 @@ import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.File;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.net.URLEncoder;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.text.DateFormat;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
|
|
|
import static com.fdkankan.platform.common.ExcelUtil.output;
|
|
|
|
|
@@ -74,6 +75,10 @@ public class ManagerServiceImpl extends ServiceImpl<IManagerMapper, Manager> imp
|
|
|
private IReceiverInfoService iReceiverInfoService;
|
|
|
@Autowired
|
|
|
private IUserService userService;
|
|
|
+ @Autowired
|
|
|
+ private ITradeLogService tradeLogService;
|
|
|
+ @Autowired
|
|
|
+ private ICompanyService companyService;
|
|
|
|
|
|
QueryWrapper<Manager> queryWrapper;
|
|
|
|
|
@@ -722,6 +727,81 @@ public class ManagerServiceImpl extends ServiceImpl<IManagerMapper, Manager> imp
|
|
|
|
|
|
ExcelUtil.writeExcel(dataList, ConstantExcel.INVOICEEXCELCOLENNAME2.length, FileUtils.getResource() + fileName + ".xls", 6);
|
|
|
|
|
|
+ outXls(request,response,fileName,file);
|
|
|
+ }
|
|
|
+ @Override
|
|
|
+ public void export(RequestOrder param, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
|
|
+ List<ResponseOrder> orders = orderService.getPageVoByParam(param).getRecords();
|
|
|
+ List<Map> dataList = new ArrayList<Map>();
|
|
|
+ int serNum = 1;
|
|
|
+ for (int i = 0; i < orders.size(); ++i) {
|
|
|
+ ResponseOrder order = orders.get(i);
|
|
|
+ Map<String, String> item = new HashMap();
|
|
|
+ String num = order.getOrderSn();
|
|
|
+ if (order.getPaymentStatus().equals(OrderEnum.PaymentStatus.unpaid.name())) { //未支付
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[0], String.valueOf(serNum));
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[1], "");
|
|
|
+ } else {
|
|
|
+ TradeLog trade = tradeLogService.getByOrderSn(order.getOrderSn());
|
|
|
+ if (trade != null) {
|
|
|
+ if (trade.getPayStatus() != 1) {
|
|
|
+ //未支付
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[0], String.valueOf(serNum));
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[1], "");
|
|
|
+ } else {
|
|
|
+ //支付成功
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[0], String.valueOf(serNum));
|
|
|
+ if(!ObjectUtils.isEmpty(trade.getTradeTime())){
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[1], new SimpleDateFormat("yyyyMMddhhmmss").format(trade.getTradeTime()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[2], order.getOrderSn());
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[3], order.getUserName());
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[4], String.valueOf(order.getTotalAmount()));
|
|
|
+ if (order.getPaymentTypeName() == -1) {
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[5], "未支付");
|
|
|
+ } else {
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[5], ConstantExcel.PAYFORM[order.getPaymentTypeName()]);
|
|
|
+ }
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[6], order.getShipAddress());
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[7], order.getShipMobile());
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[8], order.getShipName());
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[9], ConstantExcel.getOrderStatus(order.getOrderStatus()));
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[10], ConstantExcel.getPaymentStatus(order.getPaymentStatus()));
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[11], ConstantExcel.getShippingStatus(order.getShippingStatus()));
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[12], order.getTradeNum());
|
|
|
+
|
|
|
+ Invoice invoice = invoiceService.getByOrderId(order.getId());
|
|
|
+ if (invoice == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ int type = invoice.getType();
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[13], ConstantExcel.INVOICE[type - 1]);
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[14], invoice.getTitle());
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[15], invoice.getCode());
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[16], invoice.getOrganizedAddress());
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[17], invoice.getRegisterPhone());
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[18], invoice.getBankName());
|
|
|
+ item.put(ConstantExcel.ORDEREXCELCOLENNAME[19], invoice.getBankAccount());
|
|
|
+ ++serNum;
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+ DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ String dateStr = dateFormat.format(new Date());
|
|
|
+ String fileName = dateStr + ".xls";
|
|
|
+ File file = new File(FileUtils.getResource() + dateStr + ".xls");
|
|
|
+
|
|
|
+ ExcelUtil.writeExcel(dataList, 20, FileUtils.getResource() + dateStr + ".xls", 1);
|
|
|
+
|
|
|
+ outXls(request,response,fileName,file);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void outXls(HttpServletRequest request,HttpServletResponse response,String fileName,File file) throws Exception{
|
|
|
String agent = request.getHeader("User-Agent");
|
|
|
if (agent != null && (agent.contains("MSIE")||agent.contains("Trident"))) {
|
|
|
fileName = URLEncoder.encode(fileName, "UTF-8");
|
|
@@ -734,4 +814,162 @@ public class ManagerServiceImpl extends ServiceImpl<IManagerMapper, Manager> imp
|
|
|
response.setContentLength((int) file.length());
|
|
|
output(response, file);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<Manager> managerList() {
|
|
|
+ List<Long> ids = companyService.getManagerId();
|
|
|
+ LambdaQueryWrapper<Manager> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(Manager::getIsCompany,1).eq(Manager::getRecStatus,"A");
|
|
|
+ if(ids!=null || ids.size()>0){
|
|
|
+ queryWrapper.notIn(Manager::getId,ids);
|
|
|
+ }
|
|
|
+ return this.list(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String companyUpdatePassword(RequestManager param, String token) {
|
|
|
+ String userName = JwtUtil.getUsername(token);
|
|
|
+
|
|
|
+ Manager managerEntity = this.getByUserName(userName.replace(SsoUtil.PREFIX_CACHE_MANAGER, ""));
|
|
|
+ if (managerEntity == null){
|
|
|
+ throw new BusinessException(ErrorCode.USER_NOT_LOGIN);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(managerEntity.getIsCompany() != 1){
|
|
|
+ throw new BusinessException(ErrorCode.NOT_PERMISSION);
|
|
|
+ }
|
|
|
+
|
|
|
+ //对前端传的密码解密
|
|
|
+ String password = Base64Converter.decode(Base64Converter.subText(param.getPassword()));
|
|
|
+ param.setPassword(password);
|
|
|
+
|
|
|
+ String encryptPwd = PasswordUtils.encrypt(param.getUserName(), param.getPassword(), PasswordUtils.getStaticSalt());
|
|
|
+ if (!encryptPwd.equals(managerEntity.getPassword())){
|
|
|
+ throw new BusinessException(ErrorCode.PASSWORD_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!param.getNewPassword().equals(param.getConfirmPwd())){
|
|
|
+ throw new BusinessException(ErrorCode.PASSWORD_TWO_VIOLATION);
|
|
|
+ }
|
|
|
+
|
|
|
+ String newPassword = Base64Converter.decode(Base64Converter.subText(param.getNewPassword()));
|
|
|
+ param.setNewPassword(newPassword);
|
|
|
+ managerEntity.setPassword(PasswordUtils.encrypt(param.getUserName(), param.getNewPassword(), PasswordUtils.getStaticSalt()));
|
|
|
+ this.updateById(managerEntity);
|
|
|
+ return ServerCode.SUCCESS.message();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String saveManager(RequestManager param) {
|
|
|
+ if(StringUtils.isEmpty(param.getUserName()) || StringUtils.isEmpty(param.getNickname()) ||
|
|
|
+ param.getAgentFrameworkId() == null || param.getManagerRoleId() == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+
|
|
|
+ Manager managerEntity = this.getByUserName(param.getUserName());
|
|
|
+ if(managerEntity != null){
|
|
|
+ throw new BusinessException(ErrorCode.PHONE_EXIST);
|
|
|
+ }
|
|
|
+
|
|
|
+ managerEntity = new Manager();
|
|
|
+ BeanUtils.copyProperties(param, managerEntity);
|
|
|
+ managerEntity.setPassword(PasswordUtils.encrypt(param.getUserName(), "4dkankan", PasswordUtils.getStaticSalt()));
|
|
|
+ this.save(managerEntity);
|
|
|
+ return ServerCode.SUCCESS.message();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String updateManager(RequestManager param) {
|
|
|
+ if(StringUtils.isEmpty(param.getUserName()) || StringUtils.isEmpty(param.getNickname()) ||
|
|
|
+ param.getAgentFrameworkId() == null || param.getManagerRoleId() == null || param.getId() == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+
|
|
|
+ Manager managerEntity = this.getByUserName(param.getUserName());
|
|
|
+ if(managerEntity != null && managerEntity.getId() != param.getId()){
|
|
|
+ throw new BusinessException(ErrorCode.PHONE_EXIST);
|
|
|
+ }
|
|
|
+
|
|
|
+ managerEntity = new Manager();
|
|
|
+ BeanUtils.copyProperties(param, managerEntity);
|
|
|
+ this.updateById(managerEntity);
|
|
|
+ return ServerCode.SUCCESS.message();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String updatePassword(RequestManager param) {
|
|
|
+ if(StringUtils.isEmpty(param.getPassword()) || StringUtils.isEmpty(param.getNewPassword()) ||
|
|
|
+ StringUtils.isEmpty(param.getConfirmPwd()) || param.getId() == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+
|
|
|
+ Manager managerEntity = this.getById(param.getId());
|
|
|
+ if(managerEntity == null){
|
|
|
+ throw new BusinessException(ErrorCode.USER_NOT_EXIST);
|
|
|
+ }
|
|
|
+
|
|
|
+ String encryptPwd = PasswordUtils.encrypt(param.getUserName(), param.getPassword(), PasswordUtils.getStaticSalt());
|
|
|
+ if (!encryptPwd.equals(managerEntity.getPassword())){
|
|
|
+ throw new BusinessException(ErrorCode.PASSWORD_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!param.getNewPassword().equals(param.getConfirmPwd())){
|
|
|
+ throw new BusinessException(ErrorCode.PASSWORD_TWO_VIOLATION);
|
|
|
+ }
|
|
|
+
|
|
|
+ managerEntity.setPassword(PasswordUtils.encrypt(param.getUserName(), param.getNewPassword(), PasswordUtils.getStaticSalt()));
|
|
|
+ this.updateById(managerEntity);
|
|
|
+ return ServerCode.SUCCESS.message();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String deleteManager(RequestManager param) {
|
|
|
+ if(param.getId() == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ Manager managerEntity = this.getById(param.getId());
|
|
|
+ if(managerEntity == null){
|
|
|
+ throw new BusinessException(ErrorCode.USER_NOT_EXIST);
|
|
|
+ }
|
|
|
+ managerEntity.setRecStatus("I");
|
|
|
+ this.updateById(managerEntity);
|
|
|
+ return ServerCode.SUCCESS.message();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String restPassword(RequestManager param) {
|
|
|
+ if(param.getId() == null){
|
|
|
+ throw new BusinessException(ErrorCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ }
|
|
|
+ Manager managerEntity = this.getById(param.getId());
|
|
|
+ if(managerEntity == null){
|
|
|
+ throw new BusinessException(ErrorCode.USER_NOT_EXIST);
|
|
|
+ }
|
|
|
+ managerEntity.setPassword(PasswordUtils.encrypt(param.getUserName(), "4dkankan", PasswordUtils.getStaticSalt()));
|
|
|
+ this.updateById(managerEntity);
|
|
|
+ return ServerCode.SUCCESS.message();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<Manager> listNew(RequestManager param) {
|
|
|
+ LambdaQueryWrapper<Manager> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ if(StringUtils.isNotEmpty(param.getUserName())){
|
|
|
+ queryWrapper.like(Manager::getUsername,param.getUserName());
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotEmpty(param.getNickname())){
|
|
|
+ queryWrapper.like(Manager::getNickname,param.getNickname());
|
|
|
+ }
|
|
|
+ if(param.getAgentFrameworkId() != null){
|
|
|
+ queryWrapper.eq(Manager::getAgentFrameworkId,param.getAgentFrameworkId());
|
|
|
+ }
|
|
|
+ if(param.getManagerRoleId() != null){
|
|
|
+ queryWrapper.eq(Manager::getManagerRoleId,param.getManagerRoleId());
|
|
|
+ }
|
|
|
+ Page<Manager> page = new Page<>(param.getPageNum(),param.getPageSize());
|
|
|
+ Page<Manager> pageResult = this.page(page, queryWrapper);
|
|
|
+ for (Manager record : pageResult.getRecords()) {
|
|
|
+ record.setPassword(null);
|
|
|
+ }
|
|
|
+ return pageResult;
|
|
|
+ }
|
|
|
}
|