|
@@ -408,7 +408,7 @@ public class OrderServiceImpl implements OrderService {
|
|
|
head.setTitle(storeEntity.getStoreName());
|
|
|
// head.setMemberId(orderEntity.getUserName().toString());
|
|
|
head.setOrderId(orderEntity.getOrderSn());
|
|
|
- head.setTradeTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss EEE").format(new Date()));
|
|
|
+ head.setTradeTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss EEE").format(orderEntity.getPayTime()));
|
|
|
|
|
|
// 商品信息
|
|
|
Integer goodsTotal = 0; // 商品总个数
|
|
@@ -2201,31 +2201,31 @@ public class OrderServiceImpl implements OrderService {
|
|
|
// 设置支付单开始时间
|
|
|
processRecordEntity.setPaymentStartTime(new Date());
|
|
|
// 判断是微信的支付码还是支付宝的支付码
|
|
|
- if (parCode.startsWith("28")) {
|
|
|
- // 支付宝支付
|
|
|
- try {
|
|
|
- AliPay(user, parCode, order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- throw e;
|
|
|
- }
|
|
|
- } else {
|
|
|
- // 微信支付
|
|
|
- try {
|
|
|
- wxPay(user, parCode, resultObj, order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- throw e;
|
|
|
- }
|
|
|
- }
|
|
|
+// if (parCode.startsWith("28")) {
|
|
|
+// // 支付宝支付
|
|
|
+// try {
|
|
|
+// AliPay(user, parCode, order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// throw e;
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// // 微信支付
|
|
|
+// try {
|
|
|
+// wxPay(user, parCode, resultObj, order, processRecordEntity, orderWXPayRecordCurrent, store);
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// throw e;
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
|
|
|
// TODO 到时候要注释掉,测试用而已
|
|
|
-// OrderEntity orderEntity = queryObject(order.getId());
|
|
|
-// orderEntity.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_201.getItem()));
|
|
|
-// orderEntity.setPayStatus(Integer.parseInt(Dict.payStatus.item_2.getItem()));
|
|
|
-// orderEntity.setPayTime(new Date());
|
|
|
-// orderDao.update(orderEntity);
|
|
|
+ OrderEntity orderEntity = queryObject(order.getId());
|
|
|
+ orderEntity.setOrderStatus(Integer.parseInt(Dict.orderStatus.item_201.getItem()));
|
|
|
+ orderEntity.setPayStatus(Integer.parseInt(Dict.payStatus.item_2.getItem()));
|
|
|
+ orderEntity.setPayTime(new Date());
|
|
|
+ orderDao.update(orderEntity);
|
|
|
|
|
|
|
|
|
resultObj.put("shopName", store.getStoreName()); // 根据门店编号查询
|
|
@@ -3314,6 +3314,133 @@ public class OrderServiceImpl implements OrderService {
|
|
|
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public Ticket printMsgEwb(long id, String sessionId) {
|
|
|
+ OrderEntity orderEntity = queryInfos(id);
|
|
|
+
|
|
|
+ List<OrderGoodsEntity> orderGoodsEntityList = orderEntity.getOrderGoodsEntityList();
|
|
|
+ // 获取门店
|
|
|
+ StoreEntity storeEntity = storeDao.queryObject(orderEntity.getStoreId());
|
|
|
+ // 获取清关信息
|
|
|
+ OrderProcessRecordEntity orderProcessRecordEntity =
|
|
|
+ orderProcessRecordDao.queryObjectByOrderSn(orderEntity.getOrderSn());
|
|
|
+
|
|
|
+ // 小票头
|
|
|
+ TicketHead head = new TicketHead();
|
|
|
+ head.setTitle(storeEntity.getStoreName());
|
|
|
+ // head.setMemberId(orderEntity.getUserName().toString());
|
|
|
+ head.setOrderId(orderEntity.getOrderSn());
|
|
|
+ head.setTradeTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss EEE").format(orderEntity.getPayTime()));
|
|
|
+
|
|
|
+ // 商品信息
|
|
|
+ Integer goodsTotal = 0; // 商品总个数
|
|
|
+ BigDecimal total = Constant.ZERO; // 商品总计
|
|
|
+ BigDecimal taxTotal = Constant.ZERO; //税费总计
|
|
|
+ List<Goods> goodsList = new ArrayList<>();
|
|
|
+ BigDecimal discountedPrice = Constant.ZERO; // 优惠金额
|
|
|
+ for (OrderGoodsEntity orderGoods : orderGoodsEntityList) {
|
|
|
+ goodsTotal += orderGoods.getNumber();
|
|
|
+ total = total.add(orderGoods.getRetailPrice().multiply(new BigDecimal(orderGoods.getNumber())))
|
|
|
+ .setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ discountedPrice = discountedPrice.add(orderGoods.getDiscountedPrice());
|
|
|
+
|
|
|
+ GoodsEntity goodsEntity = goodsService.queryObject(orderGoods.getGoodsId());
|
|
|
+ BigDecimal goodsTax = CalculateTax.calculateFinalTax(goodsEntity, orderGoods.getRetailPrice(), goodsService).setScale(3, RoundingMode.HALF_UP);
|
|
|
+ goodsTax = goodsTax.multiply(new BigDecimal(orderGoods.getNumber())).setScale(2, RoundingMode.HALF_UP);
|
|
|
+ taxTotal = taxTotal.add(goodsTax).setScale(2, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ Goods goods = new Goods(orderGoods.getGoodsName(),
|
|
|
+ orderGoods.getRetailPrice().toString(), // 含税价
|
|
|
+// beforeTaxPrice.toString(),// 税前价
|
|
|
+ goodsTax.toString(),
|
|
|
+ orderGoods.getNumber().toString(),
|
|
|
+ new BigDecimal(orderGoods.getNumber()).multiply(orderGoods.getRetailPrice()).setScale(2, RoundingMode.HALF_UP).toString(),
|
|
|
+ orderGoods.getDiscountedPrice().toString());
|
|
|
+ goodsList.add(goods);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 收银信息
|
|
|
+ CashInfo cashInfo = new CashInfo();
|
|
|
+ cashInfo.setGoodsTotal(goodsTotal.toString());
|
|
|
+ cashInfo.setTotal(total.setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ cashInfo.setTaxTotal(taxTotal.setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ cashInfo.setReceipts(orderEntity.getActualPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ cashInfo.setOddChange(discountedPrice.toString());
|
|
|
+ cashInfo.setCoupon(orderEntity.getCouponPrice().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ cashInfo.setFreight(
|
|
|
+ new BigDecimal(orderEntity.getFreightPrice()).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ if ("alipay".equals(orderEntity.getPayFlag())) {
|
|
|
+ cashInfo.setPaymentMode("支付宝支付");
|
|
|
+ } else {
|
|
|
+ cashInfo.setPaymentMode("微信支付");
|
|
|
+ }
|
|
|
+ // 海关清单
|
|
|
+ CusListing cusListing = new CusListing();
|
|
|
+ cusListing.setOrderId(orderEntity.getOrderSn());
|
|
|
+ if (!orderEntity.getOrderBizType().equalsIgnoreCase(Dict.orderBizType.item_11.getItem())) {
|
|
|
+ cusListing.setWaybillId(orderProcessRecordEntity.getLogisticsNo());
|
|
|
+ cusListing.setInvtNo(orderProcessRecordEntity.getInvtNo()==null?"":orderProcessRecordEntity.getInvtNo());
|
|
|
+
|
|
|
+ cusListing.setConsignee(orderEntity.getConsignee());
|
|
|
+ // 脱敏设置
|
|
|
+ if (StringUtils.isNotEmpty(cusListing.getConsignee()) && cusListing.getConsignee().length() > 1) {
|
|
|
+ cusListing.setConsignee(new StringBuilder(cusListing.getConsignee()).replace(1, 2, "*").toString());
|
|
|
+ }
|
|
|
+ cusListing.setConsigneeTel(orderEntity.getMobile());
|
|
|
+ if (StringUtils.isNotEmpty(cusListing.getConsigneeTel())) {
|
|
|
+ cusListing.setConsigneeTel(new StringBuilder(cusListing.getConsigneeTel()).replace(3, 7, "****").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ cusListing.setOriginAddress(PrintTicketPropertiesBuilder.instance().getAddress());
|
|
|
+ cusListing.setDeliveryAddress(storeEntity.getStoreAddress());
|
|
|
+ // 尝试在取货码表中查询数据,如果有的话就改变状态
|
|
|
+// String orderSn = orderEntity.getOrderSn();
|
|
|
+// PickUpCodeEntity pickUpCodeEntity = pickUpCodeService.queryObject(orderSn);
|
|
|
+// if (pickUpCodeEntity != null) {
|
|
|
+// pickUpCodeEntity.setPickUpCodeStatus("0");
|
|
|
+// pickUpCodeService.update(pickUpCodeEntity);
|
|
|
+//
|
|
|
+// }
|
|
|
+ TicketMailInfo mailInfo = new TicketMailInfo();
|
|
|
+ String exprNo = orderProcessRecordEntity.getLogisticsNo();
|
|
|
+ if (StringUtils.isNullOrEmpty(exprNo)) {
|
|
|
+ throw new RRException("快递面单为空,请联系客服");
|
|
|
+ }
|
|
|
+ mailInfo.setExprNo(exprNo);
|
|
|
+ String logoUrl = "/statics/img/yto_logo.jpg";
|
|
|
+
|
|
|
+ Map<String, String> logoMap = new HashMap<>();
|
|
|
+ logoMap.put("yto", "/statics/img/yto_logo.jpg");
|
|
|
+ logoMap.put("best", "/statics/img/bestex_logo3.png");
|
|
|
+ if (StringUtils.isNotEmpty(orderEntity.getShippingCode()) && logoMap.containsKey(orderEntity.getShippingCode())) {
|
|
|
+ logoUrl = logoMap.get(orderEntity.getShippingCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ mailInfo.setExprLogoUrl(logoUrl);
|
|
|
+ byte[] barCode128 = BarcodeUtil.generateBarCode128(exprNo, 6.0D, null, true, false);
|
|
|
+ String exprNoBase64Img = new String(Base64.getEncoder().encode(barCode128));
|
|
|
+ mailInfo.setShopTel("0752-2688660");
|
|
|
+
|
|
|
+ // 发货人
|
|
|
+ mailInfo.setSenderTel("0752-2688660");
|
|
|
+ mailInfo.setSenderName("CW澳洲大药房");
|
|
|
+ mailInfo.setSenderProvince("广东省");
|
|
|
+ mailInfo.setSenderCity("深圳市");
|
|
|
+ mailInfo.setSenderDistrict("南山区");
|
|
|
+ mailInfo.setSenderAddress("前海综合保税区W104");
|
|
|
+
|
|
|
+ // 收货人
|
|
|
+ mailInfo.setConsigneeMob(new StringBuilder(orderEntity.getMobile()).replace(3, 7, "****").toString());
|
|
|
+ mailInfo.setConsigneeName(new StringBuilder(orderEntity.getConsignee()).replace(1, 2, "*").toString());
|
|
|
+ mailInfo.setConsigneeProvince(orderEntity.getProvince());
|
|
|
+ mailInfo.setConsigneeCity(orderEntity.getCity());
|
|
|
+ mailInfo.setConsigneeDistrict(orderEntity.getDistrict());
|
|
|
+ mailInfo.setConsigneeAddress(orderEntity.getAddress());
|
|
|
+
|
|
|
+ mailInfo.setExprNoBase64Img(exprNoBase64Img);
|
|
|
+ return TicketPrintUtil.print(head, goodsList, cashInfo, cusListing, mailInfo);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 设置订单数据
|