Search in sources :

Example 16 with Bill

use of com.itrus.portal.db.Bill in project portal by ixinportal.

the class PsCourierController method confirm.

// 确认配送
@RequestMapping(value = "confirm/{id}", produces = "text/html")
public String confirm(@PathVariable("id") Long id, Model uiModel, @Valid Delivery delivery, @Valid CourierInfo courierInfo, @RequestParam(value = "dvid", required = false) Integer dvid, @RequestParam(value = "itnum", required = false) Integer itnum, @RequestParam(value = "billid", required = false) Integer billid, @RequestParam(value = "ivc", required = false) Integer ivc, @RequestParam(value = "items1", required = false) String items1, @RequestParam(value = "items2", required = false) String items2) {
    // 得到配送内容
    int itemsnum = 0;
    if (items1 != null && items2 != null) {
        itemsnum = 3;
    } else if (items2 != null) {
        itemsnum = Integer.parseInt(items2);
    } else {
        itemsnum = Integer.parseInt(items1);
    }
    // 添加配送信息
    courierInfo.setCourierItems(itemsnum);
    courierInfo.setCourierTime(new Date());
    courierInfo.setCourierStatus(1);
    courierInfo.setMessageSms(0);
    sqlSession.insert("com.itrus.portal.db.CourierInfoMapper.insertSelective", courierInfo);
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billid);
    Product pdt = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    Product product1 = null;
    Product product2 = null;
    Product product3 = null;
    Integer hasKey = 0;
    /*if (null != pdt.getIsCombined() && pdt.getIsCombined() ==1){
				String[] comb = pdt.getCombinedId().split(",");
				product1 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", Long.parseLong(comb[0]));
				product2 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", Long.parseLong(comb[1]));
				if (null != product1.getUsbKey() || null != product2.getUsbKey()){
					hasKey = 1;
				}
				if(comb.length==3){
					product3 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", Long.parseLong(comb[2]));
					if (null != product3.getUsbKey()){
						hasKey = 1;
					}
				}
			}*/
    if (null != bill.getProduct1()) {
        product1 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct1());
        if (null != product1.getUsbKey()) {
            hasKey = 1;
        }
    }
    if (null != bill.getProduct2()) {
        product2 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct2());
        if (null != product2.getUsbKey()) {
            hasKey = 1;
        }
    }
    if (null != bill.getProduct3()) {
        product3 = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct3());
        if (null != product3.getUsbKey()) {
            hasKey = 1;
        }
    }
    // itnum=0 为第一次配送
    if (itnum == 0) {
        // 修改配送地址,并保存
        Delivery delivery1 = sqlSession.selectOne("com.itrus.portal.db.DeliveryMapper.selectByPrimaryKey", dvid);
        delivery1.setReceiver(delivery.getReceiver());
        delivery1.setRvPhone(delivery.getRvPhone());
        delivery1.setDetailAdds(delivery.getDetailAdds());
        delivery1.setRegionCodes(delivery.getRegionCodes());
        sqlSession.update("com.itrus.portal.db.DeliveryMapper.updateByPrimaryKeySelective", delivery1);
    }
    // itnum=1 为第二次配送,
    if (itnum == 1 || itemsnum == 3 || (itemsnum == 1 && ivc == 0) || (ivc == 1 && itemsnum == 2 && (pdt.getUsbKey() == null && hasKey == 0))) {
        // 修改bill表里的配送时间,和设置订单状态为完成
        bill.setBillStatus(8);
        bill.setDeliveryTime(new Date());
        sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
    }
    List<Map> l1 = sqlSession.selectList("com.itrus.portal.db.CourierInfoMapper.selectCourierInfoMaxId");
    // 自动发短信
    sendMoreSmsFhtz((long) l1.get(0).get("id"));
    String oper = "确认快递配送";
    String info = "快递订单: " + courierInfo.getCourierId();
    LogUtil.adminlog(sqlSession, oper, info);
    return "redirect:/pscourier";
}
Also used : Bill(com.itrus.portal.db.Bill) Product(com.itrus.portal.db.Product) Delivery(com.itrus.portal.db.Delivery) Map(java.util.Map) HashMap(java.util.HashMap) Date(java.util.Date) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with Bill

