use of com.itrus.portal.db.ExtraBill in project portal by ixinportal.
the class ExtraBillServiceImpl method getExtraBillByBillId.
/**
* 根据订单唯一编号,获取订单
*
* @param billId
* @return
* @throws Exception
*/
public ExtraBill getExtraBillByBillId(String billId) throws Exception {
ExtraBillExample example = new ExtraBillExample();
ExtraBillExample.Criteria criteria = example.or();
criteria.andBillIdEqualTo(billId);
ExtraBill extraBill = sqlSession.selectOne("com.itrus.portal.db.ExtraBillMapper.selectByExample", example);
return extraBill;
}
use of com.itrus.portal.db.ExtraBill in project portal by ixinportal.
the class ExtraProductSpecServiceImpl method getProductSpec.
/**
* 获取订单list对应的规格Map
*
* @param billList
* @return
*/
public Map<Long, ExtraProductSpec> getProductSpec(List<ExtraBill> billList) {
Map<Long, ExtraProductSpec> productSpecMap = new HashMap<Long, ExtraProductSpec>();
List<Long> productSpecIds = new ArrayList<Long>();
for (ExtraBill bill : billList) {
if (null != bill.getExtraProductSpec() && 0 != bill.getExtraProductSpec()) {
productSpecIds.add(bill.getExtraProductSpec());
}
}
if (productSpecIds.isEmpty())
return productSpecMap;
ExtraProductSpecExample example = new ExtraProductSpecExample();
ExtraProductSpecExample.Criteria criteria = example.or();
criteria.andIdIn(productSpecIds);
productSpecMap = sqlSession.selectMap("com.itrus.portal.db.ExtraProductSpecMapper.selectByExample", example, "id");
return productSpecMap;
}
use of com.itrus.portal.db.ExtraBill in project portal by ixinportal.
the class SZYQServiceImpl method queryBills.
// 2.批量查询订单状态
public ExtraBill queryBills(ExtraBill extraBill) {
// 1.查找是神州易桥接口的产品.然后遍历这些产品,根据产品查找订单,
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = null;
try {
ExtraProduct product = extraProductService.selectByPrimaryKey(extraBill.getExtraProduct());
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("productId", product.getId());
paramMap.put("isquery", 1);
paramMap.put("id", extraBill.getId());
paramMap.put("limit", 20);
// 2.查找是该产品的订单,并且订单状态是:服务商审核中4,撤销订单中8
List<Map<String, Object>> Extrabills = sqlSession.selectList("com.itrus.portal.db.ExtraBillMapper.selectByCondition_SZYQ", paramMap);
if (null == Extrabills || Extrabills.isEmpty()) {
return extraBill;
}
// 3.封装参数,发送数据到第三方平台.根据返回值是否成功,如果成功就修改订单状态和审核时间,事物提交.
for (Map<String, Object> bill : Extrabills) {
// 加密串md5(key+时间戳+参数)
String sign = new String();
// 时间戳
long ts = System.currentTimeMillis();
// 平台编号
String system_code = product.getServiceId();
// key
if (product.getServiceSecret() != null) {
product.setServiceSecret(AESencrp.decrypt(product.getServiceSecret(), dbEncKey));
}
String key = product.getServiceSecret();
String param = "";
/**
* {
* "ordersNo" : "订单id",
* "tworderId" : "天威订单id",
* “phone”:”客户手机号”
* }
*/
param = "{\"ordersNo\":\"" + bill.get("bills_no").toString() + "\"," + "\"tworderId\":\"" + bill.get("bill_id").toString() + "\"," + "\"phone\":\"" + bill.get("m_phone").toString() + "\"" + "}";
System.out.println(param);
param = ts + param;
sign = szyqBillTask.sign(param, key, "utf-8");
// TODO 发送到第三方平台
/**
* {
* "ordersNo":"订单编号"
* "tworderId ": "天威订单id",
* "ordersState":4, //订单状态 1服务处理中2.撤销订单失败3、撤销成功 4、处理完成
* "cancelReason":"撤销原因"
* }
*/
String result = "{\"ordersNo\":\"" + "订单编号" + "\"," + "\"tworderId\":\"" + "天威订单id" + "\"," + "\"ordersState\":\"" + 4 + "\"," + "\"cancelReason\":\"" + "撤销原因" + "\"" + "}";
ExtraBill bill2 = extraBillService.selectByPrimaryKey((Long) bill.get("id"));
Map<String, Object> resultMap = szyqBillTask.convertJsonStrToMap(result);
Long ordersState = Long.parseLong(resultMap.get("ordersState").toString());
if (null == ordersState) {
LogUtil.syslog(sqlSession, "查询订单失败_神州易桥", "订单号:" + bill.get("bill_id") + "推送失败,错误信息:返回的订单状态为null");
}
// 原本是服务商审核中,可能的状态是已完成或者服务商审核中
if (bill2.getBillStatus().equals(ComNames.EXTRA_BILL_STATUS_4)) {
if (ordersState.equals(ORDER_STATUS_4)) {
if (null != bill2.geteInvoice()) {
// 订单需要开票.判断是否开票了.
Boolean isinvoiced = bill2.getIsInvoiced();
if (null == isinvoiced || isinvoiced.equals(false)) {
bill2.setBillStatus(ComNames.EXTRA_BILL_STATUS_6);
} else {
bill2.setBillStatus(ComNames.EXTRA_BILL_STATUS_7);
extraBill.setFinishTime(new Date());
}
} else {
// 订单不需要开票,直接完成
bill2.setBillStatus(ComNames.EXTRA_BILL_STATUS_7);
extraBill.setFinishTime(new Date());
}
} else if (ordersState.equals(ORDER_STATUS_1)) {
}
} else if (bill2.getBillStatus().equals(ComNames.EXTRA_BILL_STATUS_8)) {
// 原本是撤销订单中,可能返回的状态是撤销成功,或者撤销失败
if (ordersState.equals(ORDER_STATUS_2)) {
// 撤销订单失败
bill2.setBillStatus(ComNames.EXTRA_BILL_STATUS_10);
} else if (ordersState.equals(ORDER_STATUS_3)) {
// 撤销订单成功
bill2.setBillStatus(ComNames.EXTRA_BILL_STATUS_9);
}
}
status = transactionManager.getTransaction(def);
extraBillService.updateByPrimaryKeySelective(bill2);
transactionManager.commit(status);
extraBill = bill2;
}
LogUtil.syslog(sqlSession, "查询订单_神州易桥", "查询成功,查询订单:" + extraBill.getBillId() + "成功");
} catch (Exception e) {
LogUtil.syslog(sqlSession, "查询订单_神州易桥", "错误,订单号:" + extraBill.getBillId() + " ,错误信息:" + e.toString());
e.printStackTrace();
} finally {
if (status != null && !status.isCompleted()) {
transactionManager.rollback(status);
}
}
return extraBill;
}
use of com.itrus.portal.db.ExtraBill in project portal by ixinportal.
the class SZYQBillTask method submitBill.
// 1.提交订单
public void submitBill() {
synchronized (SZYQBillTaskLock) {
// start------------处理双机互斥----------
if (null == taskFlag) {
taskFlag = systemConfigService.isTimedTaskHost();
}
if (taskFlag.equals(false)) {
return;
}
// end------------处理双机互斥----------
// 1.查找是神州易桥接口的产品.然后遍历这些产品,根据产品查找订单,
List<ExtraProduct> products = new ArrayList<>();
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = null;
try {
products = extraProductService.getExtraProductBySIN(ComNames.SERVICE_INTERFACE_NAME_SZYQQYDB);
if (null == products || products.isEmpty()) {
return;
}
Integer count = 0;
for (ExtraProduct product : products) {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("productId", product.getId());
paramMap.put("billStatu", ComNames.EXTRA_BILL_STATUS_3);
// 2.查找是该产品的订单,并且订单状态是已支付,待服务商审核的订单.然后遍历订单信息
List<Map<String, Object>> Extrabills = sqlSession.selectList("com.itrus.portal.db.ExtraBillMapper.selectByCondition_SZYQ", paramMap);
if (null == Extrabills || Extrabills.isEmpty()) {
continue;
}
// 平台编号
String system_code = product.getServiceId();
// key
if (product.getServiceSecret() != null) {
product.setServiceSecret(AESencrp.decrypt(product.getServiceSecret(), dbEncKey));
}
String key = product.getServiceSecret();
// 数据库中的:http://www.cs.12366.com+"/city-api/order/createOrder"
String url = product.getServiceAddress() + "/city-api/order/createOrder";
// 3.封装参数,发送数据到第三方平台.根据返回值是否成功,如果成功就修改订单状态和审核时间,事物提交.
for (Map<String, Object> bill : Extrabills) {
// 加密串md5(key+时间戳+参数)
String sign = new String();
// 时间戳
long ts = System.currentTimeMillis();
String param = "";
/**
* { " phone ":"186000000", //客户手机号
* " productName ":"1122" ,// 商品名称 "num":"1", //购买商品的数量
* " preferentialAmount ":" 1520.00 "
* ,//商品优惠价格(优惠的金额,差价) " finalAmount ":" 1520.00 "
* ,//商品最终价格(商品优惠后的价格,销售价) " orderPayType ":" 0 "
* //订单支付状态(1已支付,0待支付) }
*/
param = "{\"phone\":\"" + bill.get("m_phone").toString() + "\"," + "\"productName\":\"" + bill.get("epname").toString() + "\"," + "\"num\":\"" + bill.get("product_num").toString() + "\"," + "\"preferentialAmount\":\"" + 0 + "\"," + "\"finalAmount\":\"" + bill.get("bill_sum").toString() + "\"," + "\"orderPayType\":\"" + 1 + "\"" + "}";
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
String signAndtime = ts + param;
sign = sign(signAndtime, key, "utf-8");
map.add("sign", sign);
map.add("ts", ts);
map.add("system_code", system_code);
map.add("param", param);
// TODO 发送到第三方平台
/**
* { " orderCreateStatus ":"1", //订单生成状态(1成功,0失败)
* " ordersNo ":"112233", //订单编号 }
* {"data":"orderCreateStatus :1,orderCd:S20170717104850174,orderId:21714","returnCode":"200","returnMsg":"200"}
*/
String result = restTemplate.postForObject(url, map, String.class);
Map<String, Object> resultMap = convertJsonStrToMap(result);
Map<String, Object> dataMap = (Map<String, Object>) resultMap.get("data");
if (dataMap.get("orderCreateStatus").equals("1")) {
String ordersNo = (String) dataMap.get("orderId");
ExtraBill bill2 = extraBillService.selectByPrimaryKey((Long) bill.get("id"));
bill2.setBillsNo(ordersNo);
bill2.setBillStatus(ComNames.EXTRA_BILL_STATUS_4);
status = transactionManager.getTransaction(def);
extraBillService.updateByPrimaryKeySelective(bill2);
transactionManager.commit(status);
count++;
} else {
LogUtil.syslog(sqlSession, "推送增值订单失败_神州易桥", "订单号:" + bill.get("bill_id") + "推送失败,错误信息:" + resultMap.get("returnMsg"));
continue;
}
}
LogUtil.syslog(sqlSession, "推送增值订单_神州易桥", "推送成功,推送" + Extrabills.size() + "条,成功" + count + "条。");
}
} catch (Exception e) {
LogUtil.syslog(sqlSession, "推送增值订单失败_神州易桥", "错误:" + e.toString());
e.printStackTrace();
} finally {
if (status != null && !status.isCompleted()) {
transactionManager.rollback(status);
}
}
}
}
use of com.itrus.portal.db.ExtraBill in project portal by ixinportal.
the class SZYQBillTask method queryBills.
// 2.批量查询订单状态
public void queryBills() {
synchronized (SZYQBillTaskLock) {
// start------------处理双机互斥----------
if (null == taskFlag) {
taskFlag = systemConfigService.isTimedTaskHost();
}
if (taskFlag.equals(false)) {
return;
}
// end------------处理双机互斥----------
// 1.查找是神州易桥接口的产品.然后遍历这些产品,根据产品查找订单,
List<ExtraProduct> products = new ArrayList<>();
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
TransactionStatus status = null;
try {
products = extraProductService.getExtraProductBySIN(ComNames.SERVICE_INTERFACE_NAME_SZYQQYDB);
if (null == products || products.isEmpty()) {
return;
}
Integer count = 0;
for (ExtraProduct product : products) {
Map<String, Object> paramMap = new HashMap<String, Object>();
paramMap.put("productId", product.getId());
paramMap.put("isquery", 1);
paramMap.put("limit", 20);
// 2.查找是该产品的订单,并且订单状态是:服务商审核中4,撤销订单中8
List<Map<String, Object>> Extrabills = sqlSession.selectList("com.itrus.portal.db.ExtraBillMapper.selectByCondition_SZYQ", paramMap);
if (null == Extrabills || Extrabills.isEmpty()) {
continue;
}
// 平台编号
String system_code = product.getServiceId();
// key
if (product.getServiceSecret() != null) {
product.setServiceSecret(AESencrp.decrypt(product.getServiceSecret(), dbEncKey));
}
String key = product.getServiceSecret();
// url
String url = product.getServiceAddress() + "/city-api/order/queryOrderStatus";
// 3.封装参数,发送数据到第三方平台.根据返回值是否成功,如果成功就修改订单状态和审核时间,事物提交.
for (Map<String, Object> bill : Extrabills) {
// 加密串md5(key+时间戳+参数)
String sign = new String();
// 时间戳
long ts = System.currentTimeMillis();
String param = "";
/**
* param = "{\"orderId\":\""
* +21715+"\","
* +"\"tworderId\":\""
* +"TWCXEB5666456456"+ "\","
* +"\"phone\":\""
* + "18878996651" + "\""
* + "}";
*/
param = "{\"orderId\":\"" + bill.get("bills_no").toString() + "\"," + "\"tworderId\":\"" + bill.get("bill_id").toString() + "\"," + "\"phone\":\"" + bill.get("m_phone").toString() + "\"" + "}";
LinkedMultiValueMap<String, Object> map = new LinkedMultiValueMap<>();
String signAndtime = ts + param;
sign = sign(signAndtime, key, "utf-8");
map.add("sign", sign);
map.add("ts", ts);
map.add("system_code", system_code);
map.add("param", param);
// TODO 发送到第三方平台
/**
* { " orderCreateStatus ":"1", //订单生成状态(1成功,0失败)
* " ordersNo ":"112233", //订单编号 }
*/
// {"returnCode":200,"returnMsg":"执行成功","data":{"ordersState":2,"ordersNo":"S20170717105409304","tworderId":"TWCXEB5666456456","cancelReason":"","orderId":21715}}
String result = restTemplate.postForObject(url, map, String.class);
Map<String, Object> resultMap = convertJsonStrToMap(result);
Map<String, Object> dataMap = (Map<String, Object>) resultMap.get("data");
// TODO 发送到第三方平台
/**
* {
* "ordersNo":"订单编号"
* "tworderId ": "天威订单id",
* "ordersState":4, //订单状态 1服务处理中2.撤销订单失败3、撤销成功 4、处理完成
* "cancelReason":"撤销原因"
* }
* String result = "{\"ordersNo\":\"" + "订单编号" + "\","
* + "\"tworderId\":\"" + "天威订单id" + "\","
* + "\"ordersState\":\"" + 4 + "\","
* + "\"cancelReason\":\"" + "撤销原因" + "\""
* + "}";
*/
ExtraBill bill2 = extraBillService.selectByPrimaryKey((Long) bill.get("id"));
Long ordersState = Long.parseLong(dataMap.get("ordersState").toString());
if (null == ordersState) {
LogUtil.syslog(sqlSession, "批量查询订单失败_神州易桥", "订单号:" + bill.get("bill_id") + "推送失败,错误信息:返回的订单状态为null, 返回的信息:" + resultMap.get("returnMsg"));
continue;
}
// 原本是服务商审核中,可能的状态是已完成或者服务商审核中
if (bill2.getBillStatus().equals(ComNames.EXTRA_BILL_STATUS_4)) {
if (ordersState.equals(ORDER_STATUS_4)) {
if (null != bill2.geteInvoice()) {
// 订单需要开票.判断是否开票了.
Boolean isinvoiced = bill2.getIsInvoiced();
if (null == isinvoiced || isinvoiced.equals(false)) {
bill2.setBillStatus(ComNames.EXTRA_BILL_STATUS_6);
} else {
bill2.setBillStatus(ComNames.EXTRA_BILL_STATUS_7);
bill2.setFinishTime(new Date());
}
} else {
// 订单不需要开票,直接完成
bill2.setBillStatus(ComNames.EXTRA_BILL_STATUS_7);
bill2.setFinishTime(new Date());
}
} else if (ordersState.equals(ORDER_STATUS_1)) {
}
} else if (bill2.getBillStatus().equals(ComNames.EXTRA_BILL_STATUS_8)) {
// 原本是撤销订单中,可能返回的状态是撤销成功,或者撤销失败
if (ordersState.equals(ORDER_STATUS_2)) {
// 撤销订单失败
bill2.setBillStatus(ComNames.EXTRA_BILL_STATUS_10);
} else if (ordersState.equals(ORDER_STATUS_3)) {
// 撤销订单成功
bill2.setBillStatus(ComNames.EXTRA_BILL_STATUS_9);
}
}
count++;
status = transactionManager.getTransaction(def);
extraBillService.updateByPrimaryKeySelective(bill2);
transactionManager.commit(status);
}
LogUtil.syslog(sqlSession, "批量查询订单_神州易桥", "查询成功,查询" + Extrabills.size() + "条,成功" + count + "条。");
}
} catch (Exception e) {
LogUtil.syslog(sqlSession, "批量查询订单_神州易桥", "错误:" + e.toString());
e.printStackTrace();
} finally {
if (status != null && !status.isCompleted()) {
transactionManager.rollback(status);
}
}
}
}
Aggregations