|  | @ -736,7 +736,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
 | 
	
		
			
				|  |  |      * @param status
 | 
	
		
			
				|  |  |      * @return
 | 
	
		
			
				|  |  |      */
 | 
	
		
			
				|  |  | //    @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     @Transactional(rollbackFor = Exception.class)
 | 
	
		
			
				|  |  |     public JSONObject updateOrderOutStatus(String shipmentLogId, String status, String msg) {
 | 
	
		
			
				|  |  |         JSONObject result = new JSONObject();
 | 
	
		
			
				|  |  |         if (shipmentLogId == null || StringUtils.isEmpty(shipmentLogId)) {
 | 
	
	
		
			
				|  | @ -760,6 +760,33 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
 | 
	
		
			
				|  |  |         medicineShipmentLog.setStatus(status);
 | 
	
		
			
				|  |  |         if ("2".equals(status)) {
 | 
	
		
			
				|  |  |             medicineShipmentLog.setOutTime(new Date());
 | 
	
		
			
				|  |  |             //判断订单是否完成,
 | 
	
		
			
				|  |  |             String sql = "SELECT\n" +
 | 
	
		
			
				|  |  |                     "\tcount(DISTINCT(id))\n" +
 | 
	
		
			
				|  |  |                     "FROM\n" +
 | 
	
		
			
				|  |  |                     "\tt_medicine_shipment_log\n" +
 | 
	
		
			
				|  |  |                     "WHERE\n" +
 | 
	
		
			
				|  |  |                     "\torder_id = '" + medicineShipmentLog.getOrderId() + "'";
 | 
	
		
			
				|  |  |             int totalShipmentLog = jdbcTemplate.queryForObject(sql, Integer.class);
 | 
	
		
			
				|  |  |             sql = "SELECT\n" +
 | 
	
		
			
				|  |  |                     "\tcount(DISTINCT(id))\n" +
 | 
	
		
			
				|  |  |                     "FROM\n" +
 | 
	
		
			
				|  |  |                     "\tt_medicine_shipment_log\n" +
 | 
	
		
			
				|  |  |                     "WHERE\n" +
 | 
	
		
			
				|  |  |                     "\torder_id = '" + medicineShipmentLog.getOrderId() + "'\n" +
 | 
	
		
			
				|  |  |                     "AND `status` = 2";
 | 
	
		
			
				|  |  |             //已出货
 | 
	
		
			
				|  |  |             int shipped = jdbcTemplate.queryForObject(sql, Integer.class);
 | 
	
		
			
				|  |  |             if (Integer.compare(totalShipmentLog, shipped + 1) == 0) {
 | 
	
		
			
				|  |  |                 Mediicineorder order = orderDao.findOne(medicineShipmentLog.getOrderId());
 | 
	
		
			
				|  |  |                 order.setSellState("1");
 | 
	
		
			
				|  |  |                 orderDao.save(order);
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |             if (Integer.compare(totalShipmentLog, shipped + 1) < 0) {
 | 
	
		
			
				|  |  |                 result.put("msg", "订单已全部出货!");
 | 
	
		
			
				|  |  |                 result.put("response", ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |                 return result;
 | 
	
		
			
				|  |  |             }
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  |         if (!StringUtils.isEmpty(msg)) {
 | 
	
		
			
				|  |  |             medicineShipmentLog.setDescription(msg);
 | 
	
	
		
			
				|  | @ -806,23 +833,21 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         //查询更新订单信息start
 | 
	
		
			
				|  |  |         //订单id
 | 
	
		
			
				|  |  |         String orderId = medicineShipmentLog.getOrderId();
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  |         String sql = "SELECT\n" +
 | 
	
		
			
				|  |  |                 "\tcount(DISTINCT(id))\n" +
 | 
	
		
			
				|  |  |                 "FROM\n" +
 | 
	
		
			
				|  |  |                 "\tt_medicine_shipment_log\n" +
 | 
	
		
			
				|  |  |                 "WHERE\n" +
 | 
	
		
			
				|  |  |                 "\torder_id = '" + orderId + "'\n" +
 | 
	
		
			
				|  |  |                 "AND (`status` = 1\n" +
 | 
	
		
			
				|  |  |                 "OR `status` = 3)";
 | 
	
		
			
				|  |  |         int count = jdbcTemplate.queryForObject(sql, Integer.class);
 | 
	
		
			
				|  |  |         if (count == 0) {
 | 
	
		
			
				|  |  |             Mediicineorder order = orderDao.findOne(orderId);
 | 
	
		
			
				|  |  |             order.setSellState("1");
 | 
	
		
			
				|  |  |             orderDao.save(order);
 | 
	
		
			
				|  |  |         }
 | 
	
		
			
				|  |  | 
 | 
	
		
			
				|  |  | //        String orderId = medicineShipmentLog.getOrderId();
 | 
	
		
			
				|  |  | //        String sql = "SELECT\n" +
 | 
	
		
			
				|  |  | //                "\tcount(DISTINCT(id))\n" +
 | 
	
		
			
				|  |  | //                "FROM\n" +
 | 
	
		
			
				|  |  | //                "\tt_medicine_shipment_log\n" +
 | 
	
		
			
				|  |  | //                "WHERE\n" +
 | 
	
		
			
				|  |  | //                "\torder_id = '" + orderId + "'\n" +
 | 
	
		
			
				|  |  | //                "AND (`status` = 1\n" +
 | 
	
		
			
				|  |  | //                "OR `status` = 3)";
 | 
	
		
			
				|  |  | //        int count = jdbcTemplate.queryForObject(sql, Integer.class);
 | 
	
		
			
				|  |  | //        if (count == 0) {
 | 
	
		
			
				|  |  | //            Mediicineorder order = orderDao.findOne(orderId);
 | 
	
		
			
				|  |  | //            order.setSellState("1");
 | 
	
		
			
				|  |  | //            orderDao.save(order);
 | 
	
		
			
				|  |  | //        }
 | 
	
		
			
				|  |  |         //end
 | 
	
		
			
				|  |  |         result.put("msg", ConstantUtils.SUCCESS);
 | 
	
		
			
				|  |  |         result.put("response", ConstantUtils.SUCCESS);
 | 
	
	
		
			
				|  | @ -841,7 +866,7 @@ public class MedicineOrderService extends BaseJpaService<Mediicineorder, Mediici
 | 
	
		
			
				|  |  |         String tempSql = "select IFNULL((select count(distinct(id)) from t_medicine_shipment_log where order_id = '"+orderId+"'), 0)";
 | 
	
		
			
				|  |  |         int count = jdbcTemplate.queryForObject(tempSql, Integer.class);
 | 
	
		
			
				|  |  |         if (count == 0) {
 | 
	
		
			
				|  |  |             result.put("msg", "订单未生成出货单");
 | 
	
		
			
				|  |  |             result.put("msg", "订单未生成出货单(订单异常)");
 | 
	
		
			
				|  |  |             result.put("response", ConstantUtils.FAIL);
 | 
	
		
			
				|  |  |             return result;
 | 
	
		
			
				|  |  |         }
 |