|
@@ -10,9 +10,12 @@ import com.kmall.common.dao.TemplateConfDao;
|
|
|
import com.kmall.common.entity.FormIdsEntity;
|
|
|
import com.kmall.common.entity.TemplateConfVo;
|
|
|
import com.kmall.common.service.FormIdsService;
|
|
|
+import com.kmall.common.service.print.ticket.PrintTicketPropertiesBuilder;
|
|
|
import com.kmall.common.utils.DateUtils;
|
|
|
import com.kmall.common.utils.RRException;
|
|
|
import com.kmall.common.utils.StringUtils;
|
|
|
+import com.kmall.common.utils.print.ticket.TicketPrintUtil;
|
|
|
+import com.kmall.common.utils.print.ticket.item.*;
|
|
|
import com.kmall.common.utils.printer.FeiGeUtils;
|
|
|
import com.kmall.common.utils.wxtemplate.TemplateData;
|
|
|
import com.kmall.common.utils.wxtemplate.WxTemplate;
|
|
@@ -57,6 +60,8 @@ public class ApiOrderService {
|
|
|
private ApiFreightService apiFreightService;
|
|
|
@Autowired
|
|
|
private ApiOrderProcessRecordMapper orderProcessRecordMapper;
|
|
|
+ @Autowired
|
|
|
+ private ApiStoreMapper apiStoreMapper;
|
|
|
|
|
|
public OrderVo queryObject(Long id) {
|
|
|
return apiOrderMapper.queryObject(id);
|
|
@@ -163,7 +168,7 @@ public class ApiOrderService {
|
|
|
List<ProductVo> productVos = new ArrayList();
|
|
|
for (CartVo goodsItem : checkedGoodsList) {
|
|
|
//取得规格的信息,判断规格库存
|
|
|
- ProductVo productInfo = apiProductMapper.queryObjectByStoreId(goodsItem.getProduct_id(), storeId);
|
|
|
+ ProductVo productInfo = apiProductMapper.queryByStoreId(goodsItem.getProduct_id(), storeId);
|
|
|
if (null == productInfo || null == productInfo.getStock_num() || productInfo.getStock_num() < goodsItem.getNumber()) {
|
|
|
resultObj.put("errno", 400);
|
|
|
resultObj.put("errmsg", "库存不足,仅剩余" + productInfo.getStock_num());
|
|
@@ -623,7 +628,7 @@ public class ApiOrderService {
|
|
|
apiOrderMapper.update(orderVo);
|
|
|
}
|
|
|
|
|
|
- public String printMsg(Long orderId) {
|
|
|
+ /*public String printMsgs(Long orderId) {
|
|
|
OrderVo orderEntity = queryObject(orderId);
|
|
|
Map<String, Object> map = new HashMap<String, Object>();
|
|
|
|
|
@@ -668,6 +673,67 @@ public class ApiOrderService {
|
|
|
sn = printerEntities.get(0).getSn();
|
|
|
}
|
|
|
return FeiGeUtils.printMsg(sn, content, "1");
|
|
|
+ }*/
|
|
|
+ public Ticket printMsg(Long orderId) {
|
|
|
+ OrderVo orderEntity = queryObject(orderId);
|
|
|
+ if(orderEntity != null) {
|
|
|
+ if (orderEntity.getOrderBizType().equalsIgnoreCase(Dict.orderBizType.item_10.getItem())
|
|
|
+ || orderEntity.getOrderBizType().equalsIgnoreCase(Dict.orderBizType.item_02.getItem())) {
|
|
|
+ Map<String, Object> map = new HashMap<String, Object>();
|
|
|
+ map.put("order_id", orderEntity.getId());
|
|
|
+ List<OrderGoodsVo> orderGoodsEntityList = apiOrderGoodsMapper.queryList(map);
|
|
|
+ // 获取门店
|
|
|
+ StoreVo storeEntity = apiStoreMapper.queryObject(orderEntity.getStore_id());
|
|
|
+ // 获取清关信息
|
|
|
+ OrderProcessRecordEntity orderProcessRecordEntity = orderProcessRecordMapper.queryObjectByOrderSn(orderEntity.getOrder_sn());
|
|
|
+
|
|
|
+ UserVo userVo = apiUserMapper.queryObject(orderEntity.getUser_id());
|
|
|
+ // 小票头
|
|
|
+ TicketHead head = new TicketHead();
|
|
|
+ head.setTitle(OmsMerchPropertiesBuilder.instance().getMerchName() + storeEntity.getStoreName());
|
|
|
+ head.setMemberId(userVo.getUsername().toString());
|
|
|
+ head.setOrderId(orderEntity.getOrder_sn());
|
|
|
+ head.setTradeTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss EEE").format(new Date()));
|
|
|
+
|
|
|
+ // 商品信息
|
|
|
+ Integer goodsTotal = 0; // 商品总个数
|
|
|
+ BigDecimal total = new BigDecimal(0); // 商品总计
|
|
|
+ List<Goods> goodsList = new ArrayList<>();
|
|
|
+ for (OrderGoodsVo orderGoods : orderGoodsEntityList) {
|
|
|
+ goodsTotal += orderGoods.getNumber();
|
|
|
+ total = total.add(orderGoods.getRetail_price().subtract(new BigDecimal(orderGoods.getNumber()))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ Goods goods = new Goods(orderGoods.getGoods_name(), orderGoods.getRetail_price().toString(), orderGoods.getNumber().toString(),
|
|
|
+ orderGoods.getRetail_price().multiply(new BigDecimal(orderGoods.getNumber()).setScale(2, BigDecimal.ROUND_HALF_UP)).toString());
|
|
|
+ goodsList.add(goods);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 收银信息
|
|
|
+ CashInfo cashInfo = new CashInfo();
|
|
|
+ cashInfo.setGoodsTotal(goodsTotal.toString());
|
|
|
+ cashInfo.setTotal(total.setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ cashInfo.setReceipts(orderEntity.getActual_price().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ cashInfo.setOddChange("0.00");
|
|
|
+ cashInfo.setCoupon(orderEntity.getCoupon_price().setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ cashInfo.setFreight(new BigDecimal(orderEntity.getFreight_price()).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
|
|
|
+ cashInfo.setPaymentMode("微信支付");
|
|
|
+
|
|
|
+ // 海关清单
|
|
|
+ CusListing cusListing = new CusListing();
|
|
|
+ cusListing.setOrderId(orderEntity.getOrder_sn());
|
|
|
+ cusListing.setWaybillId(orderProcessRecordEntity.getLogisticsNo());
|
|
|
+ cusListing.setInvtNo(orderProcessRecordEntity.getInvtNo());
|
|
|
+ cusListing.setConsignee(orderEntity.getConsignee());
|
|
|
+ cusListing.setConsigneeTel(orderEntity.getMobile());
|
|
|
+ cusListing.setOriginAddress(PrintTicketPropertiesBuilder.instance().getAddress());
|
|
|
+ cusListing.setDeliveryAddress(storeEntity.getStoreAddress());
|
|
|
+
|
|
|
+ return TicketPrintUtil.print(head, goodsList, cashInfo, cusListing);
|
|
|
+ }else{
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public List<OrderVo> queryObjectByIdList(List<Long> orderIdList){
|
|
@@ -676,6 +742,5 @@ public class ApiOrderService {
|
|
|
|
|
|
public List<OrderVo> queryObjectByMerchOrderSn(String merchOrderSn){
|
|
|
return apiOrderMapper.queryObjectByMerchOrderSn(merchOrderSn);
|
|
|
-
|
|
|
}
|
|
|
}
|