use of com.itrus.portal.db.Bill in project portal by ixinportal.

the class MakeCertController method userCertMakeSealStatus.

/**
 * 证书签章授权成功
 *
 * @param type
 *            make表示证书签章,authori表示证书授权
 * @param sealImage
 *            签章时候需传图片base64
 * @param enterpriseId
 * @param userCertId
 * @return
 */
@RequestMapping("/userCertMakeSealStatus")
@ResponseBody
public Map<String, Object> userCertMakeSealStatus(@RequestParam(value = "type", required = true) String type, @RequestParam(value = "sealImage", required = false) String sealImage, @RequestParam(value = "billId", required = true) Long billId, @RequestParam(value = "enterpriseId", required = false) Long enterpriseId, @RequestParam(value = "userCertId", required = true) Long userCertId) {
    Map<String, Object> map = new HashMap<String, Object>();
    map.put("retCode", 0);
    UserCert userCert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByPrimaryKey", userCertId);
    if ("make".equals(type)) {
        // 制章
        // if (StringUtils.isBlank(sealImage)) {
        // map.put("retMsg", "获取签章图片失败,请重试");
        // return map;
        // }
        // 0未制章,1已制章
        userCert.setMakeSealmstatus(1);
    // Enterprise enterprise = sqlSession.selectOne(
    // "com.itrus.portal.db.EnterpriseMapper.selectByPrimaryKey",
    // enterpriseId);
    // 保存图片
    // try {
    // File imgDir = filePathUtils.getEnterpriseFile(enterprise
    // .getEnterpriseSn());
    // String filename = System.currentTimeMillis() + "seal"
    // + Math.round(Math.random() * 89 + 10) + ".gif";
    // // 创建磁盘文件
    // File imgFile = new File(imgDir, filename);
    // imageByBase64.saveImage(sealImage, imgFile);
    // if (null != imgFile && imgFile.isFile()) {
    // enterprise.setSealImage(imgFile.getName());
    // sqlSession
    // .update("com.itrus.portal.db.EnterpriseMapper.updateByPrimaryKey",
    // enterprise);
    // }
    // } catch (Exception e) {
    // map.put("retMsg", e.getMessage());
    // return map;
    // }
    } else if ("authori".equals(type)) {
        // 授权
        // 0未授权,1已授权
        userCert.setMakeSealastatus(1);
    } else if ("amake".equals(type)) {
        // 0未制章,1已制章
        userCert.setMakeSealmstatus(1);
        // 0未授权,1已授权
        userCert.setMakeSealastatus(1);
    }
    sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKey", userCert);
    // 更新订单状态
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    // 查询项目产品
    Product product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    updateBillStatus(bill, product);
    map.put("retCode", 1);
    return map;
}
Also used : HashMap(java.util.HashMap) Bill(com.itrus.portal.db.Bill) Product(com.itrus.portal.db.Product) JSONObject(com.alibaba.fastjson.JSONObject) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 18 with Bill

use of com.itrus.portal.db.Bill in project portal by ixinportal.

the class MakeCertController method makeSealBaiRun.

/**
 * 百润制章
 *
 * @param billId
 *            订单id
 * @param csr
 *            证书base64编码
 * @param request
 * @param response
 * @return
 * @throws EncDecException
 * @throws Exception
 */
