use of com.itrus.portal.db.EditBill in project portal by ixinportal.
the class BillWebController method delete.
// 删除填写中订单
@RequestMapping(value = "editbill/{id}.html", method = RequestMethod.DELETE, produces = "text/html")
@ResponseBody
public String delete(@PathVariable("id") Long id, HttpServletRequest request, Model uiModel) {
EditBill editBill = sqlSession.selectOne("com.itrus.portal.db.EditBillMapper.selectByPrimaryKey", id);
HttpSession session = request.getSession();
UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
if (editBill == null) {
// uiModel.addAttribute("message", "未找到要删除快递");
return "未找到要删除订单";
} else {
try {
EditBillService.delectEditInfo(editBill, userInfo.getUniqueId());
UserLog userlog = new UserLog();
userlog.setProject(userInfo.getProject());
userlog.setType("删除填写中订单");
userlog.setInfo(userInfo.getmPhone() + "删除了填写中订单" + editBill.getId());
userlog.setHostId("未知");
userlog.setSn(null == userInfo.getUniqueId() ? null : userInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
} catch (Exception e) {
return "要删除填写中订单【" + editBill.getId() + "】存在关联,无法删除";
}
}
return null;
}
use of com.itrus.portal.db.EditBill in project portal by ixinportal.
the class BillWebController method billList.
/**
* 订单列表
*
* @param billStatus
* 0未完成订单,1已完成订单
* @param request
* @param uiModel
* @return
*/
@RequestMapping(produces = "text/html")
public String billList(@RequestParam(value = "billStatus", required = false) Integer billStatus, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "size", required = false) Integer size, @RequestParam(value = "page2", required = false) Integer page2, @RequestParam(value = "size2", required = false) Integer size2, HttpServletRequest request, Model uiModel) {
HttpSession session = request.getSession();
Boolean verifyCodeStatus = (Boolean) session.getAttribute("webverifyCodeStatus");
Enterprise enterprise = (Enterprise) session.getAttribute("webenterprise");
UserInfo userInfo = (UserInfo) session.getAttribute("webuserInfo");
if (null == verifyCodeStatus || !verifyCodeStatus || null == userInfo) {
// 登录状态失效,跳转到登录页面
return "redirect:/userInfoWeb/denglu.html";
}
if (userInfo != null && enterprise == null) {
// 登录未获取到企业信息,跳转到选择企业页面
return "redirect:/userInfoWeb/choiceEnterprise";
}
uiModel.addAttribute("billStatus", billStatus);
if (page == null || page < 1) {
page = 1;
}
if (size == null || size < 1) {
size = 5;
}
BillExample billExampl = new BillExample();
BillExample.Criteria criteria = billExampl.or();
// web页面不显示解锁的订单产品
List<Long> keyUnlockProductIds = productService.getKeyUnlockProductIds();
if (null != keyUnlockProductIds && !keyUnlockProductIds.isEmpty()) {
criteria.andProductNotIn(keyUnlockProductIds);
}
// 查询当前用户当前企业的订单
// 当前用户
criteria.andUniqueIdEqualTo(userInfo.getId());
// 当前企业 v 76
criteria.andEnterpriseEqualTo(enterprise.getId());
if (null == billStatus || 0 == billStatus) {
// 未完成订单:订单状态不为8
criteria.andBillStatusNotEqualTo(ComNames.BILL_STATUS_8);
criteria.andIsDeleteEqualTo(false);
} else if (1 == billStatus) {
// 订单状态为已完成
criteria.andBillStatusEqualTo(ComNames.BILL_STATUS_8);
}
Integer count = sqlSession.selectOne("com.itrus.portal.db.BillMapper.countByExample", billExampl);
if (page > 1 && size * (page - 1) >= count) {
page = (count + size - 1) / size;
}
uiModel.addAttribute("count", count);
uiModel.addAttribute("pages", (count + size - 1) / size);
uiModel.addAttribute("page", page);
uiModel.addAttribute("size", size);
Integer offset = size * (page - 1);
billExampl.setOffset(offset);
billExampl.setLimit(size);
billExampl.setOrderByClause("create_time desc");
List<Bill> billList = sqlSession.selectList("com.itrus.portal.db.BillMapper.selectByExample", billExampl);
uiModel.addAttribute("billList", billList);
uiModel.addAttribute("itemcount", billList.size());
Map<Long, Delivery> deliveryMap = sqlSession.selectMap("com.itrus.portal.db.DeliveryMapper.selectByExample", null, "id");
uiModel.addAttribute("deliveryMap", deliveryMap);
// 填写中订单
if (page2 == null || page2 < 1) {
page2 = 1;
}
if (size2 == null || size2 < 1) {
size2 = 5;
}
EditBillExample ebEx = new EditBillExample();
EditBillExample.Criteria criteria2 = ebEx.or();
// 查询当前用户当前企业的订单
// 当前用户
criteria2.andUserInfoIdEqualTo(userInfo.getId());
//
criteria2.andEnterpriseIdEqualTo(enterprise.getId());
Integer count2 = sqlSession.selectOne("com.itrus.portal.db.EditBillMapper.countByExample", ebEx);
if (page2 > 1 && size2 * (page2 - 1) >= count2) {
page2 = (count2 + size2 - 1) / size2;
}
uiModel.addAttribute("count2", count2);
uiModel.addAttribute("pages2", (count2 + size2 - 1) / size2);
uiModel.addAttribute("page2", page2);
uiModel.addAttribute("size2", size2);
Integer offset2 = size2 * (page2 - 1);
// 产品信息:
/*Map<Long, Product> productMap = billService
.getProductMapByUserInfoId(userInfo.getId());*/
// if ((null == billStatus || billStatus.equals(2)) && count2 != 0) {
Map<Long, Product> productMap = sqlSession.selectMap("com.itrus.portal.db.ProductMapper.selectByExample", "id");
// }
uiModel.addAttribute("productMap", productMap);
// 获取产品关联的数字证书id
Set<Long> certIds = productService.getDigitalCertIds(productMap);
// 产品关联的数字证书:
Map<Long, DigitalCert> digitalCertMap = digitalCertService.getDigitalCertByProductMap(certIds);
uiModel.addAttribute("digitalCertMap", digitalCertMap);
// 获取订单对应的产品规格
Map<Long, ProductSpec> productSpecMap = productSpecService.getProductSpec(billList);
uiModel.addAttribute("productSpecMap", productSpecMap);
ebEx.setOffset(offset2);
ebEx.setLimit(size2);
ebEx.setOrderByClause("create_time desc");
List<EditBill> editBillList = sqlSession.selectList("com.itrus.portal.db.EditBillMapper.selectByExample", ebEx);
// 获取填写中订单对应的产品规格
Map<Long, ProductSpec> editBill_productSpecMap = productSpecService.getEditBillProductSpec(editBillList);
uiModel.addAttribute("editBill_productSpecMap", editBill_productSpecMap);
uiModel.addAttribute("editBillList", editBillList);
uiModel.addAttribute("itemcount2", editBillList.size());
// 订单是否对应的pfx的用户下载证书.
Map<Long, Long> pfxMap = billWebService.getPfxCertBufByBills(billList);
uiModel.addAttribute("pfxmap", pfxMap);
session.removeAttribute("sessionPlist");
session.removeAttribute("enterpriseqqE");
System.out.println(enterprise.getId());
Map param = new HashMap();
param.put("id", enterprise.getId());
if (userInfo.getmPhone() != null) {
param.put("phone", userInfo.getmPhone());
}
List<Map<String, Object>> plist = sqlSession.selectList("com.itrus.portal.db.ProjectMapper.selectProjectId", param);
Map<Long, EnterpriseQq> qqMap = new HashMap<Long, EnterpriseQq>();
for (int i = 0; i < plist.size(); i++) {
EnterpriseQqExample enterpriseQ = new EnterpriseQqExample();
EnterpriseQqExample.Criteria qqEx = enterpriseQ.createCriteria();
// System.out.println(plist.get(i));
Long pid = Long.parseLong(plist.get(i).get("id").toString());
// System.out.println(pid);
qqEx.andProjectIdEqualTo(pid);
EnterpriseQq enterpriseqq = sqlSession.selectOne("com.itrus.portal.db.EnterpriseQqMapper.selectByExample", enterpriseQ);
if (enterpriseqq != null) {
// uiModel.addAttribute("eid", enterpriseqq.getId());
qqMap.put(pid, enterpriseqq);
// session.setAttribute("enterpriseqqE", enterpriseqq.getEnterpriseQqLinks());
}
}
session.setAttribute("sessionqqMap", qqMap);
session.setAttribute("sessionPlist", plist);
return "ixinweb/zhanghuguanli_dingdanxinxi";
}
use of com.itrus.portal.db.EditBill in project portal by ixinportal.
the class ProductSpecServiceImpl method getEditBillProductSpec.
/**
* 获取填写中订单list对应的规格Map
*
* @param billList
* @return
*/
public Map<Long, ProductSpec> getEditBillProductSpec(List<EditBill> editBillList) {
Map<Long, ProductSpec> productSpecMap = new HashMap<Long, ProductSpec>();
List<Long> productSpecIds = new ArrayList<Long>();
for (EditBill bill : editBillList) {
if (null != bill.getProductSpec() && 0 != bill.getProductSpec()) {
productSpecIds.add(bill.getProductSpec());
}
}
if (productSpecIds.isEmpty())
return productSpecMap;
ProductSpecExample example = new ProductSpecExample();
ProductSpecExample.Criteria criteria = example.or();
criteria.andIdIn(productSpecIds);
productSpecMap = sqlSession.selectMap("com.itrus.portal.db.ProductSpecMapper.selectByExample", example, "id");
return productSpecMap;
}
use of com.itrus.portal.db.EditBill in project portal by ixinportal.
the class ImageByBase64 method saveImage.
/**
* 将图片写入磁盘
*
* @param fileBase64
* 图片的base64字符串
* @param saveFile
* 将写入的磁盘文件
* @throws ServiceNullException
*/
public void saveImage(String fileBase64, File saveFile) throws IOException, UserInfoServiceException, ServiceNullException {
if (fileBase64.indexOf("/reviewWeb/img/") != -1) {
String editbillImg = fileBase64.substring(fileBase64.indexOf("/reviewWeb/img/") + 15, fileBase64.length());
String[] ss = editbillImg.split("/");
Long type = Long.parseLong(ss[0]);
Long id = Long.parseLong(ss[1]);
Long num = Long.parseLong(ss[2]);
File tempFile = getImg(type, id, num);
if (null == tempFile) {
logger.error("fileBase64:" + fileBase64);
}
CopyFile.copyFile(tempFile, saveFile);
return;
}
// 检查传递的base64信息是否为图片地址:/img/{type}/{random}?t=uploadTime
if (fileBase64.length() < 100 && fileBase64.indexOf("/img/") != -1) {
try {
String[] baseInfos = fileBase64.split("/");
String[] uploadStr = baseInfos[3].split("=");
String random = uploadStr[0].substring(0, uploadStr[0].indexOf("?"));
String upload = uploadStr[1];
// upload = upload.substring(upload.indexOf("=") + 1);
// 上传时间
Date uploadTime = new Date(Long.parseLong(upload));
TempPic tempPic = tempPicService.getTempPicByRandomAndTime(random, uploadTime);
if (null == tempPic) {
logger.error("fileBase64:" + fileBase64);
throw new ServiceNullException("未找到上传的临时图片记录");
}
String type = baseInfos[2];
String fileName = null;
// } else
if ("1".equals(type)) {
// 证件图片A
fileName = tempPic.getImgFileA();
} else if ("2".equals(type)) {
// 证件图片B
fileName = tempPic.getImgFileB();
}
if (null == fileName) {
logger.error("fileBase64:" + fileBase64);
throw new ServiceNullException("未找到上传的临时图片名称");
}
File tempFile = new File(tempPicService.getDir(random), fileName);
// 将临时文件写入到需要保存的地方
CopyFile.copyFile(tempFile, saveFile);
} catch (Exception e) {
e.printStackTrace();
logger.error("fileBase64:" + fileBase64);
throw new ServiceNullException("未找到上传的临时图片记录信息");
}
} else if (fileBase64.indexOf("/editbillImg/") != -1) {
String editbillImg = fileBase64.substring(fileBase64.indexOf("/editbillImg/") + 13, fileBase64.length());
String[] ss = editbillImg.split("/");
String userSn = ss[2];
Integer type = Integer.parseInt(ss[0]);
Long editBillId = Long.parseLong(ss[1]);
EditBill editBill = null;
String fileName = "";
if (null == type || StringUtils.isBlank(userSn) || null == editBillId) {
logger.error("fileBase64:" + fileBase64);
throw new ServiceNullException("填写中的订单的图片url不正确");
}
editBill = sqlsession.selectOne("com.itrus.portal.db.EditBillMapper.selectByPrimaryKey", editBillId);
if (null == editBill) {
logger.error("fileBase64:" + fileBase64);
throw new ServiceNullException("找不到填写中的订单信息");
}
/*
* 0 营业执照图片, 1 组织机构代码图片, 2 税务登记图片, 3 法人正面图片
* 4 法人反面图片, 5 授权书图片, 6 代理人正面图片, 7 代理人反面图片
* */
if (type.equals(0)) {
fileName = editBill.getBlImgFile();
} else if (type.equals(1)) {
fileName = editBill.getOcImgFile();
} else if (type.equals(2)) {
fileName = editBill.getTrImgFile();
} else if (type.equals(3)) {
fileName = editBill.getIcfImgFile();
} else if (type.equals(4)) {
fileName = editBill.getIcbImgFile();
} else if (type.equals(5)) {
fileName = editBill.getPrImgFile();
} else if (type.equals(6)) {
fileName = editBill.getAtfImgFile();
} else if (type.equals(7)) {
fileName = editBill.getAtbImgFile();
}
File tempFile;
try {
tempFile = new File(filePathUtils.getDir(null, userSn), fileName);
// 将临时文件写入到需要保存的地方
CopyFile.copyFile(tempFile, saveFile);
} catch (Exception e) {
logger.error("fileBase64:" + fileBase64);
e.printStackTrace();
throw new ServiceNullException("填写中的订单的图片url不正确");
}
} else {
// Base64解码
byte[] b = Base64.decode(fileBase64);
OutputStream out = new FileOutputStream(saveFile);
out.write(b);
out.flush();
out.close();
}
}
Aggregations