parent
8bb1e466c9
commit
6120d54e1d
@ -0,0 +1,142 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.bweb.excelListener.ImportFleetOilCardCarListener; |
||||
import com.bweb.excelListener.ImportFleetOilCardUserListener; |
||||
import com.bweb.model.ImportFleetOilCardCarModel; |
||||
import com.bweb.model.ImportFleetOilCardUserModel; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.entity.HighFleetOilCard; |
||||
import com.hai.entity.HighFleetOilCardCar; |
||||
import com.hai.enum_type.FleetOilCardStatusEnum; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.HighFleetOilCardCarService; |
||||
import com.hai.service.HighFleetOilCardService; |
||||
import com.hai.service.HighFleetOilCardUserService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/fleetOilCardCar") |
||||
@Api(value = "车队油卡用户") |
||||
public class HighFleetOilCardCarController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HighFleetOilCardCarController.class); |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private HighFleetOilCardCarService fleetOilCardCarService; |
||||
|
||||
@Resource |
||||
private HighFleetOilCardService fleetOilCardService; |
||||
|
||||
@RequestMapping(value = "/importData", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "导入数据") |
||||
public ResponseData importData(@RequestParam(name = "cardNo", required = true) String cardNo, |
||||
@RequestParam(value = "file" , required = false) MultipartFile files) { |
||||
try { |
||||
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
if (userModel.getBsOrganization() == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "权限不足"); |
||||
} |
||||
// 查询油卡
|
||||
HighFleetOilCard fleetOilCard = fleetOilCardService.getFleetOilCardByCardNo(cardNo); |
||||
if (fleetOilCard == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到车队油卡信息"); |
||||
} |
||||
if (!fleetOilCard.getStatus().equals(FleetOilCardStatusEnum.status1.getStatus())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡状态异常"); |
||||
} |
||||
ImportFleetOilCardCarListener fleetOilCardCarListener = new ImportFleetOilCardCarListener(); |
||||
fleetOilCardCarListener.initData(userModel, fleetOilCardCarService, fleetOilCard); |
||||
EasyExcel.read(files.getInputStream(), ImportFleetOilCardCarModel.class, fleetOilCardCarListener).sheet().doRead(); |
||||
|
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("errorData", fleetOilCardCarListener.getErrorData()); |
||||
map.put("errorTotal", fleetOilCardCarListener.getErrorData().size()); |
||||
return ResponseMsgUtil.success(map); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighFleetOilCardUserController --> importData() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "删除") |
||||
public ResponseData delete(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body.getLong("id") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
HighFleetOilCardCar cardCar = fleetOilCardCarService.getDetailById(body.getLong("id")); |
||||
if (cardCar == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
cardCar.setStatus(0); |
||||
fleetOilCardCarService.editData(cardCar); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> delete() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/getCarList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询车列表") |
||||
public ResponseData getCarList(@RequestParam(name = "fleetOilCardNo", required = false) String fleetOilCardNo, |
||||
@RequestParam(name = "carLicensePlate", required = false) String carLicensePlate, |
||||
@RequestParam(name = "contactName", required = false) String contactName, |
||||
@RequestParam(name = "contactPhone", required = false) String contactPhone, |
||||
@RequestParam(name = "createTimeS", required = false) Long createTimeS, |
||||
@RequestParam(name = "createTimeE", required = false) Long createTimeE, |
||||
@RequestParam(name = "status", required = false) Integer status, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
|
||||
Map<String, Object> param = new HashMap<>(); |
||||
param.put("fleetOilCardNo", fleetOilCardNo); |
||||
param.put("carLicensePlate", carLicensePlate); |
||||
param.put("contactName", contactName); |
||||
param.put("contactPhone", contactPhone); |
||||
param.put("createTimeS", createTimeS); |
||||
param.put("createTimeE", createTimeE); |
||||
param.put("status", status); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(fleetOilCardCarService.getCarList(param))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> getCardList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,504 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.bweb.config.SysConst; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.AESEncodeUtil; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.DateUtil; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.entity.HighCompanyTwoPwd; |
||||
import com.hai.entity.HighFleetOilCard; |
||||
import com.hai.entity.HighOilCard; |
||||
import com.hai.enum_type.OilCardStatusEnum; |
||||
import com.hai.model.OilCardOrderModel; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.HighCompanyTwoPwdService; |
||||
import com.hai.service.HighFleetOilCardService; |
||||
import com.hai.service.HighOilCardService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.io.File; |
||||
import java.util.ArrayList; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/fleetOilCard") |
||||
@Api(value = "车队油卡") |
||||
public class HighFleetOilCardController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HighFleetOilCardController.class); |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private HighFleetOilCardService fleetOilCardService; |
||||
|
||||
@Resource |
||||
private HighCompanyTwoPwdService companyTwoPwdService; |
||||
|
||||
@RequestMapping(value = "/recharge", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "油卡充值") |
||||
public ResponseData recharge(@RequestBody JSONObject body) { |
||||
try { |
||||
if (StringUtils.isBlank(body.getString("cardNo")) || |
||||
body.getBigDecimal("price") == null || |
||||
StringUtils.isBlank(body.getString("twoPwd"))) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
if (userModel.getBsOrganization() == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "权限不足"); |
||||
} |
||||
|
||||
// 查询二级密码
|
||||
HighCompanyTwoPwd pwdByOrg = companyTwoPwdService.getTwoPwdByOrg(userModel.getBsOrganization().getId()); |
||||
if (pwdByOrg == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_TOW_PWD, ""); |
||||
} |
||||
if (!AESEncodeUtil.aesEncrypt(body.getString("twoPwd")).equals(pwdByOrg.getPassword())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付密码错误"); |
||||
} |
||||
// 充值
|
||||
fleetOilCardService.recharge(body.getString("cardNo"), body.getBigDecimal("price"), userModel.getBsOrganization().getId()); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> recharge() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/recycleAmount", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "回收余额") |
||||
public ResponseData recycleAmount(@RequestBody JSONObject body) { |
||||
try { |
||||
if (StringUtils.isBlank(body.getString("cardNo")) || |
||||
StringUtils.isBlank(body.getString("twoPwd"))) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
if (userModel.getBsOrganization() == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "权限不足"); |
||||
} |
||||
|
||||
// 查询二级密码
|
||||
HighCompanyTwoPwd pwdByOrg = companyTwoPwdService.getTwoPwdByOrg(userModel.getBsOrganization().getId()); |
||||
if (pwdByOrg == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_TOW_PWD, ""); |
||||
} |
||||
if (!AESEncodeUtil.aesEncrypt(body.getString("twoPwd")).equals(pwdByOrg.getPassword())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付密码错误"); |
||||
} |
||||
// 充值
|
||||
fleetOilCardService.recycleAmount(body.getString("cardNo")); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> recharge() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/generateCard", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "生成油卡") |
||||
public ResponseData generateCard(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body.getInteger("generateNum") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
if (userModel.getBsOrganization() == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "权限不足"); |
||||
} |
||||
|
||||
fleetOilCardService.generateCard(userModel.getBsOrganization().getId(), body.getInteger("generateNum")); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> generateCard() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/disabled", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "禁用") |
||||
public ResponseData disabled(@RequestBody JSONObject body) { |
||||
try { |
||||
if (StringUtils.isBlank(body.getString("cardNo"))) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
fleetOilCardService.disabled(body.getString("cardNo")); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> disabled() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/setContact", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "设置联系人") |
||||
public ResponseData setContact(@RequestBody JSONObject body) { |
||||
try { |
||||
if (StringUtils.isBlank(body.getString("cardNo")) |
||||
|| StringUtils.isBlank(body.getString("contactName")) |
||||
|| StringUtils.isBlank(body.getString("contactPhone"))) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
if (userModel.getBsOrganization() == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "权限不足"); |
||||
} |
||||
fleetOilCardService.setContact(body.getString("cardNo"),body.getString("contactName"),body.getString("contactPhone")); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> setContact() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/enable", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "启用") |
||||
public ResponseData enable(@RequestBody JSONObject body) { |
||||
try { |
||||
if (StringUtils.isBlank(body.getString("cardNo"))) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
fleetOilCardService.enable(body.getString("cardNo")); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> enable() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/getCardList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询油卡列表") |
||||
public ResponseData getCardList(@RequestParam(name = "orgId", required = false) Long orgId, |
||||
@RequestParam(name = "cardNo", required = false) String cardNo, |
||||
@RequestParam(name = "contactName", required = false) String contactName, |
||||
@RequestParam(name = "contactPhone", required = false) String contactPhone, |
||||
@RequestParam(name = "createTimeS", required = false) Long createTimeS, |
||||
@RequestParam(name = "createTimeE", required = false) Long createTimeE, |
||||
@RequestParam(name = "bindTimeS", required = false) Long bindTimeS, |
||||
@RequestParam(name = "bindTimeE", required = false) Long bindTimeE, |
||||
@RequestParam(name = "isConfigContact", required = false) Boolean isConfigContact, |
||||
@RequestParam(name = "status", required = false) Integer status, |
||||
@RequestParam(name = "bindStatus", required = false) Integer bindStatus, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
|
||||
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
|
||||
Map<String, Object> param = new HashMap<>(); |
||||
param.put("companyId", userModel.getBsCompany().getId()); |
||||
|
||||
if (userModel.getSecUser().getAdminFlag() != 1) { |
||||
param.put("orgId", userModel.getBsOrganization().getId()); |
||||
} else { |
||||
param.put("orgId", orgId); |
||||
} |
||||
param.put("cardNo", cardNo); |
||||
param.put("contactName", contactName); |
||||
param.put("contactPhone", contactPhone); |
||||
param.put("createTimeS", createTimeS); |
||||
param.put("createTimeE", createTimeE); |
||||
param.put("bindTimeS", bindTimeS); |
||||
param.put("bindTimeE", bindTimeE); |
||||
param.put("isConfigContact", isConfigContact); |
||||
param.put("status", status); |
||||
param.put("bindStatus", bindStatus); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(fleetOilCardService.getFleetOilCardList(param))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> getCardList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/exportCard", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "导出油卡") |
||||
public ResponseData exportCard(@RequestParam(name = "orgId", required = false) Long orgId, |
||||
@RequestParam(name = "cardNo", required = false) String cardNo, |
||||
@RequestParam(name = "contactName", required = false) String contactName, |
||||
@RequestParam(name = "contactPhone", required = false) String contactPhone, |
||||
@RequestParam(name = "createTimeS", required = false) Long createTimeS, |
||||
@RequestParam(name = "createTimeE", required = false) Long createTimeE, |
||||
@RequestParam(name = "bindTimeS", required = false) Long bindTimeS, |
||||
@RequestParam(name = "bindTimeE", required = false) Long bindTimeE, |
||||
@RequestParam(name = "isConfigContact", required = false) Boolean isConfigContact, |
||||
@RequestParam(name = "status", required = false) Integer status, |
||||
@RequestParam(name = "bindStatus", required = false) Integer bindStatus) { |
||||
try { |
||||
|
||||
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
|
||||
Map<String, Object> param = new HashMap<>(); |
||||
param.put("companyId", userModel.getBsCompany().getId()); |
||||
|
||||
if (userModel.getSecUser().getAdminFlag() != 1) { |
||||
param.put("orgId", userModel.getBsOrganization().getId()); |
||||
} else { |
||||
param.put("orgId", orgId); |
||||
} |
||||
param.put("cardNo", cardNo); |
||||
param.put("contactName", contactName); |
||||
param.put("contactPhone", contactPhone); |
||||
param.put("createTimeS", createTimeS); |
||||
param.put("createTimeE", createTimeE); |
||||
param.put("bindTimeS", bindTimeS); |
||||
param.put("bindTimeE", bindTimeE); |
||||
param.put("isConfigContact", isConfigContact); |
||||
param.put("status", status); |
||||
param.put("bindStatus", bindStatus); |
||||
List<HighFleetOilCard> cardList = fleetOilCardService.getFleetOilCardList(param); |
||||
|
||||
|
||||
List<String> headList = new ArrayList<>(); |
||||
headList.add("卡号"); |
||||
headList.add("余额"); |
||||
headList.add("消费金额"); |
||||
headList.add("联系人"); |
||||
headList.add("联系电话"); |
||||
headList.add("状态"); |
||||
|
||||
List<List<Object>> dataList = new ArrayList<>(); |
||||
List<Object> data; |
||||
|
||||
for (HighFleetOilCard card: cardList) { |
||||
data = new ArrayList<>(); |
||||
data.add(card.getCardNo()); |
||||
data.add(card.getAmount()); |
||||
data.add(card.getAmountConsume()); |
||||
|
||||
if (StringUtils.isNotBlank(card.getContactName())) { |
||||
data.add(card.getContactName()); |
||||
} else { |
||||
data.add("未设置"); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(card.getContactPhone())) { |
||||
data.add(card.getContactName()); |
||||
} else { |
||||
data.add("未设置"); |
||||
} |
||||
|
||||
if (card.getStatus().equals(OilCardStatusEnum.status1.getStatus())) { |
||||
data.add("正常"); |
||||
} else if (card.getStatus().equals(OilCardStatusEnum.status2.getStatus())) { |
||||
data.add("禁用"); |
||||
} |
||||
dataList.add(data); |
||||
} |
||||
|
||||
String fileUrl = SysConst.getSysConfig().getFileUrl() + "/temporary/"; |
||||
String pathName = System.currentTimeMillis()+".xlsx"; |
||||
File file = new File(fileUrl); |
||||
if (!file.exists()) { |
||||
file.mkdirs(); |
||||
} |
||||
EasyExcel.write(fileUrl+pathName).head(generationHead(headList)).sheet("油卡").doWrite(dataList); |
||||
|
||||
return ResponseMsgUtil.success(pathName); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> exportCard() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/getCardOrderList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询油卡订单列表") |
||||
public ResponseData getCardOrderList(@RequestParam(name = "orgId", required = false) Long orgId, |
||||
@RequestParam(name = "cardNo", required = false) String cardNo, |
||||
@RequestParam(name = "goodsName", required = false) String goodsName, |
||||
@RequestParam(name = "status", required = false) Integer status, |
||||
@RequestParam(name = "payTimeS", required = false) String payTimeS, |
||||
@RequestParam(name = "payTimeE", required = false) String payTimeE, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
|
||||
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
|
||||
Map<String, Object> param = new HashMap<>(); |
||||
param.put("companyId", userModel.getBsCompany().getId()); |
||||
|
||||
if (userModel.getSecUser().getAdminFlag() != 1) { |
||||
param.put("orgId", userModel.getBsOrganization().getId()); |
||||
} else { |
||||
param.put("orgId", orgId); |
||||
} |
||||
param.put("status", status); |
||||
param.put("cardNo", cardNo); |
||||
param.put("goodsName", goodsName); |
||||
param.put("payTimeS", payTimeS); |
||||
param.put("payTimeE", payTimeE); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(fleetOilCardService.getFleetOilCardOrderList(param))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> getCardOrderList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/exportCardOrder", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "导出油卡订单") |
||||
public ResponseData exportCardOrder(@RequestParam(name = "orgId", required = false) Long orgId, |
||||
@RequestParam(name = "cardNo", required = false) String cardNo, |
||||
@RequestParam(name = "goodsName", required = false) String goodsName, |
||||
@RequestParam(name = "status", required = false) Integer status, |
||||
@RequestParam(name = "payTimeS", required = false) String payTimeS, |
||||
@RequestParam(name = "payTimeE", required = false) String payTimeE, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
|
||||
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
|
||||
Map<String, Object> param = new HashMap<>(); |
||||
param.put("companyId", userModel.getBsCompany().getId()); |
||||
|
||||
if (userModel.getSecUser().getAdminFlag() != 1) { |
||||
param.put("orgId", userModel.getBsOrganization().getId()); |
||||
} else { |
||||
param.put("orgId", orgId); |
||||
} |
||||
param.put("status", status); |
||||
param.put("cardNo", cardNo); |
||||
param.put("goodsName", goodsName); |
||||
param.put("payTimeS", payTimeS); |
||||
param.put("payTimeE", payTimeE); |
||||
|
||||
List<OilCardOrderModel> cardOrderList = fleetOilCardService.getFleetOilCardOrderList(param); |
||||
List<String> headList = new ArrayList<>(); |
||||
|
||||
if (userModel.getSecUser().getAdminFlag() == 1) { |
||||
headList.add("所属部门"); |
||||
headList.add("用户手机号"); |
||||
} |
||||
headList.add("油卡卡号"); |
||||
headList.add("平台订单号"); |
||||
headList.add("团油订单号"); |
||||
headList.add("加油金额"); |
||||
headList.add("优惠金额"); |
||||
headList.add("实付金额"); |
||||
headList.add("加油站"); |
||||
headList.add("油号"); |
||||
headList.add("油枪号"); |
||||
headList.add("团油油枪价"); |
||||
headList.add("平台油枪价格"); |
||||
headList.add("订单状态"); |
||||
headList.add("创建时间"); |
||||
headList.add("支付时间"); |
||||
headList.add("退款时间"); |
||||
|
||||
List<List<Object>> dataList = new ArrayList<>(); |
||||
List<Object> data; |
||||
|
||||
for (OilCardOrderModel cardOrder: cardOrderList) { |
||||
data = new ArrayList<>(); |
||||
if (userModel.getSecUser().getAdminFlag() == 1) { |
||||
data.add(cardOrder.getOrgName()); |
||||
data.add(cardOrder.getMerPhone()); |
||||
} |
||||
data.add(cardOrder.getMemCardNo()); |
||||
data.add(cardOrder.getOrderNo()); |
||||
data.add(cardOrder.getGasOrderNo()); |
||||
data.add(cardOrder.getTotalPrice()); |
||||
data.add(cardOrder.getDeductionPrice()); |
||||
data.add(cardOrder.getPayRealPrice()); |
||||
data.add(cardOrder.getGoodsName()); |
||||
data.add(cardOrder.getGasOilNo()); |
||||
data.add(cardOrder.getGasGunNo()); |
||||
data.add(cardOrder.getGasPriceGun()); |
||||
data.add(cardOrder.getPlatformPriceGun()); |
||||
data.add(cardOrder.getStatusName()); |
||||
data.add(DateUtil.format(cardOrder.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); |
||||
data.add(DateUtil.format(cardOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss")); |
||||
if (cardOrder.getRefundTime() != null) { |
||||
data.add(DateUtil.format(cardOrder.getRefundTime(), "yyyy-MM-dd HH:mm:ss")); |
||||
} else { |
||||
data.add(""); |
||||
} |
||||
dataList.add(data); |
||||
} |
||||
|
||||
String fileUrl = SysConst.getSysConfig().getFileUrl() + "/temporary/"; |
||||
String pathName = System.currentTimeMillis()+".xlsx"; |
||||
File file = new File(fileUrl); |
||||
if (!file.exists()) { |
||||
file.mkdirs(); |
||||
} |
||||
EasyExcel.write(fileUrl+pathName).head(generationHead(headList)).sheet("油卡订单").doWrite(dataList); |
||||
|
||||
return ResponseMsgUtil.success(pathName); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> getCardOrderList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
/** |
||||
* 生成头部 |
||||
* @param headList |
||||
* @return |
||||
*/ |
||||
private static List<List<String>> generationHead(List<String> headList) { |
||||
List<List<String>> list = new ArrayList<>(); |
||||
List<String> head; |
||||
for (String headStr : headList) { |
||||
head = new ArrayList<>(); |
||||
head.add(headStr); |
||||
list.add(head); |
||||
} |
||||
return list; |
||||
} |
||||
} |
@ -0,0 +1,177 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.alibaba.excel.EasyExcel; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.bweb.excelListener.ImportCouponListener; |
||||
import com.bweb.excelListener.ImportFleetOilCardUserListener; |
||||
import com.bweb.model.ImportCouponModel; |
||||
import com.bweb.model.ImportFleetOilCardUserModel; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.AESEncodeUtil; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.entity.HighCompanyTwoPwd; |
||||
import com.hai.entity.HighFleetOilCard; |
||||
import com.hai.entity.HighFleetOilCardUser; |
||||
import com.hai.enum_type.FleetOilCardStatusEnum; |
||||
import com.hai.enum_type.OilCardStatusEnum; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.HighCompanyTwoPwdService; |
||||
import com.hai.service.HighFleetOilCardService; |
||||
import com.hai.service.HighFleetOilCardUserService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
import org.springframework.web.multipart.MultipartFile; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/fleetOilCardUser") |
||||
@Api(value = "车队油卡用户") |
||||
public class HighFleetOilCardUserController { |
||||
|
||||
private static Logger log = LoggerFactory.getLogger(HighFleetOilCardUserController.class); |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private HighFleetOilCardUserService fleetOilCardUserService; |
||||
|
||||
@Resource |
||||
private HighFleetOilCardService fleetOilCardService; |
||||
|
||||
@RequestMapping(value = "/importData", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "导入数据") |
||||
public ResponseData importData(@RequestParam(name = "cardNo", required = true) String cardNo, |
||||
@RequestParam(value = "file" , required = false) MultipartFile files) { |
||||
try { |
||||
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
if (userModel.getBsOrganization() == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "权限不足"); |
||||
} |
||||
// 查询油卡
|
||||
HighFleetOilCard fleetOilCard = fleetOilCardService.getFleetOilCardByCardNo(cardNo); |
||||
if (fleetOilCard == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到车队油卡信息"); |
||||
} |
||||
if (!fleetOilCard.getStatus().equals(FleetOilCardStatusEnum.status1.getStatus())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡状态异常"); |
||||
} |
||||
ImportFleetOilCardUserListener fleetOilCardUserListener = new ImportFleetOilCardUserListener(); |
||||
fleetOilCardUserListener.initData(userModel, fleetOilCard, fleetOilCardUserService); |
||||
EasyExcel.read(files.getInputStream(), ImportFleetOilCardUserModel.class, fleetOilCardUserListener).sheet().doRead(); |
||||
|
||||
Map<String, Object> map = new HashMap<>(); |
||||
map.put("errorData", fleetOilCardUserListener.getErrorData()); |
||||
map.put("errorTotal", fleetOilCardUserListener.getErrorData().size()); |
||||
return ResponseMsgUtil.success(map); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighFleetOilCardUserController --> importData() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/delete", method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "删除") |
||||
public ResponseData delete(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body.getLong("id") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
fleetOilCardUserService.delete(body.getLong("id")); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> delete() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/getUserList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询用户列表") |
||||
public ResponseData getUserList(@RequestParam(name = "fleetOilCardNo", required = false) String fleetOilCardNo, |
||||
@RequestParam(name = "contactName", required = false) String contactName, |
||||
@RequestParam(name = "contactPhone", required = false) String contactPhone, |
||||
@RequestParam(name = "createTimeS", required = false) Long createTimeS, |
||||
@RequestParam(name = "createTimeE", required = false) Long createTimeE, |
||||
@RequestParam(name = "status", required = false) Integer status, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
|
||||
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
Map<String, Object> param = new HashMap<>(); |
||||
param.put("fleetOilCardNo", fleetOilCardNo); |
||||
param.put("contactName", contactName); |
||||
param.put("contactPhone", contactPhone); |
||||
param.put("createTimeS", createTimeS); |
||||
param.put("createTimeE", createTimeE); |
||||
param.put("status", status); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(fleetOilCardUserService.getUserList(param))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> getCardList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/getUserOrderList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询用户订单列表") |
||||
public ResponseData getUserOrderList(@RequestParam(name = "orgId", required = false) Long orgId, |
||||
@RequestParam(name = "cardNo", required = false) String cardNo, |
||||
@RequestParam(name = "goodsName", required = false) String goodsName, |
||||
@RequestParam(name = "status", required = false) Integer status, |
||||
@RequestParam(name = "payTimeS", required = false) String payTimeS, |
||||
@RequestParam(name = "payTimeE", required = false) String payTimeE, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize) { |
||||
try { |
||||
|
||||
UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
|
||||
Map<String, Object> param = new HashMap<>(); |
||||
param.put("companyId", userModel.getBsCompany().getId()); |
||||
|
||||
if (userModel.getSecUser().getAdminFlag() != 1) { |
||||
param.put("orgId", userModel.getBsOrganization().getId()); |
||||
} else { |
||||
param.put("orgId", orgId); |
||||
} |
||||
param.put("status", status); |
||||
param.put("cardNo", cardNo); |
||||
param.put("goodsName", goodsName); |
||||
param.put("payTimeS", payTimeS); |
||||
param.put("payTimeE", payTimeE); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>()); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOilCardController --> getUserOrderList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,79 @@ |
||||
package com.bweb.excelListener; |
||||
|
||||
import com.alibaba.excel.context.AnalysisContext; |
||||
import com.alibaba.excel.event.AnalysisEventListener; |
||||
import com.bweb.model.ImportFleetOilCardCarModel; |
||||
import com.hai.entity.HighFleetOilCard; |
||||
import com.hai.entity.HighFleetOilCardCar; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.HighFleetOilCardCarService; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import java.util.*; |
||||
|
||||
public class ImportFleetOilCardCarListener extends AnalysisEventListener<ImportFleetOilCardCarModel> { |
||||
|
||||
List<ImportFleetOilCardCarModel> errorData = new ArrayList<>(); |
||||
List<HighFleetOilCardCar> successData = new ArrayList<>(); |
||||
|
||||
UserInfoModel userInfoModel; |
||||
HighFleetOilCard fleetOilCard; |
||||
HighFleetOilCardCar fleetOilCardCar; |
||||
|
||||
private HighFleetOilCardCarService fleetOilCardCarService; |
||||
|
||||
/** |
||||
* @Author 胡锐 |
||||
* @Description 解析到的每一条数据都会调用此方法 |
||||
* @Date 2021/3/20 21:08 |
||||
**/ |
||||
@Override |
||||
public void invoke(ImportFleetOilCardCarModel fleetOilCardCarModel, AnalysisContext analysisContext) { |
||||
if (StringUtils.isBlank(fleetOilCardCarModel.getContactName()) |
||||
|| StringUtils.isBlank(fleetOilCardCarModel.getContactPhone()) |
||||
|| StringUtils.isBlank(fleetOilCardCarModel.getCarLicensePlate())) { |
||||
fleetOilCardCarModel.setErrMsg("有必填项未填写"); |
||||
errorData.add(fleetOilCardCarModel); |
||||
return; |
||||
} |
||||
|
||||
fleetOilCardCar = new HighFleetOilCardCar(); |
||||
fleetOilCardCar.setFleetOilCardId(fleetOilCard.getId()); |
||||
fleetOilCardCar.setFleetOilCardNo(fleetOilCard.getCardNo()); |
||||
fleetOilCardCar.setContactName(fleetOilCardCarModel.getContactName()); |
||||
fleetOilCardCar.setContactPhone(fleetOilCardCarModel.getContactPhone()); |
||||
fleetOilCardCar.setCarLicensePlate(fleetOilCardCarModel.getCarLicensePlate()); |
||||
fleetOilCardCar.setOpUserId(userInfoModel.getSecUser().getId()); |
||||
fleetOilCardCar.setOpUserName(userInfoModel.getSecUser().getUserName()); |
||||
fleetOilCardCar.setStatus(1); |
||||
successData.add(fleetOilCardCar); |
||||
} |
||||
|
||||
/** |
||||
* @Author 胡锐 |
||||
* @Description 所有数据解析完成了 都会来调用此方法 |
||||
* @Date 2021/3/20 21:08 |
||||
**/ |
||||
@Override |
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
||||
if (successData.size() > 0) { |
||||
try { |
||||
fleetOilCardCarService.batchInsert(successData); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
this.successData.clear(); |
||||
} |
||||
|
||||
public List<ImportFleetOilCardCarModel> getErrorData() { |
||||
return errorData; |
||||
} |
||||
|
||||
public void initData(UserInfoModel userInfoModel, HighFleetOilCardCarService fleetOilCardCarService, HighFleetOilCard fleetOilCard){ |
||||
this.userInfoModel = userInfoModel; |
||||
this.fleetOilCardCarService = fleetOilCardCarService; |
||||
this.fleetOilCard = fleetOilCard; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,108 @@ |
||||
package com.bweb.excelListener; |
||||
|
||||
import com.alibaba.excel.context.AnalysisContext; |
||||
import com.alibaba.excel.event.AnalysisEventListener; |
||||
import com.bweb.model.ImportCouponModel; |
||||
import com.bweb.model.ImportFleetOilCardUserModel; |
||||
import com.hai.common.utils.DateUtil; |
||||
import com.hai.common.utils.MemberValidateUtil; |
||||
import com.hai.entity.HighCoupon; |
||||
import com.hai.entity.HighFleetOilCard; |
||||
import com.hai.entity.HighFleetOilCardUser; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.HighCouponCodeService; |
||||
import com.hai.service.HighFleetOilCardService; |
||||
import com.hai.service.HighFleetOilCardUserService; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.*; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* 导入车队油卡客户 |
||||
* @className: ImportFleetOilCardUserListener |
||||
* @author: HuRui |
||||
* @date: 2022/12/19 |
||||
**/ |
||||
public class ImportFleetOilCardUserListener extends AnalysisEventListener<ImportFleetOilCardUserModel> { |
||||
|
||||
List<ImportFleetOilCardUserModel> errorData = new ArrayList<>(); |
||||
List<HighFleetOilCardUser> successData = new ArrayList<>(); |
||||
List<HighFleetOilCardUser> allData = new ArrayList<>(); |
||||
|
||||
UserInfoModel userInfoModel; |
||||
HighFleetOilCard fleetOilCard; |
||||
HighFleetOilCardUser fleetOilCardUser; |
||||
|
||||
private HighFleetOilCardUserService fleetOilCardUserService; |
||||
|
||||
/** |
||||
* @Author 胡锐 |
||||
* @Description 解析到的每一条数据都会调用此方法 |
||||
* @Date 2021/3/20 21:08 |
||||
**/ |
||||
@Override |
||||
public void invoke(ImportFleetOilCardUserModel fleetOilCardUserModel, AnalysisContext analysisContext) { |
||||
|
||||
if (StringUtils.isBlank(fleetOilCardUserModel.getContactName()) |
||||
|| StringUtils.isBlank(fleetOilCardUserModel.getContactPhone())) { |
||||
fleetOilCardUserModel.setErrMsg("有必填项未填写"); |
||||
errorData.add(fleetOilCardUserModel); |
||||
return; |
||||
} |
||||
|
||||
if (MemberValidateUtil.validatePhone(fleetOilCardUserModel.getContactPhone()) == false) { |
||||
fleetOilCardUserModel.setErrMsg("客户电话格式校验未通过"); |
||||
errorData.add(fleetOilCardUserModel); |
||||
return; |
||||
} |
||||
|
||||
List<HighFleetOilCardUser> userList = allData.stream() |
||||
.filter(o -> o.getContactPhone().equals(fleetOilCardUserModel.getContactPhone())) |
||||
.collect(Collectors.toList()); |
||||
if (userList.size() > 0) { |
||||
fleetOilCardUserModel.setErrMsg("客户电话:" + fleetOilCardUserModel.getContactPhone() + " 已存在,请勿重复录入"); |
||||
errorData.add(fleetOilCardUserModel); |
||||
return; |
||||
} |
||||
|
||||
fleetOilCardUser = new HighFleetOilCardUser(); |
||||
fleetOilCardUser.setContactName(fleetOilCardUserModel.getContactName()); |
||||
fleetOilCardUser.setContactPhone(fleetOilCardUserModel.getContactPhone()); |
||||
fleetOilCardUser.setOpUserId(userInfoModel.getSecUser().getId()); |
||||
fleetOilCardUser.setOpUserName(userInfoModel.getSecUser().getUserName()); |
||||
successData.add(fleetOilCardUser); |
||||
allData.add(fleetOilCardUser); |
||||
} |
||||
|
||||
/** |
||||
* @Author 胡锐 |
||||
* @Description 所有数据解析完成了 都会来调用此方法 |
||||
* @Date 2021/3/20 21:08 |
||||
**/ |
||||
@Override |
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
||||
if (successData.size() > 0) { |
||||
try { |
||||
fleetOilCardUserService.importData(fleetOilCard, successData); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
} |
||||
} |
||||
this.successData.clear(); |
||||
this.allData.clear(); |
||||
} |
||||
|
||||
public List<ImportFleetOilCardUserModel> getErrorData() { |
||||
return errorData; |
||||
} |
||||
|
||||
public void initData(UserInfoModel userInfoModel,HighFleetOilCard fleetOilCard, HighFleetOilCardUserService fleetOilCardUserService){ |
||||
this.userInfoModel = userInfoModel; |
||||
this.fleetOilCard = fleetOilCard; |
||||
this.fleetOilCardUserService = fleetOilCardUserService; |
||||
this.allData = this.fleetOilCardUserService.getUserListByCard(fleetOilCard.getId()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,26 @@ |
||||
package com.bweb.model; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import com.alibaba.excel.annotation.format.DateTimeFormat; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* @className: ImportFleetOilCardUserModel |
||||
* @author: HuRui |
||||
* @date: 2022/12/19 |
||||
**/ |
||||
@Data |
||||
public class ImportFleetOilCardCarModel { |
||||
|
||||
@ExcelProperty("车主姓名") |
||||
private String contactName; |
||||
|
||||
@ExcelProperty("车主电话") |
||||
private String contactPhone; |
||||
|
||||
@ExcelProperty("车牌号") |
||||
private String carLicensePlate; |
||||
|
||||
// 错误消息
|
||||
private String errMsg; |
||||
} |
@ -0,0 +1,23 @@ |
||||
package com.bweb.model; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* 导入车队油卡客户 |
||||
* @className: ImportFleetOilCardUserModel |
||||
* @author: HuRui |
||||
* @date: 2022/12/19 |
||||
**/ |
||||
@Data |
||||
public class ImportFleetOilCardUserModel { |
||||
|
||||
@ExcelProperty("客户姓名") |
||||
private String contactName; |
||||
|
||||
@ExcelProperty("客户电话") |
||||
private String contactPhone; |
||||
|
||||
// 错误消息
|
||||
private String errMsg; |
||||
} |
File diff suppressed because one or more lines are too long
@ -0,0 +1,36 @@ |
||||
package com.hai.enum_type; |
||||
|
||||
/** |
||||
* 油卡状态 |
||||
* @author hurui |
||||
*/ |
||||
public enum FleetOilCardStatusEnum { |
||||
status0(0 , "删除"), |
||||
status1(1 , "正常"), |
||||
status2(2 , "禁用"), |
||||
; |
||||
|
||||
private Integer status; |
||||
private String name; |
||||
|
||||
FleetOilCardStatusEnum(int status , String name) { |
||||
this.status = status; |
||||
this.name = name; |
||||
} |
||||
|
||||
public Integer getStatus() { |
||||
return status; |
||||
} |
||||
|
||||
public void setStatus(Integer status) { |
||||
this.status = status; |
||||
} |
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
} |
@ -0,0 +1,41 @@ |
||||
package com.hai.service; |
||||
|
||||
import com.hai.entity.HighFleetOilCardCar; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: HighFleetOilCardCarService |
||||
* @author: HuRui |
||||
* @date: 2022/12/19 |
||||
**/ |
||||
public interface HighFleetOilCardCarService { |
||||
|
||||
/** |
||||
* 编辑数据 |
||||
* @param fleetOilCardCar |
||||
*/ |
||||
void editData(HighFleetOilCardCar fleetOilCardCar); |
||||
|
||||
/** |
||||
* 批量增加 |
||||
* @param fleetOilCardCarList |
||||
*/ |
||||
void batchInsert(List<HighFleetOilCardCar> fleetOilCardCarList); |
||||
|
||||
/** |
||||
* 根据id查询详情 |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
HighFleetOilCardCar getDetailById(Long id); |
||||
|
||||
/** |
||||
* 查询车辆列表 |
||||
* @param param |
||||
* @return |
||||
*/ |
||||
List<HighFleetOilCardCar> getCarList(Map<String, Object> param); |
||||
|
||||
} |
@ -0,0 +1,15 @@ |
||||
package com.hai.service; |
||||
|
||||
import com.hai.entity.HighFleetOilCardRecord; |
||||
|
||||
/** |
||||
* @className: HighFleetOilCardRecordService |
||||
* @author: HuRui |
||||
* @date: 2022/12/12 |
||||
**/ |
||||
public interface HighFleetOilCardRecordService { |
||||
|
||||
|
||||
void insertRecord(HighFleetOilCardRecord fleetOilCardRecord); |
||||
|
||||
} |
@ -0,0 +1,100 @@ |
||||
package com.hai.service; |
||||
|
||||
import com.hai.entity.HighFleetOilCard; |
||||
import com.hai.model.OilCardOrderModel; |
||||
|
||||
import java.math.BigDecimal; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* 车队油卡服务 |
||||
* @className: HighFleetOilCardService |
||||
* @author: HuRui |
||||
* @date: 2022/12/12 |
||||
**/ |
||||
public interface HighFleetOilCardService { |
||||
|
||||
/** |
||||
* 编辑数据 |
||||
* @param fleetOilCard |
||||
*/ |
||||
void editData(HighFleetOilCard fleetOilCard); |
||||
|
||||
/** |
||||
* 油卡充值 |
||||
* @param fleetCardNo 车队油卡卡号 |
||||
* @param price 充值金额 |
||||
* @param orgId 部门id |
||||
*/ |
||||
void recharge(String fleetCardNo, BigDecimal price, Long orgId); |
||||
|
||||
/** |
||||
* 回收余额 |
||||
* @param fleetCardNo 车队油卡卡号 |
||||
*/ |
||||
void recycleAmount(String fleetCardNo); |
||||
|
||||
/** |
||||
* 查询车队油卡详情 |
||||
* @param fleetCardNo 卡号 |
||||
* @return |
||||
*/ |
||||
HighFleetOilCard getFleetOilCardByCardNo(String fleetCardNo); |
||||
|
||||
/** |
||||
* 油卡消费 |
||||
* @param fleetCardNo 车队油卡卡号 |
||||
* @param amount 充值金额 |
||||
* @param otherParam 其他参数 |
||||
*/ |
||||
void consume(String fleetCardNo, BigDecimal amount, Map<String, Object> otherParam); |
||||
|
||||
/** |
||||
* 订单退款 |
||||
* @param orderNo 订单号 |
||||
*/ |
||||
void refund(String orderNo); |
||||
|
||||
/** |
||||
* 生成油卡 |
||||
* @param orgId 部门id |
||||
* @param generateNum 生成数量 |
||||
*/ |
||||
void generateCard(Long orgId, Integer generateNum); |
||||
|
||||
/** |
||||
* 绑定联系人 |
||||
* @param cardNo 卡号 |
||||
* @param contactName 联系人名称 |
||||
* @param contactPhone 联系人手机号 |
||||
*/ |
||||
void setContact(String cardNo,String contactName, String contactPhone); |
||||
|
||||
/** |
||||
* 禁用 |
||||
* @param fleetCardNo 车队油卡卡号 |
||||
*/ |
||||
void disabled(String fleetCardNo); |
||||
|
||||
/** |
||||
* 启用 |
||||
* @param fleetCardNo 车队油卡卡号 |
||||
*/ |
||||
void enable(String fleetCardNo); |
||||
|
||||
/** |
||||
* 查询油卡列表 |
||||
* @param param 参数 |
||||
* @return |
||||
*/ |
||||
List<HighFleetOilCard> getFleetOilCardList(Map<String,Object> param); |
||||
|
||||
/** |
||||
* 查询油卡订单列表 |
||||
* @param param |
||||
* @return |
||||
*/ |
||||
List<OilCardOrderModel> getFleetOilCardOrderList(Map<String,Object> param) throws Exception; |
||||
|
||||
} |
@ -0,0 +1,54 @@ |
||||
package com.hai.service; |
||||
|
||||
import com.hai.entity.HighFleetOilCard; |
||||
import com.hai.entity.HighFleetOilCardUser; |
||||
|
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: HighFleetOilCardUserService |
||||
* @author: HuRui |
||||
* @date: 2022/12/12 |
||||
**/ |
||||
public interface HighFleetOilCardUserService { |
||||
|
||||
/** |
||||
* 编辑用户 |
||||
* @param fleetOilCardUser |
||||
*/ |
||||
void editUser(HighFleetOilCardUser fleetOilCardUser); |
||||
|
||||
/** |
||||
* |
||||
* @param fleetOilCardUserList |
||||
*/ |
||||
void importData(HighFleetOilCard fleetOilCard, List<HighFleetOilCardUser> fleetOilCardUserList); |
||||
|
||||
/** |
||||
* 根据iD查询详情 |
||||
* @param id |
||||
* @return |
||||
*/ |
||||
HighFleetOilCardUser getDetailById(Long id); |
||||
|
||||
/** |
||||
* 删除 |
||||
* @param id |
||||
*/ |
||||
void delete(Long id); |
||||
|
||||
/** |
||||
* 查询用户列表 |
||||
* @param param |
||||
* @return |
||||
*/ |
||||
List<HighFleetOilCardUser> getUserList(Map<String, Object> param); |
||||
|
||||
/** |
||||
* 根据油卡查询用户列表 |
||||
* @param cardId |
||||
* @return |
||||
*/ |
||||
List<HighFleetOilCardUser> getUserListByCard(Long cardId); |
||||
} |
@ -0,0 +1,84 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
import com.hai.dao.HighFleetOilCardCarMapper; |
||||
import com.hai.entity.HighFleetOilCardCar; |
||||
import com.hai.entity.HighFleetOilCardCarExample; |
||||
import com.hai.service.HighFleetOilCardCarService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: HighFleetOilCardCarServiceImpl |
||||
* @author: HuRui |
||||
* @date: 2022/12/19 |
||||
**/ |
||||
@Service("fleetOilCardCarService") |
||||
public class HighFleetOilCardCarServiceImpl implements HighFleetOilCardCarService { |
||||
|
||||
@Resource |
||||
private HighFleetOilCardCarMapper fleetOilCardCarMapper; |
||||
|
||||
@Override |
||||
public void editData(HighFleetOilCardCar fleetOilCardCar) { |
||||
if (fleetOilCardCar.getId() == null) { |
||||
fleetOilCardCar.setCreateTime(new Date()); |
||||
fleetOilCardCar.setUpdateTime(new Date()); |
||||
fleetOilCardCarMapper.insert(fleetOilCardCar); |
||||
} else { |
||||
fleetOilCardCar.setUpdateTime(new Date()); |
||||
fleetOilCardCarMapper.updateByPrimaryKey(fleetOilCardCar); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(propagation = Propagation.REQUIRES_NEW) |
||||
public void batchInsert(List<HighFleetOilCardCar> fleetOilCardCarList) { |
||||
for (HighFleetOilCardCar fleetOilCardCar : fleetOilCardCarList){ |
||||
editData(fleetOilCardCar); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public HighFleetOilCardCar getDetailById(Long id) { |
||||
return fleetOilCardCarMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
public List<HighFleetOilCardCar> getCarList(Map<String, Object> param) { |
||||
HighFleetOilCardCarExample example = new HighFleetOilCardCarExample(); |
||||
HighFleetOilCardCarExample.Criteria criteria = example.createCriteria() |
||||
.andStatusNotEqualTo(0); |
||||
|
||||
if (MapUtils.getLong(param, "fleetOilCardId") != null) { |
||||
criteria.andFleetOilCardIdEqualTo(MapUtils.getLong(param, "fleetOilCardId")); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "fleetOilCardNo"))) { |
||||
criteria.andFleetOilCardNoLike("%"+MapUtils.getString(param, "fleetOilCardNo")+"%"); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "carLicensePlate"))) { |
||||
criteria.andCarLicensePlateLike("%"+MapUtils.getString(param, "carLicensePlate")+"%"); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "contactName"))) { |
||||
criteria.andContactNameLike("%"+MapUtils.getString(param, "contactName")+"%"); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "contactPhone"))) { |
||||
criteria.andContactPhoneLike("%"+MapUtils.getString(param, "contactPhone")+"%"); |
||||
} |
||||
|
||||
example.setOrderByClause("create_time desc"); |
||||
return fleetOilCardCarMapper.selectByExample(example); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,28 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
import com.hai.dao.HighFleetOilCardRecordMapper; |
||||
import com.hai.entity.HighFleetOilCardRecord; |
||||
import com.hai.service.HighFleetOilCardRecordService; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.Date; |
||||
|
||||
/** |
||||
* @className: HighFleetOilCardRecordServiceImpl |
||||
* @author: HuRui |
||||
* @date: 2022/12/12 |
||||
**/ |
||||
@Service("fleetOilCardRecordService") |
||||
public class HighFleetOilCardRecordServiceImpl implements HighFleetOilCardRecordService { |
||||
|
||||
@Resource |
||||
private HighFleetOilCardRecordMapper fleetOilCardRecordMapper; |
||||
|
||||
@Override |
||||
public void insertRecord(HighFleetOilCardRecord fleetOilCardRecord) { |
||||
fleetOilCardRecord.setCreateTime(new Date()); |
||||
fleetOilCardRecord.setStatus(1); |
||||
fleetOilCardRecordMapper.insert(fleetOilCardRecord); |
||||
} |
||||
} |
@ -0,0 +1,263 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.BankNumberUtil; |
||||
import com.hai.common.utils.DateUtil; |
||||
import com.hai.dao.HighFleetOilCardMapper; |
||||
import com.hai.entity.*; |
||||
import com.hai.enum_type.*; |
||||
import com.hai.model.OilCardOrderModel; |
||||
import com.hai.model.UserInfoModel; |
||||
import com.hai.service.*; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.data.redis.core.RedisTemplate; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.math.BigDecimal; |
||||
import java.time.Duration; |
||||
import java.util.*; |
||||
|
||||
/** |
||||
* @className: HighFleetOilCardServiceImpl |
||||
* @author: HuRui |
||||
* @date: 2022/12/12 |
||||
**/ |
||||
@Service("fleetOilCardService") |
||||
public class HighFleetOilCardServiceImpl implements HighFleetOilCardService { |
||||
|
||||
@Resource |
||||
private HighFleetOilCardMapper fleetOilCardMapper; |
||||
|
||||
@Resource |
||||
private HighFleetOilCardRecordService fleetOilCardRecordService; |
||||
|
||||
@Resource |
||||
private HighCompanyAccountService companyAccountService; |
||||
|
||||
@Resource |
||||
private BsCompanyService companyService; |
||||
|
||||
@Resource |
||||
private BsOrganizationService organizationService; |
||||
|
||||
@Autowired |
||||
private RedisTemplate<String, Object> redisTemplate; |
||||
|
||||
@Resource |
||||
private UserCenter userCenter; |
||||
|
||||
private final String LOCK_KEY = "lock_"; |
||||
|
||||
@Override |
||||
public void editData(HighFleetOilCard fleetOilCard) { |
||||
if (fleetOilCard.getId() == null) { |
||||
fleetOilCard.setCreateTime(new Date()); |
||||
fleetOilCard.setUpdateTime(new Date()); |
||||
fleetOilCardMapper.insert(fleetOilCard); |
||||
} else { |
||||
fleetOilCard.setUpdateTime(new Date()); |
||||
fleetOilCardMapper.updateByPrimaryKey(fleetOilCard); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void recharge(String fleetCardNo, BigDecimal price, Long orgId) { |
||||
HighFleetOilCard oilCard = getFleetOilCardByCardNo(fleetCardNo); |
||||
if (oilCard == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡卡号错误"); |
||||
} |
||||
if (!oilCard.getStatus().equals(OilCardStatusEnum.status1.getStatus())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡不处于正常状态"); |
||||
} |
||||
// 获取锁
|
||||
Boolean lock = redisTemplate.opsForValue().setIfAbsent(LOCK_KEY+fleetCardNo, ""); |
||||
if (!lock) { |
||||
Thread.sleep(300); |
||||
recharge(fleetCardNo, price, orgId); |
||||
} |
||||
try { |
||||
//获取锁成功
|
||||
// 账户扣款
|
||||
Map<String, Object> consumeType = new HashMap<>(); |
||||
consumeType.put("sourceType", CompanyAmountSourceTypeEnum.type4.getType()); |
||||
consumeType.put("sourceId", oilCard.getId()); |
||||
consumeType.put("sourceContent", "车队油卡:"+oilCard.getCardNo()+",充值:¥"+price.toString()); |
||||
companyAccountService.consume(orgId, price, consumeType); |
||||
|
||||
// 变更前金额
|
||||
BigDecimal beforeAmount = oilCard.getAmount(); |
||||
// 计算金额
|
||||
oilCard.setAmount(oilCard.getAmount().add(price)); |
||||
editData(oilCard); |
||||
// 变更后金额
|
||||
BigDecimal afterAmount = oilCard.getAmount(); |
||||
|
||||
HighFleetOilCardRecord record = new HighFleetOilCardRecord(); |
||||
record.setFleetOilCardId(oilCard.getId()); |
||||
record.setFleetOilCardNo(oilCard.getCardNo()); |
||||
record.setType(OilCardRecordTypeEnum.type1.getType()); |
||||
record.setTransactionAmount(price); |
||||
record.setBeforeAmount(beforeAmount); |
||||
record.setAfterAmount(afterAmount); |
||||
record.setSourceType(OilCardRecordSourceTypeEnum.type1.getType()); |
||||
try { |
||||
record.setSourceOrderNo(DateUtil.date2String(new Date(), "yyyyMMddHHmmss")); |
||||
} catch (Exception e) { |
||||
e.printStackTrace(); |
||||
}; |
||||
record.setSourceContent("充值油卡金额:" + record.getTransactionAmount()); |
||||
fleetOilCardRecordService.insertRecord(record); |
||||
|
||||
} finally { |
||||
redisTemplate.delete(LOCK_KEY+fleetCardNo); |
||||
} |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void recycleAmount(String fleetCardNo) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public HighFleetOilCard getFleetOilCardByCardNo(String fleetCardNo) { |
||||
HighFleetOilCardExample example = new HighFleetOilCardExample(); |
||||
example.createCriteria().andCardNoEqualTo(fleetCardNo).andStatusNotEqualTo(0); |
||||
List<HighFleetOilCard> list = fleetOilCardMapper.selectByExample(example); |
||||
if (list.size() > 0) { |
||||
return list.get(0); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public void consume(String fleetCardNo, BigDecimal amount, Map<String, Object> otherParam) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void refund(String orderNo) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void generateCard(Long orgId, Integer generateNum) { |
||||
UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); |
||||
// 查询部门信息
|
||||
BsOrganization organization = organizationService.findById(orgId); |
||||
if (organization == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到部门"); |
||||
} |
||||
BsCompany company = companyService.getCompanyById(organization.getCompanyId()); |
||||
|
||||
HighFleetOilCard oilCard; |
||||
for (int i = 0; i < generateNum; i++) { |
||||
oilCard = new HighFleetOilCard(); |
||||
oilCard.setCompanyId(organization.getCompanyId()); |
||||
oilCard.setCompanyName(company.getName()); |
||||
oilCard.setOrgId(organization.getId()); |
||||
oilCard.setOrgName(organization.getName()); |
||||
oilCard.setAmount(new BigDecimal("0")); |
||||
oilCard.setAmountConsume(new BigDecimal("0")); |
||||
oilCard.setCardNo(BankNumberUtil.getBrankNumber("8")); |
||||
oilCard.setOpUserId(userInfoModel.getSecUser().getId()); |
||||
oilCard.setOpUserName(userInfoModel.getSecUser().getUserName()); |
||||
oilCard.setCreateTime(new Date()); |
||||
oilCard.setUpdateTime(new Date()); |
||||
oilCard.setStatus(FleetOilCardStatusEnum.status1.getStatus()); |
||||
editData(oilCard); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void setContact(String cardNo, String contactName, String contactPhone) { |
||||
// 查询油卡
|
||||
HighFleetOilCard oilCard = getFleetOilCardByCardNo(cardNo); |
||||
if (oilCard == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油卡"); |
||||
} |
||||
oilCard.setContactName(contactName); |
||||
oilCard.setContactPhone(contactPhone); |
||||
editData(oilCard); |
||||
} |
||||
|
||||
@Override |
||||
public void disabled(String fleetCardNo) { |
||||
// 查询油卡
|
||||
HighFleetOilCard oilCard = getFleetOilCardByCardNo(fleetCardNo); |
||||
if (oilCard == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油卡"); |
||||
} |
||||
if (!oilCard.getStatus().equals(FleetOilCardStatusEnum.status1.getStatus())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡状态错误"); |
||||
} |
||||
oilCard.setStatus(FleetOilCardStatusEnum.status2.getStatus()); |
||||
editData(oilCard); |
||||
} |
||||
|
||||
@Override |
||||
public void enable(String fleetCardNo) { |
||||
// 查询油卡
|
||||
HighFleetOilCard oilCard = getFleetOilCardByCardNo(fleetCardNo); |
||||
if (oilCard == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到油卡"); |
||||
} |
||||
if (!oilCard.getStatus().equals(FleetOilCardStatusEnum.status2.getStatus())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡状态错误"); |
||||
} |
||||
oilCard.setStatus(FleetOilCardStatusEnum.status1.getStatus()); |
||||
editData(oilCard); |
||||
} |
||||
|
||||
@Override |
||||
public List<HighFleetOilCard> getFleetOilCardList(Map<String, Object> param) { |
||||
HighFleetOilCardExample example = new HighFleetOilCardExample(); |
||||
HighFleetOilCardExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0); |
||||
|
||||
if (MapUtils.getLong(param, "companyId") != null) { |
||||
criteria.andCompanyIdEqualTo(MapUtils.getLong(param, "companyId")); |
||||
} |
||||
|
||||
if (MapUtils.getLong(param, "orgId") != null) { |
||||
criteria.andOrgIdEqualTo(MapUtils.getLong(param, "orgId")); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "cardNo"))) { |
||||
criteria.andCardNoLike("%" + MapUtils.getString(param, "cardNo") + "%"); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "contactName"))) { |
||||
criteria.andContactNameLike("%" + MapUtils.getString(param, "contactName") + "%"); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "contactPhone"))) { |
||||
criteria.andContactPhoneLike("%" + MapUtils.getString(param, "contactPhone") + "%"); |
||||
} |
||||
|
||||
if (MapUtils.getLong(param, "createTimeS") != null) { |
||||
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "createTimeS"))); |
||||
} |
||||
|
||||
if (MapUtils.getLong(param, "createTimeE") != null) { |
||||
criteria.andCreateTimeLessThanOrEqualTo(new Date(MapUtils.getLong(param, "createTimeE"))); |
||||
} |
||||
|
||||
if (MapUtils.getInteger(param, "status") != null) { |
||||
criteria.andStatusEqualTo(MapUtils.getInteger(param, "status")); |
||||
} |
||||
|
||||
example.setOrderByClause("create_time desc"); |
||||
return fleetOilCardMapper.selectByExample(example); |
||||
} |
||||
|
||||
@Override |
||||
public List<OilCardOrderModel> getFleetOilCardOrderList(Map<String, Object> param) throws Exception { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,147 @@ |
||||
package com.hai.service.impl; |
||||
|
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.dao.HighFleetOilCardUserMapper; |
||||
import com.hai.entity.*; |
||||
import com.hai.enum_type.UserCardType; |
||||
import com.hai.service.HighFleetOilCardUserService; |
||||
import com.hai.service.HighUserCardService; |
||||
import com.hai.service.HighUserService; |
||||
import org.apache.commons.collections4.MapUtils; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.springframework.stereotype.Service; |
||||
import org.springframework.transaction.annotation.Propagation; |
||||
import org.springframework.transaction.annotation.Transactional; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.math.BigDecimal; |
||||
import java.util.Date; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: HighFleetOilCardUserServiceImpl |
||||
* @author: HuRui |
||||
* @date: 2022/12/12 |
||||
**/ |
||||
@Service("fleetOilCardUserService") |
||||
public class HighFleetOilCardUserServiceImpl implements HighFleetOilCardUserService { |
||||
|
||||
@Resource |
||||
private HighFleetOilCardUserMapper fleetOilCardUserMapper; |
||||
|
||||
@Resource |
||||
private HighUserService userService; |
||||
|
||||
@Resource |
||||
private HighUserCardService userCardService; |
||||
|
||||
@Override |
||||
public void editUser(HighFleetOilCardUser fleetOilCardUser) { |
||||
if (fleetOilCardUser.getId() == null) { |
||||
fleetOilCardUser.setCreateTime(new Date()); |
||||
fleetOilCardUser.setUpdateTime(new Date()); |
||||
fleetOilCardUserMapper.insert(fleetOilCardUser); |
||||
} else { |
||||
fleetOilCardUser.setUpdateTime(new Date()); |
||||
fleetOilCardUserMapper.updateByPrimaryKey(fleetOilCardUser); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
||||
public void importData(HighFleetOilCard fleetOilCard, List<HighFleetOilCardUser> fleetOilCardUserList) { |
||||
for (HighFleetOilCardUser fleetOilCardUser : fleetOilCardUserList) { |
||||
if (StringUtils.isBlank(fleetOilCardUser.getContactName()) |
||||
|| StringUtils.isBlank(fleetOilCardUser.getContactPhone())) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
fleetOilCardUser.setFleetOilCardId(fleetOilCard.getId()); |
||||
fleetOilCardUser.setFleetOilCardNo(fleetOilCard.getCardNo()); |
||||
fleetOilCardUser.setAmountConsume(new BigDecimal("0")); |
||||
fleetOilCardUser.setStatus(1); |
||||
editUser(fleetOilCardUser); |
||||
|
||||
// 查询用户信息
|
||||
HighUser user = userService.findByPhone(fleetOilCardUser.getContactPhone()); |
||||
if (user == null) { |
||||
user = new HighUser(); |
||||
user.setName(fleetOilCard.getContactName()); |
||||
user.setPhone(fleetOilCard.getContactPhone()); |
||||
user.setRegTime(new Date()); |
||||
user.setGold(0); |
||||
user.setStatus(1); |
||||
// 用户信息完整状态
|
||||
// 0:完整
|
||||
// 1:需要填写用户信息
|
||||
// 2:需要填写手机号
|
||||
user.setInfoCompleteStatus(1); |
||||
userService.insertUser(user , null); |
||||
} |
||||
|
||||
// 是否绑定油卡
|
||||
HighUserCard userCard = userCardService.getDetailByUserCardNo(user.getId(), fleetOilCard.getCardNo()); |
||||
if (userCard == null) { |
||||
userCardService.bindCard(UserCardType.type3.getType(), fleetOilCard.getCardNo(), user.getId()); |
||||
} |
||||
|
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public HighFleetOilCardUser getDetailById(Long id) { |
||||
return fleetOilCardUserMapper.selectByPrimaryKey(id); |
||||
} |
||||
|
||||
@Override |
||||
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class) |
||||
public void delete(Long id) { |
||||
HighFleetOilCardUser detail = getDetailById(id); |
||||
if (detail == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到数据"); |
||||
} |
||||
detail.setStatus(0); |
||||
editUser(detail); |
||||
|
||||
// 查询用户信息
|
||||
HighUser user = userService.findByPhone(detail.getContactPhone()); |
||||
if (user != null) { |
||||
HighUserCard userCard = userCardService.getDetailByUserCardNo(user.getId(), detail.getFleetOilCardNo()); |
||||
if (userCard != null) { |
||||
userCard.setStatus(0); |
||||
userCardService.editCard(userCard); |
||||
} |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public List<HighFleetOilCardUser> getUserList(Map<String, Object> param) { |
||||
HighFleetOilCardUserExample example = new HighFleetOilCardUserExample(); |
||||
HighFleetOilCardUserExample.Criteria criteria = example.createCriteria().andStatusNotEqualTo(0); |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "fleetOilCardNo"))) { |
||||
criteria.andFleetOilCardNoEqualTo(MapUtils.getString(param, "fleetOilCardNo")); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "contactName"))) { |
||||
criteria.andContactNameLike("%"+MapUtils.getString(param, "contactName")+"%"); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(MapUtils.getString(param, "contactPhone"))) { |
||||
criteria.andContactPhoneLike("%"+MapUtils.getString(param, "contactPhone")+"%"); |
||||
} |
||||
|
||||
example.setOrderByClause("create_time desc"); |
||||
return fleetOilCardUserMapper.selectByExample(example); |
||||
} |
||||
|
||||
@Override |
||||
public List<HighFleetOilCardUser> getUserListByCard(Long cardId) { |
||||
HighFleetOilCardUserExample example = new HighFleetOilCardUserExample(); |
||||
example.createCriteria().andStatusNotEqualTo(0).andFleetOilCardIdEqualTo(cardId); |
||||
example.setOrderByClause("create_time desc"); |
||||
return fleetOilCardUserMapper.selectByExample(example); |
||||
} |
||||
} |
Loading…
Reference in new issue