@RequestMapping(value = "/makeSealBaiRun", method = RequestMethod.POST)
public void makeSealBaiRun(@RequestParam(value = "billId", required = true) Long billId, @RequestParam(value = "sealpic", required = true) String sealpic, @RequestParam(value = "csr", required = true) String csr, @RequestParam(value = "productId", required = false) Long productId, HttpServletRequest request, HttpServletResponse response) throws EncDecException, Exception {
    // Map<String, Object> map = new HashMap<String, Object>();
    // map.put("retCode", 0);
    // 获取签章模版
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", billId);
    // 查询项目产品
    Product product = null;
    // 如为组合产品productId不为空
    if (null == productId) {
        product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", bill.getProduct());
    } else {
        product = sqlSession.selectOne("com.itrus.portal.db.ProductMapper.selectByPrimaryKey", productId);
    }
    /*
		 * if (null == product.getMakeSealServer() ||
		 * product.getMakeSealServer() <= 0) { map.put("retMsg", "该产品未配置签章服务");
		 * return map; }
		 */
    MakeSealServer makeSealServer = sqlSession.selectOne("com.itrus.portal.db.MakeSealServerMapper.selectByPrimaryKey", product.getMakeSealServer());
    // 签章服务配置
    List<MakeSealConfig> makeSealConfigs = sqlSession.selectList("com.itrus.portal.db.MakeSealConfigMapper.selectByExample");
    /*
		 * if (makeSealConfigs.isEmpty()) { map.put("retMsg", "没有找到签章服务配置");
		 * return map; }
		 */
    Map<String, Object> param = new HashMap<>();
    param.put("id", bill.getId());
    UserCertExample userc = new UserCertExample();
    UserCertExample.Criteria us = userc.createCriteria();
    us.andIdNotEqualTo(bill.getId());
    userc.setOrderByClause("cert_start_time desc");
    userc.setLimit(1);
    UserCert usercert = sqlSession.selectOne("com.itrus.portal.db.UserCertMapper.selectByExample", userc);
    CertBufExample certbuf = new CertBufExample();
    CertBufExample.Criteria cert = certbuf.createCriteria();
    cert.andIdEqualTo(usercert.getCertBuf());
    CertBuf organ = sqlSession.selectOne("com.itrus.portal.db.CertBufMapper.selectByExample", certbuf);
    if (makeSealConfigs.get(1).getName().contains(makeSealServer.getFirm())) {
        MakeSealConfig makeSealConfig = makeSealConfigs.get(0);
        // 替换-印章名称
        if (StringUtils.isNotBlank(makeSealServer.getSealName())) {
            UIDInfoUtils uidutils = new UIDInfoUtils();
            uidutils.initService(businessService, orgCodeService, taxCertService, identityCardService, userInfoService, enterpriseService);
            makeSealServer.setSealName(uidutils.getUidInfo(billId, makeSealServer.getSealName()));
        }
        try {
            log.error("request.getLocalAddr : " + request.getLocalAddr() + ",CSR:" + organ.getCertBuf());
            boolean userbool = true;
            if (usercert.getIsRegister() == null || !usercert.getIsRegister().equals(1)) {
                usercert.setIsRegister(1);
                sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKeySelective", usercert);
                // 注册用户
                userbool = UserSDK.addUser(null, makeSealConfig.getAddressKey(), organ.getCertBuf(), makeSealServer.getAccount(), Constant.APP, Constant.Token);
                log.error("makeCertController userbool : " + userbool);
            // log.info(makeSealConfig.getAddressKey());
            // log.info(String.valueOf(userbool));
            }
            // 制作印章
            Map<String, Object> result = SealSDK.makeSeal(makeSealServer.getSealName(), organ.getCertBuf(), sealpic, "公章", Constant.APP, Constant.Token);
            if (userbool && (Boolean) result.get("state")) {
                // 制章完成后的印章数据,返回到前台用作导章
                log.error("SealSDK : context");
            } else {
                log.error("SealSDK : ");
            // map.put("retMsg", "制章异常");
            }
            response.setCharacterEncoding("GBK");
            response.setContentType("text/html");
            OutputStream out = response.getOutputStream();
            out.write(result.get("data").toString().getBytes("GBK"));
            // map.put("bairun_ret",
            // result.get("data").toString().getBytes("GBK"));
            out.flush();
            out.close();
        } catch (Exception e) {
            e.printStackTrace();
        // map.put("retMsg", e.getMessage());
        }
    } else {
        MakeSealConfig makeSealConfig = makeSealConfigs.get(1);
        // 替换-印章名称
        if (StringUtils.isNotBlank(makeSealServer.getSealName())) {
            UIDInfoUtils uidutils = new UIDInfoUtils();
            uidutils.initService(businessService, orgCodeService, taxCertService, identityCardService, userInfoService, enterpriseService);
            makeSealServer.setSealName(uidutils.getUidInfo(billId, makeSealServer.getSealName()));
        }
        try {
            log.error("request.getLocalAddr : " + request.getLocalAddr() + ",CSR:" + organ.getCertBuf());
            boolean userbool = true;
            if (usercert.getIsRegister() != null && !usercert.getIsRegister().equals(1)) {
                usercert.setIsRegister(1);
                sqlSession.update("com.itrus.portal.db.UserCertMapper.updateByPrimaryKeySelective", usercert);
                // 注册用户
                userbool = UserSDK.addUser(null, makeSealConfig.getAddressKey(), organ.getCertBuf(), Constant.TianWeiChenXin, Constant.APP, Constant.Token);
            }
            // 制作印章
            Map<String, Object> result = SealSDK.makeSeal(makeSealServer.getSealName(), organ.getCertBuf(), sealpic, "公章", Constant.APP, Constant.Token);
            String s = Constant.IP;
            if (userbool && (Boolean) result.get("state")) {
                // 制章完成后的印章数据,返回到前台用作导章
                log.error("SealSDK : " + result.get("data").toString());
            } else {
                log.error("SealSDK : ");
            // map.put("retMsg", "制章异常");
            }
            response.setCharacterEncoding("GBK");
            response.setContentType("text/html");
            OutputStream out = response.getOutputStream();
            out.write(result.get("data").toString().getBytes("GBK"));
            // map.put("bairun_ret",
            // result.get("data").toString().getBytes("GBK"));
            out.flush();
            out.close();
            System.out.println(result.get("data").toString().getBytes("GBK").toString() + ":JS");
        } catch (Exception e) {
            e.printStackTrace();
        // map.put("retMsg", e.getMessage());
        }
    }
// map.put("retCode", 1);
// return map;
}
Also used : HashMap(java.util.HashMap) UserCertExample(com.itrus.portal.db.UserCertExample) OutputStream(java.io.OutputStream) Product(com.itrus.portal.db.Product) EncDecException(com.itrus.portal.exception.EncDecException) IOException(java.io.IOException) RaServiceUnavailable_Exception(cn.topca.tca.ra.service.RaServiceUnavailable_Exception) UIDInfoUtils(com.itrus.portal.utils.UIDInfoUtils) MakeSealServer(com.itrus.portal.db.MakeSealServer) MakeSealConfig(com.itrus.portal.db.MakeSealConfig) Bill(com.itrus.portal.db.Bill) CertBuf(com.itrus.portal.db.CertBuf) JSONObject(com.alibaba.fastjson.JSONObject) CertBufExample(com.itrus.portal.db.CertBufExample) UserCert(com.itrus.portal.db.UserCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 19 with Bill

use of com.itrus.portal.db.Bill in project portal by ixinportal.

the class MakeCertController method savecertinfo.

// 保存certinfo信息至 uid 字段
@RequestMapping(value = "/save/{id}", produces = "text/html")
@ResponseBody
public Map<String, Object> savecertinfo(@RequestParam(value = "certinfo", required = false) String certinfo, @PathVariable("id") Long id) {
    Map<String, Object> ret = new HashMap<String, Object>();
    Bill bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
    bill.setUid(certinfo);
    sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKeySelective", bill);
    ret.put("status", 0);
    return ret;
}
Also used : HashMap(java.util.HashMap) Bill(com.itrus.portal.db.Bill) JSONObject(com.alibaba.fastjson.JSONObject) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 20 with Bill

use of com.itrus.portal.db.Bill in project portal by ixinportal.

the class MakeCertController method push.

/**
 * 手动推送
 *
 * @param id
 * @param uiModel
 * @return
 */
@RequestMapping(value = "/{id}/{type}", method = RequestMethod.GET, produces = "text/html")
@ResponseBody
public String push(@PathVariable("id") Long id, @PathVariable("type") Long type, Model uiModel) {
    SignatureConfig sc = null;
    JSONObject data = null;
    JSONObject org = null;
    JSONObject result = null;
    Bill bill = null;
    /*if(type==1){
			try {
				bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
				log.error("bill.getMcstatus()="+bill.getMcstatus()+"bill="+bill);
				if(null == bill) {
					//log.error(bill.getMcstatus()+"---------------------------------------------"+bill);
					//System.out.println(bill.getMcstatus()+"=******************************="+bill);
					return "该订单无法推送";
				}
				Product product = productService.getProductById(bill.getProduct());
				sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey",
						product.getSignature());
				Enterprise enterprise = enterpriseService.getEnterpriseByBillId(id);
				BusinessLicense bl = businessService.getBusinessByBillId((id), null);
				if (org == null) {
					org = new JSONObject();
					
				}
				org.put("userType", 1);
				org.put("fullName", bl.getEnterpriseName());
				if (bl != null && bl.getBusinessType() == 1) {
					org.put("orgCode", bl.getLicenseNo());
				} else {
					TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId((id), null);
					org.put("orgCode", tc == null ? "" : tc.getCertNo());
				}
				org.put("papersType", "营业执照");
				UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey",
						bill.getUniqueId());
				org.put("businessNum", userInfo.getTelephone());
				// IdentityCard ic =
				// identityCardService.getIdentityCardByBillId(Long.parseLong(String.valueOf(map.get("id"))),
				// null);
				org.put("legalPersonName", bl == null ? "" : bl.getLegalPerson());
				Agent agent = agentService.getAgentByBillId((id), null);
				org.put("transactorName", agent == null ? enterprise.getEnterpriseName() : agent.getName());
				if (agent != null && agent.getCardType() == 1) {
					org.put("transactorIdCardNum", agent.getIdCode());
				}
				org.put("transactorMobile", userInfo.getmPhone());
				org.put("realInfoOrder", bill.getBillId());
				org.put("realInfoUid", bill.getUniqueId());
				if (data == null) {
					data = new JSONObject();
				}
				data.put("appId", sc.getAppId());
				data.put("timestamp", System.currentTimeMillis());
				data.put("user", org);
				data.put("autoCert", true);
				data.put("autoSeal", true);
				// String content =
				// "{\"autoCert\":true,\"timestamp\":1472105170418,\"apiId\":\"test\",\"autoSeal\":true,\"user\":{\"transactorIdCardNum\":\"120102198904025625\",\"transactorMobile\":\"15822452770\",\"orgCode\":\"120116328553325\",\"papersType\":\"营销执照\",\"businessNum\":\"022-88956296\",\"realInfoUid\":\"151\",\"fullName\":\"天津瑞普生物技术股份有限公司空港经济区分公司\",\"legalPersonName\":\"刘建\",\"transactorName\":\"李洋\",\"realInfoOrder\":\"TWCX20160824170928580820\",\"userType\":1}}";
				// bill =
				// sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey",
				// map.get("id"));
				if (bill.getMcstatus() != null && bill.getMcstatus() == 1) {
					// return "redirect:/makecert";
					return null;
				}
				log.error("打印data="+data.toString());
				
				log.error("----------接口地址**************"+sc.getAddress() + USER_URL+"***********服务密钥**********"+sc.getAddressKey());
				result = JSONObject
						.parseObject(RequestUtils.post(sc.getAddress() + USER_URL, data.toString(), sc.getAddressKey()));
				log.equals("MakeCert_push_result : " + result);
				if (result.getBoolean("isOK") && result.getIntValue("code") == 0) {
					LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + bl.getEnterpriseName());
					bill.setMcstatus(1);
					bill.setBillStatus(8);
					sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
					sqlSession.flushStatements();
					// return "redirect:/makecert";
					return null;
				}
				LogUtil.syslog(sqlSession, "手动推送用户",
						bill.getBillId() + "企业名称:" + enterprise.getEnterpriseName() + "错误:" + result.getString("message"));
				// uiModel.addAttribute("error", "错误:" +
				// result.getString("message"));
			} catch (Exception e) {
				// TODO: handle exception
				e.printStackTrace();
				// uiModel.addAttribute("error", "错误:" + e);
				return "错误【" + e + "】";
			}
		}else */
    if (type == 1) {
        try {
            bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
            log.error("bill.getMcstatus()=" + bill.getMcstatus() + "bill=" + bill);
            if (null == bill) {
                // System.out.println(bill.getMcstatus()+"=******************************="+bill);
                return "该订单无法推送";
            }
            Product product = productService.getProductById(bill.getProduct());
            sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey", product.getSignature());
            Enterprise enterprise = enterpriseService.getEnterpriseByBillId(id);
            BusinessLicense bl = businessService.getBusinessByBillId((id), null);
            if (org == null) {
                org = new JSONObject();
            }
            org.put("userType", 1);
            org.put("fullName", bl.getEnterpriseName());
            if (bl != null && bl.getBusinessType() == 1) {
                org.put("orgCode", bl.getLicenseNo());
            } else {
                TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId((id), null);
                org.put("orgCode", tc == null ? "orgCode" : tc.getCertNo());
            }
            org.put("papersType", "营业执照");
            UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
            org.put("businessNum", userInfo.getTelephone() == null ? "businessNum" : userInfo.getTelephone());
            // null);
            if (bl != null) {
                org.put("legalPersonName", bl.getLegalPerson() == null ? "legalPersonName" : bl.getLegalPerson());
            } else {
                org.put("legalPersonName", "legalPersonName");
            }
            Agent agent = agentService.getAgentByBillId((id), null);
            org.put("transactorName", agent == null ? "transactorName" : agent.getName());
            if (agent != null && agent.getCardType() == 1) {
                org.put("transactorIdCardNum", agent.getIdCode());
            } else {
                org.put("transactorIdCardNum", "transactorIdCardNum");
            }
            org.put("transactorMobile", userInfo.getmPhone());
            org.put("realInfoOrder", bill.getBillId());
            org.put("realInfoUid", bill.getUniqueId());
            if (data == null) {
                data = getJSONRequest(sc.getAppId());
            }
            data.put("autoCert", true);
            data.put("autoSeal", true);
            // data.put("appId", sc.getAppId());
            // data.put("timestamp", System.currentTimeMillis());
            data.put("user", org);
            // String content =
            // "{\"autoCert\":true,\"timestamp\":1472105170418,\"apiId\":\"test\",\"autoSeal\":true,\"user\":{\"transactorIdCardNum\":\"120102198904025625\",\"transactorMobile\":\"15822452770\",\"orgCode\":\"120116328553325\",\"papersType\":\"营销执照\",\"businessNum\":\"022-88956296\",\"realInfoUid\":\"151\",\"fullName\":\"天津瑞普生物技术股份有限公司空港经济区分公司\",\"legalPersonName\":\"刘建\",\"transactorName\":\"李洋\",\"realInfoOrder\":\"TWCX20160824170928580820\",\"userType\":1}}";
            // bill =
            // sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey",
            // map.get("id"));
            /*if (bill.getMcstatus() != null && bill.getMcstatus() == 1) {
					// return "redirect:/makecert";
					return null;
				}*/
            log.error("打印data=" + data.toString());
            log.error("----------接口地址**************" + sc.getAddress() + USER_URL + "***********服务密钥**********" + sc.getAddressKey());
            result = JSONObject.parseObject(RequestUtils.post(sc.getAddress() + USER_URL, data.toString(), sc.getAddressKey()));
            log.equals("MakeCert_push_result : " + result);
            if (result.getBoolean("isOK") && result.getIntValue("code") == 0) {
                LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + bl.getEnterpriseName());
                bill.setMcstatus(1);
                bill.setBillStatus(8);
                sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
                sqlSession.flushStatements();
                // return "redirect:/makecert";
                return null;
            }
            LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + enterprise.getEnterpriseName() + "错误:" + result.getString("message"));
        // uiModel.addAttribute("error", "错误:" +
        // result.getString("message"));
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            // uiModel.addAttribute("error", "错误:" + e);
            return "错误【" + e + "】";
        }
    } else {
        try {
            bill = sqlSession.selectOne("com.itrus.portal.db.BillMapper.selectByPrimaryKey", id);
            log.error("bill.getMcstatus()=" + bill.getMcstatus() + "bill=" + bill);
            if (null == bill) {
                // System.out.println(bill.getMcstatus()+"=******************************="+bill);
                return "该订单无法推送";
            }
            Product product = productService.getProductById(bill.getProduct());
            sc = sqlSession.selectOne("com.itrus.portal.db.SignatureConfigMapper.selectByPrimaryKey", product.getSignature());
            Enterprise enterprise = enterpriseService.getEnterpriseByBillId(id);
            BusinessLicense bl = businessService.getBusinessByBillId((id), null);
            /*if (org == null) {
					org = new JSONObject();
				}
				org.put("userType", 1);
				org.put("fullName", bl.getEnterpriseName());
				if (bl != null && bl.getBusinessType() == 1) {
					org.put("orgCode", bl.getLicenseNo());
				} else {
					TaxRegisterCert tc = taxCertService.getTaxRegisterCertByBillId((id), null);
					org.put("orgCode", tc == null ? "" : tc.getCertNo());
				}
				org.put("papersType", "营业执照");*/
            UserInfo userInfo = sqlSession.selectOne("com.itrus.portal.db.UserInfoMapper.selectByPrimaryKey", bill.getUniqueId());
            // org.put("businessNum", userInfo.getTelephone());
            // IdentityCard ic =
            // identityCardService.getIdentityCardByBillId(Long.parseLong(String.valueOf(map.get("id"))),
            // null);
            // org.put("legalPersonName", bl == null ? "" : bl.getLegalPerson());
            Agent agent = agentService.getAgentByBillId((id), null);
            /*org.put("transactorName", agent == null ? "" : agent.getName());
				if (agent != null && agent.getCardType() == 1) {
					org.put("transactorIdCardNum", agent.getIdCode());
				}
				org.put("transactorMobile", userInfo.getmPhone());
				org.put("realInfoOrder", bill.getBillId());
				org.put("realInfoUid", bill.getUniqueId());*/
            if (data == null) {
                data = new JSONObject();
            }
            Map<String, Object> treeMap = Maps.newTreeMap();
            treeMap.put("app_id", sc.getAppId());
            treeMap.put("order_number", bill.getBillId());
            treeMap.put("user_name", enterprise.getEnterpriseName());
            treeMap.put("user_email", userInfo.getEmail());
            treeMap.put("user_phone", userInfo.getmPhone());
            treeMap.put("user_type", "organization");
            /*String cardType = null;
				if(agent!=null && agent.getCardType()!=null){
					if(agent.getCardType()==1){
						cardType = "IdentityCard";
					}else if(agent.getCardType()==2){
						cardType = "NationalPassport";
					}else{
						cardType = "Other";
					}
					treeMap.put("identification_number",agent.getIdCode());
				}
				*/
            String cardType = null;
            String sn = null;
            BusinessLicense businessLicense = businessService.getBusinessByBillId(bill.getId(), null);
            if (businessLicense != null && businessLicense.getBusinessType() == 1) {
                sn = businessLicense.getLicenseNo();
                cardType = "UniformSocialCreditCode";
            }
            if (businessLicense == null || businessLicense.getBusinessType() != 1) {
                // 不是五证合一
                OrgCode oc = orgCodeService.getOrgCodeByBillId(bill.getId(), null);
                if (oc != null) {
                    sn = oc.getOrgCode();
                    cardType = "OrganizationCode";
                }
            }
            treeMap.put("identification_number", sn);
            treeMap.put("identity_type", cardType);
            String jsondata = JSONObject.toJSONString(treeMap);
            String data1 = mapToQueryString(treeMap);
            log.error(data1);
            result = JSONObject.parseObject(RequestUtils.post1(sc.getAddress(), jsondata.toString(), data1, sc.getAddressKey(), "HMAC-SHA256"));
            log.equals("MakeCert_push_result : " + result);
            if (result.getString("code") != null && "SUCCESS".equals(result.getString("code").toString())) {
                LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + bl.getEnterpriseName());
                bill.setMcstatus(1);
                bill.setBillStatus(8);
                sqlSession.update("com.itrus.portal.db.BillMapper.updateByPrimaryKey", bill);
                sqlSession.flushStatements();
                // return "redirect:/makecert";
                return null;
            }
            LogUtil.syslog(sqlSession, "手动推送用户", bill.getBillId() + "企业名称:" + enterprise.getEnterpriseName() + "错误:" + result.getString("message"));
        // uiModel.addAttribute("error", "错误:" +
        // result.getString("message"));
        } catch (Exception e) {
            // TODO: handle exception
            e.printStackTrace();
            // uiModel.addAttribute("error", "错误:" + e);
            return "错误【" + e + "】";
        }
    }
    return "错误【" + result.getString("message") + "】";
}
Also used : Agent(com.itrus.portal.db.Agent) SignatureConfig(com.itrus.portal.db.SignatureConfig) Product(com.itrus.portal.db.Product) UserInfo(com.itrus.portal.db.UserInfo) EncDecException(com.itrus.portal.exception.EncDecException) IOException(java.io.IOException) RaServiceUnavailable_Exception(cn.topca.tca.ra.service.RaServiceUnavailable_Exception) OrgCode(com.itrus.portal.db.OrgCode) BusinessLicense(com.itrus.portal.db.BusinessLicense) JSONObject(com.alibaba.fastjson.JSONObject) Bill(com.itrus.portal.db.Bill) Enterprise(com.itrus.portal.db.Enterprise) JSONObject(com.alibaba.fastjson.JSONObject) TaxRegisterCert(com.itrus.portal.db.TaxRegisterCert) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

Bill (com.itrus.portal.db.Bill)74 HashMap (java.util.HashMap)45 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)42 Product (com.itrus.portal.db.Product)39 UserInfo (com.itrus.portal.db.UserInfo)32 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)27 Enterprise (com.itrus.portal.db.Enterprise)26 UserCert (com.itrus.portal.db.UserCert)22 JSONObject (com.alibaba.fastjson.JSONObject)21 Date (java.util.Date)20 ArrayList (java.util.ArrayList)19 BillExample (com.itrus.portal.db.BillExample)18 IOException (java.io.IOException)18 UserInfoServiceException (com.itrus.portal.exception.UserInfoServiceException)16 DigitalCert (com.itrus.portal.db.DigitalCert)15 Map (java.util.Map)12 TransactionStatus (org.springframework.transaction.TransactionStatus)10 DefaultTransactionDefinition (org.springframework.transaction.support.DefaultTransactionDefinition)10 OnPayInfo (com.itrus.portal.db.OnPayInfo)9 Proxy (com.itrus.portal.db.Proxy)9