|
@@ -59,6 +59,11 @@ public class DeliveryAction implements IMINAction{
|
|
|
|
|
|
/**提货回调*/
|
|
/**提货回调*/
|
|
public static final String BACK_DELIVERY_FOR_MACHINE = "backDeliveryForMachine";
|
|
public static final String BACK_DELIVERY_FOR_MACHINE = "backDeliveryForMachine";
|
|
|
|
+
|
|
|
|
+ /**提货(无需session)*/
|
|
|
|
+ public static final String MAKE_DELIVERY_FOR_MACHINE_NOSESSION = "makeDeliveryForMachineNoSession";
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -507,6 +512,117 @@ public class DeliveryAction implements IMINAction{
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ /**
|
|
|
|
+ * 提货接口
|
|
|
|
+ * @param orderNo 订单编号
|
|
|
|
+ * @param deliveryNo 提货单编号
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @MINAction(value = MAKE_DELIVERY_FOR_MACHINE_NOSESSION ,session = false)
|
|
|
|
+ public MINActionResult makeDeliveryForMachineNoSession(
|
|
|
|
+ @MINParam ( key = "orderNo")String orderNo,
|
|
|
|
+ @MINParam ( key = "deliveryNo")String deliveryNo
|
|
|
|
+ ) throws Exception{
|
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
|
+ /**获取售货机推送地址*/
|
|
|
|
+ String url = Service.lookup(IPropertiesService.class)
|
|
|
|
+ .getSystemProperties().get("V01_GET_MACHINE_ADDRESS").getKey();
|
|
|
|
+ String retUrl = Service.lookup(IPropertiesService.class)
|
|
|
|
+ .getSystemProperties().get( "V01_RETURN_MACHINE_ADDRESS").getKey();
|
|
|
|
+ //组装推送接口
|
|
|
|
+ String sendUrl = url.concat("/VendingMachineAction/pushGoods").concat("?MINView=JSON");
|
|
|
|
+ String returnUrl = retUrl.concat("/DeliveryAction/backDeliveryForMachine");
|
|
|
|
+
|
|
|
|
+ /**查询数据(提货单号是否存在)*/
|
|
|
|
+ //初始化查询条件
|
|
|
|
+ Map<String,String> map = new HashMap<String,String>();
|
|
|
|
+ map.put("deliveryNo", deliveryNo);//提货编号
|
|
|
|
+ map.put("orderNo", orderNo);//订单编号
|
|
|
|
+ //传入渠道验证
|
|
|
|
+ map.put("channel", "V01");
|
|
|
|
+ List<Map<String,String>> list = Service.lookup(IMINDataBaseService.class)
|
|
|
|
+ .getMybatisMapper(DeliveryMapper.class)
|
|
|
|
+ .queryDeliverys(map);
|
|
|
|
+
|
|
|
|
+ if(list == null || list.size() != 1 ){
|
|
|
|
+ throw new MINBusinessException("没有提货信息!");
|
|
|
|
+ }
|
|
|
|
+ String equType = list.get(0).get("equType");
|
|
|
|
+ if(!"00".equals(equType) && !"01".equals(equType)){
|
|
|
|
+ throw new MINBusinessException("机器类型不支持推货!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ VmDeliveryInf delInf = Service.lookup(IMINDataBaseService.class)
|
|
|
|
+ .getMybatisMapper(VmDeliveryInfMapper.class).selectByPrimaryKey(deliveryNo);
|
|
|
|
+ if(delInf == null){
|
|
|
|
+ throw new MINBusinessException("没有提货信息!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if(delInf.getProNums().equals(delInf.getDeliveryNums())){
|
|
|
|
+ throw new MINBusinessException("提货已完成!");
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //改变提货状态为5处理中....
|
|
|
|
+ delInf.setStatus("5");
|
|
|
|
+ //处理提货状态
|
|
|
|
+ Service.lookup(IMINDataBaseService.class)
|
|
|
|
+ .getMybatisMapper(VmDeliveryInfMapper.class)
|
|
|
|
+ .updateByPrimaryKeySelective(delInf);
|
|
|
|
+ Map<String,String> mapNew = new HashMap<String,String>();
|
|
|
|
+ mapNew.put("imeiAddr", list.get(0).get("equIMEI"));
|
|
|
|
+ mapNew.put("cargoNo", list.get(0).get("cargoWay"));
|
|
|
|
+ mapNew.put("deliveryNo", deliveryNo);
|
|
|
|
+ mapNew.put("channel", "V01");
|
|
|
|
+ mapNew.put("returnUrl", returnUrl);
|
|
|
|
+ mapNew.put("orderNo", orderNo);
|
|
|
|
+ mapNew.put("MINView", "JSON");
|
|
|
|
+ JSONObject jsonOb = JSONObject.fromObject(mapNew);
|
|
|
|
+ String str = jsonOb.toString();
|
|
|
|
+ Log.info("通知售货机推货:".concat(str));
|
|
|
|
+ String passwardKey = Service.lookup(IPropertiesService.class)
|
|
|
|
+ .getSystemProperties().get("V01_TO_MACHINE_PASSWORD_KEY").getKey();
|
|
|
|
+ //数据加密
|
|
|
|
+ String desDe = Base64.encode(DesUtils.getInstance().encrypt(Base64.encode(str).getBytes(),passwardKey.getBytes(),null));
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ String results = HttpPostUtil.sendPostFormachine(sendUrl, desDe);
|
|
|
|
+ // //获取转义后响应信息
|
|
|
|
+ JSONObject detail = JSONObject.fromObject(results);
|
|
|
|
+ String code = String.valueOf(detail.get("code"));
|
|
|
|
+
|
|
|
|
+ if(!"0".equals(code)){
|
|
|
|
+ Log.info("售货机退货失败:".concat(code));
|
|
|
|
+ //改变提货状态为3卡货(提货失败)....
|
|
|
|
+ delInf.setStatus("3");
|
|
|
|
+ //处理提货状态
|
|
|
|
+ Service.lookup(IMINDataBaseService.class)
|
|
|
|
+ .getMybatisMapper(VmDeliveryInfMapper.class)
|
|
|
|
+ .updateByPrimaryKeySelective(delInf);
|
|
|
|
+ throw new BusinessCodeException("JINM0011");//操作失败!
|
|
|
|
+ }
|
|
|
|
+ //获取处理状态
|
|
|
|
+ String state = String.valueOf(detail.get("returnData"));
|
|
|
|
+ JSONObject stateNew = JSONObject.fromObject(state);
|
|
|
|
+ if(stateNew != null
|
|
|
|
+ && !"200".equals(String.valueOf(stateNew.get("code")))){
|
|
|
|
+ Log.info("售货机退货卡货:".concat(CommonUtil.objToString(stateNew.get("msg"))));
|
|
|
|
+ //改变提货状态为3卡货....
|
|
|
|
+ delInf.setStatus("3");
|
|
|
|
+ //处理提货状态
|
|
|
|
+ Service.lookup(IMINDataBaseService.class)
|
|
|
|
+ .getMybatisMapper(VmDeliveryInfMapper.class)
|
|
|
|
+ .updateByPrimaryKeySelective(delInf);
|
|
|
|
+ String msg = String.valueOf(stateNew.get("msg"));
|
|
|
|
+ throw new MINBusinessException(msg);//操作失败!
|
|
|
|
+ }else if("200".equals(String.valueOf(stateNew.get("code")))){
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return res;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|