use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class ClientWebController method submitOrder.
// TODO 用户提交订单:确认订单页面,点击去支付
@RequestMapping("/submitOrder")
@ResponseBody
public Map<String, Object> submitOrder(@RequestParam(value = "projectId", required = true) Long projectId, @RequestParam(value = "productId", required = true) Long productId, @RequestParam(value = "productNum", required = true) Integer productNum, @RequestParam(value = "productSpecId", required = true) Long productSpecId, @ModelAttribute("enterprise") Enterprise enterprise, @ModelAttribute("userInfo") UserInfo userInfo, @ModelAttribute("einvoice") Einvoice einvoice, @ModelAttribute("businessLicense") BusinessLicense businessLicense, @ModelAttribute("orgCode") OrgCode orgCode, @ModelAttribute("taxregisterCert") TaxRegisterCert taxregisterCert, @ModelAttribute("agent") Agent agent, @ModelAttribute("openBankInfo") OpenBankInfo openBankInfo, @ModelAttribute("identityCard") IdentityCard identityCard, HttpServletRequest request) {
Map<String, Object> retMap = new HashMap<String, Object>();
// 0标识失败,1标识成功
retMap.put("retCode", 0);
HttpSession session = request.getSession();
UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
if (null == webuserInfo || null == webenterprise) {
retMap.put("retMsg", "用户登录信息已失效,请重新登录");
return retMap;
}
ExtraProduct product = extraProductService.selectByPrimaryKey(productId);
if (null == product) {
retMap.put("retMsg", "产品信息不存在,请重新选择产品");
return retMap;
}
ExtraProductSpec productSpec = extraProductSpecService.selectByPrimaryKey(productSpecId);
if (null == productSpec || productSpec.getIsValid().equals(false)) {
retMap.put("retMsg", "规格信息不存在或已经失效,请重新选择规格");
return retMap;
}
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = transactionManager.getTransaction(def);
try {
// 保存发票信息(填写了发票信息才保存,未填写则不保存)
if (StringUtils.isNotBlank(einvoice.getName()) && StringUtils.isNotBlank(einvoice.getIdNumber()) && null != einvoice.geteReiceipt())
einvoice = EinvoiceService.saveEInvoice(webuserInfo.getId(), einvoice);
// 计算订单价格
Double billSum = null;
billSum = productNum * productSpec.getPrice();
// 生成订单
ExtraBill bill = extraBillService.saveExtraBill(projectId, webuserInfo.getId(), webenterprise.getId(), productId, productSpecId, null != einvoice.getId() ? einvoice.getId() : null, productNum, billSum, ComNames.EXTRA_BILL_STATUS_1);
// ""字符串判断,改为Null,避免覆盖数据库中的信息
if (null != enterprise && StringUtils.isBlank(enterprise.getProvince())) {
enterprise.setProvince(null);
}
if (null != enterprise && StringUtils.isBlank(enterprise.getCity())) {
enterprise.setCity(null);
}
if (null != enterprise && StringUtils.isBlank(enterprise.getShortName())) {
enterprise.setShortName(null);
}
// 更新用户信息和企业信息
if (null != enterprise && null == enterprise.getId()) {
enterprise.setId(webenterprise.getId());
}
if (null != userInfo && null == userInfo.getId()) {
userInfo.setId(webuserInfo.getId());
}
enterprise = enterpriseService.updateByPrimaryKeySelective(enterprise);
userInfo = userInfoService.updateByPrimaryKeySelective(userInfo);
// 获取产品需要的附加信息项
ExtraMessage extraMessage = extraMessageService.selectByPrimaryKey(product.getExtraMessage());
// 是否有营业执照信息,默认false没有
boolean hasBl = false;
if (null != extraMessage) {
// //企业信息 认证项(1.企业名称,2.统一社会信用代码/营业执照,3.组织机构代码,4.税务登记号)
if (StringUtils.isNotBlank(extraMessage.getEnterpriseItems())) {
if (StringUtils.isNotBlank(extraMessage.getEnterpriseItems())) {
if (extraMessage.getEnterpriseItems().contains("1")) {
}
if (extraMessage.getEnterpriseItems().contains("2") && !webenterprise.getEnterpriseNature().equals(3)) {
// 事业单位不填写营业执照
hasBl = true;
// 需要统一社会信用代码/营业执照实名认证项,但是页面没有传递过来的时候,用老的
if (null == businessLicense || !StringUtils.isNotBlank(businessLicense.getImgFile())) {
List<BusinessLicense> businessLicenses = businessService.getBusinessLicensesNews(webenterprise.getId());
if (null != businessLicenses && !businessLicenses.isEmpty()) {
businessLicense = businessLicenses.get(0);
businessLicense.setImgFile(null);
}
}
businessLicense = businessService.saveBusinessExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), businessLicense, ComNames.ITEM_STATUS_2, null);
}
if (extraMessage.getEnterpriseItems().contains("3")) {
// 需要统一组织机构代码认证项,但是页面没有传递过来的时候,用老的
if (!(hasBl && businessLicense.getBusinessType().equals(// 五证合一企业不用提交组织机构代码、税务登记信息
1))) {
if (null == orgCode || !StringUtils.isNotBlank(orgCode.getImgFile())) {
List<OrgCode> orgCodes = orgCodeService.getOrgCodesNews(webenterprise.getId());
if (null != orgCodes && !orgCodes.isEmpty()) {
orgCode = orgCodes.get(0);
orgCode.setImgFile(null);
}
}
orgCode = orgCodeService.saveOrgCodeExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), orgCode, ComNames.ITEM_STATUS_2, null);
}
}
if (extraMessage.getEnterpriseItems().contains("4")) {
if (!(hasBl && businessLicense.getBusinessType().equals(// 五证合一企业不用提交组织机构代码、税务登记信息
1))) {
// 保存税务登记证
if (// 事业单位不填写税务登记信息
!webenterprise.getEnterpriseNature().equals(3)) {
// 需要税务登记实名认证项,但是页面没有传递过来的时候,用老的
if (null == taxregisterCert || !StringUtils.isNotBlank(taxregisterCert.getImgFile())) {
List<TaxRegisterCert> taxRegisterCerts = taxCertService.getTaxRegisterCertsNews(webenterprise.getId());
if (null != taxRegisterCerts && !taxRegisterCerts.isEmpty()) {
taxregisterCert = taxRegisterCerts.get(0);
taxregisterCert.setImgFile(null);
}
}
taxregisterCert = taxCertService.saveTaxCertExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), taxregisterCert, ComNames.ITEM_STATUS_2, null);
}
}
}
}
}
// field string --fieldName agentItems
if (StringUtils.isNotBlank(extraMessage.getAgentItems())) {
if (null == agent || StringUtils.isBlank(agent.getFrontImg())) {
List<Agent> agents = agentService.getAgentsNews(webenterprise.getId());
if (null != agents && !agents.isEmpty()) {
agent = agents.get(0);
agent.setFrontImg(null);
agent.setBackImg(null);
}
}
agent = agentService.saveAgentExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), agent, ComNames.ITEM_STATUS_2, null);
}
// field string --fieldName bankItems
if (StringUtils.isNotBlank(extraMessage.getBankItems())) {
if (null == openBankInfo || StringUtils.isBlank(openBankInfo.getBankNumber())) {
List<OpenBankInfo> openBankInfos = openBankInfoService.getOpenBankInfosNews(webenterprise.getId());
if (null != openBankInfos && !openBankInfos.isEmpty()) {
openBankInfo = openBankInfos.get(0);
}
}
openBankInfo = openBankInfoService.saveOpenBankInfoExtraBill(webenterprise.getId(), bill.getId(), webuserInfo.getId(), openBankInfo, ComNames.ITEM_STATUS_2, null);
}
// field string --fieldName identityCardItems
if (StringUtils.isNotBlank(extraMessage.getIdentityCardItems())) {
if (null == identityCard || StringUtils.isBlank(identityCard.getFrontImg())) {
List<IdentityCard> identityCards = identityCardService.getIdentityCardsNews(webenterprise.getId());
if (null != identityCards && !identityCards.isEmpty()) {
identityCard = identityCards.get(0);
identityCard.setFrontImg(null);
identityCard.setBackImg(null);
}
}
identityCard = identityCardService.saveIdentityCardExtraBill(webenterprise.getId(), webenterprise.getEnterpriseSn(), bill.getId(), webuserInfo.getId(), identityCard, ComNames.ITEM_STATUS_2, null);
}
}
transactionManager.commit(status);
retMap.put("retCode", 1);
retMap.put("billId", bill.getId());
// 更新session用户和企业信息
webenterprise = enterpriseService.getEnterpriseById(webenterprise.getId());
webuserInfo = userInfoService.getUserInfoById(webuserInfo.getId());
session.setAttribute("webenterprise", webenterprise);
session.setAttribute("webuserInfo", webuserInfo);
// 记录日志
UserLog userlog = new UserLog();
userlog.setProject(projectId);
userlog.setType("购买增值产品");
userlog.setInfo(webuserInfo.getmPhone() + "购买了" + product.getAppName());
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
return retMap;
} catch (UserInfoServiceException e) {
if (!status.isCompleted()) {
transactionManager.rollback(status);
}
retMap.put("retMsg", e.getMessage());
return retMap;
} catch (Exception e) {
if (!status.isCompleted()) {
transactionManager.rollback(status);
}
UserLog userlog = new UserLog();
userlog.setProject(projectId);
userlog.setType("购买增值产品");
userlog.setInfo("url:submitOrder,详细错误:" + e.getMessage());
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
return retMap;
} finally {
if (!status.isCompleted()) {
transactionManager.rollback(status);
}
}
}
use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class ClientWebController method myApp.
/**
* 获取用户购买后的应用型产品(服务型产品需要排除掉)
* @param request
* @param uiModel
* @return
*/
@RequestMapping("/myapp")
public String myApp(HttpServletRequest request, Model uiModel) {
HttpSession session = request.getSession();
UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
if (null == webuserInfo || null == webenterprise) {
uiModel.addAttribute("errorMsg", "登录已经失效,请重新登录");
return "client/errorpage";
}
// UserInfo webuserInfo = userInfoService.getUserInfoByMphone("18878996651");
// Enterprise webenterprise = enterpriseService.getEnterpriseById(600L);
// TODO 1.选择用户已经付款的订单.并且接口类型是属于需要第三方应用的:(目前软著类的不需要,百旺的需要),若后期需要增加其他类型的应用,再进行增加
// 选择该类型的产品
List<Long> serviceInterfaceNames = new ArrayList<>();
serviceInterfaceNames.add(ComNames.SERVICE_INTERFACE_NAME_BWFPTPT);
ExtraProductExample pExample = new ExtraProductExample();
ExtraProductExample.Criteria criteria = pExample.or();
criteria.andServiceInterfaceNameIn(serviceInterfaceNames);
List<Long> productIds = new ArrayList<>();
Map<String, Object> param = new HashMap<String, Object>();
List<Integer> billStatus = new ArrayList<>();
List<Map<String, Object>> list = new ArrayList<>();
try {
// 获取用户已经付款后的订单.以及产品信息,返回给页面(用户+企业+产品(多个)+订单状态(多个))
productIds = extraProductService.selectIdsByExample(pExample);
param.put("hasProducts", productIds);
param.put("userInfo", webuserInfo.getId());
param.put("enterprise", webenterprise.getId());
billStatus = myAppStatus();
param.put("billStatus", billStatus);
list = extraBillService.selectAppByMap(param);
uiModel.addAttribute("appList", list);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "client/wodeyingyong";
}
use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class ClientWebController method zhifuPage.
/**
* 进入增值订单支付页面,若未配置支付且订单价格为0,则不需要支付
*
* @param billId
* ,增值订单id
* @param request
* @param uiModel
* @return
*/
@RequestMapping("/zhifu/{billId}")
public String zhifuPage(@PathVariable("billId") Long billId, HttpServletRequest request, Model uiModel) {
HttpSession session = request.getSession();
String ip = request.getRemoteAddr();
UserInfo currentUserInfo = (UserInfo) session.getAttribute("webuserInfo");
uiModel.addAttribute("ip", ip);
// 增值订单
ExtraBill bill = extraBillService.selectByPrimaryKey(billId);
if (null == bill || !currentUserInfo.getId().equals(bill.getUniqueId())) {
return "resourceNotFound";
}
// 增值产品
ExtraProduct product = extraProductService.selectByPrimaryKey(bill.getExtraProduct());
if (null == product) {
// 产品不存在
uiModel.addAttribute("errorMsg", "您购买的产品不存在");
return "client/errorpage";
}
// 未配置支付方式,或者订单价格为0,则不用支付
if (StringUtils.isBlank(product.getBankPay()) && StringUtils.isBlank(product.getOnlinePay()) && (null == bill.getBillSum() || bill.getBillSum().equals(0))) {
// 跳转到订单支付成功页面,并将订单状态设置为3已支付 待审核
bill.setBillStatus(ComNames.EXTRA_BILL_STATUS_3);
// TODO 跳转到支付成功或者订单列表页面
return "client/zhifuchenggong";
}
// 获取产品对应的线上支付服务
if (product.getOnlinePay() != null && product.getOnlinePay() != "") {
List<Long> onlinepays = new ArrayList<Long>();
String[] onpay = (product.getOnlinePay()).split(",");
Map<Integer, String> map = new HashMap<Integer, String>();
for (int i = 0; i < onpay.length; i++) {
OnlinePay op = sqlSession.selectOne("com.itrus.portal.db.OnlinePayMapper.selectByPrimaryKey", onpay[i]);
map.put(op.getSort(), onpay[i]);
}
Set<Integer> set = map.keySet();
Object[] obj = set.toArray();
Arrays.sort(obj);
for (int i = (onpay.length - 1); i >= 0; i--) {
String a = map.get(obj[i]);
onlinepays.add(Long.parseLong(a));
}
Map<Long, OnlinePay> opMap = sqlSession.selectMap("com.itrus.portal.db.OnlinePayMapper.selectByExample", "id");
uiModel.addAttribute("opMap", opMap);
uiModel.addAttribute("onlinepays", onlinepays);
Map<Long, PayConfig> pcMap = sqlSession.selectMap("com.itrus.portal.db.PayConfigMapper.selectByExample", "id");
uiModel.addAttribute("pcMap", pcMap);
}
// 获取产品对应的银行汇款服务
if (!StringUtils.isBlank(product.getBankPay())) {
Transfer transfer = sqlSession.selectOne("com.itrus.portal.db.TransferMapper.selectByPrimaryKey", Long.parseLong(product.getBankPay()));
uiModel.addAttribute("transfer", transfer);
}
if (null != product.getBankRemarks()) {
product.setBankRemarks(product.getBankRemarks().replace("\r\n", "<br/><span ></span>"));
}
uiModel.addAttribute("product", product);
session.setAttribute("webbill", bill);
if (null != bill.getExtraProductSpec()) {
uiModel.addAttribute("productSpec", extraProductSpecService.selectByPrimaryKey(bill.getExtraProductSpec()));
}
if (currentUserInfo != null) {
currentUserInfo = userInfoService.getUserInfoById(currentUserInfo.getId());
EnterpriseQqExample enterpriseE = new EnterpriseQqExample();
EnterpriseQqExample.Criteria qqEx = enterpriseE.createCriteria();
qqEx.andProjectIdEqualTo(currentUserInfo.getProject());
EnterpriseQq enterpriseqq = sqlSession.selectOne("com.itrus.portal.db.EnterpriseQqMapper.selectByExample", enterpriseE);
if (enterpriseqq != null && enterpriseqq.getEnterpriseQqLinks() != null) {
uiModel.addAttribute("enterpriseqq", enterpriseqq.getEnterpriseQqLinks());
session.setAttribute("enterpriseqqE", enterpriseqq.getEnterpriseQqLinks());
}
}
// TODO 跳转到支付页面
return "client/zhifu";
}
use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class ClientWebController method submitOrderJYHSQ.
/**
* 仅用户授权产品订单提交接口
* @param projectId
* @param productId
* @param productNum
* @param request
* @return
*/
@RequestMapping("/submitOrder/jyhsq")
@ResponseBody
public Map<String, Object> submitOrderJYHSQ(@RequestParam(value = "projectId", required = true) Long projectId, @RequestParam(value = "productId", required = true) Long productId, @RequestParam(value = "productNum", required = true) Integer productNum, HttpServletRequest request) {
Map<String, Object> retMap = new HashMap<String, Object>();
// 0标识失败,1标识成功
retMap.put("retCode", 0);
HttpSession session = request.getSession();
UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
if (null == webuserInfo || null == webenterprise) {
retMap.put("retMsg", "用户登录信息已失效,请重新登录");
return retMap;
}
ExtraProduct product = extraProductService.selectByPrimaryKey(productId);
if (null == product) {
retMap.put("retMsg", "产品信息不存在,请重新选择产品");
return retMap;
}
// 查询用户是否曾经买过了该产品对于的订单,如果买了,则提示只能购买一次
List<ExtraBill> bills = extraBillService.getHasByExtraBill(webuserInfo.getId(), webenterprise.getId(), productId);
if (null != bills && bills.size() > 0) {
retMap.put("retMsg", "该产品每个用户仅需开通一次即可");
retMap.put("retCode", 2);
return retMap;
}
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = transactionManager.getTransaction(def);
try {
// 计算订单价格
Double billSum = null;
billSum = 0d;
// 生成订单
ExtraBill bill = extraBillService.saveExtraBill(projectId, webuserInfo.getId(), webenterprise.getId(), productId, null, null, productNum, billSum, ComNames.EXTRA_BILL_STATUS_7);
retMap.put("retCode", 1);
retMap.put("billId", bill.getId());
// 记录日志
UserLog userlog = new UserLog();
userlog.setProject(projectId);
userlog.setType("购买增值产品");
userlog.setInfo(webuserInfo.getmPhone() + "购买了" + product.getAppName());
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
transactionManager.commit(status);
return retMap;
} catch (UserInfoServiceException e) {
// TODO: handle exception
if (!status.isCompleted())
transactionManager.rollback(status);
retMap.put("retMsg", e.getMessage());
return retMap;
} catch (Exception e) {
if (!status.isCompleted())
transactionManager.rollback(status);
UserLog userlog = new UserLog();
userlog.setProject(projectId);
userlog.setType("购买增值产品");
userlog.setInfo("url:submitOrder,详细错误:" + e.getMessage());
userlog.setHostId("未知");
userlog.setSn(null == webuserInfo.getUniqueId() ? null : webuserInfo.getUniqueId());
LogUtil.userlog(sqlSession, userlog);
retMap.put("retMsg", "服务端出现未知错误,请联系管理员");
return retMap;
}
}
use of com.itrus.portal.db.UserInfo in project portal by ixinportal.
the class ClientWebController method checkInvoce.
/**
* retCode:0为失败,1为成功
* 发票校验接口
* @param FP_DM:发票代码
* @param FP_HM:发票号码
* @param JYM:发票校验码
*/
@RequestMapping("/fpjy")
@ResponseBody
public Map<String, Object> checkInvoce(@RequestParam(value = "FP_DM", required = true) String FP_DM, @RequestParam(value = "FP_HM", required = true) String FP_HM, @RequestParam(value = "JYM", required = true) String JYM, @RequestParam(value = "productId", required = true) Long productId, HttpServletRequest request) {
HttpSession session = request.getSession();
Map<String, Object> retMap = new HashMap<>();
retMap.put("retCode", 0);
UserInfo webuserInfo = (UserInfo) session.getAttribute("webuserInfo");
Enterprise webenterprise = (Enterprise) session.getAttribute("webenterprise");
if (null == webuserInfo || null == webenterprise) {
retMap.put("retMsg", "用户登录信息已失效,请重新登录");
return retMap;
}
//
Project project = (Project) session.getAttribute("webproject");
if (null == project) {
retMap.put("retMsg", "项目信息不存在");
return retMap;
}
// 获取发票校验的应用
ExtraProduct product = extraProductService.selectByPrimaryKey(productId);
if (null == product) {
retMap.put("retMsg", "产品信息不存在");
return retMap;
}
if (StringUtils.isBlank(FP_DM) || StringUtils.isBlank(FP_HM) || StringUtils.isBlank(JYM)) {
retMap.put("retMsg", "发票代码,发票号码,发票校验码三者都不能为空");
return retMap;
}
Map<String, String> invoiceMap = baiWangService.verifyInvoice(FP_DM, FP_HM, JYM);
retMap.putAll(invoiceMap);
if (null != retMap.get("REPLYCODE") && retMap.get("REPLYCODE").equals("0000")) {
retMap.put("retCode", 1);
String info = invoiceMap.toString().replaceAll(" ", "");
checkInvoiceLogService.insertCheckInvoiceLog(product.getAppName(), webenterprise.getEnterpriseName(), info, project.getId(), webuserInfo.getRealName());
return retMap;
} else {
String REPLYMSG = (String) retMap.get("REPLYMSG");
retMap.put("retMsg", REPLYMSG);
return retMap;
}
}
Aggregations